@superdurable/dex 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +55 -3
  2. package/dist/src/attribute-store-sync.d.ts +5 -0
  3. package/dist/src/attribute-store-sync.js +19 -0
  4. package/dist/src/attribute-store-sync.js.map +1 -0
  5. package/dist/src/blob-cache.d.ts +36 -0
  6. package/dist/src/blob-cache.js +13 -0
  7. package/dist/src/blob-cache.js.map +1 -1
  8. package/dist/src/client.d.ts +183 -4
  9. package/dist/src/client.js +152 -37
  10. package/dist/src/client.js.map +1 -1
  11. package/dist/src/codec.d.ts +73 -0
  12. package/dist/src/codec.js +23 -0
  13. package/dist/src/codec.js.map +1 -1
  14. package/dist/src/context.d.ts +80 -0
  15. package/dist/src/errors.d.ts +122 -6
  16. package/dist/src/errors.js +139 -9
  17. package/dist/src/errors.js.map +1 -1
  18. package/dist/src/flow.d.ts +36 -1
  19. package/dist/src/flow.js +96 -28
  20. package/dist/src/flow.js.map +1 -1
  21. package/dist/src/gen/dex.d.ts +58 -9
  22. package/dist/src/gen/dex.js +417 -55
  23. package/dist/src/gen/dex.js.map +1 -1
  24. package/dist/src/grpc-status.d.ts +5 -4
  25. package/dist/src/grpc-status.js +52 -6
  26. package/dist/src/grpc-status.js.map +1 -1
  27. package/dist/src/invocation-context.js +3 -0
  28. package/dist/src/invocation-context.js.map +1 -1
  29. package/dist/src/options.d.ts +150 -1
  30. package/dist/src/options.js +53 -0
  31. package/dist/src/options.js.map +1 -1
  32. package/dist/src/persistence.d.ts +103 -0
  33. package/dist/src/persistence.js +98 -0
  34. package/dist/src/persistence.js.map +1 -1
  35. package/dist/src/rpc.d.ts +53 -0
  36. package/dist/src/rpc.js +17 -0
  37. package/dist/src/rpc.js.map +1 -1
  38. package/dist/src/step.d.ts +162 -0
  39. package/dist/src/step.js +85 -0
  40. package/dist/src/step.js.map +1 -1
  41. package/dist/src/value-mapper.js +48 -18
  42. package/dist/src/value-mapper.js.map +1 -1
  43. package/dist/src/wait.d.ts +180 -0
  44. package/dist/src/wait.js +157 -0
  45. package/dist/src/wait.js.map +1 -1
  46. package/dist/src/worker-dispatcher.js +52 -26
  47. package/dist/src/worker-dispatcher.js.map +1 -1
  48. package/dist/src/worker.d.ts +30 -1
  49. package/dist/src/worker.js +48 -2
  50. package/dist/src/worker.js.map +1 -1
  51. package/native/linux-aarch64/dex_blob_cache_node.node +0 -0
  52. package/native/linux-x86_64/dex_blob_cache_node.node +0 -0
  53. package/native/macos-aarch64/dex_blob_cache_node.node +0 -0
  54. package/native/macos-x86_64/dex_blob_cache_node.node +0 -0
  55. package/native/windows-x86_64/dex_blob_cache_node.node +0 -0
  56. package/package.json +2 -1
package/README.md CHANGED
@@ -26,7 +26,7 @@ class ApproveOrder implements Step<string> {
26
26
  }
27
27
 
28
28
  waitFor(_context: Context, _orderId: string): Wait {
29
- return Wait.allOf(Timer.byDuration(1_000));
29
+ return Wait.until(Timer.byDuration(1_000));
30
30
  }
31
31
 
