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
- ExternalStorage
- ExternalStorageDriverError
- ExternalStorageError
- ExternalStorageNotConfiguredError
- ExternalStorageReferenceError
- ExternalStorageUnregisteredDriverError
- IllegalStateError
- InvalidVersioningOverrideError
- JsonPayloadConverter
- NamespaceNotFoundError
- NexusOperationFailure
- PayloadConverterError
- RawValue
- ServerFailure
- StorageDriverClaim
- TemporalFailure
- TerminatedFailure
- TimeoutFailure
- TypedSearchAttributes
- UndefinedPayloadConverter
- ValueError
- WorkflowExecutionAlreadyStartedError
- WorkflowNotFoundError
Interfaces
- ActivityCancellationDetailsOptions
- ActivityDefinitionOptions
- ActivityFunction
- ActivityOptions
- ActivitySerializationContext
- ApplicationFailureOptions
- BaseWorkflowHandle
- BaseWorkflowOptions
- ConverterHint
- DataConverter
- DefaultEncodedFailureAttributes
- DefaultFailureConverterOptions
- ExternalStorageConcurrency
- FailureConverter
- HistoryAndWorkflowId
- LoadedDataConverter
- LocalActivityOptions
- Logger
- Metric
- MetricCounter
- MetricGauge
- MetricHistogram
- MetricMeter
- MetricUpDownCounter
- NexusSerializationContext
- OneTimeVersioningOverride
- PayloadCache
- PayloadCodec
- PayloadConverter
- PayloadConverterWithEncoding
- PayloadTypeInfo
- PinnedVersioningOverride
- Priority
- QueryDefinition
- QueryDefinitionOptions
- RetryPolicy
- SearchAttributeKey
- SignalDefinition
- SignalDefinitionOptions
- StorageDriver
- StorageDriverActivityInfo
- StorageDriverLimiter
- StorageDriverRetrieveContext
- StorageDriverSelectContext
- StorageDriverStoreContext
- StorageDriverWorkflowInfo
- TransferTypeConverter
- TypeInfo
- UpdateDefinition
- UpdateDefinitionOptions
- WorkerDeploymentVersion
- WorkflowDefinitionConfig
- WorkflowDefinitionOptions
- WorkflowDurationOptions
- WorkflowQueryOptions
- WorkflowSerializationContext
- WorkflowSignalOptions
- WorkflowStaticOptions
- WorkflowTypeOptions
Type Aliases
ActivityCancellationType
ActivityCancellationType = typeof
ActivityCancellationType[keyof typeofActivityCancellationType]
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.TRY_CANCEL
ActivityInterface
ActivityInterface =
Record<string,ActivityFunction>
Mapping of Activity name to function
Deprecated
not required anymore, for untyped activities use UntypedActivities
ActivityTypeInfoMap
ActivityTypeInfoMap<
A> =Partial<Record<ActivityKeys<A>,PayloadTypeInfo>>
Experimental
Type information keyed only by Activity-valued properties of A.
Type Parameters
A
A
ApplicationFailureCategory
ApplicationFailureCategory = typeof
ApplicationFailureCategory[keyof typeofApplicationFailureCategory]
Experimental
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.
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 typeofencodingTypes]
HandlerUnfinishedPolicy
HandlerUnfinishedPolicy = typeof
HandlerUnfinishedPolicy[keyof typeofHandlerUnfinishedPolicy]
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.
Headers
Headers =
Record<string,Payload>
Headers are just a mapping of header name to Payload
InitialVersioningBehavior
InitialVersioningBehavior = typeof
InitialVersioningBehavior[keyof typeofInitialVersioningBehavior]
Experimental
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.
LogLevel
LogLevel =
"TRACE"|"DEBUG"|"INFO"|"WARN"|"ERROR"
LogMetadata
LogMetadata =
Record<string|symbol,any>
MetricKind
MetricKind =
"counter"|"histogram"|"gauge"|"up-down-counter"
Experimental
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>
Experimental
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] extendsAnyFunc?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
IF
IF
FN
FN extends keyof IF
NumericMetricValueType
NumericMetricValueType =
"int"|"float"
Experimental
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.
OutputTypeInfo
OutputTypeInfo<
T> =object
Experimental
Type information used to decode an output value of type T.
Type Parameters
T
T
Properties
outputType?
optionaloutputType?:TypeInfo<T,any>
Payload
Payload =
IPayload
ProtoFailure
ProtoFailure =
IFailure
RetryState
RetryState = typeof
RetryState[keyof typeofRetryState]
SearchAttributePair
SearchAttributePair =
{ [T in SearchAttributeType]: { key: SearchAttributeKey<T>; value: IndexedValueTypeMapping[T] } }[SearchAttributeType]
SearchAttributes
SearchAttributes =
Record<string,SearchAttributeValueOrReadonly>
@deprecated: Use TypedSearchAttributes instead
SearchAttributeType
SearchAttributeType = typeof
SearchAttributeType[keyof typeofSearchAttributeType]
SearchAttributeUpdatePair
SearchAttributeUpdatePair = { [T in SearchAttributeType]: { key: SearchAttributeKey<T>; value: IndexedValueTypeMapping[T] | null } }[
SearchAttributeType]
SearchAttributeValue
SearchAttributeValue =
string[] |number[] |boolean[] |Date[]
@deprecated: Use TypedSearchAttributes instead
SerializationContext
SerializationContext =
WorkflowSerializationContext|ActivitySerializationContext|NexusSerializationContext
Experimental
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.
SignalTypeInfo
SignalTypeInfo =
Pick<PayloadTypeInfo,"inputTypes">
An interface representing a Workflow signal definition, as returned from defineSignal
Remarks
Args can be used for parameter type inference in handler functions and WorkflowHandle methods.
Name can optionally be specified with a string literal type to preserve type-level knowledge of the signal name.
StorageDriverSelector
StorageDriverSelector = (
context,payload) =>StorageDriver|null
Experimental
User-supplied function that picks the destination driver for a given
payload, or returns null to keep the payload inline.
Parameters
context
payload
Returns
StorageDriver | null
StorageDriverTargetInfo
StorageDriverTargetInfo =
StorageDriverWorkflowInfo|StorageDriverActivityInfo
Experimental
Identity of the workflow or activity that produced the payloads being stored.
StringValue
StringValue =
`${number}`|`${number}${UnitAnyCase}`|`${number} ${UnitAnyCase}`
SuggestContinueAsNewReason
SuggestContinueAsNewReason = typeof
SuggestContinueAsNewReason[keyof typeofSuggestContinueAsNewReason]
Experimental
Reason(s) why continue as new is suggested. Can potentially be multiple reasons.
May be removed or changed in the future.
TimeoutType
TimeoutType = typeof
TimeoutType[keyof typeofTimeoutType]
Timestamp
Timestamp =
ITimestamp
UntypedActivities
UntypedActivities =
Record<string,ActivityFunction>
Mapping of Activity name to function
VersioningBehavior
VersioningBehavior = typeof
VersioningBehavior[keyof typeofVersioningBehavior]
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.
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|AutoUpgradeVersioningOverride|OneTimeVersioningOverride
Represents versioning overrides. For example, when starting workflows.
WithWorkflowArgs
WithWorkflowArgs<
W,T> =T&Parameters<W> extends [any,...any[]] ?object:object
Type Parameters
W
W extends Workflow
T
T
Workflow
Workflow = (...
args) =>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>;
Parameters
args
...any[]
Returns
WorkflowDefinitionOptionsOrGetter
WorkflowDefinitionOptionsOrGetter =
WorkflowDefinitionOptions| (() =>WorkflowDefinitionOptions)
WorkflowExecution
WorkflowExecution =
IWorkflowExecution
WorkflowIdConflictPolicy
WorkflowIdConflictPolicy = typeof
WorkflowIdConflictPolicy[keyof typeofWorkflowIdConflictPolicy]
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.
WorkflowIdReusePolicy
WorkflowIdReusePolicy = typeof
WorkflowIdReusePolicy[keyof typeofWorkflowIdReusePolicy]
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.
WorkflowQueryAnnotatedType
WorkflowQueryAnnotatedType =
object
Properties
description?
optionaldescription?:string
handler
handler:
WorkflowQueryType
typeInfo?
optionaltypeInfo?:PayloadTypeInfo
WorkflowQueryType
WorkflowQueryType = (...
args) =>any
Parameters
args
...any[]
Returns
any
WorkflowResultType
WorkflowResultType<
W> =ReturnType<W> extendsPromise<infer R> ?R:never
Get the "unwrapped" return type (without Promise) of the execute handler from Workflow type W
Type Parameters
W
W extends Workflow
WorkflowReturnType
WorkflowReturnType =
Promise<any>
Type that can be returned from a Workflow execute function
WorkflowSignalAnnotatedType
WorkflowSignalAnnotatedType =
object
Properties
description?
optionaldescription?:string
handler
handler:
WorkflowSignalType
typeInfo?
optionaltypeInfo?:SignalTypeInfo
unfinishedPolicy
unfinishedPolicy:
HandlerUnfinishedPolicy
WorkflowSignalType
WorkflowSignalType = (...
args) =>Promise<void> |void
Parameters
args
...any[]
Returns
Promise<void> | void
WorkflowUpdateAnnotatedType
WorkflowUpdateAnnotatedType =
object
Properties
description?
optionaldescription?:string
handler
handler:
WorkflowUpdateType
typeInfo?
optionaltypeInfo?:PayloadTypeInfo
unfinishedPolicy
unfinishedPolicy:
HandlerUnfinishedPolicy
validator?
optionalvalidator?:WorkflowUpdateValidatorType
WorkflowUpdateType
WorkflowUpdateType = (...
args) =>Promise<any> |any
Parameters
args
...any[]
Returns
Promise<any> | any
WorkflowUpdateValidatorType
WorkflowUpdateValidatorType = (...
args) =>void
Parameters
args
...any[]
Returns
void
Variables
ActivityCancellationType
constActivityCancellationType: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.
Type Declaration
ABANDON
readonlyABANDON:"ABANDON"
Do not propagate cancellation requests to the Activity, and immediately report cancellation to the caller.
TRY_CANCEL
readonlyTRY_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
readonlyWAIT_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.
Default
ActivityCancellationType.TRY_CANCEL
ApplicationFailureCategory
constApplicationFailureCategory:object
Experimental
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
BENIGN
readonlyBENIGN:"BENIGN"
decodeApplicationFailureCategory
constdecodeApplicationFailureCategory: (input) =>"BENIGN"|undefined
Parameters
input
ApplicationErrorCategory | null | undefined
Returns
"BENIGN" | undefined
decodeInitialVersioningBehavior
constdecodeInitialVersioningBehavior: (input) =>"AUTO_UPGRADE"|"USE_RAMPING_VERSION"|undefined
Parameters
input
ContinueAsNewVersioningBehavior | null | undefined
Returns
"AUTO_UPGRADE" | "USE_RAMPING_VERSION" | undefined
decodeRetryState
constdecodeRetryState: (input) =>"IN_PROGRESS"|"NON_RETRYABLE_FAILURE"|"TIMEOUT"|"MAXIMUM_ATTEMPTS_REACHED"|"RETRY_POLICY_NOT_SET"|"INTERNAL_SERVER_ERROR"|"CANCEL_REQUESTED"|undefined
Parameters
input
RetryState | null | undefined
Returns
"IN_PROGRESS" | "NON_RETRYABLE_FAILURE" | "TIMEOUT" | "MAXIMUM_ATTEMPTS_REACHED" | "RETRY_POLICY_NOT_SET" | "INTERNAL_SERVER_ERROR" | "CANCEL_REQUESTED" | undefined
decodeTimeoutType
constdecodeTimeoutType: (input) =>"START_TO_CLOSE"|"SCHEDULE_TO_START"|"SCHEDULE_TO_CLOSE"|"HEARTBEAT"|undefined
Parameters
input
TimeoutType | null | undefined
Returns
"START_TO_CLOSE" | "SCHEDULE_TO_START" | "SCHEDULE_TO_CLOSE" | "HEARTBEAT" | undefined
decodeVersioningBehavior
constdecodeVersioningBehavior: (input) =>"PINNED"|"AUTO_UPGRADE"|undefined
Parameters
input
VersioningBehavior | null | undefined
Returns
"PINNED" | "AUTO_UPGRADE" | undefined
decodeWorkflowIdConflictPolicy
constdecodeWorkflowIdConflictPolicy: (input) =>"FAIL"|"USE_EXISTING"|"TERMINATE_EXISTING"|undefined
Parameters
input
WorkflowIdConflictPolicy | null | undefined
Returns
"FAIL" | "USE_EXISTING" | "TERMINATE_EXISTING" | undefined
decodeWorkflowIdReusePolicy
constdecodeWorkflowIdReusePolicy: (input) =>"ALLOW_DUPLICATE"|"ALLOW_DUPLICATE_FAILED_ONLY"|"REJECT_DUPLICATE"|"TERMINATE_IF_RUNNING"|undefined
Parameters
input
WorkflowIdReusePolicy | null | undefined
Returns
"ALLOW_DUPLICATE" | "ALLOW_DUPLICATE_FAILED_ONLY" | "REJECT_DUPLICATE" | "TERMINATE_IF_RUNNING" | undefined
defaultDataConverter
constdefaultDataConverter:LoadedDataConverter
A "loaded" data converter that uses the default set of failure and payload converters.
defaultFailureConverter
constdefaultFailureConverter:FailureConverter
The default FailureConverter used by the SDK.
Error messages and stack traces are serialized as plain text.
defaultPayloadConverter
constdefaultPayloadConverter: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 })
encodeApplicationFailureCategory
constencodeApplicationFailureCategory: (input) =>ApplicationErrorCategory|undefined
Parameters
input
"BENIGN" | ApplicationErrorCategory | "APPLICATION_ERROR_CATEGORY_BENIGN" | null | undefined
Returns
ApplicationErrorCategory | undefined
encodeInitialVersioningBehavior
constencodeInitialVersioningBehavior: (input) =>ContinueAsNewVersioningBehavior|undefined
Parameters
input
"AUTO_UPGRADE" | "USE_RAMPING_VERSION" | ContinueAsNewVersioningBehavior | "CONTINUE_AS_NEW_VERSIONING_BEHAVIOR_AUTO_UPGRADE" | "CONTINUE_AS_NEW_VERSIONING_BEHAVIOR_USE_RAMPING_VERSION" | null | undefined
Returns
ContinueAsNewVersioningBehavior | undefined
encodeRetryState
constencodeRetryState: (input) =>RetryState|undefined
Parameters
input
"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" | RetryState | null | undefined
Returns
RetryState | undefined
encodeTimeoutType
constencodeTimeoutType: (input) =>TimeoutType|undefined
Parameters
input
"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" | TimeoutType | null | undefined
Returns
TimeoutType | undefined
encodeVersioningBehavior
constencodeVersioningBehavior: (input) =>VersioningBehavior|undefined
Parameters
input
"PINNED" | "AUTO_UPGRADE" | VersioningBehavior | "VERSIONING_BEHAVIOR_PINNED" | "VERSIONING_BEHAVIOR_AUTO_UPGRADE" | null | undefined
Returns
VersioningBehavior | undefined
encodeWorkflowIdConflictPolicy
constencodeWorkflowIdConflictPolicy: (input) =>WorkflowIdConflictPolicy|undefined
Parameters
input
"FAIL" | "USE_EXISTING" | "TERMINATE_EXISTING" | WorkflowIdConflictPolicy | "WORKFLOW_ID_CONFLICT_POLICY_FAIL" | "WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING" | "WORKFLOW_ID_CONFLICT_POLICY_TERMINATE_EXISTING" | null | undefined
Returns
WorkflowIdConflictPolicy | undefined
encodeWorkflowIdReusePolicy
constencodeWorkflowIdReusePolicy: (input) =>WorkflowIdReusePolicy|undefined
Parameters
input
"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" | WorkflowIdReusePolicy | null | undefined
Returns
WorkflowIdReusePolicy | undefined
encodingKeys
constencodingKeys:object
Type Declaration
METADATA_ENCODING_JSON
readonlyMETADATA_ENCODING_JSON:Uint8Array<ArrayBufferLike>
METADATA_ENCODING_NULL
readonlyMETADATA_ENCODING_NULL:Uint8Array<ArrayBufferLike>
METADATA_ENCODING_PROTOBUF
readonlyMETADATA_ENCODING_PROTOBUF:Uint8Array<ArrayBufferLike>
METADATA_ENCODING_PROTOBUF_JSON
readonlyMETADATA_ENCODING_PROTOBUF_JSON:Uint8Array<ArrayBufferLike>
METADATA_ENCODING_RAW
readonlyMETADATA_ENCODING_RAW:Uint8Array<ArrayBufferLike>
encodingTypes
constencodingTypes:object
Type Declaration
METADATA_ENCODING_JSON
readonlyMETADATA_ENCODING_JSON:"json/plain"
METADATA_ENCODING_NULL
readonlyMETADATA_ENCODING_NULL:"binary/null"
METADATA_ENCODING_PROTOBUF
readonlyMETADATA_ENCODING_PROTOBUF:"binary/protobuf"
METADATA_ENCODING_PROTOBUF_JSON
readonlyMETADATA_ENCODING_PROTOBUF_JSON:"json/protobuf"
METADATA_ENCODING_RAW
readonlyMETADATA_ENCODING_RAW:"binary/plain"
FAILURE_SOURCE
constFAILURE_SOURCE:"TypeScriptSDK"="TypeScriptSDK"
HandlerUnfinishedPolicy
constHandlerUnfinishedPolicy: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
ABANDON
readonlyABANDON:"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
readonlyWARN_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
constInitialVersioningBehavior:object
Experimental
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
AUTO_UPGRADE
readonlyAUTO_UPGRADE:"AUTO_UPGRADE"
USE_RAMPING_VERSION
readonlyUSE_RAMPING_VERSION:"USE_RAMPING_VERSION"
METADATA_ENCODING_KEY
constMETADATA_ENCODING_KEY:"encoding"="encoding"
METADATA_MESSAGE_TYPE_KEY
constMETADATA_MESSAGE_TYPE_KEY:"messageType"="messageType"
noopMetricMeter
constnoopMetricMeter:NoopMetricMeter
rawPayloadTypeBrand
constrawPayloadTypeBrand: uniquesymbol
rawValueTypeInfo
Experimental
Type information for preserving a RawValue across serialization boundaries.
This bypasses the payload converter during encoding and decoding. Payload codecs are still applied.
RetryState
constRetryState:object
Type Declaration
CANCEL_REQUESTED
readonlyCANCEL_REQUESTED:"CANCEL_REQUESTED"
IN_PROGRESS
readonlyIN_PROGRESS:"IN_PROGRESS"
INTERNAL_SERVER_ERROR
readonlyINTERNAL_SERVER_ERROR:"INTERNAL_SERVER_ERROR"
MAXIMUM_ATTEMPTS_REACHED
readonlyMAXIMUM_ATTEMPTS_REACHED:"MAXIMUM_ATTEMPTS_REACHED"
NON_RETRYABLE_FAILURE
readonlyNON_RETRYABLE_FAILURE:"NON_RETRYABLE_FAILURE"
RETRY_POLICY_NOT_SET
readonlyRETRY_POLICY_NOT_SET:"RETRY_POLICY_NOT_SET"
RETRY_STATE_CANCEL_REQUESTED
readonlyRETRY_STATE_CANCEL_REQUESTED:"CANCEL_REQUESTED"
Deprecated
Use CANCEL_REQUESTED instead.
RETRY_STATE_IN_PROGRESS
readonlyRETRY_STATE_IN_PROGRESS:"IN_PROGRESS"
Deprecated
Use IN_PROGRESS instead.
RETRY_STATE_INTERNAL_SERVER_ERROR
readonlyRETRY_STATE_INTERNAL_SERVER_ERROR:"INTERNAL_SERVER_ERROR"
Deprecated
Use INTERNAL_SERVER_ERROR instead.
RETRY_STATE_MAXIMUM_ATTEMPTS_REACHED
readonlyRETRY_STATE_MAXIMUM_ATTEMPTS_REACHED:"MAXIMUM_ATTEMPTS_REACHED"
Deprecated
Use MAXIMUM_ATTEMPTS_REACHED instead.
RETRY_STATE_NON_RETRYABLE_FAILURE
readonlyRETRY_STATE_NON_RETRYABLE_FAILURE:"NON_RETRYABLE_FAILURE"
Deprecated
Use NON_RETRYABLE_FAILURE instead.
RETRY_STATE_RETRY_POLICY_NOT_SET
readonlyRETRY_STATE_RETRY_POLICY_NOT_SET:"RETRY_POLICY_NOT_SET"
Deprecated
Use RETRY_POLICY_NOT_SET instead.
RETRY_STATE_TIMEOUT
readonlyRETRY_STATE_TIMEOUT:"TIMEOUT"
Deprecated
Use TIMEOUT instead.
RETRY_STATE_UNSPECIFIED
readonlyRETRY_STATE_UNSPECIFIED:undefined
Deprecated
Use undefined instead.
TIMEOUT
readonlyTIMEOUT:"TIMEOUT"
SearchAttributeType
constSearchAttributeType:object
Type Declaration
BOOL
readonlyBOOL:"BOOL"
DATETIME
readonlyDATETIME:"DATETIME"
DOUBLE
readonlyDOUBLE:"DOUBLE"
INT
readonlyINT:"INT"
KEYWORD
readonlyKEYWORD:"KEYWORD"
KEYWORD_LIST
readonlyKEYWORD_LIST:"KEYWORD_LIST"
TEXT
readonlyTEXT:"TEXT"
SuggestContinueAsNewReason
constSuggestContinueAsNewReason:object
Experimental
Reason(s) why continue as new is suggested. Can potentially be multiple reasons.
May be removed or changed in the future.
Type Declaration
HISTORY_SIZE_TOO_LARGE
readonlyHISTORY_SIZE_TOO_LARGE:"HISTORY_SIZE_TOO_LARGE"
TOO_MANY_HISTORY_EVENTS
readonlyTOO_MANY_HISTORY_EVENTS:"TOO_MANY_HISTORY_EVENTS"
TOO_MANY_UPDATES
readonlyTOO_MANY_UPDATES:"TOO_MANY_UPDATES"
TimeoutType
constTimeoutType:object
Type Declaration
HEARTBEAT
readonlyHEARTBEAT:"HEARTBEAT"
SCHEDULE_TO_CLOSE
readonlySCHEDULE_TO_CLOSE:"SCHEDULE_TO_CLOSE"
SCHEDULE_TO_START
readonlySCHEDULE_TO_START:"SCHEDULE_TO_START"
START_TO_CLOSE
readonlySTART_TO_CLOSE:"START_TO_CLOSE"
TIMEOUT_TYPE_HEARTBEAT
readonlyTIMEOUT_TYPE_HEARTBEAT:"HEARTBEAT"
Deprecated
Use HEARTBEAT instead.
TIMEOUT_TYPE_SCHEDULE_TO_CLOSE
readonlyTIMEOUT_TYPE_SCHEDULE_TO_CLOSE:"SCHEDULE_TO_CLOSE"
Deprecated
Use SCHEDULE_TO_CLOSE instead.
TIMEOUT_TYPE_SCHEDULE_TO_START
readonlyTIMEOUT_TYPE_SCHEDULE_TO_START:"SCHEDULE_TO_START"
Deprecated
Use SCHEDULE_TO_START instead.
TIMEOUT_TYPE_START_TO_CLOSE
readonlyTIMEOUT_TYPE_START_TO_CLOSE:"START_TO_CLOSE"
Deprecated
Use START_TO_CLOSE instead.
TIMEOUT_TYPE_UNSPECIFIED
readonlyTIMEOUT_TYPE_UNSPECIFIED:undefined
Deprecated
Use undefined instead.
VersioningBehavior
constVersioningBehavior: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
AUTO_UPGRADE
readonlyAUTO_UPGRADE:"AUTO_UPGRADE"
PINNED
readonlyPINNED:"PINNED"
WorkflowIdConflictPolicy
constWorkflowIdConflictPolicy: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
FAIL
readonlyFAIL:"FAIL"
Do not start a new Workflow. Instead raise a WorkflowExecutionAlreadyStartedError.
TERMINATE_EXISTING
readonlyTERMINATE_EXISTING:"TERMINATE_EXISTING"
Start a new Workflow, terminating the current workflow if one is already running.
USE_EXISTING
readonlyUSE_EXISTING:"USE_EXISTING"
Do not start a new Workflow. Instead return a Workflow Handle for the already Running Workflow.
WorkflowIdReusePolicy
constWorkflowIdReusePolicy: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
ALLOW_DUPLICATE
readonlyALLOW_DUPLICATE:"ALLOW_DUPLICATE"
The Workflow can be started if the previous Workflow is in a Closed state.
Default
ALLOW_DUPLICATE_FAILED_ONLY
readonlyALLOW_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
readonlyREJECT_DUPLICATE:"REJECT_DUPLICATE"
The Workflow cannot be started.
TERMINATE_IF_RUNNING
readonlyTERMINATE_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
readonlyWORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE:"ALLOW_DUPLICATE"
Deprecated
Use ALLOW_DUPLICATE instead.
WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY
readonlyWORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY:"ALLOW_DUPLICATE_FAILED_ONLY"
Deprecated
Use ALLOW_DUPLICATE_FAILED_ONLY instead.
WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE
readonlyWORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE:"REJECT_DUPLICATE"
Deprecated
Use REJECT_DUPLICATE instead.
WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING
readonlyWORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING:"TERMINATE_IF_RUNNING"
Deprecated
Use TERMINATE_IF_RUNNING instead.
WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED
readonlyWORKFLOW_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.
Functions
arrayFromPayloads()
arrayFromPayloads(
converter,payloads?,context?,typeInfo?):unknown[]
Run PayloadConverter.fromPayload on each value in the array.
Parameters
converter
payloads?
IPayload[] | null
context?
typeInfo?
readonly TypeInfo<unknown, unknown>[]
Returns
unknown[]
compilePriority()
compilePriority(
priority):IPriority
Turn a TS Priority into a proto compatible Priority
Parameters
priority
Returns
compileRetryPolicy()
compileRetryPolicy(
retryPolicy):IRetryPolicy
Turn a TS RetryPolicy into a proto compatible RetryPolicy
Parameters
retryPolicy
Returns
convertOptionalToPayload()
convertOptionalToPayload(
payloadConverter,value,context?):IPayload|null|undefined
Run PayloadConverter.toPayload on an optional value, and then encode it.
Parameters
payloadConverter
value
unknown
context?
Returns
IPayload | null | undefined
createPayloadValidationError()
createPayloadValidationError(
details):ApplicationFailure
Create a non-retryable ApplicationFailure for reporting a Payload validation failure.
Payload Converters and Payload Codecs can throw this failure when they understand a Payload but
reject it as invalid. A non-nullish value is stored as a single failure detail; null and
undefined produce an empty details array.
Parameters
details
unknown
Returns
cutoffStackTrace()
cutoffStackTrace(
stack?):string
Cuts out the framework part of a stack trace, leaving only user code entries
Parameters
stack?
string
Returns
string
decodePriority()
decodePriority(
priority?):Priority
Turn a proto compatible Priority into a TS Priority
Parameters
priority?
IPriority | null
Returns
decompileRetryPolicy()
decompileRetryPolicy(
retryPolicy?):RetryPolicy|undefined
Turn a proto compatible RetryPolicy into a TS RetryPolicy
Parameters
retryPolicy?
IRetryPolicy | null
Returns
RetryPolicy | undefined
defineSearchAttributeKey()
defineSearchAttributeKey<
T>(name,type):SearchAttributeKey<T>
Type Parameters
T
T extends SearchAttributeType
Parameters
name
string
type
T
Returns
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''cause:error.causewhen it is anError
Parameters
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
err
unknown
Returns
extractWorkflowType()
extractWorkflowType<
T>(workflowTypeOrFunc):string
Type Parameters
T
T extends Workflow
Parameters
workflowTypeOrFunc
string | T
Returns
string
extractWorkflowTypeAndConfig()
extractWorkflowTypeAndConfig<
T>(workflowTypeOrFunc,callSiteTypeInfo?):WorkflowTypeOptions
Type Parameters
T
T extends Workflow
Parameters
workflowTypeOrFunc
string | T
callSiteTypeInfo?
Returns
fromPayloadsAtIndex()
fromPayloadsAtIndex<
T,D>(converter,index,payloads?,context?,typeInfo?):T
Implements conversion of an array of values of different types. Useful for deserializing arguments of function invocations.
Type Parameters
T
T
D
D = T
Parameters
converter
index
number
index of the value in the payloads
payloads?
IPayload[] | null
serialized value to convert to JS values.
context?
typeInfo?
TypeInfo<T, D>
Returns
T
converted JS value
Throws
PayloadConverterError if conversion of the data passed as parameter failed for any reason.
fromPayloadWithTypeInfo()
fromPayloadWithTypeInfo<
T,D>(converter,payload,context,typeInfo):T
Experimental
Convert a Payload and then apply TypeInfo transfer conversion to the result.
Type Parameters
T
T
D
D = T
Parameters
converter
Pick<PayloadConverter, "fromPayload">
payload
context
SerializationContext | undefined
typeInfo
TypeInfo<T, D> | undefined
Returns
T
mapFromPayloads()
mapFromPayloads<
K,T>(converter,map?,context?):Record<K,T> |undefined
Type Parameters
K
K extends string
T
T = unknown
Parameters
converter
map?
Record<K, IPayload> | null
context?
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
K
K extends string
T
T = any
Parameters
converter
map
Record<K, T>
context?
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
error
unknown
Returns
string | undefined
toCanonicalString()
toCanonicalString(
version):string
Parameters
version
Returns
string
The canonical representation of a deployment version, which is a string in the format
deploymentName.buildId.
toPayloads()
toPayloads(
converter, ...values):IPayload[] |undefined
Implements conversion of a list of values.
Parameters
converter
values
...unknown[]
JS values to convert to Payloads
Returns
IPayload[] | undefined
list of Payloads
Throws
ValueError if conversion of the value passed as parameter failed for any reason.
toPayloadWithTypeInfo()
toPayloadWithTypeInfo<
T,D>(converter,value,context,typeInfo):IPayload
Experimental
Apply TypeInfo transfer conversion before converting a value to a Payload.
Type Parameters
T
T
D
D = T
Parameters
converter
value
T
context
SerializationContext | undefined
typeInfo
TypeInfo<T, D> | undefined