@yieldstar/core 0.6.0 → 0.7.0
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.
- package/dist/base/durable-value.d.ts +7 -5
- package/dist/base/durable-value.d.ts.map +1 -1
- package/dist/base/execution.d.ts +11 -0
- package/dist/base/execution.d.ts.map +1 -1
- package/dist/base/store.d.ts +1 -1
- package/dist/base/store.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +128 -1
- package/dist/lib/execution-dispatcher.d.ts +10 -0
- package/dist/lib/execution-dispatcher.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/base/durable-value.test.ts +91 -14
- package/src/base/durable-value.ts +142 -4
- package/src/base/errors.test.ts +7 -5
- package/src/base/execution.ts +12 -0
- package/src/base/store.test.ts +56 -0
- package/src/base/store.ts +38 -1
- package/src/index.ts +1 -0
- package/src/lib/execution-dispatcher.ts +15 -0
- package/src/lib/execution-state.test.ts +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type DurableValue = null | boolean | number | string | undefined | Error | DurableValue[] | DurableObject;
|
|
1
|
+
export type DurableValue = null | boolean | number | string | undefined | bigint | Date | Error | DurableValue[] | Map<DurableValue, DurableValue> | Set<DurableValue> | DurableObject;
|
|
2
2
|
export type DurableObject = {
|
|
3
3
|
[key: string]: DurableValue;
|
|
4
4
|
};
|
|
@@ -7,7 +7,7 @@ export type DurableObject = {
|
|
|
7
7
|
* signature, it accepts interfaces. The codec still validates every value at
|
|
8
8
|
* runtime.
|
|
9
9
|
*/
|
|
10
|
-
export type Durable<T> = T extends string | number | boolean | null | undefined | Error ? T : T extends readonly (infer U)[] ? readonly Durable<U>[] : T extends
|
|
10
|
+
export type Durable<T> = T extends string | number | boolean | null | undefined | bigint | Date | Error ? T : T extends readonly (infer U)[] ? readonly Durable<U>[] : T extends Map<infer K, infer V> ? Map<Durable<K>, Durable<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<Durable<K>, Durable<V>> : T extends Set<infer U> ? Set<Durable<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<Durable<U>> : T extends Function ? never : {
|
|
11
11
|
[K in keyof T]: Durable<T[K]>;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
@@ -37,9 +37,11 @@ export interface DurableValueCodec {
|
|
|
37
37
|
/**
|
|
38
38
|
* Validates `value` recursively and returns its canonical JSON: object keys
|
|
39
39
|
* sorted by UTF-16 code unit and `-0` written as `0`, so equal values always
|
|
40
|
-
* encode to the same string. `undefined`,
|
|
41
|
-
* own `$type` key are written as tagged
|
|
42
|
-
*
|
|
40
|
+
* encode to the same string. `undefined`, `bigint`, `Date`, `Map`, `Set`,
|
|
41
|
+
* errors and plain objects with an own `$type` key are written as tagged
|
|
42
|
+
* objects. Map entries and set values keep their insertion order, so maps
|
|
43
|
+
* or sets that differ only in order encode differently. Never throws for an
|
|
44
|
+
* invalid value.
|
|
43
45
|
*/
|
|
44
46
|
encode(value: unknown): DurableValueEncoding;
|
|
45
47
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durable-value.d.ts","sourceRoot":"","sources":["../../src/base/durable-value.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GACpB,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,GACT,KAAK,GACL,YAAY,EAAE,GACd,aAAa,CAAC;AAElB,MAAM,MAAM,aAAa,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;CAAE,CAAC;AAE5D;;;;GAIG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,SACtB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,KAAK,GACL,CAAC,GACD,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAC9B,SAAS,OAAO,CAAC,CAAC,CAAC,EAAE,G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
|
56
56
|
expiresAt: number;
|
|
57
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Limits a claim to the executions that match. The claim applies it in the same
|
|
60
|
+
* atomic step, so an execution that does not match is not leased and gains no
|
|
61
|
+
* redelivery delay.
|
|
62
|
+
*/
|
|
63
|
+
export type ExecutionClaimFilter = {
|
|
64
|
+
/** Claims only executions whose ID is in this list. An empty list claims nothing. */
|
|
65
|
+
executionIds?: readonly string[];
|
|
66
|
+
};
|
|
58
67
|
/**
|
|
59
68
|
* Returned by a fenced write whose lease is no longer current: a higher token
|
|
60
69
|
* has been issued, or the lease has ended. The write changed nothing, and its
|
|
@@ -169,6 +178,8 @@ export interface ExecutionClient {
|
|
|
169
178
|
claimDue(request: {
|
|
170
179
|
limit: number;
|
|
171
180
|
duration: number;
|
|
181
|
+
/** When absent, any execution whose due time has passed may be claimed. */
|
|
182
|
+
filter?: ExecutionClaimFilter;
|
|
172
183
|
}): Promise<ExecutionLease[]>;
|
|
173
184
|
/**
|
|
174
185
|
* Extends a lease to `duration` milliseconds from now. Returns `lost` if a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/base/execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEzD,MAAM,MAAM,eAAe,GACvB,UAAU,GACV,SAAS,GACT,WAAW,GACX,WAAW,GACX,QAAQ,CAAC;AAEb,MAAM,MAAM,gBAAgB,GACxB;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GACxC;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAEvC,0EAA0E;AAC1E,MAAM,MAAM,eAAe,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IA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AAE,MAAM;CAKhC;AAED;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAEb,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAQjD;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,IAAI,EAAE,2BAA2B,CAAC;gBAE/B,IAAI,EAAE,2BAA2B,EAAE,OAAO,EAAE,MAAM;CAK/D;AAED;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;gBAE1B,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM;CAK1D;AAED,QAAA,MAAM,oBAAoB,eAA8C,CAAC;AAEzE;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,CAAC,oBAAoB,CAAC,QAAQ;gBAE3B,KAAK,EAAE,OAAO;IAK1B,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB;CAOxD;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,eAAe,GACtB,MAAM,IAAI,WAAW,GAAG,QAAQ,CAElC"}
|
package/dist/base/store.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
2
|
import { type Durable, type IfDurable } from "./durable-value";
|
|
3
|
-
export type Draft<T> = T extends object ? {
|
|
3
|
+
export type Draft<T> = T extends Date ? T : T extends ReadonlyMap<infer K, infer V> ? Map<Draft<K>, Draft<V>> : T extends ReadonlySet<infer U> ? Set<Draft<U>> : T extends object ? {
|
|
4
4
|
-readonly [K in keyof T]: Draft<T[K]>;
|
|
5
5
|
} : T;
|
|
6
6
|
export type StoreVersion = number;
|
package/dist/base/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E,MAAM,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAkEtE;AAED,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,SAAS,EAAE,EACtB,UAAU,EAAE,SAAS,EAAE,GACtB,OAAO,CAOT"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type { DeliveryOptions, WorkflowInvoker } from "./base/invoker";
|
|
|
3
3
|
export { WorkerExitedError } from "./base/invoker";
|
|
4
4
|
export type { RuntimeOptions } from "./base/runtime";
|
|
5
5
|
export { Runtime } from "./base/runtime";
|
|
6
|
-
export type { ExecutionAcknowledgeResult, ExecutionAdmissionErrorCode, ExecutionAdmissionRequest, ExecutionAdmissionResult, ExecutionClient, ExecutionLease, ExecutionOutcome, ExecutionParent, ExecutionRecord, ExecutionReleaseResult, ExecutionRenewResult, ExecutionStartRequest, ExecutionStartResult, ExecutionStatus, ExecutionWakeResult, LeaseLost, WorkflowRunOutcome, WorkflowStartErrorCode, } from "./base/execution";
|
|
6
|
+
export type { ExecutionAcknowledgeResult, ExecutionAdmissionErrorCode, ExecutionAdmissionRequest, ExecutionAdmissionResult, ExecutionClaimFilter, ExecutionClient, ExecutionLease, ExecutionOutcome, ExecutionParent, ExecutionRecord, ExecutionReleaseResult, ExecutionRenewResult, ExecutionStartRequest, ExecutionStartResult, ExecutionStatus, ExecutionWakeResult, LeaseLost, WorkflowRunOutcome, WorkflowStartErrorCode, } from "./base/execution";
|
|
7
7
|
export { ExecutionAdmissionError, InfrastructureError, LeaseLostError, StepConflictError, WorkflowStartError, isLeaseLost, isTerminalExecutionStatus, } from "./base/execution";
|
|
8
8
|
export type { EffectBeginRequest, EffectBeginResult, EffectClient, EffectConflictReport, EffectDeliveryErrorCode, EffectRecord, EffectSettleRequest, EffectSettleResult, EffectWatchRequest, WorkflowEffectErrorCode, } from "./base/effect";
|
|
9
9
|
export { EffectClientInvariantError, EffectDeliveryError, WorkflowEffectError, } from "./base/effect";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,YAAY,EACV,0BAA0B,EAC1B,2BAA2B,EAC3B,yBAAyB,EACzB,wBAAwB,EACxB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,SAAS,EACT,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,yBAAyB,GAC1B,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,uBAAuB,EACvB,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB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Q,EACR,SAAS,EACT,aAAa,EACb,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,aAAa,EACb,yBAAyB,EACzB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,WAAW,EACX,YAAY,EACZ,cAAc,EACd,eAAe,EACf,YAAY,EACZ,aAAa,GACd,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5E,YAAY,EACV,iBAAiB,EACjB,2BAA2B,EAC3B,cAAc,EACd,eAAe,EACf,aAAa,GACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,cAAc,EACd,SAAS,EACT,cAAc,EACd,SAAS,EACT,WAAW,EACX,OAAO,EACP,YAAY,EACZ,UAAU,EACV,aAAa,EACb,aAAa,EACb,eAAe,EACf,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,UAAU,E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Z,WAAW,EACX,aAAa,EACb,yBAAyB,EACzB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,WAAW,EACX,YAAY,EACZ,cAAc,EACd,eAAe,EACf,YAAY,EACZ,aAAa,GACd,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5E,YAAY,EACV,iBAAiB,EACjB,2BAA2B,EAC3B,cAAc,EACd,eAAe,EACf,aAAa,GACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,cAAc,EACd,SAAS,EACT,cAAc,EACd,SAAS,EACT,WAAW,EACX,OAAO,EACP,YAAY,EACZ,UAAU,EACV,aAAa,EACb,aAAa,EACb,eAAe,EACf,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -203,6 +203,8 @@ function encodeValue(value, path, ancestors) {
|
|
|
203
203
|
return value ? "true" : "false";
|
|
204
204
|
case "string":
|
|
205
205
|
return JSON.stringify(value);
|
|
206
|
+
case "bigint":
|
|
207
|
+
return `{"$type":"bigint","value":"${value}"}`;
|
|
206
208
|
case "number":
|
|
207
209
|
if (!Number.isFinite(value)) {
|
|
208
210
|
throw new DurableValueError(`${path}: ${value} is not a finite number`);
|
|
@@ -222,6 +224,12 @@ function encodeValue(value, path, ancestors) {
|
|
|
222
224
|
return encodeArray(value, path, ancestors);
|
|
223
225
|
if (value instanceof Error)
|
|
224
226
|
return encodeError(value, path, ancestors);
|
|
227
|
+
if (value instanceof Date)
|
|
228
|
+
return encodeDate(value, path);
|
|
229
|
+
if (value instanceof Map)
|
|
230
|
+
return encodeMap(value, path, ancestors);
|
|
231
|
+
if (value instanceof Set)
|
|
232
|
+
return encodeSet(value, path, ancestors);
|
|
225
233
|
return encodeObject(value, path, ancestors);
|
|
226
234
|
} finally {
|
|
227
235
|
ancestors.delete(value);
|
|
@@ -252,6 +260,41 @@ function encodeArray(value, path, ancestors) {
|
|
|
252
260
|
}
|
|
253
261
|
return `[${items.join(",")}]`;
|
|
254
262
|
}
|
|
263
|
+
function encodeDate(value, path) {
|
|
264
|
+
expectBuiltIn(value, Date.prototype, "dates", path);
|
|
265
|
+
if (Number.isNaN(value.getTime())) {
|
|
266
|
+
throw new DurableValueError(`${path}: invalid Date`);
|
|
267
|
+
}
|
|
268
|
+
return `{"$type":"date","value":${JSON.stringify(value.toISOString())}}`;
|
|
269
|
+
}
|
|
270
|
+
function encodeMap(value, path, ancestors) {
|
|
271
|
+
expectBuiltIn(value, Map.prototype, "maps", path);
|
|
272
|
+
const entries = [];
|
|
273
|
+
let i = 0;
|
|
274
|
+
for (const [key, item] of value) {
|
|
275
|
+
const entryPath = `${path}.entries[${i++}]`;
|
|
276
|
+
const encodedKey = encodeValue(key, `${entryPath}[0]`, ancestors);
|
|
277
|
+
entries.push(`[${encodedKey},${encodeValue(item, `${entryPath}[1]`, ancestors)}]`);
|
|
278
|
+
}
|
|
279
|
+
return `{"$type":"map","entries":[${entries.join(",")}]}`;
|
|
280
|
+
}
|
|
281
|
+
function encodeSet(value, path, ancestors) {
|
|
282
|
+
expectBuiltIn(value, Set.prototype, "sets", path);
|
|
283
|
+
const values = [];
|
|
284
|
+
let i = 0;
|
|
285
|
+
for (const item of value) {
|
|
286
|
+
values.push(encodeValue(item, `${path}.values[${i++}]`, ancestors));
|
|
287
|
+
}
|
|
288
|
+
return `{"$type":"set","values":[${values.join(",")}]}`;
|
|
289
|
+
}
|
|
290
|
+
function expectBuiltIn(value, proto, kind, path) {
|
|
291
|
+
if (Object.getPrototypeOf(value) !== proto) {
|
|
292
|
+
throw new DurableValueError(`${path}: ${kind} must not be subclassed`);
|
|
293
|
+
}
|
|
294
|
+
if (Reflect.ownKeys(value).length > 0) {
|
|
295
|
+
throw new DurableValueError(`${path}: ${kind} must not have own properties`);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
255
298
|
function encodeObject(value, path, ancestors) {
|
|
256
299
|
if (!isPlainObject(value)) {
|
|
257
300
|
const name = Object.getPrototypeOf(value)?.constructor?.name ?? "object";
|
|
@@ -380,12 +423,68 @@ function decodeParsedValue(parsed, path = "$") {
|
|
|
380
423
|
}
|
|
381
424
|
return decodeObject(value, `${path}.value`);
|
|
382
425
|
}
|
|
426
|
+
case "bigint":
|
|
427
|
+
return decodeBigInt(object, path);
|
|
428
|
+
case "date":
|
|
429
|
+
return decodeDate(object, path);
|
|
430
|
+
case "map":
|
|
431
|
+
return decodeMap(object, path);
|
|
432
|
+
case "set":
|
|
433
|
+
return decodeSet(object, path);
|
|
383
434
|
case "error":
|
|
384
435
|
return decodeError(object, path);
|
|
385
436
|
default:
|
|
386
437
|
throw new DurableValueError(`${path}: unknown $type ${JSON.stringify(object.$type)}`);
|
|
387
438
|
}
|
|
388
439
|
}
|
|
440
|
+
function decodeBigInt(tag, path) {
|
|
441
|
+
expectKeys(tag, path, ["$type", "value"], []);
|
|
442
|
+
const { value } = tag;
|
|
443
|
+
if (typeof value !== "string" || !/^-?(0|[1-9][0-9]*)$/.test(value) || value === "-0") {
|
|
444
|
+
throw new DurableValueError(`${path}.value: must be an integer string`);
|
|
445
|
+
}
|
|
446
|
+
return BigInt(value);
|
|
447
|
+
}
|
|
448
|
+
function decodeDate(tag, path) {
|
|
449
|
+
expectKeys(tag, path, ["$type", "value"], []);
|
|
450
|
+
const { value } = tag;
|
|
451
|
+
const date = typeof value === "string" ? new Date(value) : undefined;
|
|
452
|
+
if (!date || Number.isNaN(date.getTime()) || date.toISOString() !== value) {
|
|
453
|
+
throw new DurableValueError(`${path}.value: must be an ISO 8601 date string`);
|
|
454
|
+
}
|
|
455
|
+
return date;
|
|
456
|
+
}
|
|
457
|
+
function decodeMap(tag, path) {
|
|
458
|
+
expectKeys(tag, path, ["$type", "entries"], []);
|
|
459
|
+
const entries = expectArray(tag.entries, `${path}.entries`);
|
|
460
|
+
const map = new Map;
|
|
461
|
+
entries.forEach((entry, i) => {
|
|
462
|
+
const entryPath = `${path}.entries[${i}]`;
|
|
463
|
+
if (!Array.isArray(entry) || entry.length !== 2) {
|
|
464
|
+
throw new DurableValueError(`${entryPath}: must be a [key, value] pair`);
|
|
465
|
+
}
|
|
466
|
+
map.set(decodeParsedValue(entry[0], `${entryPath}[0]`), decodeParsedValue(entry[1], `${entryPath}[1]`));
|
|
467
|
+
});
|
|
468
|
+
if (map.size !== entries.length) {
|
|
469
|
+
throw new DurableValueError(`${path}.entries: duplicate keys`);
|
|
470
|
+
}
|
|
471
|
+
return map;
|
|
472
|
+
}
|
|
473
|
+
function decodeSet(tag, path) {
|
|
474
|
+
expectKeys(tag, path, ["$type", "values"], []);
|
|
475
|
+
const values = expectArray(tag.values, `${path}.values`);
|
|
476
|
+
const set = new Set(values.map((item, i) => decodeParsedValue(item, `${path}.values[${i}]`)));
|
|
477
|
+
if (set.size !== values.length) {
|
|
478
|
+
throw new DurableValueError(`${path}.values: duplicate values`);
|
|
479
|
+
}
|
|
480
|
+
return set;
|
|
481
|
+
}
|
|
482
|
+
function expectArray(value, path) {
|
|
483
|
+
if (!Array.isArray(value)) {
|
|
484
|
+
throw new DurableValueError(`${path}: must be an array`);
|
|
485
|
+
}
|
|
486
|
+
return value;
|
|
487
|
+
}
|
|
389
488
|
function decodeObject(object, path) {
|
|
390
489
|
const decoded = {};
|
|
391
490
|
for (const key of Object.keys(object)) {
|
|
@@ -1071,6 +1170,7 @@ class ExecutionDispatcher {
|
|
|
1071
1170
|
leaseDuration;
|
|
1072
1171
|
renewInterval;
|
|
1073
1172
|
abortGracePeriod;
|
|
1173
|
+
filter;
|
|
1074
1174
|
running = false;
|
|
1075
1175
|
looping = false;
|
|
1076
1176
|
timer;
|
|
@@ -1086,6 +1186,7 @@ class ExecutionDispatcher {
|
|
|
1086
1186
|
this.leaseDuration = options.leaseDuration ?? DEFAULT_LEASE_DURATION;
|
|
1087
1187
|
this.renewInterval = options.renewInterval ?? this.leaseDuration / 3;
|
|
1088
1188
|
this.abortGracePeriod = options.abortGracePeriod ?? DEFAULT_ABORT_GRACE_PERIOD;
|
|
1189
|
+
this.filter = options.filter;
|
|
1089
1190
|
if (!Number.isInteger(this.concurrency) || this.concurrency < 1) {
|
|
1090
1191
|
throw new RangeError("concurrency must be a positive integer");
|
|
1091
1192
|
}
|
|
@@ -1098,6 +1199,9 @@ class ExecutionDispatcher {
|
|
|
1098
1199
|
if (!(this.abortGracePeriod >= 0)) {
|
|
1099
1200
|
throw new RangeError("abortGracePeriod must not be negative");
|
|
1100
1201
|
}
|
|
1202
|
+
if (this.filter?.executionIds?.length === 0) {
|
|
1203
|
+
throw new RangeError("filter.executionIds must not be empty");
|
|
1204
|
+
}
|
|
1101
1205
|
}
|
|
1102
1206
|
start() {
|
|
1103
1207
|
if (this.running)
|
|
@@ -1124,7 +1228,8 @@ class ExecutionDispatcher {
|
|
|
1124
1228
|
try {
|
|
1125
1229
|
leases = await this.runtime.executions.claimDue({
|
|
1126
1230
|
limit: slots,
|
|
1127
|
-
duration: this.leaseDuration
|
|
1231
|
+
duration: this.leaseDuration,
|
|
1232
|
+
filter: this.filter
|
|
1128
1233
|
});
|
|
1129
1234
|
} finally {
|
|
1130
1235
|
this.claiming -= slots;
|
|
@@ -1693,6 +1798,11 @@ function diffStorePaths(previous, next) {
|
|
|
1693
1798
|
function visit(left, right, path) {
|
|
1694
1799
|
if (Object.is(left, right))
|
|
1695
1800
|
return;
|
|
1801
|
+
if (isOpaqueValue(left) || isOpaqueValue(right)) {
|
|
1802
|
+
if (!sameEncoding(left, right))
|
|
1803
|
+
paths.push(path);
|
|
1804
|
+
return;
|
|
1805
|
+
}
|
|
1696
1806
|
if (!isDiffableObject(left) || !isDiffableObject(right)) {
|
|
1697
1807
|
paths.push(path);
|
|
1698
1808
|
return;
|
|
@@ -1720,6 +1830,11 @@ function trackStoreSelector(state, selector) {
|
|
|
1720
1830
|
function track(value, path) {
|
|
1721
1831
|
if (!isDiffableObject(value))
|
|
1722
1832
|
return value;
|
|
1833
|
+
if (isOpaqueValue(value)) {
|
|
1834
|
+
if (path.length === 0)
|
|
1835
|
+
paths.push(path);
|
|
1836
|
+
return value;
|
|
1837
|
+
}
|
|
1723
1838
|
const cached = proxies.get(value);
|
|
1724
1839
|
if (cached)
|
|
1725
1840
|
return cached;
|
|
@@ -1766,6 +1881,10 @@ function trackStoreUpdater(target) {
|
|
|
1766
1881
|
function track(value, path) {
|
|
1767
1882
|
if (!isDiffableObject(value))
|
|
1768
1883
|
return value;
|
|
1884
|
+
if (isOpaqueValue(value)) {
|
|
1885
|
+
paths.push(path);
|
|
1886
|
+
return value;
|
|
1887
|
+
}
|
|
1769
1888
|
const cached = proxies.get(value);
|
|
1770
1889
|
if (cached)
|
|
1771
1890
|
return cached;
|
|
@@ -1818,6 +1937,14 @@ function isPathPrefix(prefix, path) {
|
|
|
1818
1937
|
function isDiffableObject(value) {
|
|
1819
1938
|
return typeof value === "object" && value !== null;
|
|
1820
1939
|
}
|
|
1940
|
+
function isOpaqueValue(value) {
|
|
1941
|
+
return value instanceof Date || value instanceof Map || value instanceof Set;
|
|
1942
|
+
}
|
|
1943
|
+
function sameEncoding(left, right) {
|
|
1944
|
+
const a = durableValueCodec.encode(left);
|
|
1945
|
+
const b = durableValueCodec.encode(right);
|
|
1946
|
+
return a.status === "encoded" && b.status === "encoded" && a.canonical === b.canonical;
|
|
1947
|
+
}
|
|
1821
1948
|
function arrayKeyToPathSegment(key) {
|
|
1822
1949
|
if (/^(0|[1-9]\d*)$/.test(key))
|
|
1823
1950
|
return Number(key);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Logger } from "pino";
|
|
2
2
|
import type { WorkflowInvoker } from "../base/invoker";
|
|
3
3
|
import type { Runtime } from "../base/runtime";
|
|
4
|
+
import type { ExecutionClaimFilter } from "../base/execution";
|
|
4
5
|
export declare const DEFAULT_DISPATCHER_CONCURRENCY = 10;
|
|
5
6
|
export declare const DEFAULT_ABORT_GRACE_PERIOD = 1000;
|
|
6
7
|
export interface DispatcherOptions {
|
|
@@ -28,6 +29,14 @@ export interface DispatcherOptions {
|
|
|
28
29
|
* @default 1_000
|
|
29
30
|
*/
|
|
30
31
|
abortGracePeriod?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Delivers only the executions that match. It is passed to every `claimDue`,
|
|
34
|
+
* so other executions are never claimed and gain no redelivery delay. An
|
|
35
|
+
* empty `executionIds` list is rejected, since the dispatcher would never
|
|
36
|
+
* deliver anything.
|
|
37
|
+
* @default every execution whose due time has passed
|
|
38
|
+
*/
|
|
39
|
+
filter?: ExecutionClaimFilter;
|
|
31
40
|
}
|
|
32
41
|
/**
|
|
33
42
|
* The only component that delivers executions. It leases due executions, reads
|
|
@@ -60,6 +69,7 @@ export declare class ExecutionDispatcher {
|
|
|
60
69
|
private leaseDuration;
|
|
61
70
|
private renewInterval;
|
|
62
71
|
private abortGracePeriod;
|
|
72
|
+
private filter;
|
|
63
73
|
private running;
|
|
64
74
|
private looping;
|
|
65
75
|
private timer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-dispatcher.d.ts","sourceRoot":"","sources":["../../src/lib/execution-dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAA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W,CAAS;IAC5B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,MAAM,CAAmC;IACjD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAA4C;IACzD,OAAO,CAAC,QAAQ,CAA4B;IAC5C,2DAA2D;IAC3D,OAAO,CAAC,QAAQ,CAAK;gBAET,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB;IA4BxD,KAAK;IAML,mEAAmE;IAC7D,IAAI;IAOV,IAAI,gBAAgB,WAEnB;IAED;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAyB7B,yDAAyD;IACnD,KAAK;IAMX,OAAO,CAAC,QAAQ;YASF,IAAI;YAiBJ,QAAQ;IAiFtB;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAiDzB;;;;;OAKG;IACH,OAAO,CAAC,KAAK;IAiDb,OAAO,CAAC,QAAQ;IAOhB,OAAO,CAAC,IAAI;CAOb"}
|
package/package.json
CHANGED
|
@@ -86,12 +86,16 @@ describe("durableValueCodec.encode rejects", () => {
|
|
|
86
86
|
test.each([
|
|
87
87
|
["functions", () => {}],
|
|
88
88
|
["symbols", Symbol("s")],
|
|
89
|
-
["bigints", 1n],
|
|
90
89
|
["NaN", Number.NaN],
|
|
91
90
|
["Infinity", Number.POSITIVE_INFINITY],
|
|
92
91
|
["-Infinity", Number.NEGATIVE_INFINITY],
|
|
93
|
-
["Dates", new Date(
|
|
94
|
-
["
|
|
92
|
+
["invalid Dates", new Date(Number.NaN)],
|
|
93
|
+
["Date subclasses", new (class Day extends Date {})(0)],
|
|
94
|
+
["Dates with own properties", Object.assign(new Date(0), { tz: "UTC" })],
|
|
95
|
+
["Map subclasses", new (class Index extends Map {})()],
|
|
96
|
+
["Sets with own properties", Object.assign(new Set(), { label: "s" })],
|
|
97
|
+
["Maps with invalid keys", new Map([[() => 1, 1]])],
|
|
98
|
+
["Sets with invalid values", new Set([Symbol("s")])],
|
|
95
99
|
["class instances", new (class Point {})()],
|
|
96
100
|
["array subclasses", new (class List extends Array {})()],
|
|
97
101
|
])("%s", (_label, value) => {
|
|
@@ -99,7 +103,8 @@ describe("durableValueCodec.encode rejects", () => {
|
|
|
99
103
|
});
|
|
100
104
|
|
|
101
105
|
test("nested invalid values, naming their path", () => {
|
|
102
|
-
expect(invalidMessage({ a: { b:
|
|
106
|
+
expect(invalidMessage({ a: { b: () => 1 } })).toMatch(/^\$\["a"\]\["b"\]: /);
|
|
107
|
+
expect(invalidMessage(new Map([["k", () => 1]]))).toMatch(/^\$\.entries\[0\]\[1\]: /);
|
|
103
108
|
});
|
|
104
109
|
|
|
105
110
|
test("missing array items", () => {
|
|
@@ -186,6 +191,69 @@ describe("durableValueCodec tags undefined", () => {
|
|
|
186
191
|
});
|
|
187
192
|
});
|
|
188
193
|
|
|
194
|
+
describe("durableValueCodec tags built-in types", () => {
|
|
195
|
+
test("bigints as decimal strings", () => {
|
|
196
|
+
expect(canonical(-12n)).toBe('{"$type":"bigint","value":"-12"}');
|
|
197
|
+
expect(roundTrip(2n ** 70n)).toBe(2n ** 70n);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test("Dates as ISO strings", () => {
|
|
201
|
+
const at = new Date("2026-10-29T12:00:00.123Z");
|
|
202
|
+
expect(canonical(at)).toBe('{"$type":"date","value":"2026-10-29T12:00:00.123Z"}');
|
|
203
|
+
const decoded = roundTrip(at);
|
|
204
|
+
expect(decoded).toBeInstanceOf(Date);
|
|
205
|
+
expect(decoded).not.toBe(at);
|
|
206
|
+
expect((decoded as Date).getTime()).toBe(at.getTime());
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
test("Dates outside the four-digit year range", () => {
|
|
210
|
+
const far = new Date(8.64e15);
|
|
211
|
+
expect((roundTrip(far) as Date).getTime()).toBe(far.getTime());
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test("Maps as entries in insertion order, with any durable keys", () => {
|
|
215
|
+
const map = new Map<unknown, unknown>([
|
|
216
|
+
["b", 1],
|
|
217
|
+
[1n, new Date(0)],
|
|
218
|
+
[{ id: 1 }, [undefined]],
|
|
219
|
+
]);
|
|
220
|
+
expect(canonical(new Map([["a", 1]]))).toBe('{"$type":"map","entries":[["a",1]]}');
|
|
221
|
+
expect(roundTrip(map)).toEqual(map);
|
|
222
|
+
expect([...(roundTrip(map) as Map<unknown, unknown>).keys()][0]).toBe("b");
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
test("Sets as values in insertion order", () => {
|
|
226
|
+
const set = new Set([3, 1, "x"]);
|
|
227
|
+
expect(canonical(set)).toBe('{"$type":"set","values":[3,1,"x"]}');
|
|
228
|
+
expect([...(roundTrip(set) as Set<unknown>)]).toEqual([3, 1, "x"]);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
test("Maps and Sets that differ only in order encode differently", () => {
|
|
232
|
+
expect(canonical(new Set([1, 2]))).not.toBe(canonical(new Set([2, 1])));
|
|
233
|
+
expect(canonical(new Map([["a", 1], ["b", 2]]))).not.toBe(
|
|
234
|
+
canonical(new Map([["b", 2], ["a", 1]]))
|
|
235
|
+
);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
test("nested inside objects, arrays and errors", () => {
|
|
239
|
+
const value = { at: new Date(0), tags: [new Set(["a"])], ids: new Map([[1, 2n]]) };
|
|
240
|
+
expect(roundTrip(value)).toEqual(value);
|
|
241
|
+
const error = Object.assign(new Error("boom"), { at: new Date(0) });
|
|
242
|
+
expect((roundTrip(error) as typeof error).at).toEqual(new Date(0));
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
test("a Map that contains itself is a reference cycle", () => {
|
|
246
|
+
const map = new Map<string, unknown>();
|
|
247
|
+
map.set("self", map);
|
|
248
|
+
expect(invalidMessage(map)).toMatch(/reference cycle/);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
test("plain objects shaped like the new tags read back as written", () => {
|
|
252
|
+
const value = { $type: "date", value: "2026-10-29T12:00:00.000Z" };
|
|
253
|
+
expect(roundTrip(value)).toEqual(value);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
|
|
189
257
|
describe("durableValueCodec wraps plain objects with a $type key", () => {
|
|
190
258
|
test("so they read back as written", () => {
|
|
191
259
|
const value = { $type: "undefined" };
|
|
@@ -243,7 +311,15 @@ describe("durableValueCodec.decode", () => {
|
|
|
243
311
|
|
|
244
312
|
test.each([
|
|
245
313
|
["text that is not JSON", "{"],
|
|
246
|
-
["an unknown tag", '{"$type":"
|
|
314
|
+
["an unknown tag", '{"$type":"regexp","value":"a"}'],
|
|
315
|
+
["a bigint that is not an integer string", '{"$type":"bigint","value":"1.5"}'],
|
|
316
|
+
["a bigint written as -0", '{"$type":"bigint","value":"-0"}'],
|
|
317
|
+
["a date that is not a string", '{"$type":"date","value":0}'],
|
|
318
|
+
["a date that is not in toISOString form", '{"$type":"date","value":"2026-10-29"}'],
|
|
319
|
+
["a map entry that is not a pair", '{"$type":"map","entries":[["a"]]}'],
|
|
320
|
+
["a map with duplicate keys", '{"$type":"map","entries":[["a",1],["a",2]]}'],
|
|
321
|
+
["a set with duplicate values", '{"$type":"set","values":[1,1]}'],
|
|
322
|
+
["a set without values", '{"$type":"set"}'],
|
|
247
323
|
["a tag with extra keys", '{"$type":"undefined","value":1}'],
|
|
248
324
|
["a wrapped value that is not an object", '{"$type":"object","value":[1]}'],
|
|
249
325
|
["an error without a message", '{"$type":"error","name":"Error"}'],
|
|
@@ -258,7 +334,7 @@ describe("Durable<T>", () => {
|
|
|
258
334
|
return value;
|
|
259
335
|
}
|
|
260
336
|
|
|
261
|
-
test("accepts interfaces, undefined and
|
|
337
|
+
test("accepts interfaces, undefined, errors and built-in types", () => {
|
|
262
338
|
interface Reservation {
|
|
263
339
|
id: string;
|
|
264
340
|
note?: string;
|
|
@@ -268,18 +344,19 @@ describe("Durable<T>", () => {
|
|
|
268
344
|
const reservation: Reservation = { id: "r", lines: [], error: null };
|
|
269
345
|
expectTypeOf(record(reservation)).toEqualTypeOf<Reservation>();
|
|
270
346
|
expectTypeOf(record(undefined)).toEqualTypeOf<undefined>();
|
|
347
|
+
record({ at: new Date(), n: 1n });
|
|
348
|
+
record({ map: new Map<string, { at: Date }>() });
|
|
349
|
+
record(new Set<number>());
|
|
350
|
+
const readonlyMap: ReadonlyMap<string, number> = new Map();
|
|
351
|
+
record({ readonlyMap });
|
|
271
352
|
});
|
|
272
353
|
|
|
273
|
-
test("rejects
|
|
274
|
-
// @ts-expect-error
|
|
275
|
-
record({ at: new Date() });
|
|
276
|
-
// @ts-expect-error
|
|
277
|
-
record({ map: new Map<string, number>() });
|
|
354
|
+
test("rejects functions, including inside Maps and Sets", () => {
|
|
278
355
|
// @ts-expect-error
|
|
279
|
-
record(
|
|
356
|
+
record({ fn: () => 1 });
|
|
280
357
|
// @ts-expect-error
|
|
281
|
-
record(
|
|
358
|
+
record(new Map<string, () => number>());
|
|
282
359
|
// @ts-expect-error
|
|
283
|
-
record(
|
|
360
|
+
record(new Set<() => number>());
|
|
284
361
|
});
|
|
285
362
|
});
|
|
@@ -6,8 +6,12 @@ export type DurableValue =
|
|
|
6
6
|
| number
|
|
7
7
|
| string
|
|
8
8
|
| undefined
|
|
9
|
+
| bigint
|
|
10
|
+
| Date
|
|
9
11
|
| Error
|
|
10
12
|
| DurableValue[]
|
|
13
|
+
| Map<DurableValue, DurableValue>
|
|
14
|
+
| Set<DurableValue>
|
|
11
15
|
| DurableObject;
|
|
12
16
|
|
|
13
17
|
export type DurableObject = { [key: string]: DurableValue };
|
|
@@ -23,11 +27,21 @@ export type Durable<T> = T extends
|
|
|
23
27
|
| boolean
|
|
24
28
|
| null
|
|
25
29
|
| undefined
|
|
30
|
+
| bigint
|
|
31
|
+
| Date
|
|
26
32
|
| Error
|
|
27
33
|
? T
|
|
28
34
|
: T extends readonly (infer U)[]
|
|
29
35
|
? readonly Durable<U>[]
|
|
30
|
-
: T extends
|
|
36
|
+
: T extends Map<infer K, infer V>
|
|
37
|
+
? Map<Durable<K>, Durable<V>>
|
|
38
|
+
: T extends ReadonlyMap<infer K, infer V>
|
|
39
|
+
? ReadonlyMap<Durable<K>, Durable<V>>
|
|
40
|
+
: T extends Set<infer U>
|
|
41
|
+
? Set<Durable<U>>
|
|
42
|
+
: T extends ReadonlySet<infer U>
|
|
43
|
+
? ReadonlySet<Durable<U>>
|
|
44
|
+
: T extends Function
|
|
31
45
|
? never
|
|
32
46
|
: { [K in keyof T]: Durable<T[K]> };
|
|
33
47
|
|
|
@@ -53,9 +67,11 @@ export interface DurableValueCodec {
|
|
|
53
67
|
/**
|
|
54
68
|
* Validates `value` recursively and returns its canonical JSON: object keys
|
|
55
69
|
* sorted by UTF-16 code unit and `-0` written as `0`, so equal values always
|
|
56
|
-
* encode to the same string. `undefined`,
|
|
57
|
-
* own `$type` key are written as tagged
|
|
58
|
-
*
|
|
70
|
+
* encode to the same string. `undefined`, `bigint`, `Date`, `Map`, `Set`,
|
|
71
|
+
* errors and plain objects with an own `$type` key are written as tagged
|
|
72
|
+
* objects. Map entries and set values keep their insertion order, so maps
|
|
73
|
+
* or sets that differ only in order encode differently. Never throws for an
|
|
74
|
+
* invalid value.
|
|
59
75
|
*/
|
|
60
76
|
encode(value: unknown): DurableValueEncoding;
|
|
61
77
|
|
|
@@ -134,6 +150,8 @@ function encodeValue(value: unknown, path: string, ancestors: Set<object>): stri
|
|
|
134
150
|
return value ? "true" : "false";
|
|
135
151
|
case "string":
|
|
136
152
|
return JSON.stringify(value);
|
|
153
|
+
case "bigint":
|
|
154
|
+
return `{"$type":"bigint","value":"${value}"}`;
|
|
137
155
|
case "number":
|
|
138
156
|
if (!Number.isFinite(value)) {
|
|
139
157
|
throw new DurableValueError(`${path}: ${value} is not a finite number`);
|
|
@@ -154,6 +172,9 @@ function encodeValue(value: unknown, path: string, ancestors: Set<object>): stri
|
|
|
154
172
|
try {
|
|
155
173
|
if (Array.isArray(value)) return encodeArray(value, path, ancestors);
|
|
156
174
|
if (value instanceof Error) return encodeError(value, path, ancestors);
|
|
175
|
+
if (value instanceof Date) return encodeDate(value, path);
|
|
176
|
+
if (value instanceof Map) return encodeMap(value, path, ancestors);
|
|
177
|
+
if (value instanceof Set) return encodeSet(value, path, ancestors);
|
|
157
178
|
return encodeObject(value, path, ancestors);
|
|
158
179
|
} finally {
|
|
159
180
|
// Error encoding recovers from invalid properties, so the set must be
|
|
@@ -187,6 +208,52 @@ function encodeArray(value: unknown[], path: string, ancestors: Set<object>) {
|
|
|
187
208
|
return `[${items.join(",")}]`;
|
|
188
209
|
}
|
|
189
210
|
|
|
211
|
+
function encodeDate(value: Date, path: string) {
|
|
212
|
+
expectBuiltIn(value, Date.prototype, "dates", path);
|
|
213
|
+
if (Number.isNaN(value.getTime())) {
|
|
214
|
+
throw new DurableValueError(`${path}: invalid Date`);
|
|
215
|
+
}
|
|
216
|
+
return `{"$type":"date","value":${JSON.stringify(value.toISOString())}}`;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function encodeMap(
|
|
220
|
+
value: Map<unknown, unknown>,
|
|
221
|
+
path: string,
|
|
222
|
+
ancestors: Set<object>
|
|
223
|
+
) {
|
|
224
|
+
expectBuiltIn(value, Map.prototype, "maps", path);
|
|
225
|
+
const entries: string[] = [];
|
|
226
|
+
let i = 0;
|
|
227
|
+
for (const [key, item] of value) {
|
|
228
|
+
const entryPath = `${path}.entries[${i++}]`;
|
|
229
|
+
const encodedKey = encodeValue(key, `${entryPath}[0]`, ancestors);
|
|
230
|
+
entries.push(`[${encodedKey},${encodeValue(item, `${entryPath}[1]`, ancestors)}]`);
|
|
231
|
+
}
|
|
232
|
+
return `{"$type":"map","entries":[${entries.join(",")}]}`;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function encodeSet(value: Set<unknown>, path: string, ancestors: Set<object>) {
|
|
236
|
+
expectBuiltIn(value, Set.prototype, "sets", path);
|
|
237
|
+
const values: string[] = [];
|
|
238
|
+
let i = 0;
|
|
239
|
+
for (const item of value) {
|
|
240
|
+
values.push(encodeValue(item, `${path}.values[${i++}]`, ancestors));
|
|
241
|
+
}
|
|
242
|
+
return `{"$type":"set","values":[${values.join(",")}]}`;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Rejects subclasses and own properties, which the tag would not keep.
|
|
247
|
+
*/
|
|
248
|
+
function expectBuiltIn(value: object, proto: object, kind: string, path: string) {
|
|
249
|
+
if (Object.getPrototypeOf(value) !== proto) {
|
|
250
|
+
throw new DurableValueError(`${path}: ${kind} must not be subclassed`);
|
|
251
|
+
}
|
|
252
|
+
if (Reflect.ownKeys(value).length > 0) {
|
|
253
|
+
throw new DurableValueError(`${path}: ${kind} must not have own properties`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
190
257
|
function encodeObject(value: object, path: string, ancestors: Set<object>) {
|
|
191
258
|
if (!isPlainObject(value)) {
|
|
192
259
|
const name = Object.getPrototypeOf(value)?.constructor?.name ?? "object";
|
|
@@ -336,6 +403,14 @@ export function decodeParsedValue(parsed: unknown, path = "$"): DurableValue {
|
|
|
336
403
|
}
|
|
337
404
|
return decodeObject(value as Record<string, unknown>, `${path}.value`);
|
|
338
405
|
}
|
|
406
|
+
case "bigint":
|
|
407
|
+
return decodeBigInt(object, path);
|
|
408
|
+
case "date":
|
|
409
|
+
return decodeDate(object, path);
|
|
410
|
+
case "map":
|
|
411
|
+
return decodeMap(object, path);
|
|
412
|
+
case "set":
|
|
413
|
+
return decodeSet(object, path);
|
|
339
414
|
case "error":
|
|
340
415
|
return decodeError(object, path);
|
|
341
416
|
default:
|
|
@@ -343,6 +418,69 @@ export function decodeParsedValue(parsed: unknown, path = "$"): DurableValue {
|
|
|
343
418
|
}
|
|
344
419
|
}
|
|
345
420
|
|
|
421
|
+
function decodeBigInt(tag: Record<string, unknown>, path: string): bigint {
|
|
422
|
+
expectKeys(tag, path, ["$type", "value"], []);
|
|
423
|
+
const { value } = tag;
|
|
424
|
+
if (typeof value !== "string" || !/^-?(0|[1-9][0-9]*)$/.test(value) || value === "-0") {
|
|
425
|
+
throw new DurableValueError(`${path}.value: must be an integer string`);
|
|
426
|
+
}
|
|
427
|
+
return BigInt(value);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function decodeDate(tag: Record<string, unknown>, path: string): Date {
|
|
431
|
+
expectKeys(tag, path, ["$type", "value"], []);
|
|
432
|
+
const { value } = tag;
|
|
433
|
+
const date = typeof value === "string" ? new Date(value) : undefined;
|
|
434
|
+
// Only the string toISOString writes is accepted, so that every date has
|
|
435
|
+
// one encoding.
|
|
436
|
+
if (!date || Number.isNaN(date.getTime()) || date.toISOString() !== value) {
|
|
437
|
+
throw new DurableValueError(`${path}.value: must be an ISO 8601 date string`);
|
|
438
|
+
}
|
|
439
|
+
return date;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function decodeMap(
|
|
443
|
+
tag: Record<string, unknown>,
|
|
444
|
+
path: string
|
|
445
|
+
): Map<DurableValue, DurableValue> {
|
|
446
|
+
expectKeys(tag, path, ["$type", "entries"], []);
|
|
447
|
+
const entries = expectArray(tag.entries, `${path}.entries`);
|
|
448
|
+
const map = new Map<DurableValue, DurableValue>();
|
|
449
|
+
entries.forEach((entry, i) => {
|
|
450
|
+
const entryPath = `${path}.entries[${i}]`;
|
|
451
|
+
if (!Array.isArray(entry) || entry.length !== 2) {
|
|
452
|
+
throw new DurableValueError(`${entryPath}: must be a [key, value] pair`);
|
|
453
|
+
}
|
|
454
|
+
map.set(
|
|
455
|
+
decodeParsedValue(entry[0], `${entryPath}[0]`),
|
|
456
|
+
decodeParsedValue(entry[1], `${entryPath}[1]`)
|
|
457
|
+
);
|
|
458
|
+
});
|
|
459
|
+
if (map.size !== entries.length) {
|
|
460
|
+
throw new DurableValueError(`${path}.entries: duplicate keys`);
|
|
461
|
+
}
|
|
462
|
+
return map;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function decodeSet(tag: Record<string, unknown>, path: string): Set<DurableValue> {
|
|
466
|
+
expectKeys(tag, path, ["$type", "values"], []);
|
|
467
|
+
const values = expectArray(tag.values, `${path}.values`);
|
|
468
|
+
const set = new Set(
|
|
469
|
+
values.map((item, i) => decodeParsedValue(item, `${path}.values[${i}]`))
|
|
470
|
+
);
|
|
471
|
+
if (set.size !== values.length) {
|
|
472
|
+
throw new DurableValueError(`${path}.values: duplicate values`);
|
|
473
|
+
}
|
|
474
|
+
return set;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
function expectArray(value: unknown, path: string): unknown[] {
|
|
478
|
+
if (!Array.isArray(value)) {
|
|
479
|
+
throw new DurableValueError(`${path}: must be an array`);
|
|
480
|
+
}
|
|
481
|
+
return value;
|
|
482
|
+
}
|
|
483
|
+
|
|
346
484
|
function decodeObject(object: Record<string, unknown>, path: string): DurableObject {
|
|
347
485
|
const decoded: DurableObject = {};
|
|
348
486
|
for (const key of Object.keys(object)) {
|
package/src/base/errors.test.ts
CHANGED
|
@@ -97,12 +97,14 @@ describe("error encoding", () => {
|
|
|
97
97
|
|
|
98
98
|
test("omits non-durable properties", () => {
|
|
99
99
|
const error = Object.assign(new Error("boom"), {
|
|
100
|
-
at: new
|
|
100
|
+
at: new WeakMap(),
|
|
101
101
|
handler: () => {},
|
|
102
102
|
ok: 1,
|
|
103
|
+
when: new Date(0),
|
|
103
104
|
});
|
|
104
105
|
const revived = roundTrip(error);
|
|
105
|
-
expect(Object.keys(revived)).toEqual(["ok"]);
|
|
106
|
+
expect(Object.keys(revived)).toEqual(["ok", "when"]);
|
|
107
|
+
expect((revived as unknown as { when: Date }).when).toEqual(new Date(0));
|
|
106
108
|
});
|
|
107
109
|
|
|
108
110
|
test("ignores a non-string code", () => {
|
|
@@ -202,9 +204,9 @@ describe("encodeThrownValue", () => {
|
|
|
202
204
|
});
|
|
203
205
|
|
|
204
206
|
test("records a non-durable thrown value as Error(String(value))", () => {
|
|
205
|
-
const revived = decode(encodeThrownValue(new
|
|
207
|
+
const revived = decode(encodeThrownValue(new WeakMap())) as Error;
|
|
206
208
|
expect(Object.getPrototypeOf(revived)).toBe(Error.prototype);
|
|
207
|
-
expect(revived.message).toBe(String(new
|
|
208
|
-
expect((decode(encodeThrownValue(
|
|
209
|
+
expect(revived.message).toBe(String(new WeakMap()));
|
|
210
|
+
expect((decode(encodeThrownValue(Symbol("s"))) as Error).message).toBe("Symbol(s)");
|
|
209
211
|
});
|
|
210
212
|
});
|
package/src/base/execution.ts
CHANGED
|
@@ -62,6 +62,16 @@ export type ExecutionLease = {
|
|
|
62
62
|
expiresAt: number;
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Limits a claim to the executions that match. The claim applies it in the same
|
|
67
|
+
* atomic step, so an execution that does not match is not leased and gains no
|
|
68
|
+
* redelivery delay.
|
|
69
|
+
*/
|
|
70
|
+
export type ExecutionClaimFilter = {
|
|
71
|
+
/** Claims only executions whose ID is in this list. An empty list claims nothing. */
|
|
72
|
+
executionIds?: readonly string[];
|
|
73
|
+
};
|
|
74
|
+
|
|
65
75
|
/**
|
|
66
76
|
* Returned by a fenced write whose lease is no longer current: a higher token
|
|
67
77
|
* has been issued, or the lease has ended. The write changed nothing, and its
|
|
@@ -184,6 +194,8 @@ export interface ExecutionClient {
|
|
|
184
194
|
claimDue(request: {
|
|
185
195
|
limit: number;
|
|
186
196
|
duration: number;
|
|
197
|
+
/** When absent, any execution whose due time has passed may be claimed. */
|
|
198
|
+
filter?: ExecutionClaimFilter;
|
|
187
199
|
}): Promise<ExecutionLease[]>;
|
|
188
200
|
|
|
189
201
|
/**
|
package/src/base/store.test.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { expect, test } from "vitest";
|
|
2
2
|
import {
|
|
3
3
|
cloneStoreState,
|
|
4
|
+
diffStorePaths,
|
|
4
5
|
storePathsIntersect,
|
|
5
6
|
trackStoreSelector,
|
|
6
7
|
trackStoreUpdater,
|
|
@@ -174,3 +175,58 @@ test("cloneStoreState launders proxy wrappers into plain objects", () => {
|
|
|
174
175
|
expect(() => structuredClone(clean)).not.toThrow();
|
|
175
176
|
expect(clean.wrapper.inner).toEqual(makeState().messages);
|
|
176
177
|
});
|
|
178
|
+
|
|
179
|
+
type Ledger = { opened: Date; totals: Map<string, number>; seen: Set<string>; note: string };
|
|
180
|
+
|
|
181
|
+
function makeLedger(): Ledger {
|
|
182
|
+
return {
|
|
183
|
+
opened: new Date(0),
|
|
184
|
+
totals: new Map([["mug", 1]]),
|
|
185
|
+
seen: new Set(["mug"]),
|
|
186
|
+
note: "",
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
test("trackStoreUpdater: Map, Set and Date methods work on the draft and record their path", () => {
|
|
191
|
+
const draft = makeLedger();
|
|
192
|
+
const tracked = trackStoreUpdater(draft);
|
|
193
|
+
|
|
194
|
+
tracked.draft.totals.set("cup", 2);
|
|
195
|
+
tracked.draft.seen.add("cup");
|
|
196
|
+
tracked.draft.opened.setTime(1);
|
|
197
|
+
|
|
198
|
+
const paths = tracked.writePaths();
|
|
199
|
+
expect(wakes(["totals"], paths)).toBe(true);
|
|
200
|
+
expect(wakes(["seen"], paths)).toBe(true);
|
|
201
|
+
expect(wakes(["opened"], paths)).toBe(true);
|
|
202
|
+
expect(wakes(["note"], paths)).toBe(false);
|
|
203
|
+
expect(draft.totals.get("cup")).toBe(2);
|
|
204
|
+
expect(draft.seen.has("cup")).toBe(true);
|
|
205
|
+
expect(draft.opened.getTime()).toBe(1);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
test("trackStoreSelector: Map, Set and Date methods work and record a read of the whole value", () => {
|
|
209
|
+
const { result, readPaths } = trackStoreSelector(makeLedger(), (state) => [
|
|
210
|
+
state.totals.get("mug"),
|
|
211
|
+
state.seen.has("mug"),
|
|
212
|
+
state.opened.getTime(),
|
|
213
|
+
]);
|
|
214
|
+
|
|
215
|
+
expect(result).toEqual([1, true, 0]);
|
|
216
|
+
expect(readPaths).toEqual(
|
|
217
|
+
expect.arrayContaining([["totals"], ["seen"], ["opened"]])
|
|
218
|
+
);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
test("diffStorePaths: compares Maps, Sets and Dates by content", () => {
|
|
222
|
+
const next = makeLedger();
|
|
223
|
+
expect(diffStorePaths(makeLedger(), next)).toEqual([]);
|
|
224
|
+
|
|
225
|
+
next.totals.set("mug", 2);
|
|
226
|
+
next.seen.add("cup");
|
|
227
|
+
next.opened = new Date(1);
|
|
228
|
+
expect(diffStorePaths(makeLedger(), next)).toEqual(
|
|
229
|
+
expect.arrayContaining([["totals"], ["seen"], ["opened"]])
|
|
230
|
+
);
|
|
231
|
+
expect(diffStorePaths(makeLedger(), next)).toHaveLength(3);
|
|
232
|
+
});
|
package/src/base/store.ts
CHANGED
|
@@ -2,7 +2,13 @@ import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
|
2
2
|
import { durableValueCodec, type Durable, type IfDurable } from "./durable-value";
|
|
3
3
|
import { WorkflowValueError, registerErrorClass } from "./errors";
|
|
4
4
|
|
|
5
|
-
export type Draft<T> = T extends
|
|
5
|
+
export type Draft<T> = T extends Date
|
|
6
|
+
? T
|
|
7
|
+
: T extends ReadonlyMap<infer K, infer V>
|
|
8
|
+
? Map<Draft<K>, Draft<V>>
|
|
9
|
+
: T extends ReadonlySet<infer U>
|
|
10
|
+
? Set<Draft<U>>
|
|
11
|
+
: T extends object
|
|
6
12
|
? { -readonly [K in keyof T]: Draft<T[K]> }
|
|
7
13
|
: T;
|
|
8
14
|
|
|
@@ -904,6 +910,11 @@ export function diffStorePaths(previous: unknown, next: unknown): StorePath[] {
|
|
|
904
910
|
function visit(left: unknown, right: unknown, path: StorePath) {
|
|
905
911
|
if (Object.is(left, right)) return;
|
|
906
912
|
|
|
913
|
+
if (isOpaqueValue(left) || isOpaqueValue(right)) {
|
|
914
|
+
if (!sameEncoding(left, right)) paths.push(path);
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
|
|
907
918
|
if (!isDiffableObject(left) || !isDiffableObject(right)) {
|
|
908
919
|
paths.push(path);
|
|
909
920
|
return;
|
|
@@ -953,6 +964,12 @@ export function trackStoreSelector<T, R>(
|
|
|
953
964
|
|
|
954
965
|
function track(value: unknown, path: StorePath): unknown {
|
|
955
966
|
if (!isDiffableObject(value)) return value;
|
|
967
|
+
if (isOpaqueValue(value)) {
|
|
968
|
+
// The selector reads the whole value, because its methods do not work
|
|
969
|
+
// on a proxy.
|
|
970
|
+
if (path.length === 0) paths.push(path);
|
|
971
|
+
return value;
|
|
972
|
+
}
|
|
956
973
|
|
|
957
974
|
const cached = proxies.get(value);
|
|
958
975
|
if (cached) return cached;
|
|
@@ -1045,6 +1062,12 @@ export function trackStoreUpdater<T>(target: T): TrackedStoreUpdater<T> {
|
|
|
1045
1062
|
|
|
1046
1063
|
function track(value: unknown, path: StorePath): unknown {
|
|
1047
1064
|
if (!isDiffableObject(value)) return value;
|
|
1065
|
+
if (isOpaqueValue(value)) {
|
|
1066
|
+
// Its methods do not work on a proxy, so the updater gets the raw value
|
|
1067
|
+
// and any read of it is recorded as a write.
|
|
1068
|
+
paths.push(path);
|
|
1069
|
+
return value;
|
|
1070
|
+
}
|
|
1048
1071
|
|
|
1049
1072
|
const cached = proxies.get(value);
|
|
1050
1073
|
if (cached) return cached;
|
|
@@ -1117,6 +1140,20 @@ function isDiffableObject(value: unknown): value is Record<string, unknown> {
|
|
|
1117
1140
|
return typeof value === "object" && value !== null;
|
|
1118
1141
|
}
|
|
1119
1142
|
|
|
1143
|
+
/**
|
|
1144
|
+
* Whether `value` keeps its contents in internal slots, which proxies and
|
|
1145
|
+
* `Object.keys` cannot see.
|
|
1146
|
+
*/
|
|
1147
|
+
function isOpaqueValue(value: unknown): value is Date | Map<unknown, unknown> | Set<unknown> {
|
|
1148
|
+
return value instanceof Date || value instanceof Map || value instanceof Set;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
function sameEncoding(left: unknown, right: unknown) {
|
|
1152
|
+
const a = durableValueCodec.encode(left);
|
|
1153
|
+
const b = durableValueCodec.encode(right);
|
|
1154
|
+
return a.status === "encoded" && b.status === "encoded" && a.canonical === b.canonical;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1120
1157
|
function arrayKeyToPathSegment(key: string): string | number {
|
|
1121
1158
|
if (/^(0|[1-9]\d*)$/.test(key)) return Number(key);
|
|
1122
1159
|
return key;
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { WorkerExitedError } from "../base/invoker";
|
|
|
4
4
|
import type { Runtime } from "../base/runtime";
|
|
5
5
|
import type {
|
|
6
6
|
ExecutionAcknowledgeResult,
|
|
7
|
+
ExecutionClaimFilter,
|
|
7
8
|
ExecutionLease,
|
|
8
9
|
WorkflowRunOutcome,
|
|
9
10
|
} from "../base/execution";
|
|
@@ -41,6 +42,14 @@ export interface DispatcherOptions {
|
|
|
41
42
|
* @default 1_000
|
|
42
43
|
*/
|
|
43
44
|
abortGracePeriod?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Delivers only the executions that match. It is passed to every `claimDue`,
|
|
47
|
+
* so other executions are never claimed and gain no redelivery delay. An
|
|
48
|
+
* empty `executionIds` list is rejected, since the dispatcher would never
|
|
49
|
+
* deliver anything.
|
|
50
|
+
* @default every execution whose due time has passed
|
|
51
|
+
*/
|
|
52
|
+
filter?: ExecutionClaimFilter;
|
|
44
53
|
}
|
|
45
54
|
|
|
46
55
|
/**
|
|
@@ -74,6 +83,7 @@ export class ExecutionDispatcher {
|
|
|
74
83
|
private leaseDuration: number;
|
|
75
84
|
private renewInterval: number;
|
|
76
85
|
private abortGracePeriod: number;
|
|
86
|
+
private filter: ExecutionClaimFilter | undefined;
|
|
77
87
|
private running = false;
|
|
78
88
|
private looping = false;
|
|
79
89
|
private timer: ReturnType<typeof setTimeout> | undefined;
|
|
@@ -91,6 +101,7 @@ export class ExecutionDispatcher {
|
|
|
91
101
|
this.leaseDuration = options.leaseDuration ?? DEFAULT_LEASE_DURATION;
|
|
92
102
|
this.renewInterval = options.renewInterval ?? this.leaseDuration / 3;
|
|
93
103
|
this.abortGracePeriod = options.abortGracePeriod ?? DEFAULT_ABORT_GRACE_PERIOD;
|
|
104
|
+
this.filter = options.filter;
|
|
94
105
|
if (!Number.isInteger(this.concurrency) || this.concurrency < 1) {
|
|
95
106
|
throw new RangeError("concurrency must be a positive integer");
|
|
96
107
|
}
|
|
@@ -103,6 +114,9 @@ export class ExecutionDispatcher {
|
|
|
103
114
|
if (!(this.abortGracePeriod >= 0)) {
|
|
104
115
|
throw new RangeError("abortGracePeriod must not be negative");
|
|
105
116
|
}
|
|
117
|
+
if (this.filter?.executionIds?.length === 0) {
|
|
118
|
+
throw new RangeError("filter.executionIds must not be empty");
|
|
119
|
+
}
|
|
106
120
|
}
|
|
107
121
|
|
|
108
122
|
start() {
|
|
@@ -137,6 +151,7 @@ export class ExecutionDispatcher {
|
|
|
137
151
|
leases = await this.runtime.executions.claimDue({
|
|
138
152
|
limit: slots,
|
|
139
153
|
duration: this.leaseDuration,
|
|
154
|
+
filter: this.filter,
|
|
140
155
|
});
|
|
141
156
|
} finally {
|
|
142
157
|
this.claiming -= slots;
|
|
@@ -30,7 +30,7 @@ test.each([
|
|
|
30
30
|
["array params", { workflowId: "w", params: [] }],
|
|
31
31
|
["null params", { workflowId: "w", params: null }],
|
|
32
32
|
["string params", { workflowId: "w", params: "x" }],
|
|
33
|
-
["class instance params", { workflowId: "w", params: new
|
|
33
|
+
["class instance params", { workflowId: "w", params: new WeakMap() }],
|
|
34
34
|
])("prepareExecutionStart rejects %s", (_label, request) => {
|
|
35
35
|
const prepared = prepareExecutionStart({ requestId, ...request } as never);
|
|
36
36
|
expect(prepared.ok).toBe(false);
|
|
@@ -169,8 +169,8 @@ test("execution events round trip through the codec", () => {
|
|
|
169
169
|
});
|
|
170
170
|
|
|
171
171
|
test.each([
|
|
172
|
-
["
|
|
173
|
-
["a
|
|
172
|
+
["an invalid Date in params", { params: { at: new Date(Number.NaN) }, context: new Map() }],
|
|
173
|
+
["a WeakMap in context", { params: {}, context: new Map([["at", new WeakMap()]]) }],
|
|
174
174
|
["a number context key", { params: {}, context: new Map([[7, 1]]) }],
|
|
175
175
|
])("prepareExecutionAdmission rejects %s with INVALID_EXECUTION_EVENT", (_label, event) => {
|
|
176
176
|
expect(prepareExecutionAdmission({ workflowId: "w", ...event })).toMatchObject({
|
|
@@ -233,7 +233,7 @@ test("acknowledging a non-durable result records a failed outcome with INVALID_S
|
|
|
233
233
|
const { state, lease } = claimExecution(admitted, { now: 0, duration: 1_000 });
|
|
234
234
|
const acknowledged = acknowledgeExecution(state, {
|
|
235
235
|
lease,
|
|
236
|
-
outcome: { status: "completed", result: { at: new
|
|
236
|
+
outcome: { status: "completed", result: { at: new WeakMap() } },
|
|
237
237
|
now: 1,
|
|
238
238
|
});
|
|
239
239
|
expect(acknowledged.state.status).toBe("failed");
|