Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getCumulusMessageFromExecutionEvent = async (executionEvent) => {
let cumulusMessage;
if (executionEvent.detail.status === 'RUNNING') {
cumulusMessage = JSON.parse(executionEvent.detail.input);
} else if (executionEvent.detail.status === 'SUCCEEDED') {
cumulusMessage = JSON.parse(executionEvent.detail.output);
} else {
const inputMessage = JSON.parse(get(executionEvent, 'detail.input', '{}'));
cumulusMessage = await getFailedExecutionMessage(inputMessage);
}
const fullCumulusMessage = await pullStepFunctionEvent(cumulusMessage);
const workflowStatus = executionStatusToWorkflowStatus(executionEvent.detail.status);
set(fullCumulusMessage, 'meta.status', workflowStatus);
set(fullCumulusMessage, 'cumulus_meta.workflow_start_time', executionEvent.detail.startDate);
set(fullCumulusMessage, 'cumulus_meta.workflow_stop_time', executionEvent.detail.stopDate);
return fullCumulusMessage;
};