Skip to content

Commit

Permalink
Merge pull request #15 from allen-munsch/typescript-typing
Browse files Browse the repository at this point in the history
Adds an initial typescript typing
  • Loading branch information
ghdna committed Jun 27, 2020
2 parents d6ea9f4 + 8c0860c commit ff8eca4
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
49 changes: 49 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
declare module 'athena-express' {
import * as aws from 'aws-sdk';
interface ConnectionConfigInterface {
aws: typeof aws;
s3: string;
getStats: boolean;
db: string,
workgroup: string,
formatJson: boolean,
retry: number,
ignoreEmpty: boolean,
encryption: Record<string, string>,
skipResults: boolean,
waitForResults: boolean
}

interface QueryResultsInterface<T> {
Items: T[];
DataScannedInMB: number;
QueryCostInUSD: number;
EngineExecutionTimeInMillis: number;
S3Location: string;
QueryExecutionId: string;
Count: number;
DataScannedInBytes: number;
TotalExecutionTimeInMillis: number;
QueryQueueTimeInMillis: number;
QueryPlanningTimeInMillis: number;
ServiceProcessingTimeInMillis: number;
}

interface QueryObjectInterface {
sql: string;
db: string;
}
type DirectQueryString = string;
type QueryExecutionId = string;

type OptionalQueryResultsInterface<T> = Partial<QueryResultsInterface<T>> & Pick<QueryResultsInterface<T>, 'QueryExecutionId'>;
type QueryResult<T> = OptionalQueryResultsInterface<T>;
type QueryFunc<T> = (query: QueryObjectInterface|DirectQueryString|QueryExecutionId) => Promise<QueryResult<T>>;

class AthenaExpress {
public new: (config: Partial<ConnectionConfigInterface>) => any;
public query: QueryFunc;
constructor(config: Partial<ConnectionConfigInterface>);
query: QueryFunc;
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "6.0.2",
"description": "Athena-Express makes it easier to execute SQL queries on Amazon Athena by consolidating & astracting several methods in the AWS SDK",
"main": "./lib/index.js",
"types": "./index.d.ts",
"scripts": {
"test": "node ./node_modules/mocha/bin/mocha",
"coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
Expand Down

0 comments on commit ff8eca4

Please sign in to comment.