@cumulus/message 9.7.1 → 9.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Queue.js CHANGED
@@ -20,13 +20,14 @@ const isNil_1 = __importDefault(require("lodash/isNil"));
20
20
  *
21
21
  * @alias module:Queue
22
22
  */
23
- exports.getQueueUrl = (message) => {
23
+ const getQueueUrl = (message) => {
24
24
  const queueUrl = message.cumulus_meta.queueUrl;
25
- if (isNil_1.default(queueUrl)) {
25
+ if ((0, isNil_1.default)(queueUrl)) {
26
26
  throw new Error('Could not find queue URL at cumulus_meta.queueUrl in message');
27
27
  }
28
28
  return queueUrl;
29
29
  };
30
+ exports.getQueueUrl = getQueueUrl;
30
31
  /**
31
32
  * Get the maximum executions for a queue.
32
33
  *
@@ -37,14 +38,15 @@ exports.getQueueUrl = (message) => {
37
38
  *
38
39
  * @alias module:Queue
39
40
  */
40
- exports.getMaximumExecutions = (message, queueUrl) => {
41
+ const getMaximumExecutions = (message, queueUrl) => {
41
42
  var _a;
42
43
  const maxExecutions = (_a = message.cumulus_meta.queueExecutionLimits) === null || _a === void 0 ? void 0 : _a[queueUrl];
43
- if (isNil_1.default(maxExecutions)) {
44
+ if ((0, isNil_1.default)(maxExecutions)) {
44
45
  throw new Error(`Could not determine maximum executions for queue ${queueUrl}`);
45
46
  }
46
47
  return maxExecutions;
47
48
  };
49
+ exports.getMaximumExecutions = getMaximumExecutions;
48
50
  /**
49
51
  * Determine if there is a queue and queue execution limit in the message.
50
52
  *
@@ -53,14 +55,15 @@ exports.getMaximumExecutions = (message, queueUrl) => {
53
55
  *
54
56
  * @alias module:Queue
55
57
  */
56
- exports.hasQueueAndExecutionLimit = (message) => {
58
+ const hasQueueAndExecutionLimit = (message) => {
57
59
  try {
58
- const queueUrl = exports.getQueueUrl(message);
59
- exports.getMaximumExecutions(message, queueUrl);
60
+ const queueUrl = (0, exports.getQueueUrl)(message);
61
+ (0, exports.getMaximumExecutions)(message, queueUrl);
60
62
  }
61
63
  catch (error) {
62
64
  return false;
63
65
  }
64
66
  return true;
65
67
  };
68
+ exports.hasQueueAndExecutionLimit = hasQueueAndExecutionLimit;
66
69
  //# sourceMappingURL=Queue.js.map
package/Queue.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Queue.js","sourceRoot":"","sources":["src/Queue.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAEb;;;;;;GAMG;AAEH,yDAAiC;AASjC;;;;;;;GAOG;AACU,QAAA,WAAW,GAAG,CAAC,OAA6B,EAAU,EAAE;IACnE,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC;IAC/C,IAAI,eAAK,CAAC,QAAQ,CAAC,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;KACjF;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF;;;;;;;;;GASG;AACU,QAAA,oBAAoB,GAAG,CAClC,OAA+B,EAC/B,QAAgB,EACR,EAAE;;IACV,MAAM,aAAa,SAAG,OAAO,CAAC,YAAY,CAAC,oBAAoB,0CAAG,QAAQ,CAAC,CAAC;IAC5E,IAAI,eAAK,CAAC,aAAa,CAAC,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,oDAAoD,QAAQ,EAAE,CAAC,CAAC;KACjF;IACD,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AAEF;;;;;;;GAOG;AACU,QAAA,yBAAyB,GAAG,CACvC,OAA6B,EACpB,EAAE;IACX,IAAI;QACF,MAAM,QAAQ,GAAG,mBAAW,CAAC,OAAO,CAAC,CAAC;QACtC,4BAAoB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;KACzC;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,KAAK,CAAC;KACd;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
1
+ {"version":3,"file":"Queue.js","sourceRoot":"","sources":["src/Queue.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAEb;;;;;;GAMG;AAEH,yDAAiC;AASjC;;;;;;;GAOG;AACI,MAAM,WAAW,GAAG,CAAC,OAA6B,EAAU,EAAE;IACnE,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC;IAC/C,IAAI,IAAA,eAAK,EAAC,QAAQ,CAAC,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;KACjF;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AANW,QAAA,WAAW,eAMtB;AAEF;;;;;;;;;GASG;AACI,MAAM,oBAAoB,GAAG,CAClC,OAA+B,EAC/B,QAAgB,EACR,EAAE;;IACV,MAAM,aAAa,GAAG,MAAA,OAAO,CAAC,YAAY,CAAC,oBAAoB,0CAAG,QAAQ,CAAC,CAAC;IAC5E,IAAI,IAAA,eAAK,EAAC,aAAa,CAAC,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,oDAAoD,QAAQ,EAAE,CAAC,CAAC;KACjF;IACD,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AATW,QAAA,oBAAoB,wBAS/B;AAEF;;;;;;;GAOG;AACI,MAAM,yBAAyB,GAAG,CACvC,OAA6B,EACpB,EAAE;IACX,IAAI;QACF,MAAM,QAAQ,GAAG,IAAA,mBAAW,EAAC,OAAO,CAAC,CAAC;QACtC,IAAA,4BAAoB,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;KACzC;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,KAAK,CAAC;KACd;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAVW,QAAA,yBAAyB,6BAUpC"}
package/README.md CHANGED
@@ -23,94 +23,118 @@ from a Cumulus message</p>
23
23
  <dt><a href="#module_Queue">Queue</a></dt>
24
24
  <dd><p>Utility functions for parsing queue information from a Cumulus message</p>
25
25
  </dd>
26
- <dt><a href="#module_StepFunctions">StepFunctions</a></dt>
27
- <dd><p>Utility functions for working with AWS Step Function events/messages</p>
28
- </dd>
29
26
  </dl>
30
27
 
31
28
  ### Functions
32
29
 
33
30
  <dl>
34
- <dt><a href="#exp_module_AsyncOperations--exports.getMessageAsyncOperationId">exports.getMessageAsyncOperationId(message)</a> ⇒ <code>undefined</code> | <code>string</code> ⏏</dt>
31
+ <dt><a href="#exp_module_AsyncOperations--getMessageAsyncOperationId">getMessageAsyncOperationId(message)</a> ⇒ <code>undefined</code> | <code>string</code> ⏏</dt>
35
32
  <dd><p>Get the async operation ID from a workflow message, if any.</p>
36
33
  </dd>
37
- <dt><a href="#exp_module_Collections--exports.constructCollectionId">exports.constructCollectionId(name, version)</a> ⇒ <code>string</code> ⏏</dt>
34
+ <dt><a href="#exp_module_Collections--constructCollectionId">constructCollectionId(name, version)</a> ⇒ <code>string</code> ⏏</dt>
38
35
  <dd><p>Returns the collection ID.</p>
39
36
  </dd>
40
37
  <dt><a href="#deconstructCollectionId">deconstructCollectionId(collectionId)</a> ⇒ <code>Object</code></dt>
41
38
  <dd><p>Returns the name and version of a collection based on
42
39
  the collectionId used in elasticsearch indexing</p>
43
40
  </dd>
44
- <dt><a href="#exp_module_Collections--exports.getCollectionNameAndVersionFromMessage">exports.getCollectionNameAndVersionFromMessage(message)</a> ⇒ <code>CollectionInfo</code> | <code>undefined</code> ⏏</dt>
41
+ <dt><a href="#exp_module_Collections--getCollectionNameAndVersionFromMessage">getCollectionNameAndVersionFromMessage(message)</a> ⇒ <code>CollectionInfo</code> | <code>undefined</code> ⏏</dt>
45
42
  <dd><p>Get collection name and version from execution message.</p>
46
43
  </dd>
47
- <dt><a href="#exp_module_Collections--exports.getCollectionIdFromMessage">exports.getCollectionIdFromMessage(message)</a> ⇒ <code>string</code> | <code>undefined</code> ⏏</dt>
44
+ <dt><a href="#exp_module_Collections--getCollectionIdFromMessage">getCollectionIdFromMessage(message)</a> ⇒ <code>string</code> | <code>undefined</code> ⏏</dt>
48
45
  <dd><p>Get collection ID from execution message.</p>
49
46
  </dd>
50
- <dt><a href="#exp_module_Granules--exports.getMessageGranules">exports.getMessageGranules(message)</a> ⇒ <code>Array.&lt;Object&gt;</code> | <code>undefined</code> ⏏</dt>
47
+ <dt><a href="#unwrapDeadLetterCumulusMessage">unwrapDeadLetterCumulusMessage(messageBody)</a> ⇒ <code>Object</code></dt>
48
+ <dd><p>Unwrap dead letter Cumulus message, which may be wrapped in a
49
+ States cloudwatch event, which is wrapped in an SQS message.</p>
50
+ </dd>
51
+ <dt><a href="#exp_module_Granules--getMessageGranules">getMessageGranules(message)</a> ⇒ <code>Array.&lt;Object&gt;</code> | <code>undefined</code> ⏏</dt>
51
52
  <dd><p>Get granules from payload?.granules of a workflow message.</p>
52
53
  </dd>
53
- <dt><a href="#exp_module_Granules--exports.messageHasGranules">exports.messageHasGranules(message)</a> ⇒ <code>boolean</code> ⏏</dt>
54
+ <dt><a href="#exp_module_Granules--messageHasGranules">messageHasGranules(message)</a> ⇒ <code>boolean</code> ⏏</dt>
54
55
  <dd><p>Determine if message has a granules object.</p>
55
56
  </dd>
56
- <dt><a href="#exp_module_Granules--exports.getGranuleStatus">exports.getGranuleStatus(workflowStatus, granule)</a> ⇒ <code>string</code> ⏏</dt>
57
+ <dt><a href="#exp_module_Granules--getGranuleStatus">getGranuleStatus(workflowStatus, granule)</a> ⇒ <code>string</code> ⏏</dt>
57
58
  <dd><p>Determine the status of a granule.</p>
58
59
  </dd>
59
- <dt><a href="#exp_module_Granules--exports.getGranuleQueryFields">exports.getGranuleQueryFields(message)</a> ⇒ <code>unknown</code> | <code>undefined</code> ⏏</dt>
60
+ <dt><a href="#exp_module_Granules--getGranuleQueryFields">getGranuleQueryFields(message)</a> ⇒ <code>unknown</code> | <code>undefined</code> ⏏</dt>
60
61
  <dd><p>Get the query fields of a granule, if any</p>
61
62
  </dd>
62
- <dt><a href="#exp_module_PDRs--exports.getMessagePdr">exports.getMessagePdr(message)</a> ⇒ <code>undefined</code> | <code>Object</code> ⏏</dt>
63
+ <dt><a href="#exp_module_PDRs--getMessagePdr">getMessagePdr(message)</a> ⇒ <code>undefined</code> | <code>Object</code> ⏏</dt>
63
64
  <dd><p>Get the PDR object from a workflow message, if any.</p>
64
65
  </dd>
65
- <dt><a href="#exp_module_PDRs--exports.messageHasPdr">exports.messageHasPdr(message)</a> ⇒ <code>boolean</code> ⏏</dt>
66
+ <dt><a href="#exp_module_PDRs--messageHasPdr">messageHasPdr(message)</a> ⇒ <code>boolean</code> ⏏</dt>
66
67
  <dd><p>Determine if message has a PDR.</p>
67
68
  </dd>
68
- <dt><a href="#exp_module_PDRs--exports.getMessagePdrPANSent">exports.getMessagePdrPANSent(message)</a> ⇒ <code>boolean</code> ⏏</dt>
69
+ <dt><a href="#exp_module_PDRs--getMessagePdrPANSent">getMessagePdrPANSent(message)</a> ⇒ <code>boolean</code> ⏏</dt>
69
70
  <dd><p>Get the PAN sent status from a workflow message, if any.</p>
70
71
  </dd>
71
- <dt><a href="#exp_module_PDRs--exports.getMessagePdrPANMessage">exports.getMessagePdrPANMessage(message)</a> ⇒ <code>string</code> ⏏</dt>
72
+ <dt><a href="#exp_module_PDRs--getMessagePdrPANMessage">getMessagePdrPANMessage(message)</a> ⇒ <code>string</code> ⏏</dt>
72
73
  <dd><p>Get the PAN message status from a workflow message, if any.</p>
73
74
  </dd>
74
- <dt><a href="#exp_module_PDRs--exports.getMessagePdrName">exports.getMessagePdrName(message)</a> ⇒ <code>string</code> ⏏</dt>
75
+ <dt><a href="#exp_module_PDRs--getMessagePdrName">getMessagePdrName(message)</a> ⇒ <code>string</code> ⏏</dt>
75
76
  <dd><p>Get the PDR name from a workflow message, if any.</p>
76
77
  </dd>
77
- <dt><a href="#exp_module_PDRs--exports.getMessagePdrRunningExecutions">exports.getMessagePdrRunningExecutions(message)</a> ⇒ <code>number</code> ⏏</dt>
78
+ <dt><a href="#exp_module_PDRs--getMessagePdrRunningExecutions">getMessagePdrRunningExecutions(message)</a> ⇒ <code>number</code> ⏏</dt>
78
79
  <dd><p>Get the number of running executions for a PDR, if any.</p>
79
80
  </dd>
80
- <dt><a href="#exp_module_PDRs--exports.getMessagePdrCompletedExecutions">exports.getMessagePdrCompletedExecutions(message)</a> ⇒ <code>number</code> ⏏</dt>
81
+ <dt><a href="#exp_module_PDRs--getMessagePdrCompletedExecutions">getMessagePdrCompletedExecutions(message)</a> ⇒ <code>number</code> ⏏</dt>
81
82
  <dd><p>Get the number of completed executions for a PDR, if any.</p>
82
83
  </dd>
83
- <dt><a href="#exp_module_PDRs--exports.getMessagePdrFailedExecutions">exports.getMessagePdrFailedExecutions(message)</a> ⇒ <code>number</code> ⏏</dt>
84
+ <dt><a href="#exp_module_PDRs--getMessagePdrFailedExecutions">getMessagePdrFailedExecutions(message)</a> ⇒ <code>number</code> ⏏</dt>
84
85
  <dd><p>Get the number of failed executions for a PDR, if any.</p>
85
86
  </dd>
86
- <dt><a href="#exp_module_PDRs--exports.getMessagePdrStats">exports.getMessagePdrStats(message)</a> ⇒ <code>PdrStats</code> ⏏</dt>
87
+ <dt><a href="#exp_module_PDRs--getMessagePdrStats">getMessagePdrStats(message)</a> ⇒ <code>PdrStats</code> ⏏</dt>
87
88
  <dd><p>Get the PDR stats from a workflow message, if any.</p>
88
89
  </dd>
89
- <dt><a href="#exp_module_PDRs--exports.getPdrPercentCompletion">exports.getPdrPercentCompletion(stats)</a> ⇒ <code>number</code> ⏏</dt>
90
+ <dt><a href="#exp_module_PDRs--getPdrPercentCompletion">getPdrPercentCompletion(stats)</a> ⇒ <code>number</code> ⏏</dt>
90
91
  <dd><p>Get the percent completion of PDR executions</p>
91
92
  </dd>
92
- <dt><a href="#exp_module_Providers--exports.getMessageProvider">exports.getMessageProvider(message)</a> ⇒ <code>MessageProvider</code> | <code>string</code> ⏏</dt>
93
+ <dt><a href="#exp_module_Providers--getMessageProvider">getMessageProvider(message)</a> ⇒ <code>MessageProvider</code> | <code>string</code> ⏏</dt>
93
94
  <dd><p>Get the provider from a workflow message, if any.</p>
94
95
  </dd>
95
- <dt><a href="#exp_module_Providers--exports.getMessageProviderId">exports.getMessageProviderId(message)</a> ⇒ <code>undefined</code> | <code>string</code> ⏏</dt>
96
+ <dt><a href="#exp_module_Providers--getMessageProviderId">getMessageProviderId(message)</a> ⇒ <code>undefined</code> | <code>string</code> ⏏</dt>
96
97
  <dd><p>Get the provider ID from a workflow message, if any.</p>
97
98
  </dd>
98
- <dt><a href="#exp_module_workflows--exports.getMetaStatus">exports.getMetaStatus(message)</a> ⇒ <code>Message.WorkflowStatus</code> | <code>undefined</code> ⏏</dt>
99
+ <dt><a href="#exp_module_StepFunctions--pullStepFunctionEvent">pullStepFunctionEvent(event)</a> ⇒ <code>Promise.&lt;Object&gt;</code> ⏏</dt>
100
+ <dd><p>Given a Step Function event, replace specified key in event with contents
101
+ of S3 remote message</p>
102
+ </dd>
103
+ <dt><a href="#exp_module_StepFunctions--parseStepMessage">parseStepMessage(stepMessage, stepName)</a> ⇒ <code>Promise.&lt;Object&gt;</code> ⏏</dt>
104
+ <dd><p>Parse step message with CMA keys and replace specified key in event with contents
105
+ of S3 remote message</p>
106
+ </dd>
107
+ <dt><a href="#getFailedStepName">getFailedStepName(events, failedStepEvent)</a> ⇒ <code>string</code></dt>
108
+ <dd><p>Searches the Execution step History for the TaskStateEntered pertaining to
109
+ the failed task Id. HistoryEvent ids are numbered sequentially, starting at
110
+ one.</p>
111
+ </dd>
112
+ <dt><a href="#lastFailedEventStep">lastFailedEventStep(events)</a> ⇒ <code>Array.&lt;HistoryEvent&gt;</code></dt>
113
+ <dd><p>Finds all failed execution events and returns the last one in the list.</p>
114
+ </dd>
115
+ <dt><a href="#getFailedExecutionMessage">getFailedExecutionMessage(inputCumulusMessage, getExecutionHistoryFunction)</a> ⇒ <code>Object</code></dt>
116
+ <dd><p>Get message to use for publishing failed execution notifications.</p>
117
+ <p>Try to get the input to the last failed step in the execution so we can
118
+ update the status of any granules/PDRs that don&#39;t exist in the initial execution
119
+ input.</p>
120
+ <p>Falls back to overall execution input.</p>
121
+ </dd>
122
+ <dt><a href="#exp_module_workflows--getMetaStatus">getMetaStatus(message)</a> ⇒ <code>Message.WorkflowStatus</code> | <code>undefined</code> ⏏</dt>
99
123
  <dd><p>Get the status of a workflow message, if any.</p>
100
124
  </dd>
101
- <dt><a href="#exp_module_workflows--exports.getMessageWorkflowTasks">exports.getMessageWorkflowTasks(message)</a> ⇒ <code>Object</code> | <code>undefined</code> ⏏</dt>
125
+ <dt><a href="#exp_module_workflows--getMessageWorkflowTasks">getMessageWorkflowTasks(message)</a> ⇒ <code>Object</code> | <code>undefined</code> ⏏</dt>
102
126
  <dd><p>Get the workflow tasks in a workflow message, if any.</p>
103
127
  </dd>
104
- <dt><a href="#exp_module_workflows--exports.getMessageWorkflowStartTime">exports.getMessageWorkflowStartTime(message)</a> ⇒ <code>number</code> | <code>undefined</code> ⏏</dt>
128
+ <dt><a href="#exp_module_workflows--getMessageWorkflowStartTime">getMessageWorkflowStartTime(message)</a> ⇒ <code>number</code> | <code>undefined</code> ⏏</dt>
105
129
  <dd><p>Get the workflow start time, if any.</p>
106
130
  </dd>
107
- <dt><a href="#exp_module_workflows--exports.getMessageWorkflowStopTime">exports.getMessageWorkflowStopTime(message)</a> ⇒ <code>number</code> | <code>undefined</code> ⏏</dt>
131
+ <dt><a href="#exp_module_workflows--getMessageWorkflowStopTime">getMessageWorkflowStopTime(message)</a> ⇒ <code>number</code> | <code>undefined</code> ⏏</dt>
108
132
  <dd><p>Get the workflow stop time, if any.</p>
109
133
  </dd>
110
- <dt><a href="#exp_module_workflows--exports.getMessageWorkflowName">exports.getMessageWorkflowName(message)</a> ⇒ <code>string</code> | <code>undefined</code> ⏏</dt>
134
+ <dt><a href="#exp_module_workflows--getMessageWorkflowName">getMessageWorkflowName(message)</a> ⇒ <code>string</code> | <code>undefined</code> ⏏</dt>
111
135
  <dd><p>Get the workflow name, if any.</p>
112
136
  </dd>
113
- <dt><a href="#exp_module_workflows--exports.getWorkflowDuration">exports.getWorkflowDuration(startTime, [stopTime])</a> ⇒ <code>number</code> ⏏</dt>
137
+ <dt><a href="#exp_module_workflows--getWorkflowDuration">getWorkflowDuration(startTime, [stopTime])</a> ⇒ <code>number</code> ⏏</dt>
114
138
  <dd><p>Get the workflow duration.</p>
115
139
  </dd>
116
140
  </dl>
@@ -124,9 +148,9 @@ Utility functions for building Cumulus messages
124
148
  ```js
125
149
  const Build = require('@cumulus/message/Build');
126
150
  ```
127
- <a name="exp_module_Build--exports.buildQueueMessageFromTemplate"></a>
151
+ <a name="exp_module_Build--buildQueueMessageFromTemplate"></a>
128
152
 
129
- #### exports.buildQueueMessageFromTemplate(params) ⇒ <code>Message.CumulusMessage</code> ⏏
153
+ #### buildQueueMessageFromTemplate(params) ⇒ <code>Message.CumulusMessage</code> ⏏
130
154
  Build an SQS message from a workflow template for queueing executions.
131
155
 
132
156
  **Kind**: Exported function
@@ -158,20 +182,20 @@ const Executions = require('@cumulus/message/Executions');
158
182
  ```
159
183
 
160
184
  * [Executions](#module_Executions)
161
- * [exports.buildExecutionArn(stateMachineArn, executionName)](#exp_module_Executions--exports.buildExecutionArn) ⇒ <code>string</code> ⏏
162
- * [exports.getExecutionUrlFromArn(executionArn)](#exp_module_Executions--exports.getExecutionUrlFromArn) ⇒ <code>string</code> ⏏
163
- * [exports.getStateMachineArnFromExecutionArn(executionArn)](#exp_module_Executions--exports.getStateMachineArnFromExecutionArn) ⇒ <code>string</code> ⏏
164
- * [exports.getMessageExecutionName(message)](#exp_module_Executions--exports.getMessageExecutionName) ⇒ <code>string</code> ⏏
165
- * [exports.getMessageStateMachineArn(message)](#exp_module_Executions--exports.getMessageStateMachineArn) ⇒ <code>string</code> ⏏
166
- * [exports.getMessageExecutionArn(message)](#exp_module_Executions--exports.getMessageExecutionArn) ⇒ <code>null</code> \| <code>string</code> ⏏
167
- * [exports.getMessageExecutionParentArn(message)](#exp_module_Executions--exports.getMessageExecutionParentArn) ⇒ <code>undefined</code> \| <code>string</code> ⏏
168
- * [exports.getMessageCumulusVersion(message)](#exp_module_Executions--exports.getMessageCumulusVersion) ⇒ <code>undefined</code> \| <code>string</code> ⏏
169
- * [exports.getMessageExecutionOriginalPayload(message)](#exp_module_Executions--exports.getMessageExecutionOriginalPayload) ⇒ <code>unknown</code> \| <code>undefined</code> ⏏
170
- * [exports.getMessageExecutionFinalPayload(message)](#exp_module_Executions--exports.getMessageExecutionFinalPayload) ⇒ <code>unknown</code> \| <code>undefined</code> ⏏
171
-
172
- <a name="exp_module_Executions--exports.buildExecutionArn"></a>
173
-
174
- #### exports.buildExecutionArn(stateMachineArn, executionName) ⇒ <code>string</code> ⏏
185
+ * [buildExecutionArn(stateMachineArn, executionName)](#exp_module_Executions--buildExecutionArn) ⇒ <code>string</code> ⏏
186
+ * [getExecutionUrlFromArn(executionArn)](#exp_module_Executions--getExecutionUrlFromArn) ⇒ <code>string</code> ⏏
187
+ * [getStateMachineArnFromExecutionArn(executionArn)](#exp_module_Executions--getStateMachineArnFromExecutionArn) ⇒ <code>string</code> ⏏
188
+ * [getMessageExecutionName(message)](#exp_module_Executions--getMessageExecutionName) ⇒ <code>string</code> ⏏
189
+ * [getMessageStateMachineArn(message)](#exp_module_Executions--getMessageStateMachineArn) ⇒ <code>string</code> ⏏
190
+ * [getMessageExecutionArn(message)](#exp_module_Executions--getMessageExecutionArn) ⇒ <code>null</code> \| <code>string</code> ⏏
191
+ * [getMessageExecutionParentArn(message)](#exp_module_Executions--getMessageExecutionParentArn) ⇒ <code>undefined</code> \| <code>string</code> ⏏
192
+ * [getMessageCumulusVersion(message)](#exp_module_Executions--getMessageCumulusVersion) ⇒ <code>undefined</code> \| <code>string</code> ⏏
193
+ * [getMessageExecutionOriginalPayload(message)](#exp_module_Executions--getMessageExecutionOriginalPayload) ⇒ <code>unknown</code> \| <code>undefined</code> ⏏
194
+ * [getMessageExecutionFinalPayload(message)](#exp_module_Executions--getMessageExecutionFinalPayload) ⇒ <code>unknown</code> \| <code>undefined</code> ⏏
195
+
196
+ <a name="exp_module_Executions--buildExecutionArn"></a>
197
+
198
+ #### buildExecutionArn(stateMachineArn, executionName) ⇒ <code>string</code> ⏏
175
199
  Build execution ARN from a state machine ARN and execution name
176
200
 
177
201
  **Kind**: Exported function
@@ -182,9 +206,9 @@ Build execution ARN from a state machine ARN and execution name
182
206
  | stateMachineArn | <code>string</code> | state machine ARN |
183
207
  | executionName | <code>string</code> | state machine's execution name |
184
208
 
185
- <a name="exp_module_Executions--exports.getExecutionUrlFromArn"></a>
209
+ <a name="exp_module_Executions--getExecutionUrlFromArn"></a>
186
210
 
187
- #### exports.getExecutionUrlFromArn(executionArn) ⇒ <code>string</code> ⏏
211
+ #### getExecutionUrlFromArn(executionArn) ⇒ <code>string</code> ⏏
188
212
  Returns execution URL from an execution ARN.
189
213
 
190
214
  **Kind**: Exported function
@@ -194,9 +218,9 @@ Returns execution URL from an execution ARN.
194
218
  | --- | --- | --- |
195
219
  | executionArn | <code>string</code> | an execution ARN |
196
220
 
197
- <a name="exp_module_Executions--exports.getStateMachineArnFromExecutionArn"></a>
221
+ <a name="exp_module_Executions--getStateMachineArnFromExecutionArn"></a>
198
222
 
199
- #### exports.getStateMachineArnFromExecutionArn(executionArn) ⇒ <code>string</code> ⏏
223
+ #### getStateMachineArnFromExecutionArn(executionArn) ⇒ <code>string</code> ⏏
200
224
  Get state machine ARN from an execution ARN
201
225
 
202
226
  **Kind**: Exported function
@@ -206,9 +230,9 @@ Get state machine ARN from an execution ARN
206
230
  | --- | --- | --- |
207
231
  | executionArn | <code>string</code> | an execution ARN |
208
232
 
209
- <a name="exp_module_Executions--exports.getMessageExecutionName"></a>
233
+ <a name="exp_module_Executions--getMessageExecutionName"></a>
210
234
 
211
- #### exports.getMessageExecutionName(message) ⇒ <code>string</code> ⏏
235
+ #### getMessageExecutionName(message) ⇒ <code>string</code> ⏏
212
236
  Get the execution name from a workflow message.
213
237
 
214
238
  **Kind**: Exported function
@@ -222,9 +246,9 @@ Get the execution name from a workflow message.
222
246
  | --- | --- | --- |
223
247
  | message | <code>Message.CumulusMessage</code> | A workflow message object |
224
248
 
225
- <a name="exp_module_Executions--exports.getMessageStateMachineArn"></a>
249
+ <a name="exp_module_Executions--getMessageStateMachineArn"></a>
226
250
 
227
- #### exports.getMessageStateMachineArn(message) ⇒ <code>string</code> ⏏
251
+ #### getMessageStateMachineArn(message) ⇒ <code>string</code> ⏏
228
252
  Get the state machine ARN from a workflow message.
229
253
 
230
254
  **Kind**: Exported function
@@ -238,9 +262,9 @@ Get the state machine ARN from a workflow message.
238
262
  | --- | --- | --- |
239
263
  | message | <code>Message.CumulusMessage</code> | A workflow message object |
240
264
 
241
- <a name="exp_module_Executions--exports.getMessageExecutionArn"></a>
265
+ <a name="exp_module_Executions--getMessageExecutionArn"></a>
242
266
 
243
- #### exports.getMessageExecutionArn(message) ⇒ <code>null</code> \| <code>string</code> ⏏
267
+ #### getMessageExecutionArn(message) ⇒ <code>null</code> \| <code>string</code> ⏏
244
268
  Get the execution ARN from a workflow message.
245
269
 
246
270
  **Kind**: Exported function
@@ -250,9 +274,9 @@ Get the execution ARN from a workflow message.
250
274
  | --- | --- | --- |
251
275
  | message | <code>Message.CumulusMessage</code> | A workflow message object |
252
276
 
253
- <a name="exp_module_Executions--exports.getMessageExecutionParentArn"></a>
277
+ <a name="exp_module_Executions--getMessageExecutionParentArn"></a>
254
278
 
255
- #### exports.getMessageExecutionParentArn(message) ⇒ <code>undefined</code> \| <code>string</code> ⏏
279
+ #### getMessageExecutionParentArn(message) ⇒ <code>undefined</code> \| <code>string</code> ⏏
256
280
  Get the parent execution ARN from a workflow message, if any.
257
281
 
258
282
  **Kind**: Exported function
@@ -262,9 +286,9 @@ Get the parent execution ARN from a workflow message, if any.
262
286
  | --- | --- | --- |
263
287
  | message | <code>Message.CumulusMessage</code> | A workflow message object |
264
288
 
265
- <a name="exp_module_Executions--exports.getMessageCumulusVersion"></a>
289
+ <a name="exp_module_Executions--getMessageCumulusVersion"></a>
266
290
 
267
- #### exports.getMessageCumulusVersion(message) ⇒ <code>undefined</code> \| <code>string</code> ⏏
291
+ #### getMessageCumulusVersion(message) ⇒ <code>undefined</code> \| <code>string</code> ⏏
268
292
  Get the Cumulus version from a workflow message, if any.
269
293
 
270
294
  **Kind**: Exported function
@@ -274,9 +298,9 @@ Get the Cumulus version from a workflow message, if any.
274
298
  | --- | --- | --- |
275
299
  | message | <code>Message.CumulusMessage</code> | A workflow message object |
276
300
 
277
- <a name="exp_module_Executions--exports.getMessageExecutionOriginalPayload"></a>
301
+ <a name="exp_module_Executions--getMessageExecutionOriginalPayload"></a>
278
302
 
279
- #### exports.getMessageExecutionOriginalPayload(message) ⇒ <code>unknown</code> \| <code>undefined</code> ⏏
303
+ #### getMessageExecutionOriginalPayload(message) ⇒ <code>unknown</code> \| <code>undefined</code> ⏏
280
304
  Get the workflow original payload, if any.
281
305
 
282
306
  **Kind**: Exported function
@@ -286,9 +310,9 @@ Get the workflow original payload, if any.
286
310
  | --- | --- | --- |
287
311
  | message | <code>Message.CumulusMessage</code> | A workflow message object |
288
312
 
289
- <a name="exp_module_Executions--exports.getMessageExecutionFinalPayload"></a>
313
+ <a name="exp_module_Executions--getMessageExecutionFinalPayload"></a>
290
314
 
291
- #### exports.getMessageExecutionFinalPayload(message) ⇒ <code>unknown</code> \| <code>undefined</code> ⏏
315
+ #### getMessageExecutionFinalPayload(message) ⇒ <code>unknown</code> \| <code>undefined</code> ⏏
292
316
  Get the workflow final payload, if any.
293
317
 
294
318
  **Kind**: Exported function
@@ -309,13 +333,13 @@ const Queue = require('@cumulus/message/Queue');
309
333
  ```
310
334
 
311
335
  * [Queue](#module_Queue)
312
- * [exports.getQueueUrl(message)](#exp_module_Queue--exports.getQueueUrl) ⇒ <code>string</code> ⏏
313
- * [exports.getMaximumExecutions(message, queueUrl)](#exp_module_Queue--exports.getMaximumExecutions) ⇒ <code>number</code> ⏏
314
- * [exports.hasQueueAndExecutionLimit(message)](#exp_module_Queue--exports.hasQueueAndExecutionLimit) ⇒ <code>boolean</code> ⏏
336
+ * [getQueueUrl(message)](#exp_module_Queue--getQueueUrl) ⇒ <code>string</code> ⏏
337
+ * [getMaximumExecutions(message, queueUrl)](#exp_module_Queue--getMaximumExecutions) ⇒ <code>number</code> ⏏
338
+ * [hasQueueAndExecutionLimit(message)](#exp_module_Queue--hasQueueAndExecutionLimit) ⇒ <code>boolean</code> ⏏
315
339
 
316
- <a name="exp_module_Queue--exports.getQueueUrl"></a>
340
+ <a name="exp_module_Queue--getQueueUrl"></a>
317
341
 
318
- #### exports.getQueueUrl(message) ⇒ <code>string</code> ⏏
342
+ #### getQueueUrl(message) ⇒ <code>string</code> ⏏
319
343
  Get the queue URL from a workflow message.
320
344
 
321
345
  **Kind**: Exported function
@@ -325,9 +349,9 @@ Get the queue URL from a workflow message.
325
349
  | --- | --- | --- |
326
350
  | message | <code>MessageWithQueueInfo</code> | A workflow message object |
327
351
 
328
- <a name="exp_module_Queue--exports.getMaximumExecutions"></a>
352
+ <a name="exp_module_Queue--getMaximumExecutions"></a>
329
353
 
330
- #### exports.getMaximumExecutions(message, queueUrl) ⇒ <code>number</code> ⏏
354
+ #### getMaximumExecutions(message, queueUrl) ⇒ <code>number</code> ⏏
331
355
  Get the maximum executions for a queue.
332
356
 
333
357
  **Kind**: Exported function
@@ -342,9 +366,9 @@ Get the maximum executions for a queue.
342
366
  | message | <code>Message.CumulusMessage</code> | A workflow message object |
343
367
  | queueUrl | <code>string</code> | A queue URL |
344
368
 
345
- <a name="exp_module_Queue--exports.hasQueueAndExecutionLimit"></a>
369
+ <a name="exp_module_Queue--hasQueueAndExecutionLimit"></a>
346
370
 
347
- #### exports.hasQueueAndExecutionLimit(message) ⇒ <code>boolean</code> ⏏
371
+ #### hasQueueAndExecutionLimit(message) ⇒ <code>boolean</code> ⏏
348
372
  Determine if there is a queue and queue execution limit in the message.
349
373
 
350
374
  **Kind**: Exported function
@@ -354,63 +378,78 @@ Determine if there is a queue and queue execution limit in the message.
354
378
  | --- | --- | --- |
355
379
  | message | <code>MessageWithQueueInfo</code> | A workflow message object |
356
380
 
357
- <a name="module_StepFunctions"></a>
381
+ <a name="deconstructCollectionId"></a>
358
382
 
359
- ### StepFunctions
360
- Utility functions for working with AWS Step Function events/messages
383
+ ### deconstructCollectionId(collectionId) ⇒ <code>Object</code>
384
+ Returns the name and version of a collection based on
385
+ the collectionId used in elasticsearch indexing
361
386
 
362
- **Example**
363
- ```js
364
- const StepFunctions = require('@cumulus/message/StepFunctions');
365
- ```
387
+ **Kind**: global function
388
+ **Returns**: <code>Object</code> - name and version as object
366
389
 
367
- * [StepFunctions](#module_StepFunctions)
368
- * [exports.pullStepFunctionEvent(event)](#exp_module_StepFunctions--exports.pullStepFunctionEvent) <code>Promise.&lt;Object&gt;</code>
369
- * [exports.parseStepMessage(stepMessage, stepName)](#exp_module_StepFunctions--exports.parseStepMessage) <code>Promise.&lt;Object&gt;</code>
390
+ | Param | Type | Description |
391
+ | --- | --- | --- |
392
+ | collectionId | <code>string</code> | collectionId used in elasticsearch index |
370
393
 
371
- <a name="exp_module_StepFunctions--exports.pullStepFunctionEvent"></a>
394
+ <a name="unwrapDeadLetterCumulusMessage"></a>
372
395
 
373
- #### exports.pullStepFunctionEvent(event) ⇒ <code>Promise.&lt;Object&gt;</code>
374
- Given a Step Function event, replace specified key in event with contents
375
- of S3 remote message
396
+ ### unwrapDeadLetterCumulusMessage(messageBody) ⇒ <code>Object</code>
397
+ Unwrap dead letter Cumulus message, which may be wrapped in a
398
+ States cloudwatch event, which is wrapped in an SQS message.
376
399
 
377
- **Kind**: Exported function
378
- **Returns**: <code>Promise.&lt;Object&gt;</code> - Updated event with target path replaced by remote message
379
- **Throws**:
400
+ **Kind**: global function
401
+ **Returns**: <code>Object</code> - the cumulus message or nearest available object
380
402
 
381
- - <code>Error</code> if target path cannot be found on source event
403
+ | Param | Type | Description |
404
+ | --- | --- | --- |
405
+ | messageBody | <code>Object</code> | received SQS message |
382
406
 
407
+ <a name="getFailedStepName"></a>
408
+
409
+ ### getFailedStepName(events, failedStepEvent) ⇒ <code>string</code>
410
+ Searches the Execution step History for the TaskStateEntered pertaining to
411
+ the failed task Id. HistoryEvent ids are numbered sequentially, starting at
412
+ one.
413
+
414
+ **Kind**: global function
415
+ **Returns**: <code>string</code> - name of the current stepfunction task or 'UnknownFailedStepName'.
383
416
 
384
417
  | Param | Type | Description |
385
418
  | --- | --- | --- |
386
- | event | <code>Message.CumulusRemoteMessage</code> | Source event |
419
+ | events | <code>Array.&lt;HistoryEvent&gt;</code> | Step Function events array |
420
+ | failedStepEvent | <code>HistoryEvent</code> | Step Function's failed event. |
387
421
 
388
- <a name="exp_module_StepFunctions--exports.parseStepMessage"></a>
422
+ <a name="lastFailedEventStep"></a>
389
423
 
390
- #### exports.parseStepMessage(stepMessage, stepName) ⇒ <code>Promise.&lt;Object&gt;</code>
391
- Parse step message with CMA keys and replace specified key in event with contents
392
- of S3 remote message
424
+ ### lastFailedEventStep(events) ⇒ <code>Array.&lt;HistoryEvent&gt;</code>
425
+ Finds all failed execution events and returns the last one in the list.
393
426
 
394
- **Kind**: Exported function
395
- **Returns**: <code>Promise.&lt;Object&gt;</code> - Parsed and updated event with target path replaced by remote message
427
+ **Kind**: global function
428
+ **Returns**: <code>Array.&lt;HistoryEvent&gt;</code> - - the last lambda or activity that failed in the
429
+ event array, or an empty array.
396
430
 
397
431
  | Param | Type | Description |
398
432
  | --- | --- | --- |
399
- | stepMessage | <code>CMAMessage</code> | Message for the step |
400
- | stepName | <code>string</code> | Name of the step |
433
+ | events | <code>Array.&lt;HistoryEventList&gt;</code> | array of AWS Stepfunction execution HistoryEvents |
401
434
 
402
- <a name="deconstructCollectionId"></a>
435
+ <a name="getFailedExecutionMessage"></a>
403
436
 
404
- ### deconstructCollectionId(collectionId) ⇒ <code>Object</code>
405
- Returns the name and version of a collection based on
406
- the collectionId used in elasticsearch indexing
437
+ ### getFailedExecutionMessage(inputCumulusMessage, getExecutionHistoryFunction) ⇒ <code>Object</code>
438
+ Get message to use for publishing failed execution notifications.
439
+
440
+ Try to get the input to the last failed step in the execution so we can
441
+ update the status of any granules/PDRs that don't exist in the initial execution
442
+ input.
443
+
444
+ Falls back to overall execution input.
407
445
 
408
446
  **Kind**: global function
409
- **Returns**: <code>Object</code> - name and version as object
447
+ **Returns**: <code>Object</code> - - CumulusMessage Execution step message or execution input message
410
448
 
411
449
  | Param | Type | Description |
412
450
  | --- | --- | --- |
413
- | collectionId | <code>string</code> | collectionId used in elasticsearch index |
451
+ | inputCumulusMessage | <code>Object</code> | Workflow execution input message |
452
+ | getExecutionHistoryFunction | <code>function</code> | Testing override for mock/etc of StepFunctions.getExecutionHistory |
414
453
 
415
454
 
416
455
  ## About Cumulus
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Utility functions for working with AWS Step Function events/messages
3
+ * @module StepFunctions
4
+ *
5
+ * @example
6
+ * const StepFunctions = require('@cumulus/message/StepFunctions');
7
+ */
8
+ import { EventBridgeEvent } from 'aws-lambda';
9
+ import { getExecutionHistory } from '@cumulus/aws-client/StepFunctions';
1
10
  import { Message } from '@cumulus/types';
2
11
  /**
3
12
  * Given a Step Function event, replace specified key in event with contents
@@ -25,4 +34,51 @@ export declare const pullStepFunctionEvent: (event: {
25
34
  * @alias module:StepFunctions
26
35
  */
27
36
  export declare const parseStepMessage: (stepMessage: Message.CMAMessage, stepName: string) => Promise<Message.CumulusMessage>;
37
+ /**
38
+ * Searches the Execution step History for the TaskStateEntered pertaining to
39
+ * the failed task Id. HistoryEvent ids are numbered sequentially, starting at
40
+ * one.
41
+ *
42
+ * @param {HistoryEvent[]} events - Step Function events array
43
+ * @param {HistoryEvent} failedStepEvent - Step Function's failed event.
44
+ * @returns {string} name of the current stepfunction task or 'UnknownFailedStepName'.
45
+ */
46
+ export declare const getFailedStepName: (events: AWS.StepFunctions.HistoryEvent[], failedStepEvent: {
47
+ id: number;
48
+ }) => string;
49
+ /**
50
+ * Finds all failed execution events and returns the last one in the list.
51
+ *
52
+ * @param {Array<HistoryEventList>} events - array of AWS Stepfunction execution HistoryEvents
53
+ * @returns {HistoryEvent[]} - the last lambda or activity that failed in the
54
+ * event array, or an empty array.
55
+ */
56
+ export declare const lastFailedEventStep: (events: AWS.StepFunctions.HistoryEvent[]) => AWS.StepFunctions.HistoryEvent | undefined;
57
+ /**
58
+ * Get message to use for publishing failed execution notifications.
59
+ *
60
+ * Try to get the input to the last failed step in the execution so we can
61
+ * update the status of any granules/PDRs that don't exist in the initial execution
62
+ * input.
63
+ *
64
+ * Falls back to overall execution input.
65
+ *
66
+ * @param {Object} inputCumulusMessage - Workflow execution input message
67
+ * @param {Function} getExecutionHistoryFunction - Testing override for mock/etc of
68
+ * StepFunctions.getExecutionHistory
69
+ * @returns {Object} - CumulusMessage Execution step message or execution input message
70
+ */
71
+ export declare const getFailedExecutionMessage: (inputCumulusMessage: Message.CumulusMessage, getExecutionHistoryFunction?: typeof getExecutionHistory) => Promise<Message.CumulusMessage | {
72
+ exception: {
73
+ failedExecutionStepName: string;
74
+ error?: string | undefined;
75
+ cause?: string | undefined;
76
+ };
77
+ cumulus_meta: Message.CumulusMeta;
78
+ meta: Message.Meta;
79
+ payload: unknown;
80
+ }>;
81
+ export declare const getCumulusMessageFromExecutionEvent: (executionEvent: EventBridgeEvent<"Step Functions Execution Status Change", {
82
+ [key: string]: string;
83
+ }>) => Promise<Message.CumulusMessage>;
28
84
  //# sourceMappingURL=StepFunctions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"StepFunctions.d.ts","sourceRoot":"","sources":["src/StepFunctions.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAMzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,UACzB;IACL,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAA;CAChC,KACA,OAAO,CAAC,OAAO,CAyBjB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,gBACd,OAAO,CAAC,UAAU,YACrB,MAAM,oCAkBjB,CAAC"}
1
+ {"version":3,"file":"StepFunctions.d.ts","sourceRoot":"","sources":["src/StepFunctions.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAK9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA6BzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,UACzB;IACL,OAAO,CAAC,EAAE,QAAQ,aAAa,CAAA;CAChC,KACA,QAAQ,OAAO,CAyBjB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,gBACd,QAAQ,UAAU,YACrB,MAAM,oCAkBjB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,WACpB,IAAI,aAAa,CAAC,YAAY,EAAE,mBACvB;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,WAehC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,WACtB,IAAI,aAAa,CAAC,YAAY,EAAE,KACvC,IAAI,aAAa,CAAC,YAAY,GAAG,SAInC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB,wBACf,QAAQ,cAAc,gCACd,0BAA0B;;;;;;;;;EAwCxD,CAAC;AAEF,eAAO,MAAM,mCAAmC;;sCA2B/C,CAAC"}