18.2.1 • Published 1 day ago

@cumulus/message v18.2.1

Weekly downloads
224
License
Apache-2.0
Repository
github
Last release
1 day ago

@cumulus/message

Utilities for building and parsing Cumulus workflow messages.

Usage

  npm install @cumulus/message

API

Modules

Functions

Build

Utility functions for building Cumulus messages

Example

const Build = require('@cumulus/message/Build');

buildQueueMessageFromTemplate(params) ⇒ Message.CumulusMessage

Build an SQS message from a workflow template for queueing executions.

Kind: Exported function
Returns: Message.CumulusMessage - A Cumulus message object

ParamTypeDescription
paramsObject
params.providerObjectA provider object
params.collectionObjectA collection object
params.parentExecutionArnstringARN for parent execution
params.messageTemplateObjectMessage template for the workflow
params.payloadObjectPayload for the workflow
params.workflowObjectworkflow name & arn object
params.asyncOperationIdstringAsync operation ID
params.customCumulusMetaObjectCustom data for message.cumulus_meta
params.customMetaObjectCustom data for message.meta
params.executionNamePrefixstringPrefix to apply to the name of the enqueued execution

Executions

Utility functions for generating execution information or parsing execution information from a Cumulus message

Example

const Executions = require('@cumulus/message/Executions');

buildExecutionArn(stateMachineArn, executionName) ⇒ string

Build execution ARN from a state machine ARN and execution name

Kind: Exported function
Returns: string - an execution ARN

ParamTypeDescription
stateMachineArnstringstate machine ARN
executionNamestringstate machine's execution name

getExecutionUrlFromArn(executionArn) ⇒ string

Returns execution URL from an execution ARN.

Kind: Exported function
Returns: string - returns AWS console URL for the execution

ParamTypeDescription
executionArnstringan execution ARN

getStateMachineArnFromExecutionArn(executionArn) ⇒ string

Get state machine ARN from an execution ARN

Kind: Exported function
Returns: string - a state machine ARN

ParamTypeDescription
executionArnstringan execution ARN

getMessageExecutionName(message) ⇒ string

Get the execution name from a workflow message.

Kind: Exported function
Returns: string - An execution name
Throws:

  • Error if there is no execution name
ParamTypeDescription
messageMessage.CumulusMessageA workflow message object

getMessageStateMachineArn(message) ⇒ string

Get the state machine ARN from a workflow message.

Kind: Exported function
Returns: string - A state machine ARN
Throws:

  • Error if there is not state machine ARN
ParamTypeDescription
messageMessage.CumulusMessageA workflow message object

getMessageExecutionArn(message) ⇒ null | string

Get the execution ARN from a workflow message.

Kind: Exported function
Returns: null | string - A state machine execution ARN

ParamTypeDescription
messageMessage.CumulusMessageA workflow message object

getMessageExecutionParentArn(message) ⇒ undefined | string

Get the parent execution ARN from a workflow message, if any.

Kind: Exported function
Returns: undefined | string - A state machine execution ARN

ParamTypeDescription
messageMessage.CumulusMessageA workflow message object

getMessageCumulusVersion(message) ⇒ undefined | string

Get the Cumulus version from a workflow message, if any.

Kind: Exported function
Returns: undefined | string - The cumulus version

ParamTypeDescription
messageMessage.CumulusMessageA workflow message object

getMessageExecutionOriginalPayload(message) ⇒ unknown | undefined

Get the workflow original payload, if any.

Kind: Exported function
Returns: unknown | undefined - The workflow original payload

ParamTypeDescription
messageMessageWithPayloadA workflow message object

getMessageExecutionFinalPayload(message) ⇒ unknown | undefined

Get the workflow final payload, if any.

Kind: Exported function
Returns: unknown | undefined - The workflow final payload

ParamTypeDescription
messageMessageWithPayloadA workflow message object

generateExecutionApiRecordFromMessage(message, updatedAt) ⇒ ApiExecution

Generate an execution record for the API from the message.

Kind: Exported function
Returns: ApiExecution - An execution API record

ParamTypeDescription
messageMessageWithPayloadA workflow message object
updatedAtstringOptional updated timestamp to apply to record

