quidproquo-actionprocessor-awslambda 0.0.21 → 0.0.24

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
+ import { ConfigGetParameterActionProcessor } from 'quidproquo-core';
2
+ import { QPQAWSLambdaConfig } from '../../../runtimeConfig/QPQAWSLambdaConfig';
3
+ declare const _default: (runtimeConfig: QPQAWSLambdaConfig) => {
4
+ "@quidproquo-core/Config/GetParameter": ConfigGetParameterActionProcessor;
5
+ };
6
+ export default _default;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const quidproquo_core_1 = require("quidproquo-core");
13
+ const qpqAwsLambdaRuntimeConfigUtils_1 = require("../../../runtimeConfig/qpqAwsLambdaRuntimeConfigUtils");
14
+ const getParameter_1 = require("../../../logic/parametersManager/getParameter");
15
+ const getProcessConfigGetParameter = (runtimeConfig) => {
16
+ return ({ parameterName }) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const awsParameterKey = (0, qpqAwsLambdaRuntimeConfigUtils_1.resolveParameterKey)(parameterName, runtimeConfig);
18
+ const parameterValue = yield (0, getParameter_1.getParameter)(awsParameterKey);
19
+ return (0, quidproquo_core_1.actionResult)(parameterValue);
20
+ });
21
+ };
22
+ exports.default = (runtimeConfig) => {
23
+ return {
24
+ [quidproquo_core_1.ConfigActionType.GetParameter]: getProcessConfigGetParameter(runtimeConfig),
25
+ };
26
+ };
@@ -0,0 +1,6 @@
1
+ import { ConfigGetParametersActionProcessor } from 'quidproquo-core';
2
+ import { QPQAWSLambdaConfig } from '../../../runtimeConfig/QPQAWSLambdaConfig';
3
+ declare const _default: (runtimeConfig: QPQAWSLambdaConfig) => {
4
+ "@quidproquo-core/Config/GetParameters": ConfigGetParametersActionProcessor;
5
+ };
6
+ export default _default;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const quidproquo_core_1 = require("quidproquo-core");
13
+ const qpqAwsLambdaRuntimeConfigUtils_1 = require("../../../runtimeConfig/qpqAwsLambdaRuntimeConfigUtils");
14
+ const getParameters_1 = require("../../../logic/parametersManager/getParameters");
15
+ const getProcessConfigGetParameters = (runtimeConfig) => {
16
+ return ({ parameterNames }) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const awsParameterKeys = parameterNames.map((pn) => (0, qpqAwsLambdaRuntimeConfigUtils_1.resolveParameterKey)(pn, runtimeConfig));
18
+ const parameterValues = yield (0, getParameters_1.getParameters)(awsParameterKeys);
19
+ return (0, quidproquo_core_1.actionResult)(parameterValues);
20
+ });
21
+ };
22
+ exports.default = (runtimeConfig) => {
23
+ return {
24
+ [quidproquo_core_1.ConfigActionType.GetParameters]: getProcessConfigGetParameters(runtimeConfig),
25
+ };
26
+ };
@@ -1,5 +1,7 @@
1
1
  import { QPQAWSLambdaConfig } from '../../../runtimeConfig/QPQAWSLambdaConfig';
2
2
  declare const _default: (runtimeConfig: QPQAWSLambdaConfig) => {
3
3
  "@quidproquo-core/Config/GetSecret": import("quidproquo-core/lib").ConfigGetSecretActionProcessor;
4
+ "@quidproquo-core/Config/GetParameters": import("quidproquo-core/lib").ConfigGetParametersActionProcessor;
5
+ "@quidproquo-core/Config/GetParameter": import("quidproquo-core/lib").ConfigGetParameterActionProcessor;
4
6
  };
5
7
  export default _default;
@@ -3,5 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const getConfigGetParameterActionProcessor_1 = __importDefault(require("./getConfigGetParameterActionProcessor"));
7
+ const getConfigGetParametersActionProcessor_1 = __importDefault(require("./getConfigGetParametersActionProcessor"));
6
8
  const getConfigGetSecretActionProcessor_1 = __importDefault(require("./getConfigGetSecretActionProcessor"));
7
- exports.default = (runtimeConfig) => (Object.assign({}, (0, getConfigGetSecretActionProcessor_1.default)(runtimeConfig)));
9
+ exports.default = (runtimeConfig) => (Object.assign(Object.assign(Object.assign({}, (0, getConfigGetParameterActionProcessor_1.default)(runtimeConfig)), (0, getConfigGetParametersActionProcessor_1.default)(runtimeConfig)), (0, getConfigGetSecretActionProcessor_1.default)(runtimeConfig)));
@@ -1,4 +1,6 @@
1
1
  export { default as getConfigGetSecretActionProcessor } from './config/getConfigGetSecretActionProcessor';
