@superdurable/dex 0.1.2 → 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 (57) hide show
  1. package/README.md +82 -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 +186 -5
  9. package/dist/src/client.js +174 -33
  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 +162 -0
  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 +58 -5
  36. package/dist/src/rpc.js +17 -0
  37. package/dist/src/rpc.js.map +1 -1
  38. package/dist/src/step.d.ts +164 -2
  39. package/dist/src/step.js +85 -0
  40. package/dist/src/step.js.map +1 -1
  41. package/dist/src/value-mapper.d.ts +1 -0
  42. package/dist/src/value-mapper.js +75 -14
  43. package/dist/src/value-mapper.js.map +1 -1
  44. package/dist/src/wait.d.ts +180 -0
  45. package/dist/src/wait.js +157 -0
  46. package/dist/src/wait.js.map +1 -1
  47. package/dist/src/worker-dispatcher.js +55 -29
  48. package/dist/src/worker-dispatcher.js.map +1 -1
  49. package/dist/src/worker.d.ts +30 -1
  50. package/dist/src/worker.js +48 -2
  51. package/dist/src/worker.js.map +1 -1
  52. package/native/linux-aarch64/dex_blob_cache_node.node +0 -0
  53. package/native/linux-x86_64/dex_blob_cache_node.node +0 -0
  54. package/native/macos-aarch64/dex_blob_cache_node.node +0 -0
  55. package/native/macos-x86_64/dex_blob_cache_node.node +0 -0
  56. package/native/windows-x86_64/dex_blob_cache_node.node +0 -0
  57. package/package.json +2 -1
@@ -1,57 +1,237 @@
1
1
  import type { Codec } from "./codec.js";
2
2
  import type { Context } from "./context.js";
3
+ /** Describes one durable Timer or Channel readiness condition. */
3
4
  export interface Condition {
5
+ /** Condition family interpreted by Dex. */
4
6
  readonly kind: "timer" | "channel";
7
+ /** Optional stable ID unique within the Wait tree. */
5
8
  readonly conditionId?: string;
9
+ /** Timer delay in non-negative milliseconds. */
6
10
  readonly durationMs?: number;
11
+ /** Physical Channel name for a Channel condition. */
7
12
  readonly channelName?: string;
13
+ /** ChannelMap instance for a map condition. */
8
14
  readonly instance?: string;
15
+ /** Inclusive lower queued-value bound. */
9
16
  readonly atLeast?: number;
17
+ /** Inclusive upper queued-value bound. */
10
18
  readonly atMost?: number;
11
19
  }
20
+ /** Groups Conditions that must become ready together. */
12
21
  export interface ConditionCombination {
22
+ /** Ordered Conditions in this all-of group. */
13
23
  readonly conditions: readonly Condition[];
14
24
  }
25
+ /** Creates all-of Condition groups for `Wait.anyCombinationOf`. */
15
26
  export declare const ConditionCombination: Readonly<{
27
+ /**
28
+ * Groups conditions that must all become ready together.
29
+ * @param conditions - Conditions in stable evaluation order.
30
+ * @returns A group with the conditions.
31
+ */
16
32
  of(...conditions: readonly Condition[]): ConditionCombination;
17
33
  }>;
34
+ /** Creates durable Timer conditions without blocking a worker thread. */
18
35
  export declare const Timer: Readonly<{
36
+ /**
37
+ * Creates a Timer ready after a non-negative delay.
38
+ * @param durationMs - Durable delay in milliseconds.
39
+ * @param conditionId - Optional stable ID used by skip-Timer APIs.
40
+ * @returns A Timer condition accepted by Wait factories.
41
+ */
19
42
  byDuration(durationMs: number, conditionId?: string): Condition;
20
43
  }>;
