@cumulus/aws-client
Advanced tools
Comparing version 9.7.0 to 9.8.0
@@ -43,3 +43,3 @@ "use strict"; | ||
options.apiVersion = version; | ||
if (test_utils_1.inTestMode()) { | ||
if ((0, test_utils_1.inTestMode)()) { | ||
// @ts-ignore - serviceIdentifier is not part of the public API and may break at any time | ||
@@ -50,3 +50,3 @@ if (aws_sdk_1.default.DynamoDB.DocumentClient.serviceIdentifier === undefined) { | ||
} | ||
return memoize((o) => test_utils_1.testAwsClient(Service, Object.assign(options, o))); | ||
return memoize((o) => (0, test_utils_1.testAwsClient)(Service, Object.assign(options, o))); | ||
} | ||
@@ -53,0 +53,0 @@ return memoize((o) => new Service(Object.assign(options, o))); |
@@ -20,4 +20,4 @@ "use strict"; | ||
*/ | ||
exports.describeCfStack = async (StackName) => { | ||
const response = await services_1.cf().describeStacks({ StackName }).promise(); | ||
const describeCfStack = async (StackName) => { | ||
const response = await (0, services_1.cf)().describeStacks({ StackName }).promise(); | ||
if (response.Stacks) | ||
@@ -27,2 +27,3 @@ return response.Stacks[0]; | ||
}; | ||
exports.describeCfStack = describeCfStack; | ||
/** | ||
@@ -36,6 +37,7 @@ * Describes the resources belonging to a given CloudFormation stack | ||
*/ | ||
exports.describeCfStackResources = async (StackName) => { | ||
const response = await services_1.cf().describeStackResources({ StackName }).promise(); | ||
const describeCfStackResources = async (StackName) => { | ||
const response = await (0, services_1.cf)().describeStackResources({ StackName }).promise(); | ||
return response.StackResources; | ||
}; | ||
exports.describeCfStackResources = describeCfStackResources; | ||
/** | ||
@@ -48,6 +50,6 @@ * Get parameter values for the given CloudFormation stack | ||
*/ | ||
exports.getCfStackParameterValues = async (stackName, parameterKeys) => { | ||
const getCfStackParameterValues = async (stackName, parameterKeys) => { | ||
let response; | ||
try { | ||
response = await exports.describeCfStack(stackName); | ||
response = await (0, exports.describeCfStack)(stackName); | ||
} | ||
@@ -62,4 +64,5 @@ catch (error) { | ||
}, {}); | ||
return pick_1.default(parameters, parameterKeys); | ||
return (0, pick_1.default)(parameters, parameterKeys); | ||
}; | ||
exports.getCfStackParameterValues = getCfStackParameterValues; | ||
//# sourceMappingURL=CloudFormation.js.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
async getStackStatus(StackName) { | ||
return await p_retry_1.default(async () => { | ||
return await (0, p_retry_1.default)(async () => { | ||
try { | ||
@@ -32,3 +32,3 @@ const stackDetails = await this.cloudFormationService.describeStacks({ | ||
catch (error) { | ||
if (errors_1.isThrottlingException(error)) | ||
if ((0, errors_1.isThrottlingException)(error)) | ||
throw new Error('Trigger retry'); | ||
@@ -35,0 +35,0 @@ throw new p_retry_1.default.AbortError(error); |
@@ -18,3 +18,3 @@ "use strict"; | ||
*/ | ||
exports.putEvent = (name, schedule, state, description, role) => services_1.cloudwatchevents().putRule({ | ||
const putEvent = (name, schedule, state, description, role) => (0, services_1.cloudwatchevents)().putRule({ | ||
Name: name, | ||
@@ -26,8 +26,11 @@ Description: description, | ||
}).promise(); | ||
exports.deleteEvent = (name) => services_1.cloudwatchevents().deleteRule({ Name: name }).promise(); | ||
exports.deleteTarget = (id, rule) => services_1.cloudwatchevents().removeTargets({ | ||
exports.putEvent = putEvent; | ||
const deleteEvent = (name) => (0, services_1.cloudwatchevents)().deleteRule({ Name: name }).promise(); | ||
exports.deleteEvent = deleteEvent; | ||
const deleteTarget = (id, rule) => (0, services_1.cloudwatchevents)().removeTargets({ | ||
Ids: [id], | ||
Rule: rule, | ||
}).promise(); | ||
exports.putTarget = (rule, id, arn, input) => services_1.cloudwatchevents().putTargets({ | ||
exports.deleteTarget = deleteTarget; | ||
const putTarget = (rule, id, arn, input) => (0, services_1.cloudwatchevents)().putTargets({ | ||
Rule: rule, | ||
@@ -42,2 +45,3 @@ Targets: [ | ||
}).promise(); | ||
exports.putTarget = putTarget; | ||
//# sourceMappingURL=CloudwatchEvents.js.map |
@@ -30,3 +30,3 @@ "use strict"; | ||
*/ | ||
exports.get = utils_1.improveStackTrace(async (params) => { | ||
exports.get = (0, utils_1.improveStackTrace)(async (params) => { | ||
const { client, getParams = {}, item, tableName, } = params; | ||
@@ -51,3 +51,3 @@ const getResponse = await client.get({ | ||
*/ | ||
exports.scan = utils_1.improveStackTrace(async (params) => { | ||
exports.scan = (0, utils_1.improveStackTrace)(async (params) => { | ||
const { client, fields, limit, query, select, startKey, tableName, } = params; | ||
@@ -81,3 +81,3 @@ const scanParams = { | ||
if (response.LastEvaluatedKey) { | ||
const more = await exports.scan({ | ||
const more = await (0, exports.scan)({ | ||
tableName, | ||
@@ -117,5 +117,5 @@ client, | ||
*/ | ||
exports.parallelScan = async (params) => { | ||
const { totalSegments, scanParams, processItemsFunc, dynamoDbClient = services_1.dynamodbDocClient(), retryOptions, } = params; | ||
return await p_map_1.default(range_1.default(totalSegments), async (_, segmentIndex) => { | ||
const parallelScan = async (params) => { | ||
const { totalSegments, scanParams, processItemsFunc, dynamoDbClient = (0, services_1.dynamodbDocClient)(), retryOptions, } = params; | ||
return await (0, p_map_1.default)((0, range_1.default)(totalSegments), async (_, segmentIndex) => { | ||
let exclusiveStartKey; | ||
@@ -129,3 +129,3 @@ const segmentScanParams = { | ||
do { | ||
const { Items = [], LastEvaluatedKey, } = await p_retry_1.default(() => dynamoDbClient.scan(segmentScanParams).promise(), retryOptions); | ||
const { Items = [], LastEvaluatedKey, } = await (0, p_retry_1.default)(() => dynamoDbClient.scan(segmentScanParams).promise(), retryOptions); | ||
exclusiveStartKey = LastEvaluatedKey; | ||
@@ -141,2 +141,3 @@ segmentScanParams.ExclusiveStartKey = exclusiveStartKey; | ||
}; | ||
exports.parallelScan = parallelScan; | ||
/** | ||
@@ -152,4 +153,4 @@ * Create a DynamoDB table and then wait for the table to exist | ||
async function createAndWaitForDynamoDbTable(params) { | ||
const createTableResult = await services_1.dynamodb().createTable(params).promise(); | ||
await services_1.dynamodb().waitFor('tableExists', { TableName: params.TableName }).promise(); | ||
const createTableResult = await (0, services_1.dynamodb)().createTable(params).promise(); | ||
await (0, services_1.dynamodb)().waitFor('tableExists', { TableName: params.TableName }).promise(); | ||
return createTableResult; | ||
@@ -168,6 +169,6 @@ } | ||
async function deleteAndWaitForDynamoDbTableNotExists(params) { | ||
await services_1.dynamodb().deleteTable(params).promise(); | ||
return services_1.dynamodb().waitFor('tableNotExists', { TableName: params.TableName }).promise(); | ||
await (0, services_1.dynamodb)().deleteTable(params).promise(); | ||
return (0, services_1.dynamodb)().waitFor('tableNotExists', { TableName: params.TableName }).promise(); | ||
} | ||
exports.deleteAndWaitForDynamoDbTableNotExists = deleteAndWaitForDynamoDbTableNotExists; | ||
//# sourceMappingURL=DynamoDb.js.map |
import * as AWS from 'aws-sdk'; | ||
declare type searchType = 'scan' | 'query'; | ||
declare type SearchType = 'scan' | 'query'; | ||
/** | ||
@@ -12,3 +12,3 @@ * Class to efficiently search all of the items in a DynamoDB table, without loading them all into | ||
private items; | ||
constructor(params: AWS.DynamoDB.DocumentClient.ScanInput, searchType?: searchType); | ||
constructor(params: AWS.DynamoDB.DocumentClient.ScanInput, searchType?: SearchType); | ||
/** | ||
@@ -15,0 +15,0 @@ * Drain all values from the searchQueue, and return to the user. |
@@ -11,3 +11,3 @@ "use strict"; | ||
this.params = params; | ||
this.dynamodbDocClient = services_1.dynamodbDocClient(); | ||
this.dynamodbDocClient = (0, services_1.dynamodbDocClient)(); | ||
this.searchType = searchType; | ||
@@ -14,0 +14,0 @@ } |
@@ -17,3 +17,3 @@ "use strict"; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
@@ -23,2 +23,3 @@ return result; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.utils = exports.testUtils = exports.StepFunctions = exports.SQS = exports.SNS = exports.services = exports.S3 = exports.KMS = exports.DynamoDb = exports.CloudFormation = void 0; | ||
exports.CloudFormation = __importStar(require("./CloudFormation")); | ||
@@ -25,0 +26,0 @@ exports.DynamoDb = __importStar(require("./DynamoDb")); |
@@ -20,5 +20,5 @@ "use strict"; | ||
*/ | ||
exports.describeStream = (params, retryOptions = { retries: 0 }) => p_retry_1.default(async () => { | ||
const describeStream = (params, retryOptions = { retries: 0 }) => (0, p_retry_1.default)(async () => { | ||
try { | ||
return await services_1.kinesis().describeStream(params).promise(); | ||
return await (0, services_1.kinesis)().describeStream(params).promise(); | ||
} | ||
@@ -31,2 +31,3 @@ catch (error) { | ||
}, { maxTimeout: 10000, ...retryOptions }); | ||
exports.describeStream = describeStream; | ||
//# sourceMappingURL=Kinesis.js.map |
13
KMS.js
@@ -17,3 +17,4 @@ "use strict"; | ||
*/ | ||
exports.createKey = (params = {}) => services_1.kms().createKey(params).promise(); | ||
const createKey = (params = {}) => (0, services_1.kms)().createKey(params).promise(); | ||
exports.createKey = createKey; | ||
/** | ||
@@ -26,4 +27,4 @@ * Encrypt a string using KMS | ||
*/ | ||
exports.encrypt = async (KeyId, Plaintext) => { | ||
const { CiphertextBlob } = await services_1.kms().encrypt({ KeyId, Plaintext }).promise(); | ||
const encrypt = async (KeyId, Plaintext) => { | ||
const { CiphertextBlob } = await (0, services_1.kms)().encrypt({ KeyId, Plaintext }).promise(); | ||
if (CiphertextBlob === undefined) | ||
@@ -33,2 +34,3 @@ throw new Error('Returned CiphertextBlob is undefined'); | ||
}; | ||
exports.encrypt = encrypt; | ||
/** | ||
@@ -40,4 +42,4 @@ * Decrypt a KMS-encrypted string, Base 64 encoded | ||
*/ | ||
exports.decryptBase64String = async (ciphertext) => { | ||
const { Plaintext } = await services_1.kms().decrypt({ | ||
const decryptBase64String = async (ciphertext) => { | ||
const { Plaintext } = await (0, services_1.kms)().decrypt({ | ||
CiphertextBlob: Buffer.from(ciphertext, 'base64'), | ||
@@ -49,2 +51,3 @@ }).promise(); | ||
}; | ||
exports.decryptBase64String = decryptBase64String; | ||
//# sourceMappingURL=KMS.js.map |
@@ -24,4 +24,4 @@ "use strict"; | ||
*/ | ||
exports.invoke = async (name, payload, type = 'Event') => { | ||
if (process.env.IS_LOCAL || test_utils_1.inTestMode()) { | ||
const invoke = async (name, payload, type = 'Event') => { | ||
if (process.env.IS_LOCAL || (0, test_utils_1.inTestMode)()) { | ||
log.info(`Faking Lambda invocation for ${name}`); | ||
@@ -31,3 +31,3 @@ return false; | ||
log.info(`Invoking ${name}`); | ||
return await services_1.lambda().invoke({ | ||
return await (0, services_1.lambda)().invoke({ | ||
FunctionName: name, | ||
@@ -40,2 +40,3 @@ Payload: JSON.stringify(payload), | ||
}; | ||
exports.invoke = invoke; | ||
//# sourceMappingURL=Lambda.js.map |
@@ -22,3 +22,3 @@ "use strict"; | ||
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPartCopy.html | ||
exports.createMultipartChunks = (objectSize, maxChunkSize = 250 * MB) => range_1.default(0, objectSize, maxChunkSize) | ||
const createMultipartChunks = (objectSize, maxChunkSize = 250 * MB) => (0, range_1.default)(0, objectSize, maxChunkSize) | ||
.map((start) => ({ | ||
@@ -28,9 +28,14 @@ start, | ||
})); | ||
exports.createMultipartUpload = async (params) => await services_1.s3().createMultipartUpload(params).promise(); | ||
exports.completeMultipartUpload = async (params) => { | ||
const result = await services_1.s3().completeMultipartUpload(params).promise(); | ||
exports.createMultipartChunks = createMultipartChunks; | ||
const createMultipartUpload = async (params) => await (0, services_1.s3)().createMultipartUpload(params).promise(); | ||
exports.createMultipartUpload = createMultipartUpload; | ||
const completeMultipartUpload = async (params) => { | ||
const result = await (0, services_1.s3)().completeMultipartUpload(params).promise(); | ||
return result; | ||
}; | ||
exports.abortMultipartUpload = async (params) => await services_1.s3().abortMultipartUpload(params).promise(); | ||
exports.uploadPartCopy = async (params) => await services_1.s3().uploadPartCopy(params).promise(); | ||
exports.completeMultipartUpload = completeMultipartUpload; | ||
const abortMultipartUpload = async (params) => await (0, services_1.s3)().abortMultipartUpload(params).promise(); | ||
exports.abortMultipartUpload = abortMultipartUpload; | ||
const uploadPartCopy = async (params) => await (0, services_1.s3)().uploadPartCopy(params).promise(); | ||
exports.uploadPartCopy = uploadPartCopy; | ||
//# sourceMappingURL=S3MultipartUploads.js.map |
{ | ||
"name": "@cumulus/aws-client", | ||
"version": "9.7.0", | ||
"version": "9.8.0", | ||
"description": "Utilities for working with AWS", | ||
@@ -46,5 +46,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@cumulus/checksum": "9.7.0", | ||
"@cumulus/errors": "9.7.0", | ||
"@cumulus/logger": "9.7.0", | ||
"@cumulus/checksum": "9.8.0", | ||
"@cumulus/errors": "9.8.0", | ||
"@cumulus/logger": "9.8.0", | ||
"aws-sdk": "^2.814.0", | ||
@@ -58,3 +58,3 @@ "jsonpath-plus": "^1.1.0", | ||
}, | ||
"gitHead": "08fb2c1d9113e7be465316f950d4ac9272bd3141" | ||
"gitHead": "913034ba6814e562b7f3d58bb39cf086255a6efd" | ||
} |
482
README.md
@@ -77,9 +77,9 @@ # @cumulus/aws-client | ||
* [CloudFormation](#module_CloudFormation) | ||
* [.describeCfStack(StackName)](#module_CloudFormation.describeCfStack) ⇒ <code>Promise.<CloudFormation.Stack></code> | ||
* [.describeCfStackResources(StackName)](#module_CloudFormation.describeCfStackResources) ⇒ <code>Promise.<CloudFormation.StackResources></code> | ||
* [.getCfStackParameterValues(stackName, parameterKeys)](#module_CloudFormation.getCfStackParameterValues) ⇒ <code>Promise.<Object></code> | ||
* [~describeCfStack(StackName)](#module_CloudFormation..describeCfStack) ⇒ <code>Promise.<CloudFormation.Stack></code> | ||
* [~describeCfStackResources(StackName)](#module_CloudFormation..describeCfStackResources) ⇒ <code>Promise.<CloudFormation.StackResources></code> | ||
* [~getCfStackParameterValues(stackName, parameterKeys)](#module_CloudFormation..getCfStackParameterValues) ⇒ <code>Promise.<Object></code> | ||
<a name="module_CloudFormation.describeCfStack"></a> | ||
<a name="module_CloudFormation..describeCfStack"></a> | ||
### CloudFormation.describeCfStack(StackName) ⇒ <code>Promise.<CloudFormation.Stack></code> | ||
### CloudFormation~describeCfStack(StackName) ⇒ <code>Promise.<CloudFormation.Stack></code> | ||
Describes a given CloudFormation stack | ||
@@ -89,3 +89,3 @@ | ||
**Kind**: static method of [<code>CloudFormation</code>](#module_CloudFormation) | ||
**Kind**: inner method of [<code>CloudFormation</code>](#module_CloudFormation) | ||
**Returns**: <code>Promise.<CloudFormation.Stack></code> - The resources belonging to the stack | ||
@@ -97,5 +97,5 @@ | ||
<a name="module_CloudFormation.describeCfStackResources"></a> | ||
<a name="module_CloudFormation..describeCfStackResources"></a> | ||
### CloudFormation.describeCfStackResources(StackName) ⇒ <code>Promise.<CloudFormation.StackResources></code> | ||
### CloudFormation~describeCfStackResources(StackName) ⇒ <code>Promise.<CloudFormation.StackResources></code> | ||
Describes the resources belonging to a given CloudFormation stack | ||
@@ -105,3 +105,3 @@ | ||
**Kind**: static method of [<code>CloudFormation</code>](#module_CloudFormation) | ||
**Kind**: inner method of [<code>CloudFormation</code>](#module_CloudFormation) | ||
**Returns**: <code>Promise.<CloudFormation.StackResources></code> - The resources belonging to the stack | ||
@@ -113,8 +113,8 @@ | ||
<a name="module_CloudFormation.getCfStackParameterValues"></a> | ||
<a name="module_CloudFormation..getCfStackParameterValues"></a> | ||
### CloudFormation.getCfStackParameterValues(stackName, parameterKeys) ⇒ <code>Promise.<Object></code> | ||
### CloudFormation~getCfStackParameterValues(stackName, parameterKeys) ⇒ <code>Promise.<Object></code> | ||
Get parameter values for the given CloudFormation stack | ||
**Kind**: static method of [<code>CloudFormation</code>](#module_CloudFormation) | ||
**Kind**: inner method of [<code>CloudFormation</code>](#module_CloudFormation) | ||
**Returns**: <code>Promise.<Object></code> - Object keyed by parameter names | ||
@@ -130,8 +130,8 @@ | ||
## CloudwatchEvents | ||
<a name="module_CloudwatchEvents.putEvent"></a> | ||
<a name="module_CloudwatchEvents..putEvent"></a> | ||
### CloudwatchEvents.putEvent(name, schedule, state, [description], [role]) ⇒ <code>Promise.<CloudWatchEvents.PutRuleResponse></code> | ||
### CloudwatchEvents~putEvent(name, schedule, state, [description], [role]) ⇒ <code>Promise.<CloudWatchEvents.PutRuleResponse></code> | ||
Create a CloudWatch Events rule | ||
**Kind**: static method of [<code>CloudwatchEvents</code>](#module_CloudwatchEvents) | ||
**Kind**: inner method of [<code>CloudwatchEvents</code>](#module_CloudwatchEvents) | ||
@@ -151,7 +151,9 @@ | Param | Type | Description | | ||
* [DynamoDb](#module_DynamoDb) | ||
* [.get](#module_DynamoDb.get) ⇒ <code>Promise.<Object></code> | ||
* [.scan](#module_DynamoDb.scan) ⇒ <code>Promise.<Object></code> | ||
* [.parallelScan(params)](#module_DynamoDb.parallelScan) ⇒ <code>Promise</code> | ||
* [.createAndWaitForDynamoDbTable(params)](#module_DynamoDb.createAndWaitForDynamoDbTable) ⇒ <code>Promise.<Object></code> | ||
* [.deleteAndWaitForDynamoDbTableNotExists(params)](#module_DynamoDb.deleteAndWaitForDynamoDbTableNotExists) ⇒ <code>Promise</code> | ||
* _static_ | ||
* [.get](#module_DynamoDb.get) ⇒ <code>Promise.<Object></code> | ||
* [.scan](#module_DynamoDb.scan) ⇒ <code>Promise.<Object></code> | ||
* [.createAndWaitForDynamoDbTable(params)](#module_DynamoDb.createAndWaitForDynamoDbTable) ⇒ <code>Promise.<Object></code> | ||
* [.deleteAndWaitForDynamoDbTableNotExists(params)](#module_DynamoDb.deleteAndWaitForDynamoDbTableNotExists) ⇒ <code>Promise</code> | ||
* _inner_ | ||
* [~parallelScan(params)](#module_DynamoDb..parallelScan) ⇒ <code>Promise</code> | ||
@@ -194,21 +196,2 @@ <a name="module_DynamoDb.get"></a> | ||
<a name="module_DynamoDb.parallelScan"></a> | ||
### DynamoDb.parallelScan(params) ⇒ <code>Promise</code> | ||
Do a parallel scan of DynamoDB table using a document client. | ||
See https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html#Scan.ParallelScan. | ||
See [DocumentClient.scan()](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#scan-property). | ||
**Kind**: static method of [<code>DynamoDb</code>](#module_DynamoDb) | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| params | <code>Object</code> | | | ||
| params.totalSegments | <code>number</code> | Total number of segments to divide table into for parallel scanning | | ||
| params.scanParams | <code>DocumentClient.ScanInput</code> | Params for the DynamoDB client scan operation See https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Scan.html | | ||
| params.processItemsFunc | <code>function</code> | Function used to process returned items by scan | | ||
| [params.dynamoDbClient] | <code>DocumentClient</code> | Instance of Dynamo DB document client | | ||
| [params.retryOptions] | <code>pRetry.Options</code> | Retry options for scan operations | | ||
<a name="module_DynamoDb.createAndWaitForDynamoDbTable"></a> | ||
@@ -237,2 +220,21 @@ | ||
<a name="module_DynamoDb..parallelScan"></a> | ||
### DynamoDb~parallelScan(params) ⇒ <code>Promise</code> | ||
Do a parallel scan of DynamoDB table using a document client. | ||
See https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html#Scan.ParallelScan. | ||
See [DocumentClient.scan()](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#scan-property). | ||
**Kind**: inner method of [<code>DynamoDb</code>](#module_DynamoDb) | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| params | <code>Object</code> | | | ||
| params.totalSegments | <code>number</code> | Total number of segments to divide table into for parallel scanning | | ||
| params.scanParams | <code>DocumentClient.ScanInput</code> | Params for the DynamoDB client scan operation See https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Scan.html | | ||
| params.processItemsFunc | <code>function</code> | Function used to process returned items by scan | | ||
| [params.dynamoDbClient] | <code>DocumentClient</code> | Instance of Dynamo DB document client | | ||
| [params.retryOptions] | <code>pRetry.Options</code> | Retry options for scan operations | | ||
<a name="module_KMS"></a> | ||
@@ -243,9 +245,9 @@ | ||
* [KMS](#module_KMS) | ||
* [.createKey(params)](#module_KMS.createKey) ⇒ <code>Promise.<Object></code> | ||
* [.encrypt(KeyId, Plaintext)](#module_KMS.encrypt) ⇒ <code>Promise.<string></code> | ||
* [.decryptBase64String(ciphertext)](#module_KMS.decryptBase64String) ⇒ <code>string</code> | ||
* [~createKey(params)](#module_KMS..createKey) ⇒ <code>Promise.<Object></code> | ||
* [~encrypt(KeyId, Plaintext)](#module_KMS..encrypt) ⇒ <code>Promise.<string></code> | ||
* [~decryptBase64String(ciphertext)](#module_KMS..decryptBase64String) ⇒ <code>string</code> | ||
<a name="module_KMS.createKey"></a> | ||
<a name="module_KMS..createKey"></a> | ||
### KMS.createKey(params) ⇒ <code>Promise.<Object></code> | ||
### KMS~createKey(params) ⇒ <code>Promise.<Object></code> | ||
Create a KMS key | ||
@@ -256,3 +258,3 @@ | ||
**Kind**: static method of [<code>KMS</code>](#module_KMS) | ||
**Kind**: inner method of [<code>KMS</code>](#module_KMS) | ||
@@ -263,8 +265,8 @@ | Param | Type | | ||
<a name="module_KMS.encrypt"></a> | ||
<a name="module_KMS..encrypt"></a> | ||
### KMS.encrypt(KeyId, Plaintext) ⇒ <code>Promise.<string></code> | ||
### KMS~encrypt(KeyId, Plaintext) ⇒ <code>Promise.<string></code> | ||
Encrypt a string using KMS | ||
**Kind**: static method of [<code>KMS</code>](#module_KMS) | ||
**Kind**: inner method of [<code>KMS</code>](#module_KMS) | ||
**Returns**: <code>Promise.<string></code> - the Base 64 encoding of the encrypted value | ||
@@ -277,8 +279,8 @@ | ||
<a name="module_KMS.decryptBase64String"></a> | ||
<a name="module_KMS..decryptBase64String"></a> | ||
### KMS.decryptBase64String(ciphertext) ⇒ <code>string</code> | ||
### KMS~decryptBase64String(ciphertext) ⇒ <code>string</code> | ||
Decrypt a KMS-encrypted string, Base 64 encoded | ||
**Kind**: static method of [<code>KMS</code>](#module_KMS) | ||
**Kind**: inner method of [<code>KMS</code>](#module_KMS) | ||
**Returns**: <code>string</code> - the plaintext | ||
@@ -293,8 +295,8 @@ | ||
## Kinesis | ||
<a name="module_Kinesis.describeStream"></a> | ||
<a name="module_Kinesis..describeStream"></a> | ||
### Kinesis.describeStream(params, retryOptions) ⇒ <code>Promise.<Object></code> | ||
### Kinesis~describeStream(params, retryOptions) ⇒ <code>Promise.<Object></code> | ||
Describe a Kinesis stream. | ||
**Kind**: static method of [<code>Kinesis</code>](#module_Kinesis) | ||
**Kind**: inner method of [<code>Kinesis</code>](#module_Kinesis) | ||
**Returns**: <code>Promise.<Object></code> - The stream description response | ||
@@ -318,7 +320,7 @@ | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| name | <code>string</code> | Lambda function name | | ||
| payload | <code>any</code> | the payload to the Lambda function | | ||
| type | <code>string</code> | the invocation type | | ||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| name | <code>string</code> | | Lambda function name | | ||
| payload | <code>any</code> | | the payload to the Lambda function | | ||
| type | <code>string</code> | <code>"Event"</code> | the invocation type | | ||
@@ -330,39 +332,41 @@ <a name="module_S3"></a> | ||
* [S3](#module_S3) | ||
* [.deleteS3Object](#module_S3.deleteS3Object) | ||
* [.headObject](#module_S3.headObject) ⇒ <code>Promise</code> | ||
* [.s3PutObject](#module_S3.s3PutObject) | ||
* [.s3CopyObject](#module_S3.s3CopyObject) ⇒ <code>Promise</code> | ||
* [.promiseS3Upload](#module_S3.promiseS3Upload) ⇒ <code>Promise</code> | ||
* [.s3GetObjectTagging](#module_S3.s3GetObjectTagging) ⇒ <code>Promise.<AWS.S3.GetObjectTaggingOutput></code> | ||
* [.s3PutObjectTagging](#module_S3.s3PutObjectTagging) ⇒ <code>Promise</code> | ||
* ~~[.getS3Object](#module_S3.getS3Object) ⇒ <code>Promise</code>~~ | ||
* [.recursivelyDeleteS3Bucket](#module_S3.recursivelyDeleteS3Bucket) ⇒ <code>Promise</code> | ||
* [.s3Join(args)](#module_S3.s3Join) ⇒ <code>string</code> | ||
* [.parseS3Uri(uri)](#module_S3.parseS3Uri) ⇒ <code>Object</code> | ||
* [.buildS3Uri(bucket, key)](#module_S3.buildS3Uri) ⇒ <code>string</code> | ||
* [.s3TagSetToQueryString(tagset)](#module_S3.s3TagSetToQueryString) ⇒ <code>string</code> | ||
* [.s3ObjectExists(params)](#module_S3.s3ObjectExists) ⇒ <code>Promise.<boolean></code> | ||
* [.waitForObjectToExist(params)](#module_S3.waitForObjectToExist) ⇒ <code>Promise.<undefined></code> | ||
* [.putFile(bucket, key, filename)](#module_S3.putFile) ⇒ <code>Promise</code> | ||
* [.streamS3Upload(uploadStream, uploadParams)](#module_S3.streamS3Upload) ⇒ <code>Promise</code> | ||
* [.downloadS3File(s3Obj, filepath)](#module_S3.downloadS3File) ⇒ <code>Promise.<string></code> | ||
* [.getObjectSize(params)](#module_S3.getObjectSize) ⇒ <code>Promise.<(number\|undefined)></code> | ||
* [.getObject(s3, params)](#module_S3.getObject) ⇒ <code>Promise.<AWS.S3.GetObjectOutput></code> | ||
* [.waitForObject(s3Client, params, [retryOptions])](#module_S3.waitForObject) ⇒ <code>Promise.<AWS.S3.GetObjectOutput></code> | ||
* [.getTextObject(bucket, key)](#module_S3.getTextObject) ⇒ <code>Promise.<string></code> | ||
* [.getJsonS3Object(bucket, key)](#module_S3.getJsonS3Object) ⇒ <code>Promise.<\*></code> | ||
* [.getObjectReadStream(params)](#module_S3.getObjectReadStream) ⇒ <code>Readable</code> | ||
* [.fileExists(bucket, key)](#module_S3.fileExists) ⇒ <code>Promise</code> | ||
* [.deleteS3Files(s3Objs)](#module_S3.deleteS3Files) ⇒ <code>Promise</code> | ||
* [.deleteS3Buckets(buckets)](#module_S3.deleteS3Buckets) ⇒ <code>Promise</code> | ||
* [.uploadS3FileStream(fileStream, bucket, key, s3opts)](#module_S3.uploadS3FileStream) ⇒ <code>Promise</code> | ||
* [.listS3Objects(bucket, prefix, skipFolders)](#module_S3.listS3Objects) ⇒ <code>Promise</code> | ||
* [.listS3ObjectsV2(params)](#module_S3.listS3ObjectsV2) ⇒ <code>Promise.<Array></code> | ||
* [.calculateObjectHash(params)](#module_S3.calculateObjectHash) | ||
* [.validateS3ObjectChecksum(params)](#module_S3.validateS3ObjectChecksum) ⇒ <code>Promise.<boolean></code> | ||
* [.getFileBucketAndKey(pathParams)](#module_S3.getFileBucketAndKey) ⇒ <code>Array.<string></code> | ||
* [.createBucket(Bucket)](#module_S3.createBucket) ⇒ <code>Promise</code> | ||
* [.createS3Buckets(buckets)](#module_S3.createS3Buckets) ⇒ <code>Promise</code> | ||
* [.multipartCopyObject(params)](#module_S3.multipartCopyObject) ⇒ <code>Promise.<{etag: string}></code> | ||
* [.moveObject(params)](#module_S3.moveObject) ⇒ <code>Promise.<undefined></code> | ||
* _static_ | ||
* [.deleteS3Object](#module_S3.deleteS3Object) | ||
* [.headObject](#module_S3.headObject) ⇒ <code>Promise</code> | ||
* [.s3PutObject](#module_S3.s3PutObject) | ||
* [.s3CopyObject](#module_S3.s3CopyObject) ⇒ <code>Promise</code> | ||
* [.promiseS3Upload](#module_S3.promiseS3Upload) ⇒ <code>Promise</code> | ||
* [.s3GetObjectTagging](#module_S3.s3GetObjectTagging) ⇒ <code>Promise.<AWS.S3.GetObjectTaggingOutput></code> | ||
* [.s3PutObjectTagging](#module_S3.s3PutObjectTagging) ⇒ <code>Promise</code> | ||
* ~~[.getS3Object](#module_S3.getS3Object) ⇒ <code>Promise</code>~~ | ||
* [.recursivelyDeleteS3Bucket](#module_S3.recursivelyDeleteS3Bucket) ⇒ <code>Promise</code> | ||
* [.listS3ObjectsV2(params)](#module_S3.listS3ObjectsV2) ⇒ <code>Promise.<Array></code> | ||
* _inner_ | ||
* [~s3Join(...args)](#module_S3..s3Join) ⇒ <code>string</code> | ||
* [~parseS3Uri(uri)](#module_S3..parseS3Uri) ⇒ <code>Object</code> | ||
* [~buildS3Uri(bucket, key)](#module_S3..buildS3Uri) ⇒ <code>string</code> | ||
* [~s3TagSetToQueryString(tagset)](#module_S3..s3TagSetToQueryString) ⇒ <code>string</code> | ||
* [~s3ObjectExists(params)](#module_S3..s3ObjectExists) ⇒ <code>Promise.<boolean></code> | ||
* [~waitForObjectToExist(params)](#module_S3..waitForObjectToExist) ⇒ <code>Promise.<undefined></code> | ||
* [~putFile(bucket, key, filename)](#module_S3..putFile) ⇒ <code>Promise</code> | ||
* [~streamS3Upload(uploadStream, uploadParams)](#module_S3..streamS3Upload) ⇒ <code>Promise</code> | ||
* [~downloadS3File(s3Obj, filepath)](#module_S3..downloadS3File) ⇒ <code>Promise.<string></code> | ||
* [~getObjectSize(params)](#module_S3..getObjectSize) ⇒ <code>Promise.<(number\|undefined)></code> | ||
* [~getObject(s3Client, params)](#module_S3..getObject) ⇒ <code>Promise.<AWS.S3.GetObjectOutput></code> | ||
* [~waitForObject(s3Client, params, [retryOptions])](#module_S3..waitForObject) ⇒ <code>Promise.<AWS.S3.GetObjectOutput></code> | ||
* [~getTextObject(bucket, key)](#module_S3..getTextObject) ⇒ <code>Promise.<string></code> | ||
* [~getJsonS3Object(bucket, key)](#module_S3..getJsonS3Object) ⇒ <code>Promise.<\*></code> | ||
* [~getObjectReadStream(params)](#module_S3..getObjectReadStream) ⇒ <code>Readable</code> | ||
* [~fileExists(bucket, key)](#module_S3..fileExists) ⇒ <code>Promise</code> | ||
* [~deleteS3Files(s3Objs)](#module_S3..deleteS3Files) ⇒ <code>Promise</code> | ||
* [~deleteS3Buckets(buckets)](#module_S3..deleteS3Buckets) ⇒ <code>Promise</code> | ||
* [~uploadS3FileStream(fileStream, bucket, key, s3opts)](#module_S3..uploadS3FileStream) ⇒ <code>Promise</code> | ||
* [~listS3Objects(bucket, prefix, skipFolders)](#module_S3..listS3Objects) ⇒ <code>Promise</code> | ||
* [~calculateObjectHash(params)](#module_S3..calculateObjectHash) | ||
* [~validateS3ObjectChecksum(params)](#module_S3..validateS3ObjectChecksum) ⇒ <code>Promise.<boolean></code> | ||
* [~getFileBucketAndKey(pathParams)](#module_S3..getFileBucketAndKey) ⇒ <code>Array.<string></code> | ||
* [~createBucket(Bucket)](#module_S3..createBucket) ⇒ <code>Promise</code> | ||
* [~createS3Buckets(buckets)](#module_S3..createS3Buckets) ⇒ <code>Promise</code> | ||
* [~multipartCopyObject(params)](#module_S3..multipartCopyObject) ⇒ <code>Promise.<{etag: string}></code> | ||
* [~moveObject(params)](#module_S3..moveObject) ⇒ <code>Promise.<undefined></code> | ||
@@ -488,8 +492,28 @@ <a name="module_S3.deleteS3Object"></a> | ||
<a name="module_S3.s3Join"></a> | ||
<a name="module_S3.listS3ObjectsV2"></a> | ||
### S3.s3Join(args) ⇒ <code>string</code> | ||
### S3.listS3ObjectsV2(params) ⇒ <code>Promise.<Array></code> | ||
Fetch complete list of S3 objects | ||
listObjectsV2 is limited to 1,000 results per call. This function continues | ||
listing objects until there are no more to be fetched. | ||
The passed params must be compatible with the listObjectsV2 call. | ||
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#listObjectsV2-property | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>Promise.<Array></code> - resolves to an array of objects corresponding to | ||
the Contents property of the listObjectsV2 response | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| params | <code>Object</code> | params for the s3.listObjectsV2 call | | ||
<a name="module_S3..s3Join"></a> | ||
### S3~s3Join(...args) ⇒ <code>string</code> | ||
Join strings into an S3 key without a leading slash | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>string</code> - the full S3 key | ||
@@ -499,10 +523,10 @@ | ||
| --- | --- | --- | | ||
| args | <code>string</code> \| <code>Array.<string></code> | the strings to join | | ||
| ...args | <code>string</code> \| <code>Array.<string></code> | the strings to join | | ||
<a name="module_S3.parseS3Uri"></a> | ||
<a name="module_S3..parseS3Uri"></a> | ||
### S3.parseS3Uri(uri) ⇒ <code>Object</code> | ||
### S3~parseS3Uri(uri) ⇒ <code>Object</code> | ||
parse an s3 uri to get the bucket and key | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>Object</code> - Returns an object with `Bucket` and `Key` properties | ||
@@ -514,8 +538,8 @@ | ||
<a name="module_S3.buildS3Uri"></a> | ||
<a name="module_S3..buildS3Uri"></a> | ||
### S3.buildS3Uri(bucket, key) ⇒ <code>string</code> | ||
### S3~buildS3Uri(bucket, key) ⇒ <code>string</code> | ||
Given a bucket and key, return an S3 URI | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>string</code> - an S3 URI | ||
@@ -528,9 +552,9 @@ | ||
<a name="module_S3.s3TagSetToQueryString"></a> | ||
<a name="module_S3..s3TagSetToQueryString"></a> | ||
### S3.s3TagSetToQueryString(tagset) ⇒ <code>string</code> | ||
### S3~s3TagSetToQueryString(tagset) ⇒ <code>string</code> | ||
Convert S3 TagSet Object to query string | ||
e.g. [{ Key: 'tag', Value: 'value }] to 'tag=value' | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>string</code> - tags query string | ||
@@ -542,8 +566,8 @@ | ||
<a name="module_S3.s3ObjectExists"></a> | ||
<a name="module_S3..s3ObjectExists"></a> | ||
### S3.s3ObjectExists(params) ⇒ <code>Promise.<boolean></code> | ||
### S3~s3ObjectExists(params) ⇒ <code>Promise.<boolean></code> | ||
Test if an object exists in S3 | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>Promise.<boolean></code> - a Promise that will resolve to a boolean indicating | ||
@@ -556,8 +580,8 @@ if the object exists | ||
<a name="module_S3.waitForObjectToExist"></a> | ||
<a name="module_S3..waitForObjectToExist"></a> | ||
### S3.waitForObjectToExist(params) ⇒ <code>Promise.<undefined></code> | ||
### S3~waitForObjectToExist(params) ⇒ <code>Promise.<undefined></code> | ||
Wait for an object to exist in S3 | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
@@ -572,8 +596,8 @@ | Param | Type | Default | Description | | ||
<a name="module_S3.putFile"></a> | ||
<a name="module_S3..putFile"></a> | ||
### S3.putFile(bucket, key, filename) ⇒ <code>Promise</code> | ||
### S3~putFile(bucket, key, filename) ⇒ <code>Promise</code> | ||
Upload a file to S3 | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
@@ -586,5 +610,5 @@ | Param | Type | Description | | ||
<a name="module_S3.streamS3Upload"></a> | ||
<a name="module_S3..streamS3Upload"></a> | ||
### S3.streamS3Upload(uploadStream, uploadParams) ⇒ <code>Promise</code> | ||
### S3~streamS3Upload(uploadStream, uploadParams) ⇒ <code>Promise</code> | ||
Upload data to S3 using a stream | ||
@@ -596,3 +620,3 @@ | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
@@ -604,8 +628,8 @@ | Param | Type | Description | | ||
<a name="module_S3.downloadS3File"></a> | ||
<a name="module_S3..downloadS3File"></a> | ||
### S3.downloadS3File(s3Obj, filepath) ⇒ <code>Promise.<string></code> | ||
### S3~downloadS3File(s3Obj, filepath) ⇒ <code>Promise.<string></code> | ||
Downloads the given s3Obj to the given filename in a streaming manner | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>Promise.<string></code> - returns filename if successful | ||
@@ -618,8 +642,8 @@ | ||
<a name="module_S3.getObjectSize"></a> | ||
<a name="module_S3..getObjectSize"></a> | ||
### S3.getObjectSize(params) ⇒ <code>Promise.<(number\|undefined)></code> | ||
### S3~getObjectSize(params) ⇒ <code>Promise.<(number\|undefined)></code> | ||
Get the size of an S3 object | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>Promise.<(number\|undefined)></code> - object size, in bytes | ||
@@ -634,8 +658,8 @@ | ||
<a name="module_S3.getObject"></a> | ||
<a name="module_S3..getObject"></a> | ||
### S3.getObject(s3, params) ⇒ <code>Promise.<AWS.S3.GetObjectOutput></code> | ||
### S3~getObject(s3Client, params) ⇒ <code>Promise.<AWS.S3.GetObjectOutput></code> | ||
Gets an object from S3. | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>Promise.<AWS.S3.GetObjectOutput></code> - response from `AWS.S3.getObject()` | ||
@@ -646,3 +670,3 @@ as a Promise | ||
| --- | --- | --- | | ||
| s3 | <code>AWS.S3</code> | an `AWS.S3` instance | | ||
| s3Client | <code>AWS.S3</code> | an `AWS.S3` instance | | ||
| params | <code>AWS.S3.GetObjectRequest</code> | parameters object to pass through to `AWS.S3.getObject()` | | ||
@@ -654,9 +678,9 @@ | ||
``` | ||
<a name="module_S3.waitForObject"></a> | ||
<a name="module_S3..waitForObject"></a> | ||
### S3.waitForObject(s3Client, params, [retryOptions]) ⇒ <code>Promise.<AWS.S3.GetObjectOutput></code> | ||
### S3~waitForObject(s3Client, params, [retryOptions]) ⇒ <code>Promise.<AWS.S3.GetObjectOutput></code> | ||
Get an object from S3, waiting for it to exist and, if specified, have the | ||
correct ETag. | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
@@ -669,8 +693,8 @@ | Param | Type | Default | | ||
<a name="module_S3.getTextObject"></a> | ||
<a name="module_S3..getTextObject"></a> | ||
### S3.getTextObject(bucket, key) ⇒ <code>Promise.<string></code> | ||
### S3~getTextObject(bucket, key) ⇒ <code>Promise.<string></code> | ||
Fetch the contents of an S3 object | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>Promise.<string></code> - the contents of the S3 object | ||
@@ -683,8 +707,8 @@ | ||
<a name="module_S3.getJsonS3Object"></a> | ||
<a name="module_S3..getJsonS3Object"></a> | ||
### S3.getJsonS3Object(bucket, key) ⇒ <code>Promise.<\*></code> | ||
### S3~getJsonS3Object(bucket, key) ⇒ <code>Promise.<\*></code> | ||
Fetch JSON stored in an S3 object | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>Promise.<\*></code> - the contents of the S3 object, parsed as JSON | ||
@@ -697,8 +721,8 @@ | ||
<a name="module_S3.getObjectReadStream"></a> | ||
<a name="module_S3..getObjectReadStream"></a> | ||
### S3.getObjectReadStream(params) ⇒ <code>Readable</code> | ||
### S3~getObjectReadStream(params) ⇒ <code>Readable</code> | ||
Get a readable stream for an S3 object | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
@@ -712,8 +736,8 @@ | Param | Type | Description | | ||
<a name="module_S3.fileExists"></a> | ||
<a name="module_S3..fileExists"></a> | ||
### S3.fileExists(bucket, key) ⇒ <code>Promise</code> | ||
### S3~fileExists(bucket, key) ⇒ <code>Promise</code> | ||
Check if a file exists in an S3 object | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>Promise</code> - returns the response from `S3.headObject` as a promise | ||
@@ -726,8 +750,8 @@ | ||
<a name="module_S3.deleteS3Files"></a> | ||
<a name="module_S3..deleteS3Files"></a> | ||
### S3.deleteS3Files(s3Objs) ⇒ <code>Promise</code> | ||
### S3~deleteS3Files(s3Objs) ⇒ <code>Promise</code> | ||
Delete files from S3 | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>Promise</code> - A promise that resolves to an Array of the data returned | ||
@@ -740,8 +764,8 @@ from the deletion operations | ||
<a name="module_S3.deleteS3Buckets"></a> | ||
<a name="module_S3..deleteS3Buckets"></a> | ||
### S3.deleteS3Buckets(buckets) ⇒ <code>Promise</code> | ||
### S3~deleteS3Buckets(buckets) ⇒ <code>Promise</code> | ||
Delete a list of buckets and all of their objects from S3 | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>Promise</code> - the promised result of `S3.deleteBucket` | ||
@@ -753,8 +777,8 @@ | ||
<a name="module_S3.uploadS3FileStream"></a> | ||
<a name="module_S3..uploadS3FileStream"></a> | ||
### S3.uploadS3FileStream(fileStream, bucket, key, s3opts) ⇒ <code>Promise</code> | ||
### S3~uploadS3FileStream(fileStream, bucket, key, s3opts) ⇒ <code>Promise</code> | ||
Upload the file associated with the given stream to an S3 bucket | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>Promise</code> - A promise | ||
@@ -769,8 +793,8 @@ | ||
<a name="module_S3.listS3Objects"></a> | ||
<a name="module_S3..listS3Objects"></a> | ||
### S3.listS3Objects(bucket, prefix, skipFolders) ⇒ <code>Promise</code> | ||
### S3~listS3Objects(bucket, prefix, skipFolders) ⇒ <code>Promise</code> | ||
List the objects in an S3 bucket | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>Promise</code> - A promise that resolves to the list of objects. Each S3 | ||
@@ -780,34 +804,14 @@ object is represented as a JS object with the following attributes: `Key`, | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| bucket | <code>string</code> | The name of the bucket | | ||
| prefix | <code>string</code> | Only objects with keys starting with this prefix will be included (useful for searching folders in buckets, e.g., '/PDR') | | ||
| skipFolders | <code>boolean</code> | If true don't return objects that are folders (defaults to true) | | ||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| bucket | <code>string</code> | | The name of the bucket | | ||
| prefix | <code>string</code> | | Only objects with keys starting with this prefix will be included (useful for searching folders in buckets, e.g., '/PDR') | | ||
| skipFolders | <code>boolean</code> | <code>true</code> | If true don't return objects that are folders (defaults to true) | | ||
<a name="module_S3.listS3ObjectsV2"></a> | ||
<a name="module_S3..calculateObjectHash"></a> | ||
### S3.listS3ObjectsV2(params) ⇒ <code>Promise.<Array></code> | ||
Fetch complete list of S3 objects | ||
listObjectsV2 is limited to 1,000 results per call. This function continues | ||
listing objects until there are no more to be fetched. | ||
The passed params must be compatible with the listObjectsV2 call. | ||
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#listObjectsV2-property | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>Promise.<Array></code> - resolves to an array of objects corresponding to | ||
the Contents property of the listObjectsV2 response | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| params | <code>Object</code> | params for the s3.listObjectsV2 call | | ||
<a name="module_S3.calculateObjectHash"></a> | ||
### S3.calculateObjectHash(params) | ||
### S3~calculateObjectHash(params) | ||
Calculate the cryptographic hash of an S3 object | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
@@ -822,8 +826,8 @@ | Param | Type | Description | | ||
<a name="module_S3.validateS3ObjectChecksum"></a> | ||
<a name="module_S3..validateS3ObjectChecksum"></a> | ||
### S3.validateS3ObjectChecksum(params) ⇒ <code>Promise.<boolean></code> | ||
### S3~validateS3ObjectChecksum(params) ⇒ <code>Promise.<boolean></code> | ||
Validate S3 object checksum against expected sum | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>Promise.<boolean></code> - returns true for success | ||
@@ -844,8 +848,8 @@ **Throws**: | ||
<a name="module_S3.getFileBucketAndKey"></a> | ||
<a name="module_S3..getFileBucketAndKey"></a> | ||
### S3.getFileBucketAndKey(pathParams) ⇒ <code>Array.<string></code> | ||
### S3~getFileBucketAndKey(pathParams) ⇒ <code>Array.<string></code> | ||
Extract the S3 bucket and key from the URL path parameters | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>Array.<string></code> - `[Bucket, Key]` | ||
@@ -857,8 +861,8 @@ | ||
<a name="module_S3.createBucket"></a> | ||
<a name="module_S3..createBucket"></a> | ||
### S3.createBucket(Bucket) ⇒ <code>Promise</code> | ||
### S3~createBucket(Bucket) ⇒ <code>Promise</code> | ||
Create an S3 bucket | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
@@ -869,8 +873,8 @@ | Param | Type | Description | | ||
<a name="module_S3.createS3Buckets"></a> | ||
<a name="module_S3..createS3Buckets"></a> | ||
### S3.createS3Buckets(buckets) ⇒ <code>Promise</code> | ||
### S3~createS3Buckets(buckets) ⇒ <code>Promise</code> | ||
Create multiple S3 buckets | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
@@ -881,8 +885,8 @@ | Param | Type | Description | | ||
<a name="module_S3.multipartCopyObject"></a> | ||
<a name="module_S3..multipartCopyObject"></a> | ||
### S3.multipartCopyObject(params) ⇒ <code>Promise.<{etag: string}></code> | ||
### S3~multipartCopyObject(params) ⇒ <code>Promise.<{etag: string}></code> | ||
Copy an S3 object to another location in S3 using a multipart copy | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
**Returns**: <code>Promise.<{etag: string}></code> - object containing the ETag of the | ||
@@ -902,8 +906,8 @@ destination object | ||
<a name="module_S3.moveObject"></a> | ||
<a name="module_S3..moveObject"></a> | ||
### S3.moveObject(params) ⇒ <code>Promise.<undefined></code> | ||
### S3~moveObject(params) ⇒ <code>Promise.<undefined></code> | ||
Move an S3 object to another location in S3 | ||
**Kind**: static method of [<code>S3</code>](#module_S3) | ||
**Kind**: inner method of [<code>S3</code>](#module_S3) | ||
@@ -923,9 +927,9 @@ | Param | Type | Default | Description | | ||
## SNS | ||
<a name="module_SNS.publishSnsMessage"></a> | ||
<a name="module_SNS..publishSnsMessage"></a> | ||
### SNS.publishSnsMessage(snsTopicArn, message, retryOptions) ⇒ <code>Promise.<undefined></code> | ||
### SNS~publishSnsMessage(snsTopicArn, message, retryOptions) ⇒ <code>Promise.<undefined></code> | ||
Publish a message to an SNS topic. Does not catch | ||
errors, to allow more specific handling by the caller. | ||
**Kind**: static method of [<code>SNS</code>](#module_SNS) | ||
**Kind**: inner method of [<code>SNS</code>](#module_SNS) | ||
@@ -943,7 +947,9 @@ | Param | Type | Description | | ||
* [SQS](#module_SQS) | ||
* [.sendSQSMessage](#module_SQS.sendSQSMessage) ⇒ <code>Promise</code> | ||
* [.deleteSQSMessage](#module_SQS.deleteSQSMessage) ⇒ <code>Promise</code> | ||
* [.createQueue(QueueName)](#module_SQS.createQueue) ⇒ <code>Promise.<string></code> | ||
* [.receiveSQSMessages(queueUrl, options)](#module_SQS.receiveSQSMessages) ⇒ <code>Promise.<Array></code> | ||
* [.sqsQueueExists(queueUrl)](#module_SQS.sqsQueueExists) ⇒ <code>Promise.<boolean></code> | ||
* _static_ | ||
* [.sendSQSMessage](#module_SQS.sendSQSMessage) ⇒ <code>Promise</code> | ||
* [.deleteSQSMessage](#module_SQS.deleteSQSMessage) ⇒ <code>Promise</code> | ||
* [.createQueue(QueueName)](#module_SQS.createQueue) ⇒ <code>Promise.<string></code> | ||
* _inner_ | ||
* [~receiveSQSMessages(queueUrl, options)](#module_SQS..receiveSQSMessages) ⇒ <code>Promise.<Array></code> | ||
* [~sqsQueueExists(queueUrl)](#module_SQS..sqsQueueExists) ⇒ <code>Promise.<boolean></code> | ||
@@ -989,9 +995,9 @@ <a name="module_SQS.sendSQSMessage"></a> | ||
<a name="module_SQS.receiveSQSMessages"></a> | ||
<a name="module_SQS..receiveSQSMessages"></a> | ||
### SQS.receiveSQSMessages(queueUrl, options) ⇒ <code>Promise.<Array></code> | ||
### SQS~receiveSQSMessages(queueUrl, options) ⇒ <code>Promise.<Array></code> | ||
Receives SQS messages from a given queue. The number of messages received | ||
can be set and the timeout is also adjustable. | ||
**Kind**: static method of [<code>SQS</code>](#module_SQS) | ||
**Kind**: inner method of [<code>SQS</code>](#module_SQS) | ||
**Returns**: <code>Promise.<Array></code> - an array of messages | ||
@@ -1007,8 +1013,8 @@ | ||
<a name="module_SQS.sqsQueueExists"></a> | ||
<a name="module_SQS..sqsQueueExists"></a> | ||
### SQS.sqsQueueExists(queueUrl) ⇒ <code>Promise.<boolean></code> | ||
### SQS~sqsQueueExists(queueUrl) ⇒ <code>Promise.<boolean></code> | ||
Test if an SQS queue exists | ||
**Kind**: static method of [<code>SQS</code>](#module_SQS) | ||
**Kind**: inner method of [<code>SQS</code>](#module_SQS) | ||
**Returns**: <code>Promise.<boolean></code> - - a Promise that will resolve to a boolean indicating | ||
@@ -1029,7 +1035,9 @@ if the queue exists | ||
* [StepFunctions](#module_StepFunctions) | ||
* [.describeExecution(params)](#module_StepFunctions.describeExecution) ⇒ <code>Promise.<Object></code> | ||
* [.describeStateMachine(params)](#module_StepFunctions.describeStateMachine) ⇒ <code>Promise.<Object></code> | ||
* [.executionExists(executionArn)](#module_StepFunctions.executionExists) ⇒ <code>Promise.<boolean></code> | ||
* [.getExecutionHistory(params)](#module_StepFunctions.getExecutionHistory) ⇒ <code>Promise.<Object></code> | ||
* [.listExecutions(params)](#module_StepFunctions.listExecutions) ⇒ <code>Promise.<Object></code> | ||
* _static_ | ||
* [.describeExecution(params)](#module_StepFunctions.describeExecution) ⇒ <code>Promise.<Object></code> | ||
* [.describeStateMachine(params)](#module_StepFunctions.describeStateMachine) ⇒ <code>Promise.<Object></code> | ||
* [.getExecutionHistory(params)](#module_StepFunctions.getExecutionHistory) ⇒ <code>Promise.<Object></code> | ||
* [.listExecutions(params)](#module_StepFunctions.listExecutions) ⇒ <code>Promise.<Object></code> | ||
* _inner_ | ||
* [~executionExists(executionArn)](#module_StepFunctions..executionExists) ⇒ <code>Promise.<boolean></code> | ||
@@ -1070,16 +1078,2 @@ <a name="module_StepFunctions.describeExecution"></a> | ||
<a name="module_StepFunctions.executionExists"></a> | ||
### StepFunctions.executionExists(executionArn) ⇒ <code>Promise.<boolean></code> | ||
Check if a Step Function Execution exists | ||
If a ThrottlingException is received, this function will retry using an | ||
exponential backoff. | ||
**Kind**: static method of [<code>StepFunctions</code>](#module_StepFunctions) | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| executionArn | <code>string</code> | the ARN of the Step Function Execution to check for | | ||
<a name="module_StepFunctions.getExecutionHistory"></a> | ||
@@ -1119,2 +1113,16 @@ | ||
<a name="module_StepFunctions..executionExists"></a> | ||
### StepFunctions~executionExists(executionArn) ⇒ <code>Promise.<boolean></code> | ||
Check if a Step Function Execution exists | ||
If a ThrottlingException is received, this function will retry using an | ||
exponential backoff. | ||
**Kind**: inner method of [<code>StepFunctions</code>](#module_StepFunctions) | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| executionArn | <code>string</code> | the ARN of the Step Function Execution to check for | | ||
<a name="DynamoDbSearchQueue"></a> | ||
@@ -1121,0 +1129,0 @@ |
@@ -196,3 +196,3 @@ /** | ||
* | ||
* @param {AWS.S3} s3 - an `AWS.S3` instance | ||
* @param {AWS.S3} s3Client - an `AWS.S3` instance | ||
* @param {AWS.S3.GetObjectRequest} params - parameters object to pass through | ||
@@ -203,3 +203,3 @@ * to `AWS.S3.getObject()` | ||
*/ | ||
export declare const getObject: (s3: { | ||
export declare const getObject: (s3Client: { | ||
getObject: GetObjectPromiseMethod; | ||
@@ -206,0 +206,0 @@ }, params: AWS.S3.GetObjectRequest) => Promise<AWS.S3.GetObjectOutput>; |
187
S3.js
@@ -20,3 +20,3 @@ "use strict"; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
@@ -54,3 +54,3 @@ return result; | ||
}; | ||
const S3_RATE_LIMIT = test_utils_1.inTestMode() ? 1 : 20; | ||
const S3_RATE_LIMIT = (0, test_utils_1.inTestMode)() ? 1 : 20; | ||
/** | ||
@@ -62,3 +62,3 @@ * Join strings into an S3 key without a leading slash | ||
*/ | ||
exports.s3Join = (...args) => { | ||
const s3Join = (...args) => { | ||
let tokens; | ||
@@ -81,2 +81,3 @@ if (typeof args[0] === 'string') | ||
}; | ||
exports.s3Join = s3Join; | ||
/** | ||
@@ -88,3 +89,3 @@ * parse an s3 uri to get the bucket and key | ||
**/ | ||
exports.parseS3Uri = (uri) => { | ||
const parseS3Uri = (uri) => { | ||
const match = uri.match('^s3://([^/]+)/(.*)$'); | ||
@@ -99,2 +100,3 @@ if (match === null) { | ||
}; | ||
exports.parseS3Uri = parseS3Uri; | ||
/** | ||
@@ -107,3 +109,4 @@ * Given a bucket and key, return an S3 URI | ||
*/ | ||
exports.buildS3Uri = (bucket, key) => `s3://${bucket}/${key.replace(/^\/+/, '')}`; | ||
const buildS3Uri = (bucket, key) => `s3://${bucket}/${key.replace(/^\/+/, '')}`; | ||
exports.buildS3Uri = buildS3Uri; | ||
/** | ||
@@ -116,3 +119,4 @@ * Convert S3 TagSet Object to query string | ||
*/ | ||
exports.s3TagSetToQueryString = (tagset) => tagset.map(({ Key, Value }) => `${Key}=${Value}`).join('&'); | ||
const s3TagSetToQueryString = (tagset) => tagset.map(({ Key, Value }) => `${Key}=${Value}`).join('&'); | ||
exports.s3TagSetToQueryString = s3TagSetToQueryString; | ||
/** | ||
@@ -125,3 +129,3 @@ * Delete an object from S3 | ||
*/ | ||
exports.deleteS3Object = utils_1.improveStackTrace((bucket, key) => services_1.s3().deleteObject({ Bucket: bucket, Key: key }).promise()); | ||
exports.deleteS3Object = (0, utils_1.improveStackTrace)((bucket, key) => (0, services_1.s3)().deleteObject({ Bucket: bucket, Key: key }).promise()); | ||
/** | ||
@@ -137,5 +141,5 @@ * Get an object header from S3 | ||
**/ | ||
exports.headObject = utils_1.improveStackTrace((Bucket, Key, retryOptions = { retries: 0 }) => p_retry_1.default(async () => { | ||
exports.headObject = (0, utils_1.improveStackTrace)((Bucket, Key, retryOptions = { retries: 0 }) => (0, p_retry_1.default)(async () => { | ||
try { | ||
return await services_1.s3().headObject({ Bucket, Key }).promise(); | ||
return await (0, services_1.s3)().headObject({ Bucket, Key }).promise(); | ||
} | ||
@@ -155,3 +159,3 @@ catch (error) { | ||
*/ | ||
exports.s3ObjectExists = (params) => exports.headObject(params.Bucket, params.Key) | ||
const s3ObjectExists = (params) => (0, exports.headObject)(params.Bucket, params.Key) | ||
.then(() => true) | ||
@@ -163,2 +167,3 @@ .catch((error) => { | ||
}); | ||
exports.s3ObjectExists = s3ObjectExists; | ||
/** | ||
@@ -174,6 +179,7 @@ * Wait for an object to exist in S3 | ||
*/ | ||
exports.waitForObjectToExist = async (params) => { | ||
const waitForObjectToExist = async (params) => { | ||
const { bucket, key, interval = 1000, timeout = 30 * 1000, } = params; | ||
await p_wait_for_1.default(() => exports.s3ObjectExists({ Bucket: bucket, Key: key }), { interval, timeout }); | ||
await (0, p_wait_for_1.default)(() => (0, exports.s3ObjectExists)({ Bucket: bucket, Key: key }), { interval, timeout }); | ||
}; | ||
exports.waitForObjectToExist = waitForObjectToExist; | ||
/** | ||
@@ -185,3 +191,3 @@ * Put an object on S3 | ||
**/ | ||
exports.s3PutObject = utils_1.improveStackTrace((params) => services_1.s3().putObject({ | ||
exports.s3PutObject = (0, utils_1.improveStackTrace)((params) => (0, services_1.s3)().putObject({ | ||
ACL: 'private', | ||
@@ -198,3 +204,3 @@ ...params, | ||
*/ | ||
exports.putFile = (bucket, key, filename) => exports.s3PutObject({ | ||
const putFile = (bucket, key, filename) => (0, exports.s3PutObject)({ | ||
Bucket: bucket, | ||
@@ -204,2 +210,3 @@ Key: key, | ||
}); | ||
exports.putFile = putFile; | ||
/** | ||
@@ -211,3 +218,3 @@ * Copy an object from one location on S3 to another | ||
**/ | ||
exports.s3CopyObject = utils_1.improveStackTrace((params) => services_1.s3().copyObject({ | ||
exports.s3CopyObject = (0, utils_1.improveStackTrace)((params) => (0, services_1.s3)().copyObject({ | ||
TaggingDirective: 'COPY', | ||
@@ -224,3 +231,3 @@ ...params, | ||
*/ | ||
exports.promiseS3Upload = utils_1.improveStackTrace((params) => services_1.s3().upload(params).promise()); | ||
exports.promiseS3Upload = (0, utils_1.improveStackTrace)((params) => (0, services_1.s3)().upload(params).promise()); | ||
/** | ||
@@ -237,3 +244,3 @@ * Upload data to S3 using a stream | ||
*/ | ||
exports.streamS3Upload = (uploadStream, uploadParams) => new Promise((resolve, reject) => { | ||
const streamS3Upload = (uploadStream, uploadParams) => new Promise((resolve, reject) => { | ||
const pass = new stream_1.PassThrough(); | ||
@@ -243,3 +250,3 @@ uploadStream.pipe(pass); | ||
pass.on('error', reject); | ||
return services_1.s3().upload({ | ||
return (0, services_1.s3)().upload({ | ||
...uploadParams, | ||
@@ -254,2 +261,3 @@ Body: pass, | ||
}); | ||
exports.streamS3Upload = streamS3Upload; | ||
/** | ||
@@ -262,7 +270,7 @@ * Downloads the given s3Obj to the given filename in a streaming manner | ||
*/ | ||
exports.downloadS3File = (s3Obj, filepath) => { | ||
const downloadS3File = (s3Obj, filepath) => { | ||
const fileWriteStream = fs_1.default.createWriteStream(filepath); | ||
return new Promise((resolve, reject) => { | ||
const objectReadStream = services_1.s3().getObject(s3Obj).createReadStream(); | ||
pump_1.default(objectReadStream, fileWriteStream, (err) => { | ||
const objectReadStream = (0, services_1.s3)().getObject(s3Obj).createReadStream(); | ||
(0, pump_1.default)(objectReadStream, fileWriteStream, (err) => { | ||
if (err) | ||
@@ -275,2 +283,3 @@ reject(err); | ||
}; | ||
exports.downloadS3File = downloadS3File; | ||
/** | ||
@@ -285,6 +294,6 @@ * Get the size of an S3 object | ||
*/ | ||
exports.getObjectSize = async (params) => { | ||
const getObjectSize = async (params) => { | ||
// eslint-disable-next-line no-shadow | ||
const { s3, bucket, key } = params; | ||
const headObjectResponse = await s3.headObject({ | ||
const { s3: s3Client, bucket, key } = params; | ||
const headObjectResponse = await s3Client.headObject({ | ||
Bucket: bucket, | ||
@@ -295,2 +304,3 @@ Key: key, | ||
}; | ||
exports.getObjectSize = getObjectSize; | ||
/** | ||
@@ -303,5 +313,5 @@ * Get object Tagging from S3 | ||
**/ | ||
exports.s3GetObjectTagging = utils_1.improveStackTrace((bucket, key) => services_1.s3().getObjectTagging({ Bucket: bucket, Key: key }).promise()); | ||
exports.s3GetObjectTagging = (0, utils_1.improveStackTrace)((bucket, key) => (0, services_1.s3)().getObjectTagging({ Bucket: bucket, Key: key }).promise()); | ||
const getObjectTags = async (bucket, key) => { | ||
const taggingResponse = await exports.s3GetObjectTagging(bucket, key); | ||
const taggingResponse = await (0, exports.s3GetObjectTagging)(bucket, key); | ||
return taggingResponse.TagSet.reduce((acc, { Key, Value }) => ({ ...acc, [Key]: Value }), {}); | ||
@@ -322,3 +332,3 @@ }; | ||
**/ | ||
exports.s3PutObjectTagging = utils_1.improveStackTrace((Bucket, Key, Tagging) => services_1.s3().putObjectTagging({ | ||
exports.s3PutObjectTagging = (0, utils_1.improveStackTrace)((Bucket, Key, Tagging) => (0, services_1.s3)().putObjectTagging({ | ||
Bucket, | ||
@@ -334,3 +344,3 @@ Key, | ||
* | ||
* @param {AWS.S3} s3 - an `AWS.S3` instance | ||
* @param {AWS.S3} s3Client - an `AWS.S3` instance | ||
* @param {AWS.S3.GetObjectRequest} params - parameters object to pass through | ||
@@ -341,5 +351,6 @@ * to `AWS.S3.getObject()` | ||
*/ | ||
exports.getObject = ( | ||
const getObject = ( | ||
// eslint-disable-next-line no-shadow | ||
s3, params) => s3.getObject(params).promise(); | ||
s3Client, params) => s3Client.getObject(params).promise(); | ||
exports.getObject = getObject; | ||
/** | ||
@@ -354,5 +365,5 @@ * Get an object from S3, waiting for it to exist and, if specified, have the | ||
*/ | ||
exports.waitForObject = (s3Client, params, retryOptions = {}) => p_retry_1.default(async () => { | ||
const waitForObject = (s3Client, params, retryOptions = {}) => (0, p_retry_1.default)(async () => { | ||
try { | ||
return await exports.getObject(s3Client, params); | ||
return await (0, exports.getObject)(s3Client, params); | ||
} | ||
@@ -370,2 +381,3 @@ catch (error) { | ||
}, retryOptions); | ||
exports.waitForObject = waitForObject; | ||
/** | ||
@@ -383,3 +395,3 @@ * Gets an object from S3. | ||
*/ | ||
exports.getS3Object = util_1.deprecate(utils_1.improveStackTrace((Bucket, Key, retryOptions = { retries: 0 }) => exports.waitForObject(services_1.s3(), { Bucket, Key }, { | ||
exports.getS3Object = (0, util_1.deprecate)((0, utils_1.improveStackTrace)((Bucket, Key, retryOptions = { retries: 0 }) => (0, exports.waitForObject)((0, services_1.s3)(), { Bucket, Key }, { | ||
maxTimeout: 10000, | ||
@@ -396,3 +408,3 @@ onFailedAttempt: (err) => log.debug(`getS3Object('${Bucket}', '${Key}') failed with ${err.retriesLeft} retries left: ${err.message}`), | ||
*/ | ||
exports.getTextObject = (bucket, key) => exports.getS3Object(bucket, key) | ||
const getTextObject = (bucket, key) => (0, exports.getS3Object)(bucket, key) | ||
.then(({ Body }) => { | ||
@@ -403,2 +415,3 @@ if (Body === undefined) | ||
}); | ||
exports.getTextObject = getTextObject; | ||
/** | ||
@@ -410,3 +423,3 @@ * Fetch JSON stored in an S3 object | ||
*/ | ||
exports.getJsonS3Object = (bucket, key) => exports.getTextObject(bucket, key) | ||
const getJsonS3Object = (bucket, key) => (0, exports.getTextObject)(bucket, key) | ||
.then((text) => { | ||
@@ -417,3 +430,4 @@ if (text === undefined) | ||
}); | ||
exports.putJsonS3Object = (bucket, key, data) => exports.s3PutObject({ | ||
exports.getJsonS3Object = getJsonS3Object; | ||
const putJsonS3Object = (bucket, key, data) => (0, exports.s3PutObject)({ | ||
Bucket: bucket, | ||
@@ -423,2 +437,3 @@ Key: key, | ||
}); | ||
exports.putJsonS3Object = putJsonS3Object; | ||
/** | ||
@@ -433,7 +448,8 @@ * Get a readable stream for an S3 object | ||
*/ | ||
exports.getObjectReadStream = (params) => { | ||
const getObjectReadStream = (params) => { | ||
// eslint-disable-next-line no-shadow | ||
const { s3, bucket, key } = params; | ||
return s3.getObject({ Bucket: bucket, Key: key }).createReadStream(); | ||
const { s3: s3Client, bucket, key } = params; | ||
return s3Client.getObject({ Bucket: bucket, Key: key }).createReadStream(); | ||
}; | ||
exports.getObjectReadStream = getObjectReadStream; | ||
/** | ||
@@ -446,5 +462,5 @@ * Check if a file exists in an S3 object | ||
**/ | ||
exports.fileExists = async (bucket, key) => { | ||
const fileExists = async (bucket, key) => { | ||
try { | ||
const r = await services_1.s3().headObject({ Key: key, Bucket: bucket }).promise(); | ||
const r = await (0, services_1.s3)().headObject({ Key: key, Bucket: bucket }).promise(); | ||
return r; | ||
@@ -460,3 +476,4 @@ } | ||
}; | ||
exports.downloadS3Files = async (s3Objs, dir, s3opts = {}) => { | ||
exports.fileExists = fileExists; | ||
const downloadS3Files = async (s3Objs, dir, s3opts = {}) => { | ||
// Scrub s3Ojbs to avoid errors from the AWS SDK | ||
@@ -475,3 +492,3 @@ const scrubbedS3Objs = s3Objs.map((s3Obj) => ({ | ||
return new Promise((resolve, reject) => { | ||
services_1.s3().getObject(opts) | ||
(0, services_1.s3)().getObject(opts) | ||
.createReadStream() | ||
@@ -487,4 +504,5 @@ .pipe(file) | ||
}; | ||
return await p_map_1.default(scrubbedS3Objs, promiseDownload, { concurrency: S3_RATE_LIMIT }); | ||
return await (0, p_map_1.default)(scrubbedS3Objs, promiseDownload, { concurrency: S3_RATE_LIMIT }); | ||
}; | ||
exports.downloadS3Files = downloadS3Files; | ||
/** | ||
@@ -497,3 +515,4 @@ * Delete files from S3 | ||
*/ | ||
exports.deleteS3Files = async (s3Objs) => await p_map_1.default(s3Objs, (s3Obj) => services_1.s3().deleteObject(s3Obj).promise(), { concurrency: S3_RATE_LIMIT }); | ||
const deleteS3Files = async (s3Objs) => await (0, p_map_1.default)(s3Objs, (s3Obj) => (0, services_1.s3)().deleteObject(s3Obj).promise(), { concurrency: S3_RATE_LIMIT }); | ||
exports.deleteS3Files = deleteS3Files; | ||
/** | ||
@@ -505,4 +524,4 @@ * Delete a bucket and all of its objects from S3 | ||
**/ | ||
exports.recursivelyDeleteS3Bucket = utils_1.improveStackTrace(async (bucket) => { | ||
const response = await services_1.s3().listObjects({ Bucket: bucket }).promise(); | ||
exports.recursivelyDeleteS3Bucket = (0, utils_1.improveStackTrace)(async (bucket) => { | ||
const response = await (0, services_1.s3)().listObjects({ Bucket: bucket }).promise(); | ||
const s3Objects = (response.Contents || []).map((o) => { | ||
@@ -516,4 +535,4 @@ if (!o.Key) | ||
}); | ||
await exports.deleteS3Files(s3Objects); | ||
await services_1.s3().deleteBucket({ Bucket: bucket }).promise(); | ||
await (0, exports.deleteS3Files)(s3Objects); | ||
await (0, services_1.s3)().deleteBucket({ Bucket: bucket }).promise(); | ||
}); | ||
@@ -526,4 +545,5 @@ /** | ||
**/ | ||
exports.deleteS3Buckets = async (buckets) => await Promise.all(buckets.map(exports.recursivelyDeleteS3Bucket)); | ||
exports.uploadS3Files = async (files, defaultBucket, keyPath, s3opts = {}) => { | ||
const deleteS3Buckets = async (buckets) => await Promise.all(buckets.map(exports.recursivelyDeleteS3Bucket)); | ||
exports.deleteS3Buckets = deleteS3Buckets; | ||
const uploadS3Files = async (files, defaultBucket, keyPath, s3opts = {}) => { | ||
let i = 0; | ||
@@ -542,3 +562,3 @@ const n = files.length; | ||
if (typeof keyPath === 'string') { | ||
key = exports.s3Join(keyPath, path_1.default.basename(file)); | ||
key = (0, exports.s3Join)(keyPath, path_1.default.basename(file)); | ||
} | ||
@@ -554,3 +574,3 @@ else { | ||
} | ||
await exports.promiseS3Upload({ | ||
await (0, exports.promiseS3Upload)({ | ||
Bucket: bucket, | ||
@@ -565,4 +585,5 @@ Key: key, | ||
}; | ||
return await p_map_1.default(files, promiseUpload, { concurrency: S3_RATE_LIMIT }); | ||
return await (0, p_map_1.default)(files, promiseUpload, { concurrency: S3_RATE_LIMIT }); | ||
}; | ||
exports.uploadS3Files = uploadS3Files; | ||
/** | ||
@@ -577,3 +598,3 @@ * Upload the file associated with the given stream to an S3 bucket | ||
*/ | ||
exports.uploadS3FileStream = (fileStream, bucket, key, s3opts = {}) => exports.promiseS3Upload({ | ||
const uploadS3FileStream = (fileStream, bucket, key, s3opts = {}) => (0, exports.promiseS3Upload)({ | ||
Bucket: bucket, | ||
@@ -584,2 +605,3 @@ Key: key, | ||
}); | ||
exports.uploadS3FileStream = uploadS3FileStream; | ||
/** | ||
@@ -597,3 +619,3 @@ * List the objects in an S3 bucket | ||
*/ | ||
exports.listS3Objects = async (bucket, prefix, skipFolders = true) => { | ||
const listS3Objects = async (bucket, prefix, skipFolders = true) => { | ||
log.info(`Listing objects in s3://${bucket}`); | ||
@@ -605,3 +627,3 @@ const params = { | ||
params.Prefix = prefix; | ||
const data = await services_1.s3().listObjects(params).promise(); | ||
const data = await (0, services_1.s3)().listObjects(params).promise(); | ||
let contents = data.Contents || []; | ||
@@ -614,2 +636,3 @@ if (skipFolders) { | ||
}; | ||
exports.listS3Objects = listS3Objects; | ||
/** | ||
@@ -631,5 +654,5 @@ * Fetch complete list of S3 objects | ||
*/ | ||
exports.listS3ObjectsV2 = async (params) => { | ||
const listS3ObjectsV2 = async (params) => { | ||
// Fetch the first list of objects from S3 | ||
let listObjectsResponse = (await services_1.s3().listObjectsV2(params).promise()); | ||
let listObjectsResponse = (await (0, services_1.s3)().listObjectsV2(params).promise()); | ||
let discoveredObjects = listObjectsResponse.Contents; | ||
@@ -639,3 +662,3 @@ // Keep listing more objects from S3 until we have all of them | ||
// eslint-disable-next-line no-await-in-loop | ||
listObjectsResponse = (await services_1.s3().listObjectsV2( | ||
listObjectsResponse = (await (0, services_1.s3)().listObjectsV2( | ||
// Update the params with a Continuation Token | ||
@@ -650,2 +673,3 @@ { | ||
}; | ||
exports.listS3ObjectsV2 = listS3ObjectsV2; | ||
/** | ||
@@ -661,8 +685,13 @@ * Calculate the cryptographic hash of an S3 object | ||
*/ | ||
exports.calculateObjectHash = async (params) => { | ||
const calculateObjectHash = async (params) => { | ||
// eslint-disable-next-line no-shadow | ||
const { algorithm, bucket, key, s3 } = params; | ||
const stream = exports.getObjectReadStream({ s3, bucket, key }); | ||
return await checksum_1.generateChecksumFromStream(algorithm, stream); | ||
const { algorithm, bucket, key, s3: s3Client } = params; | ||
const stream = (0, exports.getObjectReadStream)({ | ||
s3: s3Client, | ||
bucket, | ||
key, | ||
}); | ||
return await (0, checksum_1.generateChecksumFromStream)(algorithm, stream); | ||
}; | ||
exports.calculateObjectHash = calculateObjectHash; | ||
/** | ||
@@ -681,6 +710,6 @@ * Validate S3 object checksum against expected sum | ||
*/ | ||
exports.validateS3ObjectChecksum = async (params) => { | ||
const validateS3ObjectChecksum = async (params) => { | ||
const { algorithm, bucket, key, expectedSum, options } = params; | ||
const fileStream = exports.getObjectReadStream({ s3: services_1.s3(), bucket, key }); | ||
if (await checksum_1.validateChecksumFromStream(algorithm, fileStream, expectedSum, options)) { | ||
const fileStream = (0, exports.getObjectReadStream)({ s3: (0, services_1.s3)(), bucket, key }); | ||
if (await (0, checksum_1.validateChecksumFromStream)(algorithm, fileStream, expectedSum, options)) { | ||
return true; | ||
@@ -691,2 +720,3 @@ } | ||
}; | ||
exports.validateS3ObjectChecksum = validateS3ObjectChecksum; | ||
/** | ||
@@ -699,3 +729,3 @@ * Extract the S3 bucket and key from the URL path parameters | ||
*/ | ||
exports.getFileBucketAndKey = (pathParams) => { | ||
const getFileBucketAndKey = (pathParams) => { | ||
const [Bucket, ...fields] = pathParams.split('/'); | ||
@@ -708,2 +738,3 @@ const Key = fields.join('/'); | ||
}; | ||
exports.getFileBucketAndKey = getFileBucketAndKey; | ||
/** | ||
@@ -715,3 +746,4 @@ * Create an S3 bucket | ||
*/ | ||
exports.createBucket = (Bucket) => services_1.s3().createBucket({ Bucket }).promise(); | ||
const createBucket = (Bucket) => (0, services_1.s3)().createBucket({ Bucket }).promise(); | ||
exports.createBucket = createBucket; | ||
/** | ||
@@ -723,3 +755,4 @@ * Create multiple S3 buckets | ||
*/ | ||
exports.createS3Buckets = async (buckets) => await Promise.all(buckets.map(exports.createBucket)); | ||
const createS3Buckets = async (buckets) => await Promise.all(buckets.map(exports.createBucket)); | ||
exports.createS3Buckets = createS3Buckets; | ||
const createMultipartUpload = async (params) => { | ||
@@ -780,6 +813,6 @@ const uploadParams = { | ||
*/ | ||
exports.multipartCopyObject = async (params) => { | ||
const multipartCopyObject = async (params) => { | ||
var _a; | ||
const { sourceBucket, sourceKey, destinationBucket, destinationKey, ACL, copyTags = false, } = params; | ||
const sourceObject = (_a = params.sourceObject) !== null && _a !== void 0 ? _a : await exports.headObject(sourceBucket, sourceKey); | ||
const sourceObject = (_a = params.sourceObject) !== null && _a !== void 0 ? _a : await (0, exports.headObject)(sourceBucket, sourceKey); | ||
// Create a multi-part upload (copy) and get its UploadId | ||
@@ -835,2 +868,3 @@ const uploadId = await createMultipartUpload({ | ||
}; | ||
exports.multipartCopyObject = multipartCopyObject; | ||
/** | ||
@@ -848,4 +882,4 @@ * Move an S3 object to another location in S3 | ||
*/ | ||
exports.moveObject = async (params) => { | ||
await exports.multipartCopyObject({ | ||
const moveObject = async (params) => { | ||
await (0, exports.multipartCopyObject)({ | ||
sourceBucket: params.sourceBucket, | ||
@@ -856,6 +890,7 @@ sourceKey: params.sourceKey, | ||
ACL: params.ACL, | ||
copyTags: isBoolean_1.default(params.copyTags) ? params.copyTags : true, | ||
copyTags: (0, isBoolean_1.default)(params.copyTags) ? params.copyTags : true, | ||
}); | ||
await exports.deleteS3Object(params.sourceBucket, params.sourceKey); | ||
await (0, exports.deleteS3Object)(params.sourceBucket, params.sourceKey); | ||
}; | ||
exports.moveObject = moveObject; | ||
//# sourceMappingURL=S3.js.map |
@@ -11,3 +11,3 @@ "use strict"; | ||
this.params = params; | ||
this.s3 = services_1.s3(); | ||
this.s3 = (0, services_1.s3)(); | ||
} | ||
@@ -14,0 +14,0 @@ /** |
@@ -17,3 +17,3 @@ "use strict"; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
@@ -39,3 +39,3 @@ return result; | ||
constructor() { | ||
this.s3 = client_1.default(AWS.S3, '2006-03-01', { signatureVersion: 'v4' })(); | ||
this.s3 = (0, client_1.default)(AWS.S3, '2006-03-01', { signatureVersion: 'v4' })(); | ||
} | ||
@@ -58,4 +58,4 @@ /** | ||
} | ||
const { Bucket, Key } = S3_1.parseS3Uri(objectUrl); | ||
await S3_1.headObject(Bucket, Key); | ||
const { Bucket, Key } = (0, S3_1.parseS3Uri)(objectUrl); | ||
await (0, S3_1.headObject)(Bucket, Key); | ||
const req = this.s3.getObject({ Bucket, Key, ...options }); | ||
@@ -86,3 +86,3 @@ if (queryParams && req.on) { | ||
} | ||
const { Bucket, Key } = S3_1.parseS3Uri(objectUrl); | ||
const { Bucket, Key } = (0, S3_1.parseS3Uri)(objectUrl); | ||
const req = this.s3.headObject({ Bucket, Key, ...options }); | ||
@@ -89,0 +89,0 @@ if (queryParams && req.on) { |
@@ -8,4 +8,5 @@ "use strict"; | ||
const services_1 = require("./services"); | ||
exports.getSecretString = (SecretId) => services_1.secretsManager().getSecretValue({ SecretId }).promise() | ||
const getSecretString = (SecretId) => (0, services_1.secretsManager)().getSecretValue({ SecretId }).promise() | ||
.then((response) => response.SecretString); | ||
exports.getSecretString = getSecretString; | ||
//# sourceMappingURL=SecretsManager.js.map |
@@ -17,3 +17,3 @@ "use strict"; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
@@ -20,0 +20,0 @@ return result; |
@@ -24,7 +24,7 @@ "use strict"; | ||
*/ | ||
exports.publishSnsMessage = async (snsTopicArn, message, retryOptions = {}) => await p_retry_1.default(async () => { | ||
const publishSnsMessage = async (snsTopicArn, message, retryOptions = {}) => await (0, p_retry_1.default)(async () => { | ||
if (!snsTopicArn) { | ||
throw new p_retry_1.default.AbortError('Missing SNS topic ARN'); | ||
} | ||
await services_1.sns().publish({ | ||
await (0, services_1.sns)().publish({ | ||
TopicArn: snsTopicArn, | ||
@@ -38,2 +38,3 @@ Message: JSON.stringify(message), | ||
}); | ||
exports.publishSnsMessage = publishSnsMessage; | ||
//# sourceMappingURL=SNS.js.map |
@@ -37,3 +37,3 @@ /** | ||
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>>; | ||
declare type receiveSQSMessagesOptions = { | ||
declare type ReceiveSQSMessagesOptions = { | ||
numOfMessages?: number; | ||
@@ -55,3 +55,3 @@ visibilityTimeout?: number; | ||
*/ | ||
export declare const receiveSQSMessages: (queueUrl: string, options: receiveSQSMessagesOptions) => Promise<SQSMessage[]>; | ||
export declare const receiveSQSMessages: (queueUrl: string, options: ReceiveSQSMessagesOptions) => Promise<SQSMessage[]>; | ||
export declare const parseSQSMessageBody: (message: any) => unknown; | ||
@@ -58,0 +58,0 @@ /** |
54
SQS.js
@@ -17,3 +17,3 @@ "use strict"; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
@@ -40,11 +40,14 @@ return result; | ||
const log = new logger_1.default({ sender: '@cumulus/aws-client/SQS' }); | ||
exports.getQueueNameFromUrl = (queueUrl) => queueUrl.split('/').pop(); | ||
exports.getQueueUrl = (sourceArn, queueName) => { | ||
const getQueueNameFromUrl = (queueUrl) => queueUrl.split('/').pop(); | ||
exports.getQueueNameFromUrl = getQueueNameFromUrl; | ||
const getQueueUrl = (sourceArn, queueName) => { | ||
const arnParts = sourceArn.split(':'); | ||
return `https://sqs.${arnParts[3]}.amazonaws.com/${arnParts[4]}/${queueName}`; | ||
}; | ||
exports.getQueueUrlByName = async (queueName) => { | ||
const response = await services_1.sqs().getQueueUrl({ QueueName: queueName }).promise(); | ||
exports.getQueueUrl = getQueueUrl; | ||
const getQueueUrlByName = async (queueName) => { | ||
const response = await (0, services_1.sqs)().getQueueUrl({ QueueName: queueName }).promise(); | ||
return response.QueueUrl; | ||
}; | ||
exports.getQueueUrlByName = getQueueUrlByName; | ||
/** | ||
@@ -59,3 +62,3 @@ * Create an SQS Queue. Properly handles localstack queue URLs | ||
async function createQueue(QueueName) { | ||
const createQueueResponse = await services_1.sqs().createQueue({ | ||
const createQueueResponse = await (0, services_1.sqs)().createQueue({ | ||
QueueName, | ||
@@ -65,3 +68,3 @@ }) | ||
.promise(); | ||
if (test_utils_1.inTestMode()) { | ||
if ((0, test_utils_1.inTestMode)()) { | ||
if (createQueueResponse.QueueUrl === undefined) { | ||
@@ -85,3 +88,3 @@ throw new Error('Did not receive a QueueUrl'); | ||
exports.createQueue = createQueue; | ||
exports.deleteQueue = (queueUrl) => services_1.sqs().deleteQueue({ | ||
const deleteQueue = (queueUrl) => (0, services_1.sqs)().deleteQueue({ | ||
QueueUrl: queueUrl, | ||
@@ -91,8 +94,9 @@ }) | ||
.promise(); | ||
exports.getQueueAttributes = async (queueName) => { | ||
const queueUrl = await exports.getQueueUrlByName(queueName); | ||
exports.deleteQueue = deleteQueue; | ||
const getQueueAttributes = async (queueName) => { | ||
const queueUrl = await (0, exports.getQueueUrlByName)(queueName); | ||
if (!queueUrl) { | ||
throw new Error(`Unable to determine QueueUrl of ${queueName}`); | ||
} | ||
const response = await services_1.sqs().getQueueAttributes({ | ||
const response = await (0, services_1.sqs)().getQueueAttributes({ | ||
AttributeNames: ['All'], | ||
@@ -106,2 +110,3 @@ QueueUrl: queueUrl, | ||
}; | ||
exports.getQueueAttributes = getQueueAttributes; | ||
/** | ||
@@ -117,12 +122,12 @@ * Send a message to AWS SQS | ||
**/ | ||
exports.sendSQSMessage = utils_1.improveStackTrace((queueUrl, message, logOverride) => { | ||
exports.sendSQSMessage = (0, utils_1.improveStackTrace)((queueUrl, message, logOverride) => { | ||
const logger = logOverride || log; | ||
let messageBody; | ||
if (isString_1.default(message)) | ||
if ((0, isString_1.default)(message)) | ||
messageBody = message; | ||
else if (isObject_1.default(message)) | ||
else if ((0, isObject_1.default)(message)) | ||
messageBody = JSON.stringify(message); | ||
else | ||
throw new Error('body type is not accepted'); | ||
return services_1.sqs().sendMessage({ | ||
return (0, services_1.sqs)().sendMessage({ | ||
MessageBody: messageBody, | ||
@@ -145,3 +150,3 @@ QueueUrl: queueUrl, | ||
*/ | ||
exports.receiveSQSMessages = async (queueUrl, options) => { | ||
const receiveSQSMessages = async (queueUrl, options) => { | ||
var _a; | ||
@@ -152,11 +157,13 @@ const params = { | ||
// 0 is a valid value for VisibilityTimeout | ||
VisibilityTimeout: isNil_1.default(options.visibilityTimeout) ? 30 : options.visibilityTimeout, | ||
VisibilityTimeout: (0, isNil_1.default)(options.visibilityTimeout) ? 30 : options.visibilityTimeout, | ||
WaitTimeSeconds: options.waitTimeSeconds || 0, | ||
MaxNumberOfMessages: options.numOfMessages || 1, | ||
}; | ||
const messages = await services_1.sqs().receiveMessage(params) | ||
const messages = await (0, services_1.sqs)().receiveMessage(params) | ||
.on('error', (error) => log.error(error)).promise(); | ||
return ((_a = messages.Messages) !== null && _a !== void 0 ? _a : []); | ||
}; | ||
exports.parseSQSMessageBody = (message) => JSON.parse(get_1.default(message, 'Body', get_1.default(message, 'body', '{}'))); | ||
exports.receiveSQSMessages = receiveSQSMessages; | ||
const parseSQSMessageBody = (message) => JSON.parse((0, get_1.default)(message, 'Body', (0, get_1.default)(message, 'body', '{}'))); | ||
exports.parseSQSMessageBody = parseSQSMessageBody; | ||
/** | ||
@@ -169,3 +176,3 @@ * Delete a given SQS message from a given queue. | ||
*/ | ||
exports.deleteSQSMessage = utils_1.improveStackTrace((QueueUrl, ReceiptHandle) => services_1.sqs().deleteMessage({ QueueUrl, ReceiptHandle }) | ||
exports.deleteSQSMessage = (0, utils_1.improveStackTrace)((QueueUrl, ReceiptHandle) => (0, services_1.sqs)().deleteMessage({ QueueUrl, ReceiptHandle }) | ||
.on('error', (error) => log.error(error)) | ||
@@ -180,4 +187,4 @@ .promise()); | ||
*/ | ||
exports.sqsQueueExists = async (queueUrl) => { | ||
const QueueName = exports.getQueueNameFromUrl(queueUrl); | ||
const sqsQueueExists = async (queueUrl) => { | ||
const QueueName = (0, exports.getQueueNameFromUrl)(queueUrl); | ||
if (!QueueName) { | ||
@@ -187,3 +194,3 @@ throw new Error(`Unable to determine QueueName from ${queueUrl}`); | ||
try { | ||
await services_1.sqs().getQueueUrl({ QueueName }).promise(); | ||
await (0, services_1.sqs)().getQueueUrl({ QueueName }).promise(); | ||
return true; | ||
@@ -200,2 +207,3 @@ } | ||
}; | ||
exports.sqsQueueExists = sqsQueueExists; | ||
//# sourceMappingURL=SQS.js.map |
@@ -10,3 +10,3 @@ "use strict"; | ||
// Utility functions | ||
exports.doesExecutionExist = (describeExecutionPromise) => describeExecutionPromise | ||
const doesExecutionExist = (describeExecutionPromise) => describeExecutionPromise | ||
.then(() => true) | ||
@@ -18,2 +18,3 @@ .catch((error) => { | ||
}); | ||
exports.doesExecutionExist = doesExecutionExist; | ||
// Exported functions | ||
@@ -34,3 +35,3 @@ /** | ||
*/ | ||
exports.describeExecution = utils_1.improveStackTrace(utils_1.retryOnThrottlingException((params) => services_1.sfn().describeExecution(params).promise())); | ||
exports.describeExecution = (0, utils_1.improveStackTrace)((0, utils_1.retryOnThrottlingException)((params) => (0, services_1.sfn)().describeExecution(params).promise())); | ||
/** | ||
@@ -50,3 +51,3 @@ * Call StepFunctions DescribeStateMachine | ||
*/ | ||
exports.describeStateMachine = utils_1.improveStackTrace(utils_1.retryOnThrottlingException((params) => services_1.sfn().describeStateMachine(params).promise())); | ||
exports.describeStateMachine = (0, utils_1.improveStackTrace)((0, utils_1.retryOnThrottlingException)((params) => (0, services_1.sfn)().describeStateMachine(params).promise())); | ||
/** | ||
@@ -64,3 +65,4 @@ * Check if a Step Function Execution exists | ||
*/ | ||
exports.executionExists = (executionArn) => exports.doesExecutionExist(exports.describeExecution({ executionArn })); | ||
const executionExists = (executionArn) => (0, exports.doesExecutionExist)((0, exports.describeExecution)({ executionArn })); | ||
exports.executionExists = executionExists; | ||
/** | ||
@@ -80,6 +82,6 @@ * Call StepFunctions GetExecutionHistory | ||
*/ | ||
exports.getExecutionHistory = utils_1.improveStackTrace(utils_1.retryOnThrottlingException(async (params, previousResponse = { | ||
exports.getExecutionHistory = (0, utils_1.improveStackTrace)((0, utils_1.retryOnThrottlingException)(async (params, previousResponse = { | ||
events: [], | ||
}) => { | ||
const response = await services_1.sfn().getExecutionHistory(params).promise(); | ||
const response = await (0, services_1.sfn)().getExecutionHistory(params).promise(); | ||
const events = [ | ||
@@ -92,3 +94,3 @@ ...previousResponse.events, | ||
if (response.nextToken) { | ||
return exports.getExecutionHistory({ | ||
return (0, exports.getExecutionHistory)({ | ||
...params, | ||
@@ -104,8 +106,8 @@ nextToken: response.nextToken, | ||
})); | ||
exports.getExecutionStatus = async (executionArn) => { | ||
const getExecutionStatus = async (executionArn) => { | ||
const [execution, executionHistory] = await Promise.all([ | ||
exports.describeExecution({ executionArn }), | ||
exports.getExecutionHistory({ executionArn }), | ||
(0, exports.describeExecution)({ executionArn }), | ||
(0, exports.getExecutionHistory)({ executionArn }), | ||
]); | ||
const stateMachine = await exports.describeStateMachine({ | ||
const stateMachine = await (0, exports.describeStateMachine)({ | ||
stateMachineArn: execution.stateMachineArn, | ||
@@ -115,2 +117,3 @@ }); | ||
}; | ||
exports.getExecutionStatus = getExecutionStatus; | ||
/** | ||
@@ -130,3 +133,3 @@ * Call StepFunctions ListExecutions | ||
*/ | ||
exports.listExecutions = utils_1.improveStackTrace(utils_1.retryOnThrottlingException((params) => services_1.sfn().listExecutions(params).promise())); | ||
exports.listExecutions = (0, utils_1.improveStackTrace)((0, utils_1.retryOnThrottlingException)((params) => (0, services_1.sfn)().listExecutions(params).promise())); | ||
//# sourceMappingURL=StepFunctions.js.map |
@@ -5,3 +5,4 @@ "use strict"; | ||
const errors_1 = require("@cumulus/errors"); | ||
exports.inTestMode = () => process.env.NODE_ENV === 'test'; | ||
const inTestMode = () => process.env.NODE_ENV === 'test'; | ||
exports.inTestMode = inTestMode; | ||
// From https://github.com/localstack/localstack/blob/master/README.md | ||
@@ -115,3 +116,3 @@ const localStackPorts = { | ||
*/ | ||
exports.throttleOnce = (fn) => { | ||
const throttleOnce = (fn) => { | ||
let throttleNextCall = true; | ||
@@ -126,2 +127,3 @@ return (...args) => { | ||
}; | ||
exports.throttleOnce = throttleOnce; | ||
//# sourceMappingURL=test-utils.js.map |
13
utils.js
@@ -11,3 +11,3 @@ "use strict"; | ||
// Note: This mutates the error that was passed in. | ||
exports.setErrorStack = (error, newStack) => { | ||
const setErrorStack = (error, newStack) => { | ||
if (error.stack) { | ||
@@ -25,2 +25,3 @@ // eslint-disable-next-line no-param-reassign | ||
}; | ||
exports.setErrorStack = setErrorStack; | ||
// eslint-disable-next-line valid-jsdoc | ||
@@ -38,3 +39,3 @@ /** | ||
*/ | ||
exports.improveStackTrace = (fn) => async (...args) => { | ||
const improveStackTrace = (fn) => async (...args) => { | ||
const tracerError = new Error(); | ||
@@ -47,3 +48,3 @@ try { | ||
// @ts-ignore | ||
exports.setErrorStack(error, tracerError.stack); | ||
(0, exports.setErrorStack)(error, tracerError.stack); | ||
error.message = `${error.message}; Function params: ${JSON.stringify(args, undefined, 2)}`; | ||
@@ -53,4 +54,5 @@ throw error; | ||
}; | ||
exports.improveStackTrace = improveStackTrace; | ||
const retryIfThrottlingException = (err) => { | ||
if (errors_1.isThrottlingException(err)) | ||
if ((0, errors_1.isThrottlingException)(err)) | ||
throw err; | ||
@@ -71,3 +73,4 @@ throw new p_retry_1.default.AbortError(err); | ||
*/ | ||
exports.retryOnThrottlingException = (fn, options = {}) => (...args) => p_retry_1.default(() => fn(...args).catch(retryIfThrottlingException), { maxTimeout: 5000, ...options }); | ||
const retryOnThrottlingException = (fn, options = {}) => (...args) => (0, p_retry_1.default)(() => fn(...args).catch(retryIfThrottlingException), { maxTimeout: 5000, ...options }); | ||
exports.retryOnThrottlingException = retryOnThrottlingException; | ||
//# sourceMappingURL=utils.js.map |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
199805
3359
1213
+ Added@cumulus/checksum@9.8.0(transitive)
+ Added@cumulus/errors@9.8.0(transitive)
+ Added@cumulus/logger@9.8.0(transitive)
- Removed@cumulus/checksum@9.7.0(transitive)
- Removed@cumulus/errors@9.7.0(transitive)
- Removed@cumulus/logger@9.7.0(transitive)
Updated@cumulus/checksum@9.8.0
Updated@cumulus/errors@9.8.0
Updated@cumulus/logger@9.8.0