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
|
@@ -20,6 +20,17 @@
|
|
|
20
20
|
* Returns the same `ValidationResult` shape as `CardCompute.validate()`.
|
|
21
21
|
*/
|
|
22
22
|
declare function validateLiveCardSchema(node: unknown): ValidationResult;
|
|
23
|
+
/**
|
|
24
|
+
* Validate JSONata expressions in compute[] by compiling with the same parser used at runtime.
|
|
25
|
+
*/
|
|
26
|
+
declare function validateLiveCardRuntimeExpressions(node: unknown): ValidationResult;
|
|
27
|
+
declare function validateLiveCard(node: unknown): ValidationResult;
|
|
28
|
+
/**
|
|
29
|
+
* Full validation for live card definitions:
|
|
30
|
+
* 1) JSON Schema structure/contract checks
|
|
31
|
+
* 2) Runtime JSONata parser compatibility checks for compute expressions
|
|
32
|
+
*/
|
|
33
|
+
declare function validateLiveCardDefinition(node: unknown): ValidationResult;
|
|
23
34
|
|
|
24
35
|
/**
|
|
25
36
|
* card-compute — JSONata-powered compute engine for LiveCards nodes.
|
|
@@ -33,10 +44,10 @@ declare function validateLiveCardSchema(node: unknown): ValidationResult;
|
|
|
33
44
|
*
|
|
34
45
|
* const node = {
|
|
35
46
|
* id: 'sales',
|
|
36
|
-
*
|
|
47
|
+
* card_data: { data: [{ revenue: 100 }, { revenue: 200 }] },
|
|
37
48
|
* compute: [
|
|
38
|
-
* { bindTo: 'total', expr: '$sum(
|
|
39
|
-
* { bindTo: 'avg', expr: '$average(
|
|
49
|
+
* { bindTo: 'total', expr: '$sum(card_data.data.revenue)' },
|
|
50
|
+
* { bindTo: 'avg', expr: '$average(card_data.data.revenue)' },
|
|
40
51
|
* ],
|
|
41
52
|
* };
|
|
42
53
|
* await CardCompute.run(node);
|
|
@@ -44,10 +55,10 @@ declare function validateLiveCardSchema(node: unknown): ValidationResult;
|
|
|
44
55
|
* // node.computed_values.avg === 150
|
|
45
56
|
* ```
|
|
46
57
|
*
|
|
47
|
-
* Expressions are evaluated against {
|
|
58
|
+
* Expressions are evaluated against { card_data, requires, fetched_sources, computed_values }.
|
|
48
59
|
* computed_values is ephemeral — never persisted to disk.
|
|
49
60
|
*/
|
|
50
|
-
/** A source definition: cli writes to outputFile; bindTo names the
|
|
61
|
+
/** A source definition: cli writes to outputFile; bindTo names the fetched_sources.* key in compute context. */
|
|
51
62
|
interface ComputeSource {
|
|
52
63
|
bindTo: string;
|
|
53
64
|
outputFile?: string;
|
|
@@ -58,7 +69,7 @@ interface ComputeSource {
|
|
|
58
69
|
}
|
|
59
70
|
/** Options for CardCompute.run() */
|
|
60
71
|
interface RunOptions {
|
|
61
|
-
/** Pre-loaded
|
|
72
|
+
/** Pre-loaded source results map (keyed by bindTo). Use in browser or when caller loads files. */
|
|
62
73
|
sourcesData?: Record<string, unknown>;
|
|
63
74
|
}
|
|
64
75
|
/** A single compute step: bindTo names the computed_values key; expr is a JSONata expression. */
|
|
@@ -69,7 +80,7 @@ interface ComputeStep {
|
|
|
69
80
|
/** Minimal node shape expected by CardCompute. */
|
|
70
81
|
interface ComputeNode {
|
|
71
82
|
id?: string;
|
|
72
|
-
|
|
83
|
+
card_data?: Record<string, unknown>;
|
|
73
84
|
requires?: Record<string, unknown>;
|
|
74
85
|
sources?: ComputeSource[];
|
|
75
86
|
compute?: ComputeStep[];
|
|
@@ -80,18 +91,18 @@ interface ComputeNode {
|
|
|
80
91
|
}
|
|
81
92
|
/**
|
|
82
93
|
* Run all compute steps on a node.
|
|
83
|
-
* Each step's expr is evaluated against {
|
|
94
|
+
* Each step's expr is evaluated against { card_data, requires, fetched_sources, computed_values }.
|
|
84
95
|
* Results are written to node.computed_values[bindTo].
|
|
85
96
|
* computed_values and _sourcesData are reset on each call — ephemeral, never persisted.
|
|
86
97
|
*
|
|
87
|
-
* @param options.sourcesData Pre-loaded map of { [bindTo]: data } for
|
|
98
|
+
* @param options.sourcesData Pre-loaded map of { [bindTo]: data } for fetched_sources namespace.
|
|
88
99
|
* In Node/CLI: loaded from outputFiles by the caller (card-handler).
|
|
89
100
|
* In browser: passed in by the caller (e.g. from fetch results).
|
|
90
101
|
*/
|
|
91
102
|
declare function run(node: ComputeNode, options?: RunOptions): Promise<ComputeNode>;
|
|
92
103
|
/**
|
|
93
104
|
* Evaluate a single JSONata expression against a node's context.
|
|
94
|
-
* Context is {
|
|
105
|
+
* Context is { card_data, requires, fetched_sources, computed_values }.
|
|
95
106
|
*/
|
|
96
107
|
declare function evalExpr(expr: string, node: ComputeNode): Promise<unknown>;
|
|
97
108
|
declare function resolve(node: ComputeNode, path: string): unknown;
|
|
@@ -101,11 +112,25 @@ interface ValidationResult {
|
|
|
101
112
|
errors: string[];
|
|
102
113
|
}
|
|
103
114
|
declare function validateNode(node: unknown): ValidationResult;
|
|
115
|
+
/**
|
|
116
|
+
* Enrich sources with execution context for template interpolation and prompt rendering.
|
|
117
|
+
* Pure function: no side effects, returns new enriched sources array.
|
|
118
|
+
*
|
|
119
|
+
* @param sources - Array of source definitions
|
|
120
|
+
* @param context - Execution context containing requires, sourcesData, computed_values
|
|
121
|
+
* @returns New array of sources with _requires, _sourcesData, _computed_values attached
|
|
122
|
+
*/
|
|
123
|
+
declare function enrichSources(sources: any[] | undefined, context: {
|
|
124
|
+
requires?: Record<string, any>;
|
|
125
|
+
sourcesData?: Record<string, any>;
|
|
126
|
+
computed_values?: Record<string, any>;
|
|
127
|
+
}): any[];
|
|
104
128
|
declare const CardCompute: {
|
|
105
129
|
run: typeof run;
|
|
106
130
|
eval: typeof evalExpr;
|
|
107
131
|
resolve: typeof resolve;
|
|
108
132
|
validate: typeof validateNode;
|
|
133
|
+
enrichSources: typeof enrichSources;
|
|
109
134
|
};
|
|
110
135
|
|
|
111
|
-
export { CardCompute, type ComputeNode, type ComputeSource, type ComputeStep, type RunOptions, type ValidationResult, CardCompute as default, validateLiveCardSchema };
|
|
136
|
+
export { CardCompute, type ComputeNode, type ComputeSource, type ComputeStep, type RunOptions, type ValidationResult, CardCompute as default, validateLiveCard, validateLiveCardDefinition, validateLiveCardRuntimeExpressions, validateLiveCardSchema };
|
|
@@ -20,6 +20,17 @@
|
|
|
20
20
|
* Returns the same `ValidationResult` shape as `CardCompute.validate()`.
|
|
21
21
|
*/
|
|
22
22
|
declare function validateLiveCardSchema(node: unknown): ValidationResult;
|
|
23
|
+
/**
|
|
24
|
+
* Validate JSONata expressions in compute[] by compiling with the same parser used at runtime.
|
|
25
|
+
*/
|
|
26
|
+
declare function validateLiveCardRuntimeExpressions(node: unknown): ValidationResult;
|
|
27
|
+
declare function validateLiveCard(node: unknown): ValidationResult;
|
|
28
|
+
/**
|
|
29
|
+
* Full validation for live card definitions:
|
|
30
|
+
* 1) JSON Schema structure/contract checks
|
|
31
|
+
* 2) Runtime JSONata parser compatibility checks for compute expressions
|
|
32
|
+
*/
|
|
33
|
+
declare function validateLiveCardDefinition(node: unknown): ValidationResult;
|
|
23
34
|
|
|
24
35
|
/**
|
|
25
36
|
* card-compute — JSONata-powered compute engine for LiveCards nodes.
|
|
@@ -33,10 +44,10 @@ declare function validateLiveCardSchema(node: unknown): ValidationResult;
|
|
|
33
44
|
*
|
|
34
45
|
* const node = {
|
|
35
46
|
* id: 'sales',
|
|
36
|
-
*
|
|
47
|
+
* card_data: { data: [{ revenue: 100 }, { revenue: 200 }] },
|
|
37
48
|
* compute: [
|
|
38
|
-
* { bindTo: 'total', expr: '$sum(
|
|
39
|
-
* { bindTo: 'avg', expr: '$average(
|
|
49
|
+
* { bindTo: 'total', expr: '$sum(card_data.data.revenue)' },
|
|
50
|
+
* { bindTo: 'avg', expr: '$average(card_data.data.revenue)' },
|
|
40
51
|
* ],
|
|
41
52
|
* };
|
|
42
53
|
* await CardCompute.run(node);
|
|
@@ -44,10 +55,10 @@ declare function validateLiveCardSchema(node: unknown): ValidationResult;
|
|
|
44
55
|
* // node.computed_values.avg === 150
|
|
45
56
|
* ```
|
|
46
57
|
*
|
|
47
|
-
* Expressions are evaluated against {
|
|
58
|
+
* Expressions are evaluated against { card_data, requires, fetched_sources, computed_values }.
|
|
48
59
|
* computed_values is ephemeral — never persisted to disk.
|
|
49
60
|
*/
|
|
50
|
-
/** A source definition: cli writes to outputFile; bindTo names the
|
|
61
|
+
/** A source definition: cli writes to outputFile; bindTo names the fetched_sources.* key in compute context. */
|
|
51
62
|
interface ComputeSource {
|
|
52
63
|
bindTo: string;
|
|
53
64
|
outputFile?: string;
|
|
@@ -58,7 +69,7 @@ interface ComputeSource {
|
|
|
58
69
|
}
|
|
59
70
|
/** Options for CardCompute.run() */
|
|
60
71
|
interface RunOptions {
|
|
61
|
-
/** Pre-loaded
|
|
72
|
+
/** Pre-loaded source results map (keyed by bindTo). Use in browser or when caller loads files. */
|
|
62
73
|
sourcesData?: Record<string, unknown>;
|
|
63
74
|
}
|
|
64
75
|
/** A single compute step: bindTo names the computed_values key; expr is a JSONata expression. */
|
|
@@ -69,7 +80,7 @@ interface ComputeStep {
|
|
|
69
80
|
/** Minimal node shape expected by CardCompute. */
|
|
70
81
|
interface ComputeNode {
|
|
71
82
|
id?: string;
|
|
72
|
-
|
|
83
|
+
card_data?: Record<string, unknown>;
|
|
73
84
|
requires?: Record<string, unknown>;
|
|
74
85
|
sources?: ComputeSource[];
|
|
75
86
|
compute?: ComputeStep[];
|
|
@@ -80,18 +91,18 @@ interface ComputeNode {
|
|
|
80
91
|
}
|
|
81
92
|
/**
|
|
82
93
|
* Run all compute steps on a node.
|
|
83
|
-
* Each step's expr is evaluated against {
|
|
94
|
+
* Each step's expr is evaluated against { card_data, requires, fetched_sources, computed_values }.
|
|
84
95
|
* Results are written to node.computed_values[bindTo].
|
|
85
96
|
* computed_values and _sourcesData are reset on each call — ephemeral, never persisted.
|
|
86
97
|
*
|
|
87
|
-
* @param options.sourcesData Pre-loaded map of { [bindTo]: data } for
|
|
98
|
+
* @param options.sourcesData Pre-loaded map of { [bindTo]: data } for fetched_sources namespace.
|
|
88
99
|
* In Node/CLI: loaded from outputFiles by the caller (card-handler).
|
|
89
100
|
* In browser: passed in by the caller (e.g. from fetch results).
|
|
90
101
|
*/
|
|
91
102
|
declare function run(node: ComputeNode, options?: RunOptions): Promise<ComputeNode>;
|
|
92
103
|
/**
|
|
93
104
|
* Evaluate a single JSONata expression against a node's context.
|
|
94
|
-
* Context is {
|
|
105
|
+
* Context is { card_data, requires, fetched_sources, computed_values }.
|
|
95
106
|
*/
|
|
96
107
|
declare function evalExpr(expr: string, node: ComputeNode): Promise<unknown>;
|
|
97
108
|
declare function resolve(node: ComputeNode, path: string): unknown;
|
|
@@ -101,11 +112,25 @@ interface ValidationResult {
|
|
|
101
112
|
errors: string[];
|
|
102
113
|
}
|
|
103
114
|
declare function validateNode(node: unknown): ValidationResult;
|
|
115
|
+
/**
|
|
116
|
+
* Enrich sources with execution context for template interpolation and prompt rendering.
|
|
117
|
+
* Pure function: no side effects, returns new enriched sources array.
|
|
118
|
+
*
|
|
119
|
+
* @param sources - Array of source definitions
|
|
120
|
+
* @param context - Execution context containing requires, sourcesData, computed_values
|
|
121
|
+
* @returns New array of sources with _requires, _sourcesData, _computed_values attached
|
|
122
|
+
*/
|
|
123
|
+
declare function enrichSources(sources: any[] | undefined, context: {
|
|
124
|
+
requires?: Record<string, any>;
|
|
125
|
+
sourcesData?: Record<string, any>;
|
|
126
|
+
computed_values?: Record<string, any>;
|
|
127
|
+
}): any[];
|
|
104
128
|
declare const CardCompute: {
|
|
105
129
|
run: typeof run;
|
|
106
130
|
eval: typeof evalExpr;
|
|
107
131
|
resolve: typeof resolve;
|
|
108
132
|
validate: typeof validateNode;
|
|
133
|
+
enrichSources: typeof enrichSources;
|
|
109
134
|
};
|
|
110
135
|
|
|
111
|
-
export { CardCompute, type ComputeNode, type ComputeSource, type ComputeStep, type RunOptions, type ValidationResult, CardCompute as default, validateLiveCardSchema };
|
|
136
|
+
export { CardCompute, type ComputeNode, type ComputeSource, type ComputeStep, type RunOptions, type ValidationResult, CardCompute as default, validateLiveCard, validateLiveCardDefinition, validateLiveCardRuntimeExpressions, validateLiveCardSchema };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import jsonata2 from 'jsonata';
|
|
2
2
|
import addFormats from 'ajv-formats';
|
|
3
3
|
|
|
4
4
|
var __create = Object.create;
|
|
@@ -6416,13 +6416,11 @@ var require_ajv = __commonJS({
|
|
|
6416
6416
|
var live_cards_schema_default = {
|
|
6417
6417
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
6418
6418
|
$id: "https://nsreehari.github.io/boards/live-cards.schema.json",
|
|
6419
|
-
title: "LiveCards Node Schema",
|
|
6420
|
-
description: "Schema for Card and ExternalSource nodes in the LiveCards Board/Canvas engine",
|
|
6421
6419
|
definitions: {
|
|
6422
6420
|
bind_ref: {
|
|
6423
|
-
description: "A
|
|
6421
|
+
description: "A card data path reference, e.g. 'card_data.raw_quotes' or 'requires.upstream'",
|
|
6424
6422
|
type: "string",
|
|
6425
|
-
pattern: "^(
|
|
6423
|
+
pattern: "^(card_data|requires|fetched_sources|computed_values)(\\.|$)"
|
|
6426
6424
|
},
|
|
6427
6425
|
bind_or_literal: {
|
|
6428
6426
|
description: "A literal value or a bind reference object",
|
|
@@ -6491,7 +6489,7 @@ var live_cards_schema_default = {
|
|
|
6491
6489
|
]
|
|
6492
6490
|
},
|
|
6493
6491
|
input: {
|
|
6494
|
-
description: "
|
|
6492
|
+
description: "card_data.path, literal, array of inputs, or nested compute_expr",
|
|
6495
6493
|
oneOf: [
|
|
6496
6494
|
{ type: "string" },
|
|
6497
6495
|
{ type: "number" },
|
|
@@ -6527,18 +6525,18 @@ var live_cards_schema_default = {
|
|
|
6527
6525
|
required: ["bindTo", "src"],
|
|
6528
6526
|
properties: {
|
|
6529
6527
|
bindTo: { type: "string", description: "Token name published downstream" },
|
|
6530
|
-
src: { type: "string", description: "Path to read value from (
|
|
6528
|
+
src: { type: "string", description: "Path to read value from (card_data.*, requires.*, fetched_sources.*, computed_values.*)" }
|
|
6531
6529
|
}
|
|
6532
6530
|
},
|
|
6533
|
-
description: "Explicit bindings exposing computed
|
|
6531
|
+
description: "Explicit bindings exposing computed or card_data values downstream as named tokens"
|
|
6534
6532
|
},
|
|
6535
6533
|
compute_step: {
|
|
6536
|
-
description: "A single ordered compute step: reads
|
|
6534
|
+
description: "A single ordered compute step: reads card_data.*/requires.*/computed_values.*, writes to computed_values[bindTo]",
|
|
6537
6535
|
type: "object",
|
|
6538
6536
|
required: ["bindTo", "expr"],
|
|
6539
6537
|
properties: {
|
|
6540
6538
|
bindTo: { type: "string", description: "Key in computed_values to write result" },
|
|
6541
|
-
expr: { type: "string", description: "JSONata expression evaluated against {
|
|
6539
|
+
expr: { type: "string", description: "JSONata expression evaluated against { card_data, requires, fetched_sources, computed_values }" }
|
|
6542
6540
|
}
|
|
6543
6541
|
},
|
|
6544
6542
|
source_def: {
|
|
@@ -6547,7 +6545,7 @@ var live_cards_schema_default = {
|
|
|
6547
6545
|
required: ["bindTo"],
|
|
6548
6546
|
additionalProperties: true,
|
|
6549
6547
|
properties: {
|
|
6550
|
-
bindTo: { type: "string", description: "Key under
|
|
6548
|
+
bindTo: { type: "string", description: "Key under fetched_sources.* available in compute expressions" },
|
|
6551
6549
|
outputFile: { type: "string", description: "Board-relative path the executor writes its JSON result to. Presence of this file signals delivery." },
|
|
6552
6550
|
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." },
|
|
6553
6551
|
timeout: { type: "integer", minimum: 0, default: 12e4, description: "Executor/script timeout in ms. Default: 120 000 (2 min)." },
|
|
@@ -6575,19 +6573,17 @@ var live_cards_schema_default = {
|
|
|
6575
6573
|
"text",
|
|
6576
6574
|
"markdown",
|
|
6577
6575
|
"custom",
|
|
6578
|
-
"file-upload",
|
|
6579
|
-
"chat",
|
|
6580
6576
|
"actions"
|
|
6581
6577
|
]
|
|
6582
6578
|
},
|
|
6583
6579
|
label: { type: "string", description: "Heading above this element" },
|
|
6584
6580
|
className: { type: "string", description: "Bootstrap grid class, e.g. 'col-12 col-md-6'" },
|
|
6585
|
-
visible: { type: "string", description: "
|
|
6581
|
+
visible: { type: "string", description: "card_data/requires/fetched_sources/computed_values path \u2014 element shown only if truthy" },
|
|
6586
6582
|
data: {
|
|
6587
6583
|
type: "object",
|
|
6588
6584
|
properties: {
|
|
6589
|
-
bind: { $ref: "#/definitions/bind_ref", description: "
|
|
6590
|
-
writeTo: { $ref: "#/definitions/bind_ref", description: "
|
|
6585
|
+
bind: { $ref: "#/definitions/bind_ref", description: "card_data/requires/fetched_sources/computed_values path to read data from" },
|
|
6586
|
+
writeTo: { $ref: "#/definitions/bind_ref", description: "card_data path for user input (form, filter, todo, notes)" },
|
|
6591
6587
|
columns: { type: "array", items: { type: "string" }, description: "table: visible columns" },
|
|
6592
6588
|
maxRows: { type: "integer", description: "table/list: max rows to display" },
|
|
6593
6589
|
sortable: { type: "boolean", default: true, description: "table: enable click-to-sort" },
|
|
@@ -6620,7 +6616,7 @@ var live_cards_schema_default = {
|
|
|
6620
6616
|
label: { type: "string" },
|
|
6621
6617
|
style: { type: "string", description: "Bootstrap button variant, e.g. 'success', 'outline-danger'" },
|
|
6622
6618
|
size: { type: "string", default: "sm" },
|
|
6623
|
-
disabled: { oneOf: [{ type: "boolean" }, { type: "string", description: "
|
|
6619
|
+
disabled: { oneOf: [{ type: "boolean" }, { type: "string", description: "card_data/requires/fetched_sources/computed_values path \u2014 truthy = disabled" }] }
|
|
6624
6620
|
}
|
|
6625
6621
|
}
|
|
6626
6622
|
}
|
|
@@ -6680,14 +6676,39 @@ var live_cards_schema_default = {
|
|
|
6680
6676
|
provides: { $ref: "#/definitions/provides" },
|
|
6681
6677
|
meta: { $ref: "#/definitions/meta" },
|
|
6682
6678
|
view: { $ref: "#/definitions/view" },
|
|
6683
|
-
|
|
6679
|
+
card_data: {
|
|
6684
6680
|
type: "object",
|
|
6685
|
-
|
|
6681
|
+
description: "Authored card data supplied in the card definition",
|
|
6686
6682
|
properties: {
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6683
|
+
files: {
|
|
6684
|
+
type: "array",
|
|
6685
|
+
description: "Optional uploaded-file metadata maintained by host handlers. Stored name is normalized and serial-prefixed (for example 001-my_file.pdf).",
|
|
6686
|
+
items: {
|
|
6687
|
+
type: "object",
|
|
6688
|
+
required: ["name", "stored_name"],
|
|
6689
|
+
properties: {
|
|
6690
|
+
name: { type: "string", minLength: 1 },
|
|
6691
|
+
stored_name: {
|
|
6692
|
+
type: "string",
|
|
6693
|
+
minLength: 5,
|
|
6694
|
+
maxLength: 32,
|
|
6695
|
+
pattern: "^[0-9]{3,}-[a-z0-9._-]+$"
|
|
6696
|
+
},
|
|
6697
|
+
size: {
|
|
6698
|
+
oneOf: [
|
|
6699
|
+
{ type: "integer", minimum: 0 },
|
|
6700
|
+
{ type: "null" }
|
|
6701
|
+
]
|
|
6702
|
+
},
|
|
6703
|
+
mime_type: { type: "string" },
|
|
6704
|
+
path: { type: "string", pattern: "^[^\\s]+/files/[0-9]{3,}-[a-z0-9._-]+$" },
|
|
6705
|
+
uploaded_at: { type: "string", format: "date-time" }
|
|
6706
|
+
},
|
|
6707
|
+
additionalProperties: false
|
|
6708
|
+
}
|
|
6709
|
+
}
|
|
6710
|
+
},
|
|
6711
|
+
additionalProperties: true
|
|
6691
6712
|
},
|
|
6692
6713
|
sources: {
|
|
6693
6714
|
type: "array",
|
|
@@ -6696,7 +6717,7 @@ var live_cards_schema_default = {
|
|
|
6696
6717
|
},
|
|
6697
6718
|
compute: {
|
|
6698
6719
|
type: "array",
|
|
6699
|
-
description: "Ordered array of compute steps. Each reads
|
|
6720
|
+
description: "Ordered array of compute steps. Each reads card_data.*/requires.*/fetched_sources.*/computed_values.* and writes to ephemeral computed_values[bindTo].",
|
|
6700
6721
|
items: { $ref: "#/definitions/compute_step" }
|
|
6701
6722
|
}
|
|
6702
6723
|
}
|
|
@@ -6705,6 +6726,57 @@ var live_cards_schema_default = {
|
|
|
6705
6726
|
// src/card-compute/schema-validator.ts
|
|
6706
6727
|
var import_ajv = __toESM(require_ajv());
|
|
6707
6728
|
var _compiled = null;
|
|
6729
|
+
var NAMESPACE_REFERENCE_RE = /\b(card_data|requires|fetched_sources|computed_values|sources)\b/g;
|
|
6730
|
+
var ROOT_PATH_NAMESPACE_RE = /^\s*(card_data|requires|fetched_sources|computed_values|sources)(\.|$)/;
|
|
6731
|
+
function referencedNamespaces(expression) {
|
|
6732
|
+
const namespaces = /* @__PURE__ */ new Set();
|
|
6733
|
+
let match;
|
|
6734
|
+
NAMESPACE_REFERENCE_RE.lastIndex = 0;
|
|
6735
|
+
while ((match = NAMESPACE_REFERENCE_RE.exec(expression)) !== null) {
|
|
6736
|
+
namespaces.add(match[1]);
|
|
6737
|
+
}
|
|
6738
|
+
return namespaces;
|
|
6739
|
+
}
|
|
6740
|
+
function parseRootPathNamespace(pathValue) {
|
|
6741
|
+
const match = ROOT_PATH_NAMESPACE_RE.exec(pathValue);
|
|
6742
|
+
return match ? match[1] : null;
|
|
6743
|
+
}
|
|
6744
|
+
function validateJsonataExprWithNamespaces(expr, path, allowedNamespaces, errors) {
|
|
6745
|
+
try {
|
|
6746
|
+
jsonata2(expr);
|
|
6747
|
+
} catch (err) {
|
|
6748
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
6749
|
+
errors.push(`${path}: invalid JSONata expression (${message})`);
|
|
6750
|
+
return;
|
|
6751
|
+
}
|
|
6752
|
+
const usedNamespaces = referencedNamespaces(expr);
|
|
6753
|
+
for (const namespace of usedNamespaces) {
|
|
6754
|
+
if (!allowedNamespaces.has(namespace)) {
|
|
6755
|
+
errors.push(`${path}: disallowed namespace "${namespace}" in expression`);
|
|
6756
|
+
}
|
|
6757
|
+
}
|
|
6758
|
+
}
|
|
6759
|
+
function walkViewPathReferences(value, path, errors) {
|
|
6760
|
+
if (Array.isArray(value)) {
|
|
6761
|
+
value.forEach((entry, index) => {
|
|
6762
|
+
walkViewPathReferences(entry, `${path}/${index}`, errors);
|
|
6763
|
+
});
|
|
6764
|
+
return;
|
|
6765
|
+
}
|
|
6766
|
+
if (typeof value === "string") {
|
|
6767
|
+
const rootNamespace = parseRootPathNamespace(value);
|
|
6768
|
+
if (!rootNamespace) return;
|
|
6769
|
+
if (!(/* @__PURE__ */ new Set(["card_data", "requires", "fetched_sources", "computed_values"])).has(rootNamespace)) {
|
|
6770
|
+
errors.push(`${path}: disallowed namespace "${rootNamespace}" in view reference`);
|
|
6771
|
+
}
|
|
6772
|
+
return;
|
|
6773
|
+
}
|
|
6774
|
+
if (!value || typeof value !== "object") return;
|
|
6775
|
+
const record = value;
|
|
6776
|
+
for (const [key, next] of Object.entries(record)) {
|
|
6777
|
+
walkViewPathReferences(next, `${path}/${key}`, errors);
|
|
6778
|
+
}
|
|
6779
|
+
}
|
|
6708
6780
|
function getValidator() {
|
|
6709
6781
|
if (_compiled) return _compiled;
|
|
6710
6782
|
const ajv = new import_ajv.default({ allErrors: true });
|
|
@@ -6722,6 +6794,42 @@ function validateLiveCardSchema(node) {
|
|
|
6722
6794
|
});
|
|
6723
6795
|
return { ok: false, errors };
|
|
6724
6796
|
}
|
|
6797
|
+
function validateLiveCardRuntimeExpressions(node) {
|
|
6798
|
+
const errors = [];
|
|
6799
|
+
if (!node || typeof node !== "object" || Array.isArray(node)) {
|
|
6800
|
+
return { ok: true, errors: [] };
|
|
6801
|
+
}
|
|
6802
|
+
const asRecord = node;
|
|
6803
|
+
const compute = asRecord.compute;
|
|
6804
|
+
if (Array.isArray(compute)) {
|
|
6805
|
+
compute.forEach((step, i) => {
|
|
6806
|
+
if (!step || typeof step !== "object" || Array.isArray(step)) return;
|
|
6807
|
+
const expr = step.expr;
|
|
6808
|
+
if (typeof expr !== "string" || expr.trim().length === 0) return;
|
|
6809
|
+
validateJsonataExprWithNamespaces(
|
|
6810
|
+
expr,
|
|
6811
|
+
`/compute/${i}/expr`,
|
|
6812
|
+
/* @__PURE__ */ new Set(["card_data", "requires", "fetched_sources", "computed_values"]),
|
|
6813
|
+
errors
|
|
6814
|
+
);
|
|
6815
|
+
});
|
|
6816
|
+
}
|
|
6817
|
+
const view = asRecord.view;
|
|
6818
|
+
if (view && typeof view === "object" && !Array.isArray(view)) {
|
|
6819
|
+
walkViewPathReferences(view, "/view", errors);
|
|
6820
|
+
}
|
|
6821
|
+
return { ok: errors.length === 0, errors };
|
|
6822
|
+
}
|
|
6823
|
+
function validateLiveCard(node) {
|
|
6824
|
+
return validateLiveCardDefinition(node);
|
|
6825
|
+
}
|
|
6826
|
+
function validateLiveCardDefinition(node) {
|
|
6827
|
+
const schema = validateLiveCardSchema(node);
|
|
6828
|
+
if (!schema.ok) return schema;
|
|
6829
|
+
const runtime = validateLiveCardRuntimeExpressions(node);
|
|
6830
|
+
if (!runtime.ok) return { ok: false, errors: runtime.errors };
|
|
6831
|
+
return { ok: true, errors: [] };
|
|
6832
|
+
}
|
|
6725
6833
|
|
|
6726
6834
|
// src/card-compute/index.ts
|
|
6727
6835
|
function deepGet(obj, path) {
|
|
@@ -6745,18 +6853,18 @@ function deepSet(obj, path, value) {
|
|
|
6745
6853
|
}
|
|
6746
6854
|
async function run(node, options) {
|
|
6747
6855
|
if (!node?.compute?.length) return node;
|
|
6748
|
-
if (!node.
|
|
6856
|
+
if (!node.card_data) node.card_data = {};
|
|
6749
6857
|
node.computed_values = {};
|
|
6750
6858
|
node._sourcesData = options?.sourcesData ?? {};
|
|
6751
6859
|
const ctx = {
|
|
6752
|
-
|
|
6860
|
+
card_data: node.card_data,
|
|
6753
6861
|
requires: node.requires ?? {},
|
|
6754
|
-
|
|
6862
|
+
fetched_sources: node._sourcesData,
|
|
6755
6863
|
computed_values: node.computed_values
|
|
6756
6864
|
};
|
|
6757
6865
|
for (const step of node.compute) {
|
|
6758
6866
|
try {
|
|
6759
|
-
const val = await
|
|
6867
|
+
const val = await jsonata2(step.expr).evaluate(ctx);
|
|
6760
6868
|
deepSet(node.computed_values, step.bindTo, val);
|
|
6761
6869
|
ctx.computed_values = node.computed_values;
|
|
6762
6870
|
} catch (err) {
|
|
@@ -6767,16 +6875,16 @@ async function run(node, options) {
|
|
|
6767
6875
|
}
|
|
6768
6876
|
async function evalExpr(expr, node) {
|
|
6769
6877
|
const ctx = {
|
|
6770
|
-
|
|
6878
|
+
card_data: node.card_data ?? {},
|
|
6771
6879
|
requires: node.requires ?? {},
|
|
6772
|
-
|
|
6880
|
+
fetched_sources: node._sourcesData ?? {},
|
|
6773
6881
|
computed_values: node.computed_values ?? {}
|
|
6774
6882
|
};
|
|
6775
|
-
return
|
|
6883
|
+
return jsonata2(expr).evaluate(ctx);
|
|
6776
6884
|
}
|
|
6777
6885
|
function resolve(node, path) {
|
|
6778
|
-
if (path.startsWith("
|
|
6779
|
-
return deepGet(node._sourcesData ?? {}, path.slice("
|
|
6886
|
+
if (path.startsWith("fetched_sources.")) {
|
|
6887
|
+
return deepGet(node._sourcesData ?? {}, path.slice("fetched_sources.".length));
|
|
6780
6888
|
}
|
|
6781
6889
|
return deepGet(node, path);
|
|
6782
6890
|
}
|
|
@@ -6796,8 +6904,7 @@ var VALID_ELEMENT_KINDS = /* @__PURE__ */ new Set([
|
|
|
6796
6904
|
"markdown",
|
|
6797
6905
|
"custom"
|
|
6798
6906
|
]);
|
|
6799
|
-
var
|
|
6800
|
-
var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "state", "compute", "sources"]);
|
|
6907
|
+
var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "card_data", "compute", "sources"]);
|
|
6801
6908
|
function validateNode(node) {
|
|
6802
6909
|
const errors = [];
|
|
6803
6910
|
if (!node || typeof node !== "object" || Array.isArray(node)) {
|
|
@@ -6808,13 +6915,8 @@ function validateNode(node) {
|
|
|
6808
6915
|
for (const key of Object.keys(n)) {
|
|
6809
6916
|
if (!ALLOWED_KEYS.has(key)) errors.push(`Unknown top-level key: "${key}"`);
|
|
6810
6917
|
}
|
|
6811
|
-
if (n.
|
|
6812
|
-
errors.push("
|
|
6813
|
-
} else {
|
|
6814
|
-
const state = n.state;
|
|
6815
|
-
if (state.status != null && !VALID_STATUSES.has(state.status)) {
|
|
6816
|
-
errors.push(`state.status: must be one of: ${[...VALID_STATUSES].join(", ")}`);
|
|
6817
|
-
}
|
|
6918
|
+
if (n.card_data == null || typeof n.card_data !== "object" || Array.isArray(n.card_data)) {
|
|
6919
|
+
errors.push("card_data: required, must be an object");
|
|
6818
6920
|
}
|
|
6819
6921
|
if (n.meta != null) {
|
|
6820
6922
|
if (typeof n.meta !== "object" || Array.isArray(n.meta)) {
|
|
@@ -6903,14 +7005,24 @@ function validateNode(node) {
|
|
|
6903
7005
|
}
|
|
6904
7006
|
return { ok: errors.length === 0, errors };
|
|
6905
7007
|
}
|
|
7008
|
+
function enrichSources(sources, context) {
|
|
7009
|
+
if (!sources || sources.length === 0) return [];
|
|
7010
|
+
return sources.map((src) => ({
|
|
7011
|
+
...src,
|
|
7012
|
+
_requires: context.requires ?? {},
|
|
7013
|
+
_sourcesData: context.sourcesData ?? {},
|
|
7014
|
+
_computed_values: context.computed_values ?? {}
|
|
7015
|
+
}));
|
|
7016
|
+
}
|
|
6906
7017
|
var CardCompute = {
|
|
6907
7018
|
run,
|
|
6908
7019
|
eval: evalExpr,
|
|
6909
7020
|
resolve,
|
|
6910
|
-
validate: validateNode
|
|
7021
|
+
validate: validateNode,
|
|
7022
|
+
enrichSources
|
|
6911
7023
|
};
|
|
6912
7024
|
var card_compute_default = CardCompute;
|
|
6913
7025
|
|
|
6914
|
-
export { CardCompute, card_compute_default as default, validateLiveCardSchema };
|
|
7026
|
+
export { CardCompute, card_compute_default as default, validateLiveCard, validateLiveCardDefinition, validateLiveCardRuntimeExpressions, validateLiveCardSchema };
|
|
6915
7027
|
//# sourceMappingURL=index.js.map
|
|
6916
7028
|
//# sourceMappingURL=index.js.map
|