@cumulus/aws-client 9.7.1 → 9.9.2
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/CloudFormation.js +10 -7
- package/CloudFormationGateway.js +2 -2
- package/CloudwatchEvents.js +8 -4
- package/DynamoDb.js +12 -11
- package/DynamoDbSearchQueue.d.ts +2 -2
- package/DynamoDbSearchQueue.js +1 -1
- package/KMS.js +8 -5
- package/Kinesis.js +3 -2
- package/Lambda.js +4 -3
- package/README.md +245 -237
- package/S3.d.ts +2 -2
- package/S3.js +111 -76
- package/S3ListObjectsV2Queue.js +1 -1
- package/S3ObjectStore.js +5 -5
- package/SNS.js +3 -2
- package/SQS.d.ts +6 -3
- package/SQS.js +31 -23
- package/SecretsManager.js +2 -1
- package/StepFunctions.d.ts +3 -1
- package/StepFunctions.js +15 -12
- package/client.js +2 -2
- package/index.js +2 -1
- package/lib/S3MultipartUploads.js +11 -6
- package/package.json +5 -5
- package/services.js +1 -1
- package/test-utils.js +4 -2
- package/utils.js +8 -5
package/S3ObjectStore.js
CHANGED
|
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
14
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
15
|
if (mod && mod.__esModule) return mod;
|
|
16
16
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
@@ -35,7 +35,7 @@ const log = new logger_1.default({ sender: '@cumulus/aws-client/S3ObjectStore' }
|
|
|
35
35
|
*/
|
|
36
36
|
class S3ObjectStore {
|
|
37
37
|
constructor() {
|
|
38
|
-
this.s3 = client_1.default(AWS.S3, '2006-03-01', { signatureVersion: 'v4' })();
|
|
38
|
+
this.s3 = (0, client_1.default)(AWS.S3, '2006-03-01', { signatureVersion: 'v4' })();
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Returns an HTTPS URL that can be used to perform a GET on the given object
|
|
@@ -53,8 +53,8 @@ class S3ObjectStore {
|
|
|
53
53
|
if (url.protocol.toLowerCase() !== 's3:') {
|
|
54
54
|
throw new TypeError(`Invalid S3 URL: ${objectUrl}`);
|
|
55
55
|
}
|
|
56
|
-
const { Bucket, Key } = S3_1.parseS3Uri(objectUrl);
|
|
57
|
-
await S3_1.headObject(Bucket, Key);
|
|
56
|
+
const { Bucket, Key } = (0, S3_1.parseS3Uri)(objectUrl);
|
|
57
|
+
await (0, S3_1.headObject)(Bucket, Key);
|
|
58
58
|
const req = this.s3.getObject({ Bucket, Key, ...options });
|
|
59
59
|
if (queryParams && req.on) {
|
|
60
60
|
(req.on('build', () => { req.httpRequest.path += `${options ? '&' : '?'}${querystring.stringify(queryParams)}`; }));
|
|
@@ -80,7 +80,7 @@ class S3ObjectStore {
|
|
|
80
80
|
if (url.protocol.toLowerCase() !== 's3:') {
|
|
81
81
|
throw new TypeError(`Invalid S3 URL: ${objectUrl}`);
|
|
82
82
|
}
|
|
83
|
-
const { Bucket, Key } = S3_1.parseS3Uri(objectUrl);
|
|
83
|
+
const { Bucket, Key } = (0, S3_1.parseS3Uri)(objectUrl);
|
|
84
84
|
const req = this.s3.headObject({ Bucket, Key, ...options });
|
|
85
85
|
if (queryParams && req.on) {
|
|
86
86
|
(req.on('build', () => { req.httpRequest.path += `?${querystring.stringify(queryParams)}`; }));
|
package/SNS.js
CHANGED
|
@@ -21,11 +21,11 @@ const log = new logger_1.default({ sender: 'aws-client/sns' });
|
|
|
21
21
|
* a message fails. See https://github.com/tim-kos/node-retry#retryoperationoptions
|
|
22
22
|
* @returns {Promise<undefined>}
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
const publishSnsMessage = async (snsTopicArn, message, retryOptions = {}) => await (0, p_retry_1.default)(async () => {
|
|
25
25
|
if (!snsTopicArn) {
|
|
26
26
|
throw new p_retry_1.default.AbortError('Missing SNS topic ARN');
|
|
27
27
|
}
|
|
28
|
-
await services_1.sns().publish({
|
|
28
|
+
await (0, services_1.sns)().publish({
|
|
29
29
|
TopicArn: snsTopicArn,
|
|
30
30
|
Message: JSON.stringify(message),
|
|
31
31
|
}).promise();
|
|
@@ -34,4 +34,5 @@ exports.publishSnsMessage = async (snsTopicArn, message, retryOptions = {}) => a
|
|
|
34
34
|
onFailedAttempt: (err) => log.debug(`publishSnsMessage('${snsTopicArn}', '${message}') failed with ${err.retriesLeft} retries left: ${err.message}`),
|
|
35
35
|
...retryOptions,
|
|
36
36
|
});
|
|
37
|
+
exports.publishSnsMessage = publishSnsMessage;
|
|
37
38
|
//# sourceMappingURL=SNS.js.map
|
package/SQS.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* @module SQS
|
|
3
3
|
*/
|
|
4
4
|
import Logger from '@cumulus/logger';
|
|
5
|
+
import { SQSRecord } from 'aws-lambda';
|
|
5
6
|
export interface SQSMessage extends AWS.SQS.Message {
|
|
6
7
|
ReceiptHandle: string;
|
|
7
8
|
}
|
|
@@ -34,7 +35,7 @@ export declare const getQueueAttributes: (queueName: string) => Promise<{
|
|
|
34
35
|
|
|
35
36
|
**/
|
|
36
37
|
export declare const sendSQSMessage: (queueUrl: string, message: string | object, logOverride: Logger) => Promise<import("aws-sdk/lib/request").PromiseResult<import("aws-sdk/clients/sqs").SendMessageResult, import("aws-sdk").AWSError>>;
|
|
37
|
-
declare type
|
|
38
|
+
declare type ReceiveSQSMessagesOptions = {
|
|
38
39
|
numOfMessages?: number;
|
|
39
40
|
visibilityTimeout?: number;
|
|
40
41
|
waitTimeSeconds?: number;
|
|
@@ -51,8 +52,10 @@ declare type receiveSQSMessagesOptions = {
|
|
|
51
52
|
* @param {integer} [options.waitTimeSeconds=0] - number of seconds to poll SQS queue (long polling)
|
|
52
53
|
* @returns {Promise<Array>} an array of messages
|
|
53
54
|
*/
|
|
54
|
-
export declare const receiveSQSMessages: (queueUrl: string, options:
|
|
55
|
-
export declare const parseSQSMessageBody: (message:
|
|
55
|
+
export declare const receiveSQSMessages: (queueUrl: string, options: ReceiveSQSMessagesOptions) => Promise<SQSMessage[]>;
|
|
56
|
+
export declare const parseSQSMessageBody: (message: SQSRecord | AWS.SQS.Message) => {
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
};
|
|
56
59
|
/**
|
|
57
60
|
* Delete a given SQS message from a given queue.
|
|
58
61
|
*
|
package/SQS.js
CHANGED
|
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
14
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
15
|
if (mod && mod.__esModule) return mod;
|
|
16
16
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
@@ -36,15 +36,18 @@ const services_1 = require("./services");
|
|
|
36
36
|
const test_utils_1 = require("./test-utils");
|
|
37
37
|
const utils_1 = require("./utils");
|
|
38
38
|
const log = new logger_1.default({ sender: '@cumulus/aws-client/SQS' });
|
|
39
|
-
|
|
40
|
-
exports.
|
|
39
|
+
const getQueueNameFromUrl = (queueUrl) => queueUrl.split('/').pop();
|
|
40
|
+
exports.getQueueNameFromUrl = getQueueNameFromUrl;
|
|
41
|
+
const getQueueUrl = (sourceArn, queueName) => {
|
|
41
42
|
const arnParts = sourceArn.split(':');
|
|
42
43
|
return `https://sqs.${arnParts[3]}.amazonaws.com/${arnParts[4]}/${queueName}`;
|
|
43
44
|
};
|
|
44
|
-
exports.
|
|
45
|
-
|
|
45
|
+
exports.getQueueUrl = getQueueUrl;
|
|
46
|
+
const getQueueUrlByName = async (queueName) => {
|
|
47
|
+
const response = await (0, services_1.sqs)().getQueueUrl({ QueueName: queueName }).promise();
|
|
46
48
|
return response.QueueUrl;
|
|
47
49
|
};
|
|
50
|
+
exports.getQueueUrlByName = getQueueUrlByName;
|
|
48
51
|
/**
|
|
49
52
|
* Create an SQS Queue. Properly handles localstack queue URLs
|
|
50
53
|
*
|
|
@@ -54,12 +57,12 @@ exports.getQueueUrlByName = async (queueName) => {
|
|
|
54
57
|
* @static
|
|
55
58
|
*/
|
|
56
59
|
async function createQueue(QueueName) {
|
|
57
|
-
const createQueueResponse = await services_1.sqs().createQueue({
|
|
60
|
+
const createQueueResponse = await (0, services_1.sqs)().createQueue({
|
|
58
61
|
QueueName,
|
|
59
62
|
})
|
|
60
63
|
.on('error', (error) => log.error(error))
|
|
61
64
|
.promise();
|
|
62
|
-
if (test_utils_1.inTestMode()) {
|
|
65
|
+
if ((0, test_utils_1.inTestMode)()) {
|
|
63
66
|
if (createQueueResponse.QueueUrl === undefined) {
|
|
64
67
|
throw new Error('Did not receive a QueueUrl');
|
|
65
68
|
}
|
|
@@ -78,17 +81,18 @@ async function createQueue(QueueName) {
|
|
|
78
81
|
return createQueueResponse.QueueUrl;
|
|
79
82
|
}
|
|
80
83
|
exports.createQueue = createQueue;
|
|
81
|
-
|
|
84
|
+
const deleteQueue = (queueUrl) => (0, services_1.sqs)().deleteQueue({
|
|
82
85
|
QueueUrl: queueUrl,
|
|
83
86
|
})
|
|
84
87
|
.on('error', (error) => log.error(error))
|
|
85
88
|
.promise();
|
|
86
|
-
exports.
|
|
87
|
-
|
|
89
|
+
exports.deleteQueue = deleteQueue;
|
|
90
|
+
const getQueueAttributes = async (queueName) => {
|
|
91
|
+
const queueUrl = await (0, exports.getQueueUrlByName)(queueName);
|
|
88
92
|
if (!queueUrl) {
|
|
89
93
|
throw new Error(`Unable to determine QueueUrl of ${queueName}`);
|
|
90
94
|
}
|
|
91
|
-
const response = await services_1.sqs().getQueueAttributes({
|
|
95
|
+
const response = await (0, services_1.sqs)().getQueueAttributes({
|
|
92
96
|
AttributeNames: ['All'],
|
|
93
97
|
QueueUrl: queueUrl,
|
|
94
98
|
}).promise();
|
|
@@ -97,6 +101,7 @@ exports.getQueueAttributes = async (queueName) => {
|
|
|
97
101
|
name: queueName,
|
|
98
102
|
};
|
|
99
103
|
};
|
|
104
|
+
exports.getQueueAttributes = getQueueAttributes;
|
|
100
105
|
/**
|
|
101
106
|
* Send a message to AWS SQS
|
|
102
107
|
*
|
|
@@ -107,16 +112,16 @@ exports.getQueueAttributes = async (queueName) => {
|
|
|
107
112
|
* @returns {Promise} resolves when the messsage has been sent
|
|
108
113
|
|
|
109
114
|
**/
|
|
110
|
-
exports.sendSQSMessage = utils_1.improveStackTrace((queueUrl, message, logOverride) => {
|
|
115
|
+
exports.sendSQSMessage = (0, utils_1.improveStackTrace)((queueUrl, message, logOverride) => {
|
|
111
116
|
const logger = logOverride || log;
|
|
112
117
|
let messageBody;
|
|
113
|
-
if (isString_1.default(message))
|
|
118
|
+
if ((0, isString_1.default)(message))
|
|
114
119
|
messageBody = message;
|
|
115
|
-
else if (isObject_1.default(message))
|
|
120
|
+
else if ((0, isObject_1.default)(message))
|
|
116
121
|
messageBody = JSON.stringify(message);
|
|
117
122
|
else
|
|
118
123
|
throw new Error('body type is not accepted');
|
|
119
|
-
return services_1.sqs().sendMessage({
|
|
124
|
+
return (0, services_1.sqs)().sendMessage({
|
|
120
125
|
MessageBody: messageBody,
|
|
121
126
|
QueueUrl: queueUrl,
|
|
122
127
|
}).on('error', (error) => logger.error(error))
|
|
@@ -134,21 +139,23 @@ exports.sendSQSMessage = utils_1.improveStackTrace((queueUrl, message, logOverri
|
|
|
134
139
|
* @param {integer} [options.waitTimeSeconds=0] - number of seconds to poll SQS queue (long polling)
|
|
135
140
|
* @returns {Promise<Array>} an array of messages
|
|
136
141
|
*/
|
|
137
|
-
|
|
142
|
+
const receiveSQSMessages = async (queueUrl, options) => {
|
|
138
143
|
var _a;
|
|
139
144
|
const params = {
|
|
140
145
|
QueueUrl: queueUrl,
|
|
141
146
|
AttributeNames: ['All'],
|
|
142
147
|
// 0 is a valid value for VisibilityTimeout
|
|
143
|
-
VisibilityTimeout: isNil_1.default(options.visibilityTimeout) ? 30 : options.visibilityTimeout,
|
|
148
|
+
VisibilityTimeout: (0, isNil_1.default)(options.visibilityTimeout) ? 30 : options.visibilityTimeout,
|
|
144
149
|
WaitTimeSeconds: options.waitTimeSeconds || 0,
|
|
145
150
|
MaxNumberOfMessages: options.numOfMessages || 1,
|
|
146
151
|
};
|
|
147
|
-
const messages = await services_1.sqs().receiveMessage(params)
|
|
152
|
+
const messages = await (0, services_1.sqs)().receiveMessage(params)
|
|
148
153
|
.on('error', (error) => log.error(error)).promise();
|
|
149
154
|
return ((_a = messages.Messages) !== null && _a !== void 0 ? _a : []);
|
|
150
155
|
};
|
|
151
|
-
exports.
|
|
156
|
+
exports.receiveSQSMessages = receiveSQSMessages;
|
|
157
|
+
const parseSQSMessageBody = (message) => JSON.parse((0, get_1.default)(message, 'Body', (0, get_1.default)(message, 'body', '{}')));
|
|
158
|
+
exports.parseSQSMessageBody = parseSQSMessageBody;
|
|
152
159
|
/**
|
|
153
160
|
* Delete a given SQS message from a given queue.
|
|
154
161
|
*
|
|
@@ -156,7 +163,7 @@ exports.parseSQSMessageBody = (message) => JSON.parse(get_1.default(message, 'Bo
|
|
|
156
163
|
* @param {integer} receiptHandle - the unique identifier of the sQS message
|
|
157
164
|
* @returns {Promise} an AWS SQS response
|
|
158
165
|
*/
|
|
159
|
-
exports.deleteSQSMessage = utils_1.improveStackTrace((QueueUrl, ReceiptHandle) => services_1.sqs().deleteMessage({ QueueUrl, ReceiptHandle })
|
|
166
|
+
exports.deleteSQSMessage = (0, utils_1.improveStackTrace)((QueueUrl, ReceiptHandle) => (0, services_1.sqs)().deleteMessage({ QueueUrl, ReceiptHandle })
|
|
160
167
|
.on('error', (error) => log.error(error))
|
|
161
168
|
.promise());
|
|
162
169
|
/**
|
|
@@ -166,13 +173,13 @@ exports.deleteSQSMessage = utils_1.improveStackTrace((QueueUrl, ReceiptHandle) =
|
|
|
166
173
|
* @returns {Promise<boolean>} - a Promise that will resolve to a boolean indicating
|
|
167
174
|
* if the queue exists
|
|
168
175
|
*/
|
|
169
|
-
|
|
170
|
-
const QueueName = exports.getQueueNameFromUrl(queueUrl);
|
|
176
|
+
const sqsQueueExists = async (queueUrl) => {
|
|
177
|
+
const QueueName = (0, exports.getQueueNameFromUrl)(queueUrl);
|
|
171
178
|
if (!QueueName) {
|
|
172
179
|
throw new Error(`Unable to determine QueueName from ${queueUrl}`);
|
|
173
180
|
}
|
|
174
181
|
try {
|
|
175
|
-
await services_1.sqs().getQueueUrl({ QueueName }).promise();
|
|
182
|
+
await (0, services_1.sqs)().getQueueUrl({ QueueName }).promise();
|
|
176
183
|
return true;
|
|
177
184
|
}
|
|
178
185
|
catch (error) {
|
|
@@ -184,4 +191,5 @@ exports.sqsQueueExists = async (queueUrl) => {
|
|
|
184
191
|
throw error;
|
|
185
192
|
}
|
|
186
193
|
};
|
|
194
|
+
exports.sqsQueueExists = sqsQueueExists;
|
|
187
195
|
//# sourceMappingURL=SQS.js.map
|
package/SecretsManager.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getSecretString = void 0;
|
|
7
7
|
const services_1 = require("./services");
|
|
8
|
-
|
|
8
|
+
const getSecretString = (SecretId) => (0, services_1.secretsManager)().getSecretValue({ SecretId }).promise()
|
|
9
9
|
.then((response) => response.SecretString);
|
|
10
|
+
exports.getSecretString = getSecretString;
|
|
10
11
|
//# sourceMappingURL=SecretsManager.js.map
|
package/StepFunctions.d.ts
CHANGED
|
@@ -65,7 +65,9 @@ export declare const getExecutionHistory: (params: import("aws-sdk/clients/stepf
|
|
|
65
65
|
events: import("aws-sdk/clients/stepfunctions").HistoryEventList;
|
|
66
66
|
}>;
|
|
67
67
|
export declare const getExecutionStatus: (executionArn: string) => Promise<{
|
|
68
|
-
execution: import("aws-sdk/
|
|
68
|
+
execution: import("aws-sdk/clients/stepfunctions").DescribeExecutionOutput & {
|
|
69
|
+
$response: import("aws-sdk").Response<import("aws-sdk/clients/stepfunctions").DescribeExecutionOutput, import("aws-sdk").AWSError>;
|
|
70
|
+
};
|
|
69
71
|
executionHistory: {
|
|
70
72
|
events: import("aws-sdk/clients/stepfunctions").HistoryEventList;
|
|
71
73
|
};
|
package/StepFunctions.js
CHANGED
|
@@ -7,13 +7,14 @@ exports.listExecutions = exports.getExecutionStatus = exports.getExecutionHistor
|
|
|
7
7
|
const services_1 = require("./services");
|
|
8
8
|
const utils_1 = require("./utils");
|
|
9
9
|
// Utility functions
|
|
10
|
-
|
|
10
|
+
const doesExecutionExist = (describeExecutionPromise) => describeExecutionPromise
|
|
11
11
|
.then(() => true)
|
|
12
12
|
.catch((error) => {
|
|
13
13
|
if (error.code === 'ExecutionDoesNotExist')
|
|
14
14
|
return false;
|
|
15
15
|
throw error;
|
|
16
16
|
});
|
|
17
|
+
exports.doesExecutionExist = doesExecutionExist;
|
|
17
18
|
// Exported functions
|
|
18
19
|
/**
|
|
19
20
|
* Call StepFunctions DescribeExecution
|
|
@@ -29,7 +30,7 @@ exports.doesExecutionExist = (describeExecutionPromise) => describeExecutionProm
|
|
|
29
30
|
*
|
|
30
31
|
* @kind function
|
|
31
32
|
*/
|
|
32
|
-
exports.describeExecution = utils_1.improveStackTrace(utils_1.retryOnThrottlingException((params) => services_1.sfn().describeExecution(params).promise()));
|
|
33
|
+
exports.describeExecution = (0, utils_1.improveStackTrace)((0, utils_1.retryOnThrottlingException)((params) => (0, services_1.sfn)().describeExecution(params).promise()));
|
|
33
34
|
/**
|
|
34
35
|
* Call StepFunctions DescribeStateMachine
|
|
35
36
|
*
|
|
@@ -44,7 +45,7 @@ exports.describeExecution = utils_1.improveStackTrace(utils_1.retryOnThrottlingE
|
|
|
44
45
|
*
|
|
45
46
|
* @kind function
|
|
46
47
|
*/
|
|
47
|
-
exports.describeStateMachine = utils_1.improveStackTrace(utils_1.retryOnThrottlingException((params) => services_1.sfn().describeStateMachine(params).promise()));
|
|
48
|
+
exports.describeStateMachine = (0, utils_1.improveStackTrace)((0, utils_1.retryOnThrottlingException)((params) => (0, services_1.sfn)().describeStateMachine(params).promise()));
|
|
48
49
|
/**
|
|
49
50
|
* Check if a Step Function Execution exists
|
|
50
51
|
*
|
|
@@ -57,7 +58,8 @@ exports.describeStateMachine = utils_1.improveStackTrace(utils_1.retryOnThrottli
|
|
|
57
58
|
*
|
|
58
59
|
* @kind function
|
|
59
60
|
*/
|
|
60
|
-
|
|
61
|
+
const executionExists = (executionArn) => (0, exports.doesExecutionExist)((0, exports.describeExecution)({ executionArn }));
|
|
62
|
+
exports.executionExists = executionExists;
|
|
61
63
|
/**
|
|
62
64
|
* Call StepFunctions GetExecutionHistory
|
|
63
65
|
*
|
|
@@ -72,10 +74,10 @@ exports.executionExists = (executionArn) => exports.doesExecutionExist(exports.d
|
|
|
72
74
|
*
|
|
73
75
|
* @kind function
|
|
74
76
|
*/
|
|
75
|
-
exports.getExecutionHistory = utils_1.improveStackTrace(utils_1.retryOnThrottlingException(async (params, previousResponse = {
|
|
77
|
+
exports.getExecutionHistory = (0, utils_1.improveStackTrace)((0, utils_1.retryOnThrottlingException)(async (params, previousResponse = {
|
|
76
78
|
events: [],
|
|
77
79
|
}) => {
|
|
78
|
-
const response = await services_1.sfn().getExecutionHistory(params).promise();
|
|
80
|
+
const response = await (0, services_1.sfn)().getExecutionHistory(params).promise();
|
|
79
81
|
const events = [
|
|
80
82
|
...previousResponse.events,
|
|
81
83
|
...response.events,
|
|
@@ -83,7 +85,7 @@ exports.getExecutionHistory = utils_1.improveStackTrace(utils_1.retryOnThrottlin
|
|
|
83
85
|
// If there is a nextToken, recursively call this function to get all events
|
|
84
86
|
// in the execution history.
|
|
85
87
|
if (response.nextToken) {
|
|
86
|
-
return exports.getExecutionHistory({
|
|
88
|
+
return (0, exports.getExecutionHistory)({
|
|
87
89
|
...params,
|
|
88
90
|
nextToken: response.nextToken,
|
|
89
91
|
}, {
|
|
@@ -94,16 +96,17 @@ exports.getExecutionHistory = utils_1.improveStackTrace(utils_1.retryOnThrottlin
|
|
|
94
96
|
events,
|
|
95
97
|
};
|
|
96
98
|
}));
|
|
97
|
-
|
|
99
|
+
const getExecutionStatus = async (executionArn) => {
|
|
98
100
|
const [execution, executionHistory] = await Promise.all([
|
|
99
|
-
exports.describeExecution({ executionArn }),
|
|
100
|
-
exports.getExecutionHistory({ executionArn }),
|
|
101
|
+
(0, exports.describeExecution)({ executionArn }),
|
|
102
|
+
(0, exports.getExecutionHistory)({ executionArn }),
|
|
101
103
|
]);
|
|
102
|
-
const stateMachine = await exports.describeStateMachine({
|
|
104
|
+
const stateMachine = await (0, exports.describeStateMachine)({
|
|
103
105
|
stateMachineArn: execution.stateMachineArn,
|
|
104
106
|
});
|
|
105
107
|
return { execution, executionHistory, stateMachine };
|
|
106
108
|
};
|
|
109
|
+
exports.getExecutionStatus = getExecutionStatus;
|
|
107
110
|
/**
|
|
108
111
|
* Call StepFunctions ListExecutions
|
|
109
112
|
*
|
|
@@ -118,5 +121,5 @@ exports.getExecutionStatus = async (executionArn) => {
|
|
|
118
121
|
*
|
|
119
122
|
* @kind function
|
|
120
123
|
*/
|
|
121
|
-
exports.listExecutions = utils_1.improveStackTrace(utils_1.retryOnThrottlingException((params) => services_1.sfn().listExecutions(params).promise()));
|
|
124
|
+
exports.listExecutions = (0, utils_1.improveStackTrace)((0, utils_1.retryOnThrottlingException)((params) => (0, services_1.sfn)().listExecutions(params).promise()));
|
|
122
125
|
//# sourceMappingURL=StepFunctions.js.map
|
package/client.js
CHANGED
|
@@ -40,13 +40,13 @@ const awsClient = (Service, version, serviceOptions) => {
|
|
|
40
40
|
};
|
|
41
41
|
if (version)
|
|
42
42
|
options.apiVersion = version;
|
|
43
|
-
if (test_utils_1.inTestMode()) {
|
|
43
|
+
if ((0, test_utils_1.inTestMode)()) {
|
|
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
47
|
aws_sdk_1.default.DynamoDB.DocumentClient.serviceIdentifier = 'dynamodb';
|
|
48
48
|
}
|
|
49
|
-
return memoize((o) => test_utils_1.testAwsClient(Service, Object.assign(options, o)));
|
|
49
|
+
return memoize((o) => (0, test_utils_1.testAwsClient)(Service, Object.assign(options, o)));
|
|
50
50
|
}
|
|
51
51
|
return memoize((o) => new Service(Object.assign(options, o)));
|
|
52
52
|
};
|
package/index.js
CHANGED
|
@@ -14,11 +14,12 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
14
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
15
|
if (mod && mod.__esModule) return mod;
|
|
16
16
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.utils = exports.testUtils = exports.StepFunctions = exports.SQS = exports.SNS = exports.services = exports.S3 = exports.KMS = exports.DynamoDb = exports.CloudFormation = void 0;
|
|
22
23
|
exports.CloudFormation = __importStar(require("./CloudFormation"));
|
|
23
24
|
exports.DynamoDb = __importStar(require("./DynamoDb"));
|
|
24
25
|
exports.KMS = __importStar(require("./KMS"));
|
|
@@ -19,16 +19,21 @@ const MB = 1024 * 1024;
|
|
|
19
19
|
// From anecdotal testing, a chunk size of 250 MB seems to perform fairly well.
|
|
20
20
|
//
|
|
21
21
|
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPartCopy.html
|
|
22
|
-
|
|
22
|
+
const createMultipartChunks = (objectSize, maxChunkSize = 250 * MB) => (0, range_1.default)(0, objectSize, maxChunkSize)
|
|
23
23
|
.map((start) => ({
|
|
24
24
|
start,
|
|
25
25
|
end: Math.min(start + maxChunkSize, objectSize) - 1,
|
|
26
26
|
}));
|
|
27
|
-
exports.
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
exports.createMultipartChunks = createMultipartChunks;
|
|
28
|
+
const createMultipartUpload = async (params) => await (0, services_1.s3)().createMultipartUpload(params).promise();
|
|
29
|
+
exports.createMultipartUpload = createMultipartUpload;
|
|
30
|
+
const completeMultipartUpload = async (params) => {
|
|
31
|
+
const result = await (0, services_1.s3)().completeMultipartUpload(params).promise();
|
|
30
32
|
return result;
|
|
31
33
|
};
|
|
32
|
-
exports.
|
|
33
|
-
|
|
34
|
+
exports.completeMultipartUpload = completeMultipartUpload;
|
|
35
|
+
const abortMultipartUpload = async (params) => await (0, services_1.s3)().abortMultipartUpload(params).promise();
|
|
36
|
+
exports.abortMultipartUpload = abortMultipartUpload;
|
|
37
|
+
const uploadPartCopy = async (params) => await (0, services_1.s3)().uploadPartCopy(params).promise();
|
|
38
|
+
exports.uploadPartCopy = uploadPartCopy;
|
|
34
39
|
//# sourceMappingURL=S3MultipartUploads.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cumulus/aws-client",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.9.2",
|
|
4
4
|
"description": "Utilities for working with AWS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"GIBS",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"author": "Cumulus Authors",
|
|
44
44
|
"license": "Apache-2.0",
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@cumulus/checksum": "9.
|
|
47
|
-
"@cumulus/errors": "9.
|
|
48
|
-
"@cumulus/logger": "9.
|
|
46
|
+
"@cumulus/checksum": "9.9.2",
|
|
47
|
+
"@cumulus/errors": "9.9.2",
|
|
48
|
+
"@cumulus/logger": "9.9.2",
|
|
49
49
|
"aws-sdk": "^2.814.0",
|
|
50
50
|
"jsonpath-plus": "^1.1.0",
|
|
51
51
|
"lodash": "~4.17.20",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"p-wait-for": "^3.1.0",
|
|
55
55
|
"pump": "^3.0.0"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "0bfe94a0c4919567a35fc8bcff24643ba84a6547"
|
|
58
58
|
}
|
package/services.js
CHANGED
|
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
14
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
15
|
if (mod && mod.__esModule) return mod;
|
|
16
16
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
package/test-utils.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.throttleOnce = exports.testAwsClient = exports.getLocalstackEndpoint = exports.inTestMode = void 0;
|
|
4
4
|
const errors_1 = require("@cumulus/errors");
|
|
5
|
-
|
|
5
|
+
const inTestMode = () => process.env.NODE_ENV === 'test';
|
|
6
|
+
exports.inTestMode = inTestMode;
|
|
6
7
|
// From https://github.com/localstack/localstack/blob/master/README.md
|
|
7
8
|
const localStackPorts = {
|
|
8
9
|
stepfunctions: 4585,
|
|
@@ -111,7 +112,7 @@ exports.testAwsClient = testAwsClient;
|
|
|
111
112
|
*
|
|
112
113
|
* @private
|
|
113
114
|
*/
|
|
114
|
-
|
|
115
|
+
const throttleOnce = (fn) => {
|
|
115
116
|
let throttleNextCall = true;
|
|
116
117
|
return (...args) => {
|
|
117
118
|
if (throttleNextCall) {
|
|
@@ -121,4 +122,5 @@ exports.throttleOnce = (fn) => {
|
|
|
121
122
|
return fn(...args);
|
|
122
123
|
};
|
|
123
124
|
};
|
|
125
|
+
exports.throttleOnce = throttleOnce;
|
|
124
126
|
//# sourceMappingURL=test-utils.js.map
|
package/utils.js
CHANGED
|
@@ -8,7 +8,7 @@ const p_retry_1 = __importDefault(require("p-retry"));
|
|
|
8
8
|
const errors_1 = require("@cumulus/errors");
|
|
9
9
|
// Replace the stack of an error
|
|
10
10
|
// Note: This mutates the error that was passed in.
|
|
11
|
-
|
|
11
|
+
const setErrorStack = (error, newStack) => {
|
|
12
12
|
if (error.stack) {
|
|
13
13
|
// eslint-disable-next-line no-param-reassign
|
|
14
14
|
error.stack = [
|
|
@@ -21,6 +21,7 @@ exports.setErrorStack = (error, newStack) => {
|
|
|
21
21
|
error.stack = newStack;
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
+
exports.setErrorStack = setErrorStack;
|
|
24
25
|
// eslint-disable-next-line valid-jsdoc
|
|
25
26
|
/**
|
|
26
27
|
* Wrap a function and provide a better stack trace
|
|
@@ -33,7 +34,7 @@ exports.setErrorStack = (error, newStack) => {
|
|
|
33
34
|
*
|
|
34
35
|
* @private
|
|
35
36
|
*/
|
|
36
|
-
|
|
37
|
+
const improveStackTrace = (fn) => async (...args) => {
|
|
37
38
|
const tracerError = new Error();
|
|
38
39
|
try {
|
|
39
40
|
Error.captureStackTrace(tracerError);
|
|
@@ -41,13 +42,14 @@ exports.improveStackTrace = (fn) => async (...args) => {
|
|
|
41
42
|
}
|
|
42
43
|
catch (error) {
|
|
43
44
|
// @ts-ignore
|
|
44
|
-
exports.setErrorStack(error, tracerError.stack);
|
|
45
|
+
(0, exports.setErrorStack)(error, tracerError.stack);
|
|
45
46
|
error.message = `${error.message}; Function params: ${JSON.stringify(args, undefined, 2)}`;
|
|
46
47
|
throw error;
|
|
47
48
|
}
|
|
48
49
|
};
|
|
50
|
+
exports.improveStackTrace = improveStackTrace;
|
|
49
51
|
const retryIfThrottlingException = (err) => {
|
|
50
|
-
if (errors_1.isThrottlingException(err))
|
|
52
|
+
if ((0, errors_1.isThrottlingException)(err))
|
|
51
53
|
throw err;
|
|
52
54
|
throw new p_retry_1.default.AbortError(err);
|
|
53
55
|
};
|
|
@@ -63,5 +65,6 @@ const retryIfThrottlingException = (err) => {
|
|
|
63
65
|
*
|
|
64
66
|
* @private
|
|
65
67
|
*/
|
|
66
|
-
|
|
68
|
+
const retryOnThrottlingException = (fn, options = {}) => (...args) => (0, p_retry_1.default)(() => fn(...args).catch(retryIfThrottlingException), { maxTimeout: 5000, ...options });
|
|
69
|
+
exports.retryOnThrottlingException = retryOnThrottlingException;
|
|
67
70
|
//# sourceMappingURL=utils.js.map
|