mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-11-22 01:36:56 +01:00
feat: update connection typedefs
This commit is contained in:
parent
46599f5446
commit
fbc3d79d98
36
types/connection.d.ts
vendored
36
types/connection.d.ts
vendored
@ -19,6 +19,16 @@ export interface InputNode {
|
|||||||
endpoint: string;
|
endpoint: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type AssetResult = {
|
||||||
|
id: string;
|
||||||
|
data: Record<string, any>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type MetadataResult = {
|
||||||
|
id: string;
|
||||||
|
metadata: Record<string, any>;
|
||||||
|
};
|
||||||
|
|
||||||
export enum Endpoints {
|
export enum Endpoints {
|
||||||
blocks = 'blocks',
|
blocks = 'blocks',
|
||||||
blocksDetail = 'blocksDetail',
|
blocksDetail = 'blocksDetail',
|
||||||
@ -76,8 +86,8 @@ export interface EndpointsResponse<
|
|||||||
[Endpoints.transactionsDetail]: O extends TransactionOperations.CREATE
|
[Endpoints.transactionsDetail]: O extends TransactionOperations.CREATE
|
||||||
? CreateTransaction<A, M>
|
? CreateTransaction<A, M>
|
||||||
: TransferTransaction<M>;
|
: TransferTransaction<M>;
|
||||||
[Endpoints.assets]: { id: string; data: Record<string, any> }[];
|
[Endpoints.assets]: AssetResult[];
|
||||||
[Endpoints.metadata]: { id: string; metadata: Record<string, any> }[];
|
[Endpoints.metadata]: MetadataResult[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Connection {
|
export default class Connection {
|
||||||
@ -111,7 +121,9 @@ export default class Connection {
|
|||||||
transactionId: string
|
transactionId: string
|
||||||
): Promise<EndpointsResponse<O>[Endpoints.transactionsDetail]>;
|
): Promise<EndpointsResponse<O>[Endpoints.transactionsDetail]>;
|
||||||
|
|
||||||
listBlocks(transactionId: string): Promise<EndpointsResponse[Endpoints.blocks]>;
|
listBlocks(
|
||||||
|
transactionId: string
|
||||||
|
): Promise<EndpointsResponse[Endpoints.blocks]>;
|
||||||
|
|
||||||
listOutputs(
|
listOutputs(
|
||||||
publicKey: string,
|
publicKey: string,
|
||||||
@ -124,7 +136,7 @@ export default class Connection {
|
|||||||
): Promise<EndpointsResponse<typeof operation>[Endpoints.transactions]>;
|
): Promise<EndpointsResponse<typeof operation>[Endpoints.transactions]>;
|
||||||
|
|
||||||
postTransaction<
|
postTransaction<
|
||||||
O = TransactionOperations.CREATE,
|
O extends TransactionOperations = TransactionOperations.CREATE,
|
||||||
A = Record<string, any>,
|
A = Record<string, any>,
|
||||||
M = Record<string, any>
|
M = Record<string, any>
|
||||||
>(
|
>(
|
||||||
@ -132,7 +144,7 @@ export default class Connection {
|
|||||||
): Promise<EndpointsResponse<O, A, M>[Endpoints.transactionsCommit]>;
|
): Promise<EndpointsResponse<O, A, M>[Endpoints.transactionsCommit]>;
|
||||||
|
|
||||||
postTransactionSync<
|
postTransactionSync<
|
||||||
O = TransactionOperations.CREATE,
|
O extends TransactionOperations = TransactionOperations.CREATE,
|
||||||
A = Record<string, any>,
|
A = Record<string, any>,
|
||||||
M = Record<string, any>
|
M = Record<string, any>
|
||||||
>(
|
>(
|
||||||
@ -140,7 +152,7 @@ export default class Connection {
|
|||||||
): Promise<EndpointsResponse<O, A, M>[Endpoints.transactionsSync]>;
|
): Promise<EndpointsResponse<O, A, M>[Endpoints.transactionsSync]>;
|
||||||
|
|
||||||
postTransactionAsync<
|
postTransactionAsync<
|
||||||
O = TransactionOperations.CREATE,
|
O extends TransactionOperations = TransactionOperations.CREATE,
|
||||||
A = Record<string, any>,
|
A = Record<string, any>,
|
||||||
M = Record<string, any>
|
M = Record<string, any>
|
||||||
>(
|
>(
|
||||||
@ -148,14 +160,20 @@ export default class Connection {
|
|||||||
): Promise<EndpointsResponse<O, A, M>[Endpoints.transactionsAsync]>;
|
): Promise<EndpointsResponse<O, A, M>[Endpoints.transactionsAsync]>;
|
||||||
|
|
||||||
postTransactionCommit<
|
postTransactionCommit<
|
||||||
O = TransactionOperations.CREATE,
|
O extends TransactionOperations = TransactionOperations.CREATE,
|
||||||
A = Record<string, any>,
|
A = Record<string, any>,
|
||||||
M = Record<string, any>
|
M = Record<string, any>
|
||||||
>(
|
>(
|
||||||
transaction: TransactionCommon<O>
|
transaction: TransactionCommon<O>
|
||||||
): Promise<EndpointsResponse<O, A, M>[Endpoints.transactionsCommit]>;
|
): Promise<EndpointsResponse<O, A, M>[Endpoints.transactionsCommit]>;
|
||||||
|
|
||||||
searchAssets(search: string): Promise<EndpointsResponse[Endpoints.assets]>;
|
searchAssets(
|
||||||
|
search: string,
|
||||||
|
limit?: number
|
||||||
|
): Promise<EndpointsResponse[Endpoints.assets]>;
|
||||||
|
|
||||||
searchMetadata(search: string): Promise<EndpointsResponse[Endpoints.metadata]>;
|
searchMetadata(
|
||||||
|
search: string,
|
||||||
|
limit?: number
|
||||||
|
): Promise<EndpointsResponse[Endpoints.metadata]>;
|
||||||
}
|
}
|
||||||
|
6
types/sanitize.d.ts
vendored
6
types/sanitize.d.ts
vendored
@ -6,8 +6,8 @@ declare type FilterFn = (val: any, key?: string) => void;
|
|||||||
|
|
||||||
declare function filterFromObject<I = Record<string, any>>(
|
declare function filterFromObject<I = Record<string, any>>(
|
||||||
obj: I,
|
obj: I,
|
||||||
filter: Array | FilterFn,
|
filter: Array<any> | FilterFn,
|
||||||
conf: { isInclusion?: boolean } = {}
|
conf: { isInclusion?: boolean }
|
||||||
): Partial<I>;
|
): Partial<I>;
|
||||||
|
|
||||||
declare function applyFilterOnObject<I = Record<string, any>>(
|
declare function applyFilterOnObject<I = Record<string, any>>(
|
||||||
@ -17,7 +17,7 @@ declare function applyFilterOnObject<I = Record<string, any>>(
|
|||||||
|
|
||||||
declare function selectFromObject<I = Record<string, any>>(
|
declare function selectFromObject<I = Record<string, any>>(
|
||||||
obj: I,
|
obj: I,
|
||||||
filter: Array | FilterFn
|
filter: Array<any> | FilterFn
|
||||||
): Partial<I>;
|
): Partial<I>;
|
||||||
|
|
||||||
export default function sanitize<I = Record<string, any>>(
|
export default function sanitize<I = Record<string, any>>(
|
||||||
|
Loading…
Reference in New Issue
Block a user