quidproquo-actionprocessor-awslambda 0.0.75 → 0.0.77
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/awsNamingUtils.d.ts +4 -0
- package/lib/awsNamingUtils.js +29 -1
- package/lib/getActionProcessor/core/event/getSQSEventRecordActionProcessor.d.ts +1 -1
- package/lib/getActionProcessor/core/event/getSQSEventRecordActionProcessor.js +7 -1
- package/lib/getActionProcessor/core/event/utils/isAuthValid.js +14 -3
- package/lib/getActionProcessor/core/eventBus/getQueueSendMessageActionProcessor.d.ts +6 -0
- package/lib/getActionProcessor/core/eventBus/getQueueSendMessageActionProcessor.js +27 -0
- package/lib/getActionProcessor/core/eventBus/index.d.ts +5 -0
- package/lib/getActionProcessor/core/eventBus/index.js +7 -0
- package/lib/getActionProcessor/core/index.d.ts +1 -0
- package/lib/getActionProcessor/core/index.js +3 -1
- package/lib/logic/apiGateway/getApiKeys.d.ts +2 -0
- package/lib/logic/apiGateway/getApiKeys.js +24 -0
- package/lib/logic/sns/publishMessage.d.ts +1 -0
- package/lib/logic/sns/publishMessage.js +42 -0
- package/package.json +10 -8
package/lib/awsNamingUtils.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { QPQConfig } from 'quidproquo-core';
|
|
2
|
+
export declare const getGlobalConfigRuntimeResourceName: (resourceName: string, application: string, environment: string, feature?: string) => string;
|
|
3
|
+
export declare const getGlobalQpqRuntimeResourceName: (resourceName: string, application: string, environment: string, feature?: string, resourceType?: string) => string;
|
|
2
4
|
export declare const getConfigRuntimeResourceName: (resourceName: string, application: string, service: string, environment: string, feature?: string) => string;
|
|
3
5
|
export declare const getConfigRuntimeResourceNameFromConfig: (resourceName: string, qpqConfig: QPQConfig) => string;
|
|
4
6
|
export declare const getQpqRuntimeResourceName: (resourceName: string, application: string, service: string, environment: string, feature?: string, resourceType?: string) => string;
|
|
5
7
|
export declare const getQpqRuntimeResourceNameFromConfig: (resourceName: string, qpqConfig: QPQConfig, resourceType?: string) => string;
|
|
6
8
|
export declare const getCFExportNameUserPoolIdFromConfig: (userDirectoryName: string, qpqConfig: QPQConfig, serviceOverride?: string, applicationOverride?: string) => string;
|
|
7
9
|
export declare const getCFExportNameUserPoolClientIdFromConfig: (userDirectoryName: string, qpqConfig: QPQConfig, serviceOverride?: string, applicationOverride?: string) => string;
|
|
10
|
+
export declare const getCFExportNameApiKeyIdFromConfig: (apiKeyName: string, qpqConfig: QPQConfig, serviceOverride?: string, applicationOverride?: string) => string;
|
|
11
|
+
export declare const getCFExportNameSnsTopicArnFromConfig: (eventBusName: string, qpqConfig: QPQConfig, applicationOverride?: string) => string;
|
package/lib/awsNamingUtils.js
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCFExportNameUserPoolClientIdFromConfig = exports.getCFExportNameUserPoolIdFromConfig = exports.getQpqRuntimeResourceNameFromConfig = exports.getQpqRuntimeResourceName = exports.getConfigRuntimeResourceNameFromConfig = exports.getConfigRuntimeResourceName = void 0;
|
|
3
|
+
exports.getCFExportNameSnsTopicArnFromConfig = exports.getCFExportNameApiKeyIdFromConfig = exports.getCFExportNameUserPoolClientIdFromConfig = exports.getCFExportNameUserPoolIdFromConfig = exports.getQpqRuntimeResourceNameFromConfig = exports.getQpqRuntimeResourceName = exports.getConfigRuntimeResourceNameFromConfig = exports.getConfigRuntimeResourceName = exports.getGlobalQpqRuntimeResourceName = exports.getGlobalConfigRuntimeResourceName = void 0;
|
|
4
4
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
5
|
+
const getGlobalConfigRuntimeResourceName = (resourceName, application, environment, feature) => {
|
|
6
|
+
const baseName = `${resourceName}-${application}-${environment}`;
|
|
7
|
+
if (feature) {
|
|
8
|
+
return `${baseName}-${feature}`;
|
|
9
|
+
}
|
|
10
|
+
return baseName;
|
|
11
|
+
};
|
|
12
|
+
exports.getGlobalConfigRuntimeResourceName = getGlobalConfigRuntimeResourceName;
|
|
13
|
+
const getGlobalQpqRuntimeResourceName = (resourceName, application, environment, feature, resourceType = '') => {
|
|
14
|
+
const name = (0, exports.getGlobalConfigRuntimeResourceName)(resourceName, application, environment, feature);
|
|
15
|
+
return `${name}-qpq${resourceType}`;
|
|
16
|
+
};
|
|
17
|
+
exports.getGlobalQpqRuntimeResourceName = getGlobalQpqRuntimeResourceName;
|
|
5
18
|
const getConfigRuntimeResourceName = (resourceName, application, service, environment, feature) => {
|
|
6
19
|
const baseName = `${resourceName}-${application}-${service}-${environment}`;
|
|
7
20
|
if (feature) {
|
|
@@ -47,3 +60,18 @@ const getCFExportNameUserPoolClientIdFromConfig = (userDirectoryName, qpqConfig,
|
|
|
47
60
|
return (0, exports.getQpqRuntimeResourceName)(userDirectoryName, application, service, environment, feature, 'user-pool-client-id-export');
|
|
48
61
|
};
|
|
49
62
|
exports.getCFExportNameUserPoolClientIdFromConfig = getCFExportNameUserPoolClientIdFromConfig;
|
|
63
|
+
const getCFExportNameApiKeyIdFromConfig = (apiKeyName, qpqConfig, serviceOverride, applicationOverride) => {
|
|
64
|
+
const application = applicationOverride || quidproquo_core_1.qpqCoreUtils.getApplicationName(qpqConfig);
|
|
65
|
+
const service = serviceOverride || quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
66
|
+
const environment = quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig);
|
|
67
|
+
const feature = quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig);
|
|
68
|
+
return (0, exports.getQpqRuntimeResourceName)(apiKeyName, application, service, environment, feature, 'api-key-id-export');
|
|
69
|
+
};
|
|
70
|
+
exports.getCFExportNameApiKeyIdFromConfig = getCFExportNameApiKeyIdFromConfig;
|
|
71
|
+
const getCFExportNameSnsTopicArnFromConfig = (eventBusName, qpqConfig, applicationOverride) => {
|
|
72
|
+
const application = applicationOverride || quidproquo_core_1.qpqCoreUtils.getApplicationName(qpqConfig);
|
|
73
|
+
const environment = quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig);
|
|
74
|
+
const feature = quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig);
|
|
75
|
+
return (0, exports.getGlobalQpqRuntimeResourceName)(eventBusName, application, environment, feature, 'sns-topic-arn-export');
|
|
76
|
+
};
|
|
77
|
+
exports.getCFExportNameSnsTopicArnFromConfig = getCFExportNameSnsTopicArnFromConfig;
|
|
@@ -7,7 +7,7 @@ export declare const getQueueConfigSetting: () => QueueQPQConfigSetting;
|
|
|
7
7
|
declare const _default: (qpqConfig: QPQConfig) => {
|
|
8
8
|
"@quidproquo-core/event/TransformEventParams": EventTransformEventParamsActionProcessor<[SQSRecord, Context], AnyQueueEvent>;
|
|
9
9
|
"@quidproquo-core/event/TransformResponseResult": EventTransformResponseResultActionProcessor<boolean, AnyQueueEvent, boolean>;
|
|
10
|
-
"@quidproquo-core/event/AutoRespond": EventAutoRespondActionProcessor<AnyQueueEvent, SqsEventMatchStoryResult,
|
|
10
|
+
"@quidproquo-core/event/AutoRespond": EventAutoRespondActionProcessor<AnyQueueEvent, SqsEventMatchStoryResult, boolean>;
|
|
11
11
|
"@quidproquo-core/event/MatchStory": EventMatchStoryActionProcessor<AnyQueueEvent, SqsEventMatchStoryResult>;
|
|
12
12
|
};
|
|
13
13
|
export default _default;
|
|
@@ -36,7 +36,8 @@ const getProcessTransformResponseResult = (configs) => {
|
|
|
36
36
|
};
|
|
37
37
|
const getProcessAutoRespond = () => {
|
|
38
38
|
return (payload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
|
|
39
|
+
// If we couldn't match and hasn't thrown error, we will just gracefully exit.
|
|
40
|
+
return (0, quidproquo_core_1.actionResult)(!payload.matchResult.src);
|
|
40
41
|
});
|
|
41
42
|
};
|
|
42
43
|
const getProcessMatchStory = (qpqConfig) => {
|
|
@@ -52,6 +53,11 @@ const getProcessMatchStory = (qpqConfig) => {
|
|
|
52
53
|
}))
|
|
53
54
|
.find((m) => m.match.didMatch);
|
|
54
55
|
if (!matchedQueueType) {
|
|
56
|
+
// If we have event bus subscriptions then we don't want to error if we can't match
|
|
57
|
+
// early exit will just exit gracefully
|
|
58
|
+
if (queueQPQConfigSetting.eventBusSubscriptions.length > 0) {
|
|
59
|
+
return (0, quidproquo_core_1.actionResult)({});
|
|
60
|
+
}
|
|
55
61
|
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `queue type not found ${payload.transformedEventParams.message.type}`);
|
|
56
62
|
}
|
|
57
63
|
const sourceEntry = queueQueueProcessors[matchedQueueType.queueType];
|
|
@@ -13,6 +13,7 @@ exports.isAuthValid = void 0;
|
|
|
13
13
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
14
14
|
const verifyJwt_1 = require("../../../../logic/cognito/verifyJwt");
|
|
15
15
|
const getExportedValue_1 = require("../../../../logic/cloudformation/getExportedValue");
|
|
16
|
+
const getApiKeys_1 = require("../../../../logic/apiGateway/getApiKeys");
|
|
16
17
|
const awsNamingUtils_1 = require("../../../../awsNamingUtils");
|
|
17
18
|
const isAuthValidForCognito = (qpqConfig, authSettings, authHeader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
19
|
// If there are no auth settings ~ Its valid.
|
|
@@ -38,12 +39,22 @@ const isAuthValidForCognito = (qpqConfig, authSettings, authHeader) => __awaiter
|
|
|
38
39
|
// Verify the token
|
|
39
40
|
return yield (0, verifyJwt_1.verifyJwt)(accessToken, userPoolId, userPoolClientId, 'access');
|
|
40
41
|
});
|
|
41
|
-
const isAuthValidForApiKeys = (authSettings, apiKeyHeader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
const isAuthValidForApiKeys = (qpqConfig, authSettings, apiKeyHeader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
43
|
const apiKeys = authSettings.apiKeys || [];
|
|
43
44
|
if (apiKeys.length === 0) {
|
|
44
45
|
return true;
|
|
45
46
|
}
|
|
46
|
-
const
|
|
47
|
+
const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
48
|
+
const application = quidproquo_core_1.qpqCoreUtils.getApplicationName(qpqConfig);
|
|
49
|
+
const service = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
50
|
+
const environment = quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig);
|
|
51
|
+
const feature = quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig);
|
|
52
|
+
const realApiKeys = yield (0, getApiKeys_1.getApiKeys)(region, ...apiKeys.map((apiKey) => {
|
|
53
|
+
const apiKeyApplication = apiKey.applicationName || application;
|
|
54
|
+
const apiKeyService = apiKey.serviceName || service;
|
|
55
|
+
return (0, awsNamingUtils_1.getConfigRuntimeResourceName)(apiKey.name, apiKeyApplication, apiKeyService, environment, feature);
|
|
56
|
+
}));
|
|
57
|
+
const index = realApiKeys.findIndex((apiKey) => apiKey.value === apiKeyHeader);
|
|
47
58
|
return index >= 0;
|
|
48
59
|
});
|
|
49
60
|
const isAuthValid = (qpqConfig, authHeader, apiKeyHeader, authSettings) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -52,7 +63,7 @@ const isAuthValid = (qpqConfig, authHeader, apiKeyHeader, authSettings) => __awa
|
|
|
52
63
|
return true;
|
|
53
64
|
}
|
|
54
65
|
const cognitoValid = yield isAuthValidForCognito(qpqConfig, authSettings, authHeader);
|
|
55
|
-
const authKeysValid = yield isAuthValidForApiKeys(authSettings, apiKeyHeader);
|
|
66
|
+
const authKeysValid = yield isAuthValidForApiKeys(qpqConfig, authSettings, apiKeyHeader);
|
|
56
67
|
return cognitoValid && authKeysValid;
|
|
57
68
|
});
|
|
58
69
|
exports.isAuthValid = isAuthValid;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { QPQConfig } from 'quidproquo-core';
|
|
2
|
+
import { EventBusSendMessageActionProcessor } from 'quidproquo-core';
|
|
3
|
+
declare const _default: (qpqConfig: QPQConfig) => {
|
|
4
|
+
"@quidproquo-core/EventBus/SendMessage": EventBusSendMessageActionProcessor<any>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
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_core_2 = require("quidproquo-core");
|
|
14
|
+
const publishMessage_1 = require("../../../logic/sns/publishMessage");
|
|
15
|
+
const getExportedValue_1 = require("../../../logic/cloudformation/getExportedValue");
|
|
16
|
+
const awsNamingUtils_1 = require("../../../awsNamingUtils");
|
|
17
|
+
const getProcessEventBusSendMessage = (qpqConfig) => {
|
|
18
|
+
return ({ eventBusName, eventBusMessages }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
20
|
+
const topicArn = yield (0, getExportedValue_1.getExportedValue)((0, awsNamingUtils_1.getCFExportNameSnsTopicArnFromConfig)(eventBusName, qpqConfig), region);
|
|
21
|
+
yield (0, publishMessage_1.publishMessage)(topicArn, region, eventBusMessages.map((message) => JSON.stringify(message)));
|
|
22
|
+
return (0, quidproquo_core_2.actionResult)(void 0);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
exports.default = (qpqConfig) => ({
|
|
26
|
+
[quidproquo_core_2.EventBusActionType.SendMessages]: getProcessEventBusSendMessage(qpqConfig),
|
|
27
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
const getQueueSendMessageActionProcessor_1 = __importDefault(require("./getQueueSendMessageActionProcessor"));
|
|
7
|
+
exports.default = (qpqConfig) => (Object.assign({}, (0, getQueueSendMessageActionProcessor_1.default)(qpqConfig)));
|
|
@@ -9,3 +9,4 @@ export { default as getSystemActionProcessor } from './system';
|
|
|
9
9
|
export { default as getFileActionProcessor } from './file';
|
|
10
10
|
export { default as getQueueActionProcessor } from './queue';
|
|
11
11
|
export { default as getUserDirectoryActionProcessor } from './userDirectory';
|
|
12
|
+
export { default as getEventBusActionProcessor } from './eventBus';
|
|
@@ -3,7 +3,7 @@ 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.getUserDirectoryActionProcessor = exports.getQueueActionProcessor = exports.getFileActionProcessor = exports.getSystemActionProcessor = exports.getEventBridgeEventActionProcessor = exports.getSQSEventRecordActionProcessor = exports.getCloudFrontOriginRequestEventActionProcessor = exports.getAPIGatewayEventActionProcessor = exports.getConfigGetParametersActionProcessor = exports.getConfigGetParameterActionProcessor = exports.getConfigGetSecretActionProcessor = void 0;
|
|
6
|
+
exports.getEventBusActionProcessor = exports.getUserDirectoryActionProcessor = exports.getQueueActionProcessor = exports.getFileActionProcessor = exports.getSystemActionProcessor = exports.getEventBridgeEventActionProcessor = exports.getSQSEventRecordActionProcessor = exports.getCloudFrontOriginRequestEventActionProcessor = exports.getAPIGatewayEventActionProcessor = exports.getConfigGetParametersActionProcessor = exports.getConfigGetParameterActionProcessor = exports.getConfigGetSecretActionProcessor = void 0;
|
|
7
7
|
var getConfigGetSecretActionProcessor_1 = require("./config/getConfigGetSecretActionProcessor");
|
|
8
8
|
Object.defineProperty(exports, "getConfigGetSecretActionProcessor", { enumerable: true, get: function () { return __importDefault(getConfigGetSecretActionProcessor_1).default; } });
|
|
9
9
|
var getConfigGetParameterActionProcessor_1 = require("./config/getConfigGetParameterActionProcessor");
|
|
@@ -26,3 +26,5 @@ var queue_1 = require("./queue");
|
|
|
26
26
|
Object.defineProperty(exports, "getQueueActionProcessor", { enumerable: true, get: function () { return __importDefault(queue_1).default; } });
|
|
27
27
|
var userDirectory_1 = require("./userDirectory");
|
|
28
28
|
Object.defineProperty(exports, "getUserDirectoryActionProcessor", { enumerable: true, get: function () { return __importDefault(userDirectory_1).default; } });
|
|
29
|
+
var eventBus_1 = require("./eventBus");
|
|
30
|
+
Object.defineProperty(exports, "getEventBusActionProcessor", { enumerable: true, get: function () { return __importDefault(eventBus_1).default; } });
|
|
@@ -0,0 +1,24 @@
|
|
|
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.getApiKeys = void 0;
|
|
13
|
+
const client_api_gateway_1 = require("@aws-sdk/client-api-gateway");
|
|
14
|
+
const getApiKeys = (region, ...keyNames) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
var _a;
|
|
16
|
+
const apiGatewayClient = new client_api_gateway_1.APIGatewayClient({ region });
|
|
17
|
+
const input = {
|
|
18
|
+
includeValues: true,
|
|
19
|
+
limit: 500,
|
|
20
|
+
};
|
|
21
|
+
const res = yield apiGatewayClient.send(new client_api_gateway_1.GetApiKeysCommand(input));
|
|
22
|
+
return (((_a = res.items) === null || _a === void 0 ? void 0 : _a.filter((i) => keyNames.indexOf(i.name) >= 0).map((i) => ({ name: i.name, value: i.value, description: i.description }))) || []);
|
|
23
|
+
});
|
|
24
|
+
exports.getApiKeys = getApiKeys;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const publishMessage: (topicArn: string, region: string, messages: string[]) => Promise<void>;
|
|
@@ -0,0 +1,42 @@
|
|
|
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.publishMessage = void 0;
|
|
13
|
+
const client_sns_1 = require("@aws-sdk/client-sns");
|
|
14
|
+
const publishMessage = (topicArn, region, messages) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const sqsClient = new client_sns_1.SNSClient({
|
|
16
|
+
region,
|
|
17
|
+
});
|
|
18
|
+
// Convert them to entries
|
|
19
|
+
const entries = messages.map((message, index) => ({
|
|
20
|
+
Message: message,
|
|
21
|
+
Id: `${index}`,
|
|
22
|
+
// MessageAttributes: {
|
|
23
|
+
// type: {
|
|
24
|
+
// DataType: 'String',
|
|
25
|
+
// StringValue: JSON.parse(message).type,
|
|
26
|
+
// },
|
|
27
|
+
// },
|
|
28
|
+
}));
|
|
29
|
+
// now send them off in batches of 10
|
|
30
|
+
// We want to await incase of FIFO
|
|
31
|
+
// If you don't care about order, you can split and askParallel outside of this
|
|
32
|
+
while (entries.length > 0) {
|
|
33
|
+
// Not sure the max batch size, although the entire payload cant be bigger then 256 KB
|
|
34
|
+
// TODO: So maybe we should split based on payload sizes
|
|
35
|
+
const entriesBatch = entries.splice(0, 10);
|
|
36
|
+
yield sqsClient.send(new client_sns_1.PublishBatchCommand({
|
|
37
|
+
TopicArn: topicArn,
|
|
38
|
+
PublishBatchRequestEntries: entriesBatch,
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
exports.publishMessage = publishMessage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-actionprocessor-awslambda",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.77",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.js",
|
|
@@ -25,14 +25,16 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/joe-coady/quidproquo#readme",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aws-sdk/client-
|
|
29
|
-
"@aws-sdk/client-
|
|
30
|
-
"@aws-sdk/client-
|
|
31
|
-
"@aws-sdk/client-
|
|
32
|
-
"@aws-sdk/client-
|
|
33
|
-
"@aws-sdk/client-
|
|
28
|
+
"@aws-sdk/client-api-gateway": "^3.278.0",
|
|
29
|
+
"@aws-sdk/client-cloudformation": "^3.278.0",
|
|
30
|
+
"@aws-sdk/client-cognito-identity-provider": "^3.278.0",
|
|
31
|
+
"@aws-sdk/client-s3": "^3.278.0",
|
|
32
|
+
"@aws-sdk/client-secrets-manager": "^3.278.0",
|
|
33
|
+
"@aws-sdk/client-sns": "^3.279.0",
|
|
34
|
+
"@aws-sdk/client-sqs": "^3.278.0",
|
|
35
|
+
"@aws-sdk/client-ssm": "^3.278.0",
|
|
34
36
|
"aws-jwt-verify": "^3.4.0",
|
|
35
|
-
"aws-sdk": "^2.
|
|
37
|
+
"aws-sdk": "^2.1322.0",
|
|
36
38
|
"node-match-path": "^0.6.3",
|
|
37
39
|
"quidproquo-core": "*",
|
|
38
40
|
"quidproquo-webserver": "*"
|