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


RetryPolicy​

Re-exports RetryPolicy

Type aliases​

ActivityInterface​

Ζ¬ ActivityInterface: Record<string, ActivityFunction<any[], any>>

Mapping of Activity name to function


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


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


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[]


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


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


errorCode​

β–Έ errorCode(error): string | undefined

Get error code from an Error or return undefined

Parameters​

NameType
errorunknown

Returns​

string | undefined


errorMessage​

β–Έ errorMessage(err): string | undefined

Get error message from an Error or string or return undefined

Parameters​

NameType
errunknown

Returns​

string | undefined


errorToFailure​

β–Έ errorToFailure(err, payloadConverter): ProtoFailure

Converts a caught error to a Failure proto message

Parameters​

NameType
errunknown
payloadConverterPayloadConverter

Returns​

ProtoFailure


failureToError​

β–Έ failureToError(failure, payloadConverter): TemporalFailure

Converts a Failure proto message to a JS Error object.

Parameters​

NameType
failureIFailure
payloadConverterPayloadConverter

Returns​

TemporalFailure


failureToErrorInner​

β–Έ failureToErrorInner(failure, payloadConverter): TemporalFailure

Converts a Failure proto message to a JS Error object.

Does not set common properties, that is done in failureToError.

Parameters​

NameType
failureIFailure
payloadConverterPayloadConverter

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 PayloadConverter.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>


msNumberToTs​

β–Έ msNumberToTs(millis): Timestamp

Parameters​

NameType
millisnumber

Returns​

Timestamp


msOptionalToNumber​

β–Έ msOptionalToNumber(val): number | undefined

Parameters​

NameType
valundefined | string | number

Returns​

number | undefined


msOptionalToTs​

β–Έ msOptionalToTs(str): Timestamp | undefined

Parameters​

NameType
strundefined | string | number

Returns​

Timestamp | undefined


msToNumber​

β–Έ msToNumber(val): number

Parameters​

NameType
valstring | number

Returns​

number


msToTs​

β–Έ msToTs(str): Timestamp

Parameters​

NameType
strstring | number

Returns​

Timestamp


optionalErrorToOptionalFailure​

β–Έ optionalErrorToOptionalFailure(err, payloadConverter): ProtoFailure | undefined

Converts an error to a Failure proto message if defined or returns undefined

Parameters​

NameType
errunknown
payloadConverterPayloadConverter

Returns​

ProtoFailure | undefined


optionalFailureToOptionalError​

β–Έ optionalFailureToOptionalError(failure, payloadConverter): TemporalFailure | undefined

Converts a Failure proto message to a JS Error object if defined or returns undefined.

Parameters​

NameType
failureundefined | null | IFailure
payloadConverterPayloadConverter

Returns​

TemporalFailure | undefined


optionalTsToDate​

β–Έ optionalTsToDate(ts): Date | undefined

Parameters​

NameType
tsundefined | null | ITimestamp

Returns​

Date | undefined


optionalTsToMs​

β–Έ optionalTsToMs(ts): number | undefined

Lossy conversion function from Timestamp to number due to possible overflow. If ts is null or undefined returns undefined.

Parameters​

NameType
tsundefined | null | ITimestamp

Returns​

number | undefined


rootCause​

β–Έ rootCause(err): string | undefined

Get the root cause (string) of given error err.

In case err is a TemporalFailure, recurse the cause chain and return the root's message. Otherwise, return err.message.

Parameters​

NameType
errunknown

Returns​

string | undefined


str​

β–Έ str(a): string

Parameters​

NameType
aUint8Array

Returns​

string


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


tsToDate​

β–Έ tsToDate(ts): Date

Parameters​

NameType
tsITimestamp

Returns​

Date


tsToMs​

β–Έ tsToMs(ts): number

Lossy conversion function from Timestamp to number due to possible overflow

Parameters​

NameType
tsundefined | null | ITimestamp

Returns​

number


u8​

β–Έ u8(s): Uint8Array

Transform an ascii string into a Uint8Array

Parameters​

NameType
sstring

Returns​

Uint8Array