Skip to main content

Namespace: common

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

Enumerations​

Classes​

Interfaces​

References​

Headers​

Re-exports Headers


Next​

Re-exports Next

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


EncodingType​

Ζ¬ EncodingType: typeof encodingTypes[keyof typeof encodingTypes]


Payload​

Ζ¬ Payload: IPayload


ProtoFailure​

Ζ¬ ProtoFailure: IFailure


SearchAttributeValue​

Ζ¬ SearchAttributeValue: string[] | number[] | boolean[] | Date[]


SearchAttributes​

Ζ¬ SearchAttributes: Record<string, 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.


Timestamp​

Ζ¬ Timestamp: ITimestamp


UntypedActivities​

Ζ¬ UntypedActivities: Record<string, ActivityFunction>

Mapping of Activity name to function


WithCompiledWorkflowOptions​

Ζ¬ WithCompiledWorkflowOptions<T>: Replace<T, { workflowExecutionTimeout?: IDuration ; workflowRunTimeout?: IDuration ; workflowTaskTimeout?: IDuration }>

Type parameters​

NameType
Textends CommonWorkflowOptions

WithWorkflowArgs​

Ζ¬ WithWorkflowArgs<W, T>: T & Parameters<W> extends [any, ...any[]] ? { args: Parameters<W> } : { args?: Parameters<W> }

Type parameters​

NameType
Wextends Workflow
TT

Workflow​

Ζ¬ Workflow: (...args: any[]) => WorkflowReturnType

Type declaration​

β–Έ (...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​
NameType
...argsany[]
Returns​

WorkflowReturnType


WorkflowExecution​

Ζ¬ WorkflowExecution: IWorkflowExecution


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


WorkflowSignalType​

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

Type declaration​

β–Έ (...args): Promise<void> | void

Parameters​
NameType
...argsany[]
Returns​

Promise<void> | 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 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


compileWorkflowOptions​

β–Έ compileWorkflowOptions<T>(options): WithCompiledWorkflowOptions<T>

Type parameters​

NameType
Textends CommonWorkflowOptions

Parameters​

NameType
optionsT

Returns​

WithCompiledWorkflowOptions<T>


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


fromPayloadsAtIndex​

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

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

Throws

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

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


mapFromPayloads​

β–Έ mapFromPayloads<K>(converter, map?): Record<K, unknown> | undefined | null

Type parameters​

NameType
Kextends string

Parameters​

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

Returns​

Record<K, unknown> | undefined | null


mapToPayloads​

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

Run toPayload on each value in the map.

Throws

ValueError if conversion of any value in the map fails

Type parameters​

NameType
Kextends string

Parameters​

NameType
converterPayloadConverter
mapRecord<K, any>

Returns​

Record<K, Payload>


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.

Throws

ValueError if conversion of the value passed as parameter failed for any reason.

Parameters​

NameTypeDescription
converterPayloadConverter
...valuesunknown[]JS values to convert to Payloads

Returns​

Payload[] | undefined

list of Payloads