Namespace: common
Common library for code that's used across the Client, Worker, and/or Workflow
Enumerationsβ
Classesβ
- ActivityCancellationDetails
- ActivityFailure
- ApplicationFailure
- BinaryPayloadConverter
- CancelledFailure
- ChildWorkflowFailure
- CompleteAsyncError
- CompositePayloadConverter
- DefaultFailureConverter
- DefaultPayloadConverter
- IllegalStateError
- JsonPayloadConverter
- NamespaceNotFoundError
- NexusOperationFailure
- PayloadConverterError
- RawValue
- ServerFailure
- TemporalFailure
- TerminatedFailure
- TimeoutFailure
- TypedSearchAttributes
- UndefinedPayloadConverter
- ValueError
- WorkflowExecutionAlreadyStartedError
- WorkflowNotFoundError
Interfacesβ
- ActivityCancellationDetailsOptions
- ActivityFunction
- ActivityOptions
- ActivitySerializationContext
- ApplicationFailureOptions
- BaseWorkflowHandle
- BaseWorkflowOptions
- DataConverter
- DefaultEncodedFailureAttributes
- DefaultFailureConverterOptions
- FailureConverter
- HistoryAndWorkflowId
- LoadedDataConverter
- LocalActivityOptions
- Logger
- Metric
- MetricCounter
- MetricGauge
- MetricHistogram
- MetricMeter
- MetricUpDownCounter
- PayloadCodec
- PayloadConverter
- PayloadConverterWithEncoding
- PinnedVersioningOverride
- Priority
- QueryDefinition
- RetryPolicy
- SignalDefinition
- UpdateDefinition
- WorkerDeploymentVersion
- WorkflowDefinitionOptions
- WorkflowDurationOptions
- WorkflowSerializationContext
Type Aliasesβ
ActivityCancellationTypeβ
Ζ¬ ActivityCancellationType: typeof ActivityCancellationType[keyof typeof ActivityCancellationType]
ActivityInterfaceβ
Ζ¬ ActivityInterface: Record<string, ActivityFunction>
Mapping of Activity name to function
Deprecated
not required anymore, for untyped activities use UntypedActivities
ApplicationFailureCategoryβ
Ζ¬ ApplicationFailureCategory: typeof ApplicationFailureCategory[keyof typeof ApplicationFailureCategory]
AutoUpgradeVersioningOverrideβ
Ζ¬ AutoUpgradeVersioningOverride: "AUTO_UPGRADE"
The workflow will auto-upgrade to the current deployment version on the next workflow task.
CommonWorkflowOptionsβ
Ζ¬ CommonWorkflowOptions: BaseWorkflowOptions & WorkflowDurationOptions
Durationβ
Ζ¬ Duration: StringValue | number
A duration, expressed either as a number of milliseconds, or as a ms-formatted string.
EncodingTypeβ
Ζ¬ EncodingType: typeof encodingTypes[keyof typeof encodingTypes]
HandlerUnfinishedPolicyβ
Ζ¬ HandlerUnfinishedPolicy: typeof HandlerUnfinishedPolicy[keyof typeof HandlerUnfinishedPolicy]
Headersβ
Ζ¬ Headers: Record<string, Payload>
Headers are just a mapping of header name to Payload
InitialVersioningBehaviorβ
Ζ¬ InitialVersioningBehavior: typeof InitialVersioningBehavior[keyof typeof InitialVersioningBehavior]
LogLevelβ
Ζ¬ LogLevel: "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR"
LogMetadataβ
Ζ¬ LogMetadata: Record<string | symbol, any>
MetricKindβ
Ζ¬ MetricKind: "counter" | "histogram" | "gauge" | "up-down-counter"
The kind of a metric.
The Metric API is an experimental feature and may be subject to change.
MetricTagsβ
Ζ¬ MetricTags: Record<string, string | number | boolean>
Tags to be attached to some metrics.
The Metric API is an experimental feature and may be subject to change.
MetricTagsOrFuncβ
Ζ¬ MetricTagsOrFunc: MetricTags | () => MetricTags
Nextβ
Ζ¬ Next<IF, FN>: Required<IF>[FN] extends AnyFunc ? OmitLastParam<Required<IF>[FN]> : never
Type of the next function for a given interceptor function
Called from an interceptor to continue the interception chain
Type parametersβ
| Name | Type |
|---|---|
IF | IF |
FN | extends keyof IF |
NumericMetricValueTypeβ
Ζ¬ NumericMetricValueType: "int" | "float"
Type of numerical values recorded by a metric.
Note that this represents the configuration of the metric; however, since JavaScript doesn't have different runtime representation for integers and floats, the actual value type is always a JS 'number'.
The Metric API is an experimental feature and may be subject to change.
Payloadβ
Ζ¬ Payload: IPayload
ProtoFailureβ
Ζ¬ ProtoFailure: IFailure
RetryStateβ
Ζ¬ RetryState: typeof RetryState[keyof typeof RetryState]
SearchAttributePairβ
Ζ¬ SearchAttributePair: { [T in SearchAttributeType]: Object }[SearchAttributeType]
SearchAttributeTypeβ
Ζ¬ SearchAttributeType: typeof SearchAttributeType[keyof typeof SearchAttributeType]
SearchAttributeUpdatePairβ
Ζ¬ SearchAttributeUpdatePair: { [T in SearchAttributeType]: Object }[SearchAttributeType]
SearchAttributeValueβ
Ζ¬ SearchAttributeValue: string[] | number[] | boolean[] | Date[]
@deprecated: Use TypedSearchAttributes instead
SearchAttributesβ
Ζ¬ SearchAttributes: Record<string, SearchAttributeValueOrReadonly>
@deprecated: Use TypedSearchAttributes instead
SerializationContextβ
Ζ¬ SerializationContext: WorkflowSerializationContext | ActivitySerializationContext
Context passed to payload and failure converters.
The context describes the workflow or activity whose payload is being converted. For example:
client.workflow.start()uses the target workflow's context.executeChild()uses the child workflow's context, not the parent's.scheduleActivity()uses the scheduled activity's context.
Serialization context is an experimental feature and may change.
StringValueβ
Ζ¬ StringValue: `${number}` | `${number}${UnitAnyCase}` | `${number} ${UnitAnyCase}`
SuggestContinueAsNewReasonβ
Ζ¬ SuggestContinueAsNewReason: typeof SuggestContinueAsNewReason[keyof typeof SuggestContinueAsNewReason]
TimeoutTypeβ
Ζ¬ TimeoutType: typeof TimeoutType[keyof typeof TimeoutType]
Timestampβ
Ζ¬ Timestamp: ITimestamp
UntypedActivitiesβ
Ζ¬ UntypedActivities: Record<string, ActivityFunction>
Mapping of Activity name to function
VersioningBehaviorβ
Ζ¬ VersioningBehavior: typeof VersioningBehavior[keyof typeof VersioningBehavior]
VersioningIntentβ
Ζ¬ VersioningIntent: "COMPATIBLE" | "DEFAULT"
Indicates whether the user intends certain commands to be run on a compatible worker Build Id version or not.
COMPATIBLE indicates that the command should run on a worker with compatible version if possible. It may not be
possible if the target task queue does not also have knowledge of the current worker's Build Id.
DEFAULT indicates that the command should run on the target task queue's current overall-default Build Id.
Where this type is accepted optionally, an unset value indicates that the SDK should choose the most sensible default
behavior for the type of command, accounting for whether the command will be run on the same task queue as the
current worker. The default behavior for starting Workflows is DEFAULT. The default behavior for Workflows starting
Activities, starting Child Workflows, or Continuing As New is COMPATIBLE.
Deprecated
Worker Versioning is now deprecated. Please use the Worker Deployment API instead: https://docs.temporal.io/worker-deployments
VersioningOverrideβ
Ζ¬ VersioningOverride: PinnedVersioningOverride | "AUTO_UPGRADE"
Represents versioning overrides. For example, when starting workflows.
WithWorkflowArgsβ
Ζ¬ WithWorkflowArgs<W, T>: T & Parameters<W> extends [any, ...any[]] ? { args: Parameters<W> | Readonly<Parameters<W>> } : { args?: Parameters<W> | Readonly<Parameters<W>> }
Type parametersβ
| Name | Type |
|---|---|
W | extends Workflow |
T | T |
Workflowβ
Ζ¬ Workflow: (...args: any[]) => WorkflowReturnType
Broad Workflow function definition, specific Workflows will typically use a narrower type definition, e.g:
export async function myWorkflow(arg1: number, arg2: string): Promise<string>;
Type declarationβ
βΈ (...args): WorkflowReturnType
Parametersβ
| Name | Type |
|---|---|
...args | any[] |
Returnsβ
WorkflowDefinitionOptionsOrGetterβ
Ζ¬ WorkflowDefinitionOptionsOrGetter: WorkflowDefinitionOptions | () => WorkflowDefinitionOptions
WorkflowExecutionβ
Ζ¬ WorkflowExecution: IWorkflowExecution
WorkflowIdConflictPolicyβ
Ζ¬ WorkflowIdConflictPolicy: typeof WorkflowIdConflictPolicy[keyof typeof WorkflowIdConflictPolicy]
WorkflowIdReusePolicyβ
Ζ¬ WorkflowIdReusePolicy: typeof WorkflowIdReusePolicy[keyof typeof WorkflowIdReusePolicy]
WorkflowQueryAnnotatedTypeβ
Ζ¬ WorkflowQueryAnnotatedType: Object
Type declarationβ
| Name | Type |
|---|---|
description? | string |
handler | WorkflowQueryType |
WorkflowQueryTypeβ
Ζ¬ WorkflowQueryType: (...args: any[]) => any
Type declarationβ
βΈ (...args): any
Parametersβ
| Name | Type |
|---|---|
...args | any[] |
Returnsβ
any
WorkflowResultTypeβ
Ζ¬ WorkflowResultType<W>: ReturnType<W> extends Promise<infer R> ? R : never
Get the "unwrapped" return type (without Promise) of the execute handler from Workflow type W
Type parametersβ
| Name | Type |
|---|---|
W | extends Workflow |
WorkflowReturnTypeβ
Ζ¬ WorkflowReturnType: Promise<any>
Type that can be returned from a Workflow execute function
WorkflowSignalAnnotatedTypeβ
Ζ¬ WorkflowSignalAnnotatedType: Object
Type declarationβ
| Name | Type |
|---|---|
description? | string |
handler | WorkflowSignalType |
unfinishedPolicy | HandlerUnfinishedPolicy |
WorkflowSignalTypeβ
Ζ¬ WorkflowSignalType: (...args: any[]) => Promise<void> | void
Type declarationβ
βΈ (...args): Promise<void> | void
Parametersβ
| Name | Type |
|---|---|
...args | any[] |
Returnsβ
Promise<void> | void
WorkflowUpdateAnnotatedTypeβ
Ζ¬ WorkflowUpdateAnnotatedType: Object
Type declarationβ
| Name | Type |
|---|---|
description? | string |
handler | WorkflowUpdateType |
unfinishedPolicy | HandlerUnfinishedPolicy |
validator? | WorkflowUpdateValidatorType |
WorkflowUpdateTypeβ
Ζ¬ WorkflowUpdateType: (...args: any[]) => Promise<any> | any
Type declarationβ
βΈ (...args): Promise<any> | any
Parametersβ
| Name | Type |
|---|---|
...args | any[] |
Returnsβ
Promise<any> | any
WorkflowUpdateValidatorTypeβ
Ζ¬ WorkflowUpdateValidatorType: (...args: any[]) => void
Type declarationβ
βΈ (...args): void
Parametersβ
| Name | Type |
|---|---|
...args | any[] |
Returnsβ
void
Variablesβ
ActivityCancellationTypeβ
β’ Const ActivityCancellationType: Object
Determines:
- whether cancellation requests should be propagated from the current Workflow to the Activity; and
- when should the Activity cancellation be reported to Workflow (i.e. at which moment should the
Activity call's promise fail with an
ActivityFailure, withcauseset to aCancelledFailure).
Note that this setting only applies to cancellation originating from cancellation being
externally requested on the Workflow itself, or from internal cancellation of the
CancellationScope in which the Activity call was made. Termination of a Workflow Execution
always results in cancellation of its outstanding Activity executions, regardless of those
Activities' ActivityCancellationType settings.
Default
ActivityCancellationType.WAIT_CANCELLATION_COMPLETED
Type declarationβ
| Name | Type | Description |
|---|---|---|
ABANDON | "ABANDON" | Do not propagate cancellation requests to the Activity, and immediately report cancellation to the caller. |
TRY_CANCEL | "TRY_CANCEL" | Propagate cancellation request from the Workflow to the Activity, yet immediately report cancellation to the caller, i.e. without waiting for the server to confirm the cancellation request. Note that this cancellation type provides no guarantee, from the Workflow-side, that the cancellation request will actually be delivered to the Activity; e.g. the calling Workflow may exit before the delivery is completed, or the Activity may complete (either successfully or uncessfully) before the cancellation is delivered, resulting in a situation where the workflow thinks the activity was cancelled, but the activity actually completed successfully. To ensure that the Workflow is properly informed of the Activity's final state (i.e. either completion or cancellation), use WAIT_CANCELLATION_COMPLETED. |
WAIT_CANCELLATION_COMPLETED | "WAIT_CANCELLATION_COMPLETED" | Propagate cancellation request from the Workflow to the Activity, and wait for the activity to complete its execution (either successfully, uncessfully, or as cancelled). Note that the Activity must heartbeat to receive a cancellation notification. This can block the Workflow's cancellation for a long time if the Activity doesn't heartbeat or chooses to ignore the cancellation request. |
ApplicationFailureCategoryβ
β’ Const ApplicationFailureCategory: Object
A category to describe the severity and change the observability behavior of an application failure.
Currently, observability behavior changes are limited to:
- activities that fail due to a BENIGN application failure emit DEBUG level logs and do not record metrics
Category is a new feature and may be subject to change.
Type declarationβ
| Name | Type |
|---|---|
BENIGN | "BENIGN" |
FAILURE_SOURCEβ
β’ Const FAILURE_SOURCE: "TypeScriptSDK"
HandlerUnfinishedPolicyβ
β’ Const HandlerUnfinishedPolicy: Object
Policy defining actions taken when a workflow exits while update or signal handlers are running. The workflow exit may be due to successful return, failure, cancellation, or continue-as-new.
Type declarationβ
| Name | Type | Description |
|---|---|---|
ABANDON | "ABANDON" | Abandon the handler execution. In the case of an update handler this means that the client will receive an error rather than the update result. |
WARN_AND_ABANDON | "WARN_AND_ABANDON" | Issue a warning in addition to abandoning the handler execution. The warning will not be issued if the workflow fails. |
InitialVersioningBehaviorβ
β’ Const InitialVersioningBehavior: Object
Defines the versioning behavior to be used by the first task of a new workflow run in a continue-as-new chain.
AUTO_UPGRADE - Start the new run with AutoUpgrade behavior. Use the Target Version of the workflow's task queue at start-time, as AutoUpgrade workflows do. After the first workflow task completes, use whatever Versioning Behavior the workflow is annotated with in the workflow code.
Note that if the previous workflow had a Pinned override, that override will be inherited by the new workflow run regardless of the ContinueAsNewVersioningBehavior specified in the continue-as-new command. If a Pinned override is inherited by the new run, and the new run starts with AutoUpgrade behavior, the base version of the new run will be the Target Version as described above, but the effective version will be whatever is specified by the Versioning Override until the override is removed.
USE_RAMPING_VERSION - Use the Ramping Version of the workflow's task queue at start time, regardless of the workflow's Target Version (according to f(workflow_id, ramp_percentage)). After the first workflow task completes, the workflow will use whatever Versioning Behavior it is annotated with. If there is no Ramping Version by the time that the first workflow task is dispatched, it will be sent to the Current Version.
It is highly discouraged to use this if the workflow is annotated with AutoUpgrade behavior, because this setting ONLY applies to the first task of the workflow. If, after the first task, the workflow is AutoUpgrade, it will behave like a normal AutoUpgrade workflow and go to the Target Version, which may be the Current Version instead of the Ramping Version.
Note that if the workflow being continued has a Pinned override, that override will be inherited by the new workflow run regardless of the ContinueAsNewVersioningBehavior specified in the continue-as-new command. Versioning Override always takes precedence until it's removed manually via UpdateWorkflowExecutionOptions.
Versioning semantics with continue-as-new are experimental and may change in the future.
Type declarationβ
| Name | Type |
|---|---|
AUTO_UPGRADE | "AUTO_UPGRADE" |
USE_RAMPING_VERSION | "USE_RAMPING_VERSION" |
METADATA_ENCODING_KEYβ
β’ Const METADATA_ENCODING_KEY: "encoding"
METADATA_MESSAGE_TYPE_KEYβ
β’ Const METADATA_MESSAGE_TYPE_KEY: "messageType"
RetryStateβ
β’ Const RetryState: Object
Type declarationβ
| Name | Type | Description |
|---|---|---|
CANCEL_REQUESTED | "CANCEL_REQUESTED" | - |
INTERNAL_SERVER_ERROR | "INTERNAL_SERVER_ERROR" | - |
IN_PROGRESS | "IN_PROGRESS" | - |
MAXIMUM_ATTEMPTS_REACHED | "MAXIMUM_ATTEMPTS_REACHED" | - |
NON_RETRYABLE_FAILURE | "NON_RETRYABLE_FAILURE" | - |
RETRY_POLICY_NOT_SET | "RETRY_POLICY_NOT_SET" | - |
RETRY_STATE_CANCEL_REQUESTED | "CANCEL_REQUESTED" | Deprecated Use CANCEL_REQUESTED instead. |
RETRY_STATE_INTERNAL_SERVER_ERROR | "INTERNAL_SERVER_ERROR" | Deprecated Use INTERNAL_SERVER_ERROR instead. |
RETRY_STATE_IN_PROGRESS | "IN_PROGRESS" | Deprecated Use IN_PROGRESS instead. |
RETRY_STATE_MAXIMUM_ATTEMPTS_REACHED | "MAXIMUM_ATTEMPTS_REACHED" | Deprecated Use MAXIMUM_ATTEMPTS_REACHED instead. |
RETRY_STATE_NON_RETRYABLE_FAILURE | "NON_RETRYABLE_FAILURE" | Deprecated Use NON_RETRYABLE_FAILURE instead. |
RETRY_STATE_RETRY_POLICY_NOT_SET | "RETRY_POLICY_NOT_SET" | Deprecated Use RETRY_POLICY_NOT_SET instead. |
RETRY_STATE_TIMEOUT | "TIMEOUT" | Deprecated Use TIMEOUT instead. |
RETRY_STATE_UNSPECIFIED | undefined | Deprecated Use undefined instead. |
TIMEOUT | "TIMEOUT" | - |
SearchAttributeTypeβ
β’ Const SearchAttributeType: Object
Type declarationβ
| Name | Type |
|---|---|
BOOL | "BOOL" |
DATETIME | "DATETIME" |
DOUBLE | "DOUBLE" |
INT | "INT" |
KEYWORD | "KEYWORD" |
KEYWORD_LIST | "KEYWORD_LIST" |
TEXT | "TEXT" |
SuggestContinueAsNewReasonβ
β’ Const SuggestContinueAsNewReason: Object
Reason(s) why continue as new is suggested. Can potentially be multiple reasons.
May be removed or changed in the future.
Type declarationβ
| Name | Type |
|---|---|
HISTORY_SIZE_TOO_LARGE | "HISTORY_SIZE_TOO_LARGE" |
TOO_MANY_HISTORY_EVENTS | "TOO_MANY_HISTORY_EVENTS" |
TOO_MANY_UPDATES | "TOO_MANY_UPDATES" |
TimeoutTypeβ
β’ Const TimeoutType: Object
Type declarationβ
| Name | Type | Description |
|---|---|---|
HEARTBEAT | "HEARTBEAT" | - |
SCHEDULE_TO_CLOSE | "SCHEDULE_TO_CLOSE" | - |
SCHEDULE_TO_START | "SCHEDULE_TO_START" | - |
START_TO_CLOSE | "START_TO_CLOSE" | - |
TIMEOUT_TYPE_HEARTBEAT | "HEARTBEAT" | Deprecated Use HEARTBEAT instead. |
TIMEOUT_TYPE_SCHEDULE_TO_CLOSE | "SCHEDULE_TO_CLOSE" | Deprecated Use SCHEDULE_TO_CLOSE instead. |
TIMEOUT_TYPE_SCHEDULE_TO_START | "SCHEDULE_TO_START" | Deprecated Use SCHEDULE_TO_START instead. |
TIMEOUT_TYPE_START_TO_CLOSE | "START_TO_CLOSE" | Deprecated Use START_TO_CLOSE instead. |
TIMEOUT_TYPE_UNSPECIFIED | undefined | Deprecated Use undefined instead. |
VersioningBehaviorβ
β’ Const VersioningBehavior: Object
Specifies when a workflow might move from a worker of one Build Id to another.
- 'PINNED' - The workflow will be pinned to the current Build ID unless manually moved.
- 'AUTO_UPGRADE' - The workflow will automatically move to the latest version (default Build ID of the task queue) when the next task is dispatched.
Type declarationβ
| Name | Type |
|---|---|
AUTO_UPGRADE | "AUTO_UPGRADE" |
PINNED | "PINNED" |
WorkflowIdConflictPolicyβ
β’ Const WorkflowIdConflictPolicy: Object
Defines what happens when trying to start a Workflow with the same ID as a Running Workflow.
See WorkflowOptions.workflowIdReusePolicy for what happens when trying to start a Workflow with the same ID as a Closed Workflow.
Note: It is never possible to have two actively running Workflows with the same ID.
Type declarationβ
| Name | Type | Description |
|---|---|---|
FAIL | "FAIL" | Do not start a new Workflow. Instead raise a WorkflowExecutionAlreadyStartedError. |
TERMINATE_EXISTING | "TERMINATE_EXISTING" | Start a new Workflow, terminating the current workflow if one is already running. |
USE_EXISTING | "USE_EXISTING" | Do not start a new Workflow. Instead return a Workflow Handle for the already Running Workflow. |
WorkflowIdReusePolicyβ
β’ Const WorkflowIdReusePolicy: Object
Defines what happens when trying to start a Workflow with the same ID as a Closed Workflow.
See WorkflowOptions.workflowIdConflictPolicy for what happens when trying to start a Workflow with the same ID as a Running Workflow.
Concept: Workflow Id Reuse Policy
Note: It is not possible to have two actively running Workflows with the same ID.
Type declarationβ
| Name | Type | Description |
|---|---|---|
ALLOW_DUPLICATE | "ALLOW_DUPLICATE" | The Workflow can be started if the previous Workflow is in a Closed state. Default ts |
ALLOW_DUPLICATE_FAILED_ONLY | "ALLOW_DUPLICATE_FAILED_ONLY" | The Workflow can be started if the previous Workflow is in a Closed state that is not Completed. |
REJECT_DUPLICATE | "REJECT_DUPLICATE" | The Workflow cannot be started. |
TERMINATE_IF_RUNNING | "TERMINATE_IF_RUNNING" | Terminate the current Workflow if one is already running; otherwise allow reusing the Workflow ID. Deprecated Use WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE instead, and set WorkflowOptions.workflowIdConflictPolicy to WorkflowIdConflictPolicy.WORKFLOW_ID_CONFLICT_POLICY_TERMINATE_EXISTING. When using this option, WorkflowOptions.workflowIdConflictPolicy must be left unspecified. |
WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE | "ALLOW_DUPLICATE" | Deprecated Use ALLOW_DUPLICATE instead. |
WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY | "ALLOW_DUPLICATE_FAILED_ONLY" | Deprecated Use ALLOW_DUPLICATE_FAILED_ONLY instead. |
WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE | "REJECT_DUPLICATE" | Deprecated Use REJECT_DUPLICATE instead. |
WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING | "TERMINATE_IF_RUNNING" | Deprecated Use TERMINATE_IF_RUNNING instead. |
WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED | undefined | No need to use this. If a WorkflowIdReusePolicy is set to this, or is not set at all, the default value will be used. Deprecated Either leave property undefined, or use ALLOW_DUPLICATE instead. |
defaultDataConverterβ
β’ Const defaultDataConverter: LoadedDataConverter
A "loaded" data converter that uses the default set of failure and payload converters.
defaultFailureConverterβ
β’ Const defaultFailureConverter: FailureConverter
The default FailureConverter used by the SDK.
Error messages and stack traces are serialized as plain text.
defaultPayloadConverterβ
β’ Const defaultPayloadConverter: DefaultPayloadConverter
The default PayloadConverter used by the SDK. Supports Uint8Array and JSON serializables (so if
JSON.stringify(yourArgOrRetval)
works, the default payload converter will work).
To also support Protobufs, create a custom payload converter with DefaultPayloadConverter:
const myConverter = new DefaultPayloadConverter({ protobufRoot })
encodingKeysβ
β’ Const encodingKeys: Object
Type declarationβ
| Name | Type |
|---|---|
METADATA_ENCODING_JSON | Uint8Array |
METADATA_ENCODING_NULL | Uint8Array |
METADATA_ENCODING_PROTOBUF | Uint8Array |
METADATA_ENCODING_PROTOBUF_JSON | Uint8Array |
METADATA_ENCODING_RAW | Uint8Array |
encodingTypesβ
β’ Const encodingTypes: Object
Type declarationβ
| Name | Type |
|---|---|
METADATA_ENCODING_JSON | "json/plain" |
METADATA_ENCODING_NULL | "binary/null" |
METADATA_ENCODING_PROTOBUF | "binary/protobuf" |
METADATA_ENCODING_PROTOBUF_JSON | "json/protobuf" |
METADATA_ENCODING_RAW | "binary/plain" |
noopMetricMeterβ
β’ Const noopMetricMeter: NoopMetricMeter
rawPayloadTypeBrandβ
β’ Const rawPayloadTypeBrand: unique symbol
Functionsβ
arrayFromPayloadsβ
βΈ arrayFromPayloads(converter, payloads?, context?): unknown[]
Run PayloadConverter.fromPayload on each value in the array.
Parametersβ
| Name | Type |
|---|---|
converter | PayloadConverter |
payloads? | null | IPayload[] |
context? | SerializationContext |
Returnsβ
unknown[]
compilePriorityβ
βΈ compilePriority(priority): IPriority
Turn a TS Priority into a proto compatible Priority
Parametersβ
| Name | Type |
|---|---|
priority | Priority |
Returnsβ
compileRetryPolicyβ
βΈ compileRetryPolicy(retryPolicy): IRetryPolicy
Turn a TS RetryPolicy into a proto compatible RetryPolicy
Parametersβ
| Name | Type |
|---|---|
retryPolicy | RetryPolicy |
Returnsβ
convertOptionalToPayloadβ
βΈ convertOptionalToPayload(payloadConverter, value, context?): Payload | null | undefined
Run PayloadConverter.toPayload on an optional value, and then encode it.
Parametersβ
| Name | Type |
|---|---|
payloadConverter | PayloadConverter |
value | unknown |
context? | SerializationContext |
Returnsβ
Payload | null | undefined
cutoffStackTraceβ
βΈ cutoffStackTrace(stack?): string
Cuts out the framework part of a stack trace, leaving only user code entries
Parametersβ
| Name | Type |
|---|---|
stack? | string |
Returnsβ
string
decodeActivityCancellationTypeβ
βΈ decodeActivityCancellationType(input): undefined | RemovePrefix<"", "ABANDON" | "TRY_CANCEL" | "WAIT_CANCELLATION_COMPLETED">
Parametersβ
| Name | Type |
|---|---|
input | undefined | null | ActivityCancellationType |
Returnsβ
undefined | RemovePrefix<"", "ABANDON" | "TRY_CANCEL" | "WAIT_CANCELLATION_COMPLETED">
decodeApplicationFailureCategoryβ
βΈ decodeApplicationFailureCategory(input): undefined | "BENIGN"
Parametersβ
| Name | Type |
|---|---|
input | undefined | null | ApplicationErrorCategory |
Returnsβ
undefined | "BENIGN"
decodeInitialVersioningBehaviorβ
βΈ decodeInitialVersioningBehavior(input): undefined | "AUTO_UPGRADE" | "USE_RAMPING_VERSION"
Parametersβ
| Name | Type |
|---|---|
input | undefined | null | ContinueAsNewVersioningBehavior |
Returnsβ
undefined | "AUTO_UPGRADE" | "USE_RAMPING_VERSION"
decodePriorityβ
βΈ decodePriority(priority?): Priority
Turn a proto compatible Priority into a TS Priority
Parametersβ
| Name | Type |
|---|---|
priority? | null | IPriority |
Returnsβ
decodeRetryStateβ
βΈ decodeRetryState(input): undefined | "IN_PROGRESS" | "NON_RETRYABLE_FAILURE" | "TIMEOUT" | "MAXIMUM_ATTEMPTS_REACHED" | "RETRY_POLICY_NOT_SET" | "INTERNAL_SERVER_ERROR" | "CANCEL_REQUESTED"
Parametersβ
| Name | Type |
|---|---|
input | undefined | null | RetryState |
Returnsβ
undefined | "IN_PROGRESS" | "NON_RETRYABLE_FAILURE" | "TIMEOUT" | "MAXIMUM_ATTEMPTS_REACHED" | "RETRY_POLICY_NOT_SET" | "INTERNAL_SERVER_ERROR" | "CANCEL_REQUESTED"
decodeTimeoutTypeβ
βΈ decodeTimeoutType(input): undefined | "START_TO_CLOSE" | "SCHEDULE_TO_START" | "SCHEDULE_TO_CLOSE" | "HEARTBEAT"
Parametersβ
| Name | Type |
|---|---|
input | undefined | null | TimeoutType |
Returnsβ
undefined | "START_TO_CLOSE" | "SCHEDULE_TO_START" | "SCHEDULE_TO_CLOSE" | "HEARTBEAT"
decodeVersioningBehaviorβ
βΈ decodeVersioningBehavior(input): undefined | "PINNED" | "AUTO_UPGRADE"
Parametersβ
| Name | Type |
|---|---|
input | undefined | null | VersioningBehavior |
Returnsβ
undefined | "PINNED" | "AUTO_UPGRADE"
decodeWorkflowIdConflictPolicyβ
βΈ decodeWorkflowIdConflictPolicy(input): undefined | "FAIL" | "USE_EXISTING" | "TERMINATE_EXISTING"
Parametersβ
| Name | Type |
|---|---|
input | undefined | null | WorkflowIdConflictPolicy |
Returnsβ
undefined | "FAIL" | "USE_EXISTING" | "TERMINATE_EXISTING"
decodeWorkflowIdReusePolicyβ
βΈ decodeWorkflowIdReusePolicy(input): undefined | "ALLOW_DUPLICATE" | "ALLOW_DUPLICATE_FAILED_ONLY" | "REJECT_DUPLICATE" | "TERMINATE_IF_RUNNING"
Parametersβ
| Name | Type |
|---|---|
input | undefined | null | WorkflowIdReusePolicy |
Returnsβ
undefined | "ALLOW_DUPLICATE" | "ALLOW_DUPLICATE_FAILED_ONLY" | "REJECT_DUPLICATE" | "TERMINATE_IF_RUNNING"
decompileRetryPolicyβ
βΈ decompileRetryPolicy(retryPolicy?): RetryPolicy | undefined
Turn a proto compatible RetryPolicy into a TS RetryPolicy
Parametersβ
| Name | Type |
|---|---|
retryPolicy? | null | IRetryPolicy |
Returnsβ
RetryPolicy | undefined
defineSearchAttributeKeyβ
βΈ defineSearchAttributeKey<T>(name, type): SearchAttributeKey<T>
Type parametersβ
| Name | Type |
|---|---|
T | extends SearchAttributeType |
Parametersβ
| Name | Type |
|---|---|
name | string |
type | T |
Returnsβ
SearchAttributeKey<T>
encodeActivityCancellationTypeβ
βΈ encodeActivityCancellationType(input): undefined | ActivityCancellationType
Parametersβ
| Name | Type |
|---|---|
input | undefined | null | ActivityCancellationType | RemovePrefix<"", "ABANDON" | "TRY_CANCEL" | "WAIT_CANCELLATION_COMPLETED"> |
Returnsβ
undefined | ActivityCancellationType
encodeApplicationFailureCategoryβ
βΈ encodeApplicationFailureCategory(input): undefined | ApplicationErrorCategory
Parametersβ
| Name | Type |
|---|---|
input | undefined | null | ApplicationErrorCategory | "BENIGN" | "APPLICATION_ERROR_CATEGORY_BENIGN" |
Returnsβ
undefined | ApplicationErrorCategory
encodeInitialVersioningBehaviorβ
βΈ encodeInitialVersioningBehavior(input): undefined | ContinueAsNewVersioningBehavior
Parametersβ
| Name | Type |
|---|---|
input | undefined | null | ContinueAsNewVersioningBehavior | "AUTO_UPGRADE" | "USE_RAMPING_VERSION" | "CONTINUE_AS_NEW_VERSIONING_BEHAVIOR_AUTO_UPGRADE" | "CONTINUE_AS_NEW_VERSIONING_BEHAVIOR_USE_RAMPING_VERSION" |
Returnsβ
undefined | ContinueAsNewVersioningBehavior
encodeRetryStateβ
βΈ encodeRetryState(input): undefined | RetryState
Parametersβ
| Name | Type |
|---|---|
input | undefined | null | RetryState | "IN_PROGRESS" | "NON_RETRYABLE_FAILURE" | "TIMEOUT" | "MAXIMUM_ATTEMPTS_REACHED" | "RETRY_POLICY_NOT_SET" | "INTERNAL_SERVER_ERROR" | "CANCEL_REQUESTED" | "RETRY_STATE_IN_PROGRESS" | "RETRY_STATE_NON_RETRYABLE_FAILURE" | "RETRY_STATE_TIMEOUT" | "RETRY_STATE_MAXIMUM_ATTEMPTS_REACHED" | "RETRY_STATE_RETRY_POLICY_NOT_SET" | "RETRY_STATE_INTERNAL_SERVER_ERROR" | "RETRY_STATE_CANCEL_REQUESTED" |
Returnsβ
undefined | RetryState
encodeTimeoutTypeβ
βΈ encodeTimeoutType(input): undefined | TimeoutType
Parametersβ
| Name | Type |
|---|---|
input | undefined | null | TimeoutType | "START_TO_CLOSE" | "SCHEDULE_TO_START" | "SCHEDULE_TO_CLOSE" | "HEARTBEAT" | "TIMEOUT_TYPE_START_TO_CLOSE" | "TIMEOUT_TYPE_SCHEDULE_TO_START" | "TIMEOUT_TYPE_SCHEDULE_TO_CLOSE" | "TIMEOUT_TYPE_HEARTBEAT" |
Returnsβ
undefined | TimeoutType
encodeVersioningBehaviorβ
βΈ encodeVersioningBehavior(input): undefined | VersioningBehavior
Parametersβ
| Name | Type |
|---|---|
input | undefined | null | VersioningBehavior | "PINNED" | "AUTO_UPGRADE" | "VERSIONING_BEHAVIOR_PINNED" | "VERSIONING_BEHAVIOR_AUTO_UPGRADE" |
Returnsβ
undefined | VersioningBehavior
encodeWorkflowIdConflictPolicyβ
βΈ encodeWorkflowIdConflictPolicy(input): undefined | WorkflowIdConflictPolicy
Parametersβ
| Name | Type |
|---|---|
input | undefined | null | WorkflowIdConflictPolicy | "WORKFLOW_ID_CONFLICT_POLICY_TERMINATE_EXISTING" | "FAIL" | "USE_EXISTING" | "TERMINATE_EXISTING" | "WORKFLOW_ID_CONFLICT_POLICY_FAIL" | "WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING" |
Returnsβ
undefined | WorkflowIdConflictPolicy
encodeWorkflowIdReusePolicyβ
βΈ encodeWorkflowIdReusePolicy(input): undefined | WorkflowIdReusePolicy
Parametersβ
| Name | Type |
|---|---|
input | undefined | null | WorkflowIdReusePolicy | "ALLOW_DUPLICATE" | "ALLOW_DUPLICATE_FAILED_ONLY" | "REJECT_DUPLICATE" | "TERMINATE_IF_RUNNING" | "WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE" | "WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY" | "WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE" | "WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING" |
Returnsβ
undefined | WorkflowIdReusePolicy
ensureApplicationFailureβ
βΈ ensureApplicationFailure(error): ApplicationFailure
If error is already an ApplicationFailure, returns error.
Otherwise, converts error into an ApplicationFailure with:
message:error.messageorString(error)type:error.constructor.nameorerror.namestack:error.stackor''
Parametersβ
| Name | Type |
|---|---|
error | unknown |
Returnsβ
ensureTemporalFailureβ
βΈ ensureTemporalFailure(err): TemporalFailure
If err is an Error it is turned into an ApplicationFailure.
If err was already a TemporalFailure, returns the original error.
Otherwise returns an ApplicationFailure with String(err) as the message.
Parametersβ
| Name | Type |
|---|---|
err | unknown |
Returnsβ
extractWorkflowTypeβ
βΈ extractWorkflowType<T>(workflowTypeOrFunc): string
Type parametersβ
| Name | Type |
|---|---|
T | extends Workflow |
Parametersβ
| Name | Type |
|---|---|
workflowTypeOrFunc | string | T | WorkflowFunctionWithOptions<any[], any> |
Returnsβ
string
fromPayloadsAtIndexβ
βΈ fromPayloadsAtIndex<T>(converter, index, payloads?, context?): T
Implements conversion of an array of values of different types. Useful for deserializing arguments of function invocations.
Type parametersβ
| Name |
|---|
T |
Parametersβ
| Name | Type | Description |
|---|---|---|
converter | PayloadConverter | |
index | number | index of the value in the payloads |
payloads? | null | IPayload[] | serialized value to convert to JS values. |
context? | SerializationContext | - |
Returnsβ
T
converted JS value
Throws
PayloadConverterError if conversion of the data passed as parameter failed for any reason.
mapFromPayloadsβ
βΈ mapFromPayloads<K, T>(converter, map?, context?): Record<K, T> | undefined
Type parametersβ
| Name | Type |
|---|---|
K | extends string |
T | unknown |
Parametersβ
| Name | Type |
|---|---|
converter | PayloadConverter |
map? | null | Record<K, IPayload> |
context? | SerializationContext |
Returnsβ
Record<K, T> | undefined
mapToPayloadsβ
βΈ mapToPayloads<K, T>(converter, map, context?): Record<K, Payload>
Run PayloadConverter.toPayload on each value in the map.
Type parametersβ
| Name | Type |
|---|---|
K | extends string |
T | any |
Parametersβ
| Name | Type |
|---|---|
converter | PayloadConverter |
map | Record<K, T> |
context? | SerializationContext |
Returnsβ
Record<K, Payload>
Throws
ValueError if conversion of any value in the map fails
rootCauseβ
βΈ rootCause(error): string | undefined
Get the root cause message of given error.
In case error is a TemporalFailure, recurse the cause chain and return the root cause.message.
Otherwise, return error.message.
Parametersβ
| Name | Type |
|---|---|
error | unknown |
Returnsβ
string | undefined
toCanonicalStringβ
βΈ toCanonicalString(version): string
Parametersβ
| Name | Type |
|---|---|
version | WorkerDeploymentVersion |
Returnsβ
string
The canonical representation of a deployment version, which is a string in the format
deploymentName.buildId.
toPayloadsβ
βΈ toPayloads(converter, ...values): Payload[] | undefined
Implements conversion of a list of values.
Parametersβ
| Name | Type | Description |
|---|---|---|
converter | PayloadConverter | |
...values | unknown[] | JS values to convert to Payloads |
Returnsβ
Payload[] | undefined
list of Payloads
Throws
ValueError if conversion of the value passed as parameter failed for any reason.