@things-factory/aws-base 9.0.0-beta.76 → 9.0.0

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.
@@ -47,7 +47,10 @@ class AthenaController {
47
47
  }
48
48
  // refer to https://github.com/ghdna/athena-express#advance-config-parameters
49
49
  // about more detail configuration parameters
50
- let athenaExpressConfig = Object.assign({ aws: aws_sdk_1.default }, athenaConfig.options);
50
+ let athenaExpressConfig = {
51
+ aws: aws_sdk_1.default,
52
+ ...athenaConfig.options
53
+ };
51
54
  this.athenaExpressClient = new athena_express_1.AthenaExpress(athenaExpressConfig);
52
55
  }
53
56
  // query parameters: https://github.com/ghdna/athena-express#advance-query-parameters
@@ -67,7 +70,9 @@ class AthenaController {
67
70
  // check if sql key is available in the input parameter
68
71
  if (reqQuery.sql === undefined || reqQuery.sql === '')
69
72
  return {};
70
- let queryInput = Object.assign({}, reqQuery);
73
+ let queryInput = {
74
+ ...reqQuery
75
+ };
71
76
  // check if pagination would be available.
72
77
  if (reqQuery.pagination > 0 &&
73
78
  this.queryPaginationInfo.NextToken !== '' &&
@@ -78,8 +83,8 @@ class AthenaController {
78
83
  // run the query
79
84
  queryResult = await this.athenaExpressClient.query(queryInput);
80
85
  // keep pagination parameters if they are available in the result
81
- this.queryPaginationInfo.NextToken = (queryResult === null || queryResult === void 0 ? void 0 : queryResult.NextToken) || '';
82
- this.queryPaginationInfo.QueryExecutionId = (queryResult === null || queryResult === void 0 ? void 0 : queryResult.QueryExecutionId) || '';
86
+ this.queryPaginationInfo.NextToken = queryResult?.NextToken || '';
87
+ this.queryPaginationInfo.QueryExecutionId = queryResult?.QueryExecutionId || '';
83
88
  }
84
89
  catch (error) {
85
90
  env_1.logger.error(error);
@@ -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,MA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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"]}
1
+ {"version":3,"file":"athena-controller.js","sourceRoot":"","sources":["../../server/controllers/athena-controller.ts"],"names":[],"mappings":";;;;AAAA,mDAA8C;AAC9C,8DAA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QAAQ;aACZ,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,WAAW,EAAE,SAAS,IAAI,EAAE,CAAA;YACjE,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,GAAG,WAAW,EAAE,gBAAgB,IAAI,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"]}