2
+ export { default as getConfigGetParameterActionProcessor } from './config/getConfigGetParameterActionProcessor';
3
+ export { default as getConfigGetParametersActionProcessor } from './config/getConfigGetParametersActionProcessor';
2
4
  export { default as getAPIGatewayEventActionProcessor } from './event/getAPIGatewayEventActionProcessor';
3
5
  export { default as getEventBridgeEventActionProcessor } from './event/getEventBridgeEventActionProcessor';
4
6
  export { default as getSystemActionProcessor } from './system';
@@ -3,9 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getFileActionProcessor = exports.getSystemActionProcessor = exports.getEventBridgeEventActionProcessor = exports.getAPIGatewayEventActionProcessor = exports.getConfigGetSecretActionProcessor = void 0;
6
+ exports.getFileActionProcessor = exports.getSystemActionProcessor = exports.getEventBridgeEventActionProcessor = exports.getAPIGatewayEventActionProcessor = exports.getConfigGetParametersActionProcessor = exports.getConfigGetParameterActionProcessor = exports.getConfigGetSecretActionProcessor = void 0;
7
7
  var getConfigGetSecretActionProcessor_1 = require("./config/getConfigGetSecretActionProcessor");
8
8
  Object.defineProperty(exports, "getConfigGetSecretActionProcessor", { enumerable: true, get: function () { return __importDefault(getConfigGetSecretActionProcessor_1).default; } });
9
+ var getConfigGetParameterActionProcessor_1 = require("./config/getConfigGetParameterActionProcessor");
10
+ Object.defineProperty(exports, "getConfigGetParameterActionProcessor", { enumerable: true, get: function () { return __importDefault(getConfigGetParameterActionProcessor_1).default; } });
11
+ var getConfigGetParametersActionProcessor_1 = require("./config/getConfigGetParametersActionProcessor");
12
+ Object.defineProperty(exports, "getConfigGetParametersActionProcessor", { enumerable: true, get: function () { return __importDefault(getConfigGetParametersActionProcessor_1).default; } });
9
13
  var getAPIGatewayEventActionProcessor_1 = require("./event/getAPIGatewayEventActionProcessor");
10
14
  Object.defineProperty(exports, "getAPIGatewayEventActionProcessor", { enumerable: true, get: function () { return __importDefault(getAPIGatewayEventActionProcessor_1).default; } });
11
15
  var getEventBridgeEventActionProcessor_1 = require("./event/getEventBridgeEventActionProcessor");
@@ -8,20 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
12
  exports.getDateNow = void 0;
16
13
  const quidproquo_core_1 = require("quidproquo-core");
17
- const file_1 = __importDefault(require("../file"));
18
- const config_1 = __importDefault(require("../config"));
19
- const quidproquo_actionprocessor_node_1 = require("quidproquo-actionprocessor-node");
20
14
  const awsLambdaUtils_1 = require("./../../../awsLambdaUtils");
21
15
  const getDateNow = () => new Date().toISOString();
22
16
  exports.getDateNow = getDateNow;
