diff --git a/README.md b/README.md index de7e9d0..94e618d 100644 --- a/README.md +++ b/README.md @@ -133,9 +133,9 @@ Below is a table containing all of the possible configuration options for the `d | resourceArn | `string` | The ARN of your Aurora Serverless Cluster. This value is *required*, but can be overridden when querying. | | | secretArn | `string` | The ARN of the secret associated with your database credentials. This is *required*, but can be overridden when querying. | | | database | `string` | *Optional* default database to use with queries. Can be overridden when querying. | | -| hydrateColumnNames | `boolean` | When `true`, results will be returned as objects with column names as keys. If `false`, results will be returned as an array of values. | `true` | -| keepAlive | `boolean` | Enables HTTP Keep-Alive for calls to the AWS SDK. This dramatically decreases the latency of subsequent calls. | `true` | -| sslEnabled | `boolean` | *Optional* Enables SSL HTTP endpoint. Can be disable for local development. | `true` | +| hydrateColumnNames | `boolean` | *Optional* When `true`, results will be returned as objects with column names as keys. If `false`, results will be returned as an array of values. | `true` | +| keepAlive | `boolean` | *Optional* Enables HTTP Keep-Alive for calls to the AWS SDK. This dramatically decreases the latency of subsequent calls. | `true` | +| sslEnabled | `boolean` | *Optional* Enables SSL HTTP endpoint. Can be disabled for local development. | `true` | | options | `object` | An *optional* configuration object that is passed directly into the RDSDataService constructor. See [here](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/RDSDataService.html#constructor-property) for available options. | `{}` | | region | `string` | *Optional* AWS region to use. | `aws-sdk default` | diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..c3c4719 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,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; + rollback: (error: Error, status: any) => void; + commit: () => Promise; + } + + interface iQuery { + (sql: string, params?: [] | unknown): Promise; // params can be [] or {} + (obj: { sql: string; parameters: [] | unknown; database?: string; hydrateColumnNames?: boolean }): Promise; + } + + export interface iDataAPIClient { + query: iQuery; + transaction(): iTransaction; // needs to return an interface with + + // promisified versions of the RDSDataService methods + // TODO add actual return types + batchExecuteStatement: (...args) => Promise; + beginTransaction: (...args) => Promise; + commitTransaction: (...args) => Promise; + executeStatement: (...args) => Promise; + rollbackTransaction: (...args) => Promise; + } + + export interface iDataAPIQueryResult { + records: Array; + } + + export default function (params: iParams): iDataAPIClient; +} diff --git a/package.json b/package.json index 4e086fa..8feeb6e 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.0.1", "description": "A lightweight wrapper that simplifies working with the Amazon Aurora Serverless Data API", "main": "index.js", + "types": "index.d.ts", "scripts": { "test": "jest", "test-ci": "eslint . && jest",