@cumulus/message

中文文档
22.5.0发布于 2026/11/06Apache-2.0近 30 天下载 3123

Utilities for building and parsing Cumulus messages

原始使用文档
文档目录20 节
  1. Usage
  2. API
  3. Modules
  4. Functions
  5. Build
  6. Executions
  7. Granules
  8. Queue
  9. isCumulusMessageLike()
  10. isDLQRecordLike()
  11. unwrapDeadLetterCumulusMessage()
  12. extractSQSMetadata(message) ⇒
  13. hoistCumulusMessageDetails()
  14. getFailedStepName(events, failedStepEvent) ⇒ string
  15. lastFailedEventStep(events) ⇒ Array.<HistoryEvent> | undefi…
  16. getFailedExecutionMessage(inputCumulusMessage, getExecution…
  17. isFileExtensionMatched(granuleFile, extension) ⇒ boolean
  18. parseException(exception) ⇒ string
  19. About Cumulus
  20. Contributing

@cumulus/message

Utilities for building and parsing Cumulus workflow messages.

Usage

  npm install @cumulus/message

API

Modules

Build

Utility functions for building Cumulus messages

Executions

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

Granules

Utility functions for parsing granule information from a Cumulus message

Queue

Utility functions for parsing queue information from a Cumulus message

Functions

getMessageAsyncOperationId(message) ⇒ undefined | string ⏏

Get the async operation ID from a workflow message, if any.

constructCollectionId(name, version) ⇒ string ⏏

Returns the collection ID.

deconstructCollectionId(collectionId) ⇒ ⏏

Returns the name and version of a collection based on the collectionId used in elasticsearch indexing

getCollectionNameAndVersionFromMessage(message) ⇒ CollectionInfo | undefined ⏏

Get collection name and version from execution message.

getCollectionIdFromMessage(message) ⇒ string | undefined ⏏

Get collection ID from execution message.

isCumulusMessageLike()

Bare check for CumulusMessage Shape

isDLQRecordLike()

Bare check for SQS message Shape

unwrapDeadLetterCumulusMessage()

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

extractSQSMetadata(message) ⇒

peel out metadata from an SQS(/DLQ)record

hoistCumulusMessageDetails()

Reformat object with key attributes at top level.

getMessagePdr(message) ⇒ undefined | Object ⏏

Get the PDR object from a workflow message, if any.

messageHasPdr(message) ⇒ boolean ⏏

Determine if message has a PDR.

getMessagePdrPANSent(message) ⇒ boolean ⏏

Get the PAN sent status from a workflow message, if any.

getMessagePdrPANMessage(message) ⇒ string ⏏

Get the PAN message status from a workflow message, if any.

getMessagePdrName(message) ⇒ string ⏏

Get the PDR name from a workflow message, if any.

getMessagePdrRunningExecutions(message) ⇒ number ⏏

Get the number of running executions for a PDR, if any.

getMessagePdrCompletedExecutions(message) ⇒ number ⏏

Get the number of completed executions for a PDR, if any.

getMessagePdrFailedExecutions(message) ⇒ number ⏏

Get the number of failed executions for a PDR, if any.

getMessagePdrStats(message) ⇒ PdrStats ⏏

Get the PDR stats from a workflow message, if any.

getPdrPercentCompletion(stats) ⇒ number ⏏

Get the percent completion of PDR executions

generatePdrApiRecordFromMessage(message, [updatedAt]) ⇒ ApiPdr ⏏

Generate a PDR record for the API from the message.

getMessageProvider(message) ⇒ MessageProvider | string ⏏

Get the provider from a workflow message, if any.

getMessageProviderId(message) ⇒ undefined | string ⏏

Get the provider ID from a workflow message, if any.

pullStepFunctionEvent(event) ⇒ Promise.<object> ⏏

Given a Step Function event, replace specified key in event with contents of S3 remote message

parseStepMessage(stepMessage, stepName) ⇒ Promise.<object> ⏏

Parse step message with CMA keys and replace specified key in event with contents of S3 remote 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.

lastFailedEventStep(events) ⇒ Array.<HistoryEvent> | undefined

Finds all failed execution events and returns the last one in the list. Looks for a failed lambda execution (LambdaFunctionFailed), failed ECS Task (TaskFailed) or an external worker (ActivityFailed)

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.

isFileExtensionMatched(granuleFile, extension) ⇒ boolean

Check if the file has the extension

parseException(exception) ⇒ string

Ensures that the exception is returned as an object

getMetaStatus(message) ⇒ Message.WorkflowStatus | undefined ⏏

Get the status of a workflow message, if any.

getMessageWorkflowTasks(message) ⇒ Object | undefined ⏏

Get the workflow tasks in a workflow message, if any.

getMessageWorkflowStartTime(message) ⇒ number | undefined ⏏

Get the workflow start time, if any.

getMessageWorkflowStopTime(message) ⇒ number | undefined ⏏

Get the workflow stop time, if any.

getMessageWorkflowName(message) ⇒ string | undefined ⏏

Get the workflow name, if any.

getWorkflowDuration(startTime, [stopTime]) ⇒ number ⏏

Get the workflow duration.

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.asyncOperationId]stringAsync operation ID
[params.customCumulusMeta]ObjectCustom data for message.cumulus_meta
[params.customMeta]ObjectCustom data for message.meta
[params.executionNamePrefix]stringPrefix 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
[updatedAt]stringOptional 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
[updatedAt]stringOptional 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
messageMessage.CumulusMessageA 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
messageMessage.CumulusMessageA 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

