quidproquo-actionprocessor-awslambda 0.0.133 → 0.0.135
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.
|
@@ -14,7 +14,7 @@ const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
|
14
14
|
const executeLambdaByName_1 = require("../../../logic/lambda/executeLambdaByName");
|
|
15
15
|
const awsNamingUtils_1 = require("../../../awsNamingUtils");
|
|
16
16
|
const getServiceFunctionExecuteActionProcessor = (qpqConfig) => {
|
|
17
|
-
return ({ functionName, service, payload, context }, session) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
return ({ functionName, service, payload, context, isAsync }, session) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
18
|
const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
19
19
|
const appName = quidproquo_core_1.qpqCoreUtils.getApplicationName(qpqConfig);
|
|
20
20
|
const environment = quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig);
|
|
@@ -25,7 +25,7 @@ const getServiceFunctionExecuteActionProcessor = (qpqConfig) => {
|
|
|
25
25
|
payload: payload,
|
|
26
26
|
storySession: Object.assign(Object.assign({}, session), { context }),
|
|
27
27
|
};
|
|
28
|
-
const result = yield (0, executeLambdaByName_1.executeLambdaByName)(awsFunctionName, region, serviceFunctionEvent);
|
|
28
|
+
const result = yield (0, executeLambdaByName_1.executeLambdaByName)(awsFunctionName, region, serviceFunctionEvent, isAsync);
|
|
29
29
|
if (result === null || result === void 0 ? void 0 : result.error) {
|
|
30
30
|
return (0, quidproquo_core_1.actionResultError)(result === null || result === void 0 ? void 0 : result.error.errorType, result === null || result === void 0 ? void 0 : result.error.errorText, `${service}::${functionName}: ${(result === null || result === void 0 ? void 0 : result.error.errorStack) || ''}`);
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const executeLambdaByName: <R>(functionName: string, region: string, payload: any) => Promise<R | undefined>;
|
|
1
|
+
export declare const executeLambdaByName: <R>(functionName: string, region: string, payload: any, isAsync: boolean) => Promise<R | undefined>;
|
|
@@ -11,24 +11,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.executeLambdaByName = void 0;
|
|
13
13
|
const client_lambda_1 = require("@aws-sdk/client-lambda");
|
|
14
|
-
const executeLambdaByName = (functionName, region, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
const executeLambdaByName = (functionName, region, payload, isAsync) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
15
|
const lambda = new client_lambda_1.LambdaClient({ region });
|
|
16
16
|
const encoder = new TextEncoder();
|
|
17
17
|
const encodedPayload = encoder.encode(JSON.stringify(payload));
|
|
18
18
|
const response = yield lambda.send(new client_lambda_1.InvokeCommand({
|
|
19
19
|
FunctionName: functionName,
|
|
20
20
|
Payload: encodedPayload,
|
|
21
|
-
InvocationType: 'RequestResponse',
|
|
21
|
+
InvocationType: isAsync ? 'Event' : 'RequestResponse',
|
|
22
22
|
}));
|
|
23
23
|
if (response.FunctionError) {
|
|
24
24
|
// Get more details about the error if available
|
|
25
25
|
const errorDetails = response.Payload ? new TextDecoder().decode(response.Payload) : '';
|
|
26
26
|
throw new Error(`Lambda Error: ${response.FunctionError}. Details: ${errorDetails}`);
|
|
27
27
|
}
|
|
28
|
-
if (response.Payload) {
|
|
28
|
+
if (!isAsync && response.Payload) {
|
|
29
29
|
const jsonString = new TextDecoder().decode(response.Payload);
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
if (jsonString) {
|
|
31
|
+
const object = JSON.parse(jsonString);
|
|
32
|
+
return object;
|
|
33
|
+
}
|
|
32
34
|
}
|
|
33
35
|
return undefined;
|
|
34
36
|
});
|