forked from jeremydaly/data-api-client
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
44 lines (37 loc) · 1.45 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
declare module 'data-api-client' {
import type { ClientConfiguration } from 'aws-sdk/clients/rdsdataservice';
export interface iParams {
secretArn: string;
resourceArn: string;
database?: string;
keepAlive?: boolean;
hydrateColumnNames?: boolean;
sslEnabled?: boolean;
options?: ClientConfiguration;
region?: string;
}
interface iTransaction {
query: iQuery<iTransaction>;
rollback: (error: Error, status: any) => void;
commit: () => Promise<void>;
}
interface iQuery<T> {
(sql: string, params?: [] | unknown): Promise<T>; // params can be [] or {}
(obj: { sql: string; parameters: [] | unknown; database?: string; hydrateColumnNames?: boolean }): Promise<T>;
}
export interface iDataAPIClient {
query: iQuery<iDataAPIQueryResult>;
transaction(): iTransaction; // needs to return an interface with
// promisified versions of the RDSDataService methods
// TODO add actual return types
batchExecuteStatement: (...args) => Promise<any>;
beginTransaction: (...args) => Promise<any>;
commitTransaction: (...args) => Promise<any>;
executeStatement: (...args) => Promise<any>;
rollbackTransaction: (...args) => Promise<any>;
}
export interface iDataAPIQueryResult {
records: Array<any>;
}
export default function (params: iParams): iDataAPIClient;
}