isCumulusMessageLike()

Bare check for CumulusMessage Shape

Kind: global function

isDLQRecordLike()

Bare check for SQS message Shape

Kind: global function

unwrapDeadLetterCumulusMessage()

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

Kind: global function

extractSQSMetadata(message) ⇒

peel out metadata from an SQS(/DLQ)record

Kind: global function Returns: the given message without its body

ParamDescription
messageDLQ or SQS message

hoistCumulusMessageDetails()

Reformat object with key attributes at top level.

Kind: global function

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
failedStepEventfailedStepEventStep Function's failed event.
failedStepEvent.idnumber (long), Step Functions failed event id.

lastFailedEventStep(events) ⇒ Array.<HistoryEvent> | undefined

Finds all failed execution events and returns the last one in the list. Looks for a failed lambda execution (LambdaFunctionFailed), failed ECS Task (TaskFailed) or an external worker (ActivityFailed)

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

ParamTypeDescription
eventsArray.<HistoryEvent>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

版本与发布记录

@cumulus/message 共发布 183 个版本,首次发布于 2020/04/02;过去 12 个月发布了 35 个版本。

版本发布日期距今
22.5.0latest2026/11/065 天前
22.4.42026/11/065 天前
22.4.32026/10/031 个月前
22.4.22026/09/251 个月前
22.4.12026/09/151 个月前
22.4.02026/09/022 个月前

其他发布通道:release-v2.0.8 → 2.0.8,release-v6.0.1 → 6.0.1,release-v8.1.1 → 8.1.1,release-v9.2.1 → 9.2.1,release-v8.1.2 → 8.1.2,release-v9.2.2 → 9.2.2。

关于 @cumulus/message 的常见问题

@cumulus/message 是什么?

Utilities for building and parsing Cumulus messages

如何安装 @cumulus/message?

在项目目录运行 npm install @cumulus/message,或使用 pnpm add / yarn add / bun add。

@cumulus/message 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/cumulus__message 是否存在。

@cumulus/message 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^22.23.4。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cumulus/message 可以商用吗?

@cumulus/message 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@cumulus/message 的下载量有多少?

根据 npm 官方下载统计,@cumulus/message 在 2026/10/11 – 2026/11/09 这 30 天内被下载 3,123 次,日均约 104 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cumulus/message 还在维护吗?

最新版本 22.5.0 发布于 2026/11/06(5 天前);至今共发布 183 个版本,其中过去 12 个月发布了 35 个;首次发布于 2020/04/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。