yaml-flow 2.6.0 → 2.6.1
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/card-compute.js +100 -0
- package/dist/card-compute/index.cjs +132 -0
- package/dist/card-compute/index.cjs.map +1 -1
- package/dist/card-compute/index.d.cts +18 -1
- package/dist/card-compute/index.d.ts +18 -1
- package/dist/card-compute/index.js +132 -0
- package/dist/card-compute/index.js.map +1 -1
- package/dist/index.cjs +132 -0
- 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 +132 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/schema/live-cards.schema.json +246 -0
package/package.json
CHANGED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://nsreehari.github.io/boards/live-cards.schema.json",
|
|
4
|
+
"title": "LiveCards Node Schema",
|
|
5
|
+
"description": "Schema for Card and ExternalSource nodes in the LiveCards Board/Canvas engine",
|
|
6
|
+
|
|
7
|
+
"definitions": {
|
|
8
|
+
|
|
9
|
+
"bind_ref": {
|
|
10
|
+
"description": "A state path reference, e.g. 'state.raw_quotes' or 'state.compute_vars.total'",
|
|
11
|
+
"type": "string",
|
|
12
|
+
"pattern": "^state\\."
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
"bind_or_literal": {
|
|
16
|
+
"description": "A literal value or a bind reference object",
|
|
17
|
+
"oneOf": [
|
|
18
|
+
{ "type": "string" },
|
|
19
|
+
{ "type": "number" },
|
|
20
|
+
{ "type": "boolean" },
|
|
21
|
+
{ "type": "array" },
|
|
22
|
+
{ "type": "object",
|
|
23
|
+
"properties": { "bind": { "$ref": "#/definitions/bind_ref" } },
|
|
24
|
+
"required": ["bind"]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
"compute_expr": {
|
|
30
|
+
"description": "A declarative JSON compute expression",
|
|
31
|
+
"type": "object",
|
|
32
|
+
"required": ["fn"],
|
|
33
|
+
"properties": {
|
|
34
|
+
"fn": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "Function name from the built-in vocabulary",
|
|
37
|
+
"enum": [
|
|
38
|
+
"sum", "avg", "min", "max", "count", "first", "last",
|
|
39
|
+
"add", "sub", "mul", "div", "round", "abs", "mod",
|
|
40
|
+
"gt", "gte", "lt", "lte", "eq", "neq",
|
|
41
|
+
"if", "and", "or", "not",
|
|
42
|
+
"concat", "upper", "lower", "template",
|
|
43
|
+
"filter", "pluck", "map", "sort", "slice", "flat", "unique", "group",
|
|
44
|
+
"get", "default",
|
|
45
|
+
"now", "diff_days", "format_date"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"input": {
|
|
49
|
+
"description": "state.path, literal, array of inputs, or nested compute_expr",
|
|
50
|
+
"oneOf": [
|
|
51
|
+
{ "type": "string" },
|
|
52
|
+
{ "type": "number" },
|
|
53
|
+
{ "type": "boolean" },
|
|
54
|
+
{ "type": "array" },
|
|
55
|
+
{ "$ref": "#/definitions/compute_expr" }
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
"field": { "type": "string", "description": "For pluck/sum/group — the object key to extract" },
|
|
59
|
+
"where": { "$ref": "#/definitions/compute_expr", "description": "For filter — predicate expression ($ = current item)" },
|
|
60
|
+
"cond": { "$ref": "#/definitions/compute_expr", "description": "For if — condition expression" },
|
|
61
|
+
"then": { "description": "For if — value when cond is truthy" },
|
|
62
|
+
"else": { "description": "For if — value when cond is falsy" },
|
|
63
|
+
"format": { "type": "string", "description": "For format_date — date format string" }
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
"meta": {
|
|
68
|
+
"type": "object",
|
|
69
|
+
"properties": {
|
|
70
|
+
"title": { "type": "string" },
|
|
71
|
+
"tags": { "type": "array", "items": { "type": "string" } }
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
"data": {
|
|
76
|
+
"type": "object",
|
|
77
|
+
"properties": {
|
|
78
|
+
"requires": {
|
|
79
|
+
"type": "array",
|
|
80
|
+
"items": { "type": "string" },
|
|
81
|
+
"description": "IDs of upstream nodes this node depends on"
|
|
82
|
+
},
|
|
83
|
+
"provides": {
|
|
84
|
+
"type": "object",
|
|
85
|
+
"description": "Subset of state exposed downstream. Keys are published names, values are bind refs.",
|
|
86
|
+
"additionalProperties": { "$ref": "#/definitions/bind_or_literal" }
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
"source_def": {
|
|
92
|
+
"type": "object",
|
|
93
|
+
"required": ["kind", "bindTo"],
|
|
94
|
+
"properties": {
|
|
95
|
+
"kind": { "enum": ["api", "websocket", "static", "llm"] },
|
|
96
|
+
"bindTo": { "$ref": "#/definitions/bind_ref", "description": "state path to write fetched data into" },
|
|
97
|
+
"method": { "enum": ["GET", "POST", "PUT", "DELETE"], "default": "GET" },
|
|
98
|
+
"url_template": { "type": "string", "description": "URL with {{var}} placeholders" },
|
|
99
|
+
"headers": { "type": "object", "additionalProperties": { "$ref": "#/definitions/bind_or_literal" } },
|
|
100
|
+
"body_template": { "type": "object", "description": "Request body with {{var}} placeholders or bind refs" },
|
|
101
|
+
"template_vars": {
|
|
102
|
+
"type": "object",
|
|
103
|
+
"additionalProperties": { "$ref": "#/definitions/bind_or_literal" },
|
|
104
|
+
"description": "Variables for url/body templates — static values or bind refs"
|
|
105
|
+
},
|
|
106
|
+
"poll_interval": { "type": "integer", "minimum": 0, "description": "Auto-refresh in seconds (0 = manual)" },
|
|
107
|
+
"transform": { "type": "string", "description": "Dot-path to extract from response, e.g. 'data.items'" }
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
"render_element": {
|
|
112
|
+
"type": "object",
|
|
113
|
+
"required": ["kind"],
|
|
114
|
+
"properties": {
|
|
115
|
+
"id": { "type": "string", "description": "Optional element ID for targeted updates" },
|
|
116
|
+
"kind": {
|
|
117
|
+
"enum": ["metric", "table", "chart", "form", "filter", "list",
|
|
118
|
+
"notes", "todo", "alert", "narrative", "badge", "text",
|
|
119
|
+
"markdown", "custom"]
|
|
120
|
+
},
|
|
121
|
+
"label": { "type": "string", "description": "Heading above this element" },
|
|
122
|
+
"className": { "type": "string", "description": "Bootstrap grid class, e.g. 'col-12 col-md-6'" },
|
|
123
|
+
"visible": { "type": "string", "description": "state path — element shown only if truthy" },
|
|
124
|
+
"data": {
|
|
125
|
+
"type": "object",
|
|
126
|
+
"properties": {
|
|
127
|
+
"bind": { "$ref": "#/definitions/bind_ref", "description": "state path to read data from" },
|
|
128
|
+
"writeTo": { "$ref": "#/definitions/bind_ref", "description": "state path for user input (form, filter, todo, notes)" },
|
|
129
|
+
"columns": { "type": "array", "items": { "type": "string" }, "description": "table: visible columns" },
|
|
130
|
+
"maxRows": { "type": "integer", "description": "table/list: max rows to display" },
|
|
131
|
+
"sortable": { "type": "boolean", "default": true, "description": "table: enable click-to-sort" },
|
|
132
|
+
"placeholder": { "type": "string", "description": "Empty-state message" },
|
|
133
|
+
"chartType": { "enum": ["bar", "line", "pie", "doughnut"] },
|
|
134
|
+
"chartOptions": { "type": "object", "description": "Chart.js options passthrough" },
|
|
135
|
+
"fields": { "type": "object", "description": "JSON Schema for form/filter fields" },
|
|
136
|
+
"thresholds": {
|
|
137
|
+
"type": "object",
|
|
138
|
+
"properties": {
|
|
139
|
+
"green": { "type": "string" },
|
|
140
|
+
"amber": { "type": "string" }
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
"colorMap": { "type": "object", "description": "badge: value → Bootstrap color" },
|
|
144
|
+
"style": { "enum": ["heading", "muted", "default"], "description": "text: display style" }
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
"view": {
|
|
151
|
+
"type": "object",
|
|
152
|
+
"required": ["elements"],
|
|
153
|
+
"properties": {
|
|
154
|
+
"elements": {
|
|
155
|
+
"type": "array",
|
|
156
|
+
"minItems": 1,
|
|
157
|
+
"items": { "$ref": "#/definitions/render_element" }
|
|
158
|
+
},
|
|
159
|
+
"layout": {
|
|
160
|
+
"type": "object",
|
|
161
|
+
"properties": {
|
|
162
|
+
"board": {
|
|
163
|
+
"type": "object",
|
|
164
|
+
"properties": {
|
|
165
|
+
"col": { "type": "integer", "minimum": 1, "maximum": 12 },
|
|
166
|
+
"order": { "type": "integer" }
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
"canvas": {
|
|
170
|
+
"type": "object",
|
|
171
|
+
"properties": {
|
|
172
|
+
"x": { "type": "number" },
|
|
173
|
+
"y": { "type": "number" },
|
|
174
|
+
"w": { "type": "number" },
|
|
175
|
+
"h": { "type": "number" }
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
"features": {
|
|
181
|
+
"type": "object",
|
|
182
|
+
"properties": {
|
|
183
|
+
"chat": { "type": "boolean", "default": false },
|
|
184
|
+
"notes": { "type": "boolean", "default": false },
|
|
185
|
+
"refresh": { "type": "boolean", "default": true }
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
"oneOf": [
|
|
193
|
+
{
|
|
194
|
+
"title": "Card",
|
|
195
|
+
"description": "A renderable card node with view elements",
|
|
196
|
+
"type": "object",
|
|
197
|
+
"required": ["id", "type", "view", "state"],
|
|
198
|
+
"additionalProperties": false,
|
|
199
|
+
"properties": {
|
|
200
|
+
"id": { "type": "string" },
|
|
201
|
+
"type": { "const": "card" },
|
|
202
|
+
"meta": { "$ref": "#/definitions/meta" },
|
|
203
|
+
"data": { "$ref": "#/definitions/data" },
|
|
204
|
+
"view": { "$ref": "#/definitions/view" },
|
|
205
|
+
"state": { "type": "object", "additionalProperties": true,
|
|
206
|
+
"properties": {
|
|
207
|
+
"status": { "enum": ["fresh", "stale", "loading", "error"] },
|
|
208
|
+
"lastRun": { "type": "string", "format": "date-time" },
|
|
209
|
+
"error": { "type": "string" }
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
"compute": {
|
|
213
|
+
"type": "object",
|
|
214
|
+
"description": "Derived state: key = state path to write, value = compute_expr",
|
|
215
|
+
"additionalProperties": { "$ref": "#/definitions/compute_expr" }
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"title": "ExternalSource",
|
|
221
|
+
"description": "A data-only node that fetches from external systems (no view)",
|
|
222
|
+
"type": "object",
|
|
223
|
+
"required": ["id", "type", "source", "state"],
|
|
224
|
+
"additionalProperties": false,
|
|
225
|
+
"properties": {
|
|
226
|
+
"id": { "type": "string" },
|
|
227
|
+
"type": { "const": "source" },
|
|
228
|
+
"meta": { "$ref": "#/definitions/meta" },
|
|
229
|
+
"data": { "$ref": "#/definitions/data" },
|
|
230
|
+
"source": { "$ref": "#/definitions/source_def" },
|
|
231
|
+
"state": { "type": "object", "additionalProperties": true,
|
|
232
|
+
"properties": {
|
|
233
|
+
"status": { "enum": ["fresh", "stale", "loading", "error"] },
|
|
234
|
+
"lastRun": { "type": "string", "format": "date-time" },
|
|
235
|
+
"error": { "type": "string" }
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
"compute": {
|
|
239
|
+
"type": "object",
|
|
240
|
+
"description": "Derived state: key = state path to write, value = compute_expr",
|
|
241
|
+
"additionalProperties": { "$ref": "#/definitions/compute_expr" }
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
]
|
|
246
|
+
}
|