quidproquo-actionprocessor-awslambda 0.0.52 → 0.0.54
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/lib/awsLambdaUtils.d.ts +0 -2
- package/lib/awsLambdaUtils.js +1 -8
- package/lib/awsNamingUtils.d.ts +3 -0
- package/lib/awsNamingUtils.js +19 -0
- package/lib/getActionProcessor/core/config/getConfigGetParameterActionProcessor.js +1 -1
- package/lib/getActionProcessor/core/config/getConfigGetParametersActionProcessor.js +1 -1
- package/lib/getActionProcessor/core/config/getConfigGetSecretActionProcessor.js +1 -1
- package/lib/getActionProcessor/core/event/getAPIGatewayEventActionProcessor.js +4 -4
- package/lib/getActionProcessor/core/event/getCloudFrontOriginRequestEventActionProcessor.js +1 -1
- package/lib/getActionProcessor/core/file/getFileDeleteActionProcessor.js +1 -1
- package/lib/getActionProcessor/core/file/getFileExistsActionProcessor.js +1 -1
- package/lib/getActionProcessor/core/file/getFileListDirectoryActionProcessor.js +1 -1
- package/lib/getActionProcessor/core/file/getFileReadBinaryContentsActionProcessor.js +1 -1
- package/lib/getActionProcessor/core/file/getFileReadTextContentsActionProcessor.js +1 -1
- package/lib/getActionProcessor/core/file/getFileWriteBinaryContentsActionProcessor.js +1 -1
- package/lib/getActionProcessor/core/file/getFileWriteTextContentsActionProcessor.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/runtimeConfig/qpqAwsLambdaRuntimeConfigUtils.js +4 -4
- package/package.json +1 -1
package/lib/awsLambdaUtils.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { QPQConfig } from 'quidproquo-core';
|
|
2
1
|
export declare const randomGuid: () => string;
|
|
3
2
|
export interface UrlMatch {
|
|
4
3
|
didMatch: boolean;
|
|
5
4
|
params: Record<string, string> | null;
|
|
6
5
|
}
|
|
7
6
|
export declare const matchUrl: (path: string, url: string) => UrlMatch;
|
|
8
|
-
export declare const getRuntimeResourceName: (resourceName: string, qpqConfig: QPQConfig, resourceType?: string) => string;
|
package/lib/awsLambdaUtils.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.matchUrl = exports.randomGuid = void 0;
|
|
4
4
|
const crypto_1 = require("crypto");
|
|
5
5
|
const node_match_path_1 = require("node-match-path");
|
|
6
|
-
const quidproquo_core_1 = require("quidproquo-core");
|
|
7
6
|
const randomGuid = () => {
|
|
8
7
|
return (0, crypto_1.randomUUID)();
|
|
9
8
|
};
|
|
@@ -18,9 +17,3 @@ const matchUrl = (path, url) => {
|
|
|
18
17
|
};
|
|
19
18
|
};
|
|
20
19
|
exports.matchUrl = matchUrl;
|
|
21
|
-
const getRuntimeResourceName = (resourceName, qpqConfig, resourceType = '') => {
|
|
22
|
-
const service = quidproquo_core_1.qpqCoreUtils.getAppName(qpqConfig);
|
|
23
|
-
const environment = quidproquo_core_1.qpqCoreUtils.getAppFeature(qpqConfig);
|
|
24
|
-
return `${resourceName}-${service}-${environment}${resourceType}`;
|
|
25
|
-
};
|
|
26
|
-
exports.getRuntimeResourceName = getRuntimeResourceName;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { QPQConfig } from 'quidproquo-core';
|
|
2
|
+
export declare const getConfigRuntimeResourceName: (resourceName: string, qpqConfig: QPQConfig, resourceType?: string) => string;
|
|
3
|
+
export declare const getQpqRuntimeResourceName: (resourceName: string, qpqConfig: QPQConfig, resourceType?: string) => string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getQpqRuntimeResourceName = exports.getConfigRuntimeResourceName = void 0;
|
|
4
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
5
|
+
const getConfigRuntimeResourceName = (resourceName, qpqConfig, resourceType = '') => {
|
|
6
|
+
const service = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
7
|
+
const environment = quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig);
|
|
8
|
+
const feature = quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig);
|
|
9
|
+
if (feature) {
|
|
10
|
+
return `${resourceName}-${service}-${environment}-${feature}`;
|
|
11
|
+
}
|
|
12
|
+
return `${resourceName}-${service}-${environment}`;
|
|
13
|
+
};
|
|
14
|
+
exports.getConfigRuntimeResourceName = getConfigRuntimeResourceName;
|
|
15
|
+
const getQpqRuntimeResourceName = (resourceName, qpqConfig, resourceType = '') => {
|
|
16
|
+
const name = (0, exports.getConfigRuntimeResourceName)(resourceName, qpqConfig, resourceType);
|
|
17
|
+
return `${name}-qpq`;
|
|
18
|
+
};
|
|
19
|
+
exports.getQpqRuntimeResourceName = getQpqRuntimeResourceName;
|
|
@@ -15,7 +15,7 @@ const getParameter_1 = require("../../../logic/parametersManager/getParameter");
|
|
|
15
15
|
const getProcessConfigGetParameter = (qpqConfig) => {
|
|
16
16
|
return ({ parameterName }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
const awsParameterKey = (0, qpqAwsLambdaRuntimeConfigUtils_1.resolveParameterKey)(parameterName, qpqConfig);
|
|
18
|
-
const parameterValue = yield (0, getParameter_1.getParameter)(awsParameterKey, quidproquo_core_1.qpqCoreUtils.
|
|
18
|
+
const parameterValue = yield (0, getParameter_1.getParameter)(awsParameterKey, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig));
|
|
19
19
|
return (0, quidproquo_core_1.actionResult)(parameterValue);
|
|
20
20
|
});
|
|
21
21
|
};
|
|
@@ -15,7 +15,7 @@ const getParameters_1 = require("../../../logic/parametersManager/getParameters"
|
|
|
15
15
|
const getProcessConfigGetParameters = (qpqConfig) => {
|
|
16
16
|
return ({ parameterNames }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
const awsParameterKeys = parameterNames.map((pn) => (0, qpqAwsLambdaRuntimeConfigUtils_1.resolveParameterKey)(pn, qpqConfig));
|
|
18
|
-
const parameterValues = yield (0, getParameters_1.getParameters)(awsParameterKeys, quidproquo_core_1.qpqCoreUtils.
|
|
18
|
+
const parameterValues = yield (0, getParameters_1.getParameters)(awsParameterKeys, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig));
|
|
19
19
|
return (0, quidproquo_core_1.actionResult)(parameterValues);
|
|
20
20
|
});
|
|
21
21
|
};
|
|
@@ -15,7 +15,7 @@ const getSecret_1 = require("../../../logic/secretsManager/getSecret");
|
|
|
15
15
|
const getProcessConfigActionType = (qpqConfig) => {
|
|
16
16
|
return ({ secretName }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
const awsSecretKey = (0, qpqAwsLambdaRuntimeConfigUtils_1.resolveSecretKey)(secretName, qpqConfig);
|
|
18
|
-
const secretValue = yield (0, getSecret_1.getSecret)(awsSecretKey, quidproquo_core_1.qpqCoreUtils.
|
|
18
|
+
const secretValue = yield (0, getSecret_1.getSecret)(awsSecretKey, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig));
|
|
19
19
|
return (0, quidproquo_core_1.actionResult)(secretValue);
|
|
20
20
|
});
|
|
21
21
|
};
|
|
@@ -12,9 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
13
13
|
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
14
14
|
const awsLambdaUtils_1 = require("../../../awsLambdaUtils");
|
|
15
|
-
const getProcessTransformEventParams = (
|
|
15
|
+
const getProcessTransformEventParams = (serviceName) => {
|
|
16
16
|
return ({ eventParams: [apiGatewayEvent, context] }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
-
const path = (apiGatewayEvent.path || '').replace(new RegExp(`^(\/${
|
|
17
|
+
const path = (apiGatewayEvent.path || '').replace(new RegExp(`^(\/${serviceName})/`), '/');
|
|
18
18
|
return (0, quidproquo_core_1.actionResult)({
|
|
19
19
|
path,
|
|
20
20
|
query: Object.assign(Object.assign({}, (apiGatewayEvent.multiValueQueryStringParameters || {})), (apiGatewayEvent.queryStringParameters || {})),
|
|
@@ -84,9 +84,9 @@ const getProcessMatchStory = (routes) => {
|
|
|
84
84
|
};
|
|
85
85
|
exports.default = (config) => {
|
|
86
86
|
const routes = quidproquo_webserver_1.qpqWebServerUtils.getAllRoutes(config);
|
|
87
|
-
const
|
|
87
|
+
const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(config);
|
|
88
88
|
return {
|
|
89
|
-
[quidproquo_core_1.EventActionType.TransformEventParams]: getProcessTransformEventParams(
|
|
89
|
+
[quidproquo_core_1.EventActionType.TransformEventParams]: getProcessTransformEventParams(serviceName),
|
|
90
90
|
[quidproquo_core_1.EventActionType.TransformResponseResult]: getProcessTransformResponseResult(config),
|
|
91
91
|
[quidproquo_core_1.EventActionType.AutoRespond]: getProcessAutoRespond(config),
|
|
92
92
|
[quidproquo_core_1.EventActionType.MatchStory]: getProcessMatchStory(routes),
|
|
@@ -17,7 +17,7 @@ const getProcessTransformEventParams = (qpqConfig) => {
|
|
|
17
17
|
const cfRecordRequest = cloudFrontRequestEvent.Records[0].cf.request;
|
|
18
18
|
const headers = Object.keys(cfRecordRequest.headers).reduce((acc, header) => (Object.assign(Object.assign({}, acc), { [header]: cfRecordRequest.headers[header][0].value })), {});
|
|
19
19
|
return (0, quidproquo_core_1.actionResult)({
|
|
20
|
-
domain: quidproquo_webserver_1.qpqWebServerUtils.
|
|
20
|
+
domain: quidproquo_webserver_1.qpqWebServerUtils.getBaseDomainName(qpqConfig),
|
|
21
21
|
body: cfRecordRequest.body,
|
|
22
22
|
correlation: context.awsRequestId,
|
|
23
23
|
method: cfRecordRequest.method,
|
|
@@ -16,7 +16,7 @@ const s3Utils_1 = require("../../../logic/s3/s3Utils");
|
|
|
16
16
|
const getProcessFileDelete = (qpqConfig) => {
|
|
17
17
|
return ({ drive, filepaths }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
18
|
const s3BucketName = (0, qpqAwsLambdaRuntimeConfigUtils_1.resolveResourceName)(drive, qpqConfig);
|
|
19
|
-
const errored = yield (0, s3Utils_1.deleteFiles)(s3BucketName, filepaths, quidproquo_core_1.qpqCoreUtils.
|
|
19
|
+
const errored = yield (0, s3Utils_1.deleteFiles)(s3BucketName, filepaths, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig));
|
|
20
20
|
// errored deletes are a graceful success ~ Retry
|
|
21
21
|
// if (errored.length > 0) {
|
|
22
22
|
// return actionResultError(
|
|
@@ -15,7 +15,7 @@ const s3Utils_1 = require("../../../logic/s3/s3Utils");
|
|
|
15
15
|
const getProcessFileExists = (qpqConfig) => {
|
|
16
16
|
return ({ drive, filepath }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
const s3BucketName = (0, qpqAwsLambdaRuntimeConfigUtils_1.resolveResourceName)(drive, qpqConfig);
|
|
18
|
-
return (0, quidproquo_core_1.actionResult)(yield (0, s3Utils_1.objectExists)(s3BucketName, filepath, quidproquo_core_1.qpqCoreUtils.
|
|
18
|
+
return (0, quidproquo_core_1.actionResult)(yield (0, s3Utils_1.objectExists)(s3BucketName, filepath, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig)));
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
exports.default = (qpqConfig) => ({
|
|
@@ -15,7 +15,7 @@ const s3Utils_1 = require("../../../logic/s3/s3Utils");
|
|
|
15
15
|
const getProcessFileListDirectory = (qpqConfig) => {
|
|
16
16
|
return ({ drive, folderPath, maxFiles, pageToken }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
const s3BucketName = (0, qpqAwsLambdaRuntimeConfigUtils_1.resolveResourceName)(drive, qpqConfig);
|
|
18
|
-
const s3FileList = yield (0, s3Utils_1.listFiles)(s3BucketName, quidproquo_core_1.qpqCoreUtils.
|
|
18
|
+
const s3FileList = yield (0, s3Utils_1.listFiles)(s3BucketName, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig), folderPath, maxFiles, pageToken);
|
|
19
19
|
// Add the drive onto the list
|
|
20
20
|
const fileInfos = s3FileList.fileInfos.map((s3fi) => (Object.assign(Object.assign({}, s3fi), { drive: drive })));
|
|
21
21
|
return (0, quidproquo_core_1.actionResult)({
|
|
@@ -15,7 +15,7 @@ const s3Utils_1 = require("../../../logic/s3/s3Utils");
|
|
|
15
15
|
const getProcessFileReadBinaryContents = (qpqConfig) => {
|
|
16
16
|
return ({ drive, filepath }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
const s3BucketName = (0, qpqAwsLambdaRuntimeConfigUtils_1.resolveResourceName)(drive, qpqConfig);
|
|
18
|
-
return (0, quidproquo_core_1.actionResult)(yield (0, s3Utils_1.readBinaryFile)(s3BucketName, filepath, quidproquo_core_1.qpqCoreUtils.
|
|
18
|
+
return (0, quidproquo_core_1.actionResult)(yield (0, s3Utils_1.readBinaryFile)(s3BucketName, filepath, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig)));
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
exports.default = (qpqConfig) => ({
|
|
@@ -15,7 +15,7 @@ const s3Utils_1 = require("../../../logic/s3/s3Utils");
|
|
|
15
15
|
const getProcessFileReadTextContents = (qpqConfig) => {
|
|
16
16
|
return ({ drive, filepath }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
const s3BucketName = (0, qpqAwsLambdaRuntimeConfigUtils_1.resolveResourceName)(drive, qpqConfig);
|
|
18
|
-
return (0, quidproquo_core_1.actionResult)(yield (0, s3Utils_1.readTextFile)(s3BucketName, filepath, quidproquo_core_1.qpqCoreUtils.
|
|
18
|
+
return (0, quidproquo_core_1.actionResult)(yield (0, s3Utils_1.readTextFile)(s3BucketName, filepath, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig)));
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
exports.default = (qpqConfig) => ({
|
|
@@ -15,7 +15,7 @@ const s3Utils_1 = require("../../../logic/s3/s3Utils");
|
|
|
15
15
|
const getProcessFileWriteBinaryContents = (qpqConfig) => {
|
|
16
16
|
return ({ drive, filepath, data }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
const s3BucketName = (0, qpqAwsLambdaRuntimeConfigUtils_1.resolveResourceName)(drive, qpqConfig);
|
|
18
|
-
yield (0, s3Utils_1.writeBinaryFile)(s3BucketName, filepath, data, quidproquo_core_1.qpqCoreUtils.
|
|
18
|
+
yield (0, s3Utils_1.writeBinaryFile)(s3BucketName, filepath, data, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig));
|
|
19
19
|
return (0, quidproquo_core_1.actionResult)(void 0);
|
|
20
20
|
});
|
|
21
21
|
};
|
|
@@ -15,7 +15,7 @@ const s3Utils_1 = require("../../../logic/s3/s3Utils");
|
|
|
15
15
|
const getProcessFileWriteTextContents = (qpqConfig) => {
|
|
16
16
|
return ({ drive, filepath, data }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
const s3BucketName = (0, qpqAwsLambdaRuntimeConfigUtils_1.resolveResourceName)(drive, qpqConfig);
|
|
18
|
-
yield (0, s3Utils_1.writeTextFile)(s3BucketName, filepath, data, quidproquo_core_1.qpqCoreUtils.
|
|
18
|
+
yield (0, s3Utils_1.writeTextFile)(s3BucketName, filepath, data, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig));
|
|
19
19
|
return (0, quidproquo_core_1.actionResult)(void 0);
|
|
20
20
|
});
|
|
21
21
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './getActionProcessor';
|
|
2
2
|
export * as awsLambdaUtils from './awsLambdaUtils';
|
|
3
|
+
export * as awsNamingUtils from './awsNamingUtils';
|
|
3
4
|
export * from './runtimeConfig/QPQAWSResourceMap';
|
|
4
5
|
export * from './types/DynamicLoader';
|
|
5
6
|
export * from './logic/parametersManager/getParameter';
|
package/lib/index.js
CHANGED
|
@@ -26,9 +26,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.awsLambdaUtils = void 0;
|
|
29
|
+
exports.awsNamingUtils = exports.awsLambdaUtils = void 0;
|
|
30
30
|
__exportStar(require("./getActionProcessor"), exports);
|
|
31
31
|
exports.awsLambdaUtils = __importStar(require("./awsLambdaUtils"));
|
|
32
|
+
exports.awsNamingUtils = __importStar(require("./awsNamingUtils"));
|
|
32
33
|
__exportStar(require("./runtimeConfig/QPQAWSResourceMap"), exports);
|
|
33
34
|
__exportStar(require("./types/DynamicLoader"), exports);
|
|
34
35
|
__exportStar(require("./logic/parametersManager/getParameter"), exports);
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveParameterKey = exports.resolveSecretKey = exports.resolveResourceName = void 0;
|
|
4
|
-
const
|
|
4
|
+
const awsNamingUtils_1 = require("../awsNamingUtils");
|
|
5
5
|
const resolveResourceName = (resourceName, qpqConfig) => {
|
|
6
|
-
return (0,
|
|
6
|
+
return (0, awsNamingUtils_1.getConfigRuntimeResourceName)(resourceName, qpqConfig);
|
|
7
7
|
};
|
|
8
8
|
exports.resolveResourceName = resolveResourceName;
|
|
9
9
|
const resolveSecretKey = (secretName, qpqConfig) => {
|
|
10
|
-
return (0,
|
|
10
|
+
return (0, awsNamingUtils_1.getConfigRuntimeResourceName)(secretName, qpqConfig);
|
|
11
11
|
};
|
|
12
12
|
exports.resolveSecretKey = resolveSecretKey;
|
|
13
13
|
const resolveParameterKey = (parameterName, qpqConfig) => {
|
|
14
|
-
return (0,
|
|
14
|
+
return (0, awsNamingUtils_1.getConfigRuntimeResourceName)(parameterName, qpqConfig);
|
|
15
15
|
};
|
|
16
16
|
exports.resolveParameterKey = resolveParameterKey;
|