Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
generateDocFromPayload(payload) {
const name = get(payload, 'cumulus_meta.execution_name');
const arn = aws.getExecutionArn(
get(payload, 'cumulus_meta.state_machine'),
name
);
if (!arn) {
throw new Error('State Machine Arn is missing. Must be included in the cumulus_meta');
}
const execution = aws.getExecutionUrl(arn);
const collectionId = constructCollectionId(
get(payload, 'meta.collection.name'), get(payload, 'meta.collection.version')
);
const doc = {
name,
arn,
parentArn: get(payload, 'cumulus_meta.parentExecutionArn'),
createPdrFromSns(payload) {
const name = get(payload, 'cumulus_meta.execution_name');
const pdrObj = get(payload, 'payload.pdr', get(payload, 'meta.pdr'));
const pdrName = get(pdrObj, 'name');
if (!pdrName) return Promise.resolve();
const arn = aws.getExecutionArn(
get(payload, 'cumulus_meta.state_machine'),
name
);
const execution = aws.getExecutionUrl(arn);
const collection = get(payload, 'meta.collection');
const collectionId = constructCollectionId(collection.dataType, collection.version);
const stats = {
processing: get(payload, 'payload.running', []).length,
completed: get(payload, 'payload.completed', []).length,
failed: get(payload, 'payload.failed', []).length
};
stats.total = stats.processing + stats.completed + stats.failed;
let progress = 0;
createPdrFromSns(payload) {
const name = get(payload, 'cumulus_meta.execution_name');
const pdrObj = get(payload, 'payload.pdr', get(payload, 'meta.pdr'));
const pdrName = get(pdrObj, 'name');
if (!pdrName) return Promise.resolve();
const arn = aws.getExecutionArn(
get(payload, 'cumulus_meta.state_machine'),
name
);
const execution = aws.getExecutionUrl(arn);
const collection = get(payload, 'meta.collection');
const collectionId = constructCollectionId(collection.name, collection.version);
const stats = {
processing: get(payload, 'payload.running', []).length,
completed: get(payload, 'payload.completed', []).length,
failed: get(payload, 'payload.failed', []).length
};
stats.total = stats.processing + stats.completed + stats.failed;
let progress = 0;
createGranulesFromSns(payload) {
const name = get(payload, 'cumulus_meta.execution_name');
const granules = get(payload, 'payload.granules', get(payload, 'meta.input_granules'));
if (!granules) return Promise.resolve();
const arn = aws.getExecutionArn(
get(payload, 'cumulus_meta.state_machine'),
name
);
if (!arn) return Promise.resolve();
const execution = aws.getExecutionUrl(arn);
const collection = get(payload, 'meta.collection');
const exception = parseException(payload.exception);
const collectionId = constructCollectionId(collection.dataType, collection.version);
const done = granules.map(async (g) => {
if (g.granuleId) {
const doc = {