quidproquo-actionprocessor-awslambda 0.0.16 → 0.0.18

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.
@@ -1,8 +1,9 @@
1
- import { QPQConfig } from 'quidproquo-core';
1
+ import { QPQConfig, EventTransformEventParamsActionPayload, EventTransformResponseResultActionPayload, EventMatchStoryActionPayload, EventAutoRespondActionPayload, StorySession } from 'quidproquo-core';
2
2
  import { RouteQPQWebServerConfigSetting, HTTPEventParams } from 'quidproquo-webserver';
3
+ import { Context } from 'aws-lambda';
3
4
  declare const _default: (config: QPQConfig) => {
4
- "@quidproquo-core/event/TransformEventParams": (payload: any, session: any) => Promise<HTTPEventParams<any>>;
5
- "@quidproquo-core/event/TransformResponseResult": (payload: any, session: any) => Promise<{
5
+ "@quidproquo-core/event/TransformEventParams": (payload: EventTransformEventParamsActionPayload<[import("aws-lambda").APIGatewayProxyEvent, Context]>, session: StorySession) => Promise<HTTPEventParams<any>>;
6
+ "@quidproquo-core/event/TransformResponseResult": (payload: EventTransformResponseResultActionPayload, session: StorySession) => Promise<{
6
7
  statusCode: any;
7
8
  body: any;
8
9
  headers: {
@@ -12,7 +13,7 @@ declare const _default: (config: QPQConfig) => {
12
13
  'Access-Control-Allow-Origin': string;
13
14
  };
14
15
  }>;
15
- "@quidproquo-core/event/AutoRespond": (payload: any, session: any) => Promise<{
16
+ "@quidproquo-core/event/AutoRespond": (payload: EventAutoRespondActionPayload<HTTPEventParams<any>>, session: StorySession) => Promise<{
16
17
  statusCode: number;
17
18
  headers: {
18
19
  'Content-Type': string;
@@ -21,6 +22,6 @@ declare const _default: (config: QPQConfig) => {
21
22
  'Access-Control-Allow-Origin': string;
22
23
  };
23
24
  } | null>;
24
- "@quidproquo-core/event/MatchStory": (payload: any, session: any) => Promise<RouteQPQWebServerConfigSetting | undefined>;
25
+ "@quidproquo-core/event/MatchStory": (payload: EventMatchStoryActionPayload<HTTPEventParams<any>>, session: StorySession) => Promise<RouteQPQWebServerConfigSetting | undefined>;
25
26
  };
26
27
  export default _default;
@@ -14,15 +14,15 @@ const quidproquo_webserver_1 = require("quidproquo-webserver");
14
14
  const awsLambdaUtils_1 = require("../../../awsLambdaUtils");
15
15
  const getProcessTransformEventParams = (appName) => {
16
16
  return (payload, session) => __awaiter(void 0, void 0, void 0, function* () {
17
- const { params: [event], } = payload;
18
- const path = (event.path || '').replace(new RegExp(`^(\/${appName})/`), '/');
17
+ const [apiGatewayEvent, context] = payload.eventParams;
18
+ const path = (apiGatewayEvent.path || '').replace(new RegExp(`^(\/${appName})/`), '/');
19
19
  return {
20
20
  path,
21
- query: Object.assign(Object.assign({}, (event.multiValueQueryStringParameters || {})), (event.queryStringParameters || {})),
22
- body: event.body ? JSON.parse(event.body) : undefined,
23
- headers: event.headers || {},
24
- method: event.httpMethod,
25
- correlation: (0, awsLambdaUtils_1.randomGuid)(),
21
+ query: Object.assign(Object.assign({}, (apiGatewayEvent.multiValueQueryStringParameters || {})), (apiGatewayEvent.queryStringParameters || {})),
22
+ body: apiGatewayEvent.body ? JSON.parse(apiGatewayEvent.body) : undefined,
23
+ headers: apiGatewayEvent.headers,
24
+ method: apiGatewayEvent.httpMethod,
25
+ correlation: context.awsRequestId,
26
26
  };
27
27
  });
28
28
  };
@@ -42,7 +42,7 @@ const getProcessTransformResponseResult = (domainName) => {
42
42
  };
43
43
  const getProcessAutoRespond = (domainName) => {
44
44
  return (payload, session) => __awaiter(void 0, void 0, void 0, function* () {
45
- if (payload.http === 'OPTIONS') {
45
+ if (payload.transformedEventParams.method === 'OPTIONS') {
46
46
  return {
47
47
  statusCode: 200,
48
48
  headers: {
@@ -60,7 +60,7 @@ const getProcessMatchStory = (routes) => (payload, session) => __awaiter(void 0,
60
60
  // Sort the routes by string length
61
61
  // Note: We may need to filter variable routes out {} as the variables are length independent
62
62
  const sortedRoutes = routes
63
- .filter((r) => r.method === payload.method)
63
+ .filter((r) => r.method === payload.transformedEventParams.method)
64
64
  .sort((a, b) => {
65
65
  if (a.path.length < b.path.length)
66
66
  return -1;
@@ -69,7 +69,7 @@ const getProcessMatchStory = (routes) => (payload, session) => __awaiter(void 0,
69
69
  return 0;
70
70
  });
71
71
  // Find the most relevant match
72
- return sortedRoutes.find((r) => (0, awsLambdaUtils_1.matchUrl)(r.path, payload.path).didMatch);
72
+ return sortedRoutes.find((r) => (0, awsLambdaUtils_1.matchUrl)(r.path, payload.transformedEventParams.path).didMatch);
73
73
  });
74
74
  exports.default = (config) => {
75
75
  const routes = quidproquo_webserver_1.qpqWebServerUtils.getAllRoutes(config);
@@ -1 +1,2 @@
1
1
  export { default as getAPIGatewayEventActionProcessor } from './event/getAPIGatewayEventActionProcessor';
2
+ export { default as getExecuteStoryActionProcessor } from './system/getExecuteStoryActionProcessor';
@@ -3,6 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getAPIGatewayEventActionProcessor = void 0;
6
+ exports.getExecuteStoryActionProcessor = exports.getAPIGatewayEventActionProcessor = void 0;
7
7
  var getAPIGatewayEventActionProcessor_1 = require("./event/getAPIGatewayEventActionProcessor");
8
8
  Object.defineProperty(exports, "getAPIGatewayEventActionProcessor", { enumerable: true, get: function () { return __importDefault(getAPIGatewayEventActionProcessor_1).default; } });
9
+ var getExecuteStoryActionProcessor_1 = require("./system/getExecuteStoryActionProcessor");
10
+ Object.defineProperty(exports, "getExecuteStoryActionProcessor", { enumerable: true, get: function () { return __importDefault(getExecuteStoryActionProcessor_1).default; } });
@@ -0,0 +1,6 @@
1
+ import { QPQConfig, SystemExecuteStoryActionPayload, StorySession } from 'quidproquo-core';
2
+ export declare const getDateNow: () => string;
3
+ declare const _default: (config: QPQConfig) => {
4
+ "@quidproquo-core/System/ExecuteStory": (payload: SystemExecuteStoryActionPayload<any[]>, session: StorySession) => Promise<any>;
5
+ };
6
+ export default _default;
@@ -0,0 +1,53 @@
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
+ exports.getDateNow = void 0;
13
+ const quidproquo_core_1 = require("quidproquo-core");
14
+ const getDateNow = () => new Date().toISOString();
15
+ exports.getDateNow = getDateNow;
16
+ const getProcessExecuteStory = (appName) => {
17
+ return (payload, session) => __awaiter(void 0, void 0, void 0, function* () {
18
+ // const module = require(payload.src);
19
+ // const story = module[payload.runtime];
20
+ // const logger = async (result: any) => {
21
+ // // return await addResult(service, getDateNow(), payload.params[0][0].path, 'user-route', payload.src, payload.runtime, result);
22
+ // };
23
+ // const actionProcessors = {
24
+ // ...coreActionProcessor,
25
+ // ...webserverActionProcessor,
26
+ // };
27
+ // const result = await resolveStory(
28
+ // story,
29
+ // payload.params,
30
+ // session,
31
+ // actionProcessors,
32
+ // getDateNow,
33
+ // logger,
34
+ // randomGuid,
35
+ // );
36
+ // return {
37
+ // result: result.result,
38
+ // session: result.session,
39
+ // };
40
+ // statusCode: payload.response.result.statusCode,
41
+ // body: payload.response.result.body,
42
+ return {
43
+ result: { statusCode: 200, body: { omg: 'wtf bbq' } },
44
+ session: {},
45
+ };
46
+ });
47
+ };
48
+ exports.default = (config) => {
49
+ const appName = quidproquo_core_1.qpqCoreUtils.getAppName(config);
50
+ return {
51
+ [quidproquo_core_1.SystemActionTypeEnum.ExecuteStory]: getProcessExecuteStory(appName),
52
+ };
53
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quidproquo-actionprocessor-awslambda",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.js",
@@ -29,6 +29,7 @@
29
29
  "quidproquo-webserver": "*"
30
30
  },
31
31
  "devDependencies": {
32
+ "@types/aws-lambda": "^8.10.109",
32
33
  "@types/node": "^18.11.9",
33
34
  "quidproquo-tsconfig": "*",
34
35
  "typescript": "^4.9.3"