quidproquo-actionprocessor-awslambda 0.0.243 → 0.0.245
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/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/getEventTransformResponseResultActionProcessor.d.ts +3 -1
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/getEventTransformResponseResultActionProcessor.js +17 -6
- package/lib/commonjs/getActionProcessor/core/system/getSystemExecuteStoryActionProcessor.js +3 -2
- package/lib/commonjs/lambdas/dynamicModuleLoader/dynamicModuleLoader.d.ts +2 -1
- package/lib/esm/getActionProcessor/core/event/apiGatwayEvent/websocket/getEventTransformResponseResultActionProcessor.d.ts +3 -1
- package/lib/esm/getActionProcessor/core/event/apiGatwayEvent/websocket/getEventTransformResponseResultActionProcessor.js +16 -6
- package/lib/esm/getActionProcessor/core/system/getSystemExecuteStoryActionProcessor.js +4 -3
- package/lib/esm/lambdas/dynamicModuleLoader/dynamicModuleLoader.d.ts +2 -1
- package/package.json +19 -19
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import { ActionProcessorListResolver } from 'quidproquo-core';
|
|
1
|
+
import { ActionProcessorListResolver, AskResponse, EventTransformResponseResultActionPayload } from 'quidproquo-core';
|
|
2
|
+
import { EventInput, EventOutput, InternalEventRecord } from './types';
|
|
3
|
+
export declare function askTransformResponseStory({ eventParams, qpqEventRecordResponses: [record], }: EventTransformResponseResultActionPayload<EventInput, InternalEventRecord>): AskResponse<EventOutput>;
|
|
2
4
|
export declare const getEventTransformResponseResultActionProcessor: ActionProcessorListResolver;
|
|
@@ -9,15 +9,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getEventTransformResponseResultActionProcessor = void 0;
|
|
12
|
+
exports.getEventTransformResponseResultActionProcessor = exports.askTransformResponseStory = void 0;
|
|
13
13
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
14
|
+
const awsLambdaUtils_1 = require("../../../../../awsLambdaUtils");
|
|
15
|
+
function* askTransformResponseStory({ eventParams, qpqEventRecordResponses: [record], }) {
|
|
16
|
+
if (!record.success) {
|
|
17
|
+
yield* (0, quidproquo_core_1.askLogCreate)(quidproquo_core_1.LogLevelEnum.Fatal, record.error.errorText, record.error.errorStack);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
statusCode: 500,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.askTransformResponseStory = askTransformResponseStory;
|
|
14
24
|
const getProcessTransformResponseResult = (qpqConfig) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
// Create a custom runtime for errored responses so we can log them out
|
|
26
|
+
const errorCustomImplementation = (0, quidproquo_core_1.getProcessCustomImplementation)(qpqConfig, askTransformResponseStory, 'Transform Errored Websocket Response', null, () => new Date().toISOString(), awsLambdaUtils_1.randomGuid);
|
|
27
|
+
return (payload, session, actionProcessors, logger, updateSession, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
if (payload.qpqEventRecordResponses.some((r) => !r.success)) {
|
|
29
|
+
// We only wan't to run this for errors, because a custom imp is slower then a regular imp
|
|
30
|
+
return yield errorCustomImplementation(payload, session, actionProcessors, logger, updateSession, dynamicModuleLoader);
|
|
19
31
|
}
|
|
20
|
-
// Transform back to api gateway
|
|
21
32
|
return (0, quidproquo_core_1.actionResult)({
|
|
22
33
|
statusCode: 200,
|
|
23
34
|
});
|
|
@@ -22,6 +22,7 @@ const getProcessExecuteStory = (qpqConfig) => {
|
|
|
22
22
|
if (!story) {
|
|
23
23
|
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `Unable to dynamically load: [${payload.runtime}]`);
|
|
24
24
|
}
|
|
25
|
+
const functionKey = (0, quidproquo_core_1.getUniqueKeyFromQpqFunctionRuntime)(payload.runtime);
|
|
25
26
|
const resolveStory = (0, quidproquo_core_1.createRuntime)(qpqConfig, {
|
|
26
27
|
context: ((_a = payload.storySession) === null || _a === void 0 ? void 0 : _a.context) || session.context,
|
|
27
28
|
depth: (((_b = payload.storySession) === null || _b === void 0 ? void 0 : _b.depth) || session.depth || 0) + 1,
|
|
@@ -29,10 +30,10 @@ const getProcessExecuteStory = (qpqConfig) => {
|
|
|
29
30
|
correlation: ((_d = payload.storySession) === null || _d === void 0 ? void 0 : _d.correlation) || session.correlation,
|
|
30
31
|
}, () => __awaiter(void 0, void 0, void 0, function* () { return actionProcessors; }), exports.getDateNow, logger,
|
|
31
32
|
// TODO: Share this logic.
|
|
32
|
-
`${moduleName}::${(0, awsLambdaUtils_1.randomGuid)()}`, quidproquo_core_1.QpqRuntimeType.EXECUTE_STORY, dynamicModuleLoader, [
|
|
33
|
+
`${moduleName}::${(0, awsLambdaUtils_1.randomGuid)()}`, quidproquo_core_1.QpqRuntimeType.EXECUTE_STORY, dynamicModuleLoader, [functionKey]);
|
|
33
34
|
const storyResult = yield resolveStory(story, payload.params);
|
|
34
35
|
if (storyResult.error) {
|
|
35
|
-
return (0, quidproquo_core_1.actionResultError)(storyResult.error.errorType, storyResult.error.errorText, storyResult.error.errorStack ? `${
|
|
36
|
+
return (0, quidproquo_core_1.actionResultError)(storyResult.error.errorType, storyResult.error.errorText, storyResult.error.errorStack ? `${functionKey} -> [${storyResult.error.errorStack}]` : functionKey);
|
|
36
37
|
}
|
|
37
38
|
return (0, quidproquo_core_1.actionResult)(storyResult.result);
|
|
38
39
|
});
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { QpqFunctionRuntime } from 'quidproquo-core';
|
|
2
|
+
export declare const dynamicModuleLoader: <T = any>(modulePath: QpqFunctionRuntime) => Promise<T>;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import { ActionProcessorListResolver } from 'quidproquo-core';
|
|
1
|
+
import { ActionProcessorListResolver, AskResponse, EventTransformResponseResultActionPayload } from 'quidproquo-core';
|
|
2
|
+
import { EventInput, EventOutput, InternalEventRecord } from './types';
|
|
3
|
+
export declare function askTransformResponseStory({ eventParams, qpqEventRecordResponses: [record], }: EventTransformResponseResultActionPayload<EventInput, InternalEventRecord>): AskResponse<EventOutput>;
|
|
2
4
|
export declare const getEventTransformResponseResultActionProcessor: ActionProcessorListResolver;
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
import { actionResult,
|
|
1
|
+
import { actionResult, askLogCreate, EventActionType, getProcessCustomImplementation, LogLevelEnum, } from 'quidproquo-core';
|
|
2
|
+
import { randomGuid } from '../../../../../awsLambdaUtils';
|
|
3
|
+
export function* askTransformResponseStory({ eventParams, qpqEventRecordResponses: [record], }) {
|
|
4
|
+
if (!record.success) {
|
|
5
|
+
yield* askLogCreate(LogLevelEnum.Fatal, record.error.errorText, record.error.errorStack);
|
|
6
|
+
}
|
|
7
|
+
return {
|
|
8
|
+
statusCode: 500,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
2
11
|
const getProcessTransformResponseResult = (qpqConfig) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
12
|
+
// Create a custom runtime for errored responses so we can log them out
|
|
13
|
+
const errorCustomImplementation = getProcessCustomImplementation(qpqConfig, askTransformResponseStory, 'Transform Errored Websocket Response', null, () => new Date().toISOString(), randomGuid);
|
|
14
|
+
return async (payload, session, actionProcessors, logger, updateSession, dynamicModuleLoader) => {
|
|
15
|
+
if (payload.qpqEventRecordResponses.some((r) => !r.success)) {
|
|
16
|
+
// We only wan't to run this for errors, because a custom imp is slower then a regular imp
|
|
17
|
+
return await errorCustomImplementation(payload, session, actionProcessors, logger, updateSession, dynamicModuleLoader);
|
|
7
18
|
}
|
|
8
|
-
// Transform back to api gateway
|
|
9
19
|
return actionResult({
|
|
10
20
|
statusCode: 200,
|
|
11
21
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { actionResult, actionResultError, createRuntime, ErrorTypeEnum, qpqCoreUtils, QpqRuntimeType, SystemActionType, } from 'quidproquo-core';
|
|
1
|
+
import { actionResult, actionResultError, createRuntime, ErrorTypeEnum, getUniqueKeyFromQpqFunctionRuntime, qpqCoreUtils, QpqRuntimeType, SystemActionType, } from 'quidproquo-core';
|
|
2
2
|
import { randomGuid } from '../../../awsLambdaUtils';
|
|
3
3
|
export const getDateNow = () => new Date().toISOString();
|
|
4
4
|
const getProcessExecuteStory = (qpqConfig) => {
|
|
@@ -8,6 +8,7 @@ const getProcessExecuteStory = (qpqConfig) => {
|
|
|
8
8
|
if (!story) {
|
|
9
9
|
return actionResultError(ErrorTypeEnum.NotFound, `Unable to dynamically load: [${payload.runtime}]`);
|
|
10
10
|
}
|
|
11
|
+
const functionKey = getUniqueKeyFromQpqFunctionRuntime(payload.runtime);
|
|
11
12
|
const resolveStory = createRuntime(qpqConfig, {
|
|
12
13
|
context: payload.storySession?.context || session.context,
|
|
13
14
|
depth: (payload.storySession?.depth || session.depth || 0) + 1,
|
|
@@ -15,10 +16,10 @@ const getProcessExecuteStory = (qpqConfig) => {
|
|
|
15
16
|
correlation: payload.storySession?.correlation || session.correlation,
|
|
16
17
|
}, async () => actionProcessors, getDateNow, logger,
|
|
17
18
|
// TODO: Share this logic.
|
|
18
|
-
`${moduleName}::${randomGuid()}`, QpqRuntimeType.EXECUTE_STORY, dynamicModuleLoader, [
|
|
19
|
+
`${moduleName}::${randomGuid()}`, QpqRuntimeType.EXECUTE_STORY, dynamicModuleLoader, [functionKey]);
|
|
19
20
|
const storyResult = await resolveStory(story, payload.params);
|
|
20
21
|
if (storyResult.error) {
|
|
21
|
-
return actionResultError(storyResult.error.errorType, storyResult.error.errorText, storyResult.error.errorStack ? `${
|
|
22
|
+
return actionResultError(storyResult.error.errorType, storyResult.error.errorText, storyResult.error.errorStack ? `${functionKey} -> [${storyResult.error.errorStack}]` : functionKey);
|
|
22
23
|
}
|
|
23
24
|
return actionResult(storyResult.result);
|
|
24
25
|
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { QpqFunctionRuntime } from 'quidproquo-core';
|
|
2
|
+
export declare const dynamicModuleLoader: <T = any>(modulePath: QpqFunctionRuntime) => Promise<T>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-actionprocessor-awslambda",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.245",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -32,21 +32,21 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/joe-coady/quidproquo#readme",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@aws-sdk/client-acm": "^3.
|
|
36
|
-
"@aws-sdk/client-api-gateway": "^3.
|
|
37
|
-
"@aws-sdk/client-apigatewaymanagementapi": "^3.
|
|
38
|
-
"@aws-sdk/client-cloudformation": "^3.
|
|
39
|
-
"@aws-sdk/client-cloudfront": "^3.
|
|
40
|
-
"@aws-sdk/client-cognito-identity-provider": "^3.
|
|
41
|
-
"@aws-sdk/client-dynamodb": "^3.
|
|
42
|
-
"@aws-sdk/client-lambda": "^3.
|
|
35
|
+
"@aws-sdk/client-acm": "^3.744.0",
|
|
36
|
+
"@aws-sdk/client-api-gateway": "^3.744.0",
|
|
37
|
+
"@aws-sdk/client-apigatewaymanagementapi": "^3.744.0",
|
|
38
|
+
"@aws-sdk/client-cloudformation": "^3.744.0",
|
|
39
|
+
"@aws-sdk/client-cloudfront": "^3.744.0",
|
|
40
|
+
"@aws-sdk/client-cognito-identity-provider": "^3.744.0",
|
|
41
|
+
"@aws-sdk/client-dynamodb": "^3.744.0",
|
|
42
|
+
"@aws-sdk/client-lambda": "^3.744.0",
|
|
43
43
|
"@aws-sdk/client-neptune": "^3.658.1",
|
|
44
|
-
"@aws-sdk/client-s3": "^3.
|
|
45
|
-
"@aws-sdk/client-secrets-manager": "^3.
|
|
46
|
-
"@aws-sdk/client-sns": "^3.
|
|
47
|
-
"@aws-sdk/client-sqs": "^3.
|
|
48
|
-
"@aws-sdk/client-ssm": "^3.
|
|
49
|
-
"@aws-sdk/s3-request-presigner": "^3.
|
|
44
|
+
"@aws-sdk/client-s3": "^3.744.0",
|
|
45
|
+
"@aws-sdk/client-secrets-manager": "^3.744.0",
|
|
46
|
+
"@aws-sdk/client-sns": "^3.744.0",
|
|
47
|
+
"@aws-sdk/client-sqs": "^3.744.0",
|
|
48
|
+
"@aws-sdk/client-ssm": "^3.744.0",
|
|
49
|
+
"@aws-sdk/s3-request-presigner": "^3.744.0",
|
|
50
50
|
"aws-jwt-verify": "^3.4.0",
|
|
51
51
|
"aws-sdk": "^2.1322.0",
|
|
52
52
|
"busboy": "^1.6.0",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"lodash": "^4.17.21",
|
|
56
56
|
"node-cache": "^5.1.2",
|
|
57
57
|
"node-match-path": "^0.6.3",
|
|
58
|
-
"quidproquo-config-aws": "0.0.
|
|
59
|
-
"quidproquo-core": "0.0.
|
|
60
|
-
"quidproquo-webserver": "0.0.
|
|
58
|
+
"quidproquo-config-aws": "0.0.245",
|
|
59
|
+
"quidproquo-core": "0.0.245",
|
|
60
|
+
"quidproquo-webserver": "0.0.245"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/aws-lambda": "^8.10.109",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@types/jsonwebtoken": "^9.0.2",
|
|
66
66
|
"@types/lodash": "^4.14.194",
|
|
67
67
|
"@types/node": "^18.11.9",
|
|
68
|
-
"quidproquo-tsconfig": "0.0.
|
|
68
|
+
"quidproquo-tsconfig": "0.0.245",
|
|
69
69
|
"typescript": "^4.9.3"
|
|
70
70
|
}
|
|
71
71
|
}
|