32
32
  execute(_context: Context, orderId: string): StepDecision {
@@ -59,9 +59,28 @@ heterogeneous Steps with `.otherSteps(...)`. Use
59
59
  Non-starting Steps may use unrelated input types. `Flow` defaults to `void` for
60
60
  Flows without a start input.
61
61
 
62
+ `Worker.start()` synchronizes every registered Indexed Attribute with Dex
63
+ Server before binding its listener. Existing indexes return immediately;
64
+ failure or the default 120-second deadline aborts startup. An indexed
65
+ `AttributeMap` must provide one fixed `indexKey`.
66
+
62
67
  `StepOptions.waitForMethodTimeoutMs` and `executeMethodTimeoutMs` bound the two
63
68
  handler calls. Timer and channel conditions determine how long a Step waits.
64
69
 
70
+ Opt an Attribute or AttributeMap into Attribute Store synchronization, then
71
+ select the Server-configured Store for the Flow:
72
+
73
+ ```typescript
74
+ const email = new Attribute("customer-email", stringCodec)
75
+ .syncToAttributeStore();
76
+ const config: FlowConfig = { attributeStoreName: "profiles" };
77
+ ```
78
+
79
+ The Store is an asynchronous latest-state projection. Deletion writes SQL
80
+ `NULL`, and projection failures do not roll back Flow Attributes. Omitting
81
+ `attributeStoreName` preserves the current target; `attributeStoreName: ""`
82
+ disables future synchronization while retaining protocol presence.
83
+
65
84
  ### Async handlers
66
85
 
67
86
  `Step.execute`, `Step.waitFor`, and RPC methods may be `async` and return a
@@ -93,6 +112,33 @@ Every TypeScript Flow and Step must return an explicit durable name from
93
112
  `getFlowType()` or `getStepType()`. Class names are never used as fallbacks
94
113
  because bundlers and minifiers may rename them.
95
114
 
115
+ ## Errors
116
+
117
+ Client calls reject with concrete `DexServiceError` subclasses. Existing-Flow
118
+ reads (`getAttribute`, `describeFlow`, `waitForFlow`, and `resetFlow`) use
119
+ `FlowNotFoundError`; operations that require a running Flow use
120
+ `FlowNotActiveError`. Start conflicts, worker failures, RPC lock contention,
121
+ and long-poll timeouts use `FlowAlreadyStartedError`,
122
+ `WorkerInvocationError`, `RpcLockConflictError`, and `LongPollTimeoutError`.
123
+
124
+ ```typescript
125
+ try {
126
+ await client.publish(flowId, orders.approved, orderId);
127
+ } catch (error) {
128
+ if (error instanceof FlowNotActiveError) {
129
+ // The Flow is missing or already closed.
130
+ } else {
131
+ throw error;
132
+ }
133
+ }
134
+ ```
135
+
136
+ Every service error retains `code`, `subStatus`, `detail`, `operation`,
137
+ `flowId`, and the original gRPC error as `cause`. `WorkerInvocationError` also
138
+ retains `workerCode`, `workerErrorType`, and `workerErrorDetail`. Registration,
139
+ serialization, and invalid handler returns use `FlowDefinitionError`,
140
+ `ValueMappingError`, and `InvalidStepResultError` instead of transport errors.
141
+
96
142
  ## Source layout
97
143
 
98
144
  Public contracts are grouped by domain under `src/`. The root `src/index.ts`
@@ -113,8 +159,14 @@ continue importing only from `@superdurable/dex`.
113
159
  - `gen/`: checked-in protobuf and grpc-js bindings
114
160
 
115
161
  Run `npm run build:native` once to stage the DXBC Node addon for the current
116
- platform, then `npm test` for runtime contracts and `npm run typecheck` for
117
- strict static contracts. Run `./run-integration-tests.sh` for all 58 IWF
162
+ platform, then `npm test` for runtime contracts, `npm run typecheck` for strict
163
+ static contracts, and `npm run docs:check` for public API documentation. The
164
+ documentation check follows the actual exports of `src/index.ts` and requires
165
+ JSDoc for every public class, interface, type, overload, member, object-style
166
+ enum value, type parameter, input, and output; generated sources are excluded.
167
+ The comments appear in TypeScript language-service and IDE hovers.
168
+
169
+ Run `./run-integration-tests.sh` for all 58 IWF
118
170
  compatibility scenarios against an isolated `dexcli dev` environment. Run
119
171
  `npm run generate:proto` after changing `protos/dex.proto`; `protoc` and its
120
172
  standard protobuf includes must be installed.
@@ -0,0 +1,5 @@
1
+ import type { AttributeSyncConfig } from "./gen/dex.js";
2
+ import type { FlowConfig } from "./options.js";
3
+ export declare function markAttributeStoreSynced<Definition extends object>(definition: Definition): Definition;
4
+ export declare function mapAttributeStoreSync(definition: object): AttributeSyncConfig | undefined;
5
+ export declare function mapAttributeStoreName(config: FlowConfig | undefined): string | undefined;
@@ -0,0 +1,19 @@
1
+ // Copyright (c) 2026 Super Durable, Inc.
2
+ //
3
+ // Licensed under the Super Durable Source License 1.0.
4
+ // You may not use this file except in compliance with the License.
5
+ // See the LICENSE file in the repository root.
6
+ //
7
+ // SPDX-License-Identifier: LicenseRef-Super-Durable-1.0
8
+ const syncedDefinitions = new WeakSet();
9
+ export function markAttributeStoreSynced(definition) {
10
+ syncedDefinitions.add(definition);
11
+ return definition;
12
+ }
13
+ export function mapAttributeStoreSync(definition) {
14
+ return syncedDefinitions.has(definition) ? { enabled: true } : undefined;
15
+ }
16
+ export function mapAttributeStoreName(config) {
17
+ return config?.attributeStoreName;
18
+ }
19
+ //# sourceMappingURL=attribute-store-sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribute-store-sync.js","sourceRoot":"","sources":["../../src/attribute-store-sync.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,uDAAuD;AACvD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,wDAAwD;AAKxD,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAU,CAAC;AAEhD,MAAM,UAAU,wBAAwB,CACtC,UAAsB;IAEtB,iBAAiB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAClC,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,UAAkB;IAElB,OAAO,iBAAiB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAA8B;IAClE,OAAO,MAAM,EAAE,kBAAkB,CAAC;AACpC,CAAC"}
@@ -1,14 +1,50 @@
1
+ /** Configures the local persistent cache for large Dex values. */
1
2
  export interface BlobCacheConfig {
3
+ /** Writable directory used for cache payloads and metadata. */
2
4
  readonly directory: string;
5
+ /** Positive maximum on-disk payload size in bytes. */
3
6
  readonly maxBytes: number;
7
+ /** Admission-policy counter count; zero or `undefined` uses the native default. */
4
8
  readonly frequencyCounters?: number;
5
9
  }
10
+ /** Provides concurrent, bounded storage for content-addressed Dex blobs. */
6
11
  export interface BlobCache {
12
+ /** Effective configuration used by this cache. */
7
13
  readonly config: BlobCacheConfig;
14
+ /**
15
+ * Reads a cached payload without contacting Dex.
16
+ * @param blobId - Opaque server-assigned blob identifier.
17
+ * @returns A copied payload, or `undefined` when absent.
18
+ */
8
19
  get(blobId: string): Uint8Array | undefined;
20
+ /**
21
+ * Offers a payload to the bounded cache.
22
+ * @param blobId - Opaque server-assigned blob identifier.
23
+ * @param payload - Bytes copied into native storage.
24
+ * @returns `true` when admitted or `false` when rejected by policy.
25
+ */
9
26
  put(blobId: string, payload: Uint8Array): boolean;
27
+ /**
28
+ * Deletes one cached payload when present.
29
+ * @param blobId - Opaque identifier to remove.
30
+ */
10
31
  delete(blobId: string): void;
32
+ /** Deletes every payload while keeping the cache open. */
11
33
  deleteAll(): void;
34
+ /** Flushes metadata and releases native resources; repeated calls are safe. */
12
35
  close(): void;
13
36
  }
37
+ /**
38
+ * Opens or creates a native BlobCache owned by the caller.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * const cache = openBlobCache({ directory: ".dex-cache", maxBytes: 64 * 1024 ** 2 });
43
+ * try { cache.put("blob-1", new Uint8Array([1, 2])); } finally { cache.close(); }
44
+ * ```
45
+ * @param config - Directory, positive byte capacity, and optional counter count.
46
+ * @returns An open cache that must be closed at application shutdown.
47
+ * @throws {@link TypeError} when the directory is empty.
48
+ * @throws {@link RangeError} when a numeric setting is invalid.
49
+ */
14
50
  export declare function openBlobCache(config: BlobCacheConfig): BlobCache;
@@ -10,6 +10,19 @@ import { dirname, join } from "node:path";
10
10
  import { fileURLToPath } from "node:url";
11
11
  const require = createRequire(import.meta.url);
12
12
  let nativeModule;
13
+ /**
14
+ * Opens or creates a native BlobCache owned by the caller.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const cache = openBlobCache({ directory: ".dex-cache", maxBytes: 64 * 1024 ** 2 });
19
+ * try { cache.put("blob-1", new Uint8Array([1, 2])); } finally { cache.close(); }
20
+ * ```
21
+ * @param config - Directory, positive byte capacity, and optional counter count.
22
+ * @returns An open cache that must be closed at application shutdown.
23
+ * @throws {@link TypeError} when the directory is empty.
24
+ * @throws {@link RangeError} when a numeric setting is invalid.
25
+ */
13
26
  export function openBlobCache(config) {
14
27
  if (config.directory.length === 0) {
15
28
  throw new TypeError("blob cache directory is required");
@@ -1 +1 @@
1
- {"version":3,"file":"blob-cache.js","sourceRoot":"","sources":["../../src/blob-cache.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,uDAAuD;AACvD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,wDAAwD;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,O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owConfig, type FlowInfo, type ResetFlowOptio
6
6
  import { AttributeMap, type Attribute } from "./persistence.js";
7
7
  import type { RPCResult } from "./rpc.js";
8
8
  import { ChannelMap, type Channel } from "./wait.js";
9
+ /**
10
+ * Calls Dex FlowService through registered, typed Flow definitions.
11
+ *
12
+ * Methods perform asynchronous gRPC I/O. A Client owns its service connection but
13
+ * not its Registry or BlobCache; call `close` during application shutdown.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const client = new Client(registry, cache);
18
+ * try {
19
+ * const runId = await client.startFlow(orders, "order-42", input);
20
+ * const result = await client.waitForFlow("order-42", orderResultCodec);
21
+ * } finally { await client.close(); }
22
+ * ```
23
+ */
9
24
  export declare class Client {
10
25
  readonly registry: Registry;
11
26
  readonly blobCache: BlobCache;
12
27
  readonly options: ClientOptions;
13
28
  private readonly service;
14
29
  private readonly hydrator;
30
+ /**
31
+ * Constructs a Client and lazy plaintext gRPC connection.
32
+ * @param registry - Flow definitions used for validation and routing.
33
+ * @param blobCache - Open cache used to hydrate large response values.
34
+ * @param options - Service address and default Worker target.
35
+ */
15
36
  constructor(registry: Registry, blobCache: BlobCache, options?: ClientOptions);
37
+ /**
38
+ * Starts a Flow and returns after Dex accepts it.
39
+ * @typeParam StartInput - Starting Step input type.
40
+ * @param flow - Exact Flow instance registered with this Client.
41
+ * @param flowId - Non-empty application ID stable across runs.
42
+ * @param input - Starting Step input, or `undefined` when no start Step exists.
43
+ * @param options - Timeout, reuse, retry, configuration, and initial state.
44
+ * @returns The server-assigned run ID.
45
+ * @throws {@link FlowAlreadyStartedError} when reuse policy rejects the Flow ID.
46
+ * @throws {@link FlowDefinitionError} when `flow` is not registered.
47
+ */
16
48
  startFlow<StartInput>(flow: Flow<StartInput>, flowId: string, input: StartInput, options?: StartFlowOptions): Promise<string>;
17
- invokeRPC<Input, Output>(rpcMethod: (context: Context, input: Input) => RPCResult<Output>, flowId: string, input: Input, runId?: string): Promise<Output>;
18
- invokeRPC<Output>(rpcMethod: (context: Context) => RPCResult<Output>, flowId: string, runId?: string): Promise<Output>;
19
- invokeRPC<Input>(rpcMethod: (context: Context, input: Input) => void, flowId: string, input: Input, runId?: string): Promise<void>;
20
- invokeRPC(rpcMethod: (context: Context) => void, flowId: string, runId?: string): Promise<void>;
49
+ /**
50
+ * Invokes an RPC with typed input and output.
51
+ * @typeParam Input - RPC input type.
52
+ * @typeParam Output - RPC output type.
53
+ * @param rpcMethod - Bound method decorated with `rpc` on the registered Flow.
54
+ * @param flowId - Non-empty target Flow ID.
55
+ * @param input - Typed handler input.
56
+ * @param runId - Optional exact run; targets the active run when omitted.
57
+ * @returns The decoded RPCResult output.
58
+ */
59
+ invokeRPC<Input, Output>(rpcMethod: (context: Context, input: Input) => RPCResult<Output> | Promise<RPCResult<Output>>, flowId: string, input: Input, runId?: string): Promise<Output>;
60
+ /**
61
+ * Invokes an input-free RPC with typed output.
62
+ * @typeParam Output - RPC output type.
63
+ * @param rpcMethod - Bound method decorated with `rpc` on the registered Flow.
64
+ * @param flowId - Non-empty target Flow ID.
65
+ * @param runId - Optional exact run; targets the active run when omitted.
66
+ * @returns The decoded RPCResult output.
67
+ */
68
+ invokeRPC<Output>(rpcMethod: (context: Context) => RPCResult<Output> | Promise<RPCResult<Output>>, flowId: string, runId?: string): Promise<Output>;
69
+ /**
70
+ * Invokes a typed-input RPC that returns no output.
71
+ * @typeParam Input - RPC input type.
72
+ * @param rpcMethod - Bound method decorated with `rpc` on the registered Flow.
73
+ * @param flowId - Non-empty target Flow ID.
74
+ * @param input - Typed handler input.
75
+ * @param runId - Optional exact run; targets the active run when omitted.
76
+ * @returns A promise resolved after successful handler completion.
77
+ */
78
+ invokeRPC<Input>(rpcMethod: (context: Context, input: Input) => void | Promise<void>, flowId: string, input: Input, runId?: string): Promise<void>;
79
+ /**
80
+ * Invokes an input-free, output-free RPC.
81
+ * @param rpcMethod - Bound method decorated with `rpc` on the registered Flow.
82
+ * @param flowId - Non-empty target Flow ID.
83
+ * @param runId - Optional exact run; targets the active run when omitted.
84
+ * @returns A promise resolved after successful handler completion.
85
+ */
86
+ invokeRPC(rpcMethod: (context: Context) => void | Promise<void>, flowId: string, runId?: string): Promise<void>;
87
+ /**
88
+ * Reads a singleton Attribute.
89
+ * @typeParam T - Attribute value type.
90
+ * @param flowId - Non-empty existing Flow ID.
91
+ * @param attribute - Typed singleton Attribute definition.
92
+ * @param runId - Optional exact run; targets the current run when omitted.
93
+ * @returns The decoded value, or `undefined` when unset.
94
+ */
21
95
  getAttribute<T>(flowId: string, attribute: Attribute<T>, runId?: string): Promise<T | undefined>;
96
+ /**
97
+ * Reads one AttributeMap instance.
98
+ * @typeParam T - Attribute value type.
99
+ * @param flowId - Non-empty existing Flow ID.
100
+ * @param attribute - Typed AttributeMap definition.
101
+ * @param instance - Non-empty logical map key.
102
+ * @param runId - Optional exact run; targets the current run when omitted.
103
+ * @returns The decoded value, or `undefined` when unset.
104
+ */
22
105
  getAttribute<T>(flowId: string, attribute: AttributeMap<T>, instance: string, runId?: string): Promise<T | undefined>;
106
+ /**
107
+ * Writes a singleton Attribute on an active Flow.
108
+ * @typeParam T - Attribute value type.
109
+ * @param flowId - Non-empty active Flow ID.
110
+ * @param attribute - Typed singleton Attribute definition.
111
+ * @param value - Value encoded by the Attribute codec.
112
+ * @param runId - Optional exact run; targets the active run when omitted.
113
+ * @returns A promise resolved after Dex applies the write.
114
+ */
23
115
  setAttribute<T>(flowId: string, attribute: Attribute<T>, value: T, runId?: string): Promise<void>;
116
+ /**
117
+ * Writes one AttributeMap instance on an active Flow.
118
+ * @typeParam T - Attribute value type.
119
+ * @param flowId - Non-empty active Flow ID.
120
+ * @param attribute - Typed AttributeMap definition.
121
+ * @param instance - Non-empty logical map key.
122
+ * @param value - Value encoded by the Attribute codec.
123
+ * @param runId - Optional exact run; targets the active run when omitted.
124
+ * @returns A promise resolved after Dex applies the write.
125
+ */
24
126
  setAttribute<T>(flowId: string, attribute: AttributeMap<T>, instance: string, value: T, runId?: string): Promise<void>;
127
+ /**
128
+ * Publishes one or more values to a singleton Channel.
129
+ * @typeParam T - Channel element type.
130
+ * @param flowId - Non-empty active Flow ID.
131
+ * @param channel - Typed singleton Channel definition.
132
+ * @param values - Values appended in argument order.
133
+ * @returns A promise resolved after Dex accepts the batch.
134
+ */
25
135
  publish<T>(flowId: string, channel: Channel<T>, ...values: readonly T[]): Promise<void>;
136
+ /**
137
+ * Publishes one or more values to a ChannelMap instance.
138
+ * @typeParam T - Channel element type.
139
+ * @param flowId - Non-empty active Flow ID.
140
+ * @param channel - Typed ChannelMap definition.
141
+ * @param instance - Non-empty logical map key.
142
+ * @param values - Values appended in argument order.
143
+ * @returns A promise resolved after Dex accepts the batch.
144
+ */
26
145
  publish<T>(flowId: string, channel: ChannelMap<T>, instance: string, ...values: readonly T[]): Promise<void>;
146
+ /**
147
+ * Waits for successful Flow completion without decoding output.
148
+ * @param flowId - Non-empty existing Flow ID.
149
+ * @returns A promise resolved on successful completion.
150
+ */
27
151
  waitForFlow(flowId: string): Promise<void>;
152
+ /**
153
+ * Waits for successful Flow completion and decodes the latest Step output.
154
+ * @typeParam Output - Expected completion output type.
155
+ * @param flowId - Non-empty existing Flow ID.
156
+ * @param outputCodec - Codec for the expected output.
157
+ * @param timeoutMs - Optional server-side long-poll duration in milliseconds.
158
+ * @returns The decoded latest completed Step output.
159
+ */
28
160
  waitForFlow<Output>(flowId: string, outputCodec: Codec<Output>, timeoutMs?: number): Promise<Output>;
161
+ /**
162
+ * Requests cancellation, termination, or failure of an active Flow.
163
+ * The promise resolves after acceptance and does not await terminal status.
164
+ * @param flowId - Non-empty active Flow ID.
165
+ * @param options - Stop mode and optional recorded reason.
166
+ */
29
167
  stopFlow(flowId: string, options?: StopFlowOptions): Promise<void>;
168
+ /**
169
+ * Returns summary metadata for the current or latest Flow run.
170
+ * @param flowId - Non-empty existing Flow ID.
171
+ * @returns Flow ID, run ID, type, status, and UTC start time.
172
+ */
30
173
  describeFlow(flowId: string): Promise<FlowInfo>;
174
+ /**
175
+ * Returns one page of Flow runs matching a visibility query.
176
+ * @param query - Dex visibility query; empty uses server defaults.
177
+ * @param pageSize - Non-negative requested maximum result count.
178
+ * @param nextPageToken - Opaque token from the preceding page, or empty first.
179
+ * @returns Server-ordered entries and the next-page token.
180
+ */
31
181
  searchFlows(query: string, pageSize: number, nextPageToken?: string): Promise<SearchFlowsPage>;
32
182
  private mapSearchEntry;
183
+ /**
184
+ * Creates a new run from a selected point in existing Flow history.
185
+ * @param flowId - Non-empty Flow ID whose history is reset.
186
+ * @param options - Reset selector, reason, and replay controls.
187
+ * @returns The new server-assigned run ID; the Flow ID remains unchanged.
188
+ */
33
189
  resetFlow(flowId: string, options: ResetFlowOptions): Promise<string>;
190
+ /**
191
+ * Makes one waiting Timer condition immediately ready.
192
+ * @param flowId - Non-empty active Flow ID.
193
+ * @param stepExecutionId - Step type and positive execution number.
194
+ * @param timerId - Exactly one Timer condition ID or zero-based index.
195
+ */
34
196
  skipTimer(flowId: string, stepExecutionId: StepExecutionId, timerId: TimerId): Promise<void>;
197
+ /**
198
+ * Long-polls until one Step execution completes.
199
+ * @param flowId - Non-empty active Flow ID.
200
+ * @param stepExecutionId - Step type and positive execution number.
201
+ * @param timeoutMs - Non-negative server-side wait duration in milliseconds.
202
+ * @throws {@link LongPollTimeoutError} when completion is not observed in time.
203
+ */
35
204
  waitForStepCompletion(flowId: string, stepExecutionId: StepExecutionId, timeoutMs: number): Promise<void>;
205
+ /**
206
+ * Replaces mutable configuration for an active Flow.
207
+ * The update affects later decisions and does not recall dispatched work.
208
+ * @param flowId - Non-empty active Flow ID.
209
+ * @param config - New optional Flow configuration fields.
210
+ */
36
211
  updateFlowConfig(flowId: string, config: FlowConfig): Promise<void>;
212
+ /**
213
+ * Closes the owned FlowService connection.
214
+ * Registry and BlobCache ownership remains with the caller.
215
+ */
37
216
  close(): Promise<void>;
38
217
  }