generatePdrApiRecordFromMessage(message, updatedAt) ⇒ ApiPdr

Generate a PDR record for the API from the message.

Kind: global method of Executions
Returns: ApiPdr - An PDR API record

ParamTypeDescription
messageMessageWithOptionalPayloadPdrA workflow message object
updatedAtstringOptional updated timestamp to apply to record

Granules

Utility functions for parsing granule information from a Cumulus message

Example

const Granules = require('@cumulus/message/Granules');

getMessageGranules(message) ⇒ Array.<Object> | undefined

Get granules from payload?.granules of a workflow message.

Kind: Exported function
Returns: Array.<Object> | undefined - An array of granule objects, or undefined if message.payload.granules is not set

ParamTypeDescription
messageMessageWithGranulesA workflow message

messageHasGranules(message) ⇒ boolean

Determine if message has a granules object.

Kind: Exported function
Returns: boolean - true if message has a granules object

ParamTypeDescription
messageMessageWithOptionalGranulesA workflow message object

getGranuleStatus(workflowStatus, granule) ⇒ string

Determine the status of a granule.

Kind: Exported function
Returns: string - The granule status

ParamTypeDescription
workflowStatusstringThe workflow status
granuleMessageGranuleA granule record conforming to the 'api' schema

getGranuleQueryFields(message) ⇒ unknown | undefined

Get the query fields of a granule, if any

Kind: Exported function
Returns: unknown | undefined - The granule query fields, if any

ParamTypeDescription
messageMessageWithGranulesA workflow message

generateGranuleApiRecord(message) ⇒ Promise.<ApiGranule>

Generate an API granule record

Kind: Exported function
Returns: Promise.<ApiGranule> - The granule API record

ParamTypeDescription
messageMessageWithGranulesA workflow message

Queue

Utility functions for parsing queue information from a Cumulus message

Example

const Queue = require('@cumulus/message/Queue');

getQueueUrl(message) ⇒ string

Get the queue URL from a workflow message.

Kind: Exported function
Returns: string - A queue URL

ParamTypeDescription
messageMessageWithQueueInfoA workflow message object

getMaximumExecutions(message, queueUrl) ⇒ number

Get the maximum executions for a queue.

Kind: Exported function
Returns: number - Count of the maximum executions for the queue
Throws:

  • Error if no maximum executions can be found
ParamTypeDescription
messageMessage.CumulusMessageA workflow message object
queueUrlstringA queue URL

hasQueueAndExecutionLimit(message) ⇒ boolean

Determine if there is a queue and queue execution limit in the message.

Kind: Exported function
Returns: boolean - True if there is a queue and execution limit.

ParamTypeDescription
messageMessageWithQueueInfoA workflow message object

unwrapDeadLetterCumulusMessage(messageBody) ⇒ Object

Unwrap dead letter Cumulus message, which may be wrapped in a States cloudwatch event, which is wrapped in an SQS message.

Kind: global function
Returns: Object - the cumulus message or nearest available object

ParamTypeDescription
messageBodyObjectreceived SQS message

getFailedStepName(events, failedStepEvent) ⇒ string

Searches the Execution step History for the TaskStateEntered pertaining to the failed task Id. HistoryEvent ids are numbered sequentially, starting at one.

Kind: global function
Returns: string - name of the current stepfunction task or 'UnknownFailedStepName'.

ParamTypeDescription
eventsArray.<HistoryEvent>Step Function events array
failedStepEventHistoryEventStep Function's failed event.

lastFailedEventStep(events) ⇒ HistoryEventList | undefined

Finds all failed execution events and returns the last one in the list.

Kind: global function
Returns: HistoryEventList | undefined - - the last lambda or activity that failed in the event array, or an empty array.

ParamTypeDescription
eventsArray.<HistoryEventList>array of AWS Stepfunction execution HistoryEvents

getFailedExecutionMessage(inputCumulusMessage, getExecutionHistoryFunction) ⇒ Object

Get message to use for publishing failed execution notifications.

Try to get the input to the last failed step in the execution so we can update the status of any granules/PDRs that don't exist in the initial execution input.

Falls back to overall execution input.

Kind: global function
Returns: Object - - CumulusMessage Execution step message or execution input message

