1
0
mirror of https://github.com/bigchaindb/js-bigchaindb-driver.git synced 2024-11-21 17:26:56 +01:00

feat: update connection typedefs

This commit is contained in:
getlarge 2022-02-15 14:12:27 +01:00
parent 46599f5446
commit fbc3d79d98
No known key found for this signature in database
GPG Key ID: E4E13243600F9566
2 changed files with 30 additions and 12 deletions

36
types/connection.d.ts vendored
View File

@ -19,6 +19,16 @@ export interface InputNode {
endpoint: string;
}
export type AssetResult = {
id: string;
data: Record<string, any>;
};
export type MetadataResult = {
id: string;
metadata: Record<string, any>;
};
export enum Endpoints {
blocks = 'blocks',
blocksDetail = 'blocksDetail',
@ -76,8 +86,8 @@ export interface EndpointsResponse<
[Endpoints.transactionsDetail]: O extends TransactionOperations.CREATE
? CreateTransaction<A, M>
: TransferTransaction<M>;
[Endpoints.assets]: { id: string; data: Record<string, any> }[];
[Endpoints.metadata]: { id: string; metadata: Record<string, any> }[];
[Endpoints.assets]: AssetResult[];
[Endpoints.metadata]: MetadataResult[];
}
export default class Connection {
@ -111,7 +121,9 @@ export default class Connection {
transactionId: string
): Promise<EndpointsResponse<O>[Endpoints.transactionsDetail]>;
listBlocks(transactionId: string): Promise<EndpointsResponse[Endpoints.blocks]>;
listBlocks(
transactionId: string
): Promise<EndpointsResponse[Endpoints.blocks]>;
listOutputs(
publicKey: string,
@ -124,7 +136,7 @@ export default class Connection {
): Promise<EndpointsResponse<typeof operation>[Endpoints.transactions]>;
postTransaction<
O = TransactionOperations.CREATE,
O extends TransactionOperations = TransactionOperations.CREATE,
A = Record<string, any>,
M = Record<string, any>
>(
@ -132,7 +144,7 @@ export default class Connection {
): Promise<EndpointsResponse<O, A, M>[Endpoints.transactionsCommit]>;
postTransactionSync<
O = TransactionOperations.CREATE,
O extends TransactionOperations = TransactionOperations.CREATE,
A = Record<string, any>,
M = Record<string, any>
>(
@ -140,7 +152,7 @@ export default class Connection {
): Promise<EndpointsResponse<O, A, M>[Endpoints.transactionsSync]>;
postTransactionAsync<
O = TransactionOperations.CREATE,
O extends TransactionOperations = TransactionOperations.CREATE,
A = Record<string, any>,
M = Record<string, any>
>(
@ -148,14 +160,20 @@ export default class Connection {
): Promise<EndpointsResponse<O, A, M>[Endpoints.transactionsAsync]>;
postTransactionCommit<
O = TransactionOperations.CREATE,
O extends TransactionOperations = TransactionOperations.CREATE,
A = Record<string, any>,
M = Record<string, any>
>(
transaction: TransactionCommon<O>
): 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
View File

@ -6,8 +6,8 @@ declare type FilterFn = (val: any, key?: string) => void;
declare function filterFromObject<I = Record<string, any>>(
obj: I,
filter: Array | FilterFn,
conf: { isInclusion?: boolean } = {}
filter: Array<any> | FilterFn,
conf: { isInclusion?: boolean }
): Partial<I>;
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>>(
obj: I,
filter: Array | FilterFn
filter: Array<any> | FilterFn
): Partial<I>;
export default function sanitize<I = Record<string, any>>(