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>


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


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


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