@things-factory/aws-base 7.0.1-beta.0 → 7.0.1-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ export declare class AthenaController {
2
+ private athenaExpressClient;
3
+ private queryPaginationInfo;
4
+ constructor();
5
+ query(reqQuery: any): Promise<any>;
6
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"athena-controller.js","sourceRoot":"","sources":["../../server/controllers/athena-controller.ts"],"names":[],"mappings":";;;;AAAA,mDAA8C;AAC9C,8DAAyB;AAEzB,6CAAoD;AAEpD,MAAM,YAAY,GAAG,YAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,cAAc,GAAG;IACrB,MAAM,EAAE,YAAY,CAAC,MAAM;IAC3B,WAAW,EAAE,YAAY,CAAC,WAAW;IACrC,eAAe,EAAE,YAAY,CAAC,eAAe;CAC9C,CAAA;AAED,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;IACxB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;CAeb,CAAC,CAAA;CACD;AAED,MAAa,gBAAgB;IAO3B;QALQ,wBAAmB,GAAG;YAC5B,SAAS,EAAE,EAAE;YACb,gBAAgB,EAAE,EAAE;SACrB,CAAA;QAGC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;YACxB,OAAM;SACP;QAED,IAAI;YACF,iBAAG,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;SAClC;QAAC,OAAO,GAAG,EAAE;YACZ,iBAAiB;YACjB,YAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;SAClB;QAED,6EAA6E;QAC7E,6CAA6C;QAC7C,IAAI,mBAAmB,mBACrB,GAAG,EAAE,iBAAG,IACL,YAAY,CAAC,OAAO,CACxB,CAAA;QAED,IAAI,CAAC,mBAAmB,GAAG,IAAI,8BAAa,CAAC,mBAAmB,CAAC,CAAA;IACnE,CAAC;IAED,qFAAqF;IACrF;;;;;;;;YAQQ;IAER,iEAAiE;IACjE,KAAK,CAAC,KAAK,CAAC,QAAQ;QAClB,IAAI,WAAW,CAAA;QACf,IAAI;YACF,uDAAuD;YACvD,IAAI,QAAQ,CAAC,GAAG,KAAK,SAAS,IAAI,QAAQ,CAAC,GAAG,KAAK,EAAE;gBAAE,OAAO,EAAE,CAAA;YAEhE,IAAI,UAAU,qBACT,QAAQ,CACZ,CAAA;YAED,0CAA0C;YAC1C,IACE,QAAQ,CAAC,UAAU,GAAG,CAAC;gBACvB,IAAI,CAAC,mBAAmB,CAAC,SAAS,KAAK,EAAE;gBACzC,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,KAAK,EAAE,EAChD;gBACA,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAA;gBACzD,UAAU,CAAC,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAA;aACxE;YAED,gBAAgB;YAChB,WAAW,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;YAE9D,iEAAiE;YACjE,IAAI,CAAC,mBAAmB,CAAC,SAAS,GAAG,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,SAAS,KAAI,EAAE,CAAA;YACjE,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,GAAG,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,gBAAgB,KAAI,EAAE,CAAA;SAChF;QAAC,OAAO,KAAK,EAAE;YACd,YAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;SACpB;QAED,OAAO,WAAW,CAAA;IACpB,CAAC;CACF;AAzED,4CAyEC","sourcesContent":["import { AthenaExpress } from 'athena-express'\nimport AWS from 'aws-sdk'\n\nimport { config, logger } from '@things-factory/env'\n\nconst athenaConfig = config.get('athena', {})\nconst awsCredentials = {\n region: athenaConfig.region,\n accessKeyId: athenaConfig.accessKeyId,\n secretAccessKey: athenaConfig.secretAccessKey\n}\n\nif (!athenaConfig.region) {\n console.log(`\\\napplication config for 'athena' required like following\n/*\nathena: {\naccessKeyId: 'YOUR ACCESS KEY ID',\nsecretAccessKey: 'YOUR SECRET ACCESS KEY',\nregion: 'YOUR S3 REGION'\noptions: { athenaExpressConfig\n retry: 200,\n getStats: true,\n formatJson: true\n}\n}\n*/\nplease, refer to https://github.com/ghdna/athena-express#advance-config-parameters for about more detail configuration parameters\n`)\n}\n\nexport class AthenaController {\n private athenaExpressClient\n private queryPaginationInfo = {\n NextToken: '',\n QueryExecutionId: ''\n }\n\n constructor() {\n if (!athenaConfig.region) {\n return\n }\n\n try {\n AWS.config.update(awsCredentials)\n } catch (err) {\n // missing config\n logger.error(err)\n }\n\n // refer to https://github.com/ghdna/athena-express#advance-config-parameters\n // about more detail configuration parameters\n let athenaExpressConfig = {\n aws: AWS,\n ...athenaConfig.options\n }\n\n this.athenaExpressClient = new AthenaExpress(athenaExpressConfig)\n }\n\n // query parameters: https://github.com/ghdna/athena-express#advance-query-parameters\n /* SAMPLE QUERY PARAMTERS\n {\n sql: \"SELECT * FROM elb_logs LIMIT 3\" // required,\n db: \"sampledb\", // optional.\n pagination: 5, //optional\n NextToken: \"ARfCDXRjMk...\", //optional\n QueryExecutionId: \"c274843b-4c5c-4ccf-ac8b-e33d595b927d\", //optional\n catalog: \"hive\" //optional\n }; */\n\n // pagination: https://github.com/ghdna/athena-express#pagination\n async query(reqQuery) {\n var queryResult\n try {\n // check if sql key is available in the input parameter\n if (reqQuery.sql === undefined || reqQuery.sql === '') return {}\n\n let queryInput = {\n ...reqQuery\n }\n\n // check if pagination would be available.\n if (\n reqQuery.pagination > 0 &&\n this.queryPaginationInfo.NextToken !== '' &&\n this.queryPaginationInfo.QueryExecutionId !== ''\n ) {\n queryInput.NextToken = this.queryPaginationInfo.NextToken\n queryInput.QueryExecutionId = this.queryPaginationInfo.QueryExecutionId\n }\n\n // run the query\n queryResult = await this.athenaExpressClient.query(queryInput)\n\n // keep pagination parameters if they are available in the result\n this.queryPaginationInfo.NextToken = queryResult?.NextToken || ''\n this.queryPaginationInfo.QueryExecutionId = queryResult?.QueryExecutionId || ''\n } catch (error) {\n logger.error(error)\n }\n\n return queryResult\n }\n}\n"]}
1
+ {"version":3,"file":"athena-controller.js","sourceRoot":"","sources":["../../server/controllers/athena-controller.ts"],"names":[],"mappings":";;;;AAAA,mDAA8C;AAC9C,8DAAyB;AAEzB,6CAAoD;AAEpD,MAAM,YAAY,GAAG,YAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,cAAc,GAAG;IACrB,MAAM,EAAE,YAAY,CAAC,MAAM;IAC3B,WAAW,EAAE,YAAY,CAAC,WAAW;IACrC,eAAe,EAAE,YAAY,CAAC,eAAe;CAC9C,CAAA;AAED,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;IACzB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;CAeb,CAAC,CAAA;AACF,CAAC;AAED,MAAa,gBAAgB;IAO3B;QALQ,wBAAmB,GAAG;YAC5B,SAAS,EAAE,EAAE;YACb,gBAAgB,EAAE,EAAE;SACrB,CAAA;QAGC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;YACzB,OAAM;QACR,CAAC;QAED,IAAI,CAAC;YACH,iBAAG,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;QACnC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,iBAAiB;YACjB,YAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACnB,CAAC;QAED,6EAA6E;QAC7E,6CAA6C;QAC7C,IAAI,mBAAmB,mBACrB,GAAG,EAAE,iBAAG,IACL,YAAY,CAAC,OAAO,CACxB,CAAA;QAED,IAAI,CAAC,mBAAmB,GAAG,IAAI,8BAAa,CAAC,mBAAmB,CAAC,CAAA;IACnE,CAAC;IAED,qFAAqF;IACrF;;;;;;;;YAQQ;IAER,iEAAiE;IACjE,KAAK,CAAC,KAAK,CAAC,QAAQ;QAClB,IAAI,WAAW,CAAA;QACf,IAAI,CAAC;YACH,uDAAuD;YACvD,IAAI,QAAQ,CAAC,GAAG,KAAK,SAAS,IAAI,QAAQ,CAAC,GAAG,KAAK,EAAE;gBAAE,OAAO,EAAE,CAAA;YAEhE,IAAI,UAAU,qBACT,QAAQ,CACZ,CAAA;YAED,0CAA0C;YAC1C,IACE,QAAQ,CAAC,UAAU,GAAG,CAAC;gBACvB,IAAI,CAAC,mBAAmB,CAAC,SAAS,KAAK,EAAE;gBACzC,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,KAAK,EAAE,EAChD,CAAC;gBACD,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAA;gBACzD,UAAU,CAAC,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAA;YACzE,CAAC;YAED,gBAAgB;YAChB,WAAW,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;YAE9D,iEAAiE;YACjE,IAAI,CAAC,mBAAmB,CAAC,SAAS,GAAG,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,SAAS,KAAI,EAAE,CAAA;YACjE,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,GAAG,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,gBAAgB,KAAI,EAAE,CAAA;QACjF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,YAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACrB,CAAC;QAED,OAAO,WAAW,CAAA;IACpB,CAAC;CACF;AAzED,4CAyEC","sourcesContent":["import { AthenaExpress } from 'athena-express'\nimport AWS from 'aws-sdk'\n\nimport { config, logger } from '@things-factory/env'\n\nconst athenaConfig = config.get('athena', {})\nconst awsCredentials = {\n region: athenaConfig.region,\n accessKeyId: athenaConfig.accessKeyId,\n secretAccessKey: athenaConfig.secretAccessKey\n}\n\nif (!athenaConfig.region) {\n console.log(`\\\napplication config for 'athena' required like following\n/*\nathena: {\naccessKeyId: 'YOUR ACCESS KEY ID',\nsecretAccessKey: 'YOUR SECRET ACCESS KEY',\nregion: 'YOUR S3 REGION'\noptions: { athenaExpressConfig\n retry: 200,\n getStats: true,\n formatJson: true\n}\n}\n*/\nplease, refer to https://github.com/ghdna/athena-express#advance-config-parameters for about more detail configuration parameters\n`)\n}\n\nexport class AthenaController {\n private athenaExpressClient\n private queryPaginationInfo = {\n NextToken: '',\n QueryExecutionId: ''\n }\n\n constructor() {\n if (!athenaConfig.region) {\n return\n }\n\n try {\n AWS.config.update(awsCredentials)\n } catch (err) {\n // missing config\n logger.error(err)\n }\n\n // refer to https://github.com/ghdna/athena-express#advance-config-parameters\n // about more detail configuration parameters\n let athenaExpressConfig = {\n aws: AWS,\n ...athenaConfig.options\n }\n\n this.athenaExpressClient = new AthenaExpress(athenaExpressConfig)\n }\n\n // query parameters: https://github.com/ghdna/athena-express#advance-query-parameters\n /* SAMPLE QUERY PARAMTERS\n {\n sql: \"SELECT * FROM elb_logs LIMIT 3\" // required,\n db: \"sampledb\", // optional.\n pagination: 5, //optional\n NextToken: \"ARfCDXRjMk...\", //optional\n QueryExecutionId: \"c274843b-4c5c-4ccf-ac8b-e33d595b927d\", //optional\n catalog: \"hive\" //optional\n }; */\n\n // pagination: https://github.com/ghdna/athena-express#pagination\n async query(reqQuery) {\n var queryResult\n try {\n // check if sql key is available in the input parameter\n if (reqQuery.sql === undefined || reqQuery.sql === '') return {}\n\n let queryInput = {\n ...reqQuery\n }\n\n // check if pagination would be available.\n if (\n reqQuery.pagination > 0 &&\n this.queryPaginationInfo.NextToken !== '' &&\n this.queryPaginationInfo.QueryExecutionId !== ''\n ) {\n queryInput.NextToken = this.queryPaginationInfo.NextToken\n queryInput.QueryExecutionId = this.queryPaginationInfo.QueryExecutionId\n }\n\n // run the query\n queryResult = await this.athenaExpressClient.query(queryInput)\n\n // keep pagination parameters if they are available in the result\n this.queryPaginationInfo.NextToken = queryResult?.NextToken || ''\n this.queryPaginationInfo.QueryExecutionId = queryResult?.QueryExecutionId || ''\n } catch (error) {\n logger.error(error)\n }\n\n return queryResult\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export * from './athena-controller';
@@ -0,0 +1,6 @@
1
+ export * from './controllers';
2
+ export * from './migrations';
3
+ export * from './middlewares';
4
+ export * from './service';
5
+ export * from './controllers/athena-controller';
6
+ import './routes';
@@ -0,0 +1 @@
1
+ export declare function initMiddlewares(app: any): void;
@@ -0,0 +1 @@
1
+ export declare var migrations: any[];
File without changes
@@ -0,0 +1,4 @@
1
+ import '@things-factory/auth-base';
2
+ export declare class AthenaQuery {
3
+ queryFromAthena(_: any, queryData: any, context: ResolverContext): Promise<any>;
4
+ }
@@ -14,6 +14,7 @@ class AthenaQuery {
14
14
  return queryResult;
15
15
  }
16
16
  }
17
+ exports.AthenaQuery = AthenaQuery;
17
18
  tslib_1.__decorate([
18
19
  (0, type_graphql_1.Query)(returns => shell_1.ScalarAny, { description: 'To query data in S3 using Amazon Athena SDK' }),
19
20
  tslib_1.__param(0, (0, type_graphql_1.Root)()),
@@ -23,5 +24,4 @@ tslib_1.__decorate([
23
24
  tslib_1.__metadata("design:paramtypes", [Object, Object, Object]),
24
25
  tslib_1.__metadata("design:returntype", Promise)
25
26
  ], AthenaQuery.prototype, "queryFromAthena", null);
26
- exports.AthenaQuery = AthenaQuery;
27
27
  //# sourceMappingURL=athena-query.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"athena-query.js","sourceRoot":"","sources":["../../../server/service/athena/athena-query.ts"],"names":[],"mappings":";;;;AAAA,qCAAkC,CAAC,sBAAsB;AAEzD,+CAAoD;AAEpD,iDAA+D;AAE/D,mDAAoD;AAEpD,MAAM,YAAY,GAAG,IAAI,8BAAgB,EAAE,CAAA;AAE3C,MAAa,WAAW;IAEhB,AAAN,KAAK,CAAC,eAAe,CACX,CAAC,EAC+B,SAAc,EAC/C,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEtC,IAAI,WAAW,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QAErD,OAAO,WAAW,CAAA;IACpB,CAAC;CACF;AAXO;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,iBAAS,EAAE,EAAE,WAAW,EAAE,6CAA6C,EAAE,CAAC;IAEzF,mBAAA,IAAA,mBAAI,GAAE,CAAA;IACN,mBAAA,IAAA,kBAAG,EAAC,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC,oBAAY,CAAC,CAAA;IACtC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;kDAOP;AAZH,kCAaC","sourcesContent":["import '@things-factory/auth-base' // for ResolverContext\n\nimport { Arg, Ctx, Query, Root } from 'type-graphql'\n\nimport { ScalarAny, ScalarObject } from '@things-factory/shell'\n\nimport { AthenaController } from '../../controllers'\n\nconst athenaClient = new AthenaController()\n\nexport class AthenaQuery {\n @Query(returns => ScalarAny, { description: 'To query data in S3 using Amazon Athena SDK' })\n async queryFromAthena(\n @Root() _,\n @Arg('queryData', type => ScalarObject) queryData: any,\n @Ctx() context: ResolverContext\n ): Promise<any> {\n const { domain, user } = context.state\n\n var queryResult = await athenaClient.query(queryData)\n\n return queryResult\n }\n}\n"]}
1
+ {"version":3,"file":"athena-query.js","sourceRoot":"","sources":["../../../server/service/athena/athena-query.ts"],"names":[],"mappings":";;;;AAAA,qCAAkC,CAAC,sBAAsB;AAEzD,+CAAoD;AAEpD,iDAA+D;AAE/D,mDAAoD;AAEpD,MAAM,YAAY,GAAG,IAAI,8BAAgB,EAAE,CAAA;AAE3C,MAAa,WAAW;IAEhB,AAAN,KAAK,CAAC,eAAe,CACX,CAAC,EAC+B,SAAc,EAC/C,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEtC,IAAI,WAAW,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QAErD,OAAO,WAAW,CAAA;IACpB,CAAC;CACF;AAbD,kCAaC;AAXO;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,iBAAS,EAAE,EAAE,WAAW,EAAE,6CAA6C,EAAE,CAAC;IAEzF,mBAAA,IAAA,mBAAI,GAAE,CAAA;IACN,mBAAA,IAAA,kBAAG,EAAC,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC,oBAAY,CAAC,CAAA;IACtC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;kDAOP","sourcesContent":["import '@things-factory/auth-base' // for ResolverContext\n\nimport { Arg, Ctx, Query, Root } from 'type-graphql'\n\nimport { ScalarAny, ScalarObject } from '@things-factory/shell'\n\nimport { AthenaController } from '../../controllers'\n\nconst athenaClient = new AthenaController()\n\nexport class AthenaQuery {\n @Query(returns => ScalarAny, { description: 'To query data in S3 using Amazon Athena SDK' })\n async queryFromAthena(\n @Root() _,\n @Arg('queryData', type => ScalarObject) queryData: any,\n @Ctx() context: ResolverContext\n ): Promise<any> {\n const { domain, user } = context.state\n\n var queryResult = await athenaClient.query(queryData)\n\n return queryResult\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { AthenaQuery } from './athena-query';
2
+ export declare const entities: any[];
3
+ export declare const resolvers: (typeof AthenaQuery)[];
@@ -0,0 +1,4 @@
1
+ export declare const entities: any[];
2
+ export declare const schema: {
3
+ resolverClasses: typeof import("./athena/athena-query").AthenaQuery[];
4
+ };