lightflow-engine 0.2.7 → 0.2.8
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/compat/api.js +8 -7
- package/dist/index.js +7 -2
- package/package.json +1 -1
package/dist/compat/api.js
CHANGED
|
@@ -12,18 +12,19 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { Engine, registerWorkflow } from "../index.js";
|
|
14
14
|
import { workflowIdFor } from "./workflow.js";
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const g = globalThis;
|
|
16
|
+
if (!g.__lightflowCompat)
|
|
17
|
+
g.__lightflowCompat = { engine: null, store: null };
|
|
17
18
|
/** Configure the compat layer with a store/engine (call once at boot). */
|
|
18
19
|
export function initWorkflowApi(store, engine) {
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
g.__lightflowCompat.store = store;
|
|
21
|
+
g.__lightflowCompat.engine = engine ?? new Engine(store);
|
|
21
22
|
}
|
|
22
23
|
export function getEngine() {
|
|
23
|
-
if (!
|
|
24
|
+
if (!g.__lightflowCompat.engine) {
|
|
24
25
|
throw new Error("workflow/api not initialized — call initWorkflowApi(store) at startup");
|
|
25
26
|
}
|
|
26
|
-
return
|
|
27
|
+
return g.__lightflowCompat.engine;
|
|
27
28
|
}
|
|
28
29
|
/**
|
|
29
30
|
* Register a workflow function under a stable id and start it. Mirrors
|
|
@@ -31,7 +32,7 @@ export function getEngine() {
|
|
|
31
32
|
*/
|
|
32
33
|
function makeRunHandle(runId) {
|
|
33
34
|
const engine = getEngine();
|
|
34
|
-
const store =
|
|
35
|
+
const store = g.__lightflowCompat.store;
|
|
35
36
|
/** One DB read -> Vercel status vocabulary. */
|
|
36
37
|
const readStatus = async () => {
|
|
37
38
|
const row = await store.getRun(runId);
|
package/dist/index.js
CHANGED
|
@@ -26,8 +26,13 @@ export class FatalError extends Error {
|
|
|
26
26
|
this.name = "FatalError";
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
const
|
|
30
|
-
|
|
29
|
+
const reg = globalThis;
|
|
30
|
+
if (!reg.__lightflowWorkflows)
|
|
31
|
+
reg.__lightflowWorkflows = new Map();
|
|
32
|
+
if (!reg.__lightflowSteps)
|
|
33
|
+
reg.__lightflowSteps = new Map();
|
|
34
|
+
const workflows = reg.__lightflowWorkflows;
|
|
35
|
+
const steps = reg.__lightflowSteps;
|
|
31
36
|
export function registerWorkflow(id, fn) {
|
|
32
37
|
workflows.set(id, fn);
|
|
33
38
|
}
|