Constructs a Client and lazy plaintext gRPC connection.
Flow definitions used for validation and routing.
Open cache used to hydrate large response values.
Service address and optional bearer credential.
ReadonlyblobOpen cache used to hydrate large response values.
ReadonlyoptionsService address and optional bearer credential.
ReadonlyregistryFlow definitions used for validation and routing.
Closes the owned FlowService connection. Registry and BlobCache ownership remains with the caller.
Returns summary metadata for the current or latest Flow run.
Non-empty existing Flow ID.
Flow ID, run ID, type, status, and UTC start time.
Reads committed Attribute and AttributeMap instance values from the current or latest Flow run.
Use getAttributes to read Flow state from outside the Flow without defining an RPC. Pass one
read per value: a singleton Attribute, or an AttributeMap instance selected with
AttributeMap.instance. The returned Promise resolves to a tuple with one element per
read, in read order. Each element has the read's value type, or undefined when that Attribute
or AttributeMap instance is not set. Writing null or undefined deletes an Attribute, so it
then reads as undefined. A stored value that its codec decodes to null stays null. Falsy
values such as "", 0n, and false are set values.
The Client sends all keys in one FlowService request, so every value comes from the same committed state. No Worker runs. The read targets the current run, or the latest run when no run is open. A closed run stays readable until Dex purges it. The call sees only committed state. It does not see writes staged by an RPC or Step that is still running, unlike an Attribute read inside an RPC handler.
Hard-delete Attributes from Attribute.hardDeleteOnNull are supported; Dex returns their current stored values. The Client hydrates large values through LoadBlobs and its BlobCache, then decodes every value with its definition's codec. The Promise resolves only after every value decodes. On any error it rejects and returns no values.
Every definition must be registered by some Flow in this Client's Registry. Registered means
the exact definition object returned by that Flow's getPersistenceSchema. A different object
with the same name, such as one with another codec or one created by calling
hardDeleteOnNull() again, is rejected. The definition need not belong to the target Flow's
type; Dex reads the key by name. A same-named Attribute with another value type in the target
Flow fails to decode.
The reads parameter requires at least one read at compile time. A plain array can be empty, so
spreading it alone does not compile. Pass its first read separately, as in
client.getAttributes(flowId, first, ...rest). The result then has one element for first,
followed by one element per read in rest.
Tuple of reads. TypeScript infers it from the arguments, and the result
tuple maps each read to its value type or undefined.
Non-empty Flow ID.
At least one Attribute or AttributeMap instance selection. Two reads of the same Attribute or AttributeMap instance are rejected.
A tuple with one decoded value or undefined per read, in read order.
type Note = { readonly text: string };
const orderStatus = new Attribute("order-status", stringCodec);
const notes = new AttributeMap("notes", jsonCodec<Note>());
// Register orderStatus and notes in a Flow's getPersistenceSchema.
try {
const [status, note] = await client.getAttributes(
"order-42",
orderStatus,
notes.instance("n1"),
);
console.log(status ?? "new", note?.text ?? "no note yet");
} catch (error) {
if (error instanceof FlowNotFoundError) {
console.log(`order ${error.flowId} does not exist`);
} else {
throw error;
}
}
TypeError before any request when flowId is empty, no read is passed, a read
is not an Attribute or AttributeMap instance selection, or two reads select the same value.
FlowDefinitionError before any request when a definition is not registered by a Flow in the Client's Registry, or differs from the registered definition object.
FlowNotFoundError when the Flow does not exist or its latest run is being purged.
ValueMappingError when a value cannot be hydrated or decoded with its codec.
DexServiceError for other FlowService failures, including a failed LoadBlobs
request. The error keeps the gRPC code and the server detail, and its operation is
loadBlobs for a LoadBlobs failure.
Invokes an RPC with typed input and output. A non-transactional RPC without Attribute locks starts from a backend query. A retained terminal execution can serve it when the handler returns no durable effects. Locks, transactional execution, returned effects, or server policy can require an active execution.
RPC input type.
RPC output type.
Bound method decorated with rpc on the registered Flow.
Non-empty target Flow ID.
Typed handler input.
OptionalrunId: stringOptional exact run; the server resolves the current execution when omitted.
The decoded RPCResult output.
Invokes an input-free RPC with typed output. A retained terminal execution can serve a query-only RPC. Other execution paths can require an active execution.
RPC output type.
The decoded RPCResult output.
Invokes a typed-input RPC that returns no output. A retained terminal execution can serve a query-only RPC. Other execution paths can require an active execution.
RPC input type.
A promise resolved after successful handler completion.
Invokes an input-free, output-free RPC. A retained terminal execution can serve a query-only RPC. Other execution paths can require an active execution.
Bound method decorated with rpc on the registered Flow.
Non-empty target Flow ID.
OptionalrunId: stringOptional exact run; the server resolves the current execution when omitted.
A promise resolved after successful handler completion.
Invokes an input-bearing RPC with additive runtime map-instance selections.
RPC input type.
RPC output type.
Bound method decorated with rpc on the registered Flow.
Non-empty target Flow ID.
Typed handler input.
Runtime AttributeMap locks and exact map-instance loads.
OptionalrunId: stringOptional exact run; the server resolves the current execution when omitted.
The decoded RPCResult output.
Invokes an input-free RPC with additive runtime map-instance selections.
RPC output type.
Bound method decorated with rpc on the registered Flow.
Non-empty target Flow ID.
Runtime AttributeMap locks and exact map-instance loads.
OptionalrunId: stringOptional exact run; the server resolves the current execution when omitted.
The decoded RPCResult output.
Invokes an input-bearing, output-free RPC with runtime map-instance selections.
RPC input type.
Bound method decorated with rpc on the registered Flow.
Non-empty target Flow ID.
Typed handler input.
Runtime AttributeMap locks and exact map-instance loads.
OptionalrunId: stringOptional exact run; the server resolves the current execution when omitted.
A promise resolved after successful handler completion.
Invokes an input-free, output-free RPC with runtime map-instance selections.
Bound method decorated with rpc on the registered Flow.
Non-empty target Flow ID.
Runtime AttributeMap locks and exact map-instance loads.
OptionalrunId: stringOptional exact run; the server resolves the current execution when omitted.
A promise resolved after successful handler completion.
Returns one newest-first page of retained Stream messages without waiting for writes.
An empty token starts at the retained tail. Pass nextPageToken unchanged to read the next,
older page. Stream trimming may remove messages between pages.
Stream message type.
Logical Flow instance ID used as the Stream instance key.
Stream registered in exactly one Flow schema.
Positive maximum count within the server-configured limit.
Opaque token from the preceding page, or empty for the first page.
Decoded messages in newest-first order and the next-page token.
Returns the next retained Stream message after an opaque resume token.
Stream message type.
Logical Flow instance ID used as the Stream instance key.
Stream registered in exactly one Flow schema.
Previous message token, or empty to start at the retained head.
OptionaltimeoutMs: numberOptional server-side long-poll duration in milliseconds.
Decoded value and resumable metadata for one retained message.
Returns one page of Flow runs matching a visibility query.
Dex visibility query; empty uses server defaults.
Non-negative requested maximum result count.
Opaque token from the preceding page, or empty first.
Whether to include earlier Continue-as-New runs; defaults to exclusion.
Server-ordered entries and the next-page token.
Makes one waiting Timer condition immediately ready.
Non-empty active Flow ID.
Step type and positive execution number.
Exactly one Timer condition ID or zero-based index.
Starts a Flow and returns after Dex accepts it.
Starting Step input type.
Exact Flow instance registered with this Client.
Non-empty application ID stable across runs.
Starting Step input, or undefined when no start Step exists.
Timeout, reuse, retry, configuration, and initial state.
The server-assigned run ID.
FlowAlreadyStartedError when reuse policy rejects the Flow ID.
FlowDefinitionError when flow is not registered.
ValueMappingError when a hard-delete initial value encodes to a number or Boolean.
Requests cancellation, termination, or failure of an active Flow. The promise resolves after acceptance and does not await terminal status.
Non-empty active Flow ID.
Stop mode and optional recorded reason.
Creates a new run from a selected point in existing Flow history.
Non-empty Flow ID whose history supplies the new run.
Time travel selector, reason, and replay controls.
The new server-assigned run ID; the Flow ID remains unchanged.
Requests that an active Flow roll its history into a new run. The Flow ID stays the same; the request returns after Dex accepts it.
Non-empty active Flow ID.
Updates mutable configuration for an active Flow. The update affects later decisions and does not recall dispatched work. Updates preserve the existing Worker target, including when config is empty.
Non-empty active Flow ID.
New optional Flow configuration fields.
Waits until a singleton Attribute in the current run satisfies a match. Returns the current value observed by the successful wait operation. The server derives a stable Request ID from the condition when none is supplied. Request timeout covers transport reattachments. Internal handler timeout rolls generations.
Attribute value type.
Non-empty active Flow ID.
Registered singleton Attribute to observe.
Scalar predicate whose operand has the Attribute value type.
Optional Request ID override and request and internal handler timeout controls.
The matched current Attribute value.
TypeError when attribute uses Attribute.hardDeleteOnNull; no request is sent.
Waits until one AttributeMap instance in the current run satisfies a match.
Primitive-value restrictions, options, and timeout errors match waitForAttributeMatch.
AttributeMap value type.
Non-empty active Flow ID.
Registered AttributeMap to observe.
The map instance to observe. Slash is prohibited because it is a reserved character.
Scalar predicate whose operand has the AttributeMap value type.
Optional Request ID override and request and internal handler timeout controls.
The matched current AttributeMap value.
TypeError when attribute uses AttributeMap.hardDeleteOnNull; no request is sent.
Long-polls until a Flow closes and returns every output-bearing completion.
Non-empty existing Flow ID.
OptionaltimeoutMs: numberOptional server-side long-poll duration in milliseconds.
Immutable Step completions in server collection order.
LongPollTimeoutError when the Flow remains open at timeout.
ValueMappingError when Dex returns malformed blob-backed output.
Waits until one Step execution completes or its request budget expires. The server derives a stable Request ID from the Step execution when none is supplied.
Non-empty active Flow ID.
Step type and positive execution number.
Optional Request ID, request timeout, and internal handler timeout.
RequestTimeoutError when a positive request timeout expires first.
Appends one typed best-effort Stream message with source metadata.
Stream message type.
Calls Dex FlowService through registered, typed Flow definitions.
Methods perform asynchronous gRPC I/O. A Client owns its service connection but not its Registry or BlobCache; call
closeduring application shutdown.Example