@yieldstar/core 0.4.5 → 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/index.js
CHANGED
|
@@ -1,4 +1,368 @@
|
|
|
1
|
-
//
|
|
1
|
+
// src/base/store.ts
|
|
2
|
+
function defineStore(name, schema) {
|
|
3
|
+
return { name, schema };
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
class StoreClient {
|
|
7
|
+
store(definition, id) {
|
|
8
|
+
return {
|
|
9
|
+
get: () => this.getStore({
|
|
10
|
+
definition,
|
|
11
|
+
id
|
|
12
|
+
}),
|
|
13
|
+
update: (updater) => this.updateStore({
|
|
14
|
+
definition,
|
|
15
|
+
id,
|
|
16
|
+
updater
|
|
17
|
+
}),
|
|
18
|
+
updateFrom: (snapshot, updater) => this.updateStoreFrom({
|
|
19
|
+
definition,
|
|
20
|
+
id,
|
|
21
|
+
snapshot,
|
|
22
|
+
updater
|
|
23
|
+
}),
|
|
24
|
+
deleteFrom: (snapshot) => this.deleteStoreFrom({
|
|
25
|
+
definition,
|
|
26
|
+
id,
|
|
27
|
+
snapshot
|
|
28
|
+
})
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class CasStoreClient extends StoreClient {
|
|
34
|
+
async updateStore(params) {
|
|
35
|
+
const applied = await this.getAppliedResult(params);
|
|
36
|
+
if (applied) {
|
|
37
|
+
return applied.result;
|
|
38
|
+
}
|
|
39
|
+
let snapshot = await this.getStore({
|
|
40
|
+
definition: params.definition,
|
|
41
|
+
id: params.id
|
|
42
|
+
});
|
|
43
|
+
while (true) {
|
|
44
|
+
const prepared = await prepareStoreUpdate(params.definition, snapshot, params.updater);
|
|
45
|
+
const result = {
|
|
46
|
+
state: cloneStoreState(prepared.nextState),
|
|
47
|
+
previousVersion: snapshot.version,
|
|
48
|
+
version: snapshot.version + 1
|
|
49
|
+
};
|
|
50
|
+
const committed = await this.commitStoreMutation({
|
|
51
|
+
definition: params.definition,
|
|
52
|
+
id: params.id,
|
|
53
|
+
expected: snapshot,
|
|
54
|
+
nextState: prepared.nextState,
|
|
55
|
+
changedPaths: prepared.changedPaths,
|
|
56
|
+
stepId: params.stepId,
|
|
57
|
+
result
|
|
58
|
+
});
|
|
59
|
+
if (committed.status === "committed")
|
|
60
|
+
return result;
|
|
61
|
+
if (committed.status === "already-applied") {
|
|
62
|
+
return committed.result;
|
|
63
|
+
}
|
|
64
|
+
snapshot = committed.snapshot;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async updateStoreFrom(params) {
|
|
68
|
+
const applied = await this.getAppliedResult(params);
|
|
69
|
+
if (applied) {
|
|
70
|
+
return applied.result;
|
|
71
|
+
}
|
|
72
|
+
assertStoreSnapshotInstanceId(params.snapshot);
|
|
73
|
+
const current = await this.getStore({
|
|
74
|
+
definition: params.definition,
|
|
75
|
+
id: params.id
|
|
76
|
+
});
|
|
77
|
+
if (!sameStoreVersion(current, params.snapshot)) {
|
|
78
|
+
return storeUpdateConflict(params.snapshot, current);
|
|
79
|
+
}
|
|
80
|
+
const prepared = await prepareStoreUpdate(params.definition, params.snapshot, params.updater);
|
|
81
|
+
const result = {
|
|
82
|
+
updated: true,
|
|
83
|
+
state: cloneStoreState(prepared.nextState),
|
|
84
|
+
previousVersion: params.snapshot.version,
|
|
85
|
+
version: params.snapshot.version + 1
|
|
86
|
+
};
|
|
87
|
+
const committed = await this.commitStoreMutation({
|
|
88
|
+
definition: params.definition,
|
|
89
|
+
id: params.id,
|
|
90
|
+
expected: params.snapshot,
|
|
91
|
+
nextState: prepared.nextState,
|
|
92
|
+
changedPaths: prepared.changedPaths,
|
|
93
|
+
stepId: params.stepId,
|
|
94
|
+
result
|
|
95
|
+
});
|
|
96
|
+
if (committed.status === "committed")
|
|
97
|
+
return result;
|
|
98
|
+
if (committed.status === "already-applied") {
|
|
99
|
+
return committed.result;
|
|
100
|
+
}
|
|
101
|
+
return storeUpdateConflict(params.snapshot, committed.snapshot);
|
|
102
|
+
}
|
|
103
|
+
async takeFromStore(params) {
|
|
104
|
+
const applied = await this.getAppliedResult(params);
|
|
105
|
+
if (applied)
|
|
106
|
+
return applied.result;
|
|
107
|
+
let snapshot = await this.getStore({
|
|
108
|
+
definition: params.definition,
|
|
109
|
+
id: params.id
|
|
110
|
+
});
|
|
111
|
+
while (true) {
|
|
112
|
+
const previousState = cloneStoreState(snapshot.state);
|
|
113
|
+
const draft = cloneStoreState(previousState);
|
|
114
|
+
const tracked = trackStoreUpdater(draft);
|
|
115
|
+
const { result: selectedResult, readPaths } = trackStoreSelector(tracked.draft, params.selector);
|
|
116
|
+
if (!isStoreSelectorMatch(selectedResult)) {
|
|
117
|
+
return {
|
|
118
|
+
matched: false,
|
|
119
|
+
instanceId: snapshot.instanceId,
|
|
120
|
+
version: snapshot.version,
|
|
121
|
+
readPaths
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const selected = unwrapTrackedValue(selectedResult);
|
|
125
|
+
assertSynchronousClaim(params.claim(tracked.draft, selected));
|
|
126
|
+
const prepared = await finalizeStoreMutation({
|
|
127
|
+
definition: params.definition,
|
|
128
|
+
previousState,
|
|
129
|
+
draft,
|
|
130
|
+
tracked
|
|
131
|
+
});
|
|
132
|
+
const selectedSnapshot = cloneStoreState(selected);
|
|
133
|
+
const result = {
|
|
134
|
+
matched: true,
|
|
135
|
+
selected: selectedSnapshot,
|
|
136
|
+
instanceId: snapshot.instanceId,
|
|
137
|
+
version: snapshot.version + 1
|
|
138
|
+
};
|
|
139
|
+
const committed = await this.commitStoreMutation({
|
|
140
|
+
definition: params.definition,
|
|
141
|
+
id: params.id,
|
|
142
|
+
expected: snapshot,
|
|
143
|
+
nextState: prepared.nextState,
|
|
144
|
+
changedPaths: prepared.changedPaths,
|
|
145
|
+
stepId: params.stepId,
|
|
146
|
+
result
|
|
147
|
+
});
|
|
148
|
+
if (committed.status === "committed")
|
|
149
|
+
return result;
|
|
150
|
+
if (committed.status === "already-applied") {
|
|
151
|
+
return committed.result;
|
|
152
|
+
}
|
|
153
|
+
snapshot = committed.snapshot;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
getAppliedResult(params) {
|
|
157
|
+
return params.stepId ? this.getAppliedStoreStep({
|
|
158
|
+
definition: params.definition,
|
|
159
|
+
id: params.id,
|
|
160
|
+
stepId: params.stepId
|
|
161
|
+
}) : Promise.resolve(undefined);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async function prepareStoreUpdate(definition, snapshot, updater) {
|
|
165
|
+
const previousState = cloneStoreState(snapshot.state);
|
|
166
|
+
const draft = cloneStoreState(previousState);
|
|
167
|
+
const tracked = trackStoreUpdater(draft);
|
|
168
|
+
const updated = updater(tracked.draft);
|
|
169
|
+
assertSynchronousUpdater(updated);
|
|
170
|
+
const returned = updated === undefined ? undefined : unwrapTrackedValue(updated);
|
|
171
|
+
return finalizeStoreMutation({
|
|
172
|
+
definition,
|
|
173
|
+
previousState,
|
|
174
|
+
draft,
|
|
175
|
+
tracked,
|
|
176
|
+
replacement: returned
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
async function finalizeStoreMutation(params) {
|
|
180
|
+
const isReplacement = params.replacement !== undefined && params.replacement !== params.draft;
|
|
181
|
+
const nextState = await validateStoreState(params.definition, isReplacement ? params.replacement : params.draft);
|
|
182
|
+
const changedPaths = !isReplacement && nextState === params.draft ? params.tracked.writePaths() : diffStorePaths(params.previousState, nextState);
|
|
183
|
+
return { nextState, changedPaths };
|
|
184
|
+
}
|
|
185
|
+
function sameStoreVersion(left, right) {
|
|
186
|
+
return left.instanceId === right.instanceId && left.version === right.version;
|
|
187
|
+
}
|
|
188
|
+
function assertStoreSnapshotInstanceId(snapshot) {
|
|
189
|
+
if (!snapshot.instanceId) {
|
|
190
|
+
throw new Error("Store snapshot is missing instanceId; read a fresh snapshot");
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function storeUpdateConflict(expected, actual) {
|
|
194
|
+
return {
|
|
195
|
+
updated: false,
|
|
196
|
+
expectedInstanceId: expected.instanceId,
|
|
197
|
+
actualInstanceId: actual.instanceId,
|
|
198
|
+
expectedVersion: expected.version,
|
|
199
|
+
actualVersion: actual.version
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function isStoreSelectorMatch(result) {
|
|
203
|
+
return result !== undefined && result !== null && result !== false;
|
|
204
|
+
}
|
|
205
|
+
function assertSynchronousClaim(claimResult) {
|
|
206
|
+
if (claimResult && typeof claimResult.then === "function") {
|
|
207
|
+
throw new Error("Store take claims must be synchronous");
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function assertSynchronousUpdater(updaterResult) {
|
|
211
|
+
if (updaterResult && typeof updaterResult.then === "function") {
|
|
212
|
+
throw new Error("Store updaters must be synchronous");
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
async function validateStoreState(definition, state) {
|
|
216
|
+
const result = await definition.schema["~standard"].validate(state);
|
|
217
|
+
if ("issues" in result && result.issues) {
|
|
218
|
+
const messages = result.issues.map((issue) => issue.message).join("; ");
|
|
219
|
+
throw new Error(`Invalid store state for "${definition.name}": ${messages}`);
|
|
220
|
+
}
|
|
221
|
+
return result.value;
|
|
222
|
+
}
|
|
223
|
+
function cloneStoreState(state) {
|
|
224
|
+
if (typeof structuredClone === "function") {
|
|
225
|
+
try {
|
|
226
|
+
return structuredClone(state);
|
|
227
|
+
} catch {}
|
|
228
|
+
}
|
|
229
|
+
return JSON.parse(JSON.stringify(state));
|
|
230
|
+
}
|
|
231
|
+
function diffStorePaths(previous, next) {
|
|
232
|
+
const paths = [];
|
|
233
|
+
function visit(left, right, path) {
|
|
234
|
+
if (Object.is(left, right))
|
|
235
|
+
return;
|
|
236
|
+
if (!isDiffableObject(left) || !isDiffableObject(right)) {
|
|
237
|
+
paths.push(path);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const keys = new Set([...Object.keys(left), ...Object.keys(right)]);
|
|
241
|
+
for (const key of keys) {
|
|
242
|
+
visit(left[key], right[key], [...path, arrayKeyToPathSegment(key)]);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
visit(previous, next, []);
|
|
246
|
+
return collapseStorePaths(paths);
|
|
247
|
+
}
|
|
248
|
+
var TRACKING_TARGET = Symbol("yieldstar.trackingTarget");
|
|
249
|
+
function unwrapTrackedValue(value) {
|
|
250
|
+
if (isDiffableObject(value)) {
|
|
251
|
+
const target = value[TRACKING_TARGET];
|
|
252
|
+
if (target !== undefined)
|
|
253
|
+
return target;
|
|
254
|
+
}
|
|
255
|
+
return value;
|
|
256
|
+
}
|
|
257
|
+
function trackStoreSelector(state, selector) {
|
|
258
|
+
const paths = [];
|
|
259
|
+
const proxies = new WeakMap;
|
|
260
|
+
function track(value, path) {
|
|
261
|
+
if (!isDiffableObject(value))
|
|
262
|
+
return value;
|
|
263
|
+
const cached = proxies.get(value);
|
|
264
|
+
if (cached)
|
|
265
|
+
return cached;
|
|
266
|
+
const proxy = new Proxy(value, {
|
|
267
|
+
get(target, property, receiver) {
|
|
268
|
+
if (typeof property === "symbol") {
|
|
269
|
+
if (property === TRACKING_TARGET)
|
|
270
|
+
return target;
|
|
271
|
+
return Reflect.get(target, property, receiver);
|
|
272
|
+
}
|
|
273
|
+
const nextPath = [...path, arrayKeyToPathSegment(property)];
|
|
274
|
+
if (nextPath.length > 0) {
|
|
275
|
+
paths.push(nextPath);
|
|
276
|
+
}
|
|
277
|
+
const child = Reflect.get(target, property, receiver);
|
|
278
|
+
return track(child, nextPath);
|
|
279
|
+
},
|
|
280
|
+
set() {
|
|
281
|
+
throw new Error("Store selectors must not mutate state");
|
|
282
|
+
},
|
|
283
|
+
deleteProperty() {
|
|
284
|
+
throw new Error("Store selectors must not mutate state");
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
proxies.set(value, proxy);
|
|
288
|
+
return proxy;
|
|
289
|
+
}
|
|
290
|
+
const result = selector(track(state, []));
|
|
291
|
+
return {
|
|
292
|
+
result,
|
|
293
|
+
readPaths: collapseStorePaths(paths)
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
function trackStoreUpdater(target) {
|
|
297
|
+
const paths = [];
|
|
298
|
+
const proxies = new WeakMap;
|
|
299
|
+
function record(path, property) {
|
|
300
|
+
if (typeof property === "symbol") {
|
|
301
|
+
paths.push(path);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
paths.push([...path, arrayKeyToPathSegment(String(property))]);
|
|
305
|
+
}
|
|
306
|
+
function track(value, path) {
|
|
307
|
+
if (!isDiffableObject(value))
|
|
308
|
+
return value;
|
|
309
|
+
const cached = proxies.get(value);
|
|
310
|
+
if (cached)
|
|
311
|
+
return cached;
|
|
312
|
+
const proxy = new Proxy(value, {
|
|
313
|
+
get(target2, property, receiver) {
|
|
314
|
+
if (typeof property === "symbol") {
|
|
315
|
+
if (property === TRACKING_TARGET)
|
|
316
|
+
return target2;
|
|
317
|
+
return Reflect.get(target2, property, receiver);
|
|
318
|
+
}
|
|
319
|
+
const child = Reflect.get(target2, property);
|
|
320
|
+
return track(child, [...path, arrayKeyToPathSegment(property)]);
|
|
321
|
+
},
|
|
322
|
+
set(target2, property, value2) {
|
|
323
|
+
record(path, property);
|
|
324
|
+
return Reflect.set(target2, property, unwrapTrackedValue(value2));
|
|
325
|
+
},
|
|
326
|
+
deleteProperty(target2, property) {
|
|
327
|
+
record(path, property);
|
|
328
|
+
return Reflect.deleteProperty(target2, property);
|
|
329
|
+
},
|
|
330
|
+
defineProperty(target2, property, descriptor) {
|
|
331
|
+
record(path, property);
|
|
332
|
+
if ("value" in descriptor) {
|
|
333
|
+
descriptor = { ...descriptor, value: unwrapTrackedValue(descriptor.value) };
|
|
334
|
+
}
|
|
335
|
+
return Reflect.defineProperty(target2, property, descriptor);
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
proxies.set(value, proxy);
|
|
339
|
+
return proxy;
|
|
340
|
+
}
|
|
341
|
+
return {
|
|
342
|
+
draft: track(target, []),
|
|
343
|
+
writePaths: () => collapseStorePaths(paths)
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
function storePathsIntersect(readPaths, writePaths) {
|
|
347
|
+
return readPaths.some((readPath) => writePaths.some((writePath) => isPathPrefix(readPath, writePath) || isPathPrefix(writePath, readPath)));
|
|
348
|
+
}
|
|
349
|
+
function collapseStorePaths(paths) {
|
|
350
|
+
const unique = new Map(paths.map((path) => [path.join("\x00"), path]));
|
|
351
|
+
return [...unique.values()];
|
|
352
|
+
}
|
|
353
|
+
function isPathPrefix(prefix, path) {
|
|
354
|
+
if (prefix.length > path.length)
|
|
355
|
+
return false;
|
|
356
|
+
return prefix.every((segment, index) => segment === path[index]);
|
|
357
|
+
}
|
|
358
|
+
function isDiffableObject(value) {
|
|
359
|
+
return typeof value === "object" && value !== null;
|
|
360
|
+
}
|
|
361
|
+
function arrayKeyToPathSegment(key) {
|
|
362
|
+
if (/^(0|[1-9]\d*)$/.test(key))
|
|
363
|
+
return Number(key);
|
|
364
|
+
return key;
|
|
365
|
+
}
|
|
2
366
|
// src/base/step.ts
|
|
3
367
|
class StepResponse {
|
|
4
368
|
}
|
|
@@ -53,6 +417,14 @@ class WorkflowDelay extends StepResponse {
|
|
|
53
417
|
}
|
|
54
418
|
}
|
|
55
419
|
|
|
420
|
+
class StepStoreWait extends StepResponse {
|
|
421
|
+
static type = "store-wait";
|
|
422
|
+
type = "store-wait";
|
|
423
|
+
constructor() {
|
|
424
|
+
super();
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
56
428
|
class WorkflowRestart extends StepResponse {
|
|
57
429
|
static type = "workflow-restart";
|
|
58
430
|
type = "workflow-restart";
|
|
@@ -90,10 +462,12 @@ class StepDelay extends StepResponse {
|
|
|
90
462
|
class WorkflowRunner {
|
|
91
463
|
heapClient;
|
|
92
464
|
schedulerClient;
|
|
465
|
+
storeClient;
|
|
93
466
|
router;
|
|
94
467
|
constructor(params) {
|
|
95
468
|
this.heapClient = params.heapClient;
|
|
96
469
|
this.schedulerClient = params.schedulerClient;
|
|
470
|
+
this.storeClient = params.storeClient;
|
|
97
471
|
this.router = params.router;
|
|
98
472
|
}
|
|
99
473
|
run = async (event, logger) => {
|
|
@@ -113,6 +487,8 @@ class WorkflowRunner {
|
|
|
113
487
|
case "workflow-delay":
|
|
114
488
|
this.schedulerClient.requestWakeUp(event, response.resumeIn);
|
|
115
489
|
break;
|
|
490
|
+
case "store-wait":
|
|
491
|
+
break;
|
|
116
492
|
}
|
|
117
493
|
} catch (err) {
|
|
118
494
|
throw err;
|
|
@@ -123,6 +499,7 @@ class WorkflowRunner {
|
|
|
123
499
|
const workflowIterator = workflow({
|
|
124
500
|
event,
|
|
125
501
|
heapClient: this.heapClient,
|
|
502
|
+
storeClient: this.storeClient,
|
|
126
503
|
logger
|
|
127
504
|
});
|
|
128
505
|
const iteratorResult = await workflowIterator.next();
|
|
@@ -133,6 +510,9 @@ class WorkflowRunner {
|
|
|
133
510
|
if (stageResponse instanceof StepDelay) {
|
|
134
511
|
return new WorkflowDelay(stageResponse.resumeIn - Date.now());
|
|
135
512
|
}
|
|
513
|
+
if (stageResponse instanceof StepStoreWait) {
|
|
514
|
+
return stageResponse;
|
|
515
|
+
}
|
|
136
516
|
throw new Error("Workflow runner critical error. This is likely because your worklow and worker are referencing different versions of @yieldstar/core.");
|
|
137
517
|
}
|
|
138
518
|
}
|
|
@@ -148,7 +528,13 @@ function errorWithOriginalStack(error, fn) {
|
|
|
148
528
|
class ReadOnlyMap {
|
|
149
529
|
sourceMap;
|
|
150
530
|
constructor(sourceMap) {
|
|
151
|
-
|
|
531
|
+
if (sourceMap instanceof Map) {
|
|
532
|
+
this.sourceMap = sourceMap;
|
|
533
|
+
} else if (typeof sourceMap === "object" && sourceMap !== null) {
|
|
534
|
+
this.sourceMap = new Map(Object.entries(sourceMap));
|
|
535
|
+
} else {
|
|
536
|
+
this.sourceMap = new Map;
|
|
537
|
+
}
|
|
152
538
|
}
|
|
153
539
|
get(key) {
|
|
154
540
|
return this.sourceMap.get(key);
|
|
@@ -207,11 +593,24 @@ class FreezableMap extends Map {
|
|
|
207
593
|
}
|
|
208
594
|
}
|
|
209
595
|
export {
|
|
596
|
+
validateStoreState,
|
|
597
|
+
unwrapTrackedValue,
|
|
598
|
+
trackStoreUpdater,
|
|
599
|
+
trackStoreSelector,
|
|
600
|
+
storePathsIntersect,
|
|
601
|
+
isStoreSelectorMatch,
|
|
210
602
|
errorWithOriginalStack,
|
|
603
|
+
diffStorePaths,
|
|
604
|
+
defineStore,
|
|
605
|
+
cloneStoreState,
|
|
606
|
+
assertSynchronousUpdater,
|
|
607
|
+
assertSynchronousClaim,
|
|
211
608
|
WorkflowRunner,
|
|
212
609
|
WorkflowResult,
|
|
213
610
|
WorkflowRestart,
|
|
214
611
|
WorkflowDelay,
|
|
612
|
+
StoreClient,
|
|
613
|
+
StepStoreWait,
|
|
215
614
|
StepResult,
|
|
216
615
|
StepResponse,
|
|
217
616
|
StepKey,
|
|
@@ -220,5 +619,6 @@ export {
|
|
|
220
619
|
StepDelay,
|
|
221
620
|
StepCacheCheck,
|
|
222
621
|
ReadOnlyMap,
|
|
223
|
-
FreezableMap
|
|
622
|
+
FreezableMap,
|
|
623
|
+
CasStoreClient
|
|
224
624
|
};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { Logger } from "pino";
|
|
2
|
-
import type { WorkflowGenerator, HeapClient, SchedulerClient, EventProcessor } from "..";
|
|
2
|
+
import type { WorkflowGenerator, HeapClient, SchedulerClient, StoreClient, EventProcessor } from "..";
|
|
3
3
|
export declare class WorkflowRunner<Router extends Record<string, WorkflowGenerator<any, any, any>>> {
|
|
4
4
|
private heapClient;
|
|
5
5
|
private schedulerClient;
|
|
6
|
+
private storeClient;
|
|
6
7
|
private router;
|
|
7
8
|
constructor(params: {
|
|
8
9
|
heapClient: HeapClient;
|
|
9
10
|
schedulerClient: SchedulerClient;
|
|
11
|
+
storeClient: StoreClient;
|
|
10
12
|
router: Router;
|
|
11
13
|
logger: Logger;
|
|
12
14
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-runner.d.ts","sourceRoot":"","sources":["../../src/lib/workflow-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,cAAc,EAGf,MAAM,IAAI,CAAC;AAIZ,qBAAa,cAAc,CACzB,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAE/D,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE;QAClB,UAAU,EAAE,UAAU,CAAC;QACvB,eAAe,EAAE,eAAe,CAAC;QACjC,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB;
|
|
1
|
+
{"version":3,"file":"workflow-runner.d.ts","sourceRoot":"","sources":["../../src/lib/workflow-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,WAAW,EACX,cAAc,EAGf,MAAM,IAAI,CAAC;AAIZ,qBAAa,cAAc,CACzB,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAE/D,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE;QAClB,UAAU,EAAE,UAAU,CAAC;QACvB,eAAe,EAAE,eAAe,CAAC;QACjC,WAAW,EAAE,WAAW,CAAC;QACzB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB;IAOD,GAAG,EAAE,cAAc,CA6BjB;YAEY,YAAY;CAsC3B"}
|
package/dist/utils/map.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare class ReadOnlyMap<K, V> implements ReadonlyMap<K, V> {
|
|
2
2
|
private sourceMap;
|
|
3
|
-
constructor(sourceMap: Map<K, V>);
|
|
3
|
+
constructor(sourceMap: Map<K, V> | Record<any, any> | undefined);
|
|
4
4
|
get(key: K): V | undefined;
|
|
5
5
|
has(key: K): boolean;
|
|
6
6
|
get size(): number;
|
package/dist/utils/map.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/utils/map.ts"],"names":[],"mappings":"AAEA,qBAAa,WAAW,CAAC,CAAC,EAAE,CAAC,CAAE,YAAW,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC;IACzD,OAAO,CAAC,SAAS,CAAY;gBAEjB,SAAS,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/utils/map.ts"],"names":[],"mappings":"AAEA,qBAAa,WAAW,CAAC,CAAC,EAAE,CAAC,CAAE,YAAW,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC;IACzD,OAAO,CAAC,SAAS,CAAY;gBAEjB,SAAS,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS;IAU/D,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAI1B,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAIpB,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAI9B,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC;IAItB,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC;IAIxB,OAAO,CACL,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,EACtD,OAAO,CAAC,EAAE,GAAG,GACZ,IAAI;IAIP,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAGzC;AAED,qBAAa,YAAY,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,MAAM,CAAS;IAEvB,MAAM,IAAI,IAAI;IAId,QAAQ,IAAI,OAAO;IAInB,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAQ3B,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAQvB,KAAK,IAAI,IAAI;CAOd"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yieldstar/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "Daniel Grant",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/notationlabs/yieldstar.git",
|
|
9
|
+
"directory": "packages/core"
|
|
10
|
+
},
|
|
4
11
|
"type": "module",
|
|
5
12
|
"main": "dist/index.js",
|
|
6
13
|
"types": "dist/index.d.ts",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@standard-schema/spec": "^1.1.0"
|
|
16
|
+
},
|
|
7
17
|
"devDependencies": {
|
|
8
|
-
"@types/
|
|
18
|
+
"@types/node": "^22.18.0",
|
|
9
19
|
"pino": "^9.9.0"
|
|
10
20
|
},
|
|
11
21
|
"scripts": {
|
|
12
|
-
"build": "bun build src/index.ts --outfile dist/index.js --target
|
|
22
|
+
"build": "bun build src/index.ts --outfile dist/index.js --target node --packages=external"
|
|
13
23
|
}
|
|
14
24
|
}
|
package/src/base/step.ts
CHANGED
|
@@ -52,6 +52,14 @@ export class WorkflowDelay extends StepResponse {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
export class StepStoreWait extends StepResponse {
|
|
56
|
+
static type = "store-wait";
|
|
57
|
+
readonly type = "store-wait";
|
|
58
|
+
constructor() {
|
|
59
|
+
super();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
55
63
|
export class WorkflowRestart extends StepResponse {
|
|
56
64
|
static type = "workflow-restart";
|
|
57
65
|
readonly type = "workflow-restart";
|