@cumulus/aws-client 11.0.0 → 11.1.1
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/DynamoDb.d.ts +27 -24
- package/DynamoDb.js +31 -19
- package/DynamoDbSearchQueue.js +10 -5
- package/README.md +168 -159
- package/S3.d.ts +86 -94
- package/S3.js +176 -135
- package/S3ListObjectsV2Queue.d.ts +4 -3
- package/S3ListObjectsV2Queue.js +1 -1
- package/S3ObjectStore.d.ts +12 -9
- package/S3ObjectStore.js +43 -44
- package/client.d.ts +2 -2
- package/client.js +13 -14
- package/lib/S3MultipartUploads.d.ts +5 -4
- package/lib/S3MultipartUploads.js +4 -4
- package/package.json +20 -7
- package/services.d.ts +25 -21
- package/services.js +30 -22
- package/test-utils.d.ts +26 -4
- package/test-utils.js +24 -17
- package/types.d.ts +6 -0
- package/types.js +3 -0
- package/utils.d.ts +1 -0
- package/utils.js +3 -1
package/S3ObjectStore.js
CHANGED
|
@@ -1,33 +1,11 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
|
-
const querystring = __importStar(require("querystring"));
|
|
29
5
|
const url_1 = require("url");
|
|
30
|
-
const
|
|
6
|
+
const uuid_1 = require("uuid");
|
|
7
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
8
|
+
const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
|
|
31
9
|
const logger_1 = __importDefault(require("@cumulus/logger"));
|
|
32
10
|
const S3_1 = require("./S3");
|
|
33
11
|
const client_1 = __importDefault(require("./client"));
|
|
@@ -38,8 +16,35 @@ const log = new logger_1.default({ sender: '@cumulus/aws-client/S3ObjectStore' }
|
|
|
38
16
|
*
|
|
39
17
|
*/
|
|
40
18
|
class S3ObjectStore {
|
|
41
|
-
constructor() {
|
|
42
|
-
this.s3 = (0, client_1.default)(
|
|
19
|
+
constructor(config) {
|
|
20
|
+
this.s3 = (0, client_1.default)(client_s3_1.S3, '2006-03-01', {
|
|
21
|
+
signatureVersion: 'v4',
|
|
22
|
+
})(config);
|
|
23
|
+
this.queryParams = {};
|
|
24
|
+
this.middlewareName = `customQueryParams${(0, uuid_1.v4)()}`;
|
|
25
|
+
}
|
|
26
|
+
getQueryParams() {
|
|
27
|
+
return this.queryParams;
|
|
28
|
+
}
|
|
29
|
+
setQueryParams(queryParams) {
|
|
30
|
+
this.queryParams = queryParams;
|
|
31
|
+
}
|
|
32
|
+
async getS3SignedUrlWithCustomQueryParams(command) {
|
|
33
|
+
this.s3.middlewareStack.addRelativeTo((next) => (args) => {
|
|
34
|
+
const { request } = args;
|
|
35
|
+
request.query = {
|
|
36
|
+
...this.getQueryParams(),
|
|
37
|
+
...request.query,
|
|
38
|
+
};
|
|
39
|
+
return next(args);
|
|
40
|
+
}, {
|
|
41
|
+
name: this.middlewareName,
|
|
42
|
+
relation: 'before',
|
|
43
|
+
toMiddleware: 'presignInterceptMiddleware',
|
|
44
|
+
});
|
|
45
|
+
const signedUrl = await (0, s3_request_presigner_1.getSignedUrl)(this.s3, command);
|
|
46
|
+
this.s3.middlewareStack.remove(this.middlewareName);
|
|
47
|
+
return signedUrl;
|
|
43
48
|
}
|
|
44
49
|
/**
|
|
45
50
|
* Returns an HTTPS URL that can be used to perform a GET on the given object
|
|
@@ -51,7 +56,7 @@ class S3ObjectStore {
|
|
|
51
56
|
* @returns {Promise<string>} a signed URL
|
|
52
57
|
* @throws TypeError - if the URL is not a recognized protocol or cannot be parsed
|
|
53
58
|
*/
|
|
54
|
-
async signGetObject(objectUrl, options = {}, queryParams) {
|
|
59
|
+
async signGetObject(objectUrl, options = {}, queryParams = {}) {
|
|
55
60
|
log.info(`Executing signGetObject with objectUrl: ${objectUrl}, options: ${JSON.stringify(options)}, queryParams: ${JSON.stringify(queryParams)}`);
|
|
56
61
|
const url = new url_1.URL(objectUrl);
|
|
57
62
|
if (url.protocol.toLowerCase() !== 's3:') {
|
|
@@ -59,14 +64,11 @@ class S3ObjectStore {
|
|
|
59
64
|
}
|
|
60
65
|
const { Bucket, Key } = (0, S3_1.parseS3Uri)(objectUrl);
|
|
61
66
|
await (0, S3_1.headObject)(Bucket, Key);
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const result = await req.presign();
|
|
68
|
-
log.debug(`Signed GetObject request URL: ${result}`);
|
|
69
|
-
return result;
|
|
67
|
+
const command = new client_s3_1.GetObjectCommand({ Bucket, Key, ...options });
|
|
68
|
+
this.setQueryParams(queryParams);
|
|
69
|
+
const signedUrl = await this.getS3SignedUrlWithCustomQueryParams(command);
|
|
70
|
+
log.debug(`Signed GetObject request URL: ${signedUrl}`);
|
|
71
|
+
return signedUrl;
|
|
70
72
|
}
|
|
71
73
|
/**
|
|
72
74
|
* Returns an HTTPS URL that can be used to perform a HEAD on the given object
|
|
@@ -85,14 +87,11 @@ class S3ObjectStore {
|
|
|
85
87
|
throw new TypeError(`Invalid S3 URL: ${objectUrl}`);
|
|
86
88
|
}
|
|
87
89
|
const { Bucket, Key } = (0, S3_1.parseS3Uri)(objectUrl);
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const result = await req.presign();
|
|
94
|
-
log.debug(`Signed HeadObject request URL: ${result}`);
|
|
95
|
-
return result;
|
|
90
|
+
const command = new client_s3_1.HeadObjectCommand({ Bucket, Key, ...options });
|
|
91
|
+
this.setQueryParams(queryParams);
|
|
92
|
+
const signedUrl = await this.getS3SignedUrlWithCustomQueryParams(command);
|
|
93
|
+
log.debug(`Signed HeadObject request URL: ${signedUrl}`);
|
|
94
|
+
return signedUrl;
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
97
|
module.exports = S3ObjectStore;
|
package/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AWSClientTypes } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Return a function which, when called, will return an AWS service object
|
|
4
4
|
*
|
|
@@ -14,6 +14,6 @@ import AWS from 'aws-sdk';
|
|
|
14
14
|
*
|
|
15
15
|
* @private
|
|
16
16
|
*/
|
|
17
|
-
declare const awsClient: <T extends
|
|
17
|
+
declare const awsClient: <T extends AWSClientTypes>(Service: new (params: object) => T, version?: string | undefined, serviceOptions?: object | undefined) => (params?: object | undefined) => T;
|
|
18
18
|
export = awsClient;
|
|
19
19
|
//# sourceMappingURL=client.d.ts.map
|
package/client.js
CHANGED
|
@@ -3,21 +3,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
const aws_sdk_1 = __importDefault(require("aws-sdk"));
|
|
6
|
+
const mem_1 = __importDefault(require("mem"));
|
|
6
7
|
const test_utils_1 = require("./test-utils");
|
|
7
|
-
const
|
|
8
|
+
const utils_1 = require("./utils");
|
|
8
9
|
const getRegion = () => process.env.AWS_DEFAULT_REGION || process.env.AWS_REGION || 'us-east-1';
|
|
9
|
-
// Workaround upload hangs. See: https://github.com/andrewrk/node-s3-client/issues/74
|
|
10
|
-
// @ts-ignore - AWS.util is not part of the public API and may break
|
|
11
|
-
aws_sdk_1.default.util.update(aws_sdk_1.default.S3.prototype, { addExpect100Continue: noop });
|
|
12
10
|
aws_sdk_1.default.config.setPromisesDependency(Promise);
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return memo;
|
|
19
|
-
};
|
|
11
|
+
const buildServiceClient = (Service, options) => {
|
|
12
|
+
if ((0, test_utils_1.inTestMode)()) {
|
|
13
|
+
return new Service((0, test_utils_1.getLocalstackAwsClientOptions)(Service, options));
|
|
14
|
+
}
|
|
15
|
+
return new Service(options);
|
|
20
16
|
};
|
|
17
|
+
const getMemoizedClient = (0, mem_1.default)(buildServiceClient, {
|
|
18
|
+
cacheKey: (arguments_) => `${(0, utils_1.getServiceIdentifer)(arguments_[0])}${JSON.stringify(arguments_[1])}`,
|
|
19
|
+
});
|
|
20
|
+
const getServiceClient = (Service, options = {}) => (overrides) => getMemoizedClient(Service, Object.assign(options, overrides));
|
|
21
21
|
/**
|
|
22
22
|
* Return a function which, when called, will return an AWS service object
|
|
23
23
|
*
|
|
@@ -44,11 +44,10 @@ const awsClient = (Service, version, serviceOptions) => {
|
|
|
44
44
|
// @ts-ignore - serviceIdentifier is not part of the public API and may break at any time
|
|
45
45
|
if (aws_sdk_1.default.DynamoDB.DocumentClient.serviceIdentifier === undefined) {
|
|
46
46
|
// @ts-ignore - serviceIdentifier is not part of the public API and may break at any time
|
|
47
|
-
aws_sdk_1.default.DynamoDB.DocumentClient.serviceIdentifier = '
|
|
47
|
+
aws_sdk_1.default.DynamoDB.DocumentClient.serviceIdentifier = 'dynamodbclient';
|
|
48
48
|
}
|
|
49
|
-
return memoize((o) => (0, test_utils_1.testAwsClient)(Service, Object.assign(options, o)));
|
|
50
49
|
}
|
|
51
|
-
return
|
|
50
|
+
return getServiceClient(Service, options);
|
|
52
51
|
};
|
|
53
52
|
module.exports = awsClient;
|
|
54
53
|
//# sourceMappingURL=client.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AbortMultipartUploadRequest, CompleteMultipartUploadRequest, CreateMultipartUploadRequest, UploadPartCopyRequest } from '@aws-sdk/client-s3';
|
|
1
2
|
export interface CompleteMultipartUploadOutput extends AWS.S3.CompleteMultipartUploadOutput {
|
|
2
3
|
ETag: string;
|
|
3
4
|
}
|
|
@@ -23,9 +24,9 @@ declare type Chunk = {
|
|
|
23
24
|
* @returns {Promise<Array<Chunk>>} - array of chunks
|
|
24
25
|
*/
|
|
25
26
|
export declare const createMultipartChunks: (objectSize: number, chunkSize?: number) => Chunk[];
|
|
26
|
-
export declare const createMultipartUpload: (params:
|
|
27
|
-
export declare const completeMultipartUpload: (params:
|
|
28
|
-
export declare const abortMultipartUpload: (params:
|
|
29
|
-
export declare const uploadPartCopy: (params:
|
|
27
|
+
export declare const createMultipartUpload: (params: CreateMultipartUploadRequest) => Promise<import("@aws-sdk/client-s3").CreateMultipartUploadCommandOutput>;
|
|
28
|
+
export declare const completeMultipartUpload: (params: CompleteMultipartUploadRequest) => Promise<CompleteMultipartUploadOutput>;
|
|
29
|
+
export declare const abortMultipartUpload: (params: AbortMultipartUploadRequest) => Promise<import("@aws-sdk/client-s3").AbortMultipartUploadCommandOutput>;
|
|
30
|
+
export declare const uploadPartCopy: (params: UploadPartCopyRequest) => Promise<import("@aws-sdk/client-s3").UploadPartCopyCommandOutput>;
|
|
30
31
|
export {};
|
|
31
32
|
//# sourceMappingURL=S3MultipartUploads.d.ts.map
|
|
@@ -31,15 +31,15 @@ const createMultipartChunks = (objectSize, chunkSize = 250 * MB) => (0, range_1.
|
|
|
31
31
|
end: Math.min(start + chunkSize, objectSize) - 1,
|
|
32
32
|
}));
|
|
33
33
|
exports.createMultipartChunks = createMultipartChunks;
|
|
34
|
-
const createMultipartUpload = async (params) => await (0, services_1.s3)().createMultipartUpload(params)
|
|
34
|
+
const createMultipartUpload = async (params) => await (0, services_1.s3)().createMultipartUpload(params);
|
|
35
35
|
exports.createMultipartUpload = createMultipartUpload;
|
|
36
36
|
const completeMultipartUpload = async (params) => {
|
|
37
|
-
const result = await (0, services_1.s3)().completeMultipartUpload(params)
|
|
37
|
+
const result = await (0, services_1.s3)().completeMultipartUpload(params);
|
|
38
38
|
return result;
|
|
39
39
|
};
|
|
40
40
|
exports.completeMultipartUpload = completeMultipartUpload;
|
|
41
|
-
const abortMultipartUpload = async (params) => await (0, services_1.s3)().abortMultipartUpload(params)
|
|
41
|
+
const abortMultipartUpload = async (params) => await (0, services_1.s3)().abortMultipartUpload(params);
|
|
42
42
|
exports.abortMultipartUpload = abortMultipartUpload;
|
|
43
|
-
const uploadPartCopy = async (params) => await (0, services_1.s3)().uploadPartCopy(params)
|
|
43
|
+
const uploadPartCopy = async (params) => await (0, services_1.s3)().uploadPartCopy(params);
|
|
44
44
|
exports.uploadPartCopy = uploadPartCopy;
|
|
45
45
|
//# sourceMappingURL=S3MultipartUploads.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cumulus/aws-client",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.1.1",
|
|
4
4
|
"description": "Utilities for working with AWS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"GIBS",
|
|
@@ -43,17 +43,30 @@
|
|
|
43
43
|
"author": "Cumulus Authors",
|
|
44
44
|
"license": "Apache-2.0",
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"aws-sdk": "^
|
|
46
|
+
"@aws-sdk/client-dynamodb": "^3.53.0",
|
|
47
|
+
"@aws-sdk/client-dynamodb-streams": "^3.53.0",
|
|
48
|
+
"@aws-sdk/client-s3": "^3.53.0",
|
|
49
|
+
"@aws-sdk/lib-dynamodb": "^3.53.0",
|
|
50
|
+
"@aws-sdk/lib-storage": "^3.53.0",
|
|
51
|
+
"@aws-sdk/s3-request-presigner": "^3.53.0",
|
|
52
|
+
"@aws-sdk/signature-v4-crt": "^3.53.0",
|
|
53
|
+
"@aws-sdk/types": "^3.53.0",
|
|
54
|
+
"@cumulus/checksum": "11.1.1",
|
|
55
|
+
"@cumulus/errors": "11.1.1",
|
|
56
|
+
"@cumulus/logger": "11.1.1",
|
|
57
|
+
"aws-sdk": "^2.585.0",
|
|
50
58
|
"jsonpath-plus": "^1.1.0",
|
|
51
59
|
"lodash": "~4.17.21",
|
|
60
|
+
"mem": "^8.0.2",
|
|
52
61
|
"p-map": "^1.2.0",
|
|
53
62
|
"p-retry": "^4.2.0",
|
|
54
63
|
"p-timeout": "^4.1.0",
|
|
55
64
|
"p-wait-for": "^3.2.0",
|
|
56
|
-
"pump": "^3.0.0"
|
|
65
|
+
"pump": "^3.0.0",
|
|
66
|
+
"uuid": "^8.2.0"
|
|
57
67
|
},
|
|
58
|
-
"
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@types/uuid": "^8.0.0"
|
|
70
|
+
},
|
|
71
|
+
"gitHead": "07fe682da23821434372759fb1948b081da429b5"
|
|
59
72
|
}
|
package/services.d.ts
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
|
+
import { DynamoDB } from '@aws-sdk/client-dynamodb';
|
|
2
|
+
import { DynamoDBStreamsClient } from '@aws-sdk/client-dynamodb-streams';
|
|
3
|
+
import { S3 } from '@aws-sdk/client-s3';
|
|
4
|
+
import { DynamoDBDocument, TranslateConfig } from '@aws-sdk/lib-dynamodb';
|
|
1
5
|
import * as AWS from 'aws-sdk';
|
|
2
|
-
export declare const apigateway: (
|
|
3
|
-
export declare const ecs: (
|
|
4
|
-
export declare const ec2: (
|
|
5
|
-
export declare const s3: (
|
|
6
|
-
export declare const kinesis: (
|
|
7
|
-
export declare const lambda: (
|
|
8
|
-
export declare const sqs: (
|
|
9
|
-
export declare const cloudwatchevents: (
|
|
10
|
-
export declare const cloudwatchlogs: (
|
|
11
|
-
export declare const cloudwatch: (
|
|
12
|
-
export declare const dynamodb: (
|
|
13
|
-
export declare const dynamodbstreams: (
|
|
14
|
-
export declare const dynamodbDocClient: (
|
|
15
|
-
export declare const sfn: (
|
|
16
|
-
export declare const cf: (
|
|
17
|
-
export declare const sns: (
|
|
18
|
-
export declare const secretsManager: (
|
|
19
|
-
export declare const systemsManager: (
|
|
20
|
-
export declare const kms: (
|
|
21
|
-
export declare const es: (
|
|
22
|
-
export declare const sts: (
|
|
6
|
+
export declare const apigateway: (params?: object | undefined) => AWS.APIGateway;
|
|
7
|
+
export declare const ecs: (params?: object | undefined) => AWS.ECS;
|
|
8
|
+
export declare const ec2: (params?: object | undefined) => AWS.EC2;
|
|
9
|
+
export declare const s3: (params?: object | undefined) => S3;
|
|
10
|
+
export declare const kinesis: (params?: object | undefined) => AWS.Kinesis;
|
|
11
|
+
export declare const lambda: (params?: object | undefined) => AWS.Lambda;
|
|
12
|
+
export declare const sqs: (params?: object | undefined) => AWS.SQS;
|
|
13
|
+
export declare const cloudwatchevents: (params?: object | undefined) => AWS.CloudWatchEvents;
|
|
14
|
+
export declare const cloudwatchlogs: (params?: object | undefined) => AWS.CloudWatchLogs;
|
|
15
|
+
export declare const cloudwatch: (params?: object | undefined) => AWS.CloudWatch;
|
|
16
|
+
export declare const dynamodb: (params?: object | undefined) => DynamoDB;
|
|
17
|
+
export declare const dynamodbstreams: (params?: object | undefined) => DynamoDBStreamsClient;
|
|
18
|
+
export declare const dynamodbDocClient: (docClientOptions?: TranslateConfig | undefined, dynamoOptions?: object | undefined) => DynamoDBDocument;
|
|
19
|
+
export declare const sfn: (params?: object | undefined) => AWS.StepFunctions;
|
|
20
|
+
export declare const cf: (params?: object | undefined) => AWS.CloudFormation;
|
|
21
|
+
export declare const sns: (params?: object | undefined) => AWS.SNS;
|
|
22
|
+
export declare const secretsManager: (params?: object | undefined) => AWS.SecretsManager;
|
|
23
|
+
export declare const systemsManager: (params?: object | undefined) => AWS.SSM;
|
|
24
|
+
export declare const kms: (params?: object | undefined) => AWS.KMS;
|
|
25
|
+
export declare const es: (params?: object | undefined) => AWS.ES;
|
|
26
|
+
export declare const sts: (params?: object | undefined) => AWS.STS;
|
|
23
27
|
//# sourceMappingURL=services.d.ts.map
|
package/services.js
CHANGED
|
@@ -22,29 +22,37 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
exports.sts = exports.es = exports.kms = exports.systemsManager = exports.secretsManager = exports.sns = exports.cf = exports.sfn = exports.dynamodbDocClient = exports.dynamodbstreams = exports.dynamodb = exports.cloudwatch = exports.cloudwatchlogs = exports.cloudwatchevents = exports.sqs = exports.lambda = exports.kinesis = exports.s3 = exports.ec2 = exports.ecs = exports.apigateway = void 0;
|
|
30
|
+
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
31
|
+
const client_dynamodb_streams_1 = require("@aws-sdk/client-dynamodb-streams");
|
|
32
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
33
|
+
const lib_dynamodb_1 = require("@aws-sdk/lib-dynamodb");
|
|
27
34
|
const AWS = __importStar(require("aws-sdk"));
|
|
28
|
-
const
|
|
29
|
-
exports.apigateway =
|
|
30
|
-
exports.ecs =
|
|
31
|
-
exports.ec2 =
|
|
32
|
-
exports.s3 =
|
|
33
|
-
exports.kinesis =
|
|
34
|
-
exports.lambda =
|
|
35
|
-
exports.sqs =
|
|
36
|
-
exports.cloudwatchevents =
|
|
37
|
-
exports.cloudwatchlogs =
|
|
38
|
-
exports.cloudwatch =
|
|
39
|
-
exports.dynamodb =
|
|
40
|
-
exports.dynamodbstreams =
|
|
41
|
-
|
|
42
|
-
exports.
|
|
43
|
-
exports.
|
|
44
|
-
exports.
|
|
45
|
-
exports.
|
|
46
|
-
exports.
|
|
47
|
-
exports.
|
|
48
|
-
exports.
|
|
49
|
-
exports.
|
|
35
|
+
const client_1 = __importDefault(require("./client"));
|
|
36
|
+
exports.apigateway = (0, client_1.default)(AWS.APIGateway, '2015-07-09');
|
|
37
|
+
exports.ecs = (0, client_1.default)(AWS.ECS, '2014-11-13');
|
|
38
|
+
exports.ec2 = (0, client_1.default)(AWS.EC2, '2016-11-15');
|
|
39
|
+
exports.s3 = (0, client_1.default)(client_s3_1.S3, '2006-03-01');
|
|
40
|
+
exports.kinesis = (0, client_1.default)(AWS.Kinesis, '2013-12-02');
|
|
41
|
+
exports.lambda = (0, client_1.default)(AWS.Lambda, '2015-03-31');
|
|
42
|
+
exports.sqs = (0, client_1.default)(AWS.SQS, '2012-11-05');
|
|
43
|
+
exports.cloudwatchevents = (0, client_1.default)(AWS.CloudWatchEvents, '2014-02-03');
|
|
44
|
+
exports.cloudwatchlogs = (0, client_1.default)(AWS.CloudWatchLogs, '2014-03-28');
|
|
45
|
+
exports.cloudwatch = (0, client_1.default)(AWS.CloudWatch, '2010-08-01');
|
|
46
|
+
exports.dynamodb = (0, client_1.default)(client_dynamodb_1.DynamoDB, '2012-08-10');
|
|
47
|
+
exports.dynamodbstreams = (0, client_1.default)(client_dynamodb_streams_1.DynamoDBStreamsClient, '2012-08-10');
|
|
48
|
+
const dynamodbDocClient = (docClientOptions, dynamoOptions) => lib_dynamodb_1.DynamoDBDocument.from((0, client_1.default)(client_dynamodb_1.DynamoDB, '2012-08-10')(dynamoOptions), docClientOptions);
|
|
49
|
+
exports.dynamodbDocClient = dynamodbDocClient;
|
|
50
|
+
exports.sfn = (0, client_1.default)(AWS.StepFunctions, '2016-11-23');
|
|
51
|
+
exports.cf = (0, client_1.default)(AWS.CloudFormation, '2010-05-15');
|
|
52
|
+
exports.sns = (0, client_1.default)(AWS.SNS, '2010-03-31');
|
|
53
|
+
exports.secretsManager = (0, client_1.default)(AWS.SecretsManager, '2017-10-17');
|
|
54
|
+
exports.systemsManager = (0, client_1.default)(AWS.SSM, '2017-10-17');
|
|
55
|
+
exports.kms = (0, client_1.default)(AWS.KMS, '2014-11-01');
|
|
56
|
+
exports.es = (0, client_1.default)(AWS.ES, '2015-01-01');
|
|
57
|
+
exports.sts = (0, client_1.default)(AWS.STS, '2011-06-15');
|
|
50
58
|
//# sourceMappingURL=services.js.map
|
package/test-utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AWSClientTypes } from './types';
|
|
2
2
|
export declare const inTestMode: () => boolean;
|
|
3
3
|
declare const localStackPorts: {
|
|
4
4
|
stepfunctions: number;
|
|
@@ -7,7 +7,11 @@ declare const localStackPorts: {
|
|
|
7
7
|
cloudwatch: number;
|
|
8
8
|
cloudwatchevents: number;
|
|
9
9
|
cloudwatchlogs: number;
|
|
10
|
-
|
|
10
|
+
DynamoDB: number;
|
|
11
|
+
DynamoDBClient: number;
|
|
12
|
+
DynamoDBStreamsClient: number;
|
|
13
|
+
ec2: number;
|
|
14
|
+
ecs: number;
|
|
11
15
|
es: number;
|
|
12
16
|
firehose: number;
|
|
13
17
|
iam: number;
|
|
@@ -16,7 +20,7 @@ declare const localStackPorts: {
|
|
|
16
20
|
lambda: number;
|
|
17
21
|
redshift: number;
|
|
18
22
|
route53: number;
|
|
19
|
-
|
|
23
|
+
S3: number;
|
|
20
24
|
secretsmanager: number;
|
|
21
25
|
ses: number;
|
|
22
26
|
sns: number;
|
|
@@ -33,6 +37,22 @@ declare const localStackPorts: {
|
|
|
33
37
|
* @private
|
|
34
38
|
*/
|
|
35
39
|
export declare function getLocalstackEndpoint(identifier: keyof typeof localStackPorts): string;
|
|
40
|
+
/**
|
|
41
|
+
* Create an AWS service object that talks to LocalStack.
|
|
42
|
+
*
|
|
43
|
+
* This function expects that the LOCALSTACK_HOST environment variable will be set.
|
|
44
|
+
*
|
|
45
|
+
* @param {Function} Service - an AWS service object constructor function
|
|
46
|
+
* @param {Object} options - options to pass to the service object constructor function
|
|
47
|
+
* @returns {Object} an AWS service object
|
|
48
|
+
*
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
export declare function localStackAwsClientOptions<T>(Service: new (params: object) => T, options?: {
|
|
52
|
+
credentials?: object;
|
|
53
|
+
}): {
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
};
|
|
36
56
|
/**
|
|
37
57
|
* Create an AWS service object that does not actually talk to AWS.
|
|
38
58
|
*
|
|
@@ -42,7 +62,9 @@ export declare function getLocalstackEndpoint(identifier: keyof typeof localStac
|
|
|
42
62
|
*
|
|
43
63
|
* @private
|
|
44
64
|
*/
|
|
45
|
-
export declare function
|
|
65
|
+
export declare function getLocalstackAwsClientOptions<T extends AWSClientTypes>(Service: new (params: object) => T, options?: {
|
|
66
|
+
credentials?: object;
|
|
67
|
+
}): object;
|
|
46
68
|
/**
|
|
47
69
|
* Return a function that throws a ThrottlingException the first time it is called, then returns as
|
|
48
70
|
* normal any other times.
|
package/test-utils.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.throttleOnce = exports.
|
|
3
|
+
exports.throttleOnce = exports.getLocalstackAwsClientOptions = exports.localStackAwsClientOptions = exports.getLocalstackEndpoint = exports.inTestMode = void 0;
|
|
4
4
|
const errors_1 = require("@cumulus/errors");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
5
6
|
const inTestMode = () => process.env.NODE_ENV === 'test';
|
|
6
7
|
exports.inTestMode = inTestMode;
|
|
7
8
|
// From https://github.com/localstack/localstack/blob/master/README.md
|
|
@@ -12,7 +13,11 @@ const localStackPorts = {
|
|
|
12
13
|
cloudwatch: 4566,
|
|
13
14
|
cloudwatchevents: 4566,
|
|
14
15
|
cloudwatchlogs: 4566,
|
|
15
|
-
|
|
16
|
+
DynamoDB: 4566,
|
|
17
|
+
DynamoDBClient: 4566,
|
|
18
|
+
DynamoDBStreamsClient: 4566,
|
|
19
|
+
ec2: 4566,
|
|
20
|
+
ecs: 4566,
|
|
16
21
|
es: 4566,
|
|
17
22
|
firehose: 4566,
|
|
18
23
|
iam: 4566,
|
|
@@ -21,7 +26,7 @@ const localStackPorts = {
|
|
|
21
26
|
lambda: 4566,
|
|
22
27
|
redshift: 4566,
|
|
23
28
|
route53: 4566,
|
|
24
|
-
|
|
29
|
+
S3: 4566,
|
|
25
30
|
secretsmanager: 4566,
|
|
26
31
|
ses: 4566,
|
|
27
32
|
sns: 4566,
|
|
@@ -68,23 +73,26 @@ exports.getLocalstackEndpoint = getLocalstackEndpoint;
|
|
|
68
73
|
*
|
|
69
74
|
* @private
|
|
70
75
|
*/
|
|
71
|
-
function
|
|
76
|
+
function localStackAwsClientOptions(Service, options = {}) {
|
|
72
77
|
if (!process.env.LOCALSTACK_HOST) {
|
|
73
78
|
throw new Error('The LOCALSTACK_HOST environment variable is not set.');
|
|
74
79
|
}
|
|
75
|
-
|
|
76
|
-
const serviceIdentifier = Service.serviceIdentifier;
|
|
80
|
+
const serviceIdentifier = (0, utils_1.getServiceIdentifer)(Service);
|
|
77
81
|
const localStackOptions = {
|
|
78
|
-
...options,
|
|
79
|
-
accessKeyId: 'my-access-key-id',
|
|
80
|
-
secretAccessKey: 'my-secret-access-key',
|
|
81
82
|
region: 'us-east-1',
|
|
82
83
|
endpoint: getLocalstackEndpoint(serviceIdentifier),
|
|
84
|
+
...options,
|
|
85
|
+
credentials: {
|
|
86
|
+
accessKeyId: 'my-access-key-id',
|
|
87
|
+
secretAccessKey: 'my-secret-access-key',
|
|
88
|
+
...options.credentials,
|
|
89
|
+
},
|
|
83
90
|
};
|
|
84
|
-
if (serviceIdentifier === 's3')
|
|
85
|
-
localStackOptions.
|
|
86
|
-
return
|
|
91
|
+
if (serviceIdentifier.toLowerCase() === 's3')
|
|
92
|
+
localStackOptions.forcePathStyle = true;
|
|
93
|
+
return localStackOptions;
|
|
87
94
|
}
|
|
95
|
+
exports.localStackAwsClientOptions = localStackAwsClientOptions;
|
|
88
96
|
/**
|
|
89
97
|
* Create an AWS service object that does not actually talk to AWS.
|
|
90
98
|
*
|
|
@@ -94,15 +102,14 @@ function localStackAwsClient(Service, options) {
|
|
|
94
102
|
*
|
|
95
103
|
* @private
|
|
96
104
|
*/
|
|
97
|
-
function
|
|
98
|
-
|
|
99
|
-
const serviceIdentifier = Service.serviceIdentifier;
|
|
105
|
+
function getLocalstackAwsClientOptions(Service, options = {}) {
|
|
106
|
+
const serviceIdentifier = (0, utils_1.getServiceIdentifer)(Service);
|
|
100
107
|
if (localstackSupportedService(serviceIdentifier)) {
|
|
101
|
-
return
|
|
108
|
+
return localStackAwsClientOptions(Service, options);
|
|
102
109
|
}
|
|
103
110
|
return {};
|
|
104
111
|
}
|
|
105
|
-
exports.
|
|
112
|
+
exports.getLocalstackAwsClientOptions = getLocalstackAwsClientOptions;
|
|
106
113
|
/**
|
|
107
114
|
* Return a function that throws a ThrottlingException the first time it is called, then returns as
|
|
108
115
|
* normal any other times.
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as AWS from 'aws-sdk';
|
|
2
|
+
import { DynamoDBStreamsClient } from '@aws-sdk/client-dynamodb-streams';
|
|
3
|
+
import { DynamoDB, DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
|
4
|
+
import { S3 } from '@aws-sdk/client-s3';
|
|
5
|
+
export declare type AWSClientTypes = DynamoDB | DynamoDBClient | DynamoDBStreamsClient | S3 | AWS.Service | AWS.DynamoDB.DocumentClient;
|
|
6
|
+
//# sourceMappingURL=types.d.ts.map
|
package/types.js
ADDED
package/utils.d.ts
CHANGED
package/utils.js
CHANGED
|
@@ -3,9 +3,11 @@ 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.retryOnThrottlingException = exports.improveStackTrace = exports.setErrorStack = void 0;
|
|
6
|
+
exports.retryOnThrottlingException = exports.improveStackTrace = exports.setErrorStack = exports.getServiceIdentifer = void 0;
|
|
7
7
|
const p_retry_1 = __importDefault(require("p-retry"));
|
|
8
8
|
const errors_1 = require("@cumulus/errors");
|
|
9
|
+
const getServiceIdentifer = (service) => service.serviceIdentifier || service.name;
|
|
10
|
+
exports.getServiceIdentifer = getServiceIdentifer;
|
|
9
11
|
// Replace the stack of an error
|
|
10
12
|
// Note: This mutates the error that was passed in.
|
|
11
13
|
const setErrorStack = (error, newStack) => {
|