quidproquo-deploy-awscdk 0.0.31 → 0.0.32
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/lambdas/index.d.ts +3 -0
- package/lib/lambdas/index.js +19 -0
- package/lib/lambdas/lambdaAPIGatewayEvent.d.ts +13 -0
- package/lib/lambdas/lambdaAPIGatewayEvent.js +77 -0
- package/lib/lambdas/lambdaConfig.d.ts +4 -0
- package/lib/lambdas/lambdaConfig.js +4 -0
- package/lib/lambdas/lambdaEventBridgeEvent.d.ts +5 -0
- package/lib/lambdas/lambdaEventBridgeEvent.js +36 -0
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
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("./lambdaConfig"), exports);
|
|
18
|
+
__exportStar(require("./lambdaAPIGatewayEvent"), exports);
|
|
19
|
+
__exportStar(require("./lambdaEventBridgeEvent"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DynamicModuleLoader } from 'quidproquo-actionprocessor-awslambda';
|
|
2
|
+
import { Context } from 'aws-lambda';
|
|
3
|
+
import { ActionProcessorListResolver } from './lambdaConfig';
|
|
4
|
+
export declare const getAPIGatewayEventExecutor: (dynamicModuleLoader: DynamicModuleLoader, getCustomActionProcessors?: ActionProcessorListResolver) => (event: import("aws-lambda").APIGatewayProxyEvent, context: Context) => Promise<{
|
|
5
|
+
statusCode: any;
|
|
6
|
+
body: string;
|
|
7
|
+
headers: any;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const executeAPIGatewayEvent: (event: import("aws-lambda").APIGatewayProxyEvent, context: Context) => Promise<{
|
|
10
|
+
statusCode: any;
|
|
11
|
+
body: string;
|
|
12
|
+
headers: any;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.executeAPIGatewayEvent = exports.getAPIGatewayEventExecutor = void 0;
|
|
16
|
+
const quidproquo_actionprocessor_node_1 = require("quidproquo-actionprocessor-node");
|
|
17
|
+
const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocessor-awslambda");
|
|
18
|
+
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
19
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
20
|
+
const lambdaConfig_1 = require("./lambdaConfig");
|
|
21
|
+
// @ts-ignore - Special webpack loader
|
|
22
|
+
const qpq_dynamic_loader_1 = __importDefault(require("qpq-dynamic-loader!"));
|
|
23
|
+
// TODO: Make this a util or something based on server time or something..
|
|
24
|
+
const getDateNow = () => new Date().toISOString();
|
|
25
|
+
const ErrorTypeHttpResponseMap = {
|
|
26
|
+
[quidproquo_core_1.ErrorTypeEnum.BadRequest]: 400,
|
|
27
|
+
[quidproquo_core_1.ErrorTypeEnum.Unauthorized]: 401,
|
|
28
|
+
[quidproquo_core_1.ErrorTypeEnum.PaymentRequired]: 402,
|
|
29
|
+
[quidproquo_core_1.ErrorTypeEnum.Forbidden]: 403,
|
|
30
|
+
[quidproquo_core_1.ErrorTypeEnum.NotFound]: 404,
|
|
31
|
+
[quidproquo_core_1.ErrorTypeEnum.TimeOut]: 408,
|
|
32
|
+
[quidproquo_core_1.ErrorTypeEnum.UnsupportedMediaType]: 415,
|
|
33
|
+
[quidproquo_core_1.ErrorTypeEnum.OutOfResources]: 500,
|
|
34
|
+
[quidproquo_core_1.ErrorTypeEnum.GenericError]: 500,
|
|
35
|
+
[quidproquo_core_1.ErrorTypeEnum.NotImplemented]: 501,
|
|
36
|
+
[quidproquo_core_1.ErrorTypeEnum.NoContent]: 204,
|
|
37
|
+
[quidproquo_core_1.ErrorTypeEnum.Invalid]: 422,
|
|
38
|
+
};
|
|
39
|
+
const getAPIGatewayEventExecutor = (dynamicModuleLoader, getCustomActionProcessors = () => ({})) => {
|
|
40
|
+
return (event, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
// Build a processor for the session and stuff
|
|
42
|
+
// Remove the non route ones ~ let the story execute action add them
|
|
43
|
+
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getAPIGatewayEventActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParametersActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), getCustomActionProcessors(lambdaConfig_1.lambdaRuntimeConfig));
|
|
44
|
+
const logger = (result) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
// addResult(
|
|
46
|
+
// envConfig.appName,
|
|
47
|
+
// getDateNow(),
|
|
48
|
+
// doWeCarePath,
|
|
49
|
+
// "route-infrastructure",
|
|
50
|
+
// "infrastructure",
|
|
51
|
+
// "askRoute",
|
|
52
|
+
// result
|
|
53
|
+
// );
|
|
54
|
+
});
|
|
55
|
+
// // Run the callback
|
|
56
|
+
const resolveStory = (0, quidproquo_core_1.createRuntime)({}, storyActionProcessor, getDateNow, logger, quidproquo_actionprocessor_awslambda_1.awsLambdaUtils.randomGuid);
|
|
57
|
+
const result = yield resolveStory(quidproquo_core_1.askProcessEvent, [event, context]);
|
|
58
|
+
// Run the callback
|
|
59
|
+
if (!result.error) {
|
|
60
|
+
return {
|
|
61
|
+
statusCode: result.result.statusCode,
|
|
62
|
+
body: JSON.stringify(result.result.body),
|
|
63
|
+
headers: result.result.headers,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
console.log(JSON.stringify(result));
|
|
67
|
+
const code = ErrorTypeHttpResponseMap[result.error.errorType];
|
|
68
|
+
return {
|
|
69
|
+
statusCode: code || 500,
|
|
70
|
+
body: JSON.stringify(result.error),
|
|
71
|
+
headers: quidproquo_webserver_1.qpqWebServerUtils.getCorsHeaders(lambdaConfig_1.lambdaRuntimeConfig.qpqConfig, {}, event.headers),
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
exports.getAPIGatewayEventExecutor = getAPIGatewayEventExecutor;
|
|
76
|
+
// Default executor
|
|
77
|
+
exports.executeAPIGatewayEvent = (0, exports.getAPIGatewayEventExecutor)(qpq_dynamic_loader_1.default);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ActionProcessorList } from 'quidproquo-core';
|
|
2
|
+
import { QPQAWSLambdaConfig } from 'quidproquo-actionprocessor-awslambda';
|
|
3
|
+
export declare const lambdaRuntimeConfig: QPQAWSLambdaConfig;
|
|
4
|
+
export type ActionProcessorListResolver = (lambdaRuntimeConfig: QPQAWSLambdaConfig) => ActionProcessorList;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DynamicModuleLoader } from 'quidproquo-actionprocessor-awslambda';
|
|
2
|
+
import { EventBridgeEvent, Context } from 'aws-lambda';
|
|
3
|
+
import { ActionProcessorListResolver } from './lambdaConfig';
|
|
4
|
+
export declare const getEventBridgeEventExecutor: (dynamicModuleLoader: DynamicModuleLoader, getCustomActionProcessors?: ActionProcessorListResolver) => (event: EventBridgeEvent<string, void>, context: Context) => Promise<void>;
|
|
5
|
+
export declare const executeEventBridgeEvent: (event: EventBridgeEvent<string, void>, context: Context) => Promise<void>;
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.executeEventBridgeEvent = exports.getEventBridgeEventExecutor = void 0;
|
|
16
|
+
const quidproquo_actionprocessor_node_1 = require("quidproquo-actionprocessor-node");
|
|
17
|
+
const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocessor-awslambda");
|
|
18
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
19
|
+
const lambdaConfig_1 = require("./lambdaConfig");
|
|
20
|
+
// @ts-ignore - Special webpack loader
|
|
21
|
+
const qpq_dynamic_loader_1 = __importDefault(require("qpq-dynamic-loader!"));
|
|
22
|
+
// TODO: Make this a util or something based on server time or something..
|
|
23
|
+
const getDateNow = () => new Date().toISOString();
|
|
24
|
+
const getEventBridgeEventExecutor = (dynamicModuleLoader, getCustomActionProcessors = () => ({})) => {
|
|
25
|
+
return (event, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
// Build a processor for the session and stuff
|
|
27
|
+
// Remove the non event ones
|
|
28
|
+
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getEventBridgeEventActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParametersActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), getCustomActionProcessors(lambdaConfig_1.lambdaRuntimeConfig));
|
|
29
|
+
const logger = (result) => __awaiter(void 0, void 0, void 0, function* () { });
|
|
30
|
+
// Run the callback
|
|
31
|
+
const resolveStory = (0, quidproquo_core_1.createRuntime)({}, storyActionProcessor, getDateNow, logger, quidproquo_actionprocessor_awslambda_1.awsLambdaUtils.randomGuid);
|
|
32
|
+
yield resolveStory(quidproquo_core_1.askProcessEvent, [event, context]);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
exports.getEventBridgeEventExecutor = getEventBridgeEventExecutor;
|
|
36
|
+
exports.executeEventBridgeEvent = (0, exports.getEventBridgeEventExecutor)(qpq_dynamic_loader_1.default);
|