44
+ /**
45
+ * Defines a typed, durable singleton message stream owned by a Flow.
46
+ * @typeParam T - Type of every published value.
47
+ */
21
48
  export declare class Channel<T> {
22
49
  readonly name: string;
23
50
  readonly codec: Codec<T>;
51
+ /**
52
+ * Creates a Channel definition.
53
+ * @param name - Non-empty name unique within the Flow.
54
+ * @param codec - Element codec.
55
+ */
24
56
  constructor(name: string, codec: Codec<T>);
57
+ /**
58
+ * Stages one value to append with the current decision.
59
+ * @param context - Current Step or RPC Context.
60
+ * @param value - Typed value to append.
61
+ */
25
62
  publish(context: Context, value: T): void;
63
+ /**
64
+ * Returns the current queued value count.
65
+ * @param context - Current Step or RPC Context.
66
+ * @returns Non-negative queued value count.
67
+ */
26
68
  size(context: Context): number;
69
+ /**
70
+ * Returns values selected by this Step's satisfied condition.
71
+ * @param context - Current Step Context.
72
+ * @returns Ordered values, or an empty array when this Channel was not selected.
73
+ */
27
74
  results(context: Context): readonly T[];
75
+ /**
76
+ * Creates a condition consuming exactly one value.
77
+ * @param conditionId - Optional stable condition identifier.
78
+ * @returns An exact-one Channel condition.
79
+ */
28
80
  forOne(conditionId?: string): Condition;
81
+ /**
82
+ * Creates a condition consuming exactly `count` values.
83
+ * @param count - Required non-negative count.
84
+ * @param conditionId - Optional stable condition identifier.
85
+ * @returns A condition with equal lower and upper bounds.
86
+ */
29
87
  forN(count: number, conditionId?: string): Condition;
88
+ /**
89
+ * Creates a condition requiring at least `count` values.
90
+ * @param count - Inclusive non-negative lower bound.
91
+ * @param conditionId - Optional stable condition identifier.
92
+ * @returns A condition without an upper bound.
93
+ */
30
94
  atLeast(count: number, conditionId?: string): Condition;
95
+ /**
96
+ * Creates a condition consuming at most `count` available values.
97
+ * @param count - Inclusive non-negative upper bound.
98
+ * @param conditionId - Optional stable condition identifier.
99
+ * @returns A condition without a positive lower bound.
100
+ */
31
101
  atMost(count: number, conditionId?: string): Condition;
102
+ /**
103
+ * Creates a bounded condition for queued Channel values.
104
+ * @param atLeast - Optional inclusive lower bound.
105
+ * @param atMost - Optional inclusive upper bound.
106
+ * @param conditionId - Optional stable condition identifier.
107
+ * @returns A validated Channel condition.
108
+ */
32
109
  range(atLeast?: number, atMost?: number, conditionId?: string): Condition;
33
110
  }
111
+ /**
112
+ * Defines keyed Channel instances that share one typed schema.
113
+ * @typeParam T - Type of every published value.
114
+ */
34
115
  export declare class ChannelMap<T> {
35
116
  readonly name: string;
36
117
  readonly codec: Codec<T>;
118
+ /**
119
+ * Creates a ChannelMap definition.
120
+ * @param name - Non-empty name unique within the Flow.
121
+ * @param codec - Element codec shared by every instance.
122
+ */
37
123
  constructor(name: string, codec: Codec<T>);
124
+ /**
125
+ * Stages one value for a ChannelMap instance.
126
+ * @param context - Current Step or RPC Context.
127
+ * @param instance - Non-empty logical map key.
128
+ * @param value - Typed value to append.
129
+ */
38
130
  publish(context: Context, instance: string, value: T): void;
131
+ /**
132
+ * Returns one instance's queued value count.
133
+ * @param context - Current Step or RPC Context.
134
+ * @param instance - Non-empty logical map key.
135
+ * @returns Non-negative queued value count.
136
+ */
39
137
  size(context: Context, instance: string): number;
138
+ /**
139
+ * Returns values selected for one instance by the satisfied condition.
140
+ * @param context - Current Step Context.
141
+ * @param instance - Non-empty logical map key.
142
+ * @returns Ordered values for this Step execution.
143
+ */
40
144
  results(context: Context, instance: string): readonly T[];
145
+ /**
146
+ * Creates an instance condition consuming exactly one value.
147
+ * @param instance - Non-empty logical map key.
148
+ * @param conditionId - Optional stable condition identifier.
149
+ * @returns An exact-one instance condition.
150
+ */
41
151
  forOne(instance: string, conditionId?: string): Condition;
152
+ /**
153
+ * Creates an instance condition consuming exactly `count` values.
154
+ * @param instance - Non-empty logical map key.
155
+ * @param count - Required non-negative count.
156
+ * @param conditionId - Optional stable condition identifier.
157
+ * @returns A condition with equal bounds.
158
+ */
42
159
  forN(instance: string, count: number, conditionId?: string): Condition;
160
+ /**
161
+ * Creates an instance condition requiring at least `count` values.
162
+ * @param instance - Non-empty logical map key.
163
+ * @param count - Inclusive non-negative lower bound.
164
+ * @param conditionId - Optional stable condition identifier.
165
+ * @returns A condition without an upper bound.
166
+ */
43
167
  atLeast(instance: string, count: number, conditionId?: string): Condition;
168
+ /**
169
+ * Creates an instance condition consuming at most `count` values.
170
+ * @param instance - Non-empty logical map key.
171
+ * @param count - Inclusive non-negative upper bound.
172
+ * @param conditionId - Optional stable condition identifier.
173
+ * @returns A condition without a positive lower bound.
174
+ */
44
175
  atMost(instance: string, count: number, conditionId?: string): Condition;
176
+ /**
177
+ * Creates a bounded condition for one ChannelMap instance.
178
+ * @param instance - Non-empty logical map key.
179
+ * @param atLeast - Optional inclusive lower bound.
180
+ * @param atMost - Optional inclusive upper bound.
181
+ * @param conditionId - Optional stable condition identifier.
182
+ * @returns A validated instance condition.
183
+ */
45
184
  range(instance: string, atLeast?: number, atMost?: number, conditionId?: string): Condition;
46
185
  }
