quidproquo-actionprocessor-awslambda 0.0.31 → 0.0.32
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.
- package/package.json +2 -3
- package/lib/lambdas/index.d.ts +0 -3
- package/lib/lambdas/index.js +0 -19
- package/lib/lambdas/lambdaAPIGatewayEvent.d.ts +0 -13
- package/lib/lambdas/lambdaAPIGatewayEvent.js +0 -101
- package/lib/lambdas/lambdaConfig.d.ts +0 -4
- package/lib/lambdas/lambdaConfig.js +0 -4
- package/lib/lambdas/lambdaEventBridgeEvent.d.ts +0 -5
- package/lib/lambdas/lambdaEventBridgeEvent.js +0 -60
- package/src/awsLambdaUtils.ts +0 -22
- package/src/getActionProcessor/core/config/getConfigGetParameterActionProcessor.ts +0 -23
- package/src/getActionProcessor/core/config/getConfigGetParametersActionProcessor.ts +0 -27
- package/src/getActionProcessor/core/config/getConfigGetSecretActionProcessor.ts +0 -23
- package/src/getActionProcessor/core/config/index.ts +0 -11
- package/src/getActionProcessor/core/event/getAPIGatewayEventActionProcessor.ts +0 -134
- package/src/getActionProcessor/core/event/getEventBridgeEventActionProcessor.ts +0 -66
- package/src/getActionProcessor/core/file/getFileDeleteActionProcessor.ts +0 -31
- package/src/getActionProcessor/core/file/getFileExistsActionProcessor.ts +0 -16
- package/src/getActionProcessor/core/file/getFileListDirectoryActionProcessor.ts +0 -28
- package/src/getActionProcessor/core/file/getFileReadTextContentsActionProcessor.ts +0 -18
- package/src/getActionProcessor/core/file/getFileWriteTextContentsActionProcessor.ts +0 -23
- package/src/getActionProcessor/core/file/index.ts +0 -15
- package/src/getActionProcessor/core/index.ts +0 -7
- package/src/getActionProcessor/core/system/getExecuteStoryActionProcessor.ts +0 -67
- package/src/getActionProcessor/core/system/index.ts +0 -6
- package/src/getActionProcessor/index.ts +0 -1
- package/src/index.ts +0 -6
- package/src/lambdas/index.ts +0 -4
- package/src/lambdas/lambdaAPIGatewayEvent.ts +0 -105
- package/src/lambdas/lambdaConfig.ts +0 -11
- package/src/lambdas/lambdaEventBridgeEvent.ts +0 -60
- package/src/logic/parametersManager/getParameter.ts +0 -13
- package/src/logic/parametersManager/getParameters.ts +0 -15
- package/src/logic/s3/deleteFiles.ts +0 -17
- package/src/logic/s3/listFiles.ts +0 -66
- package/src/logic/s3/objectExists.ts +0 -18
- package/src/logic/s3/readTextFile.ts +0 -14
- package/src/logic/s3/s3Client.ts +0 -5
- package/src/logic/s3/s3Utils.ts +0 -5
- package/src/logic/s3/writeTextFile.ts +0 -17
- package/src/logic/secretsManager/getSecret.ts +0 -13
- package/src/runtimeConfig/QPQAWSLambdaConfig.ts +0 -15
- package/src/runtimeConfig/qpqAwsLambdaRuntimeConfigUtils.ts +0 -19
- package/src/types/DynamicLoader.ts +0 -1
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-actionprocessor-awslambda",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.js",
|
|
7
7
|
"files": [
|
|
8
|
-
"lib/**/*"
|
|
9
|
-
"src/**/*"
|
|
8
|
+
"lib/**/*"
|
|
10
9
|
],
|
|
11
10
|
"scripts": {
|
|
12
11
|
"test": "echo \"Error: no test specified\" && exit 1",
|
package/lib/lambdas/index.d.ts
DELETED
package/lib/lambdas/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./lambdaConfig"), exports);
|
|
18
|
-
__exportStar(require("./lambdaAPIGatewayEvent"), exports);
|
|
19
|
-
__exportStar(require("./lambdaEventBridgeEvent"), exports);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Context } from 'aws-lambda';
|
|
2
|
-
import { DynamicModuleLoader } from '../types/DynamicLoader';
|
|
3
|
-
import { ActionProcessorListResolver } from './lambdaConfig';
|
|
4
|
-
export declare const getAPIGatewayEventExecutor: (dynamicModuleLoader: DynamicModuleLoader, getCustomActionProcessors?: ActionProcessorListResolver) => (event: import("aws-lambda").APIGatewayProxyEvent, context: Context) => Promise<{
|
|
5
|
-
statusCode: any;
|
|
6
|
-
body: string;
|
|
7
|
-
headers: any;
|
|
8
|
-
}>;
|
|
9
|
-
export declare const executeAPIGatewayEvent: (event: import("aws-lambda").APIGatewayProxyEvent, context: Context) => Promise<{
|
|
10
|
-
statusCode: any;
|
|
11
|
-
body: string;
|
|
12
|
-
headers: any;
|
|
13
|
-
}>;
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.executeAPIGatewayEvent = exports.getAPIGatewayEventExecutor = void 0;
|
|
39
|
-
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
40
|
-
const quidproquo_core_1 = require("quidproquo-core");
|
|
41
|
-
const quidproquo_actionprocessor_node_1 = require("quidproquo-actionprocessor-node");
|
|
42
|
-
const awsLambdaUtils = __importStar(require("../awsLambdaUtils"));
|
|
43
|
-
const getActionProcessor_1 = require("../getActionProcessor");
|
|
44
|
-
const lambdaConfig_1 = require("./lambdaConfig");
|
|
45
|
-
// @ts-ignore - Special webpack loader
|
|
46
|
-
const qpq_dynamic_loader_1 = __importDefault(require("qpq-dynamic-loader!"));
|
|
47
|
-
// TODO: Make this a util or something based on server time or something..
|
|
48
|
-
const getDateNow = () => new Date().toISOString();
|
|
49
|
-
const ErrorTypeHttpResponseMap = {
|
|
50
|
-
[quidproquo_core_1.ErrorTypeEnum.BadRequest]: 400,
|
|
51
|
-
[quidproquo_core_1.ErrorTypeEnum.Unauthorized]: 401,
|
|
52
|
-
[quidproquo_core_1.ErrorTypeEnum.PaymentRequired]: 402,
|
|
53
|
-
[quidproquo_core_1.ErrorTypeEnum.Forbidden]: 403,
|
|
54
|
-
[quidproquo_core_1.ErrorTypeEnum.NotFound]: 404,
|
|
55
|
-
[quidproquo_core_1.ErrorTypeEnum.TimeOut]: 408,
|
|
56
|
-
[quidproquo_core_1.ErrorTypeEnum.UnsupportedMediaType]: 415,
|
|
57
|
-
[quidproquo_core_1.ErrorTypeEnum.OutOfResources]: 500,
|
|
58
|
-
[quidproquo_core_1.ErrorTypeEnum.GenericError]: 500,
|
|
59
|
-
[quidproquo_core_1.ErrorTypeEnum.NotImplemented]: 501,
|
|
60
|
-
[quidproquo_core_1.ErrorTypeEnum.NoContent]: 204,
|
|
61
|
-
[quidproquo_core_1.ErrorTypeEnum.Invalid]: 422,
|
|
62
|
-
};
|
|
63
|
-
const getAPIGatewayEventExecutor = (dynamicModuleLoader, getCustomActionProcessors = () => ({})) => {
|
|
64
|
-
return (event, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
-
// Build a processor for the session and stuff
|
|
66
|
-
// Remove the non route ones ~ let the story execute action add them
|
|
67
|
-
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, getActionProcessor_1.getAPIGatewayEventActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig.qpqConfig)), (0, getActionProcessor_1.getConfigGetSecretActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, getActionProcessor_1.getConfigGetParameterActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, getActionProcessor_1.getConfigGetParametersActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, getActionProcessor_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, getActionProcessor_1.getFileActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), getCustomActionProcessors(lambdaConfig_1.lambdaRuntimeConfig));
|
|
68
|
-
const logger = (result) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
-
// addResult(
|
|
70
|
-
// envConfig.appName,
|
|
71
|
-
// getDateNow(),
|
|
72
|
-
// doWeCarePath,
|
|
73
|
-
// "route-infrastructure",
|
|
74
|
-
// "infrastructure",
|
|
75
|
-
// "askRoute",
|
|
76
|
-
// result
|
|
77
|
-
// );
|
|
78
|
-
});
|
|
79
|
-
// // Run the callback
|
|
80
|
-
const resolveStory = (0, quidproquo_core_1.createRuntime)({}, storyActionProcessor, getDateNow, logger, awsLambdaUtils.randomGuid);
|
|
81
|
-
const result = yield resolveStory(quidproquo_core_1.askProcessEvent, [event, context]);
|
|
82
|
-
// Run the callback
|
|
83
|
-
if (!result.error) {
|
|
84
|
-
return {
|
|
85
|
-
statusCode: result.result.statusCode,
|
|
86
|
-
body: JSON.stringify(result.result.body),
|
|
87
|
-
headers: result.result.headers,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
console.log(JSON.stringify(result));
|
|
91
|
-
const code = ErrorTypeHttpResponseMap[result.error.errorType];
|
|
92
|
-
return {
|
|
93
|
-
statusCode: code || 500,
|
|
94
|
-
body: JSON.stringify(result.error),
|
|
95
|
-
headers: quidproquo_webserver_1.qpqWebServerUtils.getCorsHeaders(lambdaConfig_1.lambdaRuntimeConfig.qpqConfig, {}, event.headers),
|
|
96
|
-
};
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
exports.getAPIGatewayEventExecutor = getAPIGatewayEventExecutor;
|
|
100
|
-
// Default executor
|
|
101
|
-
exports.executeAPIGatewayEvent = (0, exports.getAPIGatewayEventExecutor)(qpq_dynamic_loader_1.default);
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ActionProcessorList } from 'quidproquo-core';
|
|
2
|
-
import { QPQAWSLambdaConfig } from '../runtimeConfig/QPQAWSLambdaConfig';
|
|
3
|
-
export declare const lambdaRuntimeConfig: QPQAWSLambdaConfig;
|
|
4
|
-
export type ActionProcessorListResolver = (lambdaRuntimeConfig: QPQAWSLambdaConfig) => ActionProcessorList;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { EventBridgeEvent, Context } from 'aws-lambda';
|
|
2
|
-
import { DynamicModuleLoader } from '../types/DynamicLoader';
|
|
3
|
-
import { ActionProcessorListResolver } from './lambdaConfig';
|
|
4
|
-
export declare const getEventBridgeEventExecutor: (dynamicModuleLoader: DynamicModuleLoader, getCustomActionProcessors?: ActionProcessorListResolver) => (event: EventBridgeEvent<string, void>, context: Context) => Promise<void>;
|
|
5
|
-
export declare const executeEventBridgeEvent: (event: EventBridgeEvent<string, void>, context: Context) => Promise<void>;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.executeEventBridgeEvent = exports.getEventBridgeEventExecutor = void 0;
|
|
39
|
-
const quidproquo_core_1 = require("quidproquo-core");
|
|
40
|
-
const quidproquo_actionprocessor_node_1 = require("quidproquo-actionprocessor-node");
|
|
41
|
-
const awsLambdaUtils = __importStar(require("../awsLambdaUtils"));
|
|
42
|
-
const getActionProcessor_1 = require("../getActionProcessor");
|
|
43
|
-
const lambdaConfig_1 = require("./lambdaConfig");
|
|
44
|
-
// @ts-ignore - Special webpack loader
|
|
45
|
-
const qpq_dynamic_loader_1 = __importDefault(require("qpq-dynamic-loader!"));
|
|
46
|
-
// TODO: Make this a util or something based on server time or something..
|
|
47
|
-
const getDateNow = () => new Date().toISOString();
|
|
48
|
-
const getEventBridgeEventExecutor = (dynamicModuleLoader, getCustomActionProcessors = () => ({})) => {
|
|
49
|
-
return (event, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
-
// Build a processor for the session and stuff
|
|
51
|
-
// Remove the non event ones
|
|
52
|
-
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, getActionProcessor_1.getEventBridgeEventActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, getActionProcessor_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, getActionProcessor_1.getFileActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, getActionProcessor_1.getConfigGetSecretActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, getActionProcessor_1.getConfigGetParameterActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, getActionProcessor_1.getConfigGetParametersActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), getCustomActionProcessors(lambdaConfig_1.lambdaRuntimeConfig));
|
|
53
|
-
const logger = (result) => __awaiter(void 0, void 0, void 0, function* () { });
|
|
54
|
-
// Run the callback
|
|
55
|
-
const resolveStory = (0, quidproquo_core_1.createRuntime)({}, storyActionProcessor, getDateNow, logger, awsLambdaUtils.randomGuid);
|
|
56
|
-
yield resolveStory(quidproquo_core_1.askProcessEvent, [event, context]);
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
exports.getEventBridgeEventExecutor = getEventBridgeEventExecutor;
|
|
60
|
-
exports.executeEventBridgeEvent = (0, exports.getEventBridgeEventExecutor)(qpq_dynamic_loader_1.default);
|
package/src/awsLambdaUtils.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'crypto';
|
|
2
|
-
import { match } from 'node-match-path';
|
|
3
|
-
|
|
4
|
-
export const randomGuid = () => {
|
|
5
|
-
return randomUUID();
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export interface UrlMatch {
|
|
9
|
-
didMatch: boolean;
|
|
10
|
-
params: Record<string, string> | null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const matchUrl = (path: string, url: string): UrlMatch => {
|
|
14
|
-
// /attempt/{attemptUuid}/result/{test} => /attempt/:attemptUuid/result/:test
|
|
15
|
-
const modifiedPath = path.replaceAll(/{(.+?)}/g, (m, g) => `:${g}`);
|
|
16
|
-
|
|
17
|
-
const matchResult = match(modifiedPath, url);
|
|
18
|
-
return {
|
|
19
|
-
didMatch: matchResult.matches,
|
|
20
|
-
params: matchResult.params,
|
|
21
|
-
};
|
|
22
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ConfigActionType, ConfigGetParameterActionProcessor, actionResult } from 'quidproquo-core';
|
|
2
|
-
|
|
3
|
-
import { QPQAWSLambdaConfig } from '../../../runtimeConfig/QPQAWSLambdaConfig';
|
|
4
|
-
import { resolveParameterKey } from '../../../runtimeConfig/qpqAwsLambdaRuntimeConfigUtils';
|
|
5
|
-
|
|
6
|
-
import { getParameter } from '../../../logic/parametersManager/getParameter';
|
|
7
|
-
|
|
8
|
-
const getProcessConfigGetParameter = (
|
|
9
|
-
runtimeConfig: QPQAWSLambdaConfig,
|
|
10
|
-
): ConfigGetParameterActionProcessor => {
|
|
11
|
-
return async ({ parameterName }) => {
|
|
12
|
-
const awsParameterKey = resolveParameterKey(parameterName, runtimeConfig);
|
|
13
|
-
const parameterValue = await getParameter(awsParameterKey);
|
|
14
|
-
|
|
15
|
-
return actionResult(parameterValue);
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default (runtimeConfig: QPQAWSLambdaConfig) => {
|
|
20
|
-
return {
|
|
21
|
-
[ConfigActionType.GetParameter]: getProcessConfigGetParameter(runtimeConfig),
|
|
22
|
-
};
|
|
23
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ConfigActionType,
|
|
3
|
-
ConfigGetParametersActionProcessor,
|
|
4
|
-
actionResult,
|
|
5
|
-
} from 'quidproquo-core';
|
|
6
|
-
|
|
7
|
-
import { QPQAWSLambdaConfig } from '../../../runtimeConfig/QPQAWSLambdaConfig';
|
|
8
|
-
import { resolveParameterKey } from '../../../runtimeConfig/qpqAwsLambdaRuntimeConfigUtils';
|
|
9
|
-
|
|
10
|
-
import { getParameters } from '../../../logic/parametersManager/getParameters';
|
|
11
|
-
|
|
12
|
-
const getProcessConfigGetParameters = (
|
|
13
|
-
runtimeConfig: QPQAWSLambdaConfig,
|
|
14
|
-
): ConfigGetParametersActionProcessor => {
|
|
15
|
-
return async ({ parameterNames }) => {
|
|
16
|
-
const awsParameterKeys = parameterNames.map((pn) => resolveParameterKey(pn, runtimeConfig));
|
|
17
|
-
const parameterValues = await getParameters(awsParameterKeys);
|
|
18
|
-
|
|
19
|
-
return actionResult(parameterValues);
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export default (runtimeConfig: QPQAWSLambdaConfig) => {
|
|
24
|
-
return {
|
|
25
|
-
[ConfigActionType.GetParameters]: getProcessConfigGetParameters(runtimeConfig),
|
|
26
|
-
};
|
|
27
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ConfigActionType, ConfigGetSecretActionProcessor, actionResult } from 'quidproquo-core';
|
|
2
|
-
|
|
3
|
-
import { QPQAWSLambdaConfig } from '../../../runtimeConfig/QPQAWSLambdaConfig';
|
|
4
|
-
import { resolveSecretKey } from '../../../runtimeConfig/qpqAwsLambdaRuntimeConfigUtils';
|
|
5
|
-
|
|
6
|
-
import { getSecret } from '../../../logic/secretsManager/getSecret';
|
|
7
|
-
|
|
8
|
-
const getProcessConfigActionType = (
|
|
9
|
-
runtimeConfig: QPQAWSLambdaConfig,
|
|
10
|
-
): ConfigGetSecretActionProcessor => {
|
|
11
|
-
return async ({ secretName }) => {
|
|
12
|
-
const awsSecretKey = resolveSecretKey(secretName, runtimeConfig);
|
|
13
|
-
const secretValue = await getSecret(awsSecretKey);
|
|
14
|
-
|
|
15
|
-
return actionResult(secretValue);
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default (runtimeConfig: QPQAWSLambdaConfig) => {
|
|
20
|
-
return {
|
|
21
|
-
[ConfigActionType.GetSecret]: getProcessConfigActionType(runtimeConfig),
|
|
22
|
-
};
|
|
23
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { QPQAWSLambdaConfig } from '../../../runtimeConfig/QPQAWSLambdaConfig';
|
|
2
|
-
|
|
3
|
-
import getConfigGetParameterActionProcessor from './getConfigGetParameterActionProcessor';
|
|
4
|
-
import getConfigGetParametersActionProcessor from './getConfigGetParametersActionProcessor';
|
|
5
|
-
import getConfigGetSecretActionProcessor from './getConfigGetSecretActionProcessor';
|
|
6
|
-
|
|
7
|
-
export default (runtimeConfig: QPQAWSLambdaConfig) => ({
|
|
8
|
-
...getConfigGetParameterActionProcessor(runtimeConfig),
|
|
9
|
-
...getConfigGetParametersActionProcessor(runtimeConfig),
|
|
10
|
-
...getConfigGetSecretActionProcessor(runtimeConfig),
|
|
11
|
-
});
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EventActionType,
|
|
3
|
-
QPQConfig,
|
|
4
|
-
qpqCoreUtils,
|
|
5
|
-
MatchStoryResult,
|
|
6
|
-
EventMatchStoryActionProcessor,
|
|
7
|
-
EventTransformEventParamsActionProcessor,
|
|
8
|
-
EventTransformResponseResultActionProcessor,
|
|
9
|
-
EventAutoRespondActionProcessor,
|
|
10
|
-
actionResult,
|
|
11
|
-
actionResultError,
|
|
12
|
-
ErrorTypeEnum,
|
|
13
|
-
} from 'quidproquo-core';
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
RouteQPQWebServerConfigSetting,
|
|
17
|
-
HTTPEventParams,
|
|
18
|
-
qpqWebServerUtils,
|
|
19
|
-
} from 'quidproquo-webserver';
|
|
20
|
-
|
|
21
|
-
import { APIGatewayEvent, Context, APIGatewayProxyResult } from 'aws-lambda';
|
|
22
|
-
|
|
23
|
-
import { matchUrl } from '../../../awsLambdaUtils';
|
|
24
|
-
|
|
25
|
-
const getProcessTransformEventParams = (
|
|
26
|
-
appName: string,
|
|
27
|
-
): EventTransformEventParamsActionProcessor<[APIGatewayEvent, Context], HTTPEventParams<any>> => {
|
|
28
|
-
return async ({ eventParams: [apiGatewayEvent, context] }) => {
|
|
29
|
-
const path = (apiGatewayEvent.path || '').replace(new RegExp(`^(\/${appName})/`), '/');
|
|
30
|
-
console.log('getProcessTransformEventParams', JSON.stringify(apiGatewayEvent));
|
|
31
|
-
|
|
32
|
-
return actionResult({
|
|
33
|
-
path,
|
|
34
|
-
query: {
|
|
35
|
-
...(apiGatewayEvent.multiValueQueryStringParameters || {}),
|
|
36
|
-
...(apiGatewayEvent.queryStringParameters || {}),
|
|
37
|
-
} as { [key: string]: undefined | string | string[] },
|
|
38
|
-
body: apiGatewayEvent.body ? JSON.parse(apiGatewayEvent.body) : undefined,
|
|
39
|
-
headers: apiGatewayEvent.headers,
|
|
40
|
-
method: apiGatewayEvent.httpMethod as 'GET' | 'POST',
|
|
41
|
-
correlation: context.awsRequestId,
|
|
42
|
-
sourceIp: apiGatewayEvent.requestContext.identity.sourceIp,
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const getProcessTransformResponseResult = (
|
|
48
|
-
configs: QPQConfig,
|
|
49
|
-
): EventTransformResponseResultActionProcessor<APIGatewayProxyResult> => {
|
|
50
|
-
// We might need to JSON.stringify the body.
|
|
51
|
-
return async (payload) => {
|
|
52
|
-
// Validate response
|
|
53
|
-
// if !valid actionResultError
|
|
54
|
-
|
|
55
|
-
console.log('getProcessTransformResponseResult', JSON.stringify(payload));
|
|
56
|
-
|
|
57
|
-
return actionResult<APIGatewayProxyResult>({
|
|
58
|
-
statusCode: payload.response.result.statusCode,
|
|
59
|
-
body: payload.response.result.body,
|
|
60
|
-
headers: {
|
|
61
|
-
'Content-Type': 'application/json',
|
|
62
|
-
...qpqWebServerUtils.getCorsHeaders(configs, {}, payload.transformedEventParams.headers),
|
|
63
|
-
...(payload.response.headers || {}),
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const getProcessAutoRespond = (
|
|
70
|
-
configs: QPQConfig,
|
|
71
|
-
): EventAutoRespondActionProcessor<HTTPEventParams<any>> => {
|
|
72
|
-
return async (payload) => {
|
|
73
|
-
if (payload.transformedEventParams.method === 'OPTIONS') {
|
|
74
|
-
return actionResult({
|
|
75
|
-
result: {
|
|
76
|
-
statusCode: 200,
|
|
77
|
-
headers: qpqWebServerUtils.getCorsHeaders(
|
|
78
|
-
configs,
|
|
79
|
-
{},
|
|
80
|
-
payload.transformedEventParams.headers,
|
|
81
|
-
),
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return actionResult(null);
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const getProcessMatchStory = (
|
|
91
|
-
routes: RouteQPQWebServerConfigSetting[],
|
|
92
|
-
): EventMatchStoryActionProcessor<HTTPEventParams<any>> => {
|
|
93
|
-
return async (payload) => {
|
|
94
|
-
// Sort the routes by string length
|
|
95
|
-
// Note: We may need to filter variable routes out {} as the variables are length independent
|
|
96
|
-
const sortedRoutes = routes
|
|
97
|
-
.filter((r: any) => r.method === payload.transformedEventParams.method)
|
|
98
|
-
.sort((a: any, b: any) => {
|
|
99
|
-
if (a.path.length < b.path.length) return -1;
|
|
100
|
-
if (a.path.length > b.path.length) return 1;
|
|
101
|
-
return 0;
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// Find the most relevant match
|
|
105
|
-
const matchedRoute = sortedRoutes
|
|
106
|
-
.map((r) => ({
|
|
107
|
-
match: matchUrl(r.path, payload.transformedEventParams.path),
|
|
108
|
-
route: r,
|
|
109
|
-
}))
|
|
110
|
-
.find((m) => m.match.didMatch);
|
|
111
|
-
|
|
112
|
-
if (!matchedRoute) {
|
|
113
|
-
return actionResultError(ErrorTypeEnum.NotFound, 'route not found');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return actionResult<MatchStoryResult>({
|
|
117
|
-
src: matchedRoute.route.src,
|
|
118
|
-
runtime: matchedRoute.route.runtime,
|
|
119
|
-
options: matchedRoute.match.params || {},
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export default (config: QPQConfig) => {
|
|
125
|
-
const routes = qpqWebServerUtils.getAllRoutes(config);
|
|
126
|
-
const appName = qpqCoreUtils.getAppName(config);
|
|
127
|
-
|
|
128
|
-
return {
|
|
129
|
-
[EventActionType.TransformEventParams]: getProcessTransformEventParams(appName),
|
|
130
|
-
[EventActionType.TransformResponseResult]: getProcessTransformResponseResult(config),
|
|
131
|
-
[EventActionType.AutoRespond]: getProcessAutoRespond(config),
|
|
132
|
-
[EventActionType.MatchStory]: getProcessMatchStory(routes),
|
|
133
|
-
};
|
|
134
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EventActionType,
|
|
3
|
-
MatchStoryResult,
|
|
4
|
-
EventMatchStoryActionProcessor,
|
|
5
|
-
EventTransformEventParamsActionProcessor,
|
|
6
|
-
EventTransformResponseResultActionProcessor,
|
|
7
|
-
EventAutoRespondActionProcessor,
|
|
8
|
-
actionResult,
|
|
9
|
-
actionResultError,
|
|
10
|
-
ErrorTypeEnum,
|
|
11
|
-
ScheduledEventParams,
|
|
12
|
-
} from 'quidproquo-core';
|
|
13
|
-
|
|
14
|
-
import { QPQAWSLambdaConfig, LambdaRuntimeConfig } from '../../../runtimeConfig/QPQAWSLambdaConfig';
|
|
15
|
-
|
|
16
|
-
import { EventBridgeEvent, Context, APIGatewayProxyResult } from 'aws-lambda';
|
|
17
|
-
|
|
18
|
-
const getProcessTransformEventParams = (): EventTransformEventParamsActionProcessor<
|
|
19
|
-
[EventBridgeEvent<any, any>, Context],
|
|
20
|
-
ScheduledEventParams<any>
|
|
21
|
-
> => {
|
|
22
|
-
return async ({ eventParams: [eventBridgeEvent, context] }) => {
|
|
23
|
-
return actionResult({
|
|
24
|
-
time: eventBridgeEvent.time,
|
|
25
|
-
correlation: context.awsRequestId,
|
|
26
|
-
detail: eventBridgeEvent.detail,
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// No transform
|
|
32
|
-
const getProcessTransformResponseResult = (): EventTransformResponseResultActionProcessor<any> => {
|
|
33
|
-
return async ({ response }) => actionResult<any>(response);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// never early exit (maybe add validation?)
|
|
37
|
-
const getProcessAutoRespond = (): EventAutoRespondActionProcessor<ScheduledEventParams<any>> => {
|
|
38
|
-
return async () => actionResult(null);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const getProcessMatchStory = (
|
|
42
|
-
lambdaRuntimeConfig?: LambdaRuntimeConfig,
|
|
43
|
-
): EventMatchStoryActionProcessor<ScheduledEventParams<any>> => {
|
|
44
|
-
return async (payload) => {
|
|
45
|
-
console.log('Trying to match story');
|
|
46
|
-
console.log(JSON.stringify(lambdaRuntimeConfig));
|
|
47
|
-
if (!lambdaRuntimeConfig) {
|
|
48
|
-
return actionResultError(ErrorTypeEnum.NotFound, 'event runtime not found');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return actionResult<MatchStoryResult>({
|
|
52
|
-
src: lambdaRuntimeConfig.src,
|
|
53
|
-
runtime: lambdaRuntimeConfig.runtime,
|
|
54
|
-
options: {},
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export default (runtimeConfig: QPQAWSLambdaConfig) => {
|
|
60
|
-
return {
|
|
61
|
-
[EventActionType.TransformEventParams]: getProcessTransformEventParams(),
|
|
62
|
-
[EventActionType.TransformResponseResult]: getProcessTransformResponseResult(),
|
|
63
|
-
[EventActionType.AutoRespond]: getProcessAutoRespond(),
|
|
64
|
-
[EventActionType.MatchStory]: getProcessMatchStory(runtimeConfig.lambdaRuntimeConfig),
|
|
65
|
-
};
|
|
66
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { QPQAWSLambdaConfig } from '../../../runtimeConfig/QPQAWSLambdaConfig';
|
|
2
|
-
import { resolveResourceName } from '../../../runtimeConfig/qpqAwsLambdaRuntimeConfigUtils';
|
|
3
|
-
import {
|
|
4
|
-
FileDeleteActionProcessor,
|
|
5
|
-
actionResult,
|
|
6
|
-
actionResultError,
|
|
7
|
-
FileActionType,
|
|
8
|
-
ErrorTypeEnum,
|
|
9
|
-
} from 'quidproquo-core';
|
|
10
|
-
import { deleteFiles } from '../../../logic/s3/s3Utils';
|
|
11
|
-
|
|
12
|
-
const getProcessFileDelete = (runtimeConfig: QPQAWSLambdaConfig): FileDeleteActionProcessor => {
|
|
13
|
-
return async ({ drive, filepaths }) => {
|
|
14
|
-
const s3BucketName = resolveResourceName(drive, runtimeConfig);
|
|
15
|
-
const errored = await deleteFiles(s3BucketName, filepaths);
|
|
16
|
-
|
|
17
|
-
// errored deletes are a graceful success ~ Retry
|
|
18
|
-
// if (errored.length > 0) {
|
|
19
|
-
// return actionResultError(
|
|
20
|
-
// ErrorTypeEnum.GenericError,
|
|
21
|
-
// `Could not delete files ${errored.length}`,
|
|
22
|
-
// );
|
|
23
|
-
// }
|
|
24
|
-
|
|
25
|
-
return actionResult(errored);
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default (runtimeConfig: QPQAWSLambdaConfig) => ({
|
|
30
|
-
[FileActionType.Delete]: getProcessFileDelete(runtimeConfig),
|
|
31
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { QPQAWSLambdaConfig } from '../../../runtimeConfig/QPQAWSLambdaConfig';
|
|
2
|
-
import { resolveResourceName } from '../../../runtimeConfig/qpqAwsLambdaRuntimeConfigUtils';
|
|
3
|
-
import { FileExistsActionProcessor, actionResult, FileActionType } from 'quidproquo-core';
|
|
4
|
-
import { objectExists } from '../../../logic/s3/s3Utils';
|
|
5
|
-
|
|
6
|
-
const getProcessFileExists = (runtimeConfig: QPQAWSLambdaConfig): FileExistsActionProcessor => {
|
|
7
|
-
return async ({ drive, filepath }) => {
|
|
8
|
-
const s3BucketName = resolveResourceName(drive, runtimeConfig);
|
|
9
|
-
|
|
10
|
-
return actionResult(await objectExists(s3BucketName, filepath));
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export default (runtimeConfig: QPQAWSLambdaConfig) => ({
|
|
15
|
-
[FileActionType.Exists]: getProcessFileExists(runtimeConfig),
|
|
16
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { QPQAWSLambdaConfig } from '../../../runtimeConfig/QPQAWSLambdaConfig';
|
|
2
|
-
import { resolveResourceName } from '../../../runtimeConfig/qpqAwsLambdaRuntimeConfigUtils';
|
|
3
|
-
import { FileListDirectoryActionProcessor, actionResult, FileActionType } from 'quidproquo-core';
|
|
4
|
-
import { listFiles } from '../../../logic/s3/s3Utils';
|
|
5
|
-
|
|
6
|
-
const getProcessFileListDirectory = (
|
|
7
|
-
runtimeConfig: QPQAWSLambdaConfig,
|
|
8
|
-
): FileListDirectoryActionProcessor => {
|
|
9
|
-
return async ({ drive, folderPath, maxFiles, pageToken }) => {
|
|
10
|
-
const s3BucketName = resolveResourceName(drive, runtimeConfig);
|
|
11
|
-
const s3FileList = await listFiles(s3BucketName, folderPath, maxFiles, pageToken);
|
|
12
|
-
|
|
13
|
-
// Add the drive onto the list
|
|
14
|
-
const fileInfos = s3FileList.fileInfos.map((s3fi) => ({
|
|
15
|
-
...s3fi,
|
|
16
|
-
drive: drive,
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
return actionResult({
|
|
20
|
-
fileInfos,
|
|
21
|
-
pageToken: s3FileList.pageToken,
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default (runtimeConfig: QPQAWSLambdaConfig) => ({
|
|
27
|
-
[FileActionType.ListDirectory]: getProcessFileListDirectory(runtimeConfig),
|
|
28
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { QPQAWSLambdaConfig } from '../../../runtimeConfig/QPQAWSLambdaConfig';
|
|
2
|
-
import { resolveResourceName } from '../../../runtimeConfig/qpqAwsLambdaRuntimeConfigUtils';
|
|
3
|
-
import { FileReadTextContentsActionProcessor, actionResult, FileActionType } from 'quidproquo-core';
|
|
4
|
-
import { readTextFile } from '../../../logic/s3/s3Utils';
|
|
5
|
-
|
|
6
|
-
const getProcessFileReadTextContents = (
|
|
7
|
-
runtimeConfig: QPQAWSLambdaConfig,
|
|
8
|
-
): FileReadTextContentsActionProcessor => {
|
|
9
|
-
return async ({ drive, filepath }) => {
|
|
10
|
-
const s3BucketName = resolveResourceName(drive, runtimeConfig);
|
|
11
|
-
|
|
12
|
-
return actionResult(await readTextFile(s3BucketName, filepath));
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default (runtimeConfig: QPQAWSLambdaConfig) => ({
|
|
17
|
-
[FileActionType.ReadTextContents]: getProcessFileReadTextContents(runtimeConfig),
|
|
18
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { QPQAWSLambdaConfig } from '../../../runtimeConfig/QPQAWSLambdaConfig';
|
|
2
|
-
import { resolveResourceName } from '../../../runtimeConfig/qpqAwsLambdaRuntimeConfigUtils';
|
|
3
|
-
import {
|
|
4
|
-
FileWriteTextContentsActionProcessor,
|
|
5
|
-
actionResult,
|
|
6
|
-
FileActionType,
|
|
7
|
-
} from 'quidproquo-core';
|
|
8
|
-
import { writeTextFile } from '../../../logic/s3/s3Utils';
|
|
9
|
-
|
|
10
|
-
const getProcessFileWriteTextContents = (
|
|
11
|
-
runtimeConfig: QPQAWSLambdaConfig,
|
|
12
|
-
): FileWriteTextContentsActionProcessor => {
|
|
13
|
-
return async ({ drive, filepath, data }) => {
|
|
14
|
-
const s3BucketName = resolveResourceName(drive, runtimeConfig);
|
|
15
|
-
await writeTextFile(s3BucketName, filepath, data);
|
|
16
|
-
|
|
17
|
-
return actionResult(void 0);
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default (runtimeConfig: QPQAWSLambdaConfig) => ({
|
|
22
|
-
[FileActionType.WriteTextContents]: getProcessFileWriteTextContents(runtimeConfig),
|
|
23
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { QPQAWSLambdaConfig } from '../../../runtimeConfig/QPQAWSLambdaConfig';
|
|
2
|
-
|
|
3
|
-
import getFileDeleteActionProcessor from './getFileDeleteActionProcessor';
|
|
4
|
-
import getFileExistsActionProcessor from './getFileExistsActionProcessor';
|
|
5
|
-
import getFileListDirectoryActionProcessor from './getFileListDirectoryActionProcessor';
|
|
6
|
-
import getFileReadTextContentsActionProcessor from './getFileReadTextContentsActionProcessor';
|
|
7
|
-
import getFileWriteTextContentsActionProcessor from './getFileWriteTextContentsActionProcessor';
|
|
8
|
-
|
|
9
|
-
export default (runtimeConfig: QPQAWSLambdaConfig) => ({
|
|
10
|
-
...getFileDeleteActionProcessor(runtimeConfig),
|
|
11
|
-
...getFileExistsActionProcessor(runtimeConfig),
|
|
12
|
-
...getFileListDirectoryActionProcessor(runtimeConfig),
|
|
13
|
-
...getFileReadTextContentsActionProcessor(runtimeConfig),
|
|
14
|
-
...getFileWriteTextContentsActionProcessor(runtimeConfig),
|
|
15
|
-
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { default as getConfigGetSecretActionProcessor } from './config/getConfigGetSecretActionProcessor';
|
|
2
|
-
export { default as getConfigGetParameterActionProcessor } from './config/getConfigGetParameterActionProcessor';
|
|
3
|
-
export { default as getConfigGetParametersActionProcessor } from './config/getConfigGetParametersActionProcessor';
|
|
4
|
-
export { default as getAPIGatewayEventActionProcessor } from './event/getAPIGatewayEventActionProcessor';
|
|
5
|
-
export { default as getEventBridgeEventActionProcessor } from './event/getEventBridgeEventActionProcessor';
|
|
6
|
-
export { default as getSystemActionProcessor } from './system';
|
|
7
|
-
export { default as getFileActionProcessor } from './file';
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SystemActionType,
|
|
3
|
-
QPQConfig,
|
|
4
|
-
qpqCoreUtils,
|
|
5
|
-
SystemExecuteStoryActionPayload,
|
|
6
|
-
StorySession,
|
|
7
|
-
createRuntime,
|
|
8
|
-
SystemExecuteStoryActionProcessor,
|
|
9
|
-
actionResultError,
|
|
10
|
-
ErrorTypeEnum,
|
|
11
|
-
actionResult,
|
|
12
|
-
ActionProcessorList,
|
|
13
|
-
} from 'quidproquo-core';
|
|
14
|
-
|
|
15
|
-
import { randomGuid } from './../../../awsLambdaUtils';
|
|
16
|
-
import { DynamicModuleLoader } from '../../../types/DynamicLoader';
|
|
17
|
-
|
|
18
|
-
export const getDateNow = () => new Date().toISOString();
|
|
19
|
-
|
|
20
|
-
const getProcessExecuteStory = <T extends Array<any>>(
|
|
21
|
-
dynamicModuleLoader: DynamicModuleLoader,
|
|
22
|
-
): SystemExecuteStoryActionProcessor<T> => {
|
|
23
|
-
return async (
|
|
24
|
-
payload: SystemExecuteStoryActionPayload<T>,
|
|
25
|
-
session: StorySession,
|
|
26
|
-
actionProcessors: ActionProcessorList,
|
|
27
|
-
): Promise<any> => {
|
|
28
|
-
let module = await dynamicModuleLoader(payload.src);
|
|
29
|
-
if (module === null) {
|
|
30
|
-
return actionResultError(ErrorTypeEnum.NotFound, `Module not found [${payload.src}]`);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const story = module[payload.runtime];
|
|
34
|
-
if (!story) {
|
|
35
|
-
return actionResultError(
|
|
36
|
-
ErrorTypeEnum.NotFound,
|
|
37
|
-
`[${payload.runtime}] not found in module [${payload.src}]`,
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const logger = async (result: any) => {
|
|
42
|
-
// return await addResult(service, getDateNow(), payload.params[0][0].path, 'user-route', payload.src, payload.runtime, result);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const resolveStory = createRuntime(session, actionProcessors, getDateNow, logger, randomGuid);
|
|
46
|
-
const storyResult = await resolveStory(story, payload.params);
|
|
47
|
-
|
|
48
|
-
if (storyResult.error) {
|
|
49
|
-
return actionResultError(
|
|
50
|
-
storyResult.error.errorType,
|
|
51
|
-
`story error! in ${payload.src}::${payload.runtime} -> [${storyResult.error.errorText}]`,
|
|
52
|
-
storyResult.error.errorStack,
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return actionResult({
|
|
57
|
-
result: storyResult.result,
|
|
58
|
-
session: storyResult.session,
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export default (dynamicModuleLoader: DynamicModuleLoader) => {
|
|
64
|
-
return {
|
|
65
|
-
[SystemActionType.ExecuteStory]: getProcessExecuteStory(dynamicModuleLoader),
|
|
66
|
-
};
|
|
67
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import getExecuteStoryActionProcessor from './getExecuteStoryActionProcessor';
|
|
2
|
-
import { DynamicModuleLoader } from '../../../types/DynamicLoader';
|
|
3
|
-
|
|
4
|
-
export default (dynamicModuleLoader: DynamicModuleLoader) => ({
|
|
5
|
-
...getExecuteStoryActionProcessor(dynamicModuleLoader),
|
|
6
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './core';
|
package/src/index.ts
DELETED
package/src/lambdas/index.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { APIGatewayEvent, Context } from 'aws-lambda';
|
|
2
|
-
import { qpqWebServerUtils } from 'quidproquo-webserver';
|
|
3
|
-
import { createRuntime, askProcessEvent, ErrorTypeEnum } from 'quidproquo-core';
|
|
4
|
-
import { coreActionProcessor, webserverActionProcessor } from 'quidproquo-actionprocessor-node';
|
|
5
|
-
|
|
6
|
-
import { DynamicModuleLoader } from '../types/DynamicLoader';
|
|
7
|
-
import * as awsLambdaUtils from '../awsLambdaUtils';
|
|
8
|
-
import {
|
|
9
|
-
getAPIGatewayEventActionProcessor,
|
|
10
|
-
getSystemActionProcessor,
|
|
11
|
-
getFileActionProcessor,
|
|
12
|
-
getConfigGetSecretActionProcessor,
|
|
13
|
-
getConfigGetParameterActionProcessor,
|
|
14
|
-
getConfigGetParametersActionProcessor,
|
|
15
|
-
} from '../getActionProcessor';
|
|
16
|
-
|
|
17
|
-
import { lambdaRuntimeConfig, ActionProcessorListResolver } from './lambdaConfig';
|
|
18
|
-
|
|
19
|
-
// @ts-ignore - Special webpack loader
|
|
20
|
-
import qpqDynamicModuleLoader from 'qpq-dynamic-loader!';
|
|
21
|
-
|
|
22
|
-
// TODO: Make this a util or something based on server time or something..
|
|
23
|
-
const getDateNow = () => new Date().toISOString();
|
|
24
|
-
|
|
25
|
-
const ErrorTypeHttpResponseMap = {
|
|
26
|
-
[ErrorTypeEnum.BadRequest]: 400,
|
|
27
|
-
[ErrorTypeEnum.Unauthorized]: 401,
|
|
28
|
-
[ErrorTypeEnum.PaymentRequired]: 402,
|
|
29
|
-
[ErrorTypeEnum.Forbidden]: 403,
|
|
30
|
-
[ErrorTypeEnum.NotFound]: 404,
|
|
31
|
-
[ErrorTypeEnum.TimeOut]: 408,
|
|
32
|
-
[ErrorTypeEnum.UnsupportedMediaType]: 415,
|
|
33
|
-
[ErrorTypeEnum.OutOfResources]: 500,
|
|
34
|
-
[ErrorTypeEnum.GenericError]: 500,
|
|
35
|
-
[ErrorTypeEnum.NotImplemented]: 501,
|
|
36
|
-
[ErrorTypeEnum.NoContent]: 204,
|
|
37
|
-
[ErrorTypeEnum.Invalid]: 422,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const getAPIGatewayEventExecutor = (
|
|
41
|
-
dynamicModuleLoader: DynamicModuleLoader,
|
|
42
|
-
getCustomActionProcessors: ActionProcessorListResolver = () => ({}),
|
|
43
|
-
) => {
|
|
44
|
-
return async (event: APIGatewayEvent, context: Context) => {
|
|
45
|
-
// Build a processor for the session and stuff
|
|
46
|
-
// Remove the non route ones ~ let the story execute action add them
|
|
47
|
-
const storyActionProcessor = {
|
|
48
|
-
...coreActionProcessor,
|
|
49
|
-
...webserverActionProcessor,
|
|
50
|
-
|
|
51
|
-
...getAPIGatewayEventActionProcessor(lambdaRuntimeConfig.qpqConfig),
|
|
52
|
-
...getConfigGetSecretActionProcessor(lambdaRuntimeConfig),
|
|
53
|
-
...getConfigGetParameterActionProcessor(lambdaRuntimeConfig),
|
|
54
|
-
...getConfigGetParametersActionProcessor(lambdaRuntimeConfig),
|
|
55
|
-
...getSystemActionProcessor(dynamicModuleLoader),
|
|
56
|
-
...getFileActionProcessor(lambdaRuntimeConfig),
|
|
57
|
-
|
|
58
|
-
...getCustomActionProcessors(lambdaRuntimeConfig),
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const logger = async (result: any) => {
|
|
62
|
-
// addResult(
|
|
63
|
-
// envConfig.appName,
|
|
64
|
-
// getDateNow(),
|
|
65
|
-
// doWeCarePath,
|
|
66
|
-
// "route-infrastructure",
|
|
67
|
-
// "infrastructure",
|
|
68
|
-
// "askRoute",
|
|
69
|
-
// result
|
|
70
|
-
// );
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// // Run the callback
|
|
74
|
-
|
|
75
|
-
const resolveStory = createRuntime(
|
|
76
|
-
{},
|
|
77
|
-
storyActionProcessor,
|
|
78
|
-
getDateNow,
|
|
79
|
-
logger,
|
|
80
|
-
awsLambdaUtils.randomGuid,
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
const result = await resolveStory(askProcessEvent, [event, context]);
|
|
84
|
-
|
|
85
|
-
// Run the callback
|
|
86
|
-
if (!result.error) {
|
|
87
|
-
return {
|
|
88
|
-
statusCode: result.result.statusCode,
|
|
89
|
-
body: JSON.stringify(result.result.body),
|
|
90
|
-
headers: result.result.headers,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
console.log(JSON.stringify(result));
|
|
95
|
-
const code = ErrorTypeHttpResponseMap[result.error.errorType];
|
|
96
|
-
return {
|
|
97
|
-
statusCode: code || 500,
|
|
98
|
-
body: JSON.stringify(result.error),
|
|
99
|
-
headers: qpqWebServerUtils.getCorsHeaders(lambdaRuntimeConfig.qpqConfig, {}, event.headers),
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// Default executor
|
|
105
|
-
export const executeAPIGatewayEvent = getAPIGatewayEventExecutor(qpqDynamicModuleLoader);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ActionProcessorList } from 'quidproquo-core';
|
|
2
|
-
|
|
3
|
-
import { QPQAWSLambdaConfig } from '../runtimeConfig/QPQAWSLambdaConfig';
|
|
4
|
-
|
|
5
|
-
export const lambdaRuntimeConfig = JSON.parse(
|
|
6
|
-
process.env.lambdaRuntimeConfig || '{}',
|
|
7
|
-
) as QPQAWSLambdaConfig;
|
|
8
|
-
|
|
9
|
-
export type ActionProcessorListResolver = (
|
|
10
|
-
lambdaRuntimeConfig: QPQAWSLambdaConfig,
|
|
11
|
-
) => ActionProcessorList;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { EventBridgeEvent, Context } from 'aws-lambda';
|
|
2
|
-
import { createRuntime, askProcessEvent } from 'quidproquo-core';
|
|
3
|
-
import { coreActionProcessor, webserverActionProcessor } from 'quidproquo-actionprocessor-node';
|
|
4
|
-
|
|
5
|
-
import { DynamicModuleLoader } from '../types/DynamicLoader';
|
|
6
|
-
import * as awsLambdaUtils from '../awsLambdaUtils';
|
|
7
|
-
import {
|
|
8
|
-
getEventBridgeEventActionProcessor,
|
|
9
|
-
getSystemActionProcessor,
|
|
10
|
-
getFileActionProcessor,
|
|
11
|
-
getConfigGetSecretActionProcessor,
|
|
12
|
-
getConfigGetParameterActionProcessor,
|
|
13
|
-
getConfigGetParametersActionProcessor,
|
|
14
|
-
} from '../getActionProcessor';
|
|
15
|
-
|
|
16
|
-
import { lambdaRuntimeConfig, ActionProcessorListResolver } from './lambdaConfig';
|
|
17
|
-
|
|
18
|
-
// @ts-ignore - Special webpack loader
|
|
19
|
-
import qpqDynamicModuleLoader from 'qpq-dynamic-loader!';
|
|
20
|
-
|
|
21
|
-
// TODO: Make this a util or something based on server time or something..
|
|
22
|
-
const getDateNow = () => new Date().toISOString();
|
|
23
|
-
|
|
24
|
-
export const getEventBridgeEventExecutor = (
|
|
25
|
-
dynamicModuleLoader: DynamicModuleLoader,
|
|
26
|
-
getCustomActionProcessors: ActionProcessorListResolver = () => ({}),
|
|
27
|
-
) => {
|
|
28
|
-
return async (event: EventBridgeEvent<string, void>, context: Context) => {
|
|
29
|
-
// Build a processor for the session and stuff
|
|
30
|
-
// Remove the non event ones
|
|
31
|
-
const storyActionProcessor = {
|
|
32
|
-
...coreActionProcessor,
|
|
33
|
-
...webserverActionProcessor,
|
|
34
|
-
|
|
35
|
-
...getEventBridgeEventActionProcessor(lambdaRuntimeConfig),
|
|
36
|
-
...getSystemActionProcessor(dynamicModuleLoader),
|
|
37
|
-
...getFileActionProcessor(lambdaRuntimeConfig),
|
|
38
|
-
...getConfigGetSecretActionProcessor(lambdaRuntimeConfig),
|
|
39
|
-
...getConfigGetParameterActionProcessor(lambdaRuntimeConfig),
|
|
40
|
-
...getConfigGetParametersActionProcessor(lambdaRuntimeConfig),
|
|
41
|
-
|
|
42
|
-
...getCustomActionProcessors(lambdaRuntimeConfig),
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const logger = async (result: any) => {};
|
|
46
|
-
|
|
47
|
-
// Run the callback
|
|
48
|
-
const resolveStory = createRuntime(
|
|
49
|
-
{},
|
|
50
|
-
storyActionProcessor,
|
|
51
|
-
getDateNow,
|
|
52
|
-
logger,
|
|
53
|
-
awsLambdaUtils.randomGuid,
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
await resolveStory(askProcessEvent, [event, context]);
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export const executeEventBridgeEvent = getEventBridgeEventExecutor(qpqDynamicModuleLoader);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { SSMClient, GetParameterCommand } from '@aws-sdk/client-ssm';
|
|
2
|
-
|
|
3
|
-
const smClient = new SSMClient({});
|
|
4
|
-
|
|
5
|
-
export const getParameter = async (parameterName: string): Promise<string> => {
|
|
6
|
-
const response = await smClient.send(
|
|
7
|
-
new GetParameterCommand({
|
|
8
|
-
Name: parameterName,
|
|
9
|
-
}),
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
return response.Parameter?.Value || '';
|
|
13
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { SSMClient, GetParametersCommand } from '@aws-sdk/client-ssm';
|
|
2
|
-
|
|
3
|
-
const smClient = new SSMClient({});
|
|
4
|
-
|
|
5
|
-
export const getParameters = async (parameterNames: string[]): Promise<string[]> => {
|
|
6
|
-
const response = await smClient.send(
|
|
7
|
-
new GetParametersCommand({
|
|
8
|
-
Names: parameterNames,
|
|
9
|
-
}),
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
const resolvedParams = response.Parameters || [];
|
|
13
|
-
|
|
14
|
-
return parameterNames.map((pn) => resolvedParams.find((rp) => rp.Name == pn)?.Value || '');
|
|
15
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { DeleteObjectsCommand, DeleteObjectsCommandInput } from '@aws-sdk/client-s3';
|
|
2
|
-
|
|
3
|
-
import s3Client from './s3Client';
|
|
4
|
-
|
|
5
|
-
export const deleteFiles = async (drive: string, filepaths: string[]): Promise<string[]> => {
|
|
6
|
-
const bucketParams: DeleteObjectsCommandInput = {
|
|
7
|
-
Bucket: drive,
|
|
8
|
-
Delete: {
|
|
9
|
-
Quiet: true,
|
|
10
|
-
Objects: filepaths.map((fp) => ({ Key: fp })),
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const response = await s3Client.send(new DeleteObjectsCommand(bucketParams));
|
|
15
|
-
|
|
16
|
-
return (response.Errors || []).map((e) => e.Key || '');
|
|
17
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { ListObjectsV2Command, ListObjectsV2CommandInput } from '@aws-sdk/client-s3';
|
|
2
|
-
import { filePathDelimiter } from 'quidproquo-core';
|
|
3
|
-
import s3Client from './s3Client';
|
|
4
|
-
|
|
5
|
-
export interface S3FileInfo {
|
|
6
|
-
filepath: string;
|
|
7
|
-
isDir: boolean;
|
|
8
|
-
hashMd5?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface S3FileList {
|
|
12
|
-
fileInfos: S3FileInfo[];
|
|
13
|
-
pageToken?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const listFiles = async (
|
|
17
|
-
drive: string,
|
|
18
|
-
folder: string = '',
|
|
19
|
-
maxKeys: number = 1000,
|
|
20
|
-
pageToken?: string,
|
|
21
|
-
): Promise<S3FileList> => {
|
|
22
|
-
const validatedPrefix = `${folder}${
|
|
23
|
-
folder.endsWith(filePathDelimiter) || !folder ? '' : filePathDelimiter
|
|
24
|
-
}`;
|
|
25
|
-
const bucketParams: ListObjectsV2CommandInput = {
|
|
26
|
-
Bucket: drive,
|
|
27
|
-
Delimiter: filePathDelimiter,
|
|
28
|
-
Prefix: validatedPrefix,
|
|
29
|
-
ContinuationToken: pageToken,
|
|
30
|
-
MaxKeys: maxKeys,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// Declare truncated as a flag that the while loop is based on.
|
|
34
|
-
let files: S3FileInfo[] = [];
|
|
35
|
-
|
|
36
|
-
const response = await s3Client.send(new ListObjectsV2Command(bucketParams));
|
|
37
|
-
|
|
38
|
-
if (response.CommonPrefixes && !bucketParams.ContinuationToken) {
|
|
39
|
-
files = [
|
|
40
|
-
...files,
|
|
41
|
-
...response.CommonPrefixes.filter((cp) => !!cp.Prefix).map((cp) => ({
|
|
42
|
-
filepath: cp.Prefix!,
|
|
43
|
-
drive: drive,
|
|
44
|
-
isDir: true,
|
|
45
|
-
})),
|
|
46
|
-
];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
files = [
|
|
50
|
-
...files,
|
|
51
|
-
...(response.Contents || [])
|
|
52
|
-
.filter((c) => !!c.Key && c.Key != folder)
|
|
53
|
-
.map(
|
|
54
|
-
(item): S3FileInfo => ({
|
|
55
|
-
filepath: item.Key!,
|
|
56
|
-
isDir: item.Key!.endsWith(filePathDelimiter),
|
|
57
|
-
hashMd5: item.ETag,
|
|
58
|
-
}),
|
|
59
|
-
),
|
|
60
|
-
];
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
fileInfos: files,
|
|
64
|
-
pageToken: response.NextContinuationToken,
|
|
65
|
-
};
|
|
66
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { HeadObjectCommand } from '@aws-sdk/client-s3';
|
|
2
|
-
|
|
3
|
-
import s3Client from './s3Client';
|
|
4
|
-
|
|
5
|
-
export const objectExists = async (bucketName: string, key: string): Promise<boolean> => {
|
|
6
|
-
try {
|
|
7
|
-
const response = await s3Client.send(
|
|
8
|
-
new HeadObjectCommand({
|
|
9
|
-
Key: key,
|
|
10
|
-
Bucket: bucketName,
|
|
11
|
-
}),
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
return true;
|
|
15
|
-
} catch {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { GetObjectCommand } from '@aws-sdk/client-s3';
|
|
2
|
-
|
|
3
|
-
import s3Client from './s3Client';
|
|
4
|
-
|
|
5
|
-
export const readTextFile = async (bucketName: string, key: string): Promise<string> => {
|
|
6
|
-
const response = await s3Client.send(
|
|
7
|
-
new GetObjectCommand({
|
|
8
|
-
Key: key,
|
|
9
|
-
Bucket: bucketName,
|
|
10
|
-
}),
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
return (await response.Body?.transformToString()) || '';
|
|
14
|
-
};
|
package/src/logic/s3/s3Client.ts
DELETED
package/src/logic/s3/s3Utils.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { PutObjectCommand } from '@aws-sdk/client-s3';
|
|
2
|
-
|
|
3
|
-
import s3Client from './s3Client';
|
|
4
|
-
|
|
5
|
-
export const writeTextFile = async (
|
|
6
|
-
bucketName: string,
|
|
7
|
-
key: string,
|
|
8
|
-
data: string,
|
|
9
|
-
): Promise<void> => {
|
|
10
|
-
await s3Client.send(
|
|
11
|
-
new PutObjectCommand({
|
|
12
|
-
Key: key,
|
|
13
|
-
Bucket: bucketName,
|
|
14
|
-
Body: Buffer.from(data),
|
|
15
|
-
}),
|
|
16
|
-
);
|
|
17
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { SecretsManagerClient, GetSecretValueCommand } from '@aws-sdk/client-secrets-manager';
|
|
2
|
-
|
|
3
|
-
const smClient = new SecretsManagerClient({});
|
|
4
|
-
|
|
5
|
-
export const getSecret = async (secretName: string): Promise<string> => {
|
|
6
|
-
const response = await smClient.send(
|
|
7
|
-
new GetSecretValueCommand({
|
|
8
|
-
SecretId: secretName,
|
|
9
|
-
}),
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
return response.SecretString || '';
|
|
13
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { QPQConfig } from 'quidproquo-core';
|
|
2
|
-
export interface LambdaRuntimeConfig {
|
|
3
|
-
src: string;
|
|
4
|
-
runtime: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface QPQAWSLambdaConfig {
|
|
8
|
-
qpqConfig: QPQConfig;
|
|
9
|
-
|
|
10
|
-
resourceNameMap: Record<string, string>;
|
|
11
|
-
secretNameMap: Record<string, string>;
|
|
12
|
-
parameterNameMap: Record<string, string>;
|
|
13
|
-
|
|
14
|
-
lambdaRuntimeConfig?: LambdaRuntimeConfig;
|
|
15
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { QPQAWSLambdaConfig } from './QPQAWSLambdaConfig';
|
|
2
|
-
|
|
3
|
-
export const resolveResourceName = (
|
|
4
|
-
resourceName: string,
|
|
5
|
-
qpqAwsLambdaConfig: QPQAWSLambdaConfig,
|
|
6
|
-
) => {
|
|
7
|
-
return qpqAwsLambdaConfig.resourceNameMap[resourceName] || resourceName;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const resolveSecretKey = (secretName: string, qpqAwsLambdaConfig: QPQAWSLambdaConfig) => {
|
|
11
|
-
return qpqAwsLambdaConfig.secretNameMap[secretName] || secretName;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const resolveParameterKey = (
|
|
15
|
-
parameterName: string,
|
|
16
|
-
qpqAwsLambdaConfig: QPQAWSLambdaConfig,
|
|
17
|
-
) => {
|
|
18
|
-
return qpqAwsLambdaConfig.parameterNameMap[parameterName] || parameterName;
|
|
19
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type DynamicModuleLoader = (src: string) => Promise<any>;
|