yaml-flow 5.2.5 → 5.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/board-livecards-server-runtime.js +260 -35
- package/browser/board-livegraph-engine.js +57 -32
- package/browser/board-livegraph-engine.js.map +1 -1
- package/browser/card-compute.js +17 -17
- package/browser/live-cards.js +139 -12
- package/browser/live-cards.schema.json +14 -9
- package/dist/board-livegraph-runtime/index.cjs +57 -32
- 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 +57 -32
- package/dist/board-livegraph-runtime/index.js.map +1 -1
- package/dist/card-compute/index.cjs +96 -38
- 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 +96 -38
- package/dist/card-compute/index.js.map +1 -1
- package/dist/cli/board-live-cards-cli.cjs +7200 -201
- 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 +7199 -201
- package/dist/cli/board-live-cards-cli.js.map +1 -1
- package/dist/continuous-event-graph/index.cjs +55 -30
- 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 +55 -30
- package/dist/continuous-event-graph/index.js.map +1 -1
- package/dist/index.cjs +121 -53
- 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 +121 -53
- 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 +1 -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 +57 -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 +79 -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 +436 -246
- package/examples/example-board/scripts/copilot_wrapper.bat +157 -0
- package/examples/example-board/scripts/copilot_wrapper_helper.ps1 +190 -0
- 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 +14 -9
|
@@ -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
|
}
|
|
@@ -6667,7 +6672,7 @@ var live_cards_schema_default = {
|
|
|
6667
6672
|
}
|
|
6668
6673
|
},
|
|
6669
6674
|
title: "LiveCard",
|
|
6670
|
-
description: "A unified card node. Behavior depends on which sections are present (
|
|
6675
|
+
description: "A unified card node. Behavior depends on which sections are present (source_defs, compute, view, etc.)",
|
|
6671
6676
|
type: "object",
|
|
6672
6677
|
required: ["id"],
|
|
6673
6678
|
additionalProperties: false,
|
|
@@ -6710,22 +6715,22 @@ var live_cards_schema_default = {
|
|
|
6710
6715
|
},
|
|
6711
6716
|
llm_task_completion_inference: {
|
|
6712
6717
|
type: "object",
|
|
6713
|
-
description: "Runtime state written by the inference adapter (advanced/undocumented). Prefer the standard
|
|
6718
|
+
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
6719
|
properties: {
|
|
6715
6720
|
inferenceRequested: { type: "string", format: "date-time", description: "Timestamp when the latest inference request was initiated" },
|
|
6716
6721
|
inferenceCompletedAt: { type: "string", format: "date-time", description: "Timestamp when the latest inference request completed" },
|
|
6717
6722
|
isTaskCompleted: { type: "boolean", description: "Whether the task is considered complete by the adapter" },
|
|
6718
6723
|
reasoning: { type: "string", description: "Explanation of completion decision" },
|
|
6719
|
-
evidence: { type: "array", description: "Supporting evidence from
|
|
6724
|
+
evidence: { type: "array", description: "Supporting evidence from source_defs/compute" }
|
|
6720
6725
|
},
|
|
6721
6726
|
additionalProperties: true
|
|
6722
6727
|
}
|
|
6723
6728
|
},
|
|
6724
6729
|
additionalProperties: true
|
|
6725
6730
|
},
|
|
6726
|
-
|
|
6731
|
+
source_defs: {
|
|
6727
6732
|
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
|
|
6733
|
+
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
6734
|
items: { $ref: "#/definitions/source_def" }
|
|
6730
6735
|
},
|
|
6731
6736
|
compute: {
|
|
@@ -6743,8 +6748,8 @@ var live_cards_schema_default = {
|
|
|
6743
6748
|
// src/card-compute/schema-validator.ts
|
|
6744
6749
|
var import_ajv = __toESM(require_ajv());
|
|
6745
6750
|
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|
|
|
6751
|
+
var NAMESPACE_REFERENCE_RE = /\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g;
|
|
6752
|
+
var ROOT_PATH_NAMESPACE_RE = /^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;
|
|
6748
6753
|
function referencedNamespaces(expression) {
|
|
6749
6754
|
const namespaces = /* @__PURE__ */ new Set();
|
|
6750
6755
|
let match;
|
|
@@ -6809,22 +6814,22 @@ function validateLiveCardSchema(node) {
|
|
|
6809
6814
|
return `${path}: ${e.message ?? "unknown error"}`;
|
|
6810
6815
|
});
|
|
6811
6816
|
if (node && typeof node === "object" && !Array.isArray(node)) {
|
|
6812
|
-
const
|
|
6813
|
-
if (Array.isArray(
|
|
6817
|
+
const source_defs = node.source_defs;
|
|
6818
|
+
if (Array.isArray(source_defs)) {
|
|
6814
6819
|
const bindTos = /* @__PURE__ */ new Set();
|
|
6815
6820
|
const outputFiles = /* @__PURE__ */ new Set();
|
|
6816
|
-
|
|
6821
|
+
source_defs.forEach((src, i) => {
|
|
6817
6822
|
if (!src || typeof src !== "object" || Array.isArray(src)) return;
|
|
6818
6823
|
const s = src;
|
|
6819
6824
|
if (typeof s.bindTo === "string" && s.bindTo) {
|
|
6820
6825
|
if (bindTos.has(s.bindTo)) {
|
|
6821
|
-
errors.push(`/
|
|
6826
|
+
errors.push(`/source_defs/${i}/bindTo: bindTo "${s.bindTo}" must be unique across all source_defs`);
|
|
6822
6827
|
}
|
|
6823
6828
|
bindTos.add(s.bindTo);
|
|
6824
6829
|
}
|
|
6825
6830
|
if (typeof s.outputFile === "string" && s.outputFile) {
|
|
6826
6831
|
if (outputFiles.has(s.outputFile)) {
|
|
6827
|
-
errors.push(`/
|
|
6832
|
+
errors.push(`/source_defs/${i}/outputFile: outputFile "${s.outputFile}" must be unique across all source_defs`);
|
|
6828
6833
|
}
|
|
6829
6834
|
outputFiles.add(s.outputFile);
|
|
6830
6835
|
}
|
|
@@ -6854,10 +6859,48 @@ function validateLiveCardRuntimeExpressions(node) {
|
|
|
6854
6859
|
);
|
|
6855
6860
|
});
|
|
6856
6861
|
}
|
|
6862
|
+
const VALID_PROVIDES_SRC_NAMESPACES = /* @__PURE__ */ new Set([
|
|
6863
|
+
"card_data",
|
|
6864
|
+
"requires",
|
|
6865
|
+
"fetched_sources",
|
|
6866
|
+
"computed_values"
|
|
6867
|
+
]);
|
|
6868
|
+
const provides = asRecord.provides;
|
|
6869
|
+
if (Array.isArray(provides)) {
|
|
6870
|
+
provides.forEach((entry, i) => {
|
|
6871
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return;
|
|
6872
|
+
const ref = entry.ref;
|
|
6873
|
+
if (typeof ref !== "string" || ref.trim().length === 0) return;
|
|
6874
|
+
const rootNamespace = parseRootPathNamespace(ref);
|
|
6875
|
+
if (rootNamespace === null) {
|
|
6876
|
+
errors.push(`/provides/${i}/ref: path "${ref}" must start with a valid namespace (${[...VALID_PROVIDES_SRC_NAMESPACES].join(", ")})`);
|
|
6877
|
+
} else if (!VALID_PROVIDES_SRC_NAMESPACES.has(rootNamespace)) {
|
|
6878
|
+
errors.push(`/provides/${i}/ref: disallowed namespace "${rootNamespace}" in path "${ref}" (valid: ${[...VALID_PROVIDES_SRC_NAMESPACES].join(", ")})`);
|
|
6879
|
+
}
|
|
6880
|
+
});
|
|
6881
|
+
}
|
|
6857
6882
|
const view = asRecord.view;
|
|
6858
6883
|
if (view && typeof view === "object" && !Array.isArray(view)) {
|
|
6859
6884
|
walkViewPathReferences(view, "/view", errors);
|
|
6860
6885
|
}
|
|
6886
|
+
const VALID_PROJECTION_NAMESPACES = /* @__PURE__ */ new Set(["card_data", "requires"]);
|
|
6887
|
+
const source_defs = asRecord.source_defs;
|
|
6888
|
+
if (Array.isArray(source_defs)) {
|
|
6889
|
+
source_defs.forEach((srcDef, i) => {
|
|
6890
|
+
if (!srcDef || typeof srcDef !== "object" || Array.isArray(srcDef)) return;
|
|
6891
|
+
const projections = srcDef.projections;
|
|
6892
|
+
if (!projections || typeof projections !== "object" || Array.isArray(projections)) return;
|
|
6893
|
+
for (const [key, exprVal] of Object.entries(projections)) {
|
|
6894
|
+
if (typeof exprVal !== "string" || exprVal.trim().length === 0) continue;
|
|
6895
|
+
validateJsonataExprWithNamespaces(
|
|
6896
|
+
exprVal,
|
|
6897
|
+
`/source_defs/${i}/projections/${key}`,
|
|
6898
|
+
VALID_PROJECTION_NAMESPACES,
|
|
6899
|
+
errors
|
|
6900
|
+
);
|
|
6901
|
+
}
|
|
6902
|
+
});
|
|
6903
|
+
}
|
|
6861
6904
|
return { ok: errors.length === 0, errors };
|
|
6862
6905
|
}
|
|
6863
6906
|
function validateLiveCard(node) {
|
|
@@ -6944,7 +6987,7 @@ var VALID_ELEMENT_KINDS = /* @__PURE__ */ new Set([
|
|
|
6944
6987
|
"markdown",
|
|
6945
6988
|
"custom"
|
|
6946
6989
|
]);
|
|
6947
|
-
var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "card_data", "compute", "
|
|
6990
|
+
var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "card_data", "compute", "source_defs"]);
|
|
6948
6991
|
function validateNode(node) {
|
|
6949
6992
|
const errors = [];
|
|
6950
6993
|
if (!node || typeof node !== "object" || Array.isArray(node)) {
|
|
@@ -6970,15 +7013,15 @@ function validateNode(node) {
|
|
|
6970
7013
|
if (n.requires != null && !Array.isArray(n.requires)) errors.push("requires: must be an array of strings");
|
|
6971
7014
|
if (n.provides != null) {
|
|
6972
7015
|
if (!Array.isArray(n.provides)) {
|
|
6973
|
-
errors.push("provides: must be an array of { bindTo,
|
|
7016
|
+
errors.push("provides: must be an array of { bindTo, ref } bindings");
|
|
6974
7017
|
} else {
|
|
6975
7018
|
n.provides.forEach((p, i) => {
|
|
6976
7019
|
if (!p || typeof p !== "object" || Array.isArray(p)) {
|
|
6977
|
-
errors.push(`provides[${i}]: must be an object with bindTo and
|
|
7020
|
+
errors.push(`provides[${i}]: must be an object with bindTo and ref`);
|
|
6978
7021
|
} else {
|
|
6979
7022
|
const b = p;
|
|
6980
7023
|
if (typeof b.bindTo !== "string" || !b.bindTo) errors.push(`provides[${i}]: missing required "bindTo" string`);
|
|
6981
|
-
if (typeof b.
|
|
7024
|
+
if (typeof b.ref !== "string" || !b.ref) errors.push(`provides[${i}]: missing required "ref" string`);
|
|
6982
7025
|
}
|
|
6983
7026
|
});
|
|
6984
7027
|
}
|
|
@@ -6998,35 +7041,35 @@ function validateNode(node) {
|
|
|
6998
7041
|
});
|
|
6999
7042
|
}
|
|
7000
7043
|
}
|
|
7001
|
-
if (n.
|
|
7002
|
-
if (!Array.isArray(n.
|
|
7003
|
-
errors.push("
|
|
7044
|
+
if (n.source_defs != null) {
|
|
7045
|
+
if (!Array.isArray(n.source_defs)) {
|
|
7046
|
+
errors.push("source_defs: must be an array");
|
|
7004
7047
|
} else {
|
|
7005
7048
|
const bindTos = /* @__PURE__ */ new Set();
|
|
7006
7049
|
const outputFiles = /* @__PURE__ */ new Set();
|
|
7007
|
-
n.
|
|
7050
|
+
n.source_defs.forEach((src, i) => {
|
|
7008
7051
|
if (!src || typeof src !== "object" || Array.isArray(src)) {
|
|
7009
|
-
errors.push(`
|
|
7052
|
+
errors.push(`source_defs[${i}]: must be an object`);
|
|
7010
7053
|
} else {
|
|
7011
7054
|
const s = src;
|
|
7012
7055
|
if (typeof s.bindTo !== "string" || !s.bindTo) {
|
|
7013
|
-
errors.push(`
|
|
7056
|
+
errors.push(`source_defs[${i}]: missing required "bindTo" property`);
|
|
7014
7057
|
} else {
|
|
7015
7058
|
if (bindTos.has(s.bindTo)) {
|
|
7016
|
-
errors.push(`
|
|
7059
|
+
errors.push(`source_defs[${i}]: bindTo "${s.bindTo}" is not unique across source_defs`);
|
|
7017
7060
|
}
|
|
7018
7061
|
bindTos.add(s.bindTo);
|
|
7019
7062
|
}
|
|
7020
7063
|
if (typeof s.outputFile !== "string" || !s.outputFile) {
|
|
7021
|
-
errors.push(`
|
|
7064
|
+
errors.push(`source_defs[${i}]: missing required "outputFile" property`);
|
|
7022
7065
|
} else {
|
|
7023
7066
|
if (outputFiles.has(s.outputFile)) {
|
|
7024
|
-
errors.push(`
|
|
7067
|
+
errors.push(`source_defs[${i}]: outputFile "${s.outputFile}" is not unique across source_defs`);
|
|
7025
7068
|
}
|
|
7026
7069
|
outputFiles.add(s.outputFile);
|
|
7027
7070
|
}
|
|
7028
7071
|
if (s.optionalForCompletionGating != null && typeof s.optionalForCompletionGating !== "boolean") {
|
|
7029
|
-
errors.push(`
|
|
7072
|
+
errors.push(`source_defs[${i}]: optionalForCompletionGating must be a boolean`);
|
|
7030
7073
|
}
|
|
7031
7074
|
}
|
|
7032
7075
|
});
|
|
@@ -7061,14 +7104,29 @@ function validateNode(node) {
|
|
|
7061
7104
|
}
|
|
7062
7105
|
return { ok: errors.length === 0, errors };
|
|
7063
7106
|
}
|
|
7064
|
-
function enrichSources(
|
|
7065
|
-
if (!
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7107
|
+
async function enrichSources(source_defs, context) {
|
|
7108
|
+
if (!source_defs || source_defs.length === 0) return [];
|
|
7109
|
+
const evalCtx = {
|
|
7110
|
+
card_data: context.card_data ?? {},
|
|
7111
|
+
requires: context.requires ?? {}
|
|
7112
|
+
};
|
|
7113
|
+
return Promise.all(
|
|
7114
|
+
source_defs.map(async (src) => {
|
|
7115
|
+
const _projections = {};
|
|
7116
|
+
if (src.projections && typeof src.projections === "object" && !Array.isArray(src.projections)) {
|
|
7117
|
+
for (const [key, expr] of Object.entries(src.projections)) {
|
|
7118
|
+
if (typeof expr === "string" && expr.trim().length > 0) {
|
|
7119
|
+
try {
|
|
7120
|
+
_projections[key] = await jsonata2(expr).evaluate(evalCtx);
|
|
7121
|
+
} catch {
|
|
7122
|
+
_projections[key] = void 0;
|
|
7123
|
+
}
|
|
7124
|
+
}
|
|
7125
|
+
}
|
|
7126
|
+
}
|
|
7127
|
+
return { ...src, _projections };
|
|
7128
|
+
})
|
|
7129
|
+
);
|
|
7072
7130
|
}
|
|
7073
7131
|
var CardCompute = {
|
|
7074
7132
|
run,
|