yaml-flow 5.2.6 → 5.3.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/README.md +6 -6
- package/board-livecards-server-runtime.js +260 -35
- package/browser/board-livegraph-engine.js +61 -33
- package/browser/board-livegraph-engine.js.map +1 -1
- package/browser/card-compute.js +18 -18
- package/browser/live-cards.js +317 -156
- package/browser/live-cards.schema.json +15 -10
- package/dist/board-livegraph-runtime/index.cjs +61 -33
- package/dist/board-livegraph-runtime/index.cjs.map +1 -1
- package/dist/board-livegraph-runtime/index.d.cts +1 -1
- package/dist/board-livegraph-runtime/index.d.ts +1 -1
- package/dist/board-livegraph-runtime/index.js +61 -33
- package/dist/board-livegraph-runtime/index.js.map +1 -1
- package/dist/card-compute/index.cjs +101 -39
- package/dist/card-compute/index.cjs.map +1 -1
- package/dist/card-compute/index.d.cts +13 -8
- package/dist/card-compute/index.d.ts +13 -8
- package/dist/card-compute/index.js +101 -39
- package/dist/card-compute/index.js.map +1 -1
- package/dist/cli/board-live-cards-cli.cjs +7205 -202
- package/dist/cli/board-live-cards-cli.cjs.map +1 -1
- package/dist/cli/board-live-cards-cli.d.cts +6 -6
- package/dist/cli/board-live-cards-cli.d.ts +6 -6
- package/dist/cli/board-live-cards-cli.js +7204 -202
- package/dist/cli/board-live-cards-cli.js.map +1 -1
- package/dist/continuous-event-graph/index.cjs +59 -31
- package/dist/continuous-event-graph/index.cjs.map +1 -1
- package/dist/continuous-event-graph/index.d.cts +2 -2
- package/dist/continuous-event-graph/index.d.ts +2 -2
- package/dist/continuous-event-graph/index.js +59 -31
- package/dist/continuous-event-graph/index.js.map +1 -1
- package/dist/index.cjs +126 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +126 -54
- package/dist/index.js.map +1 -1
- package/dist/{live-cards-bridge-CeNxiVcm.d.ts → live-cards-bridge-EQjytzI_.d.ts} +10 -5
- package/dist/{live-cards-bridge-z_rJCSbi.d.cts → live-cards-bridge-x5XREkXm.d.cts} +10 -5
- package/examples/browser/boards/portfolio-tracker/cards/holdings-table.json +1 -1
- package/examples/browser/boards/portfolio-tracker/cards/portfolio-form.json +1 -1
- package/examples/browser/boards/portfolio-tracker/cards/portfolio-risk-assessment.json +1 -1
- package/examples/browser/boards/portfolio-tracker/cards/portfolio-value.json +1 -1
- package/examples/browser/boards/portfolio-tracker/cards/price-fetch.json +2 -2
- package/examples/browser/boards/portfolio-tracker/cards/rebalancing-strategy.json +1 -1
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker.js +10 -10
- 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 +1 -1
- 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 +2 -2
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +1 -1
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +1 -1
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +1 -1
- package/examples/example-board/agent-instructions-cardlayout.md +29 -1
- package/examples/example-board/agent-instructions.md +271 -45
- package/examples/example-board/cards/card-concentration.json +8 -5
- package/examples/example-board/cards/card-market-prices.json +14 -9
- package/examples/example-board/cards/card-my-identity.json +28 -0
- package/examples/example-board/cards/card-portfolio-value.json +1 -1
- package/examples/example-board/cards/card-portfolio.json +1 -1
- package/examples/example-board/cards/card-rebalance-impact.json +65 -0
- package/examples/example-board/cards/card-rebalance-sim.json +67 -0
- package/examples/example-board/demo-chat-handler.js +2 -1
- package/examples/example-board/demo-server-config.json +6 -1
- package/examples/example-board/demo-server.js +91 -8
- package/examples/example-board/demo-shell-browser.html +6 -6
- package/examples/example-board/demo-shell-with-server.html +4 -4
- package/examples/example-board/demo-task-executor.js +457 -246
- package/examples/example-board/scripts/copilot_wrapper.bat +16 -0
- package/examples/example-board/scripts/copilot_wrapper_helper.ps1 +19 -10
- package/examples/example-board/scripts/workiq_wrapper.mjs +66 -0
- package/examples/npm-libs/continuous-event-graph/live-cards-board.ts +5 -5
- package/examples/npm-libs/continuous-event-graph/soc-incident-board.ts +3 -3
- package/examples/npm-libs/event-graph/research-pipeline.ts +5 -5
- package/examples/npm-libs/graph-of-graphs/multi-stage-etl.ts +9 -9
- package/examples/step-machine-cli/portfolio-tracker/cards/holdings-table.json +1 -1
- package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +1 -1
- package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +1 -1
- package/examples/step-machine-cli/portfolio-tracker/cards/price-fetch.json +3 -3
- package/examples/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +1 -1
- package/examples/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +1 -1
- package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +1 -1
- package/package.json +2 -2
- package/schema/live-cards.schema.json +15 -10
|
@@ -58,13 +58,16 @@ declare function validateLiveCardDefinition(node: unknown): ValidationResult;
|
|
|
58
58
|
* Expressions are evaluated against { card_data, requires, fetched_sources, computed_values }.
|
|
59
59
|
* computed_values is ephemeral — never persisted to disk.
|
|
60
60
|
*/
|
|
61
|
-
/** A source definition: cli writes to outputFile; bindTo names the fetched_sources.* key in compute context. Both bindTo and outputFile must be unique across
|
|
61
|
+
/** A source definition: cli writes to outputFile; bindTo names the fetched_sources.* key in compute context. Both bindTo and outputFile must be unique across source_defs in a card. */
|
|
62
62
|
interface ComputeSource {
|
|
63
63
|
bindTo: string;
|
|
64
64
|
outputFile: string;
|
|
65
65
|
cli?: string;
|
|
66
66
|
script?: string;
|
|
67
67
|
optionalForCompletionGating?: boolean;
|
|
68
|
+
/** Named data projections: each key maps to a JSONata expression rooted at card_data or requires.
|
|
69
|
+
* The engine evaluates these before spawning the executor and passes results as _projections. */
|
|
70
|
+
projections?: Record<string, string>;
|
|
68
71
|
[key: string]: unknown;
|
|
69
72
|
}
|
|
70
73
|
/** Options for CardCompute.run() */
|
|
@@ -82,7 +85,7 @@ interface ComputeNode {
|
|
|
82
85
|
id?: string;
|
|
83
86
|
card_data?: Record<string, unknown>;
|
|
84
87
|
requires?: Record<string, unknown>;
|
|
85
|
-
|
|
88
|
+
source_defs?: ComputeSource[];
|
|
86
89
|
compute?: ComputeStep[];
|
|
87
90
|
computed_values?: Record<string, unknown>;
|
|
88
91
|
/** Ephemeral: populated by run() from sourcesData option. Never persisted. */
|
|
@@ -113,18 +116,20 @@ interface ValidationResult {
|
|
|
113
116
|
}
|
|
114
117
|
declare function validateNode(node: unknown): ValidationResult;
|
|
115
118
|
/**
|
|
116
|
-
* Enrich
|
|
117
|
-
* Pure function: no side effects, returns new enriched
|
|
119
|
+
* Enrich source_defs with execution context for template interpolation and prompt rendering.
|
|
120
|
+
* Pure function: no side effects, returns new enriched source_defs array.
|
|
118
121
|
*
|
|
119
|
-
* @param
|
|
122
|
+
* @param source_defs - Array of source definitions
|
|
120
123
|
* @param context - Execution context containing requires, sourcesData, computed_values
|
|
121
|
-
* @returns
|
|
124
|
+
* @returns Promise resolving to a new array of source_defs with _projections attached.
|
|
125
|
+
* Each _projections entry is the evaluated result of the corresponding projections expression.
|
|
122
126
|
*/
|
|
123
|
-
declare function enrichSources(
|
|
127
|
+
declare function enrichSources(source_defs: any[] | undefined, context: {
|
|
128
|
+
card_data?: Record<string, any>;
|
|
124
129
|
requires?: Record<string, any>;
|
|
125
130
|
sourcesData?: Record<string, any>;
|
|
126
131
|
computed_values?: Record<string, any>;
|
|
127
|
-
}): any[]
|
|
132
|
+
}): Promise<any[]>;
|
|
128
133
|
declare const CardCompute: {
|
|
129
134
|
run: typeof run;
|
|
130
135
|
eval: typeof evalExpr;
|
|
@@ -58,13 +58,16 @@ declare function validateLiveCardDefinition(node: unknown): ValidationResult;
|
|
|
58
58
|
* Expressions are evaluated against { card_data, requires, fetched_sources, computed_values }.
|
|
59
59
|
* computed_values is ephemeral — never persisted to disk.
|
|
60
60
|
*/
|
|
61
|
-
/** A source definition: cli writes to outputFile; bindTo names the fetched_sources.* key in compute context. Both bindTo and outputFile must be unique across
|
|
61
|
+
/** A source definition: cli writes to outputFile; bindTo names the fetched_sources.* key in compute context. Both bindTo and outputFile must be unique across source_defs in a card. */
|
|
62
62
|
interface ComputeSource {
|
|
63
63
|
bindTo: string;
|
|
64
64
|
outputFile: string;
|
|
65
65
|
cli?: string;
|
|
66
66
|
script?: string;
|
|
67
67
|
optionalForCompletionGating?: boolean;
|
|
68
|
+
/** Named data projections: each key maps to a JSONata expression rooted at card_data or requires.
|
|
69
|
+
* The engine evaluates these before spawning the executor and passes results as _projections. */
|
|
70
|
+
projections?: Record<string, string>;
|
|
68
71
|
[key: string]: unknown;
|
|
69
72
|
}
|
|
70
73
|
/** Options for CardCompute.run() */
|
|
@@ -82,7 +85,7 @@ interface ComputeNode {
|
|
|
82
85
|
id?: string;
|
|
83
86
|
card_data?: Record<string, unknown>;
|
|
84
87
|
requires?: Record<string, unknown>;
|
|
85
|
-
|
|
88
|
+
source_defs?: ComputeSource[];
|
|
86
89
|
compute?: ComputeStep[];
|
|
87
90
|
computed_values?: Record<string, unknown>;
|
|
88
91
|
/** Ephemeral: populated by run() from sourcesData option. Never persisted. */
|
|
@@ -113,18 +116,20 @@ interface ValidationResult {
|
|
|
113
116
|
}
|
|
114
117
|
declare function validateNode(node: unknown): ValidationResult;
|
|
115
118
|
/**
|
|
116
|
-
* Enrich
|
|
117
|
-
* Pure function: no side effects, returns new enriched
|
|
119
|
+
* Enrich source_defs with execution context for template interpolation and prompt rendering.
|
|
120
|
+
* Pure function: no side effects, returns new enriched source_defs array.
|
|
118
121
|
*
|
|
119
|
-
* @param
|
|
122
|
+
* @param source_defs - Array of source definitions
|
|
120
123
|
* @param context - Execution context containing requires, sourcesData, computed_values
|
|
121
|
-
* @returns
|
|
124
|
+
* @returns Promise resolving to a new array of source_defs with _projections attached.
|
|
125
|
+
* Each _projections entry is the evaluated result of the corresponding projections expression.
|
|
122
126
|
*/
|
|
123
|
-
declare function enrichSources(
|
|
127
|
+
declare function enrichSources(source_defs: any[] | undefined, context: {
|
|
128
|
+
card_data?: Record<string, any>;
|
|
124
129
|
requires?: Record<string, any>;
|
|
125
130
|
sourcesData?: Record<string, any>;
|
|
126
131
|
computed_values?: Record<string, any>;
|
|
127
|
-
}): any[]
|
|
132
|
+
}): Promise<any[]>;
|
|
128
133
|
declare const CardCompute: {
|
|
129
134
|
run: typeof run;
|
|
130
135
|
eval: typeof evalExpr;
|
|
@@ -6522,10 +6522,10 @@ var live_cards_schema_default = {
|
|
|
6522
6522
|
type: "array",
|
|
6523
6523
|
items: {
|
|
6524
6524
|
type: "object",
|
|
6525
|
-
required: ["bindTo", "
|
|
6525
|
+
required: ["bindTo", "ref"],
|
|
6526
6526
|
properties: {
|
|
6527
6527
|
bindTo: { type: "string", description: "Token name published downstream" },
|
|
6528
|
-
|
|
6528
|
+
ref: { type: "string", description: "Path to read value from (card_data.*, requires.*, fetched_sources.*, computed_values.*)" }
|
|
6529
6529
|
}
|
|
6530
6530
|
},
|
|
6531
6531
|
description: "Explicit bindings exposing computed or card_data values downstream as named tokens"
|
|
@@ -6540,14 +6540,19 @@ var live_cards_schema_default = {
|
|
|
6540
6540
|
}
|
|
6541
6541
|
},
|
|
6542
6542
|
source_def: {
|
|
6543
|
-
description: "One source entry. The engine requires 'bindTo' (compute namespace key) and 'outputFile' (delivery signal path). bindTo and outputFile must be unique across all
|
|
6543
|
+
description: "One source entry. The engine requires 'bindTo' (compute namespace key) and 'outputFile' (delivery signal path). bindTo and outputFile must be unique across all source_defs in a card. Every other property is yours \u2014 add whatever your task-executor needs: kind, url, headers, mailbox, channel, model, query, etc. The full object is passed verbatim as the --in JSON to the executor.",
|
|
6544
6544
|
type: "object",
|
|
6545
6545
|
required: ["bindTo", "outputFile"],
|
|
6546
6546
|
additionalProperties: true,
|
|
6547
6547
|
properties: {
|
|
6548
6548
|
bindTo: { type: "string", description: "Key under fetched_sources.* available in compute expressions" },
|
|
6549
6549
|
outputFile: { type: "string", description: "Board-relative path the executor writes its JSON result to. Presence of this file signals delivery." },
|
|
6550
|
-
|
|
6550
|
+
projections: {
|
|
6551
|
+
type: "object",
|
|
6552
|
+
description: "Named data projections from card_data or requires, evaluated before the executor is called. Each key is a ref name; each value is a JSONata expression rooted at card_data or requires. The resolved values are passed to the executor as _projections. fetched_sources, computed_values, and source_defs are not accessible here \u2014 sources run before those exist.",
|
|
6553
|
+
additionalProperties: { type: "string" }
|
|
6554
|
+
},
|
|
6555
|
+
optionalForCompletionGating: { type: "boolean", default: false, description: "When true this source does not gate card completion. Default false when absent, so source_defs are completion-gating by default." },
|
|
6551
6556
|
timeout: { type: "integer", minimum: 0, default: 12e4, description: "Executor/script timeout in ms. Default: 120 000 (2 min)." },
|
|
6552
6557
|
script: { type: "string", description: "Legacy direct-run: shell command executed when no .task-executor is registered. stdout is captured as the result." }
|
|
6553
6558
|
}
|
|
@@ -6573,6 +6578,7 @@ var live_cards_schema_default = {
|
|
|
6573
6578
|
"badge",
|
|
6574
6579
|
"text",
|
|
6575
6580
|
"markdown",
|
|
6581
|
+
"ref",
|
|
6576
6582
|
"custom",
|
|
6577
6583
|
"actions"
|
|
6578
6584
|
]
|
|
@@ -6667,7 +6673,7 @@ var live_cards_schema_default = {
|
|
|
6667
6673
|
}
|
|
6668
6674
|
},
|
|
6669
6675
|
title: "LiveCard",
|
|
6670
|
-
description: "A unified card node. Behavior depends on which sections are present (
|
|
6676
|
+
description: "A unified card node. Behavior depends on which sections are present (source_defs, compute, view, etc.)",
|
|
6671
6677
|
type: "object",
|
|
6672
6678
|
required: ["id"],
|
|
6673
6679
|
additionalProperties: false,
|
|
@@ -6710,22 +6716,22 @@ var live_cards_schema_default = {
|
|
|
6710
6716
|
},
|
|
6711
6717
|
llm_task_completion_inference: {
|
|
6712
6718
|
type: "object",
|
|
6713
|
-
description: "Runtime state written by the inference adapter (advanced/undocumented). Prefer the standard
|
|
6719
|
+
description: "Runtime state written by the inference adapter (advanced/undocumented). Prefer the standard source_defs \u2192 compute \u2192 provides pattern for LLM-based signals.",
|
|
6714
6720
|
properties: {
|
|
6715
6721
|
inferenceRequested: { type: "string", format: "date-time", description: "Timestamp when the latest inference request was initiated" },
|
|
6716
6722
|
inferenceCompletedAt: { type: "string", format: "date-time", description: "Timestamp when the latest inference request completed" },
|
|
6717
6723
|
isTaskCompleted: { type: "boolean", description: "Whether the task is considered complete by the adapter" },
|
|
6718
6724
|
reasoning: { type: "string", description: "Explanation of completion decision" },
|
|
6719
|
-
evidence: { type: "array", description: "Supporting evidence from
|
|
6725
|
+
evidence: { type: "array", description: "Supporting evidence from source_defs/compute" }
|
|
6720
6726
|
},
|
|
6721
6727
|
additionalProperties: true
|
|
6722
6728
|
}
|
|
6723
6729
|
},
|
|
6724
6730
|
additionalProperties: true
|
|
6725
6731
|
},
|
|
6726
|
-
|
|
6732
|
+
source_defs: {
|
|
6727
6733
|
type: "array",
|
|
6728
|
-
description: "Source entries. Each entry is passed verbatim to the board's .task-executor (registered via init --task-executor) as the --in JSON file. The executor fetches/generates the data and writes JSON to --out. If no executor is registered, the built-in executor runs the entry's 'cli' command directly. Sources gate completion by default. Set optionalForCompletionGating: true for enrichment-only
|
|
6734
|
+
description: "Source entries. Each entry is passed verbatim to the board's .task-executor (registered via init --task-executor) as the --in JSON file. The executor fetches/generates the data and writes JSON to --out. If no executor is registered, the built-in executor runs the entry's 'cli' command directly. Sources gate completion by default. Set optionalForCompletionGating: true for enrichment-only source_defs that should not block task-completed.",
|
|
6729
6735
|
items: { $ref: "#/definitions/source_def" }
|
|
6730
6736
|
},
|
|
6731
6737
|
compute: {
|
|
@@ -6743,8 +6749,8 @@ var live_cards_schema_default = {
|
|
|
6743
6749
|
// src/card-compute/schema-validator.ts
|
|
6744
6750
|
var import_ajv = __toESM(require_ajv());
|
|
6745
6751
|
var _compiled = null;
|
|
6746
|
-
var NAMESPACE_REFERENCE_RE = /\b(card_data|requires|fetched_sources|computed_values|
|
|
6747
|
-
var ROOT_PATH_NAMESPACE_RE = /^\s*(card_data|requires|fetched_sources|computed_values|
|
|
6752
|
+
var NAMESPACE_REFERENCE_RE = /\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g;
|
|
6753
|
+
var ROOT_PATH_NAMESPACE_RE = /^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;
|
|
6748
6754
|
function referencedNamespaces(expression) {
|
|
6749
6755
|
const namespaces = /* @__PURE__ */ new Set();
|
|
6750
6756
|
let match;
|
|
@@ -6809,22 +6815,22 @@ function validateLiveCardSchema(node) {
|
|
|
6809
6815
|
return `${path}: ${e.message ?? "unknown error"}`;
|
|
6810
6816
|
});
|
|
6811
6817
|
if (node && typeof node === "object" && !Array.isArray(node)) {
|
|
6812
|
-
const
|
|
6813
|
-
if (Array.isArray(
|
|
6818
|
+
const source_defs = node.source_defs;
|
|
6819
|
+
if (Array.isArray(source_defs)) {
|
|
6814
6820
|
const bindTos = /* @__PURE__ */ new Set();
|
|
6815
6821
|
const outputFiles = /* @__PURE__ */ new Set();
|
|
6816
|
-
|
|
6822
|
+
source_defs.forEach((src, i) => {
|
|
6817
6823
|
if (!src || typeof src !== "object" || Array.isArray(src)) return;
|
|
6818
6824
|
const s = src;
|
|
6819
6825
|
if (typeof s.bindTo === "string" && s.bindTo) {
|
|
6820
6826
|
if (bindTos.has(s.bindTo)) {
|
|
6821
|
-
errors.push(`/
|
|
6827
|
+
errors.push(`/source_defs/${i}/bindTo: bindTo "${s.bindTo}" must be unique across all source_defs`);
|
|
6822
6828
|
}
|
|
6823
6829
|
bindTos.add(s.bindTo);
|
|
6824
6830
|
}
|
|
6825
6831
|
if (typeof s.outputFile === "string" && s.outputFile) {
|
|
6826
6832
|
if (outputFiles.has(s.outputFile)) {
|
|
6827
|
-
errors.push(`/
|
|
6833
|
+
errors.push(`/source_defs/${i}/outputFile: outputFile "${s.outputFile}" must be unique across all source_defs`);
|
|
6828
6834
|
}
|
|
6829
6835
|
outputFiles.add(s.outputFile);
|
|
6830
6836
|
}
|
|
@@ -6854,10 +6860,48 @@ function validateLiveCardRuntimeExpressions(node) {
|
|
|
6854
6860
|
);
|
|
6855
6861
|
});
|
|
6856
6862
|
}
|
|
6863
|
+
const VALID_PROVIDES_SRC_NAMESPACES = /* @__PURE__ */ new Set([
|
|
6864
|
+
"card_data",
|
|
6865
|
+
"requires",
|
|
6866
|
+
"fetched_sources",
|
|
6867
|
+
"computed_values"
|
|
6868
|
+
]);
|
|
6869
|
+
const provides = asRecord.provides;
|
|
6870
|
+
if (Array.isArray(provides)) {
|
|
6871
|
+
provides.forEach((entry, i) => {
|
|
6872
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return;
|
|
6873
|
+
const ref = entry.ref;
|
|
6874
|
+
if (typeof ref !== "string" || ref.trim().length === 0) return;
|
|
6875
|
+
const rootNamespace = parseRootPathNamespace(ref);
|
|
6876
|
+
if (rootNamespace === null) {
|
|
6877
|
+
errors.push(`/provides/${i}/ref: path "${ref}" must start with a valid namespace (${[...VALID_PROVIDES_SRC_NAMESPACES].join(", ")})`);
|
|
6878
|
+
} else if (!VALID_PROVIDES_SRC_NAMESPACES.has(rootNamespace)) {
|
|
6879
|
+
errors.push(`/provides/${i}/ref: disallowed namespace "${rootNamespace}" in path "${ref}" (valid: ${[...VALID_PROVIDES_SRC_NAMESPACES].join(", ")})`);
|
|
6880
|
+
}
|
|
6881
|
+
});
|
|
6882
|
+
}
|
|
6857
6883
|
const view = asRecord.view;
|
|
6858
6884
|
if (view && typeof view === "object" && !Array.isArray(view)) {
|
|
6859
6885
|
walkViewPathReferences(view, "/view", errors);
|
|
6860
6886
|
}
|
|
6887
|
+
const VALID_PROJECTION_NAMESPACES = /* @__PURE__ */ new Set(["card_data", "requires"]);
|
|
6888
|
+
const source_defs = asRecord.source_defs;
|
|
6889
|
+
if (Array.isArray(source_defs)) {
|
|
6890
|
+
source_defs.forEach((srcDef, i) => {
|
|
6891
|
+
if (!srcDef || typeof srcDef !== "object" || Array.isArray(srcDef)) return;
|
|
6892
|
+
const projections = srcDef.projections;
|
|
6893
|
+
if (!projections || typeof projections !== "object" || Array.isArray(projections)) return;
|
|
6894
|
+
for (const [key, exprVal] of Object.entries(projections)) {
|
|
6895
|
+
if (typeof exprVal !== "string" || exprVal.trim().length === 0) continue;
|
|
6896
|
+
validateJsonataExprWithNamespaces(
|
|
6897
|
+
exprVal,
|
|
6898
|
+
`/source_defs/${i}/projections/${key}`,
|
|
6899
|
+
VALID_PROJECTION_NAMESPACES,
|
|
6900
|
+
errors
|
|
6901
|
+
);
|
|
6902
|
+
}
|
|
6903
|
+
});
|
|
6904
|
+
}
|
|
6861
6905
|
return { ok: errors.length === 0, errors };
|
|
6862
6906
|
}
|
|
6863
6907
|
function validateLiveCard(node) {
|
|
@@ -6931,6 +6975,7 @@ function resolve(node, path) {
|
|
|
6931
6975
|
var VALID_ELEMENT_KINDS = /* @__PURE__ */ new Set([
|
|
6932
6976
|
"metric",
|
|
6933
6977
|
"table",
|
|
6978
|
+
"editable-table",
|
|
6934
6979
|
"chart",
|
|
6935
6980
|
"form",
|
|
6936
6981
|
"filter",
|
|
@@ -6942,9 +6987,11 @@ var VALID_ELEMENT_KINDS = /* @__PURE__ */ new Set([
|
|
|
6942
6987
|
"badge",
|
|
6943
6988
|
"text",
|
|
6944
6989
|
"markdown",
|
|
6945
|
-
"
|
|
6990
|
+
"ref",
|
|
6991
|
+
"custom",
|
|
6992
|
+
"actions"
|
|
6946
6993
|
]);
|
|
6947
|
-
var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "card_data", "compute", "
|
|
6994
|
+
var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "card_data", "compute", "source_defs"]);
|
|
6948
6995
|
function validateNode(node) {
|
|
6949
6996
|
const errors = [];
|
|
6950
6997
|
if (!node || typeof node !== "object" || Array.isArray(node)) {
|
|
@@ -6970,15 +7017,15 @@ function validateNode(node) {
|
|
|
6970
7017
|
if (n.requires != null && !Array.isArray(n.requires)) errors.push("requires: must be an array of strings");
|
|
6971
7018
|
if (n.provides != null) {
|
|
6972
7019
|
if (!Array.isArray(n.provides)) {
|
|
6973
|
-
errors.push("provides: must be an array of { bindTo,
|
|
7020
|
+
errors.push("provides: must be an array of { bindTo, ref } bindings");
|
|
6974
7021
|
} else {
|
|
6975
7022
|
n.provides.forEach((p, i) => {
|
|
6976
7023
|
if (!p || typeof p !== "object" || Array.isArray(p)) {
|
|
6977
|
-
errors.push(`provides[${i}]: must be an object with bindTo and
|
|
7024
|
+
errors.push(`provides[${i}]: must be an object with bindTo and ref`);
|
|
6978
7025
|
} else {
|
|
6979
7026
|
const b = p;
|
|
6980
7027
|
if (typeof b.bindTo !== "string" || !b.bindTo) errors.push(`provides[${i}]: missing required "bindTo" string`);
|
|
6981
|
-
if (typeof b.
|
|
7028
|
+
if (typeof b.ref !== "string" || !b.ref) errors.push(`provides[${i}]: missing required "ref" string`);
|
|
6982
7029
|
}
|
|
6983
7030
|
});
|
|
6984
7031
|
}
|
|
@@ -6998,35 +7045,35 @@ function validateNode(node) {
|
|
|
6998
7045
|
});
|
|
6999
7046
|
}
|
|
7000
7047
|
}
|
|
7001
|
-
if (n.
|
|
7002
|
-
if (!Array.isArray(n.
|
|
7003
|
-
errors.push("
|
|
7048
|
+
if (n.source_defs != null) {
|
|
7049
|
+
if (!Array.isArray(n.source_defs)) {
|
|
7050
|
+
errors.push("source_defs: must be an array");
|
|
7004
7051
|
} else {
|
|
7005
7052
|
const bindTos = /* @__PURE__ */ new Set();
|
|
7006
7053
|
const outputFiles = /* @__PURE__ */ new Set();
|
|
7007
|
-
n.
|
|
7054
|
+
n.source_defs.forEach((src, i) => {
|
|
7008
7055
|
if (!src || typeof src !== "object" || Array.isArray(src)) {
|
|
7009
|
-
errors.push(`
|
|
7056
|
+
errors.push(`source_defs[${i}]: must be an object`);
|
|
7010
7057
|
} else {
|
|
7011
7058
|
const s = src;
|
|
7012
7059
|
if (typeof s.bindTo !== "string" || !s.bindTo) {
|
|
7013
|
-
errors.push(`
|
|
7060
|
+
errors.push(`source_defs[${i}]: missing required "bindTo" property`);
|
|
7014
7061
|
} else {
|
|
7015
7062
|
if (bindTos.has(s.bindTo)) {
|
|
7016
|
-
errors.push(`
|
|
7063
|
+
errors.push(`source_defs[${i}]: bindTo "${s.bindTo}" is not unique across source_defs`);
|
|
7017
7064
|
}
|
|
7018
7065
|
bindTos.add(s.bindTo);
|
|
7019
7066
|
}
|
|
7020
7067
|
if (typeof s.outputFile !== "string" || !s.outputFile) {
|
|
7021
|
-
errors.push(`
|
|
7068
|
+
errors.push(`source_defs[${i}]: missing required "outputFile" property`);
|
|
7022
7069
|
} else {
|
|
7023
7070
|
if (outputFiles.has(s.outputFile)) {
|
|
7024
|
-
errors.push(`
|
|
7071
|
+
errors.push(`source_defs[${i}]: outputFile "${s.outputFile}" is not unique across source_defs`);
|
|
7025
7072
|
}
|
|
7026
7073
|
outputFiles.add(s.outputFile);
|
|
7027
7074
|
}
|
|
7028
7075
|
if (s.optionalForCompletionGating != null && typeof s.optionalForCompletionGating !== "boolean") {
|
|
7029
|
-
errors.push(`
|
|
7076
|
+
errors.push(`source_defs[${i}]: optionalForCompletionGating must be a boolean`);
|
|
7030
7077
|
}
|
|
7031
7078
|
}
|
|
7032
7079
|
});
|
|
@@ -7061,14 +7108,29 @@ function validateNode(node) {
|
|
|
7061
7108
|
}
|
|
7062
7109
|
return { ok: errors.length === 0, errors };
|
|
7063
7110
|
}
|
|
7064
|
-
function enrichSources(
|
|
7065
|
-
if (!
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7111
|
+
async function enrichSources(source_defs, context) {
|
|
7112
|
+
if (!source_defs || source_defs.length === 0) return [];
|
|
7113
|
+
const evalCtx = {
|
|
7114
|
+
card_data: context.card_data ?? {},
|
|
7115
|
+
requires: context.requires ?? {}
|
|
7116
|
+
};
|
|
7117
|
+
return Promise.all(
|
|
7118
|
+
source_defs.map(async (src) => {
|
|
7119
|
+
const _projections = {};
|
|
7120
|
+
if (src.projections && typeof src.projections === "object" && !Array.isArray(src.projections)) {
|
|
7121
|
+
for (const [key, expr] of Object.entries(src.projections)) {
|
|
7122
|
+
if (typeof expr === "string" && expr.trim().length > 0) {
|
|
7123
|
+
try {
|
|
7124
|
+
_projections[key] = await jsonata2(expr).evaluate(evalCtx);
|
|
7125
|
+
} catch {
|
|
7126
|
+
_projections[key] = void 0;
|
|
7127
|
+
}
|
|
7128
|
+
}
|
|
7129
|
+
}
|
|
7130
|
+
}
|
|
7131
|
+
return { ...src, _projections };
|
|
7132
|
+
})
|
|
7133
|
+
);
|
|
7072
7134
|
}
|
|
7073
7135
|
var CardCompute = {
|
|
7074
7136
|
run,
|