yaml-flow 4.0.0 → 5.0.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.js +87 -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 +1284 -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,13 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var crypto = require('crypto');
|
|
4
3
|
var child_process = require('child_process');
|
|
5
|
-
var
|
|
4
|
+
var jsonata2 = require('jsonata');
|
|
6
5
|
require('ajv-formats');
|
|
7
6
|
|
|
8
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
8
|
|
|
10
|
-
var
|
|
9
|
+
var jsonata2__default = /*#__PURE__*/_interopDefault(jsonata2);
|
|
11
10
|
|
|
12
11
|
// src/event-graph/constants.ts
|
|
13
12
|
var TASK_STATUS = {
|
|
@@ -1029,9 +1028,11 @@ var MemoryJournal = class {
|
|
|
1029
1028
|
return this.buffer.length;
|
|
1030
1029
|
}
|
|
1031
1030
|
};
|
|
1031
|
+
|
|
1032
|
+
// src/continuous-event-graph/reactive.ts
|
|
1032
1033
|
function computeDataHash(data) {
|
|
1033
1034
|
const json = stableStringify(data);
|
|
1034
|
-
return
|
|
1035
|
+
return fnv1a64Hex(json);
|
|
1035
1036
|
}
|
|
1036
1037
|
function stableStringify(value) {
|
|
1037
1038
|
if (value === null || value === void 0 || typeof value !== "object") {
|
|
@@ -1044,13 +1045,49 @@ function stableStringify(value) {
|
|
|
1044
1045
|
const keys = Object.keys(obj).sort();
|
|
1045
1046
|
return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",") + "}";
|
|
1046
1047
|
}
|
|
1048
|
+
function fnv1a64Hex(input) {
|
|
1049
|
+
let hash = 0xcbf29ce484222325n;
|
|
1050
|
+
const prime = 0x100000001b3n;
|
|
1051
|
+
const mod = 0xffffffffffffffffn;
|
|
1052
|
+
for (let i = 0; i < input.length; i++) {
|
|
1053
|
+
hash ^= BigInt(input.charCodeAt(i));
|
|
1054
|
+
hash = hash * prime & mod;
|
|
1055
|
+
}
|
|
1056
|
+
return hash.toString(16).padStart(16, "0");
|
|
1057
|
+
}
|
|
1058
|
+
function base64UrlEncode(input) {
|
|
1059
|
+
if (typeof Buffer !== "undefined") {
|
|
1060
|
+
return Buffer.from(input, "utf8").toString("base64url");
|
|
1061
|
+
}
|
|
1062
|
+
if (typeof btoa === "function") {
|
|
1063
|
+
const bytes = new TextEncoder().encode(input);
|
|
1064
|
+
let binary = "";
|
|
1065
|
+
for (const b of bytes) binary += String.fromCharCode(b);
|
|
1066
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
1067
|
+
}
|
|
1068
|
+
throw new Error("No base64 encoder available in this runtime");
|
|
1069
|
+
}
|
|
1070
|
+
function base64UrlDecode(input) {
|
|
1071
|
+
if (typeof Buffer !== "undefined") {
|
|
1072
|
+
return Buffer.from(input, "base64url").toString("utf8");
|
|
1073
|
+
}
|
|
1074
|
+
if (typeof atob === "function") {
|
|
1075
|
+
const base64 = input.replace(/-/g, "+").replace(/_/g, "/");
|
|
1076
|
+
const padded = base64 + "=".repeat((4 - base64.length % 4) % 4);
|
|
1077
|
+
const binary = atob(padded);
|
|
1078
|
+
const bytes = new Uint8Array(binary.length);
|
|
1079
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
1080
|
+
return new TextDecoder().decode(bytes);
|
|
1081
|
+
}
|
|
1082
|
+
throw new Error("No base64 decoder available in this runtime");
|
|
1083
|
+
}
|
|
1047
1084
|
function encodeCallbackToken(taskName) {
|
|
1048
1085
|
const payload = JSON.stringify({ t: taskName, n: Date.now().toString(36) + Math.random().toString(36).slice(2, 6) });
|
|
1049
|
-
return
|
|
1086
|
+
return base64UrlEncode(payload);
|
|
1050
1087
|
}
|
|
1051
1088
|
function decodeCallbackToken(token) {
|
|
1052
1089
|
try {
|
|
1053
|
-
const payload = JSON.parse(
|
|
1090
|
+
const payload = JSON.parse(base64UrlDecode(token));
|
|
1054
1091
|
if (typeof payload?.t === "string") return { taskName: payload.t };
|
|
1055
1092
|
return null;
|
|
1056
1093
|
} catch {
|
|
@@ -1678,18 +1715,18 @@ function deepSet(obj, path, value) {
|
|
|
1678
1715
|
}
|
|
1679
1716
|
async function run(node, options) {
|
|
1680
1717
|
if (!node?.compute?.length) return node;
|
|
1681
|
-
if (!node.
|
|
1718
|
+
if (!node.card_data) node.card_data = {};
|
|
1682
1719
|
node.computed_values = {};
|
|
1683
1720
|
node._sourcesData = options?.sourcesData ?? {};
|
|
1684
1721
|
const ctx = {
|
|
1685
|
-
|
|
1722
|
+
card_data: node.card_data,
|
|
1686
1723
|
requires: node.requires ?? {},
|
|
1687
|
-
|
|
1724
|
+
fetched_sources: node._sourcesData,
|
|
1688
1725
|
computed_values: node.computed_values
|
|
1689
1726
|
};
|
|
1690
1727
|
for (const step of node.compute) {
|
|
1691
1728
|
try {
|
|
1692
|
-
const val = await
|
|
1729
|
+
const val = await jsonata2__default.default(step.expr).evaluate(ctx);
|
|
1693
1730
|
deepSet(node.computed_values, step.bindTo, val);
|
|
1694
1731
|
ctx.computed_values = node.computed_values;
|
|
1695
1732
|
} catch (err) {
|
|
@@ -1700,16 +1737,16 @@ async function run(node, options) {
|
|
|
1700
1737
|
}
|
|
1701
1738
|
async function evalExpr(expr, node) {
|
|
1702
1739
|
const ctx = {
|
|
1703
|
-
|
|
1740
|
+
card_data: node.card_data ?? {},
|
|
1704
1741
|
requires: node.requires ?? {},
|
|
1705
|
-
|
|
1742
|
+
fetched_sources: node._sourcesData ?? {},
|
|
1706
1743
|
computed_values: node.computed_values ?? {}
|
|
1707
1744
|
};
|
|
1708
|
-
return
|
|
1745
|
+
return jsonata2__default.default(expr).evaluate(ctx);
|
|
1709
1746
|
}
|
|
1710
1747
|
function resolve(node, path) {
|
|
1711
|
-
if (path.startsWith("
|
|
1712
|
-
return deepGet(node._sourcesData ?? {}, path.slice("
|
|
1748
|
+
if (path.startsWith("fetched_sources.")) {
|
|
1749
|
+
return deepGet(node._sourcesData ?? {}, path.slice("fetched_sources.".length));
|
|
1713
1750
|
}
|
|
1714
1751
|
return deepGet(node, path);
|
|
1715
1752
|
}
|
|
@@ -1729,8 +1766,7 @@ var VALID_ELEMENT_KINDS = /* @__PURE__ */ new Set([
|
|
|
1729
1766
|
"markdown",
|
|
1730
1767
|
"custom"
|
|
1731
1768
|
]);
|
|
1732
|
-
var
|
|
1733
|
-
var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "state", "compute", "sources"]);
|
|
1769
|
+
var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "card_data", "compute", "sources"]);
|
|
1734
1770
|
function validateNode(node) {
|
|
1735
1771
|
const errors = [];
|
|
1736
1772
|
if (!node || typeof node !== "object" || Array.isArray(node)) {
|
|
@@ -1741,13 +1777,8 @@ function validateNode(node) {
|
|
|
1741
1777
|
for (const key of Object.keys(n)) {
|
|
1742
1778
|
if (!ALLOWED_KEYS.has(key)) errors.push(`Unknown top-level key: "${key}"`);
|
|
1743
1779
|
}
|
|
1744
|
-
if (n.
|
|
1745
|
-
errors.push("
|
|
1746
|
-
} else {
|
|
1747
|
-
const state = n.state;
|
|
1748
|
-
if (state.status != null && !VALID_STATUSES.has(state.status)) {
|
|
1749
|
-
errors.push(`state.status: must be one of: ${[...VALID_STATUSES].join(", ")}`);
|
|
1750
|
-
}
|
|
1780
|
+
if (n.card_data == null || typeof n.card_data !== "object" || Array.isArray(n.card_data)) {
|
|
1781
|
+
errors.push("card_data: required, must be an object");
|
|
1751
1782
|
}
|
|
1752
1783
|
if (n.meta != null) {
|
|
1753
1784
|
if (typeof n.meta !== "object" || Array.isArray(n.meta)) {
|
|
@@ -1836,11 +1867,21 @@ function validateNode(node) {
|
|
|
1836
1867
|
}
|
|
1837
1868
|
return { ok: errors.length === 0, errors };
|
|
1838
1869
|
}
|
|
1870
|
+
function enrichSources(sources, context) {
|
|
1871
|
+
if (!sources || sources.length === 0) return [];
|
|
1872
|
+
return sources.map((src) => ({
|
|
1873
|
+
...src,
|
|
1874
|
+
_requires: context.requires ?? {},
|
|
1875
|
+
_sourcesData: context.sourcesData ?? {},
|
|
1876
|
+
_computed_values: context.computed_values ?? {}
|
|
1877
|
+
}));
|
|
1878
|
+
}
|
|
1839
1879
|
var CardCompute = {
|
|
1840
1880
|
run,
|
|
1841
1881
|
eval: evalExpr,
|
|
1842
1882
|
resolve,
|
|
1843
|
-
validate: validateNode
|
|
1883
|
+
validate: validateNode,
|
|
1884
|
+
enrichSources
|
|
1844
1885
|
};
|
|
1845
1886
|
|
|
1846
1887
|
// src/continuous-event-graph/live-cards-bridge.ts
|
|
@@ -1876,7 +1917,7 @@ function liveCardsToReactiveGraph(input, options = {}) {
|
|
|
1876
1917
|
const allTokens = /* @__PURE__ */ new Set();
|
|
1877
1918
|
const tokenToCardId = /* @__PURE__ */ new Map();
|
|
1878
1919
|
for (const card of cards) {
|
|
1879
|
-
for (const binding of card.provides ?? [{ bindTo: card.id, src:
|
|
1920
|
+
for (const binding of card.provides ?? [{ bindTo: card.id, src: "card_data" }]) {
|
|
1880
1921
|
allTokens.add(binding.bindTo);
|
|
1881
1922
|
tokenToCardId.set(binding.bindTo, card.id);
|
|
1882
1923
|
}
|
|
@@ -1890,7 +1931,7 @@ function liveCardsToReactiveGraph(input, options = {}) {
|
|
|
1890
1931
|
}
|
|
1891
1932
|
tasks[card.id] = {
|
|
1892
1933
|
requires: requires.length > 0 ? requires : void 0,
|
|
1893
|
-
provides: (card.provides ?? [{ bindTo: card.id, src:
|
|
1934
|
+
provides: (card.provides ?? [{ bindTo: card.id, src: "card_data" }]).map((p) => p.bindTo),
|
|
1894
1935
|
taskHandlers: [card.id],
|
|
1895
1936
|
description: card.meta?.title ?? card.id
|
|
1896
1937
|
};
|
|
@@ -1942,9 +1983,9 @@ function buildSourceHandler(card, sourceHandlers, defaultSourceHandler, sharedSt
|
|
|
1942
1983
|
};
|
|
1943
1984
|
}
|
|
1944
1985
|
return async (input) => {
|
|
1945
|
-
const
|
|
1946
|
-
sharedState.set(card.id,
|
|
1947
|
-
getResolve()(input.callbackToken,
|
|
1986
|
+
const data = { ...card.card_data };
|
|
1987
|
+
sharedState.set(card.id, data);
|
|
1988
|
+
getResolve()(input.callbackToken, data);
|
|
1948
1989
|
return "task-initiated";
|
|
1949
1990
|
};
|
|
1950
1991
|
}
|
|
@@ -1967,7 +2008,7 @@ function buildCardHandler(card, cardHandlers, sharedState, _cardMap, tokenToCard
|
|
|
1967
2008
|
}
|
|
1968
2009
|
const computeNode = {
|
|
1969
2010
|
id: card.id,
|
|
1970
|
-
|
|
2011
|
+
card_data: { ...card.card_data },
|
|
1971
2012
|
requires: requiresData,
|
|
1972
2013
|
compute: card.compute
|
|
1973
2014
|
};
|
|
@@ -1979,9 +2020,9 @@ function buildCardHandler(card, cardHandlers, sharedState, _cardMap, tokenToCard
|
|
|
1979
2020
|
resultData[bindTo] = CardCompute.resolve(computeNode, src);
|
|
1980
2021
|
}
|
|
1981
2022
|
} else {
|
|
1982
|
-
resultData = { ...computeNode.
|
|
2023
|
+
resultData = { ...computeNode.card_data, ...computeNode.computed_values };
|
|
1983
2024
|
}
|
|
1984
|
-
const resultState = { ...computeNode.
|
|
2025
|
+
const resultState = { ...computeNode.card_data, ...computeNode.computed_values };
|
|
1985
2026
|
sharedState.set(card.id, resultState);
|
|
1986
2027
|
getResolve()(input.callbackToken, resultData);
|
|
1987
2028
|
return "task-initiated";
|