quidproquo-actionprocessor-awslambda 0.0.198 → 0.0.199
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/api/autoRespond.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/api/autoRespond.js +47 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/api/getRecords.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/api/getRecords.js +47 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/api/getStorySession.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/api/getStorySession.js +22 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/api/index.d.ts +8 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/api/index.js +13 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/api/matchStory.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/api/matchStory.js +45 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/api/transformResponseResult.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/api/transformResponseResult.js +64 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/api/types.d.ts +10 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/api/types.js +2 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/index.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/index.js +18 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/autoRespond.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/autoRespond.js +22 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/getRecords.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/getRecords.js +38 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/getStorySession.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/getStorySession.js +22 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/index.d.ts +8 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/index.js +13 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/matchStory.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/matchStory.js +43 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/transformResponseResult.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/transformResponseResult.js +29 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/types.d.ts +16 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/types.js +5 -0
- package/lib/commonjs/getActionProcessor/core/event/cloudFrontOriginRequest/autoRespond.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/cloudFrontOriginRequest/autoRespond.js +22 -0
- package/lib/commonjs/getActionProcessor/core/event/cloudFrontOriginRequest/getRecords.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/cloudFrontOriginRequest/getRecords.js +39 -0
- package/lib/commonjs/getActionProcessor/core/event/cloudFrontOriginRequest/getStorySession.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/cloudFrontOriginRequest/getStorySession.js +22 -0
- package/lib/commonjs/getActionProcessor/core/event/cloudFrontOriginRequest/index.d.ts +8 -0
- package/lib/commonjs/getActionProcessor/core/event/cloudFrontOriginRequest/index.js +13 -0
- package/lib/commonjs/getActionProcessor/core/event/cloudFrontOriginRequest/matchStory.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/cloudFrontOriginRequest/matchStory.js +43 -0
- package/lib/commonjs/getActionProcessor/core/event/cloudFrontOriginRequest/transformResponseResult.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/cloudFrontOriginRequest/transformResponseResult.js +71 -0
- package/lib/commonjs/getActionProcessor/core/event/cloudFrontOriginRequest/types.d.ts +8 -0
- package/lib/commonjs/getActionProcessor/core/event/cloudFrontOriginRequest/types.js +2 -0
- package/lib/commonjs/getActionProcessor/core/event/cognitoCustomMessage/autoRespond.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/cognitoCustomMessage/autoRespond.js +46 -0
- package/lib/commonjs/getActionProcessor/core/event/cognitoCustomMessage/getRecords.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/cognitoCustomMessage/getRecords.js +45 -0
- package/lib/commonjs/getActionProcessor/core/event/cognitoCustomMessage/getStorySession.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/cognitoCustomMessage/getStorySession.js +22 -0
- package/lib/commonjs/getActionProcessor/core/event/cognitoCustomMessage/index.d.ts +8 -0
- package/lib/commonjs/getActionProcessor/core/event/cognitoCustomMessage/index.js +13 -0
- package/lib/commonjs/getActionProcessor/core/event/cognitoCustomMessage/matchStory.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/cognitoCustomMessage/matchStory.js +45 -0
- package/lib/commonjs/getActionProcessor/core/event/cognitoCustomMessage/transformResponseResult.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/cognitoCustomMessage/transformResponseResult.js +30 -0
- package/lib/commonjs/getActionProcessor/core/event/cognitoCustomMessage/types.d.ts +9 -0
- package/lib/commonjs/getActionProcessor/core/event/cognitoCustomMessage/types.js +4 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/deployStack/autoRespond.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/deployStack/autoRespond.js +26 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/deployStack/getRecords.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/deployStack/getRecords.js +44 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/deployStack/getStorySession.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/deployStack/getStorySession.js +22 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/deployStack/index.d.ts +8 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/deployStack/index.js +13 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/deployStack/matchStory.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/deployStack/matchStory.js +31 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/deployStack/transformResponseResult.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/deployStack/transformResponseResult.js +28 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/deployStack/types.d.ts +15 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/deployStack/types.js +2 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/index.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/index.js +18 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/recurringSchedule/autoRespond.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/recurringSchedule/autoRespond.js +22 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/recurringSchedule/getRecords.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/recurringSchedule/getRecords.js +27 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/recurringSchedule/getStorySession.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/recurringSchedule/getStorySession.js +22 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/recurringSchedule/index.d.ts +8 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/recurringSchedule/index.js +13 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/recurringSchedule/matchStory.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/recurringSchedule/matchStory.js +28 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/recurringSchedule/transformResponseResult.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/recurringSchedule/transformResponseResult.js +28 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/recurringSchedule/types.d.ts +7 -0
- package/lib/commonjs/getActionProcessor/core/event/eventBridgeEvent/recurringSchedule/types.js +2 -0
- package/lib/commonjs/getActionProcessor/core/event/index.d.ts +7 -0
- package/lib/commonjs/getActionProcessor/core/event/index.js +23 -0
- package/lib/commonjs/getActionProcessor/core/event/lambda/index.d.ts +1 -0
- package/lib/commonjs/getActionProcessor/core/event/lambda/index.js +17 -0
- package/lib/commonjs/getActionProcessor/core/event/lambda/serviceFunction/autoRespond.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/lambda/serviceFunction/autoRespond.js +22 -0
- package/lib/commonjs/getActionProcessor/core/event/lambda/serviceFunction/getRecords.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/lambda/serviceFunction/getRecords.js +26 -0
- package/lib/commonjs/getActionProcessor/core/event/lambda/serviceFunction/getStorySession.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/lambda/serviceFunction/getStorySession.js +22 -0
- package/lib/commonjs/getActionProcessor/core/event/lambda/serviceFunction/index.d.ts +8 -0
- package/lib/commonjs/getActionProcessor/core/event/lambda/serviceFunction/index.js +13 -0
- package/lib/commonjs/getActionProcessor/core/event/lambda/serviceFunction/matchStory.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/{getServiceFunctionExecuteEventActionProcessor.js → lambda/serviceFunction/matchStory.js} +3 -21
- package/lib/commonjs/getActionProcessor/core/event/lambda/serviceFunction/transformResponseResult.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/lambda/serviceFunction/transformResponseResult.js +25 -0
- package/lib/commonjs/getActionProcessor/core/event/lambda/serviceFunction/types.d.ts +11 -0
- package/lib/commonjs/getActionProcessor/core/event/lambda/serviceFunction/types.js +2 -0
- package/lib/commonjs/getActionProcessor/core/event/s3/fileEvent/autoRespond.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/s3/fileEvent/autoRespond.js +22 -0
- package/lib/commonjs/getActionProcessor/core/event/s3/fileEvent/getRecords.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/s3/fileEvent/getRecords.js +33 -0
- package/lib/commonjs/getActionProcessor/core/event/s3/fileEvent/getStorySession.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/s3/fileEvent/getStorySession.js +22 -0
- package/lib/commonjs/getActionProcessor/core/event/s3/fileEvent/index.d.ts +8 -0
- package/lib/commonjs/getActionProcessor/core/event/s3/fileEvent/index.js +13 -0
- package/lib/commonjs/getActionProcessor/core/event/s3/fileEvent/matchStory.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/s3/fileEvent/matchStory.js +23 -0
- package/lib/commonjs/getActionProcessor/core/event/s3/fileEvent/transformResponseResult.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/s3/fileEvent/transformResponseResult.js +28 -0
- package/lib/commonjs/getActionProcessor/core/event/s3/fileEvent/types.d.ts +10 -0
- package/lib/commonjs/getActionProcessor/core/event/s3/fileEvent/types.js +6 -0
- package/lib/commonjs/getActionProcessor/core/event/s3/index.d.ts +1 -0
- package/lib/commonjs/getActionProcessor/core/event/s3/index.js +17 -0
- package/lib/commonjs/getActionProcessor/core/event/sqs/index.d.ts +1 -0
- package/lib/commonjs/getActionProcessor/core/event/sqs/index.js +17 -0
- package/lib/commonjs/getActionProcessor/core/event/sqs/queue/autoRespond.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/sqs/queue/autoRespond.js +22 -0
- package/lib/commonjs/getActionProcessor/core/event/sqs/queue/getRecords.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/sqs/queue/getRecords.js +35 -0
- package/lib/commonjs/getActionProcessor/core/event/sqs/queue/getStorySession.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/sqs/queue/getStorySession.js +28 -0
- package/lib/commonjs/getActionProcessor/core/event/sqs/queue/index.d.ts +8 -0
- package/lib/commonjs/getActionProcessor/core/event/sqs/queue/index.js +13 -0
- package/lib/commonjs/getActionProcessor/core/event/sqs/queue/matchStory.d.ts +7 -0
- package/lib/commonjs/getActionProcessor/core/event/{getSQSEventRecordActionProcessor.js → sqs/queue/matchStory.js} +5 -28
- package/lib/commonjs/getActionProcessor/core/event/sqs/queue/transformResponseResult.d.ts +6 -0
- package/lib/commonjs/getActionProcessor/core/event/sqs/queue/transformResponseResult.js +35 -0
- package/lib/commonjs/getActionProcessor/core/event/sqs/queue/types.d.ts +12 -0
- package/lib/commonjs/getActionProcessor/core/event/sqs/queue/types.js +2 -0
- package/lib/commonjs/getActionProcessor/core/index.d.ts +1 -10
- package/lib/commonjs/getActionProcessor/core/index.js +16 -21
- package/lib/commonjs/getActionProcessor/core/system/getExecuteStoryActionProcessor.d.ts +1 -1
- package/lib/commonjs/getActionProcessor/core/system/getExecuteStoryActionProcessor.js +7 -1
- package/lib/commonjs/getActionProcessor/core/system/index.d.ts +1 -1
- package/lib/commonjs/getActionProcessor/webserver/serviceFunction/getServiceFunctionActionProcessor.js +6 -3
- package/package.json +5 -5
- package/lib/commonjs/getActionProcessor/core/event/getAPIGatewayEventActionProcessor.d.ts +0 -12
- package/lib/commonjs/getActionProcessor/core/event/getAPIGatewayEventActionProcessor.js +0 -127
- package/lib/commonjs/getActionProcessor/core/event/getCloudFrontOriginRequestEventActionProcessor.d.ts +0 -11
- package/lib/commonjs/getActionProcessor/core/event/getCloudFrontOriginRequestEventActionProcessor.js +0 -73
- package/lib/commonjs/getActionProcessor/core/event/getCustomResourceCloudflareDnsEventActionProcessor.d.ts +0 -12
- package/lib/commonjs/getActionProcessor/core/event/getCustomResourceCloudflareDnsEventActionProcessor.js +0 -80
- package/lib/commonjs/getActionProcessor/core/event/getEventBridgeEventActionProcessor.d.ts +0 -13
- package/lib/commonjs/getActionProcessor/core/event/getEventBridgeEventActionProcessor.js +0 -49
- package/lib/commonjs/getActionProcessor/core/event/getEventBridgeEventStackDeployActionProcessor.d.ts +0 -18
- package/lib/commonjs/getActionProcessor/core/event/getEventBridgeEventStackDeployActionProcessor.js +0 -75
- package/lib/commonjs/getActionProcessor/core/event/getLambdaCognitoCustomMessage.d.ts +0 -12
- package/lib/commonjs/getActionProcessor/core/event/getLambdaCognitoCustomMessage.js +0 -104
- package/lib/commonjs/getActionProcessor/core/event/getS3FileEventActionProcessor.d.ts +0 -12
- package/lib/commonjs/getActionProcessor/core/event/getS3FileEventActionProcessor.js +0 -54
- package/lib/commonjs/getActionProcessor/core/event/getSQSEventRecordActionProcessor.d.ts +0 -13
- package/lib/commonjs/getActionProcessor/core/event/getServiceFunctionExecuteEventActionProcessor.d.ts +0 -14
- package/lib/commonjs/getActionProcessor/core/event/getWebsocketAPIGatewayEventActionProcessor.d.ts +0 -22
- package/lib/commonjs/getActionProcessor/core/event/getWebsocketAPIGatewayEventActionProcessor.js +0 -82
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { QPQConfig, EventAutoRespondActionProcessor } from 'quidproquo-core';
|
|
2
|
+
import { MatchResult } from './types';
|
|
3
|
+
declare const _default: (qpqConfig: QPQConfig) => {
|
|
4
|
+
"@quidproquo-core/event/AutoRespond": EventAutoRespondActionProcessor<import("./types").AnyHTTPEvent, MatchResult, import("./types").AnyHTTPEventResponse>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,47 @@
|
|
|
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 quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
14
|
+
const isAuthValid_1 = require("../../utils/isAuthValid");
|
|
15
|
+
const getProcessAutoRespond = (qpqConfig) => {
|
|
16
|
+
return ({ qpqEventRecord, matchResult }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
var _a;
|
|
18
|
+
// Just auto respond for options requests
|
|
19
|
+
if (qpqEventRecord.method === 'OPTIONS') {
|
|
20
|
+
return (0, quidproquo_core_1.actionResult)({
|
|
21
|
+
status: 200,
|
|
22
|
+
isBase64Encoded: false,
|
|
23
|
+
body: '',
|
|
24
|
+
headers: quidproquo_webserver_1.qpqWebServerUtils.getCorsHeaders(qpqConfig, matchResult.config || {}, qpqEventRecord.headers),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
// TODO: We can pull out the jwt from the session if thats a better way?
|
|
28
|
+
// Think about that when you dont have covid.
|
|
29
|
+
const authValid = yield (0, isAuthValid_1.isAuthValid)(qpqConfig, quidproquo_webserver_1.qpqWebServerUtils.getHeaderValue('Authorization', qpqEventRecord.headers), quidproquo_webserver_1.qpqWebServerUtils.getHeaderValue('x-api-key', qpqEventRecord.headers), (_a = matchResult.config) === null || _a === void 0 ? void 0 : _a.routeAuthSettings);
|
|
30
|
+
if (!authValid) {
|
|
31
|
+
return (0, quidproquo_core_1.actionResult)({
|
|
32
|
+
status: 401,
|
|
33
|
+
isBase64Encoded: false,
|
|
34
|
+
body: JSON.stringify({
|
|
35
|
+
message: 'You are unauthorized to access this resource',
|
|
36
|
+
}),
|
|
37
|
+
headers: quidproquo_webserver_1.qpqWebServerUtils.getCorsHeaders(qpqConfig, matchResult.config || {}, qpqEventRecord.headers),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return (0, quidproquo_core_1.actionResult)(null);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
exports.default = (qpqConfig) => {
|
|
44
|
+
return {
|
|
45
|
+
[quidproquo_core_1.EventActionType.AutoRespond]: getProcessAutoRespond(qpqConfig),
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { QPQConfig, EventGetRecordsActionProcessor } from 'quidproquo-core';
|
|
2
|
+
import { EventInput } from './types';
|
|
3
|
+
declare const _default: (qpqConfig: QPQConfig) => {
|
|
4
|
+
"@quidproquo-core/Event/GetRecords": EventGetRecordsActionProcessor<EventInput, import("./types").AnyHTTPEvent>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,47 @@
|
|
|
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 quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
14
|
+
const parseMultipartFormData_1 = require("../../utils/parseMultipartFormData");
|
|
15
|
+
const getProcessGetRecords = (qpqConfig) => {
|
|
16
|
+
const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
17
|
+
return ({ eventParams: [apiGatewayEvent, context] }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
// Initialize `path` by removing the service name prefix from `apiGatewayEvent.path`.
|
|
19
|
+
// This adjustment is necessary because the API gateway routes requests to services based on
|
|
20
|
+
// a base path that includes the service name. By subtracting `serviceName.length + 1` from the
|
|
21
|
+
// substring method's start index, we effectively strip the leading `/<serviceName>` segment,
|
|
22
|
+
// accounting for the leading slash. This ensures `path` reflects the intended resource location
|
|
23
|
+
// after the service name. Defaults to '/' if `apiGatewayEvent.path` is not provided.
|
|
24
|
+
const path = (apiGatewayEvent.path || '/').substring(serviceName.length + 1);
|
|
25
|
+
const internalEventRecord = {
|
|
26
|
+
path,
|
|
27
|
+
query: Object.assign(Object.assign({}, (apiGatewayEvent.multiValueQueryStringParameters || {})), (apiGatewayEvent.queryStringParameters || {})),
|
|
28
|
+
body: apiGatewayEvent.body,
|
|
29
|
+
headers: apiGatewayEvent.headers,
|
|
30
|
+
method: apiGatewayEvent.httpMethod,
|
|
31
|
+
correlation: context.awsRequestId,
|
|
32
|
+
sourceIp: apiGatewayEvent.requestContext.identity.sourceIp,
|
|
33
|
+
isBase64Encoded: apiGatewayEvent.isBase64Encoded,
|
|
34
|
+
};
|
|
35
|
+
// Transform the body if its a multipart/form-data
|
|
36
|
+
if ((quidproquo_webserver_1.qpqWebServerUtils.getHeaderValue('Content-Type', apiGatewayEvent.headers) || '').startsWith('multipart/form-data') && apiGatewayEvent.body) {
|
|
37
|
+
internalEventRecord.files = yield (0, parseMultipartFormData_1.parseMultipartFormData)(apiGatewayEvent);
|
|
38
|
+
}
|
|
39
|
+
console.log(JSON.stringify(internalEventRecord, null, 2));
|
|
40
|
+
return (0, quidproquo_core_1.actionResult)([internalEventRecord]);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
exports.default = (qpqConfig) => {
|
|
44
|
+
return {
|
|
45
|
+
[quidproquo_core_1.EventActionType.GetRecords]: getProcessGetRecords(qpqConfig),
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { QPQConfig, EventGetStorySessionActionProcessor } from 'quidproquo-core';
|
|
2
|
+
import { EventInput } from './types';
|
|
3
|
+
declare const _default: (qpqConfig: QPQConfig) => {
|
|
4
|
+
"@quidproquo-core/event/GetStorySession": EventGetStorySessionActionProcessor<EventInput, import("./types").AnyHTTPEvent>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
@@ -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
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
13
|
+
const getProcessGetStorySession = (qpqConfig) => {
|
|
14
|
+
return ({ qpqEventRecord, eventParams }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
return (0, quidproquo_core_1.actionResult)(void 0);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
exports.default = (qpqConfig) => {
|
|
19
|
+
return {
|
|
20
|
+
[quidproquo_core_1.EventActionType.GetStorySession]: getProcessGetStorySession(qpqConfig),
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { QPQConfig } from 'quidproquo-core';
|
|
2
|
+
export declare const getApiGatewayApiEventEventProcessor: (qpqConfig: QPQConfig) => {
|
|
3
|
+
"@quidproquo-core/event/TransformResponseResult": import("quidproquo-core").EventTransformResponseResultActionProcessor<import("./types").EventInput, import("./types").AnyHTTPEventResponse, import("aws-lambda").APIGatewayProxyResult>;
|
|
4
|
+
"@quidproquo-core/event/AutoRespond": import("quidproquo-core").EventAutoRespondActionProcessor<import("./types").AnyHTTPEvent, import("./types").MatchResult, import("./types").AnyHTTPEventResponse>;
|
|
5
|
+
"@quidproquo-core/event/MatchStory": import("quidproquo-core").EventMatchStoryActionProcessor<import("./types").AnyHTTPEvent, import("./types").MatchResult>;
|
|
6
|
+
"@quidproquo-core/Event/GetRecords": import("quidproquo-core").EventGetRecordsActionProcessor<import("./types").EventInput, import("./types").AnyHTTPEvent>;
|
|
7
|
+
"@quidproquo-core/event/GetStorySession": import("quidproquo-core").EventGetStorySessionActionProcessor<import("./types").EventInput, import("./types").AnyHTTPEvent>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getApiGatewayApiEventEventProcessor = void 0;
|
|
7
|
+
const autoRespond_1 = __importDefault(require("./autoRespond"));
|
|
8
|
+
const getRecords_1 = __importDefault(require("./getRecords"));
|
|
9
|
+
const getStorySession_1 = __importDefault(require("./getStorySession"));
|
|
10
|
+
const matchStory_1 = __importDefault(require("./matchStory"));
|
|
11
|
+
const transformResponseResult_1 = __importDefault(require("./transformResponseResult"));
|
|
12
|
+
const getApiGatewayApiEventEventProcessor = (qpqConfig) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, getStorySession_1.default)(qpqConfig)), (0, getRecords_1.default)(qpqConfig)), (0, matchStory_1.default)(qpqConfig)), (0, autoRespond_1.default)(qpqConfig)), (0, transformResponseResult_1.default)(qpqConfig)));
|
|
13
|
+
exports.getApiGatewayApiEventEventProcessor = getApiGatewayApiEventEventProcessor;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EventMatchStoryActionProcessor, QPQConfig } from 'quidproquo-core';
|
|
2
|
+
import { MatchResult } from './types';
|
|
3
|
+
declare const _default: (qpqConfig: QPQConfig) => {
|
|
4
|
+
"@quidproquo-core/event/MatchStory": EventMatchStoryActionProcessor<import("./types").AnyHTTPEvent, MatchResult>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,45 @@
|
|
|
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 quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
14
|
+
const awsLambdaUtils_1 = require("../../../../../awsLambdaUtils");
|
|
15
|
+
const getProcessMatchStory = (qpqConfig) => {
|
|
16
|
+
const routes = quidproquo_webserver_1.qpqWebServerUtils.getAllRoutes(qpqConfig);
|
|
17
|
+
return ({ qpqEventRecord }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
// Sort the routes by string length
|
|
19
|
+
// Note: We may need to filter variable routes out {} as the variables are length independent
|
|
20
|
+
const routesWithNoOptions = routes.filter((r) => r.method === qpqEventRecord.method || qpqEventRecord.method === 'OPTIONS' || (qpqEventRecord.method === 'HEAD' && r.method === 'GET'));
|
|
21
|
+
// Find the most relevant match
|
|
22
|
+
const sortedRoutes = quidproquo_webserver_1.qpqWebServerUtils.sortPathMatchConfigs(routesWithNoOptions);
|
|
23
|
+
const matchedRoute = sortedRoutes
|
|
24
|
+
.map((r) => ({
|
|
25
|
+
match: (0, awsLambdaUtils_1.matchUrl)(r.path, qpqEventRecord.path),
|
|
26
|
+
route: r,
|
|
27
|
+
}))
|
|
28
|
+
.find((m) => m.match.didMatch);
|
|
29
|
+
if (!matchedRoute) {
|
|
30
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `route not found [${qpqEventRecord.path}] - [${quidproquo_webserver_1.qpqWebServerUtils.getHeaderValue('user-agent', qpqEventRecord.headers)}]`);
|
|
31
|
+
}
|
|
32
|
+
return (0, quidproquo_core_1.actionResult)({
|
|
33
|
+
src: matchedRoute.route.src,
|
|
34
|
+
runtime: matchedRoute.route.runtime,
|
|
35
|
+
runtimeOptions: matchedRoute.match.params || {},
|
|
36
|
+
// TODO: Make this aware of the API that we are eventing
|
|
37
|
+
config: quidproquo_webserver_1.qpqWebServerUtils.mergeAllRouteOptions('api', matchedRoute.route, qpqConfig),
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
exports.default = (qpqConfig) => {
|
|
42
|
+
return {
|
|
43
|
+
[quidproquo_core_1.EventActionType.MatchStory]: getProcessMatchStory(qpqConfig),
|
|
44
|
+
};
|
|
45
|
+
};
|
package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/api/transformResponseResult.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { QPQConfig, EventTransformResponseResultActionProcessor } from 'quidproquo-core';
|
|
2
|
+
import { EventInput } from './types';
|
|
3
|
+
declare const _default: (qpqConfig: QPQConfig) => {
|
|
4
|
+
"@quidproquo-core/event/TransformResponseResult": EventTransformResponseResultActionProcessor<EventInput, import("./types").AnyHTTPEventResponse, import("aws-lambda").APIGatewayProxyResult>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/api/transformResponseResult.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
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 quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
14
|
+
const ErrorTypeHttpResponseMap = {
|
|
15
|
+
[quidproquo_core_1.ErrorTypeEnum.BadRequest]: 400,
|
|
16
|
+
[quidproquo_core_1.ErrorTypeEnum.Unauthorized]: 401,
|
|
17
|
+
[quidproquo_core_1.ErrorTypeEnum.PaymentRequired]: 402,
|
|
18
|
+
[quidproquo_core_1.ErrorTypeEnum.Forbidden]: 403,
|
|
19
|
+
[quidproquo_core_1.ErrorTypeEnum.NotFound]: 404,
|
|
20
|
+
[quidproquo_core_1.ErrorTypeEnum.TimeOut]: 408,
|
|
21
|
+
[quidproquo_core_1.ErrorTypeEnum.Conflict]: 409,
|
|
22
|
+
[quidproquo_core_1.ErrorTypeEnum.UnsupportedMediaType]: 415,
|
|
23
|
+
[quidproquo_core_1.ErrorTypeEnum.OutOfResources]: 500,
|
|
24
|
+
[quidproquo_core_1.ErrorTypeEnum.GenericError]: 500,
|
|
25
|
+
[quidproquo_core_1.ErrorTypeEnum.NotImplemented]: 501,
|
|
26
|
+
[quidproquo_core_1.ErrorTypeEnum.NoContent]: 204,
|
|
27
|
+
[quidproquo_core_1.ErrorTypeEnum.Invalid]: 422,
|
|
28
|
+
};
|
|
29
|
+
const transformHttpEventHeadersToAPIGatewayProxyResultHeaders = (headers) => {
|
|
30
|
+
return Object.keys(headers)
|
|
31
|
+
.filter((header) => !!headers[header])
|
|
32
|
+
.reduce((acc, header) => (Object.assign(Object.assign({}, acc), { [header]: headers[header] })), {});
|
|
33
|
+
};
|
|
34
|
+
const getResponseFromErrorResult = (error) => {
|
|
35
|
+
const statusCode = ErrorTypeHttpResponseMap[error.errorType] || 500;
|
|
36
|
+
return quidproquo_webserver_1.qpqWebServerUtils.toJsonEventResponse({
|
|
37
|
+
errorType: error.errorType,
|
|
38
|
+
errorText: error.errorText,
|
|
39
|
+
}, statusCode);
|
|
40
|
+
};
|
|
41
|
+
const getProcessTransformResponseResult = (qpqConfig) => {
|
|
42
|
+
// We might need to JSON.stringify the body.
|
|
43
|
+
return ({ eventParams, qpqEventRecordResponses }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
const [apiGatewayEvent] = eventParams;
|
|
45
|
+
const [record] = qpqEventRecordResponses;
|
|
46
|
+
// If we have an error, we need to transform it to a response, otherwise we can just use the record as is
|
|
47
|
+
const successRecord = record.success ? record.result : getResponseFromErrorResult(record.error);
|
|
48
|
+
// Add the cors headers
|
|
49
|
+
const currentHeaders = successRecord.headers || {};
|
|
50
|
+
const headers = Object.assign(Object.assign({}, quidproquo_webserver_1.qpqWebServerUtils.getCorsHeaders(qpqConfig, {}, currentHeaders)), currentHeaders);
|
|
51
|
+
// Transform back to api gateway
|
|
52
|
+
return (0, quidproquo_core_1.actionResult)({
|
|
53
|
+
statusCode: successRecord.status,
|
|
54
|
+
body: apiGatewayEvent.httpMethod === 'HEAD' || !successRecord.body ? '' : successRecord.body,
|
|
55
|
+
isBase64Encoded: successRecord.isBase64Encoded,
|
|
56
|
+
headers: transformHttpEventHeadersToAPIGatewayProxyResultHeaders(headers),
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
exports.default = (qpqConfig) => {
|
|
61
|
+
return {
|
|
62
|
+
[quidproquo_core_1.EventActionType.TransformResponseResult]: getProcessTransformResponseResult(qpqConfig),
|
|
63
|
+
};
|
|
64
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HTTPEvent, HTTPEventResponse } from 'quidproquo-webserver';
|
|
2
|
+
import { APIGatewayEvent, Context, APIGatewayProxyResult } from 'aws-lambda';
|
|
3
|
+
import { MatchStoryResult } from 'quidproquo-core';
|
|
4
|
+
export type AnyHTTPEvent = HTTPEvent<any>;
|
|
5
|
+
export type AnyHTTPEventResponse = HTTPEventResponse<any>;
|
|
6
|
+
export type EventInput = [APIGatewayEvent, Context];
|
|
7
|
+
export type EventOutput = APIGatewayProxyResult;
|
|
8
|
+
export type InternalEventRecord = AnyHTTPEvent;
|
|
9
|
+
export type InternalEventOutput = AnyHTTPEventResponse;
|
|
10
|
+
export type MatchResult = MatchStoryResult<any, any>;
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./api"), exports);
|
|
18
|
+
__exportStar(require("./websocket"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { QPQConfig, EventAutoRespondActionProcessor } from 'quidproquo-core';
|
|
2
|
+
import { InternalEventRecord, MatchResult } from './types';
|
|
3
|
+
declare const _default: (qpqConfig: QPQConfig) => {
|
|
4
|
+
"@quidproquo-core/event/AutoRespond": EventAutoRespondActionProcessor<InternalEventRecord, MatchResult, void>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
@@ -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
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
13
|
+
const getProcessAutoRespond = (qpqConfig) => {
|
|
14
|
+
return ({ qpqEventRecord, matchResult }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
return (0, quidproquo_core_1.actionResult)(null);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
exports.default = (qpqConfig) => {
|
|
19
|
+
return {
|
|
20
|
+
[quidproquo_core_1.EventActionType.AutoRespond]: getProcessAutoRespond(qpqConfig),
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { QPQConfig, EventGetRecordsActionProcessor } from 'quidproquo-core';
|
|
2
|
+
import { EventInput, InternalEventRecord } from './types';
|
|
3
|
+
declare const _default: (qpqConfig: QPQConfig) => {
|
|
4
|
+
"@quidproquo-core/Event/GetRecords": EventGetRecordsActionProcessor<EventInput, InternalEventRecord>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,38 @@
|
|
|
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 quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
14
|
+
const awsToQoqEventTypeMap = {
|
|
15
|
+
MESSAGE: quidproquo_webserver_1.WebSocketEventType.Message,
|
|
16
|
+
CONNECT: quidproquo_webserver_1.WebSocketEventType.Connect,
|
|
17
|
+
DISCONNECT: quidproquo_webserver_1.WebSocketEventType.Disconnect,
|
|
18
|
+
};
|
|
19
|
+
const getProcessGetRecords = (qpqConfig) => {
|
|
20
|
+
return ({ eventParams: [websocketEvent, context] }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
const internalEventRecord = {
|
|
22
|
+
eventType: awsToQoqEventTypeMap[websocketEvent.requestContext.eventType],
|
|
23
|
+
messageId: websocketEvent.requestContext.messageId,
|
|
24
|
+
connectionId: websocketEvent.requestContext.connectionId,
|
|
25
|
+
requestTimeEpoch: websocketEvent.requestContext.requestTimeEpoch,
|
|
26
|
+
sourceIp: websocketEvent.requestContext.identity.sourceIp,
|
|
27
|
+
userAgent: websocketEvent.requestContext.identity.userAgent,
|
|
28
|
+
requestTime: new Date(websocketEvent.requestContext.requestTimeEpoch).toISOString(),
|
|
29
|
+
body: websocketEvent.body,
|
|
30
|
+
};
|
|
31
|
+
return (0, quidproquo_core_1.actionResult)([internalEventRecord]);
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
exports.default = (qpqConfig) => {
|
|
35
|
+
return {
|
|
36
|
+
[quidproquo_core_1.EventActionType.GetRecords]: getProcessGetRecords(qpqConfig),
|
|
37
|
+
};
|
|
38
|
+
};
|
package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/getStorySession.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { QPQConfig, EventGetStorySessionActionProcessor } from 'quidproquo-core';
|
|
2
|
+
import { EventInput, InternalEventRecord } from './types';
|
|
3
|
+
declare const _default: (qpqConfig: QPQConfig) => {
|
|
4
|
+
"@quidproquo-core/event/GetStorySession": EventGetStorySessionActionProcessor<EventInput, InternalEventRecord>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/getStorySession.js
ADDED
|
@@ -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
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
13
|
+
const getProcessGetStorySession = (qpqConfig) => {
|
|
14
|
+
return ({ qpqEventRecord, eventParams }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
return (0, quidproquo_core_1.actionResult)(void 0);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
exports.default = (qpqConfig) => {
|
|
19
|
+
return {
|
|
20
|
+
[quidproquo_core_1.EventActionType.GetStorySession]: getProcessGetStorySession(qpqConfig),
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { QPQConfig } from 'quidproquo-core';
|
|
2
|
+
export declare const getApiGatewayWebsocketEventEventProcessor: (qpqConfig: QPQConfig) => {
|
|
3
|
+
"@quidproquo-core/event/TransformResponseResult": import("quidproquo-core").EventTransformResponseResultActionProcessor<import("./types").EventInput, void, import("./types").EventOutput>;
|
|
4
|
+
"@quidproquo-core/event/AutoRespond": import("quidproquo-core").EventAutoRespondActionProcessor<import("./types").InternalEventRecord, import("./types").MatchResult, void>;
|
|
5
|
+
"@quidproquo-core/event/MatchStory": import("quidproquo-core").EventMatchStoryActionProcessor<import("./types").InternalEventRecord, import("./types").MatchResult>;
|
|
6
|
+
"@quidproquo-core/Event/GetRecords": import("quidproquo-core").EventGetRecordsActionProcessor<import("./types").EventInput, import("./types").InternalEventRecord>;
|
|
7
|
+
"@quidproquo-core/event/GetStorySession": import("quidproquo-core").EventGetStorySessionActionProcessor<import("./types").EventInput, import("./types").InternalEventRecord>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getApiGatewayWebsocketEventEventProcessor = void 0;
|
|
7
|
+
const autoRespond_1 = __importDefault(require("./autoRespond"));
|
|
8
|
+
const getRecords_1 = __importDefault(require("./getRecords"));
|
|
9
|
+
const matchStory_1 = __importDefault(require("./matchStory"));
|
|
10
|
+
const transformResponseResult_1 = __importDefault(require("./transformResponseResult"));
|
|
11
|
+
const getStorySession_1 = __importDefault(require("./getStorySession"));
|
|
12
|
+
const getApiGatewayWebsocketEventEventProcessor = (qpqConfig) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, getStorySession_1.default)(qpqConfig)), (0, getRecords_1.default)(qpqConfig)), (0, matchStory_1.default)(qpqConfig)), (0, autoRespond_1.default)(qpqConfig)), (0, transformResponseResult_1.default)(qpqConfig)));
|
|
13
|
+
exports.getApiGatewayWebsocketEventEventProcessor = getApiGatewayWebsocketEventEventProcessor;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EventMatchStoryActionProcessor, QPQConfig } from 'quidproquo-core';
|
|
2
|
+
import { InternalEventRecord, MatchResult } from './types';
|
|
3
|
+
declare const _default: (qpqConfig: QPQConfig) => {
|
|
4
|
+
"@quidproquo-core/event/MatchStory": EventMatchStoryActionProcessor<InternalEventRecord, MatchResult>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,43 @@
|
|
|
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 types_1 = require("./types");
|
|
14
|
+
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
15
|
+
const getProcessMatchStory = (qpqConfig) => {
|
|
16
|
+
const userDirectoryConfig = quidproquo_webserver_1.qpqWebServerUtils.getWebsocketEntryByApiName(types_1.GLOBAL_WEBSOCKET_API_NAME, qpqConfig);
|
|
17
|
+
return ({ qpqEventRecord }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
switch (qpqEventRecord.eventType) {
|
|
19
|
+
case quidproquo_webserver_1.WebSocketEventType.Connect:
|
|
20
|
+
return (0, quidproquo_core_1.actionResult)({
|
|
21
|
+
src: userDirectoryConfig.eventProcessors.onConnect.src,
|
|
22
|
+
runtime: userDirectoryConfig.eventProcessors.onConnect.runtime,
|
|
23
|
+
});
|
|
24
|
+
case quidproquo_webserver_1.WebSocketEventType.Disconnect:
|
|
25
|
+
return (0, quidproquo_core_1.actionResult)({
|
|
26
|
+
src: userDirectoryConfig.eventProcessors.onDisconnect.src,
|
|
27
|
+
runtime: userDirectoryConfig.eventProcessors.onDisconnect.runtime,
|
|
28
|
+
});
|
|
29
|
+
case quidproquo_webserver_1.WebSocketEventType.Message:
|
|
30
|
+
return (0, quidproquo_core_1.actionResult)({
|
|
31
|
+
src: userDirectoryConfig.eventProcessors.onMessage.src,
|
|
32
|
+
runtime: userDirectoryConfig.eventProcessors.onMessage.runtime,
|
|
33
|
+
});
|
|
34
|
+
default:
|
|
35
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `Websocket lambda not implemented for ${qpqEventRecord.eventType}`);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
exports.default = (qpqConfig) => {
|
|
40
|
+
return {
|
|
41
|
+
[quidproquo_core_1.EventActionType.MatchStory]: getProcessMatchStory(qpqConfig),
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { QPQConfig, EventTransformResponseResultActionProcessor } from 'quidproquo-core';
|
|
2
|
+
import { EventInput, EventOutput } from './types';
|
|
3
|
+
declare const _default: (qpqConfig: QPQConfig) => {
|
|
4
|
+
"@quidproquo-core/event/TransformResponseResult": EventTransformResponseResultActionProcessor<EventInput, void, EventOutput>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
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 getProcessTransformResponseResult = (qpqConfig) => {
|
|
14
|
+
return ({ eventParams, qpqEventRecordResponses }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const [record] = qpqEventRecordResponses;
|
|
16
|
+
if (!record.success) {
|
|
17
|
+
return (0, quidproquo_core_1.actionResultError)(record.error.errorType, record.error.errorText, record.error.errorStack);
|
|
18
|
+
}
|
|
19
|
+
// Transform back to api gateway
|
|
20
|
+
return (0, quidproquo_core_1.actionResult)({
|
|
21
|
+
statusCode: 200,
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
exports.default = (qpqConfig) => {
|
|
26
|
+
return {
|
|
27
|
+
[quidproquo_core_1.EventActionType.TransformResponseResult]: getProcessTransformResponseResult(qpqConfig),
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WebsocketEvent, WebsocketEventResponse } from 'quidproquo-webserver';
|
|
2
|
+
import { APIGatewayEventWebsocketRequestContextV2, APIGatewayProxyWebsocketEventV2WithRequestContext, Context, APIGatewayProxyResultV2 } from 'aws-lambda';
|
|
3
|
+
import { MatchStoryResult } from 'quidproquo-core';
|
|
4
|
+
type ApiGatwayEventWebsocketWithIdentity = APIGatewayProxyWebsocketEventV2WithRequestContext<APIGatewayEventWebsocketRequestContextV2 & {
|
|
5
|
+
identity: {
|
|
6
|
+
sourceIp: string;
|
|
7
|
+
userAgent: string;
|
|
8
|
+
};
|
|
9
|
+
}>;
|
|
10
|
+
export declare const GLOBAL_WEBSOCKET_API_NAME: string;
|
|
11
|
+
export type EventInput = [ApiGatwayEventWebsocketWithIdentity, Context];
|
|
12
|
+
export type EventOutput = APIGatewayProxyResultV2;
|
|
13
|
+
export type InternalEventRecord = WebsocketEvent<string | Blob | ArrayBuffer>;
|
|
14
|
+
export type InternalEventOutput = WebsocketEventResponse;
|
|
15
|
+
export type MatchResult = MatchStoryResult<any, any>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { QPQConfig, EventAutoRespondActionProcessor } from 'quidproquo-core';
|
|
2
|
+
import { InternalEventRecord, MatchResult } from './types';
|
|
3
|
+
declare const _default: (qpqConfig: QPQConfig) => {
|
|
4
|
+
"@quidproquo-core/event/AutoRespond": EventAutoRespondActionProcessor<InternalEventRecord, MatchResult, import("quidproquo-webserver").SeoEventResponse>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
@@ -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
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
13
|
+
const getProcessAutoRespond = (qpqConfig) => {
|
|
14
|
+
return () => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
return (0, quidproquo_core_1.actionResult)(null);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
exports.default = (qpqConfig) => {
|
|
19
|
+
return {
|
|
20
|
+
[quidproquo_core_1.EventActionType.AutoRespond]: getProcessAutoRespond(qpqConfig),
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { QPQConfig, EventGetRecordsActionProcessor } from 'quidproquo-core';
|
|
2
|
+
import { EventInput, InternalEventRecord } from './types';
|
|
3
|
+
declare const _default: (qpqConfig: QPQConfig) => {
|
|
4
|
+
"@quidproquo-core/Event/GetRecords": EventGetRecordsActionProcessor<EventInput, InternalEventRecord>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|