Skip to main content

Namespace: common

Common library for code that's used across the Client, Worker, and/or Workflow

Enumerations

Classes

Interfaces

Type Aliases

ActivityInterface

Ƭ ActivityInterface: Record<string, ActivityFunction>

Mapping of Activity name to function

Deprecated

not required anymore, for untyped activities use UntypedActivities


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]


Headers

Ƭ Headers: Record<string, Payload>

Headers are just a mapping of header name to Payload


LogLevel

Ƭ LogLevel: "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR"


LogMetadata

Ƭ LogMetadata: Record<string | symbol, any>


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

NameType
IFIF
FNextends keyof IF

Payload

Ƭ Payload: IPayload


ProtoFailure

Ƭ ProtoFailure: IFailure


SearchAttributeValue

Ƭ SearchAttributeValue: string[] | number[] | boolean[] | Date[]


SearchAttributes

Ƭ SearchAttributes: Record<string, SearchAttributeValue | Readonly<SearchAttributeValue> | undefined>

If another SDK creates a Search Attribute that's not an array, we wrap it in an array.

Dates are serialized as ISO strings.


StringValue

Ƭ StringValue: `${number}` | `${number}${UnitAnyCase}` | `${number} ${UnitAnyCase}`


Timestamp

Ƭ Timestamp: ITimestamp


UntypedActivities

Ƭ UntypedActivities: Record<string, ActivityFunction>

Mapping of Activity name to function


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.


WithWorkflowArgs

Ƭ WithWorkflowArgs<W, T>: T & Parameters<W> extends [any, ...any[]] ? { args: Parameters<W> | Readonly<Parameters<W>> } : { args?: Parameters<W> | Readonly<Parameters<W>> }

Type parameters

NameType
Wextends Workflow
TT

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
NameType
...argsany[]
Returns

WorkflowReturnType


WorkflowExecution

Ƭ WorkflowExecution: IWorkflowExecution


WorkflowQueryAnnotatedType

Ƭ WorkflowQueryAnnotatedType: Object

Type declaration

NameType
description?string
handlerWorkflowQueryType

WorkflowQueryType

Ƭ WorkflowQueryType: (...args: any[]) => any

Type declaration

▸ (...args): any

Parameters
NameType
...argsany[]
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

NameType
Wextends Workflow

WorkflowReturnType

Ƭ WorkflowReturnType: Promise<any>

Type that can be returned from a Workflow execute function


WorkflowSignalAnnotatedType

Ƭ WorkflowSignalAnnotatedType: Object

Type declaration

NameType
description?string
handlerWorkflowSignalType
unfinishedPolicyHandlerUnfinishedPolicy

WorkflowSignalType

Ƭ WorkflowSignalType: (...args: any[]) => Promise<void> | void

Type declaration

▸ (...args): Promise<void> | void

Parameters
NameType
...argsany[]
Returns

Promise<void> | void


WorkflowUpdateAnnotatedType

Ƭ WorkflowUpdateAnnotatedType: Object

Type declaration

NameType
description?string
handlerWorkflowUpdateType
unfinishedPolicyHandlerUnfinishedPolicy
validator?WorkflowUpdateValidatorType

WorkflowUpdateType

Ƭ WorkflowUpdateType: (...args: any[]) => Promise<any> | any

Type declaration

▸ (...args): Promise<any> | any

Parameters
NameType
...argsany[]
Returns

Promise<any> | any


WorkflowUpdateValidatorType

Ƭ WorkflowUpdateValidatorType: (...args: any[]) => void

Type declaration

▸ (...args): void

Parameters
NameType
...argsany[]
Returns

void

Variables

FAILURE_SOURCE

Const FAILURE_SOURCE: "TypeScriptSDK"


METADATA_ENCODING_KEY

Const METADATA_ENCODING_KEY: "encoding"


METADATA_MESSAGE_TYPE_KEY

Const METADATA_MESSAGE_TYPE_KEY: "messageType"


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 serizalized 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

NameType
METADATA_ENCODING_JSONUint8Array
METADATA_ENCODING_NULLUint8Array
METADATA_ENCODING_PROTOBUFUint8Array
METADATA_ENCODING_PROTOBUF_JSONUint8Array
METADATA_ENCODING_RAWUint8Array

encodingTypes

Const encodingTypes: Object

Type declaration

NameType
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"

searchAttributePayloadConverter

Const searchAttributePayloadConverter: SearchAttributePayloadConverter

Functions

arrayFromPayloads

arrayFromPayloads(converter, payloads?): unknown[]

Run PayloadConverter.fromPayload on each value in the array.

Parameters

NameType
converterPayloadConverter
payloads?null | IPayload[]

Returns

unknown[]


compileRetryPolicy

compileRetryPolicy(retryPolicy): IRetryPolicy

Turn a TS RetryPolicy into a proto compatible RetryPolicy

Parameters

NameType
retryPolicyRetryPolicy

Returns

IRetryPolicy


cutoffStackTrace

cutoffStackTrace(stack?): string

Cuts out the framework part of a stack trace, leaving only user code entries

Parameters

NameType
stack?string

Returns

string


decompileRetryPolicy

decompileRetryPolicy(retryPolicy?): RetryPolicy | undefined

Turn a proto compatible RetryPolicy into a TS RetryPolicy

Parameters

NameType
retryPolicy?null | IRetryPolicy

Returns

RetryPolicy | undefined


ensureApplicationFailure

ensureApplicationFailure(error): ApplicationFailure

If error is already an ApplicationFailure, returns error.

Otherwise, converts error into an ApplicationFailure with:

  • message: error.message or String(error)
  • type: error.constructor.name or error.name
  • stack: error.stack or ''

Parameters

NameType
errorunknown

Returns

ApplicationFailure


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

NameType
errunknown

Returns

TemporalFailure


extractWorkflowType

extractWorkflowType<T>(workflowTypeOrFunc): string

Type parameters

NameType
Textends Workflow

Parameters

NameType
workflowTypeOrFuncstring | T

Returns

string


fromPayloadsAtIndex

fromPayloadsAtIndex<T>(converter, index, payloads?): T

Implements conversion of an array of values of different types. Useful for deserializing arguments of function invocations.

Type parameters

Name
T

Parameters

NameTypeDescription
converterPayloadConverter
indexnumberindex of the value in the payloads
payloads?null | IPayload[]serialized value to convert to JS values.

Returns

T

converted JS value

Throws

PayloadConverterError if conversion of the data passed as parameter failed for any reason.


mapFromPayloads

mapFromPayloads<K>(converter, map?): Record<K, unknown> | undefined

Type parameters

NameType
Kextends string

Parameters

NameType
converterPayloadConverter
map?null | Record<K, IPayload>

Returns

Record<K, unknown> | undefined


mapToPayloads

mapToPayloads<K>(converter, map): Record<K, Payload>

Run PayloadConverter.toPayload on each value in the map.

Type parameters

NameType
Kextends string

Parameters

NameType
converterPayloadConverter
mapRecord<K, any>

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

NameType
errorunknown

Returns

string | undefined


toPayloads

toPayloads(converter, ...values): Payload[] | undefined

Implements conversion of a list of values.

Parameters

NameTypeDescription
converterPayloadConverter
...valuesunknown[]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.