@executablemd/durable-streams 0.3.0 → 0.4.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/esm/combinators.js +0 -12
- package/esm/divergence.js +0 -6
- package/esm/each.js +0 -15
- package/esm/effect.js +0 -6
- package/esm/replay-guard.js +0 -6
- package/esm/serialize.js +0 -6
- package/package.json +1 -1
package/esm/combinators.js
CHANGED
|
@@ -21,9 +21,6 @@ import { all as effectionAll, ensure, race as effectionRace, spawn, suspend, use
|
|
|
21
21
|
import { DurableCtx } from "./context.js";
|
|
22
22
|
import { ephemeral } from "./ephemeral.js";
|
|
23
23
|
import { deserializeError, serializeError } from "./serialize.js";
|
|
24
|
-
// ---------------------------------------------------------------------------
|
|
25
|
-
// Internal: wrap a child workflow with DurableContext + Close emission
|
|
26
|
-
// ---------------------------------------------------------------------------
|
|
27
24
|
/**
|
|
28
25
|
* Run a child workflow within a spawned scope, setting up its own
|
|
29
26
|
* DurableContext and emitting a Close event when it terminates.
|
|
@@ -121,9 +118,6 @@ function* runDurableChild(childWorkflow, childId, parentCtx) {
|
|
|
121
118
|
throw error;
|
|
122
119
|
}
|
|
123
120
|
}
|
|
124
|
-
// ---------------------------------------------------------------------------
|
|
125
|
-
// durableSpawn — spawn a single durable child, returns Task<T>
|
|
126
|
-
// ---------------------------------------------------------------------------
|
|
127
121
|
/**
|
|
128
122
|
* Spawn a durable child workflow.
|
|
129
123
|
*
|
|
@@ -147,9 +141,6 @@ export function durableSpawn(childWorkflow) {
|
|
|
147
141
|
return yield* spawn(() => runDurableChild(childWorkflow, childId, ctx));
|
|
148
142
|
})());
|
|
149
143
|
}
|
|
150
|
-
// ---------------------------------------------------------------------------
|
|
151
|
-
// durableAll — fork/join, wait for all children
|
|
152
|
-
// ---------------------------------------------------------------------------
|
|
153
144
|
/**
|
|
154
145
|
* Run multiple durable workflows concurrently and wait for all to complete.
|
|
155
146
|
*
|
|
@@ -187,9 +178,6 @@ export function durableAll(workflows) {
|
|
|
187
178
|
return yield* effectionAll(childOps);
|
|
188
179
|
})());
|
|
189
180
|
}
|
|
190
|
-
// ---------------------------------------------------------------------------
|
|
191
|
-
// durableRace — first child to complete wins, others cancelled
|
|
192
|
-
// ---------------------------------------------------------------------------
|
|
193
181
|
/**
|
|
194
182
|
* Race multiple durable workflows. The first to complete wins;
|
|
195
183
|
* remaining children are cancelled.
|
package/esm/divergence.js
CHANGED
|
@@ -21,9 +21,6 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { createApi } from "effection/experimental";
|
|
23
23
|
import { ContinuePastCloseDivergenceError, DivergenceError } from "./errors.js";
|
|
24
|
-
// ---------------------------------------------------------------------------
|
|
25
|
-
// Default policy (strict — all divergences are fatal)
|
|
26
|
-
// ---------------------------------------------------------------------------
|
|
27
24
|
/** The default (strict) decide function. */
|
|
28
25
|
function defaultDecide(info) {
|
|
29
26
|
if (info.kind === "description-mismatch") {
|
|
@@ -39,9 +36,6 @@ function defaultDecide(info) {
|
|
|
39
36
|
};
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
|
-
// ---------------------------------------------------------------------------
|
|
43
|
-
// The Divergence API instance
|
|
44
|
-
// ---------------------------------------------------------------------------
|
|
45
39
|
/**
|
|
46
40
|
* The Divergence API.
|
|
47
41
|
*
|
package/esm/each.js
CHANGED
|
@@ -16,9 +16,6 @@
|
|
|
16
16
|
import { ensure } from "effection";
|
|
17
17
|
import { createDurableOperation } from "./effect.js";
|
|
18
18
|
import { ephemeral } from "./ephemeral.js";
|
|
19
|
-
// ---------------------------------------------------------------------------
|
|
20
|
-
// Internal state
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
19
|
/** Sentinel for source exhaustion. Not exported — cannot collide with JSON. */
|
|
23
20
|
const DONE = Symbol("durableEach.done");
|
|
24
21
|
/** Type guard for the DONE sentinel. */
|
|
@@ -46,9 +43,6 @@ function isDone(value) {
|
|
|
46
43
|
* support for context that spans across ephemeral() boundaries.
|
|
47
44
|
*/
|
|
48
45
|
let activeState = null;
|
|
49
|
-
// ---------------------------------------------------------------------------
|
|
50
|
-
// durableEachFetch — shared helper for fetching one item
|
|
51
|
-
// ---------------------------------------------------------------------------
|
|
52
46
|
/**
|
|
53
47
|
* Fetch a single item from the source (or replay it from the journal).
|
|
54
48
|
*
|
|
@@ -71,9 +65,6 @@ function durableEachFetch(name, source) {
|
|
|
71
65
|
return result.value;
|
|
72
66
|
})();
|
|
73
67
|
}
|
|
74
|
-
// ---------------------------------------------------------------------------
|
|
75
|
-
// durableEach — initial fetch + returns synchronous iterable
|
|
76
|
-
// ---------------------------------------------------------------------------
|
|
77
68
|
/**
|
|
78
69
|
* Durable iteration over a DurableSource (internal implementation).
|
|
79
70
|
*
|
|
@@ -148,9 +139,6 @@ function* _durableEachOp(name, source) {
|
|
|
148
139
|
function _durableEach(name, source) {
|
|
149
140
|
return ephemeral(_durableEachOp(name, source));
|
|
150
141
|
}
|
|
151
|
-
// ---------------------------------------------------------------------------
|
|
152
|
-
// durableEach.next — static method to advance iteration
|
|
153
|
-
// ---------------------------------------------------------------------------
|
|
154
142
|
/**
|
|
155
143
|
* Advance the current durable iteration.
|
|
156
144
|
*
|
|
@@ -171,9 +159,6 @@ function* _durableEachNext() {
|
|
|
171
159
|
state.current = yield* durableEachFetch(state.name, state.source);
|
|
172
160
|
state.advanced = true;
|
|
173
161
|
}
|
|
174
|
-
// ---------------------------------------------------------------------------
|
|
175
|
-
// Public API — durableEach with static .next() method
|
|
176
|
-
// ---------------------------------------------------------------------------
|
|
177
162
|
/**
|
|
178
163
|
* Durable iteration over a DurableSource.
|
|
179
164
|
*
|
package/esm/effect.js
CHANGED
|
@@ -117,9 +117,6 @@ function checkReplay(desc, resolve, routine, ctx) {
|
|
|
117
117
|
} // end replay block
|
|
118
118
|
return { path: "live" };
|
|
119
119
|
}
|
|
120
|
-
// ---------------------------------------------------------------------------
|
|
121
|
-
// createDurableEffect — callback-based (Executor pattern)
|
|
122
|
-
// ---------------------------------------------------------------------------
|
|
123
120
|
/**
|
|
124
121
|
* Creates a DurableEffect using a callback-based executor.
|
|
125
122
|
*
|
|
@@ -209,9 +206,6 @@ export function createDurableEffect(desc, execute) {
|
|
|
209
206
|
},
|
|
210
207
|
};
|
|
211
208
|
}
|
|
212
|
-
// ---------------------------------------------------------------------------
|
|
213
|
-
// createDurableOperation — Operation-based (structured concurrency)
|
|
214
|
-
// ---------------------------------------------------------------------------
|
|
215
209
|
/**
|
|
216
210
|
* Creates a DurableEffect from an Operation-returning function.
|
|
217
211
|
*
|
package/esm/replay-guard.js
CHANGED
|
@@ -31,9 +31,6 @@
|
|
|
31
31
|
* See replay-guard-spec.md for the full design.
|
|
32
32
|
*/
|
|
33
33
|
import { createApi } from "effection/experimental";
|
|
34
|
-
// ---------------------------------------------------------------------------
|
|
35
|
-
// Default implementation (pass-through)
|
|
36
|
-
// ---------------------------------------------------------------------------
|
|
37
34
|
/**
|
|
38
35
|
* Default check — no-op. Events pass through without observation.
|
|
39
36
|
*/
|
|
@@ -48,9 +45,6 @@ function* defaultCheck(_event) {
|
|
|
48
45
|
function defaultDecide(_event) {
|
|
49
46
|
return { outcome: "replay" };
|
|
50
47
|
}
|
|
51
|
-
// ---------------------------------------------------------------------------
|
|
52
|
-
// The ReplayGuard API instance
|
|
53
|
-
// ---------------------------------------------------------------------------
|
|
54
48
|
/**
|
|
55
49
|
* The ReplayGuard API.
|
|
56
50
|
*
|
package/esm/serialize.js
CHANGED
|
@@ -6,9 +6,6 @@
|
|
|
6
6
|
* - Effection Result ({ ok: true, value } | { ok: false, error })
|
|
7
7
|
* - Error ↔ SerializedError
|
|
8
8
|
*/
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
// Error serialization
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
9
|
/** Serialize an Error to a JSON-safe SerializedError. */
|
|
13
10
|
export function serializeError(error) {
|
|
14
11
|
return {
|
|
@@ -26,9 +23,6 @@ export function deserializeError(se) {
|
|
|
26
23
|
error.stack = se.stack;
|
|
27
24
|
return error;
|
|
28
25
|
}
|
|
29
|
-
// ---------------------------------------------------------------------------
|
|
30
|
-
// Result conversion: Protocol ↔ Effection
|
|
31
|
-
// ---------------------------------------------------------------------------
|
|
32
26
|
/**
|
|
33
27
|
* Convert a protocol Result to an Effection Result.
|
|
34
28
|
*
|