ParamTypeDescription
inputCumulusMessageObjectWorkflow execution input message
getExecutionHistoryFunctionfunctionTesting override for mock/etc of StepFunctions.getExecutionHistory

isFileExtensionMatched(granuleFile, extension) ⇒ boolean

Check if the file has the extension

Kind: global function
Returns: boolean - whether the file has the extension

ParamTypeDescription
granuleFileApiFileGranule file
extensionstringFile extension to check

parseException(exception) ⇒ string

Ensures that the exception is returned as an object

Kind: global function
Returns: string - an stringified exception

ParamTypeDescription
exceptionObject | undefinedthe exception

About Cumulus

Cumulus is a cloud-based data ingest, archive, distribution and management prototype for NASA's future Earth science data streams.

Cumulus Documentation

Contributing

To make a contribution, please see our contributing guidelines.


Generated automatically using npm run build-docs

18.2.1

1 day ago

16.1.4

11 days ago

18.2.0

3 months ago

16.1.3

4 months ago

18.2.0-alpha.0

5 months ago

16.1.1

9 months ago

16.1.0

9 months ago

16.1.2

6 months ago

18.1.0

7 months ago

17.0.0

9 months ago

18.0.0

8 months ago

16.0.3-alpha.0

10 months ago

16.0.0

10 months ago

15.0.4

11 months ago

16.0.1-alpha.0

11 months ago

16.0.2-alpha.0

11 months ago

15.0.2

1 year ago

15.0.3

1 year ago

15.0.1

1 year ago

14.1.0

1 year ago

15.0.0

1 year ago

13.3.3-alpha.0

2 years ago

13.4.0

2 years ago

14.0.0

1 year ago

13.3.3-alpha.1

2 years ago

11.1.8

2 years ago

13.3.2

2 years ago

12.0.3

2 years ago

13.3.1

2 years ago

11.1.6

2 years ago

11.1.7

2 years ago

13.3.0

2 years ago

13.1.0

2 years ago

12.0.1

2 years ago

12.0.2

2 years ago

10.1.3

2 years ago

13.2.0

2 years ago

13.2.1

2 years ago

13.0.0

2 years ago

13.0.1

2 years ago

11.1.5

2 years ago

11.1.3

2 years ago

11.1.4

2 years ago

11.1.2

2 years ago

12.0.0

2 years ago

10.0.2

2 years ago

11.1.1

2 years ago

11.1.0

2 years ago

11.0.0

2 years ago

9.9.4

2 years ago

10.1.2

2 years ago

9.4.2

2 years ago

10.1.1-alpha.0

2 years ago

10.1.1

2 years ago

9.4.1

2 years ago

10.0.0

2 years ago

10.0.1

2 years ago

9.9.1

2 years ago

9.7.1

2 years ago

10.1.0

2 years ago

9.9.2

2 years ago

9.9.3

2 years ago

9.2.4

2 years ago

9.2.3

2 years ago

10.0.0-beta.0

2 years ago

9.9.0

3 years ago

9.8.0

3 years ago

9.7.0

3 years ago

9.6.0

3 years ago

9.5.0

3 years ago

9.4.0

3 years ago

9.2.2

3 years ago

8.1.2

3 years ago

9.2.1

3 years ago

9.3.0

3 years ago

9.2.0

3 years ago

8.1.1

3 years ago

9.1.0

3 years ago

8.1.0

3 years ago

9.0.1

3 years ago

9.0.0

3 years ago

8.0.0

3 years ago

6.0.1

3 years ago

7.2.0

3 years ago

7.1.0

3 years ago

7.0.0

3 years ago

6.0.0

3 years ago

5.0.1

3 years ago

5.0.0

3 years ago

4.0.0

3 years ago

3.0.1

4 years ago

2.0.8

4 years ago

3.0.0

4 years ago

2.0.7

4 years ago

2.0.6

4 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.24.0

4 years ago

1.23.2

4 years ago

1.23.1

4 years ago

1.23.0

4 years ago

1.22.1

4 years ago

1.22.0

4 years ago

1.21.0

4 years ago

1.21.0-alpha3

4 years ago

1.21.0-alpha2

4 years ago

1.21.0-alpha1

4 years ago