23
17
  const getProcessExecuteStory = (runtimeConfig) => {
24
- return (payload, session) => __awaiter(void 0, void 0, void 0, function* () {
18
+ return (payload, session, actionProcessors) => __awaiter(void 0, void 0, void 0, function* () {
25
19
  let module = yield (0, awsLambdaUtils_1.loadModule)(payload.src);
26
20
  if (module === null) {
27
21
  return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `Module not found [${payload.src}]`);
@@ -33,8 +27,7 @@ const getProcessExecuteStory = (runtimeConfig) => {
33
27
  const logger = (result) => __awaiter(void 0, void 0, void 0, function* () {
34
28
  // return await addResult(service, getDateNow(), payload.params[0][0].path, 'user-route', payload.src, payload.runtime, result);
35
29
  });
36
- const allActionProcessors = Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, file_1.default)(runtimeConfig)), (0, config_1.default)(runtimeConfig));
37
- const resolveStory = (0, quidproquo_core_1.createRuntime)(session, allActionProcessors, exports.getDateNow, logger, awsLambdaUtils_1.randomGuid);
30
+ const resolveStory = (0, quidproquo_core_1.createRuntime)(session, actionProcessors, exports.getDateNow, logger, awsLambdaUtils_1.randomGuid);
38
31
  const storyResult = yield resolveStory(story, payload.params);
39
32
  if (storyResult.error) {
40
33
  return (0, quidproquo_core_1.actionResultError)(storyResult.error.errorType, `story error! in ${payload.src}::${payload.runtime} -> [${storyResult.error.errorText}]`, storyResult.error.errorStack);
@@ -0,0 +1 @@
1
+ export declare const getParameter: (parameterName: string) => Promise<string>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getParameter = void 0;
13
+ const client_ssm_1 = require("@aws-sdk/client-ssm");
14
+ const smClient = new client_ssm_1.SSMClient({});
15
+ const getParameter = (parameterName) => __awaiter(void 0, void 0, void 0, function* () {
16
+ var _a;
17
+ const response = yield smClient.send(new client_ssm_1.GetParameterCommand({
18
+ Name: parameterName,
19
+ }));
20
+ return ((_a = response.Parameter) === null || _a === void 0 ? void 0 : _a.Value) || '';
21
+ });
22
+ exports.getParameter = getParameter;
@@ -0,0 +1 @@
1
+ export declare const getParameters: (parameterNames: string[]) => Promise<string[]>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getParameters = void 0;
13
+ const client_ssm_1 = require("@aws-sdk/client-ssm");
14
+ const smClient = new client_ssm_1.SSMClient({});
15
+ const getParameters = (parameterNames) => __awaiter(void 0, void 0, void 0, function* () {
16
+ const response = yield smClient.send(new client_ssm_1.GetParametersCommand({
17
+ Names: parameterNames,
18
+ }));
19
+ const resolvedParams = response.Parameters || [];
20
+ return parameterNames.map((pn) => { var _a; return ((_a = resolvedParams.find((rp) => rp.Name == pn)) === null || _a === void 0 ? void 0 : _a.Value) || ''; });
21
+ });
22
+ exports.getParameters = getParameters;
@@ -7,5 +7,6 @@ export interface QPQAWSLambdaConfig {
7
7
  qpqConfig: QPQConfig;
8
8
  resourceNameMap: Record<string, string>;
9
9
  secretNameMap: Record<string, string>;
10
+ parameterNameMap: Record<string, string>;
10
11
  lambdaRuntimeConfig?: LambdaRuntimeConfig;
11
12
  }
@@ -1,3 +1,4 @@
1
1
  import { QPQAWSLambdaConfig } from './QPQAWSLambdaConfig';
2
2
  export declare const resolveResourceName: (resourceName: string, qpqAwsLambdaConfig: QPQAWSLambdaConfig) => string;
3
3
  export declare const resolveSecretKey: (secretName: string, qpqAwsLambdaConfig: QPQAWSLambdaConfig) => string;
4
+ export declare const resolveParameterKey: (parameterName: string, qpqAwsLambdaConfig: QPQAWSLambdaConfig) => string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveSecretKey = exports.resolveResourceName = void 0;
3
+ exports.resolveParameterKey = exports.resolveSecretKey = exports.resolveResourceName = void 0;
4
4
  const resolveResourceName = (resourceName, qpqAwsLambdaConfig) => {
5
5
  return qpqAwsLambdaConfig.resourceNameMap[resourceName] || resourceName;
6
6
  };
@@ -9,3 +9,7 @@ const resolveSecretKey = (secretName, qpqAwsLambdaConfig) => {
9
9
  return qpqAwsLambdaConfig.secretNameMap[secretName] || secretName;
10
10
  };
11
11
  exports.resolveSecretKey = resolveSecretKey;
12
+ const resolveParameterKey = (parameterName, qpqAwsLambdaConfig) => {
13
+ return qpqAwsLambdaConfig.parameterNameMap[parameterName] || parameterName;
14
+ };
15
+ exports.resolveParameterKey = resolveParameterKey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quidproquo-actionprocessor-awslambda",
3
- "version": "0.0.21",
3
+ "version": "0.0.24",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.js",
@@ -26,6 +26,7 @@
26
26
  "dependencies": {
27
27
  "@aws-sdk/client-s3": "^3.224.0",
28
28
  "@aws-sdk/client-secrets-manager": "^3.229.0",
29
+ "@aws-sdk/client-ssm": "^3.236.0",
29
30
  "aws-sdk": "^2.1264.0",
30
31
  "node-match-path": "^0.6.3",
31
32
  "quidproquo-core": "*",