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
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var jsonata2 = require('jsonata');
|
|
6
6
|
var addFormats = require('ajv-formats');
|
|
7
7
|
|
|
8
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var jsonata2__default = /*#__PURE__*/_interopDefault(jsonata2);
|
|
11
11
|
var addFormats__default = /*#__PURE__*/_interopDefault(addFormats);
|
|
12
12
|
|
|
13
13
|
var __create = Object.create;
|
|
@@ -6425,13 +6425,11 @@ var require_ajv = __commonJS({
|
|
|
6425
6425
|
var live_cards_schema_default = {
|
|
6426
6426
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
6427
6427
|
$id: "https://nsreehari.github.io/boards/live-cards.schema.json",
|
|
6428
|
-
title: "LiveCards Node Schema",
|
|
6429
|
-
description: "Schema for Card and ExternalSource nodes in the LiveCards Board/Canvas engine",
|
|
6430
6428
|
definitions: {
|
|
6431
6429
|
bind_ref: {
|
|
6432
|
-
description: "A
|
|
6430
|
+
description: "A card data path reference, e.g. 'card_data.raw_quotes' or 'requires.upstream'",
|
|
6433
6431
|
type: "string",
|
|
6434
|
-
pattern: "^(
|
|
6432
|
+
pattern: "^(card_data|requires|fetched_sources|computed_values)(\\.|$)"
|
|
6435
6433
|
},
|
|
6436
6434
|
bind_or_literal: {
|
|
6437
6435
|
description: "A literal value or a bind reference object",
|
|
@@ -6500,7 +6498,7 @@ var live_cards_schema_default = {
|
|
|
6500
6498
|
]
|
|
6501
6499
|
},
|
|
6502
6500
|
input: {
|
|
6503
|
-
description: "
|
|
6501
|
+
description: "card_data.path, literal, array of inputs, or nested compute_expr",
|
|
6504
6502
|
oneOf: [
|
|
6505
6503
|
{ type: "string" },
|
|
6506
6504
|
{ type: "number" },
|
|
@@ -6536,18 +6534,18 @@ var live_cards_schema_default = {
|
|
|
6536
6534
|
required: ["bindTo", "src"],
|
|
6537
6535
|
properties: {
|
|
6538
6536
|
bindTo: { type: "string", description: "Token name published downstream" },
|
|
6539
|
-
src: { type: "string", description: "Path to read value from (
|
|
6537
|
+
src: { type: "string", description: "Path to read value from (card_data.*, requires.*, fetched_sources.*, computed_values.*)" }
|
|
6540
6538
|
}
|
|
6541
6539
|
},
|
|
6542
|
-
description: "Explicit bindings exposing computed
|
|
6540
|
+
description: "Explicit bindings exposing computed or card_data values downstream as named tokens"
|
|
6543
6541
|
},
|
|
6544
6542
|
compute_step: {
|
|
6545
|
-
description: "A single ordered compute step: reads
|
|
6543
|
+
description: "A single ordered compute step: reads card_data.*/requires.*/computed_values.*, writes to computed_values[bindTo]",
|
|
6546
6544
|
type: "object",
|
|
6547
6545
|
required: ["bindTo", "expr"],
|
|
6548
6546
|
properties: {
|
|
6549
6547
|
bindTo: { type: "string", description: "Key in computed_values to write result" },
|
|
6550
|
-
expr: { type: "string", description: "JSONata expression evaluated against {
|
|
6548
|
+
expr: { type: "string", description: "JSONata expression evaluated against { card_data, requires, fetched_sources, computed_values }" }
|
|
6551
6549
|
}
|
|
6552
6550
|
},
|
|
6553
6551
|
source_def: {
|
|
@@ -6556,7 +6554,7 @@ var live_cards_schema_default = {
|
|
|
6556
6554
|
required: ["bindTo"],
|
|
6557
6555
|
additionalProperties: true,
|
|
6558
6556
|
properties: {
|
|
6559
|
-
bindTo: { type: "string", description: "Key under
|
|
6557
|
+
bindTo: { type: "string", description: "Key under fetched_sources.* available in compute expressions" },
|
|
6560
6558
|
outputFile: { type: "string", description: "Board-relative path the executor writes its JSON result to. Presence of this file signals delivery." },
|
|
6561
6559
|
optionalForCompletionGating: { type: "boolean", default: false, description: "When true this source does not gate card completion. Default false when absent, so sources are completion-gating by default." },
|
|
6562
6560
|
timeout: { type: "integer", minimum: 0, default: 12e4, description: "Executor/script timeout in ms. Default: 120 000 (2 min)." },
|
|
@@ -6584,19 +6582,17 @@ var live_cards_schema_default = {
|
|
|
6584
6582
|
"text",
|
|
6585
6583
|
"markdown",
|
|
6586
6584
|
"custom",
|
|
6587
|
-
"file-upload",
|
|
6588
|
-
"chat",
|
|
6589
6585
|
"actions"
|
|
6590
6586
|
]
|
|
6591
6587
|
},
|
|
6592
6588
|
label: { type: "string", description: "Heading above this element" },
|
|
6593
6589
|
className: { type: "string", description: "Bootstrap grid class, e.g. 'col-12 col-md-6'" },
|
|
6594
|
-
visible: { type: "string", description: "
|
|
6590
|
+
visible: { type: "string", description: "card_data/requires/fetched_sources/computed_values path \u2014 element shown only if truthy" },
|
|
6595
6591
|
data: {
|
|
6596
6592
|
type: "object",
|
|
6597
6593
|
properties: {
|
|
6598
|
-
bind: { $ref: "#/definitions/bind_ref", description: "
|
|
6599
|
-
writeTo: { $ref: "#/definitions/bind_ref", description: "
|
|
6594
|
+
bind: { $ref: "#/definitions/bind_ref", description: "card_data/requires/fetched_sources/computed_values path to read data from" },
|
|
6595
|
+
writeTo: { $ref: "#/definitions/bind_ref", description: "card_data path for user input (form, filter, todo, notes)" },
|
|
6600
6596
|
columns: { type: "array", items: { type: "string" }, description: "table: visible columns" },
|
|
6601
6597
|
maxRows: { type: "integer", description: "table/list: max rows to display" },
|
|
6602
6598
|
sortable: { type: "boolean", default: true, description: "table: enable click-to-sort" },
|
|
@@ -6629,7 +6625,7 @@ var live_cards_schema_default = {
|
|
|
6629
6625
|
label: { type: "string" },
|
|
6630
6626
|
style: { type: "string", description: "Bootstrap button variant, e.g. 'success', 'outline-danger'" },
|
|
6631
6627
|
size: { type: "string", default: "sm" },
|
|
6632
|
-
disabled: { oneOf: [{ type: "boolean" }, { type: "string", description: "
|
|
6628
|
+
disabled: { oneOf: [{ type: "boolean" }, { type: "string", description: "card_data/requires/fetched_sources/computed_values path \u2014 truthy = disabled" }] }
|
|
6633
6629
|
}
|
|
6634
6630
|
}
|
|
6635
6631
|
}
|
|
@@ -6689,14 +6685,39 @@ var live_cards_schema_default = {
|
|
|
6689
6685
|
provides: { $ref: "#/definitions/provides" },
|
|
6690
6686
|
meta: { $ref: "#/definitions/meta" },
|
|
6691
6687
|
view: { $ref: "#/definitions/view" },
|
|
6692
|
-
|
|
6688
|
+
card_data: {
|
|
6693
6689
|
type: "object",
|
|
6694
|
-
|
|
6690
|
+
description: "Authored card data supplied in the card definition",
|
|
6695
6691
|
properties: {
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6692
|
+
files: {
|
|
6693
|
+
type: "array",
|
|
6694
|
+
description: "Optional uploaded-file metadata maintained by host handlers. Stored name is normalized and serial-prefixed (for example 001-my_file.pdf).",
|
|
6695
|
+
items: {
|
|
6696
|
+
type: "object",
|
|
6697
|
+
required: ["name", "stored_name"],
|
|
6698
|
+
properties: {
|
|
6699
|
+
name: { type: "string", minLength: 1 },
|
|
6700
|
+
stored_name: {
|
|
6701
|
+
type: "string",
|
|
6702
|
+
minLength: 5,
|
|
6703
|
+
maxLength: 32,
|
|
6704
|
+
pattern: "^[0-9]{3,}-[a-z0-9._-]+$"
|
|
6705
|
+
},
|
|
6706
|
+
size: {
|
|
6707
|
+
oneOf: [
|
|
6708
|
+
{ type: "integer", minimum: 0 },
|
|
6709
|
+
{ type: "null" }
|
|
6710
|
+
]
|
|
6711
|
+
},
|
|
6712
|
+
mime_type: { type: "string" },
|
|
6713
|
+
path: { type: "string", pattern: "^[^\\s]+/files/[0-9]{3,}-[a-z0-9._-]+$" },
|
|
6714
|
+
uploaded_at: { type: "string", format: "date-time" }
|
|
6715
|
+
},
|
|
6716
|
+
additionalProperties: false
|
|
6717
|
+
}
|
|
6718
|
+
}
|
|
6719
|
+
},
|
|
6720
|
+
additionalProperties: true
|
|
6700
6721
|
},
|
|
6701
6722
|
sources: {
|
|
6702
6723
|
type: "array",
|
|
@@ -6705,7 +6726,7 @@ var live_cards_schema_default = {
|
|
|
6705
6726
|
},
|
|
6706
6727
|
compute: {
|
|
6707
6728
|
type: "array",
|
|
6708
|
-
description: "Ordered array of compute steps. Each reads
|
|
6729
|
+
description: "Ordered array of compute steps. Each reads card_data.*/requires.*/fetched_sources.*/computed_values.* and writes to ephemeral computed_values[bindTo].",
|
|
6709
6730
|
items: { $ref: "#/definitions/compute_step" }
|
|
6710
6731
|
}
|
|
6711
6732
|
}
|
|
@@ -6714,6 +6735,57 @@ var live_cards_schema_default = {
|
|
|
6714
6735
|
// src/card-compute/schema-validator.ts
|
|
6715
6736
|
var import_ajv = __toESM(require_ajv());
|
|
6716
6737
|
var _compiled = null;
|
|
6738
|
+
var NAMESPACE_REFERENCE_RE = /\b(card_data|requires|fetched_sources|computed_values|sources)\b/g;
|
|
6739
|
+
var ROOT_PATH_NAMESPACE_RE = /^\s*(card_data|requires|fetched_sources|computed_values|sources)(\.|$)/;
|
|
6740
|
+
function referencedNamespaces(expression) {
|
|
6741
|
+
const namespaces = /* @__PURE__ */ new Set();
|
|
6742
|
+
let match;
|
|
6743
|
+
NAMESPACE_REFERENCE_RE.lastIndex = 0;
|
|
6744
|
+
while ((match = NAMESPACE_REFERENCE_RE.exec(expression)) !== null) {
|
|
6745
|
+
namespaces.add(match[1]);
|
|
6746
|
+
}
|
|
6747
|
+
return namespaces;
|
|
6748
|
+
}
|
|
6749
|
+
function parseRootPathNamespace(pathValue) {
|
|
6750
|
+
const match = ROOT_PATH_NAMESPACE_RE.exec(pathValue);
|
|
6751
|
+
return match ? match[1] : null;
|
|
6752
|
+
}
|
|
6753
|
+
function validateJsonataExprWithNamespaces(expr, path, allowedNamespaces, errors) {
|
|
6754
|
+
try {
|
|
6755
|
+
jsonata2__default.default(expr);
|
|
6756
|
+
} catch (err) {
|
|
6757
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
6758
|
+
errors.push(`${path}: invalid JSONata expression (${message})`);
|
|
6759
|
+
return;
|
|
6760
|
+
}
|
|
6761
|
+
const usedNamespaces = referencedNamespaces(expr);
|
|
6762
|
+
for (const namespace of usedNamespaces) {
|
|
6763
|
+
if (!allowedNamespaces.has(namespace)) {
|
|
6764
|
+
errors.push(`${path}: disallowed namespace "${namespace}" in expression`);
|
|
6765
|
+
}
|
|
6766
|
+
}
|
|
6767
|
+
}
|
|
6768
|
+
function walkViewPathReferences(value, path, errors) {
|
|
6769
|
+
if (Array.isArray(value)) {
|
|
6770
|
+
value.forEach((entry, index) => {
|
|
6771
|
+
walkViewPathReferences(entry, `${path}/${index}`, errors);
|
|
6772
|
+
});
|
|
6773
|
+
return;
|
|
6774
|
+
}
|
|
6775
|
+
if (typeof value === "string") {
|
|
6776
|
+
const rootNamespace = parseRootPathNamespace(value);
|
|
6777
|
+
if (!rootNamespace) return;
|
|
6778
|
+
if (!(/* @__PURE__ */ new Set(["card_data", "requires", "fetched_sources", "computed_values"])).has(rootNamespace)) {
|
|
6779
|
+
errors.push(`${path}: disallowed namespace "${rootNamespace}" in view reference`);
|
|
6780
|
+
}
|
|
6781
|
+
return;
|
|
6782
|
+
}
|
|
6783
|
+
if (!value || typeof value !== "object") return;
|
|
6784
|
+
const record = value;
|
|
6785
|
+
for (const [key, next] of Object.entries(record)) {
|
|
6786
|
+
walkViewPathReferences(next, `${path}/${key}`, errors);
|
|
6787
|
+
}
|
|
6788
|
+
}
|
|
6717
6789
|
function getValidator() {
|
|
6718
6790
|
if (_compiled) return _compiled;
|
|
6719
6791
|
const ajv = new import_ajv.default({ allErrors: true });
|
|
@@ -6731,6 +6803,42 @@ function validateLiveCardSchema(node) {
|
|
|
6731
6803
|
});
|
|
6732
6804
|
return { ok: false, errors };
|
|
6733
6805
|
}
|
|
6806
|
+
function validateLiveCardRuntimeExpressions(node) {
|
|
6807
|
+
const errors = [];
|
|
6808
|
+
if (!node || typeof node !== "object" || Array.isArray(node)) {
|
|
6809
|
+
return { ok: true, errors: [] };
|
|
6810
|
+
}
|
|
6811
|
+
const asRecord = node;
|
|
6812
|
+
const compute = asRecord.compute;
|
|
6813
|
+
if (Array.isArray(compute)) {
|
|
6814
|
+
compute.forEach((step, i) => {
|
|
6815
|
+
if (!step || typeof step !== "object" || Array.isArray(step)) return;
|
|
6816
|
+
const expr = step.expr;
|
|
6817
|
+
if (typeof expr !== "string" || expr.trim().length === 0) return;
|
|
6818
|
+
validateJsonataExprWithNamespaces(
|
|
6819
|
+
expr,
|
|
6820
|
+
`/compute/${i}/expr`,
|
|
6821
|
+
/* @__PURE__ */ new Set(["card_data", "requires", "fetched_sources", "computed_values"]),
|
|
6822
|
+
errors
|
|
6823
|
+
);
|
|
6824
|
+
});
|
|
6825
|
+
}
|
|
6826
|
+
const view = asRecord.view;
|
|
6827
|
+
if (view && typeof view === "object" && !Array.isArray(view)) {
|
|
6828
|
+
walkViewPathReferences(view, "/view", errors);
|
|
6829
|
+
}
|
|
6830
|
+
return { ok: errors.length === 0, errors };
|
|
6831
|
+
}
|
|
6832
|
+
function validateLiveCard(node) {
|
|
6833
|
+
return validateLiveCardDefinition(node);
|
|
6834
|
+
}
|
|
6835
|
+
function validateLiveCardDefinition(node) {
|
|
6836
|
+
const schema = validateLiveCardSchema(node);
|
|
6837
|
+
if (!schema.ok) return schema;
|
|
6838
|
+
const runtime = validateLiveCardRuntimeExpressions(node);
|
|
6839
|
+
if (!runtime.ok) return { ok: false, errors: runtime.errors };
|
|
6840
|
+
return { ok: true, errors: [] };
|
|
6841
|
+
}
|
|
6734
6842
|
|
|
6735
6843
|
// src/card-compute/index.ts
|
|
6736
6844
|
function deepGet(obj, path) {
|
|
@@ -6754,18 +6862,18 @@ function deepSet(obj, path, value) {
|
|
|
6754
6862
|
}
|
|
6755
6863
|
async function run(node, options) {
|
|
6756
6864
|
if (!node?.compute?.length) return node;
|
|
6757
|
-
if (!node.
|
|
6865
|
+
if (!node.card_data) node.card_data = {};
|
|
6758
6866
|
node.computed_values = {};
|
|
6759
6867
|
node._sourcesData = options?.sourcesData ?? {};
|
|
6760
6868
|
const ctx = {
|
|
6761
|
-
|
|
6869
|
+
card_data: node.card_data,
|
|
6762
6870
|
requires: node.requires ?? {},
|
|
6763
|
-
|
|
6871
|
+
fetched_sources: node._sourcesData,
|
|
6764
6872
|
computed_values: node.computed_values
|
|
6765
6873
|
};
|
|
6766
6874
|
for (const step of node.compute) {
|
|
6767
6875
|
try {
|
|
6768
|
-
const val = await
|
|
6876
|
+
const val = await jsonata2__default.default(step.expr).evaluate(ctx);
|
|
6769
6877
|
deepSet(node.computed_values, step.bindTo, val);
|
|
6770
6878
|
ctx.computed_values = node.computed_values;
|
|
6771
6879
|
} catch (err) {
|
|
@@ -6776,16 +6884,16 @@ async function run(node, options) {
|
|
|
6776
6884
|
}
|
|
6777
6885
|
async function evalExpr(expr, node) {
|
|
6778
6886
|
const ctx = {
|
|
6779
|
-
|
|
6887
|
+
card_data: node.card_data ?? {},
|
|
6780
6888
|
requires: node.requires ?? {},
|
|
6781
|
-
|
|
6889
|
+
fetched_sources: node._sourcesData ?? {},
|
|
6782
6890
|
computed_values: node.computed_values ?? {}
|
|
6783
6891
|
};
|
|
6784
|
-
return
|
|
6892
|
+
return jsonata2__default.default(expr).evaluate(ctx);
|
|
6785
6893
|
}
|
|
6786
6894
|
function resolve(node, path) {
|
|
6787
|
-
if (path.startsWith("
|
|
6788
|
-
return deepGet(node._sourcesData ?? {}, path.slice("
|
|
6895
|
+
if (path.startsWith("fetched_sources.")) {
|
|
6896
|
+
return deepGet(node._sourcesData ?? {}, path.slice("fetched_sources.".length));
|
|
6789
6897
|
}
|
|
6790
6898
|
return deepGet(node, path);
|
|
6791
6899
|
}
|
|
@@ -6805,8 +6913,7 @@ var VALID_ELEMENT_KINDS = /* @__PURE__ */ new Set([
|
|
|
6805
6913
|
"markdown",
|
|
6806
6914
|
"custom"
|
|
6807
6915
|
]);
|
|
6808
|
-
var
|
|
6809
|
-
var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "state", "compute", "sources"]);
|
|
6916
|
+
var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "card_data", "compute", "sources"]);
|
|
6810
6917
|
function validateNode(node) {
|
|
6811
6918
|
const errors = [];
|
|
6812
6919
|
if (!node || typeof node !== "object" || Array.isArray(node)) {
|
|
@@ -6817,13 +6924,8 @@ function validateNode(node) {
|
|
|
6817
6924
|
for (const key of Object.keys(n)) {
|
|
6818
6925
|
if (!ALLOWED_KEYS.has(key)) errors.push(`Unknown top-level key: "${key}"`);
|
|
6819
6926
|
}
|
|
6820
|
-
if (n.
|
|
6821
|
-
errors.push("
|
|
6822
|
-
} else {
|
|
6823
|
-
const state = n.state;
|
|
6824
|
-
if (state.status != null && !VALID_STATUSES.has(state.status)) {
|
|
6825
|
-
errors.push(`state.status: must be one of: ${[...VALID_STATUSES].join(", ")}`);
|
|
6826
|
-
}
|
|
6927
|
+
if (n.card_data == null || typeof n.card_data !== "object" || Array.isArray(n.card_data)) {
|
|
6928
|
+
errors.push("card_data: required, must be an object");
|
|
6827
6929
|
}
|
|
6828
6930
|
if (n.meta != null) {
|
|
6829
6931
|
if (typeof n.meta !== "object" || Array.isArray(n.meta)) {
|
|
@@ -6912,16 +7014,29 @@ function validateNode(node) {
|
|
|
6912
7014
|
}
|
|
6913
7015
|
return { ok: errors.length === 0, errors };
|
|
6914
7016
|
}
|
|
7017
|
+
function enrichSources(sources, context) {
|
|
7018
|
+
if (!sources || sources.length === 0) return [];
|
|
7019
|
+
return sources.map((src) => ({
|
|
7020
|
+
...src,
|
|
7021
|
+
_requires: context.requires ?? {},
|
|
7022
|
+
_sourcesData: context.sourcesData ?? {},
|
|
7023
|
+
_computed_values: context.computed_values ?? {}
|
|
7024
|
+
}));
|
|
7025
|
+
}
|
|
6915
7026
|
var CardCompute = {
|
|
6916
7027
|
run,
|
|
6917
7028
|
eval: evalExpr,
|
|
6918
7029
|
resolve,
|
|
6919
|
-
validate: validateNode
|
|
7030
|
+
validate: validateNode,
|
|
7031
|
+
enrichSources
|
|
6920
7032
|
};
|
|
6921
7033
|
var card_compute_default = CardCompute;
|
|
6922
7034
|
|
|
6923
7035
|
exports.CardCompute = CardCompute;
|
|
6924
7036
|
exports.default = card_compute_default;
|
|
7037
|
+
exports.validateLiveCard = validateLiveCard;
|
|
7038
|
+
exports.validateLiveCardDefinition = validateLiveCardDefinition;
|
|
7039
|
+
exports.validateLiveCardRuntimeExpressions = validateLiveCardRuntimeExpressions;
|
|
6925
7040
|
exports.validateLiveCardSchema = validateLiveCardSchema;
|
|
6926
7041
|
//# sourceMappingURL=index.cjs.map
|
|
6927
7042
|
//# sourceMappingURL=index.cjs.map
|