quidproquo-actionprocessor-awslambda 0.0.140 → 0.0.141
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/awsLambdaUtils.d.ts +3 -0
- package/lib/commonjs/awsLambdaUtils.js +23 -1
- package/lib/commonjs/awsNamingUtils.d.ts +1 -1
- package/lib/commonjs/awsNamingUtils.js +2 -4
- package/lib/commonjs/getActionProcessor/core/eventBus/getQueueSendMessageActionProcessor.js +7 -2
- package/lib/commonjs/getActionProcessor/core/file/getFileListDirectoryActionProcessor.js +1 -2
- package/lib/commonjs/getActionProcessor/core/file/getFileWriteBinaryContentsActionProcessor.js +3 -2
- package/lib/commonjs/getActionProcessor/core/file/getFileWriteTextContentsActionProcessor.js +3 -2
- package/lib/commonjs/getActionProcessor/core/file/utils/resolveStorageDriveBucketName.d.ts +2 -3
- package/lib/commonjs/getActionProcessor/core/file/utils/resolveStorageDriveBucketName.js +8 -12
- package/lib/commonjs/logic/s3/writeBinaryFile.d.ts +2 -1
- package/lib/commonjs/logic/s3/writeBinaryFile.js +2 -1
- package/lib/commonjs/logic/s3/writeTextFile.d.ts +2 -1
- package/lib/commonjs/logic/s3/writeTextFile.js +2 -1
- package/package.json +1 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { StorageClass } from '@aws-sdk/client-s3';
|
|
2
|
+
import { StorageDriveTier } from 'quidproquo-core';
|
|
1
3
|
export declare const randomGuid: () => `${string}-${string}-${string}-${string}-${string}`;
|
|
2
4
|
export interface UrlMatch {
|
|
3
5
|
didMatch: boolean;
|
|
4
6
|
params: Record<string, string> | null;
|
|
5
7
|
}
|
|
6
8
|
export declare const matchUrl: (path: string, url: string) => UrlMatch;
|
|
9
|
+
export declare const getS3BucketStorageClassFromStorageDriveTier: (driveTier?: StorageDriveTier) => keyof typeof StorageClass;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.matchUrl = exports.randomGuid = void 0;
|
|
3
|
+
exports.getS3BucketStorageClassFromStorageDriveTier = exports.matchUrl = exports.randomGuid = void 0;
|
|
4
4
|
const crypto_1 = require("crypto");
|
|
5
5
|
const node_match_path_1 = require("node-match-path");
|
|
6
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
6
7
|
const randomGuid = () => {
|
|
7
8
|
return (0, crypto_1.randomUUID)();
|
|
8
9
|
};
|
|
@@ -17,3 +18,24 @@ const matchUrl = (path, url) => {
|
|
|
17
18
|
};
|
|
18
19
|
};
|
|
19
20
|
exports.matchUrl = matchUrl;
|
|
21
|
+
const getS3BucketStorageClassFromStorageDriveTier = (driveTier) => {
|
|
22
|
+
switch (driveTier) {
|
|
23
|
+
case quidproquo_core_1.StorageDriveTier.REGULAR:
|
|
24
|
+
return "STANDARD";
|
|
25
|
+
case quidproquo_core_1.StorageDriveTier.OCCASIONAL_ACCESS:
|
|
26
|
+
return "STANDARD_IA";
|
|
27
|
+
case quidproquo_core_1.StorageDriveTier.SINGLE_ZONE_OCCASIONAL_ACCESS:
|
|
28
|
+
return "ONEZONE_IA";
|
|
29
|
+
case quidproquo_core_1.StorageDriveTier.COLD_STORAGE:
|
|
30
|
+
return "GLACIER";
|
|
31
|
+
case quidproquo_core_1.StorageDriveTier.COLD_STORAGE_INSTANT_ACCESS:
|
|
32
|
+
return "GLACIER_IR";
|
|
33
|
+
case quidproquo_core_1.StorageDriveTier.DEEP_COLD_STORAGE:
|
|
34
|
+
return "DEEP_ARCHIVE";
|
|
35
|
+
case quidproquo_core_1.StorageDriveTier.SMART_TIERING:
|
|
36
|
+
return "INTELLIGENT_TIERING";
|
|
37
|
+
default:
|
|
38
|
+
return "INTELLIGENT_TIERING";
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.getS3BucketStorageClassFromStorageDriveTier = getS3BucketStorageClassFromStorageDriveTier;
|
|
@@ -6,7 +6,7 @@ export declare const getConfigRuntimeResourceNameFromConfig: (resourceName: stri
|
|
|
6
6
|
export declare const getConfigRuntimeResourceNameFromConfigWithServiceOverride: (resourceName: string, qpqConfig: QPQConfig, serviceOverride?: string) => string;
|
|
7
7
|
export declare const getQpqRuntimeResourceName: (resourceName: string, application: string, service: string, environment: string, feature?: string, resourceType?: string) => string;
|
|
8
8
|
export declare const getQpqRuntimeResourceNameFromConfig: (resourceName: ResourceName, qpqConfig: QPQConfig, resourceType?: string) => string;
|
|
9
|
-
export declare const getKvsDynamoTableNameFromConfig: (resourceName:
|
|
9
|
+
export declare const getKvsDynamoTableNameFromConfig: (resourceName: string, qpqConfig: QPQConfig, resourceType?: string) => string;
|
|
10
10
|
export declare const getCFExportNameUserPoolIdFromConfig: (userDirectoryName: string, qpqConfig: QPQConfig, serviceOverride?: string, applicationOverride?: string) => string;
|
|
11
11
|
export declare const getCFExportNameUserPoolClientIdFromConfig: (userDirectoryName: string, qpqConfig: QPQConfig, serviceOverride?: string, applicationOverride?: string) => string;
|
|
12
12
|
export declare const getCFExportNameApiKeyIdFromConfig: (apiKeyName: string, qpqConfig: QPQConfig, serviceOverride?: string, applicationOverride?: string) => string;
|
|
@@ -57,14 +57,12 @@ exports.getQpqRuntimeResourceNameFromConfig = getQpqRuntimeResourceNameFromConfi
|
|
|
57
57
|
const getKvsDynamoTableNameFromConfig = (resourceName, qpqConfig, resourceType = '') => {
|
|
58
58
|
var _a;
|
|
59
59
|
const storeConfig = quidproquo_core_1.qpqCoreUtils.getKeyValueStoreByName(qpqConfig, resourceName);
|
|
60
|
-
const crossServiceResourceName = quidproquo_core_1.qpqCoreUtils.resolveCrossServiceResourceName(resourceName);
|
|
61
60
|
const application = quidproquo_core_1.qpqCoreUtils.getApplicationName(qpqConfig);
|
|
62
|
-
const service =
|
|
63
|
-
((_a = storeConfig === null || storeConfig === void 0 ? void 0 : storeConfig.owner) === null || _a === void 0 ? void 0 : _a.module) ||
|
|
61
|
+
const service = ((_a = storeConfig === null || storeConfig === void 0 ? void 0 : storeConfig.owner) === null || _a === void 0 ? void 0 : _a.module) ||
|
|
64
62
|
quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
65
63
|
const environment = quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig);
|
|
66
64
|
const feature = quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig);
|
|
67
|
-
return (0, exports.getQpqRuntimeResourceName)(
|
|
65
|
+
return (0, exports.getQpqRuntimeResourceName)(resourceName, application, service, environment, feature, resourceType);
|
|
68
66
|
};
|
|
69
67
|
exports.getKvsDynamoTableNameFromConfig = getKvsDynamoTableNameFromConfig;
|
|
70
68
|
const getCFExportNameUserPoolIdFromConfig = (userDirectoryName, qpqConfig, serviceOverride, applicationOverride) => {
|
|
@@ -14,9 +14,14 @@ const quidproquo_core_2 = require("quidproquo-core");
|
|
|
14
14
|
const publishMessage_1 = require("../../../logic/sns/publishMessage");
|
|
15
15
|
const awsNamingUtils_1 = require("../../../awsNamingUtils");
|
|
16
16
|
const getProcessEventBusSendMessage = (qpqConfig) => {
|
|
17
|
-
return ({ eventBusName, eventBusMessages,
|
|
17
|
+
return ({ eventBusName, eventBusMessages, context }, session) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
var _a, _b, _c, _d, _e;
|
|
18
19
|
const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
19
|
-
const
|
|
20
|
+
const eventBusConfig = quidproquo_core_1.qpqCoreUtils.getEventBusConfigByName(eventBusName, qpqConfig);
|
|
21
|
+
if (!eventBusConfig) {
|
|
22
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `Event bus ${eventBusName} not found`);
|
|
23
|
+
}
|
|
24
|
+
const topicArn = (0, awsNamingUtils_1.getEventBusSnsTopicArn)(((_a = eventBusConfig.owner) === null || _a === void 0 ? void 0 : _a.resourceNameOverride) || eventBusName, qpqConfig, ((_b = eventBusConfig.owner) === null || _b === void 0 ? void 0 : _b.module) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig), ((_c = eventBusConfig.owner) === null || _c === void 0 ? void 0 : _c.environment) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig), ((_d = eventBusConfig.owner) === null || _d === void 0 ? void 0 : _d.application) || quidproquo_core_1.qpqCoreUtils.getApplicationName(qpqConfig), ((_e = eventBusConfig.owner) === null || _e === void 0 ? void 0 : _e.feature) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig));
|
|
20
25
|
yield (0, publishMessage_1.publishMessage)(topicArn, region, eventBusMessages.map((message) => {
|
|
21
26
|
const eventBusMessageWithSession = Object.assign(Object.assign({}, message), { storySession: Object.assign(Object.assign({}, session), { context }) });
|
|
22
27
|
return JSON.stringify(eventBusMessageWithSession);
|
|
@@ -14,11 +14,10 @@ const utils_1 = require("./utils");
|
|
|
14
14
|
const s3Utils_1 = require("../../../logic/s3/s3Utils");
|
|
15
15
|
const getProcessFileListDirectory = (qpqConfig) => {
|
|
16
16
|
return ({ drive, folderPath, maxFiles, pageToken }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
-
const xServiceDriveName = (0, utils_1.resolveCrossServiceDriveName)(drive);
|
|
18
17
|
const s3BucketName = (0, utils_1.resolveStorageDriveBucketName)(drive, qpqConfig);
|
|
19
18
|
const s3FileList = yield (0, s3Utils_1.listFiles)(s3BucketName, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig), folderPath, maxFiles, pageToken);
|
|
20
19
|
// Add the drive onto the list
|
|
21
|
-
const fileInfos = s3FileList.fileInfos.map((s3fi) => (Object.assign(Object.assign({}, s3fi), { drive
|
|
20
|
+
const fileInfos = s3FileList.fileInfos.map((s3fi) => (Object.assign(Object.assign({}, s3fi), { drive })));
|
|
22
21
|
return (0, quidproquo_core_1.actionResult)({
|
|
23
22
|
fileInfos,
|
|
24
23
|
pageToken: s3FileList.pageToken,
|
package/lib/commonjs/getActionProcessor/core/file/getFileWriteBinaryContentsActionProcessor.js
CHANGED
|
@@ -12,10 +12,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
13
13
|
const utils_1 = require("./utils");
|
|
14
14
|
const s3Utils_1 = require("../../../logic/s3/s3Utils");
|
|
15
|
+
const awsLambdaUtils_1 = require("../../../awsLambdaUtils");
|
|
15
16
|
const getProcessFileWriteBinaryContents = (qpqConfig) => {
|
|
16
|
-
return ({ drive, filepath, data }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
return ({ drive, filepath, data, storageDriveAdvancedWriteOptions }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
18
|
const s3BucketName = (0, utils_1.resolveStorageDriveBucketName)(drive, qpqConfig);
|
|
18
|
-
yield (0, s3Utils_1.writeBinaryFile)(s3BucketName, filepath, data, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig));
|
|
19
|
+
yield (0, s3Utils_1.writeBinaryFile)(s3BucketName, filepath, data, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig), (0, awsLambdaUtils_1.getS3BucketStorageClassFromStorageDriveTier)(storageDriveAdvancedWriteOptions === null || storageDriveAdvancedWriteOptions === void 0 ? void 0 : storageDriveAdvancedWriteOptions.storageDriveTier));
|
|
19
20
|
return (0, quidproquo_core_1.actionResult)(void 0);
|
|
20
21
|
});
|
|
21
22
|
};
|
package/lib/commonjs/getActionProcessor/core/file/getFileWriteTextContentsActionProcessor.js
CHANGED
|
@@ -12,10 +12,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
13
13
|
const utils_1 = require("./utils");
|
|
14
14
|
const s3Utils_1 = require("../../../logic/s3/s3Utils");
|
|
15
|
+
const awsLambdaUtils_1 = require("../../../awsLambdaUtils");
|
|
15
16
|
const getProcessFileWriteTextContents = (qpqConfig) => {
|
|
16
|
-
return ({ drive, filepath, data }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
return ({ drive, filepath, data, storageDriveAdvancedWriteOptions }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
18
|
const s3BucketName = (0, utils_1.resolveStorageDriveBucketName)(drive, qpqConfig);
|
|
18
|
-
yield (0, s3Utils_1.writeTextFile)(s3BucketName, filepath, data, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig));
|
|
19
|
+
yield (0, s3Utils_1.writeTextFile)(s3BucketName, filepath, data, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig), (0, awsLambdaUtils_1.getS3BucketStorageClassFromStorageDriveTier)(storageDriveAdvancedWriteOptions === null || storageDriveAdvancedWriteOptions === void 0 ? void 0 : storageDriveAdvancedWriteOptions.storageDriveTier));
|
|
19
20
|
return (0, quidproquo_core_1.actionResult)(void 0);
|
|
20
21
|
});
|
|
21
22
|
};
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { QPQConfig
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const resolveStorageDriveBucketName: (drive: DriveName, qpqConfig: QPQConfig) => string;
|
|
1
|
+
import { QPQConfig } from 'quidproquo-core';
|
|
2
|
+
export declare const resolveStorageDriveBucketName: (drive: string, qpqConfig: QPQConfig) => string;
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveStorageDriveBucketName =
|
|
3
|
+
exports.resolveStorageDriveBucketName = void 0;
|
|
4
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
4
5
|
const awsNamingUtils_1 = require("../../../../awsNamingUtils");
|
|
5
|
-
const resolveCrossServiceDriveName = (drive) => {
|
|
6
|
-
if (typeof drive === 'string') {
|
|
7
|
-
return {
|
|
8
|
-
name: drive,
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
return drive;
|
|
12
|
-
};
|
|
13
|
-
exports.resolveCrossServiceDriveName = resolveCrossServiceDriveName;
|
|
14
6
|
const resolveStorageDriveBucketName = (drive, qpqConfig) => {
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
var _a, _b;
|
|
8
|
+
const storageDriveConfig = quidproquo_core_1.qpqCoreUtils.getStorageDriveByName(drive, qpqConfig);
|
|
9
|
+
if (!storageDriveConfig) {
|
|
10
|
+
throw new Error(`Could not find storage drive config for [${drive}]`);
|
|
11
|
+
}
|
|
12
|
+
return (0, awsNamingUtils_1.getConfigRuntimeResourceNameFromConfigWithServiceOverride)(((_a = storageDriveConfig.owner) === null || _a === void 0 ? void 0 : _a.resourceNameOverride) || drive, qpqConfig, (_b = storageDriveConfig.owner) === null || _b === void 0 ? void 0 : _b.module);
|
|
17
13
|
};
|
|
18
14
|
exports.resolveStorageDriveBucketName = resolveStorageDriveBucketName;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { QPQBinaryData } from 'quidproquo-core';
|
|
2
|
-
|
|
2
|
+
import { StorageClass } from '@aws-sdk/client-s3';
|
|
3
|
+
export declare const writeBinaryFile: (bucketName: string, key: string, data: QPQBinaryData, region: string, storageClass: keyof typeof StorageClass) => Promise<void>;
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.writeBinaryFile = void 0;
|
|
13
13
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
14
14
|
const createAwsClient_1 = require("../createAwsClient");
|
|
15
|
-
const writeBinaryFile = (bucketName, key, data, region) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const writeBinaryFile = (bucketName, key, data, region, storageClass) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
const s3Client = (0, createAwsClient_1.createAwsClient)(client_s3_1.S3Client, { region });
|
|
17
17
|
yield s3Client.send(new client_s3_1.PutObjectCommand({
|
|
18
18
|
Key: key,
|
|
@@ -20,6 +20,7 @@ const writeBinaryFile = (bucketName, key, data, region) => __awaiter(void 0, voi
|
|
|
20
20
|
Body: Buffer.from(data.base64Data, 'base64'),
|
|
21
21
|
ContentType: data.mimetype,
|
|
22
22
|
ContentDisposition: data.contentDisposition,
|
|
23
|
+
StorageClass: storageClass
|
|
23
24
|
}));
|
|
24
25
|
});
|
|
25
26
|
exports.writeBinaryFile = writeBinaryFile;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { StorageClass } from '@aws-sdk/client-s3';
|
|
2
|
+
export declare const writeTextFile: (bucketName: string, key: string, data: string, region: string, storageClass: keyof typeof StorageClass) => Promise<void>;
|
|
@@ -12,12 +12,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.writeTextFile = void 0;
|
|
13
13
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
14
14
|
const createAwsClient_1 = require("../createAwsClient");
|
|
15
|
-
const writeTextFile = (bucketName, key, data, region) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const writeTextFile = (bucketName, key, data, region, storageClass) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
const s3Client = (0, createAwsClient_1.createAwsClient)(client_s3_1.S3Client, { region });
|
|
17
17
|
yield s3Client.send(new client_s3_1.PutObjectCommand({
|
|
18
18
|
Key: key,
|
|
19
19
|
Bucket: bucketName,
|
|
20
20
|
Body: Buffer.from(data),
|
|
21
|
+
StorageClass: storageClass
|
|
21
22
|
}));
|
|
22
23
|
});
|
|
23
24
|
exports.writeTextFile = writeTextFile;
|