186
+ /**
187
+ * Describes the durable readiness rule evaluated before a Step executes.
188
+ *
189
+ * @example
190
+ * ```ts
191
+ * const approvals = new Channel("approvals", stringCodec);
192
+ * const wait = Wait.anyOf(
193
+ * approvals.forOne("approved"),
194
+ * Timer.byDuration(5 * 60_000, "timeout"),
195
+ * );
196
+ * ```
197
+ */
47
198
  export type Wait = Readonly<{
199
+ /** Combination rule interpreted by Dex. */
48
200
  kind: "skipImmediately" | "allOf" | "anyOf" | "anyCombinationOf";
201
+ /** Direct conditions for all-of or any-of waits. */
49
202
  conditions: readonly Condition[];
203
+ /** Alternative all-of groups for any-combination waits. */
50
204
  combinations: readonly ConditionCombination[];
51
205
  }>;
206
+ /** Creates durable Step Wait values. */
52
207
  export declare const Wait: Readonly<{
208
+ /**
209
+ * Creates an immediate Wait.
210
+ * @returns A Wait that proceeds to `execute` immediately.
211
+ */
53
212
  skipImmediately(): Wait;
213
+ /**
214
+ * Creates a Wait for one condition.
215
+ * @param condition - The only readiness condition.
216
+ * @returns An all-of Wait with the condition.
217
+ */
218
+ until(condition: Condition): Wait;
219
+ /**
220
+ * Creates a Wait requiring every condition.
221
+ * @param conditions - Conditions evaluated as one all-of group.
222
+ * @returns An all-of Wait.
223
+ */
54
224
  allOf(...conditions: readonly Condition[]): Wait;
225
+ /**
226
+ * Creates a Wait that continues when any condition is ready.
227
+ * @param conditions - Alternative readiness conditions.
228
+ * @returns An any-of Wait.
229
+ */
55
230
  anyOf(...conditions: readonly Condition[]): Wait;
231
+ /**
232
+ * Creates a Wait accepting any complete condition combination.
233
+ * @param combinations - Alternative all-of condition groups.
234
+ * @returns An any-combination Wait.
235
+ */
56
236
  anyCombinationOf(...combinations: readonly ConditionCombination[]): Wait;
57
237
  }>;
package/dist/src/wait.js CHANGED
@@ -6,12 +6,25 @@
6
6
  //
7
7
  // SPDX-License-Identifier: LicenseRef-Super-Durable-1.0
8
8
  import { requireConditionId, requireName, validateChannelBounds, } from "./validation.js";
9
+ /** Creates all-of Condition groups for `Wait.anyCombinationOf`. */
9
10
  export const ConditionCombination = Object.freeze({
11
+ /**
12
+ * Groups conditions that must all become ready together.
13
+ * @param conditions - Conditions in stable evaluation order.
14
+ * @returns A group with the conditions.
15
+ */
10
16
  of(...conditions) {
11
17
  return { conditions };
12
18
  },
13
19
  });
