forked from thomsonreuters/data-api-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
68 lines (60 loc) · 2.79 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Minimum TypeScript Version: 3.8
import type { RDSDataClientConfig, BatchExecuteStatementCommandInput, BeginTransactionCommandOutput, CommitTransactionCommandInput, ExecuteStatementCommandInput, RollbackTransactionCommandInput } from "@aws-sdk/client-rds-data";
declare namespace Client {
type OmittedValues = "database" | "resourceArn" | "secretArn" | "schema";
interface iParams {
secretArn: string;
resourceArn: string;
database?: string | undefined;
keepAlive?: boolean | undefined;
hydrateColumnNames?: boolean | undefined;
sslEnabled?: boolean | undefined;
options?: RDSDataClientConfig | undefined;
region?: string | undefined;
engine?: "mysql" | "pg" | undefined;
formatOptions?:
| {
deserializeDate?: boolean | undefined;
treatAsLocalDate?: boolean | undefined;
}
| undefined;
}
interface Transaction {
query(sql: string, params?: [] | unknown): Transaction; // params can be [] or {};
query(
obj:
| {
sql: string;
parameters: [] | unknown;
database?: string | undefined;
hydrateColumnNames?: boolean | undefined;
}
| ((prevResult: { insertId?: any }) => any),
): Transaction;
rollback(cb: (error: Error, status: any) => void): Transaction;
commit: () => Promise<void>;
}
interface iDataAPIClient {
/* eslint-disable @definitelytyped/no-unnecessary-generics */
query<T = any>(sql: string, params?: [] | unknown): Promise<iDataAPIQueryResult<T>>; // params can be [] or {};
query<T = any>(obj: {
sql: string;
parameters?: [] | unknown | undefined;
transactionId?: string | undefined;
database?: string | undefined;
hydrateColumnNames?: boolean | undefined;
}): Promise<iDataAPIQueryResult<T>>;
transaction(): Transaction; // needs to return an interface with
// promisified versions of the RDSDataService methods
batchExecuteStatement: (params: Omit<BatchExecuteStatementCommandInput, OmittedValues>) => Promise<any>;
beginTransaction: () => Promise<BeginTransactionCommandOutput>;
commitTransaction: (params: Omit<CommitTransactionCommandInput, OmittedValues>) => Promise<any>;
executeStatement: (params: Omit<ExecuteStatementCommandInput, OmittedValues>) => Promise<any>;
rollbackTransaction: (params: Omit<RollbackTransactionCommandInput, OmittedValues>) => Promise<any>;
}
interface iDataAPIQueryResult<T = any> {
records: T[];
}
}
declare function Client(params: Client.iParams): Client.iDataAPIClient;
export = Client;