yaml-flow 4.0.0 → 5.1.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/browser/board-livegraph-runtime.js +1453 -0
- package/browser/board-livegraph-runtime.js.map +1 -0
- package/browser/card-compute.js +36 -17
- package/browser/live-cards.js +848 -109
- package/browser/live-cards.schema.json +46 -21
- package/dist/board-livegraph-runtime/index.cjs +1448 -0
- package/dist/board-livegraph-runtime/index.cjs.map +1 -0
- package/dist/board-livegraph-runtime/index.d.cts +101 -0
- package/dist/board-livegraph-runtime/index.d.ts +101 -0
- package/dist/board-livegraph-runtime/index.js +1441 -0
- package/dist/board-livegraph-runtime/index.js.map +1 -0
- package/dist/card-compute/index.cjs +159 -44
- package/dist/card-compute/index.cjs.map +1 -1
- package/dist/card-compute/index.d.cts +36 -11
- package/dist/card-compute/index.d.ts +36 -11
- package/dist/card-compute/index.js +156 -44
- package/dist/card-compute/index.js.map +1 -1
- package/dist/cli/board-live-cards-cli.cjs +476 -105
- package/dist/cli/board-live-cards-cli.cjs.map +1 -1
- package/dist/cli/board-live-cards-cli.d.cts +8 -16
- package/dist/cli/board-live-cards-cli.d.ts +8 -16
- package/dist/cli/board-live-cards-cli.js +476 -106
- package/dist/cli/board-live-cards-cli.js.map +1 -1
- package/dist/continuous-event-graph/index.cjs +74 -33
- package/dist/continuous-event-graph/index.cjs.map +1 -1
- package/dist/continuous-event-graph/index.d.cts +7 -23
- package/dist/continuous-event-graph/index.d.ts +7 -23
- package/dist/continuous-event-graph/index.js +73 -32
- package/dist/continuous-event-graph/index.js.map +1 -1
- package/dist/index.cjs +1440 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -3
- package/dist/index.d.ts +21 -3
- package/dist/index.js +1434 -56
- package/dist/index.js.map +1 -1
- package/dist/journal-DRfJiheM.d.cts +28 -0
- package/dist/journal-NLYuqege.d.ts +28 -0
- package/dist/{journal-B_2JnBMF.d.ts → live-cards-bridge-Or7fdEJV.d.ts} +5 -32
- package/dist/{journal-BJDjWb5Q.d.cts → live-cards-bridge-vGJ6tMzN.d.cts} +5 -32
- package/dist/schedule-CMcZe5Ny.d.ts +21 -0
- package/dist/schedule-CiucyCan.d.cts +21 -0
- package/examples/browser/boards/portfolio-tracker/cards/holdings-table.json +1 -1
- package/examples/browser/boards/portfolio-tracker/cards/portfolio-form.json +3 -3
- package/examples/browser/boards/portfolio-tracker/cards/portfolio-value.json +1 -1
- package/examples/browser/boards/portfolio-tracker/cards/price-fetch.json +3 -3
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-task-executor.cjs +96 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker.js +33 -5
- package/examples/browser/livecards-browser/index.html +37 -684
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/holdings-table.json +1 -1
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +3 -3
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +1 -1
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/price-fetch.json +3 -3
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +2 -2
- package/examples/example-board/board.yaml +23 -0
- package/examples/example-board/bootstrap_payload.json +1 -0
- package/examples/example-board/cards/card-chain-region-alert.json +39 -0
- package/examples/example-board/cards/card-chain-region-totals.json +26 -0
- package/examples/example-board/cards/card-chain-top-region.json +24 -0
- package/examples/example-board/cards/card-ex-actions.json +32 -0
- package/examples/example-board/cards/card-ex-chart.json +30 -0
- package/examples/example-board/cards/card-ex-filter.json +36 -0
- package/examples/example-board/cards/card-ex-filtered-by-preference.json +59 -0
- package/examples/example-board/cards/card-ex-form.json +91 -0
- package/examples/example-board/cards/card-ex-list.json +22 -0
- package/examples/example-board/cards/card-ex-markdown.json +17 -0
- package/examples/example-board/cards/card-ex-metric.json +19 -0
- package/examples/example-board/cards/card-ex-narrative.json +36 -0
- package/examples/example-board/cards/card-ex-source-http.json +28 -0
- package/examples/example-board/cards/card-ex-source.json +21 -0
- package/examples/example-board/cards/card-ex-status.json +35 -0
- package/examples/example-board/cards/card-ex-table.json +30 -0
- package/examples/example-board/cards/card-ex-todo.json +29 -0
- package/examples/example-board/demo-chat-handler.js +69 -0
- package/examples/example-board/demo-server-config.json +7 -0
- package/examples/example-board/demo-server.js +124 -0
- package/examples/example-board/demo-shell-browser.html +806 -0
- package/examples/example-board/demo-shell-with-server.html +280 -0
- package/examples/example-board/demo-shell.html +62 -0
- package/examples/example-board/demo-task-executor.js +255 -0
- package/examples/example-board/mock.db +15 -0
- package/examples/example-board/reusable-board-runtime-client.js +265 -0
- package/examples/example-board/reusable-runtime-artifacts-adapter.js +233 -0
- package/examples/example-board/reusable-server-runtime.js +1341 -0
- package/examples/index.html +16 -9
- package/examples/npm-libs/continuous-event-graph/live-cards-board.ts +17 -17
- package/examples/npm-libs/continuous-event-graph/live-portfolio-dashboard.ts +23 -23
- package/examples/step-machine-cli/portfolio-tracker/cards/holdings-table.json +1 -1
- package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +3 -3
- package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +1 -1
- package/examples/step-machine-cli/portfolio-tracker/cards/price-fetch.json +1 -1
- package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker-task-executor.cjs +96 -0
- package/package.json +16 -2
- package/schema/card-runtime.schema.json +25 -0
- package/schema/live-cards.schema.json +46 -21
- package/browser/ingest-board.js +0 -296
- package/examples/ingest.js +0 -733
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { L as LiveGraph, N as NodeInfo, b as LiveGraphSnapshot,
|
|
2
|
-
export { B as BlockedTask, P as PendingTask, d as UnresolvedDependency } from '../types-BzLD8bjb.cjs';
|
|
1
|
+
import { L as LiveGraph, N as NodeInfo, b as LiveGraphSnapshot, D as DownstreamResult, U as UnreachableNodesResult, c as UnreachableTokensResult, e as UpstreamResult, a as LiveGraphHealth } from '../types-BzLD8bjb.cjs';
|
|
2
|
+
export { B as BlockedTask, P as PendingTask, S as ScheduleResult, d as UnresolvedDependency } from '../types-BzLD8bjb.cjs';
|
|
3
3
|
import { T as TaskConfig, f as GraphEvent, G as GraphConfig } from '../types-CMFSIjpc.cjs';
|
|
4
4
|
export { c as ExecutionState, e as GraphEngineStore, g as GraphSettings } from '../types-CMFSIjpc.cjs';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export { s as schedule } from '../schedule-CiucyCan.cjs';
|
|
6
|
+
import { R as ReactiveGraph, e as TaskHandlerInput, T as TaskHandlerFn } from '../live-cards-bridge-vGJ6tMzN.cjs';
|
|
7
|
+
export { L as LiveBoard, a as LiveCard, b as LiveCardsToReactiveOptions, c as LiveCardsToReactiveResult, d as ReactiveGraphOptions, f as TaskHandlerReturn, h as computeDataHash, g as createReactiveGraph, l as liveCardsToReactiveGraph } from '../live-cards-bridge-vGJ6tMzN.cjs';
|
|
7
8
|
import { a as GraphValidationResult } from '../validate-ke92Cleg.cjs';
|
|
9
|
+
export { J as Journal, M as MemoryJournal } from '../journal-DRfJiheM.cjs';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Continuous Event Graph — Core
|
|
@@ -113,24 +115,6 @@ declare function snapshot(live: LiveGraph): LiveGraphSnapshot;
|
|
|
113
115
|
*/
|
|
114
116
|
declare function restore(data: unknown): LiveGraph;
|
|
115
117
|
|
|
116
|
-
/**
|
|
117
|
-
* Continuous Event Graph — Schedule
|
|
118
|
-
*
|
|
119
|
-
* Pure read-only projection: LiveGraph → ScheduleResult
|
|
120
|
-
*
|
|
121
|
-
* Classifies every non-terminal task into one of:
|
|
122
|
-
* - eligible: all requires satisfied, ready to dispatch
|
|
123
|
-
* - pending: requires not yet met, but a viable producer exists (normal waiting)
|
|
124
|
-
* - unresolved: requires not met, NO task in the graph can produce them (caller's problem)
|
|
125
|
-
* - blocked: requires not met because the producing task FAILED (caller's problem)
|
|
126
|
-
*/
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Compute the scheduling status of every task in the live graph.
|
|
130
|
-
* Pure function — no side effects.
|
|
131
|
-
*/
|
|
132
|
-
declare function schedule(live: LiveGraph): ScheduleResult;
|
|
133
|
-
|
|
134
118
|
/**
|
|
135
119
|
* Continuous Event Graph — Inspect
|
|
136
120
|
*
|
|
@@ -490,4 +474,4 @@ declare function createWebhookHandler(options: WebhookHandlerOptions): TaskHandl
|
|
|
490
474
|
*/
|
|
491
475
|
declare function createNoopHandler(getResolve: () => ResolveCallbackFn, staticData?: Record<string, unknown>): TaskHandlerFn;
|
|
492
476
|
|
|
493
|
-
export { DownstreamResult, GraphConfig, GraphEvent, type GraphMutation, LiveGraph, LiveGraphHealth, LiveGraphSnapshot, NodeInfo, ReactiveGraph, type ReactiveGraphValidationInput, type ResolveCallbackFn,
|
|
477
|
+
export { DownstreamResult, GraphConfig, GraphEvent, type GraphMutation, LiveGraph, LiveGraphHealth, LiveGraphSnapshot, NodeInfo, ReactiveGraph, type ReactiveGraphValidationInput, type ResolveCallbackFn, type ScriptHandlerOptions, type ShellHandlerOptions, TaskConfig, TaskHandlerFn, TaskHandlerInput, UnreachableNodesResult, UnreachableTokensResult, UpstreamResult, type WebhookHandlerOptions, addNode, addProvides, addRequires, applyEvent, applyEvents, createCallbackHandler, createFireAndForgetHandler, createLiveGraph, createNoopHandler, createScriptHandler, createShellHandler, createWebhookHandler, disableNode, drainTokens, enableNode, getDownstream, getNode, getUnreachableNodes, getUnreachableTokens, getUpstream, injectTokens, inspect, mutateGraph, removeNode, removeProvides, removeRequires, resetNode, restore, snapshot, validateLiveGraph, validateReactiveGraph };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { L as LiveGraph, N as NodeInfo, b as LiveGraphSnapshot,
|
|
2
|
-
export { B as BlockedTask, P as PendingTask, d as UnresolvedDependency } from '../types-C2eJ7DAV.js';
|
|
1
|
+
import { L as LiveGraph, N as NodeInfo, b as LiveGraphSnapshot, D as DownstreamResult, U as UnreachableNodesResult, c as UnreachableTokensResult, e as UpstreamResult, a as LiveGraphHealth } from '../types-C2eJ7DAV.js';
|
|
2
|
+
export { B as BlockedTask, P as PendingTask, S as ScheduleResult, d as UnresolvedDependency } from '../types-C2eJ7DAV.js';
|
|
3
3
|
import { T as TaskConfig, f as GraphEvent, G as GraphConfig } from '../types-CMFSIjpc.js';
|
|
4
4
|
export { c as ExecutionState, e as GraphEngineStore, g as GraphSettings } from '../types-CMFSIjpc.js';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export { s as schedule } from '../schedule-CMcZe5Ny.js';
|
|
6
|
+
import { R as ReactiveGraph, e as TaskHandlerInput, T as TaskHandlerFn } from '../live-cards-bridge-Or7fdEJV.js';
|
|
7
|
+
export { L as LiveBoard, a as LiveCard, b as LiveCardsToReactiveOptions, c as LiveCardsToReactiveResult, d as ReactiveGraphOptions, f as TaskHandlerReturn, h as computeDataHash, g as createReactiveGraph, l as liveCardsToReactiveGraph } from '../live-cards-bridge-Or7fdEJV.js';
|
|
7
8
|
import { a as GraphValidationResult } from '../validate-DJQTQ6bP.js';
|
|
9
|
+
export { J as Journal, M as MemoryJournal } from '../journal-NLYuqege.js';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Continuous Event Graph — Core
|
|
@@ -113,24 +115,6 @@ declare function snapshot(live: LiveGraph): LiveGraphSnapshot;
|
|
|
113
115
|
*/
|
|
114
116
|
declare function restore(data: unknown): LiveGraph;
|
|
115
117
|
|
|
116
|
-
/**
|
|
117
|
-
* Continuous Event Graph — Schedule
|
|
118
|
-
*
|
|
119
|
-
* Pure read-only projection: LiveGraph → ScheduleResult
|
|
120
|
-
*
|
|
121
|
-
* Classifies every non-terminal task into one of:
|
|
122
|
-
* - eligible: all requires satisfied, ready to dispatch
|
|
123
|
-
* - pending: requires not yet met, but a viable producer exists (normal waiting)
|
|
124
|
-
* - unresolved: requires not met, NO task in the graph can produce them (caller's problem)
|
|
125
|
-
* - blocked: requires not met because the producing task FAILED (caller's problem)
|
|
126
|
-
*/
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Compute the scheduling status of every task in the live graph.
|
|
130
|
-
* Pure function — no side effects.
|
|
131
|
-
*/
|
|
132
|
-
declare function schedule(live: LiveGraph): ScheduleResult;
|
|
133
|
-
|
|
134
118
|
/**
|
|
135
119
|
* Continuous Event Graph — Inspect
|
|
136
120
|
*
|
|
@@ -490,4 +474,4 @@ declare function createWebhookHandler(options: WebhookHandlerOptions): TaskHandl
|
|
|
490
474
|
*/
|
|
491
475
|
declare function createNoopHandler(getResolve: () => ResolveCallbackFn, staticData?: Record<string, unknown>): TaskHandlerFn;
|
|
492
476
|
|
|
493
|
-
export { DownstreamResult, GraphConfig, GraphEvent, type GraphMutation, LiveGraph, LiveGraphHealth, LiveGraphSnapshot, NodeInfo, ReactiveGraph, type ReactiveGraphValidationInput, type ResolveCallbackFn,
|
|
477
|
+
export { DownstreamResult, GraphConfig, GraphEvent, type GraphMutation, LiveGraph, LiveGraphHealth, LiveGraphSnapshot, NodeInfo, ReactiveGraph, type ReactiveGraphValidationInput, type ResolveCallbackFn, type ScriptHandlerOptions, type ShellHandlerOptions, TaskConfig, TaskHandlerFn, TaskHandlerInput, UnreachableNodesResult, UnreachableTokensResult, UpstreamResult, type WebhookHandlerOptions, addNode, addProvides, addRequires, applyEvent, applyEvents, createCallbackHandler, createFireAndForgetHandler, createLiveGraph, createNoopHandler, createScriptHandler, createShellHandler, createWebhookHandler, disableNode, drainTokens, enableNode, getDownstream, getNode, getUnreachableNodes, getUnreachableTokens, getUpstream, injectTokens, inspect, mutateGraph, removeNode, removeProvides, removeRequires, resetNode, restore, snapshot, validateLiveGraph, validateReactiveGraph };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { createHash } from 'crypto';
|
|
2
1
|
import { exec } from 'child_process';
|
|
3
|
-
import
|
|
2
|
+
import jsonata2 from 'jsonata';
|
|
4
3
|
import 'ajv-formats';
|
|
5
4
|
|
|
6
5
|
// src/event-graph/constants.ts
|
|
@@ -1023,9 +1022,11 @@ var MemoryJournal = class {
|
|
|
1023
1022
|
return this.buffer.length;
|
|
1024
1023
|
}
|
|
1025
1024
|
};
|
|
1025
|
+
|
|
1026
|
+
// src/continuous-event-graph/reactive.ts
|
|
1026
1027
|
function computeDataHash(data) {
|
|
1027
1028
|
const json = stableStringify(data);
|
|
1028
|
-
return
|
|
1029
|
+
return fnv1a64Hex(json);
|
|
1029
1030
|
}
|
|
1030
1031
|
function stableStringify(value) {
|
|
1031
1032
|
if (value === null || value === void 0 || typeof value !== "object") {
|
|
@@ -1038,13 +1039,49 @@ function stableStringify(value) {
|
|
|
1038
1039
|
const keys = Object.keys(obj).sort();
|
|
1039
1040
|
return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",") + "}";
|
|
1040
1041
|
}
|
|
1042
|
+
function fnv1a64Hex(input) {
|
|
1043
|
+
let hash = 0xcbf29ce484222325n;
|
|
1044
|
+
const prime = 0x100000001b3n;
|
|
1045
|
+
const mod = 0xffffffffffffffffn;
|
|
1046
|
+
for (let i = 0; i < input.length; i++) {
|
|
1047
|
+
hash ^= BigInt(input.charCodeAt(i));
|
|
1048
|
+
hash = hash * prime & mod;
|
|
1049
|
+
}
|
|
1050
|
+
return hash.toString(16).padStart(16, "0");
|
|
1051
|
+
}
|
|
1052
|
+
function base64UrlEncode(input) {
|
|
1053
|
+
if (typeof Buffer !== "undefined") {
|
|
1054
|
+
return Buffer.from(input, "utf8").toString("base64url");
|
|
1055
|
+
}
|
|
1056
|
+
if (typeof btoa === "function") {
|
|
1057
|
+
const bytes = new TextEncoder().encode(input);
|
|
1058
|
+
let binary = "";
|
|
1059
|
+
for (const b of bytes) binary += String.fromCharCode(b);
|
|
1060
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
1061
|
+
}
|
|
1062
|
+
throw new Error("No base64 encoder available in this runtime");
|
|
1063
|
+
}
|
|
1064
|
+
function base64UrlDecode(input) {
|
|
1065
|
+
if (typeof Buffer !== "undefined") {
|
|
1066
|
+
return Buffer.from(input, "base64url").toString("utf8");
|
|
1067
|
+
}
|
|
1068
|
+
if (typeof atob === "function") {
|
|
1069
|
+
const base64 = input.replace(/-/g, "+").replace(/_/g, "/");
|
|
1070
|
+
const padded = base64 + "=".repeat((4 - base64.length % 4) % 4);
|
|
1071
|
+
const binary = atob(padded);
|
|
1072
|
+
const bytes = new Uint8Array(binary.length);
|
|
1073
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
1074
|
+
return new TextDecoder().decode(bytes);
|
|
1075
|
+
}
|
|
1076
|
+
throw new Error("No base64 decoder available in this runtime");
|
|
1077
|
+
}
|
|
1041
1078
|
function encodeCallbackToken(taskName) {
|
|
1042
1079
|
const payload = JSON.stringify({ t: taskName, n: Date.now().toString(36) + Math.random().toString(36).slice(2, 6) });
|
|
1043
|
-
return
|
|
1080
|
+
return base64UrlEncode(payload);
|
|
1044
1081
|
}
|
|
1045
1082
|
function decodeCallbackToken(token) {
|
|
1046
1083
|
try {
|
|
1047
|
-
const payload = JSON.parse(
|
|
1084
|
+
const payload = JSON.parse(base64UrlDecode(token));
|
|
1048
1085
|
if (typeof payload?.t === "string") return { taskName: payload.t };
|
|
1049
1086
|
return null;
|
|
1050
1087
|
} catch {
|
|
@@ -1672,18 +1709,18 @@ function deepSet(obj, path, value) {
|
|
|
1672
1709
|
}
|
|
1673
1710
|
async function run(node, options) {
|
|
1674
1711
|
if (!node?.compute?.length) return node;
|
|
1675
|
-
if (!node.
|
|
1712
|
+
if (!node.card_data) node.card_data = {};
|
|
1676
1713
|
node.computed_values = {};
|
|
1677
1714
|
node._sourcesData = options?.sourcesData ?? {};
|
|
1678
1715
|
const ctx = {
|
|
1679
|
-
|
|
1716
|
+
card_data: node.card_data,
|
|
1680
1717
|
requires: node.requires ?? {},
|
|
1681
|
-
|
|
1718
|
+
fetched_sources: node._sourcesData,
|
|
1682
1719
|
computed_values: node.computed_values
|
|
1683
1720
|
};
|
|
1684
1721
|
for (const step of node.compute) {
|
|
1685
1722
|
try {
|
|
1686
|
-
const val = await
|
|
1723
|
+
const val = await jsonata2(step.expr).evaluate(ctx);
|
|
1687
1724
|
deepSet(node.computed_values, step.bindTo, val);
|
|
1688
1725
|
ctx.computed_values = node.computed_values;
|
|
1689
1726
|
} catch (err) {
|
|
@@ -1694,16 +1731,16 @@ async function run(node, options) {
|
|
|
1694
1731
|
}
|
|
1695
1732
|
async function evalExpr(expr, node) {
|
|
1696
1733
|
const ctx = {
|
|
1697
|
-
|
|
1734
|
+
card_data: node.card_data ?? {},
|
|
1698
1735
|
requires: node.requires ?? {},
|
|
1699
|
-
|
|
1736
|
+
fetched_sources: node._sourcesData ?? {},
|
|
1700
1737
|
computed_values: node.computed_values ?? {}
|
|
1701
1738
|
};
|
|
1702
|
-
return
|
|
1739
|
+
return jsonata2(expr).evaluate(ctx);
|
|
1703
1740
|
}
|
|
1704
1741
|
function resolve(node, path) {
|
|
1705
|
-
if (path.startsWith("
|
|
1706
|
-
return deepGet(node._sourcesData ?? {}, path.slice("
|
|
1742
|
+
if (path.startsWith("fetched_sources.")) {
|
|
1743
|
+
return deepGet(node._sourcesData ?? {}, path.slice("fetched_sources.".length));
|
|
1707
1744
|
}
|
|
1708
1745
|
return deepGet(node, path);
|
|
1709
1746
|
}
|
|
@@ -1723,8 +1760,7 @@ var VALID_ELEMENT_KINDS = /* @__PURE__ */ new Set([
|
|
|
1723
1760
|
"markdown",
|
|
1724
1761
|
"custom"
|
|
1725
1762
|
]);
|
|
1726
|
-
var
|
|
1727
|
-
var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "state", "compute", "sources"]);
|
|
1763
|
+
var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "card_data", "compute", "sources"]);
|
|
1728
1764
|
function validateNode(node) {
|
|
1729
1765
|
const errors = [];
|
|
1730
1766
|
if (!node || typeof node !== "object" || Array.isArray(node)) {
|
|
@@ -1735,13 +1771,8 @@ function validateNode(node) {
|
|
|
1735
1771
|
for (const key of Object.keys(n)) {
|
|
1736
1772
|
if (!ALLOWED_KEYS.has(key)) errors.push(`Unknown top-level key: "${key}"`);
|
|
1737
1773
|
}
|
|
1738
|
-
if (n.
|
|
1739
|
-
errors.push("
|
|
1740
|
-
} else {
|
|
1741
|
-
const state = n.state;
|
|
1742
|
-
if (state.status != null && !VALID_STATUSES.has(state.status)) {
|
|
1743
|
-
errors.push(`state.status: must be one of: ${[...VALID_STATUSES].join(", ")}`);
|
|
1744
|
-
}
|
|
1774
|
+
if (n.card_data == null || typeof n.card_data !== "object" || Array.isArray(n.card_data)) {
|
|
1775
|
+
errors.push("card_data: required, must be an object");
|
|
1745
1776
|
}
|
|
1746
1777
|
if (n.meta != null) {
|
|
1747
1778
|
if (typeof n.meta !== "object" || Array.isArray(n.meta)) {
|
|
@@ -1830,11 +1861,21 @@ function validateNode(node) {
|
|
|
1830
1861
|
}
|
|
1831
1862
|
return { ok: errors.length === 0, errors };
|
|
1832
1863
|
}
|
|
1864
|
+
function enrichSources(sources, context) {
|
|
1865
|
+
if (!sources || sources.length === 0) return [];
|
|
1866
|
+
return sources.map((src) => ({
|
|
1867
|
+
...src,
|
|
1868
|
+
_requires: context.requires ?? {},
|
|
1869
|
+
_sourcesData: context.sourcesData ?? {},
|
|
1870
|
+
_computed_values: context.computed_values ?? {}
|
|
1871
|
+
}));
|
|
1872
|
+
}
|
|
1833
1873
|
var CardCompute = {
|
|
1834
1874
|
run,
|
|
1835
1875
|
eval: evalExpr,
|
|
1836
1876
|
resolve,
|
|
1837
|
-
validate: validateNode
|
|
1877
|
+
validate: validateNode,
|
|
1878
|
+
enrichSources
|
|
1838
1879
|
};
|
|
1839
1880
|
|
|
1840
1881
|
// src/continuous-event-graph/live-cards-bridge.ts
|
|
@@ -1870,7 +1911,7 @@ function liveCardsToReactiveGraph(input, options = {}) {
|
|
|
1870
1911
|
const allTokens = /* @__PURE__ */ new Set();
|
|
1871
1912
|
const tokenToCardId = /* @__PURE__ */ new Map();
|
|
1872
1913
|
for (const card of cards) {
|
|
1873
|
-
for (const binding of card.provides ?? [{ bindTo: card.id, src:
|
|
1914
|
+
for (const binding of card.provides ?? [{ bindTo: card.id, src: "card_data" }]) {
|
|
1874
1915
|
allTokens.add(binding.bindTo);
|
|
1875
1916
|
tokenToCardId.set(binding.bindTo, card.id);
|
|
1876
1917
|
}
|
|
@@ -1884,7 +1925,7 @@ function liveCardsToReactiveGraph(input, options = {}) {
|
|
|
1884
1925
|
}
|
|
1885
1926
|
tasks[card.id] = {
|
|
1886
1927
|
requires: requires.length > 0 ? requires : void 0,
|
|
1887
|
-
provides: (card.provides ?? [{ bindTo: card.id, src:
|
|
1928
|
+
provides: (card.provides ?? [{ bindTo: card.id, src: "card_data" }]).map((p) => p.bindTo),
|
|
1888
1929
|
taskHandlers: [card.id],
|
|
1889
1930
|
description: card.meta?.title ?? card.id
|
|
1890
1931
|
};
|
|
@@ -1936,9 +1977,9 @@ function buildSourceHandler(card, sourceHandlers, defaultSourceHandler, sharedSt
|
|
|
1936
1977
|
};
|
|
1937
1978
|
}
|
|
1938
1979
|
return async (input) => {
|
|
1939
|
-
const
|
|
1940
|
-
sharedState.set(card.id,
|
|
1941
|
-
getResolve()(input.callbackToken,
|
|
1980
|
+
const data = { ...card.card_data };
|
|
1981
|
+
sharedState.set(card.id, data);
|
|
1982
|
+
getResolve()(input.callbackToken, data);
|
|
1942
1983
|
return "task-initiated";
|
|
1943
1984
|
};
|
|
1944
1985
|
}
|
|
@@ -1961,7 +2002,7 @@ function buildCardHandler(card, cardHandlers, sharedState, _cardMap, tokenToCard
|
|
|
1961
2002
|
}
|
|
1962
2003
|
const computeNode = {
|
|
1963
2004
|
id: card.id,
|
|
1964
|
-
|
|
2005
|
+
card_data: { ...card.card_data },
|
|
1965
2006
|
requires: requiresData,
|
|
1966
2007
|
compute: card.compute
|
|
1967
2008
|
};
|
|
@@ -1973,9 +2014,9 @@ function buildCardHandler(card, cardHandlers, sharedState, _cardMap, tokenToCard
|
|
|
1973
2014
|
resultData[bindTo] = CardCompute.resolve(computeNode, src);
|
|
1974
2015
|
}
|
|
1975
2016
|
} else {
|
|
1976
|
-
resultData = { ...computeNode.
|
|
2017
|
+
resultData = { ...computeNode.card_data, ...computeNode.computed_values };
|
|
1977
2018
|
}
|
|
1978
|
-
const resultState = { ...computeNode.
|
|
2019
|
+
const resultState = { ...computeNode.card_data, ...computeNode.computed_values };
|
|
1979
2020
|
sharedState.set(card.id, resultState);
|
|
1980
2021
|
getResolve()(input.callbackToken, resultData);
|
|
1981
2022
|
return "task-initiated";
|