20
+ /** Creates durable Timer conditions without blocking a worker thread. */
14
21
  export const Timer = Object.freeze({
22
+ /**
23
+ * Creates a Timer ready after a non-negative delay.
24
+ * @param durationMs - Durable delay in milliseconds.
25
+ * @param conditionId - Optional stable ID used by skip-Timer APIs.
26
+ * @returns A Timer condition accepted by Wait factories.
27
+ */
15
28
  byDuration(durationMs, conditionId) {
16
29
  if (durationMs < 0 || !Number.isFinite(durationMs)) {
17
30
  throw new RangeError("timer duration must be non-negative");
@@ -24,35 +37,89 @@ export const Timer = Object.freeze({
24
37
  };
25
38
  },
26
39
  });
40
+ /**
41
+ * Defines a typed, durable singleton message stream owned by a Flow.
42
+ * @typeParam T - Type of every published value.
43
+ */
27
44
  export class Channel {
28
45
  name;
29
46
  codec;
47
+ /**
48
+ * Creates a Channel definition.
49
+ * @param name - Non-empty name unique within the Flow.
50
+ * @param codec - Element codec.
51
+ */
30
52
  constructor(name, codec) {
31
53
  this.name = name;
32
54
  this.codec = codec;
33
55
  requireName(name);
34
56
  }
57
+ /**
58
+ * Stages one value to append with the current decision.
59
+ * @param context - Current Step or RPC Context.
60
+ * @param value - Typed value to append.
61
+ */
35
62
  publish(context, value) {
36
63
  context.publish(this, value);
37
64
  }
65
+ /**
66
+ * Returns the current queued value count.
67
+ * @param context - Current Step or RPC Context.
68
+ * @returns Non-negative queued value count.
69
+ */
38
70
  size(context) {
39
71
  return context.channelSize(this);
40
72
  }
73
+ /**
74
+ * Returns values selected by this Step's satisfied condition.
75
+ * @param context - Current Step Context.
76
+ * @returns Ordered values, or an empty array when this Channel was not selected.
77
+ */
41
78
  results(context) {
42
79
  return context.channelResults(this);
43
80
  }
81
+ /**
82
+ * Creates a condition consuming exactly one value.
83
+ * @param conditionId - Optional stable condition identifier.
84
+ * @returns An exact-one Channel condition.
85
+ */
44
86
  forOne(conditionId) {
45
87
  return this.range(1, 1, conditionId);
46
88
  }
89
+ /**
90
+ * Creates a condition consuming exactly `count` values.
91
+ * @param count - Required non-negative count.
92
+ * @param conditionId - Optional stable condition identifier.
93
+ * @returns A condition with equal lower and upper bounds.
94
+ */
47
95
  forN(count, conditionId) {
48
96
  return this.range(count, count, conditionId);
49
97
  }
98
+ /**
99
+ * Creates a condition requiring at least `count` values.
100
+ * @param count - Inclusive non-negative lower bound.
101
+ * @param conditionId - Optional stable condition identifier.
102
+ * @returns A condition without an upper bound.
103
+ */
50
104
  atLeast(count, conditionId) {
51
105
  return this.range(count, undefined, conditionId);
52
106
  }
107
+ /**
108
+ * Creates a condition consuming at most `count` available values.
109
+ * @param count - Inclusive non-negative upper bound.
110
+ * @param conditionId - Optional stable condition identifier.
111
+ * @returns A condition without a positive lower bound.
112
+ */
53
113
  atMost(count, conditionId) {
54
114
  return this.range(undefined, count, conditionId);
55
115
  }
116
+ /**
117
+ * Creates a bounded condition for queued Channel values.
118
+ * @param atLeast - Optional inclusive lower bound.
119
+ * @param atMost - Optional inclusive upper bound.
120
+ * @param conditionId - Optional stable condition identifier.
121
+ * @returns A validated Channel condition.
122
+ */
56
123
  range(atLeast, atMost, conditionId) {
57
124
  validateChannelBounds(atLeast, atMost);
58
125
  requireConditionId(conditionId);
@@ -65,35 +132,97 @@ export class Channel {
65
132
  };
66
133
  }
67
134
  }
135
+ /**
136
+ * Defines keyed Channel instances that share one typed schema.
137
+ * @typeParam T - Type of every published value.
138
+ */
68
139
  export class ChannelMap {
69
140
  name;
70
141
  codec;
142
+ /**
143
+ * Creates a ChannelMap definition.
144
+ * @param name - Non-empty name unique within the Flow.
145
+ * @param codec - Element codec shared by every instance.
146
+ */
71
147
  constructor(name, codec) {
72
148
  this.name = name;
73
149
  this.codec = codec;
74
150
  requireName(name);
75
151
  }
152
+ /**
153
+ * Stages one value for a ChannelMap instance.
154
+ * @param context - Current Step or RPC Context.
155
+ * @param instance - Non-empty logical map key.
156
+ * @param value - Typed value to append.
157
+ */
76
158
  publish(context, instance, value) {
77
159
  context.publish(this, value, instance);
78
160
  }
161
+ /**
162
+ * Returns one instance's queued value count.
163
+ * @param context - Current Step or RPC Context.
164
+ * @param instance - Non-empty logical map key.
165
+ * @returns Non-negative queued value count.
166
+ */
79
167
  size(context, instance) {
80
168
  return context.channelSize(this, instance);
81
169
  }
170
+ /**
171
+ * Returns values selected for one instance by the satisfied condition.
172
+ * @param context - Current Step Context.
173
+ * @param instance - Non-empty logical map key.
174
+ * @returns Ordered values for this Step execution.
175
+ */
82
176
  results(context, instance) {
83
177
  return context.channelResults(this, instance);
84
178
  }
179
+ /**
180
+ * Creates an instance condition consuming exactly one value.
181
+ * @param instance - Non-empty logical map key.
182
+ * @param conditionId - Optional stable condition identifier.
183
+ * @returns An exact-one instance condition.
184
+ */
85
185
  forOne(instance, conditionId) {
86
186
  return this.range(instance, 1, 1, conditionId);
87
187
  }
188
+ /**
189
+ * Creates an instance condition consuming exactly `count` values.
190
+ * @param instance - Non-empty logical map key.
191
+ * @param count - Required non-negative count.
192
+ * @param conditionId - Optional stable condition identifier.
193
+ * @returns A condition with equal bounds.
194
+ */
88
195
  forN(instance, count, conditionId) {
89
196
  return this.range(instance, count, count, conditionId);
90
197
  }
198
+ /**
199
+ * Creates an instance condition requiring at least `count` values.
200
+ * @param instance - Non-empty logical map key.
201
+ * @param count - Inclusive non-negative lower bound.
202
+ * @param conditionId - Optional stable condition identifier.
203
+ * @returns A condition without an upper bound.
204
+ */
91
205
  atLeast(instance, count, conditionId) {
92
206
  return this.range(instance, count, undefined, conditionId);
93
207
  }
208
+ /**
209
+ * Creates an instance condition consuming at most `count` values.
210
+ * @param instance - Non-empty logical map key.
211
+ * @param count - Inclusive non-negative upper bound.
212
+ * @param conditionId - Optional stable condition identifier.
213
+ * @returns A condition without a positive lower bound.
214
+ */
94
215
  atMost(instance, count, conditionId) {
95
216
  return this.range(instance, undefined, count, conditionId);
96
217
  }
218
+ /**
219
+ * Creates a bounded condition for one ChannelMap instance.
220
+ * @param instance - Non-empty logical map key.
221
+ * @param atLeast - Optional inclusive lower bound.
222
+ * @param atMost - Optional inclusive upper bound.
223
+ * @param conditionId - Optional stable condition identifier.
224
+ * @returns A validated instance condition.
225
+ */
97
226
  range(instance, atLeast, atMost, conditionId) {
98
227
  validateChannelBounds(atLeast, atMost);
99
228
  requireConditionId(conditionId);
@@ -107,16 +236,44 @@ export class ChannelMap {
107
236
  };
108
237
  }
109
238
  }
239
+ /** Creates durable Step Wait values. */
110
240
  export const Wait = Object.freeze({
241
+ /**
242
+ * Creates an immediate Wait.
243
+ * @returns A Wait that proceeds to `execute` immediately.
244
+ */
111
245
  skipImmediately() {
112
246
  return { kind: "skipImmediately", conditions: [], combinations: [] };
113
247
  },
248
+ /**
249
+ * Creates a Wait for one condition.
250
+ * @param condition - The only readiness condition.
251
+ * @returns An all-of Wait with the condition.
252
+ */
253
+ until(condition) {
254
+ return Wait.allOf(condition);
255
+ },
256
+ /**
257
+ * Creates a Wait requiring every condition.
258
+ * @param conditions - Conditions evaluated as one all-of group.
259
+ * @returns An all-of Wait.
260
+ */
114
261
  allOf(...conditions) {
115
262
  return { kind: "allOf", conditions, combinations: [] };
116
263
  },
264
+ /**
265
+ * Creates a Wait that continues when any condition is ready.
266
+ * @param conditions - Alternative readiness conditions.
267
+ * @returns An any-of Wait.
268
+ */
117
269
  anyOf(...conditions) {
118
270
  return { kind: "anyOf", conditions, combinations: [] };
119
271
  },
272
+ /**
273
+ * Creates a Wait accepting any complete condition combination.
274
+ * @param combinations - Alternative all-of condition groups.
275
+ * @returns An any-combination Wait.
276
+ */
120
277
  anyCombinationOf(...combinations) {
121
278
  return { kind: "anyCombinationOf", conditions: [], combinations };
122
279
  },
@@ -1 +1 @@
1
- {"version":3,"file":"wait.js","sourceRoot":"","sources":["../../src/wait.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,uDAAuD;AACvD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,wDAAwD;AAIxD,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAgBzB,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC;IAChD,EAAE,CAAC,GAAG,UAAgC;QACpC,OAAO,EAAE,UAAU,EAAE,CAAC;IACxB,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;IACj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,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;SACtD,CAAC;IACJ,CAAC;CACF;AAuBD,wCAAwC;AACxC,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;IAChC;;;OAGG;IACH,eAAe;QACb,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,UAAU,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IACvE,CAAC;IACD;;;;OAIG;IACH,KAAK,CAAC,SAAoB;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;IACD;;;;OAIG;IACH,KAAK,CAAC,GAAG,UAAgC;QACvC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IACzD,CAAC;IACD;;;;OAIG;IACH,KAAK,CAAC,GAAG,UAAgC;QACvC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IACzD,CAAC;IACD;;;;OAIG;IACH,gBAAgB,CAAC,GAAG,YAA6C;QAC/D,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,UAAU,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC;IACpE,CAAC;CACF,CAAC,CAAC"}
@@ -6,6 +6,7 @@
6
6
  //
7
7
  // SPDX-License-Identifier: LicenseRef-Super-Durable-1.0
8
8
  import { ChannelCondition, CloseDecision, CloseDecisionType, ConditionCombination as ProtoConditionCombination, ExecuteMethodFailurePolicy, InvokeExecuteMethodResponse, InvokeWaitForMethodResponse, InvokeWorkerRPCResponse, StepDecision as ProtoStepDecision, StepMovement as ProtoStepMovement, StepOptions as ProtoStepOptions, TimerCondition, WaitForMethodFailurePolicy, WaitingCondition, WaitingConditionType, } from "./gen/dex.js";
9
+ import { InvalidStepResultError, ValueMappingError } from "./errors.js";
9
10
  import { registeredFlowByName, registeredRPCByName, registeredStep, } from "./flow.js";
10
11
  import { InvocationContext } from "./invocation-context.js";
11
12
  import { decodeValue, encodeUnknown, encodeValue, } from "./value-mapper.js";
@@ -27,14 +28,19 @@ export class WorkerDispatcher {
27
28
  if (step.step.waitFor === undefined) {
28
29
  throw new TypeError(`Step ${step.name} does not implement waitFor`);
29
30
  }
30
- const wait = step.step.waitFor(context, input);
31
- return InvokeWaitForMethodResponse.create({
32
- upsertAttributes: [...context.getAttributeWrites()],
33
- waitingCondition: mapWait(flow, wait),
34
- upsertStepExeLocals: [...context.getLocalWrites()],
35
- recordEvents: [...context.getEvents()],
36
- publishToChannel: [...context.getPublications()],
37
- });
31
+ const wait = await step.step.waitFor(context, input);
32
+ try {
33
+ return InvokeWaitForMethodResponse.create({
34
+ upsertAttributes: [...context.getAttributeWrites()],
35
+ waitingCondition: mapWait(flow, wait),
36
+ upsertStepExeLocals: [...context.getLocalWrites()],
37
+ recordEvents: [...context.getEvents()],
38
+ publishToChannel: [...context.getPublications()],
39
+ });
40
+ }
41
+ catch (failure) {
42
+ throw invalidStepResult(flow.name, step.name, "waitFor", failure);
43
+ }
38
44
  }
39
45
  async invokeExecute(original) {
40
46
  const request = await this.hydrateExecute(original);
@@ -42,33 +48,43 @@ export class WorkerDispatcher {
42
48
  const step = registeredStep(flow, request.stepType);
43
49
  const context = new InvocationContext("execute", flow, request.context, request.attributes, request.stepExeLocals, request.conditionResults);
44
50
  const input = decodeValue(step.step.inputCodec, requireValue(request.stepInput, "Step input"));
45
- const decision = step.step.execute(context, input);
46
- return InvokeExecuteMethodResponse.create({
47
- stepDecision: mapDecision(flow, decision),
48
- upsertAttributes: [...context.getAttributeWrites()],
49
- recordEvents: [...context.getEvents()],
50
- upsertStepExeLocals: [...context.getLocalWrites()],
51
- publishToChannel: [...context.getPublications()],
52
- });
51
+ const decision = await step.step.execute(context, input);
52
+ try {
53
+ return InvokeExecuteMethodResponse.create({
54
+ stepDecision: mapDecision(flow, decision),
55
+ upsertAttributes: [...context.getAttributeWrites()],
56
+ recordEvents: [...context.getEvents()],
57
+ upsertStepExeLocals: [...context.getLocalWrites()],
58
+ publishToChannel: [...context.getPublications()],
59
+ });
60
+ }
61
+ catch (failure) {
62
+ throw invalidStepResult(flow.name, step.name, "execute", failure);
63
+ }
53
64
  }
54
65
  async invokeRPC(original) {
55
66
  const request = await this.hydrateRPC(original);
56
67
  const flow = registeredFlowByName(this.registry, request.flowType);
57
68
  const rpc = registeredRPCByName(flow, request.rpcName);
58
69
  const context = new InvocationContext("rpc", flow, request.context, request.attributes, [], undefined, request.channelInfos);
59
- const returned = invokeRPC(flow, rpc, context, request.input);
60
- const result = rpcResult(rpc, returned);
61
- return InvokeWorkerRPCResponse.create({
62
- output: rpc.options.outputCodec === undefined
63
- ? encodeUnknown(undefined)
64
- : encodeValue(rpc.options.outputCodec, result?.output),
65
- stepDecision: result?.nextSteps === undefined || result.nextSteps.length === 0
66
- ? undefined
67
- : ProtoStepDecision.create({ nextSteps: mapMovements(flow, result.nextSteps) }),
68
- upsertAttributes: [...context.getAttributeWrites()],
69
- recordEvents: [...context.getEvents()],
70
- publishToChannel: [...context.getPublications()],
71
- });
70
+ const returned = await invokeRPC(flow, rpc, context, request.input);
71
+ try {
72
+ const result = rpcResult(rpc, returned);
73
+ return InvokeWorkerRPCResponse.create({
74
+ output: rpc.options.outputCodec === undefined
75
+ ? encodeUnknown(undefined)
76
+ : encodeValue(rpc.options.outputCodec, result?.output),
77
+ stepDecision: result?.nextSteps === undefined || result.nextSteps.length === 0
78
+ ? undefined
79
+ : ProtoStepDecision.create({ nextSteps: mapMovements(flow, result.nextSteps) }),
80
+ upsertAttributes: [...context.getAttributeWrites()],
81
+ recordEvents: [...context.getEvents()],
82
+ publishToChannel: [...context.getPublications()],
83
+ });
84
+ }
85
+ catch (failure) {
86
+ throw invalidStepResult(flow.name, undefined, "rpc", failure);
87
+ }
72
88
  }
73
89
  async hydrateWaitFor(request) {
74
90
  const values = await this.hydrator.hydrateAll([
@@ -371,4 +387,14 @@ function seconds(milliseconds) {
371
387
  }
372
388
  return milliseconds / 1_000;
373
389
  }
390
+ function invalidStepResult(flowType, stepType, method, failure) {
391
+ if (failure instanceof ValueMappingError) {
392
+ return failure;
393
+ }
394
+ if (failure instanceof InvalidStepResultError) {
395
+ return failure;
396
+ }
397
+ const detail = failure instanceof Error ? failure.message : String(failure);
398
+ return new InvalidStepResultError(flowType, stepType, method, detail, { cause: failure });
399
+ }
374
400
  //# sourceMappingURL=worker-dispatcher.js.map