@yieldstar/core 0.4.6 → 0.5.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/step.d.ts +5 -0
- package/dist/base/step.d.ts.map +1 -1
- package/dist/base/store.d.ts +317 -0
- package/dist/base/store.d.ts.map +1 -0
- package/dist/base/store.test.d.ts +2 -0
- package/dist/base/store.test.d.ts.map +1 -0
- package/dist/base/workflow.d.ts +2 -0
- package/dist/base/workflow.d.ts.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +403 -3
- package/dist/lib/workflow-runner.d.ts +3 -1
- package/dist/lib/workflow-runner.d.ts.map +1 -1
- package/dist/utils/map.d.ts +1 -1
- package/dist/utils/map.d.ts.map +1 -1
- package/package.json +13 -3
- package/src/base/step.ts +8 -0
- package/src/base/store.test.ts +176 -0
- package/src/base/store.ts +833 -0
- package/src/base/workflow.ts +2 -0
- package/src/index.ts +37 -0
- package/src/lib/workflow-runner.ts +14 -2
- package/src/utils/map.test.ts +1 -1
- package/src/utils/map.ts +8 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/base/map.d.ts +0 -21
- package/dist/base/map.d.ts.map +0 -1
- package/dist/base/map.test.d.ts +0 -2
- package/dist/base/map.test.d.ts.map +0 -1
- package/dist/base/schedule.d.ts +0 -71
- package/dist/base/schedule.d.ts.map +0 -1
- package/dist/base/types.d.ts +0 -24
- package/dist/base/types.d.ts.map +0 -1
package/dist/base/step.d.ts
CHANGED
|
@@ -33,6 +33,11 @@ export declare class WorkflowDelay extends StepResponse {
|
|
|
33
33
|
resumeIn: number;
|
|
34
34
|
constructor(resumeIn: number);
|
|
35
35
|
}
|
|
36
|
+
export declare class StepStoreWait extends StepResponse {
|
|
37
|
+
static type: string;
|
|
38
|
+
readonly type = "store-wait";
|
|
39
|
+
constructor();
|
|
40
|
+
}
|
|
36
41
|
export declare class WorkflowRestart extends StepResponse {
|
|
37
42
|
static type: string;
|
|
38
43
|
readonly type = "workflow-restart";
|
package/dist/base/step.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/base/step.ts"],"names":[],"mappings":"AAAA,8BAAsB,YAAY;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,OAAQ,SAAQ,YAAY;IACvC,MAAM,CAAC,IAAI,SAAc;IACzB,QAAQ,CAAC,IAAI,cAAc;IAC3B,GAAG,EAAE,MAAM,CAAC;gBACA,GAAG,EAAE,MAAM;CAIxB;AAED,qBAAa,cAAe,SAAQ,YAAY;IAC9C,MAAM,CAAC,IAAI,SAAiB;IAC5B,QAAQ,CAAC,IAAI,iBAAiB;CAC/B;AAED,qBAAa,WAAY,SAAQ,YAAY;IAC3C,MAAM,CAAC,IAAI,SAAkB;IAC7B,QAAQ,CAAC,IAAI,kBAAkB;CAChC;AAED,qBAAa,UAAW,SAAQ,YAAY;IAC1C,MAAM,CAAC,IAAI,SAAiB;IAC5B,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,MAAM,EAAE,GAAG,CAAC;gBACA,MAAM,EAAE,GAAG;CAIxB;AAED,qBAAa,cAAc,CAAC,CAAC,SAAS,GAAG,CAAE,SAAQ,YAAY;IAC7D,MAAM,CAAC,IAAI,SAAqB;IAChC,QAAQ,CAAC,IAAI,qBAAqB;IAClC,MAAM,EAAE,CAAC,CAAC;gBACE,MAAM,EAAE,CAAC;CAItB;AAED,qBAAa,aAAc,SAAQ,YAAY;IAC7C,MAAM,CAAC,IAAI,SAAoB;IAC/B,QAAQ,CAAC,IAAI,oBAAoB;IACjC,QAAQ,EAAE,MAAM,CAAC;gBACL,QAAQ,EAAE,MAAM;CAI7B;AAED,qBAAa,eAAgB,SAAQ,YAAY;IAC/C,MAAM,CAAC,IAAI,SAAsB;IACjC,QAAQ,CAAC,IAAI,sBAAsB;;CAIpC;AAED,qBAAa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vent } from "./event";
|
|
3
|
+
export type Draft<T> = T extends object ? {
|
|
4
|
+
-readonly [K in keyof T]: Draft<T[K]>;
|
|
5
|
+
} : T;
|
|
6
|
+
export type StoreVersion = number;
|
|
7
|
+
export type StorePath = readonly (string | number)[];
|
|
8
|
+
export type StoreDefinition<Schema extends StandardSchemaV1 = StandardSchemaV1> = {
|
|
9
|
+
name: string;
|
|
10
|
+
schema: Schema;
|
|
11
|
+
};
|
|
12
|
+
export type StoreState<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema>;
|
|
13
|
+
export type StoreKey = {
|
|
14
|
+
storeName: string;
|
|
15
|
+
storeId: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Identifies the durable workflow step performing a store operation.
|
|
19
|
+
* When provided to `updateStore`/`takeFromStore`, the store client records
|
|
20
|
+
* the committed result in an applied-steps ledger keyed by
|
|
21
|
+
* (storeName, storeId, executionId, stepKey), written atomically with the
|
|
22
|
+
* state change. A retried call with the same StoreStepId returns the recorded
|
|
23
|
+
* result without re-running the updater/selector/claim, making the operation
|
|
24
|
+
* exactly-once even if the caller crashes before persisting its own record
|
|
25
|
+
* of the result (e.g. the workflow heap write).
|
|
26
|
+
*/
|
|
27
|
+
export type StoreStepId = {
|
|
28
|
+
executionId: string;
|
|
29
|
+
stepKey: string;
|
|
30
|
+
};
|
|
31
|
+
export type StoreSnapshot<T> = {
|
|
32
|
+
state: T;
|
|
33
|
+
instanceId: string;
|
|
34
|
+
version: StoreVersion;
|
|
35
|
+
};
|
|
36
|
+
export type StoreUpdateResult<T> = {
|
|
37
|
+
state: T;
|
|
38
|
+
previousVersion: StoreVersion;
|
|
39
|
+
version: StoreVersion;
|
|
40
|
+
};
|
|
41
|
+
export type StoreUpdateFromResult<T> = ({
|
|
42
|
+
updated: true;
|
|
43
|
+
} & StoreUpdateResult<T>) | {
|
|
44
|
+
updated: false;
|
|
45
|
+
expectedInstanceId: string;
|
|
46
|
+
actualInstanceId: string;
|
|
47
|
+
expectedVersion: StoreVersion;
|
|
48
|
+
actualVersion: StoreVersion;
|
|
49
|
+
};
|
|
50
|
+
export type StoreDeleteFromResult = {
|
|
51
|
+
deleted: true;
|
|
52
|
+
} | {
|
|
53
|
+
deleted: false;
|
|
54
|
+
reason: "conflict";
|
|
55
|
+
expectedInstanceId: string;
|
|
56
|
+
actualInstanceId: string;
|
|
57
|
+
expectedVersion: StoreVersion;
|
|
58
|
+
actualVersion: StoreVersion;
|
|
59
|
+
} | {
|
|
60
|
+
deleted: false;
|
|
61
|
+
reason: "not-found";
|
|
62
|
+
expectedInstanceId: string;
|
|
63
|
+
expectedVersion: StoreVersion;
|
|
64
|
+
};
|
|
65
|
+
export type StoreSelector<T, R> = (state: Readonly<T>) => R;
|
|
66
|
+
export type StoreTakeResult<R> = {
|
|
67
|
+
matched: true;
|
|
68
|
+
selected: NonNullable<R>;
|
|
69
|
+
instanceId: string;
|
|
70
|
+
version: StoreVersion;
|
|
71
|
+
} | {
|
|
72
|
+
matched: false;
|
|
73
|
+
instanceId: string;
|
|
74
|
+
version: StoreVersion;
|
|
75
|
+
readPaths: StorePath[];
|
|
76
|
+
};
|
|
77
|
+
export type StoreWaiter = {
|
|
78
|
+
workflowId: string;
|
|
79
|
+
executionId: string;
|
|
80
|
+
stepKey: string;
|
|
81
|
+
event: WorkflowEvent;
|
|
82
|
+
storeName: string;
|
|
83
|
+
storeId: string;
|
|
84
|
+
instanceId: string;
|
|
85
|
+
sinceVersion: StoreVersion;
|
|
86
|
+
readPaths: StorePath[];
|
|
87
|
+
};
|
|
88
|
+
export type StoreMutationCommitResult = {
|
|
89
|
+
status: "committed";
|
|
90
|
+
} | {
|
|
91
|
+
status: "already-applied";
|
|
92
|
+
result: unknown;
|
|
93
|
+
} | {
|
|
94
|
+
status: "conflict";
|
|
95
|
+
snapshot: StoreSnapshot<unknown>;
|
|
96
|
+
};
|
|
97
|
+
export type StoreMutation = {
|
|
98
|
+
definition: StoreDefinition;
|
|
99
|
+
id: string;
|
|
100
|
+
expected: StoreSnapshot<unknown>;
|
|
101
|
+
nextState: unknown;
|
|
102
|
+
changedPaths: StorePath[];
|
|
103
|
+
stepId?: StoreStepId;
|
|
104
|
+
result: unknown;
|
|
105
|
+
};
|
|
106
|
+
export type RuntimeStore<T> = {
|
|
107
|
+
get(): Promise<StoreSnapshot<T>>;
|
|
108
|
+
update(updater: (draft: Draft<T>) => void | T): Promise<StoreUpdateResult<T>>;
|
|
109
|
+
updateFrom(snapshot: StoreSnapshot<T>, updater: (draft: Draft<T>) => void | T): Promise<StoreUpdateFromResult<T>>;
|
|
110
|
+
deleteFrom(snapshot: StoreSnapshot<T>): Promise<StoreDeleteFromResult>;
|
|
111
|
+
};
|
|
112
|
+
export declare function defineStore<Schema extends StandardSchemaV1>(name: string, schema: Schema): StoreDefinition<Schema>;
|
|
113
|
+
export declare abstract class StoreClient {
|
|
114
|
+
store<Schema extends StandardSchemaV1>(definition: StoreDefinition<Schema>, id: string): RuntimeStore<StoreState<Schema>>;
|
|
115
|
+
abstract getOrCreateStore<Schema extends StandardSchemaV1>(params: {
|
|
116
|
+
definition: StoreDefinition<Schema>;
|
|
117
|
+
id: string;
|
|
118
|
+
initial?: StoreState<Schema> | (() => StoreState<Schema> | Promise<StoreState<Schema>>);
|
|
119
|
+
}): Promise<StoreSnapshot<StoreState<Schema>>>;
|
|
120
|
+
abstract getStore<Schema extends StandardSchemaV1>(params: {
|
|
121
|
+
definition: StoreDefinition<Schema>;
|
|
122
|
+
id: string;
|
|
123
|
+
}): Promise<StoreSnapshot<StoreState<Schema>>>;
|
|
124
|
+
/**
|
|
125
|
+
* Updates a store's state atomically.
|
|
126
|
+
* Updaters must be synchronous, deterministic, and side-effect-free. CAS-backed
|
|
127
|
+
* clients may run an updater again when another writer wins the version race.
|
|
128
|
+
* A rejected promise does not prove that the mutation was rolled back: a
|
|
129
|
+
* connector may commit state and then fail while delivering its durable wake
|
|
130
|
+
* intents. Retrying is exactly-once only when the same `stepId` is supplied.
|
|
131
|
+
* Callers without a `stepId` must read and reconcile instead of blindly retrying.
|
|
132
|
+
*
|
|
133
|
+
* When `stepId` is provided the update is exactly-once per
|
|
134
|
+
* (executionId, stepKey): the committed StoreUpdateResult is recorded in
|
|
135
|
+
* the applied-steps ledger inside the same transaction as the state change,
|
|
136
|
+
* and a repeated call with the same stepId returns the recorded result
|
|
137
|
+
* verbatim without running the updater or bumping the version.
|
|
138
|
+
*/
|
|
139
|
+
abstract updateStore<Schema extends StandardSchemaV1>(params: {
|
|
140
|
+
definition: StoreDefinition<Schema>;
|
|
141
|
+
id: string;
|
|
142
|
+
updater: (draft: Draft<StoreState<Schema>>) => void | StoreState<Schema>;
|
|
143
|
+
stepId?: StoreStepId;
|
|
144
|
+
}): Promise<StoreUpdateResult<StoreState<Schema>>>;
|
|
145
|
+
/**
|
|
146
|
+
* Updates a store only if it has not changed since `snapshot` was read.
|
|
147
|
+
* A conflict does not change the store, though a racing writer may cause a
|
|
148
|
+
* pure updater to have been evaluated before the conflict is observed. When `stepId`
|
|
149
|
+
* identifies an update that already committed, its recorded result wins
|
|
150
|
+
* over the version check so replay remains exactly-once.
|
|
151
|
+
*/
|
|
152
|
+
abstract updateStoreFrom<Schema extends StandardSchemaV1>(params: {
|
|
153
|
+
definition: StoreDefinition<Schema>;
|
|
154
|
+
id: string;
|
|
155
|
+
snapshot: StoreSnapshot<StoreState<Schema>>;
|
|
156
|
+
updater: (draft: Draft<StoreState<Schema>>) => void | StoreState<Schema>;
|
|
157
|
+
stepId?: StoreStepId;
|
|
158
|
+
}): Promise<StoreUpdateFromResult<StoreState<Schema>>>;
|
|
159
|
+
/**
|
|
160
|
+
* Atomically selects and claims from a store. The selector and claim run
|
|
161
|
+
* locally against a snapshot, then commit with a single conditional version
|
|
162
|
+
* bump. A conflict re-runs both functions against the new snapshot. If the selector does not match, nothing is
|
|
163
|
+
* committed and the store's current version plus the selector's tracked
|
|
164
|
+
* read paths are returned so the caller can register a waiter with the
|
|
165
|
+
* correct sinceVersion (closing the lost-wakeup gap by construction).
|
|
166
|
+
*
|
|
167
|
+
* `claim` must be synchronous – implementations must reject (throw) if it
|
|
168
|
+
* returns a Promise.
|
|
169
|
+
*
|
|
170
|
+
* When `stepId` is provided, a MATCHED (committed) take is recorded in the
|
|
171
|
+
* applied-steps ledger inside the same transaction as the claim commit, and
|
|
172
|
+
* a repeated call with the same stepId returns the recorded outcome without
|
|
173
|
+
* re-running the selector or claim. Unmatched outcomes are NOT recorded:
|
|
174
|
+
* an unmatched take commits nothing and registers a waiter, so it must
|
|
175
|
+
* remain free to re-evaluate the selector on every wake.
|
|
176
|
+
*/
|
|
177
|
+
abstract takeFromStore<Schema extends StandardSchemaV1, R>(params: {
|
|
178
|
+
definition: StoreDefinition<Schema>;
|
|
179
|
+
id: string;
|
|
180
|
+
selector: StoreSelector<StoreState<Schema>, R>;
|
|
181
|
+
claim: (draft: Draft<StoreState<Schema>>, selected: NonNullable<R>) => void;
|
|
182
|
+
stepId?: StoreStepId;
|
|
183
|
+
}): Promise<StoreTakeResult<R>>;
|
|
184
|
+
abstract registerWaiter(waiter: StoreWaiter): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Enumerates the ids of every store created under a given definition name.
|
|
187
|
+
* Needed by external consumers (e.g. Notation's state backend) that treat a
|
|
188
|
+
* store name as a collection of instances and must list them. Order is
|
|
189
|
+
* ascending by id so callers get a deterministic sequence.
|
|
190
|
+
*/
|
|
191
|
+
abstract listStores(definition: StoreDefinition): Promise<string[]>;
|
|
192
|
+
/**
|
|
193
|
+
* Removes a store instance and all of its associated rows (state, waiters,
|
|
194
|
+
* applied-steps ledger). A no-op if the store does not exist.
|
|
195
|
+
*/
|
|
196
|
+
abstract deleteStore(params: {
|
|
197
|
+
definition: StoreDefinition;
|
|
198
|
+
id: string;
|
|
199
|
+
}): Promise<void>;
|
|
200
|
+
/** Deletes a store only if its instance ID and version still match the snapshot. */
|
|
201
|
+
abstract deleteStoreFrom(params: {
|
|
202
|
+
definition: StoreDefinition;
|
|
203
|
+
id: string;
|
|
204
|
+
snapshot: StoreSnapshot<unknown>;
|
|
205
|
+
stepId?: StoreStepId;
|
|
206
|
+
}): Promise<StoreDeleteFromResult>;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Implements store transformations as read/compute/compare-and-swap loops.
|
|
210
|
+
* Storage connectors only implement the atomic mutation protocol and never
|
|
211
|
+
* execute application callbacks while holding a storage transaction.
|
|
212
|
+
*/
|
|
213
|
+
export declare abstract class CasStoreClient extends StoreClient {
|
|
214
|
+
protected abstract getAppliedStoreStep(params: {
|
|
215
|
+
definition: StoreDefinition;
|
|
216
|
+
id: string;
|
|
217
|
+
stepId: StoreStepId;
|
|
218
|
+
}): Promise<{
|
|
219
|
+
result: unknown;
|
|
220
|
+
} | undefined>;
|
|
221
|
+
/**
|
|
222
|
+
* Atomically compares `expected`, writes the next state, records the step
|
|
223
|
+
* result, and persists the changed paths for durable wake delivery.
|
|
224
|
+
*/
|
|
225
|
+
protected abstract commitStoreMutation(mutation: StoreMutation): Promise<StoreMutationCommitResult>;
|
|
226
|
+
updateStore<Schema extends StandardSchemaV1>(params: {
|
|
227
|
+
definition: StoreDefinition<Schema>;
|
|
228
|
+
id: string;
|
|
229
|
+
updater: (draft: Draft<StoreState<Schema>>) => void | StoreState<Schema>;
|
|
230
|
+
stepId?: StoreStepId;
|
|
231
|
+
}): Promise<StoreUpdateResult<StoreState<Schema>>>;
|
|
232
|
+
updateStoreFrom<Schema extends StandardSchemaV1>(params: {
|
|
233
|
+
definition: StoreDefinition<Schema>;
|
|
234
|
+
id: string;
|
|
235
|
+
snapshot: StoreSnapshot<StoreState<Schema>>;
|
|
236
|
+
updater: (draft: Draft<StoreState<Schema>>) => void | StoreState<Schema>;
|
|
237
|
+
stepId?: StoreStepId;
|
|
238
|
+
}): Promise<StoreUpdateFromResult<StoreState<Schema>>>;
|
|
239
|
+
takeFromStore<Schema extends StandardSchemaV1, R>(params: {
|
|
240
|
+
definition: StoreDefinition<Schema>;
|
|
241
|
+
id: string;
|
|
242
|
+
selector: StoreSelector<StoreState<Schema>, R>;
|
|
243
|
+
claim: (draft: Draft<StoreState<Schema>>, selected: NonNullable<R>) => void;
|
|
244
|
+
stepId?: StoreStepId;
|
|
245
|
+
}): Promise<StoreTakeResult<R>>;
|
|
246
|
+
private getAppliedResult;
|
|
247
|
+
}
|
|
248
|
+
export declare function isStoreSelectorMatch<R>(result: R): result is Exclude<R, undefined | null | false>;
|
|
249
|
+
export declare function assertSynchronousClaim(claimResult: unknown): void;
|
|
250
|
+
export declare function assertSynchronousUpdater(updaterResult: unknown): void;
|
|
251
|
+
export declare function validateStoreState<Schema extends StandardSchemaV1>(definition: StoreDefinition<Schema>, state: unknown): Promise<StoreState<Schema>>;
|
|
252
|
+
export declare function cloneStoreState<T>(state: T): T;
|
|
253
|
+
/**
|
|
254
|
+
* Diffs two store states and returns the set of changed paths.
|
|
255
|
+
*
|
|
256
|
+
* This is O(total state size). `trackStoreUpdater` records ordinary mutation
|
|
257
|
+
* paths in O(changes); the diff handles cases a recording proxy cannot observe:
|
|
258
|
+
* - the updater RETURNED a replacement state instead of mutating the draft
|
|
259
|
+
* - schema validation returned a transformed copy of the draft
|
|
260
|
+
*
|
|
261
|
+
* NOTE: array splices (insert/remove in the middle) report all shifted
|
|
262
|
+
* indices as changed, which can over-wake waiters. This is safe – wakes are
|
|
263
|
+
* spurious at worst, since replay re-evaluates the selector.
|
|
264
|
+
*/
|
|
265
|
+
export declare function diffStorePaths(previous: unknown, next: unknown): StorePath[];
|
|
266
|
+
/**
|
|
267
|
+
* Unwraps a tracking proxy (`trackStoreSelector` or `trackStoreUpdater`)
|
|
268
|
+
* one level, back to the object it wraps. When a selector runs over a
|
|
269
|
+
* write-recording draft, the selected value unwraps to the RECORDING proxy,
|
|
270
|
+
* so claim mutations applied through it land on the draft AND are recorded
|
|
271
|
+
* as write paths. Derived values (fresh arrays/objects built inside the
|
|
272
|
+
* selector) are returned as-is.
|
|
273
|
+
*/
|
|
274
|
+
export declare function unwrapTrackedValue<V>(value: V): V;
|
|
275
|
+
export declare function trackStoreSelector<T, R>(state: T, selector: StoreSelector<T, R>): {
|
|
276
|
+
result: R;
|
|
277
|
+
readPaths: StorePath[];
|
|
278
|
+
};
|
|
279
|
+
export type TrackedStoreUpdater<T> = {
|
|
280
|
+
/** Write-recording proxy over the raw draft. Hand this to the updater. */
|
|
281
|
+
draft: T;
|
|
282
|
+
/** The collapsed set of paths written so far (O(changes), not O(state)). */
|
|
283
|
+
writePaths(): StorePath[];
|
|
284
|
+
};
|
|
285
|
+
/**
|
|
286
|
+
* Wraps a draft in a write-recording Proxy so changed paths can be derived
|
|
287
|
+
* from the updater's own mutations in O(changes) instead of deep-diffing the
|
|
288
|
+
* whole previous/next state (O(state size) – see `diffStorePaths`).
|
|
289
|
+
*
|
|
290
|
+
* - Every `set` and `deleteProperty` through the proxy records its full
|
|
291
|
+
* path. Mutating array methods are trapped naturally via the index/length
|
|
292
|
+
* sets they perform: a push onto `messages` records ["messages", 3] (and
|
|
293
|
+
* ["messages", "length"]), preserving prefix-match wake semantics – a
|
|
294
|
+
* waiter on ["messages"] still wakes via prefix intersection.
|
|
295
|
+
* - Reads return proxied children so nested mutations are captured, but the
|
|
296
|
+
* mutation itself lands on the underlying raw draft (Reflect.set on the
|
|
297
|
+
* target), because the mutated draft becomes the next state.
|
|
298
|
+
* - Values assigned through the proxy are unwrapped (top-level) so the raw
|
|
299
|
+
* draft never stores a proxy wrapper for the common `draft.a = draft.b`
|
|
300
|
+
* case. Deeper wrappers (a proxy nested inside a fresh object) are
|
|
301
|
+
* laundered at commit time: `cloneStoreState` always produces fresh plain
|
|
302
|
+
* objects (structuredClone rejects proxies and falls back to JSON), and
|
|
303
|
+
* the SQLite client serializes state through JSON.stringify.
|
|
304
|
+
* - Ambiguous traps (`defineProperty`) record conservatively. Changed paths
|
|
305
|
+
* only affect wake precision, never state correctness: an extra path is a
|
|
306
|
+
* spurious wake (safe – replay re-evaluates the selector), while a missed
|
|
307
|
+
* path would lose a wakeup. When in doubt, over-report.
|
|
308
|
+
*
|
|
309
|
+
* IMPORTANT: this only observes MUTATIONS of the draft. If the updater
|
|
310
|
+
* RETURNS a replacement state instead of mutating (the
|
|
311
|
+
* `updated === undefined ? draft : updated` contract), no writes go through
|
|
312
|
+
* the proxy – callers must detect that case and fall back to
|
|
313
|
+
* `diffStorePaths(previousState, replacement)`.
|
|
314
|
+
*/
|
|
315
|
+
export declare function trackStoreUpdater<T>(target: T): TrackedStoreUpdater<T>;
|
|
316
|
+
export declare function storePathsIntersect(readPaths: StorePath[], writePaths: StorePath[]): boolean;
|
|
317
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/base/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GACnC;IAAE,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACzC,CAAC,CAAC;AAEN,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAClC,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;AAErD,MAAM,MAAM,eAAe,CAAC,MAAM,SAAS,gBAAgB,GAAG,gBAAgB,IAC5E;IACE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEJ,MAAM,MAAM,UAAU,CAAC,MAAM,SAAS,gBAAgB,IACpD,gBAAgB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAEvC,MAAM,MAAM,QAAQ,GA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E,KAAK,EAAE,CAAC,CAAC;IACT,4EAA4E;IAC5E,UAAU,IAAI,SAAS,EAAE,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CA4DtE;AAED,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,SAAS,EAAE,EACtB,UAAU,EAAE,SAAS,EAAE,GACtB,OAAO,CAOT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.test.d.ts","sourceRoot":"","sources":["../../src/base/store.test.ts"],"names":[],"mappings":""}
|
package/dist/base/workflow.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { Logger } from "pino";
|
|
2
2
|
import type { EventParams, WorkflowEvent, EventContext } from "./event";
|
|
3
3
|
import { HeapClient } from "./heap";
|
|
4
|
+
import { StoreClient } from "./store";
|
|
4
5
|
import { StepResponse, WorkflowResult } from "./step";
|
|
5
6
|
export type WorkflowGeneratorParams<Params extends EventParams, Context extends EventContext> = {
|
|
6
7
|
event: WorkflowEvent<Params, Context>;
|
|
7
8
|
heapClient: HeapClient;
|
|
9
|
+
storeClient: StoreClient;
|
|
8
10
|
logger: Logger;
|
|
9
11
|
};
|
|
10
12
|
export type WorkflowGenerator<Params extends EventParams, Result, Context extends EventContext> = (genParams: WorkflowGeneratorParams<Params, Context>) => AsyncGenerator<StepResponse, WorkflowResult<Result>, StepResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/base/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,UAAU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,CAAC,SAAS,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAClE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,10 +2,13 @@ export type { HeapClient, HeapRecord } from "./base/heap";
|
|
|
2
2
|
export type { WorkflowInvoker } from "./base/invoker";
|
|
3
3
|
export type { EventProcessor } from "./base/runtime";
|
|
4
4
|
export type { SchedulerClient } from "./base/scheduler";
|
|
5
|
+
export type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
6
|
+
export type { Draft, RuntimeStore, StoreDefinition, StoreDeleteFromResult, StoreKey, StorePath, StoreSelector, StoreSnapshot, StoreState, StoreStepId, StoreTakeResult, StoreUpdateFromResult, StoreUpdateResult, StoreVersion, StoreWaiter, StoreMutation, StoreMutationCommitResult, TrackedStoreUpdater, } from "./base/store";
|
|
7
|
+
export { StoreClient, CasStoreClient, assertSynchronousClaim, assertSynchronousUpdater, cloneStoreState, defineStore, diffStorePaths, isStoreSelectorMatch, storePathsIntersect, trackStoreSelector, trackStoreUpdater, unwrapTrackedValue, validateStoreState, } from "./base/store";
|
|
5
8
|
export type { EventParams, EventContext, ExecutionEvent, MiddlewareEvent, TriggerEvent, WorkflowEvent, } from "./base/event";
|
|
6
9
|
export type { MiddlewareNext, MiddlewareFunction } from "./base/middleware";
|
|
7
10
|
export type { WorkflowGenerator, WorkflowGeneratorReturnType, WorkflowRouter, EventOfWorkflow, EventParamsOf, } from "./base/workflow";
|
|
8
|
-
export { StepCacheCheck, StepDelay, StepError, StepInvalid, StepKey, StepResponse, StepResult, WorkflowDelay, WorkflowRestart, WorkflowResult, } from "./base/step";
|
|
11
|
+
export { StepCacheCheck, StepDelay, StepError, StepInvalid, StepKey, StepResponse, StepResult, StepStoreWait, WorkflowDelay, WorkflowRestart, WorkflowResult, } from "./base/step";
|
|
9
12
|
export { WorkflowRunner } from "./lib/workflow-runner";
|
|
10
13
|
export { ReadOnlyMap, FreezableMap } from "./utils/map";
|
|
11
14
|
export { errorWithOriginalStack } from "./utils/error";
|
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,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,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,SAAS,EACT,WAAW,EACX,OAAO,EACP,YAAY,EACZ,UAAU,EACV,aAAa,EACb,eAAe,EACf,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,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,EAAE,MAAM,aAAa,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,cAAc,EAAE,M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