agent2dashboard 0.2.0__py3-none-any.whl

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.
Files changed (79) hide show
  1. agent2dashboard/__init__.py +593 -0
  2. agent2dashboard/__main__.py +3 -0
  3. agent2dashboard/_env.py +79 -0
  4. agent2dashboard/a2ui/__init__.py +1 -0
  5. agent2dashboard/a2ui/catalogs/dashboard/v1/catalog.json +496 -0
  6. agent2dashboard/a2ui/checks.py +656 -0
  7. agent2dashboard/a2ui/express.py +349 -0
  8. agent2dashboard/a2ui/layout_actions.py +409 -0
  9. agent2dashboard/a2ui/render.py +252 -0
  10. agent2dashboard/a2ui/state.py +600 -0
  11. agent2dashboard/a2ui/surfaces.py +23 -0
  12. agent2dashboard/agent/__init__.py +83 -0
  13. agent2dashboard/agent/builtin_tools.py +258 -0
  14. agent2dashboard/agent/history.py +218 -0
  15. agent2dashboard/agent/loop.py +341 -0
  16. agent2dashboard/agent/prompt.py +66 -0
  17. agent2dashboard/agent/tools.py +162 -0
  18. agent2dashboard/agent/turn.py +201 -0
  19. agent2dashboard/auth.py +350 -0
  20. agent2dashboard/cli/__init__.py +50 -0
  21. agent2dashboard/errors.py +18 -0
  22. agent2dashboard/http/__init__.py +40 -0
  23. agent2dashboard/http/dashboards.py +100 -0
  24. agent2dashboard/http/functions.py +462 -0
  25. agent2dashboard/http/queries.py +168 -0
  26. agent2dashboard/http/revisions.py +126 -0
  27. agent2dashboard/http/router.py +353 -0
  28. agent2dashboard/http/schemas.py +102 -0
  29. agent2dashboard/llm/__init__.py +7 -0
  30. agent2dashboard/llm/_messages_api.py +123 -0
  31. agent2dashboard/llm/bedrock.py +96 -0
  32. agent2dashboard/llm/direct.py +40 -0
  33. agent2dashboard/llm/messages.py +45 -0
  34. agent2dashboard/migrations/__init__.py +383 -0
  35. agent2dashboard/migrations/versions/0001_initial.py +228 -0
  36. agent2dashboard/ports.py +538 -0
  37. agent2dashboard/py.typed +0 -0
  38. agent2dashboard/query/__init__.py +65 -0
  39. agent2dashboard/query/errors.py +39 -0
  40. agent2dashboard/query/executor.py +203 -0
  41. agent2dashboard/query/filters.py +446 -0
  42. agent2dashboard/query/governed.py +155 -0
  43. agent2dashboard/query/readonly.py +166 -0
  44. agent2dashboard/query/registry.py +213 -0
  45. agent2dashboard/query/row_filter.py +135 -0
  46. agent2dashboard/query/service.py +93 -0
  47. agent2dashboard/query/sql_guard.py +219 -0
  48. agent2dashboard/runs/__init__.py +87 -0
  49. agent2dashboard/runs/errors.py +65 -0
  50. agent2dashboard/runs/events.py +147 -0
  51. agent2dashboard/runs/hooks.py +135 -0
  52. agent2dashboard/runs/http.py +169 -0
  53. agent2dashboard/runs/memory.py +148 -0
  54. agent2dashboard/runs/redis_bus.py +219 -0
  55. agent2dashboard/runs/service.py +728 -0
  56. agent2dashboard/runs/writer.py +95 -0
  57. agent2dashboard/semantic/__init__.py +6 -0
  58. agent2dashboard/semantic/cube.py +39 -0
  59. agent2dashboard/semantic/static.py +81 -0
  60. agent2dashboard/storage/__init__.py +60 -0
  61. agent2dashboard/storage/lifecycle.py +105 -0
  62. agent2dashboard/storage/memory.py +488 -0
  63. agent2dashboard/storage/records.py +219 -0
  64. agent2dashboard/storage/sql.py +666 -0
  65. agent2dashboard/storage/tables.py +387 -0
  66. agent2dashboard/testing/__init__.py +20 -0
  67. agent2dashboard/testing/event_bus.py +10 -0
  68. agent2dashboard/testing/fake_llm.py +129 -0
  69. agent2dashboard/testing/host.py +191 -0
  70. agent2dashboard/tracing/__init__.py +36 -0
  71. agent2dashboard/tracing/db.py +143 -0
  72. agent2dashboard/tracing/fanout.py +153 -0
  73. agent2dashboard/tracing/langfuse.py +339 -0
  74. agent2dashboard/tracing/masking.py +26 -0
  75. agent2dashboard-0.2.0.dist-info/METADATA +81 -0
  76. agent2dashboard-0.2.0.dist-info/RECORD +79 -0
  77. agent2dashboard-0.2.0.dist-info/WHEEL +4 -0
  78. agent2dashboard-0.2.0.dist-info/entry_points.txt +3 -0
  79. agent2dashboard-0.2.0.dist-info/licenses/LICENSE +202 -0
@@ -0,0 +1,496 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://techx.dev/a2ui/dashboard/v1",
4
+ "protocolVersion": "1.0",
5
+ "title": "Agent Dashboard Catalog v1",
6
+ "description": "Governed dashboards built by an agent inside a conversation: layout containers, text, KPI cards, charts, tables and filters. Data widgets never carry rows or SQL; they call runQuery with the id of a query registered on the server.",
7
+ "catalogId": "https://techx.dev/a2ui/dashboard/v1",
8
+ "instructions": "## How to build a dashboard\n\n1. Where to write it. Write the Express block only as the `a2ui` argument of the `render_dashboard` tool, never in your chat reply. If the tool returns errors, fix exactly what they name and call it again.\n\n2. One surface per conversation. The host tells you the surface id (`dash_...`). The first dashboard is `surface(\"<id>\")` followed by `root = Dashboard(...)`. Every later change is `surface(\"<id>\", update=true)` followed by only the components that change. Never create the surface twice and never delete it.\n\n3. Ids. Assign every widget and container to a variable: the variable name is the component id. Ids are lowercase snake_case (`kpi_open`, `by_team`, `trend`), at most 32 characters. An inline component may set its own id with `id=\"...\"`. Keep ids stable: to change a widget, redefine the same id in an update.\n\n4. Referring to what is on screen. The host lists the components on screen (id, type, queryId). In an update, use those ids as plain names without redefining them, e.g. `body = Column([kpis, by_team, trend])`. To remove a widget, rewrite its parent's children without it. To move one, rewrite both parents.\n\n5. Data. Never write rows, numbers or SQL. Register each query with `define_query` first, then bind it: `data=runQuery(\"<queryId>\", $/filters)`. Field props (`x`, `series` keys, `value`, `change`, `status`, `label`, table `columns`) name result columns of that query, exactly as `define_query` returned them. The only data you may assign is a filter default under `$/filters/<key>` and view state under `$/ui/...`; any other `$/...` assignment is refused.\n\n6. Filters. Put one `FilterBar` in the Dashboard's `filters`. Each picker binds `$/filters/<key>`, where `<key>` is a filter declared with `define_query`. Set its default in the same block, e.g. `$/filters/time = \"last_30d\"`. Pass `$/filters` to `runQuery` for every widget that should follow the filters; a filter change then re-runs only those widgets.\n\n7. Layout. Compose `Row`, `Column`, `Card` and `Tabs` freely, at most 4 levels deep. Put KPI cards in the first Row (2 to 4 of them), then charts, then tables. Use `weight` to share a Row (e.g. 2 and 1). Spacing comes from `gap` on containers only. Use `DashboardGrid` only when the user asks for exact placement or resizing; it has 12 columns and items must not overlap. At most 12 data widgets per dashboard.\n\n8. Choosing a chart. Go down this list and stop at the first match:\n - the x axis is time or an ordered sequence with more than 10 points: LineChart (AreaChart when the stacked total over time matters);\n - an item can belong to several groups, or the groups do not add up to a whole: BarChart;\n - one number or one percentage with no breakdown: KpiCard;\n - more than 5 groups: BarChart (eleven categories is still a bar);\n - 2 to 5 mutually exclusive groups that add up to the whole: PieChart.\n Use LineChart only on a time or ordered axis. At most 4 series per chart. No dual axes. Colours are chosen by the renderer; never ask for one.\n\n9. Numbers come from SQL exactly as shown. The UI renders what the query returns and never rescales, derives, sorts, sums or compares values. So: return the final display value (a percentage as `ROUND(100.0 * x / NULLIF(y, 0), 1) AS baselined_pct`, shown with `suffix=\"%\"`); compute a KPI's change and status in SQL (`status` is `met`, `at_risk` or `missed`, or `good`, `bad` or `flat`); ORDER BY in SQL; for a PieChart return at most 5 rows, grouping the rest into `Other` in SQL. `decimals`, `prefix`, `suffix`, `currency` and `grouping` only change how a value is written, never the value.\n\n10. Text. `Text` is Markdown without HTML, links or images; keep it short. Use `Notice` for caveats about the data (tone `warn`) or how to read the dashboard (tone `info`).\n\n## Example: first render\n\n```text\nsurface(\"dash_c1\")\n$/filters/time = \"last_30d\"\nperiod = PeriodPicker(\"Period\", $/filters/time)\nteam = FilterSelect(\"Team\", $/filters/team, filterOptions(\"team\"))\nkpi_open = KpiCard(\"Open tickets\", runQuery(\"q_open\", $/filters), \"open\", change=\"open_change\", status=\"open_tone\")\nkpi_sla = KpiCard(\"SLA met\", runQuery(\"q_sla\", $/filters), \"sla_met_pct\", suffix=\"%\", decimals=1, goal=95, status=\"sla_status\")\nby_team = BarChart(\"Open by team\", runQuery(\"q_by_team\", $/filters), \"team\", [{key: \"open\", label: \"Open\"}])\ntrend = LineChart(\"Opened per day\", runQuery(\"q_trend\", $/filters), \"day\", [{key: \"opened\"}])\nkpis = Row([kpi_open, kpi_sla], gap=\"md\")\ncharts = Row([Column([by_team], weight=2), Column([trend], weight=1)], gap=\"md\")\nbody = Column([kpis, charts], gap=\"lg\")\nroot = Dashboard(\"Support backlog\", body, filters=FilterBar([period, team]))\n```\n\n## Example: follow-up edit (\"make the trend a bar chart and put it under the KPIs\")\n\n```text\nsurface(\"dash_c1\", update=true)\ntrend = BarChart(\"Opened per day\", runQuery(\"q_trend\", $/filters), \"day\", [{key: \"opened\"}])\nbody = Column([kpis, trend, by_team], gap=\"lg\")\n```",
9
+ "components": {
10
+ "Dashboard": {
11
+ "type": "object",
12
+ "description": "The root of every dashboard; use it exactly once, as `root`. Holds the title, an optional filter bar and the body container.",
13
+ "allowedParents": ["Surface"],
14
+ "properties": {
15
+ "component": {"const": "Dashboard"},
16
+ "title": {"type": "string", "description": "Short dashboard title, at most 80 characters."},
17
+ "body": {"$ref": "common_types.json#/$defs/Child", "description": "The id of the single container (usually a Column) holding every widget."},
18
+ "filters": {"$ref": "common_types.json#/$defs/Child", "description": "Optional. The id of the FilterBar."},
19
+ "description": {"type": "string", "description": "Optional one-line subtitle: what the dashboard answers."}
20
+ },
21
+ "required": ["component", "title", "body"]
22
+ },
23
+ "Row": {
24
+ "type": "object",
25
+ "description": "Lays its children out side by side. Put 2 to 4 widgets in a Row; the renderer wraps it on narrow screens.",
26
+ "properties": {
27
+ "component": {"const": "Row"},
28
+ "children": {"$ref": "common_types.json#/$defs/ChildList", "description": "The ids of the children, left to right."},
29
+ "gap": {"$ref": "#/$defs/Gap"},
30
+ "wrap": {"type": "boolean", "default": true, "description": "Optional. Wrap when too narrow."},
31
+ "justify": {"type": "string", "enum": ["start", "center", "end", "spaceBetween", "spaceAround", "spaceEvenly", "stretch"], "default": "start"},
32
+ "align": {"type": "string", "enum": ["start", "center", "end", "stretch"], "default": "stretch"},
33
+ "weight": {"$ref": "#/$defs/Weight"}
34
+ },
35
+ "required": ["component", "children"]
36
+ },
37
+ "Column": {
38
+ "type": "object",
39
+ "description": "Stacks its children top to bottom. The Dashboard body is usually a Column.",
40
+ "properties": {
41
+ "component": {"const": "Column"},
42
+ "children": {"$ref": "common_types.json#/$defs/ChildList", "description": "The ids of the children, top to bottom."},
43
+ "gap": {"$ref": "#/$defs/Gap"},
44
+ "justify": {"type": "string", "enum": ["start", "center", "end", "spaceBetween", "spaceAround", "spaceEvenly", "stretch"], "default": "start"},
45
+ "align": {"type": "string", "enum": ["start", "center", "end", "stretch"], "default": "stretch"},
46
+ "weight": {"$ref": "#/$defs/Weight"}
47
+ },
48
+ "required": ["component", "children"]
49
+ },
50
+ "DashboardGrid": {
51
+ "type": "object",
52
+ "description": "A 12-column grid with explicit sizes. Use it only when the user asks for exact placement or resizing; otherwise use Row and Column.",
53
+ "properties": {
54
+ "component": {"const": "DashboardGrid"},
55
+ "items": {
56
+ "type": "array",
57
+ "minItems": 1,
58
+ "maxItems": 24,
59
+ "description": "One entry per widget. Leave x and y out to flow items left to right.",
60
+ "items": {
61
+ "type": "object",
62
+ "properties": {
63
+ "child": {"$ref": "common_types.json#/$defs/Child", "description": "The id of the widget."},
64
+ "w": {"type": "integer", "minimum": 1, "maximum": 12, "description": "Width in columns, 1 to 12."},
65
+ "h": {"type": "integer", "minimum": 1, "maximum": 40, "description": "Height in grid rows (a KPI is 2, a chart 6)."},
66
+ "x": {"type": "integer", "minimum": 0, "maximum": 11, "description": "Optional. Left column, 0 to 11; x + w must be at most 12."},
67
+ "y": {"type": "integer", "minimum": 0, "maximum": 1000, "description": "Optional. Top row."}
68
+ },
69
+ "required": ["child", "w", "h"],
70
+ "additionalProperties": false
71
+ }
72
+ },
73
+ "weight": {"$ref": "#/$defs/Weight"}
74
+ },
75
+ "required": ["component", "items"]
76
+ },
77
+ "Card": {
78
+ "type": "object",
79
+ "description": "A titled panel around one child. Use it to group related widgets; wrap several in a Row or Column first.",
80
+ "properties": {
81
+ "component": {"const": "Card"},
82
+ "child": {"$ref": "common_types.json#/$defs/Child", "description": "The id of the single child."},
83
+ "title": {"type": "string", "description": "Optional panel title."},
84
+ "weight": {"$ref": "#/$defs/Weight"}
85
+ },
86
+ "required": ["component", "child"]
87
+ },
88
+ "Tabs": {
89
+ "type": "object",
90
+ "description": "Shows one of several children at a time. Use it for alternative views of the same subject (trend vs detail).",
91
+ "properties": {
92
+ "component": {"const": "Tabs"},
93
+ "tabs": {
94
+ "type": "array",
95
+ "minItems": 1,
96
+ "maxItems": 6,
97
+ "description": "The tabs, in order.",
98
+ "items": {
99
+ "type": "object",
100
+ "properties": {
101
+ "title": {"type": "string", "description": "The tab label."},
102
+ "child": {"$ref": "common_types.json#/$defs/Child", "description": "The id of the tab's content."}
103
+ },
104
+ "required": ["title", "child"],
105
+ "additionalProperties": false
106
+ }
107
+ },
108
+ "weight": {"$ref": "#/$defs/Weight"}
109
+ },
110
+ "required": ["component", "tabs"]
111
+ },
112
+ "Divider": {
113
+ "type": "object",
114
+ "description": "A thin rule between sections. Rarely needed: gap usually separates enough.",
115
+ "properties": {
116
+ "component": {"const": "Divider"},
117
+ "axis": {"type": "string", "enum": ["horizontal", "vertical"], "default": "horizontal", "description": "Optional."},
118
+ "weight": {"$ref": "#/$defs/Weight"}
119
+ },
120
+ "required": ["component"]
121
+ },
122
+ "Text": {
123
+ "type": "object",
124
+ "description": "A short block of Markdown (no HTML, links or images).",
125
+ "properties": {
126
+ "component": {"const": "Text"},
127
+ "text": {"$ref": "common_types.json#/$defs/DynamicString", "description": "The Markdown text."},
128
+ "variant": {"type": "string", "enum": ["heading", "body", "caption"], "default": "body", "description": "Optional. `heading` for a section title, `caption` for fine print."},
129
+ "weight": {"$ref": "#/$defs/Weight"}
130
+ },
131
+ "required": ["component", "text"]
132
+ },
133
+ "Notice": {
134
+ "type": "object",
135
+ "description": "A highlighted note: a caveat about the data or a hint on reading the dashboard.",
136
+ "properties": {
137
+ "component": {"const": "Notice"},
138
+ "text": {"$ref": "common_types.json#/$defs/DynamicString", "description": "The note, one or two sentences of Markdown."},
139
+ "tone": {"type": "string", "enum": ["info", "warn"], "default": "info", "description": "Optional. `warn` for caveats about the data."},
140
+ "weight": {"$ref": "#/$defs/Weight"}
141
+ },
142
+ "required": ["component", "text"]
143
+ },
144
+ "KpiCard": {
145
+ "type": "object",
146
+ "description": "One headline number from the first row of its query, shown exactly as the query returns it, with an optional change, status, sparkline and goal from the same row. Also the right choice for a single percentage: return it from SQL already multiplied by 100 and set suffix=\"%\".",
147
+ "properties": {
148
+ "component": {"const": "KpiCard"},
149
+ "title": {"type": "string", "description": "What the number is, at most 40 characters."},
150
+ "data": {"$ref": "#/$defs/QueryData"},
151
+ "value": {"type": "string", "description": "Result column holding the number; the first row is shown as returned, never rescaled."},
152
+ "decimals": {"$ref": "#/$defs/Decimals"},
153
+ "prefix": {"$ref": "#/$defs/Prefix"},
154
+ "suffix": {"$ref": "#/$defs/Suffix"},
155
+ "currency": {"$ref": "#/$defs/Currency"},
156
+ "grouping": {"$ref": "#/$defs/Grouping"},
157
+ "change": {"type": "string", "description": "Optional. Result column with the change to show next to the value (e.g. vs the previous period), computed in SQL and shown as returned, with its sign."},
158
+ "changeSuffix": {"type": "string", "description": "Optional. Text after the change, e.g. `%` or ` pts`. The change is never rescaled."},
159
+ "status": {"type": "string", "description": "Optional. Result column (text) computed in SQL: `met`, `at_risk` or `missed` (shown as a goal badge), or `good`, `bad` or `flat` (colours the change)."},
160
+ "trend": {"type": "string", "description": "Optional. Result column holding an array of numbers, oldest first, drawn as a sparkline."},
161
+ "goal": {"type": ["string", "number"], "description": "Optional. Reference value shown under the number: a result column name, or a literal number in the same units as the value. Display only; the UI never compares it with the value (compute `status` in SQL)."},
162
+ "height": {"$ref": "#/$defs/Height", "description": "Optional. Defaults to `xs`."},
163
+ "weight": {"$ref": "#/$defs/Weight"}
164
+ },
165
+ "required": ["component", "title", "data", "value"]
166
+ },
167
+ "BarChart": {
168
+ "type": "object",
169
+ "description": "Compares numbers across categories. The default chart for categories, including more than 5 of them and groups that overlap.",
170
+ "properties": {
171
+ "component": {"const": "BarChart"},
172
+ "title": {"type": "string", "description": "At most 80 characters."},
173
+ "data": {"$ref": "#/$defs/QueryData"},
174
+ "x": {"type": "string", "description": "Result column for the category axis. Drawn in the order returned."},
175
+ "series": {"$ref": "#/$defs/SeriesList"},
176
+ "stacked": {"type": "boolean", "default": false, "description": "Optional. Stack the series when their sum is meaningful."},
177
+ "horizontal": {"type": "boolean", "default": false, "description": "Optional. Horizontal bars, for long category names."},
178
+ "decimals": {"$ref": "#/$defs/Decimals"},
179
+ "prefix": {"$ref": "#/$defs/Prefix"},
180
+ "suffix": {"$ref": "#/$defs/Suffix"},
181
+ "height": {"$ref": "#/$defs/Height", "description": "Optional. Defaults to `md`."},
182
+ "weight": {"$ref": "#/$defs/Weight"}
183
+ },
184
+ "required": ["component", "title", "data", "x", "series"]
185
+ },
186
+ "LineChart": {
187
+ "type": "object",
188
+ "description": "Shows how numbers change along a time or ordered axis. Use it only when x is a date or an order and there are more than 10 points.",
189
+ "properties": {
190
+ "component": {"const": "LineChart"},
191
+ "title": {"type": "string", "description": "At most 80 characters."},
192
+ "data": {"$ref": "#/$defs/QueryData"},
193
+ "x": {"type": "string", "description": "Result column for the x axis: a date or an ordered value. Drawn in the order returned."},
194
+ "series": {"$ref": "#/$defs/SeriesList"},
195
+ "decimals": {"$ref": "#/$defs/Decimals"},
196
+ "prefix": {"$ref": "#/$defs/Prefix"},
197
+ "suffix": {"$ref": "#/$defs/Suffix"},
198
+ "height": {"$ref": "#/$defs/Height", "description": "Optional. Defaults to `md`."},
199
+ "weight": {"$ref": "#/$defs/Weight"}
200
+ },
201
+ "required": ["component", "title", "data", "x", "series"]
202
+ },
203
+ "AreaChart": {
204
+ "type": "object",
205
+ "description": "A LineChart with filled areas. Use it over time when the stacked total matters.",
206
+ "properties": {
207
+ "component": {"const": "AreaChart"},
208
+ "title": {"type": "string", "description": "At most 80 characters."},
209
+ "data": {"$ref": "#/$defs/QueryData"},
210
+ "x": {"type": "string", "description": "Result column for the x axis: a date or an ordered value. Drawn in the order returned."},
211
+ "series": {"$ref": "#/$defs/SeriesList"},
212
+ "stacked": {"type": "boolean", "default": false, "description": "Optional. Stack the areas so their top is the total."},
213
+ "decimals": {"$ref": "#/$defs/Decimals"},
214
+ "prefix": {"$ref": "#/$defs/Prefix"},
215
+ "suffix": {"$ref": "#/$defs/Suffix"},
216
+ "height": {"$ref": "#/$defs/Height", "description": "Optional. Defaults to `md`."},
217
+ "weight": {"$ref": "#/$defs/Weight"}
218
+ },
219
+ "required": ["component", "title", "data", "x", "series"]
220
+ },
221
+ "PieChart": {
222
+ "type": "object",
223
+ "description": "A donut of 2 to 5 mutually exclusive groups that add up to the whole: one slice per returned row, in the order returned. The query must return at most 5 rows; group the rest into an `Other` row in SQL. More than 5 groups, or overlapping groups: use BarChart.",
224
+ "properties": {
225
+ "component": {"const": "PieChart"},
226
+ "title": {"type": "string", "description": "At most 80 characters."},
227
+ "data": {"$ref": "#/$defs/QueryData"},
228
+ "label": {"type": "string", "description": "Result column naming each slice."},
229
+ "value": {"type": "string", "description": "Result column with each slice's number, drawn as returned."},
230
+ "decimals": {"$ref": "#/$defs/Decimals"},
231
+ "prefix": {"$ref": "#/$defs/Prefix"},
232
+ "suffix": {"$ref": "#/$defs/Suffix"},
233
+ "height": {"$ref": "#/$defs/Height", "description": "Optional. Defaults to `md`."},
234
+ "weight": {"$ref": "#/$defs/Weight"}
235
+ },
236
+ "required": ["component", "title", "data", "label", "value"]
237
+ },
238
+ "DataTable": {
239
+ "type": "object",
240
+ "description": "Rows of its query as a paged table, in the order and with the values the query returns. Use it for detail the charts summarise.",
241
+ "properties": {
242
+ "component": {"const": "DataTable"},
243
+ "title": {"type": "string", "description": "At most 80 characters."},
244
+ "data": {"$ref": "#/$defs/QueryData"},
245
+ "columns": {
246
+ "type": "array",
247
+ "minItems": 1,
248
+ "maxItems": 30,
249
+ "description": "Optional. Result columns to show, in order; leave it out to show all.",
250
+ "items": {
251
+ "type": "object",
252
+ "properties": {
253
+ "key": {"type": "string", "description": "Result column name."},
254
+ "label": {"type": "string", "description": "Optional header text."},
255
+ "decimals": {"$ref": "#/$defs/Decimals"},
256
+ "prefix": {"$ref": "#/$defs/Prefix"},
257
+ "suffix": {"$ref": "#/$defs/Suffix"},
258
+ "currency": {"$ref": "#/$defs/Currency"},
259
+ "grouping": {"$ref": "#/$defs/Grouping"}
260
+ },
261
+ "required": ["key"],
262
+ "additionalProperties": false
263
+ }
264
+ },
265
+ "pageSize": {"type": "integer", "minimum": 1, "maximum": 100, "default": 10, "description": "Optional. Rows per page."},
266
+ "height": {"$ref": "#/$defs/Height", "description": "Optional. Defaults to `lg`."},
267
+ "weight": {"$ref": "#/$defs/Weight"}
268
+ },
269
+ "required": ["component", "title", "data"]
270
+ },
271
+ "FilterBar": {
272
+ "type": "object",
273
+ "description": "The row of filters above the body. Use it only as the Dashboard's `filters`, holding PeriodPicker and FilterSelect children.",
274
+ "allowedChildren": ["PeriodPicker", "FilterSelect"],
275
+ "properties": {
276
+ "component": {"const": "FilterBar"},
277
+ "children": {"$ref": "common_types.json#/$defs/ChildList", "description": "The ids of the pickers, left to right."}
278
+ },
279
+ "required": ["component", "children"]
280
+ },
281
+ "PeriodPicker": {
282
+ "type": "object",
283
+ "description": "Picks the time window for the dashboard. Its value is a preset name or a custom {from, to} range the user picks.",
284
+ "allowedParents": ["FilterBar"],
285
+ "properties": {
286
+ "component": {"const": "PeriodPicker"},
287
+ "label": {"type": "string", "description": "The picker's label, e.g. `Period`."},
288
+ "value": {"$ref": "common_types.json#/$defs/DynamicValue", "description": "Bind to `$/filters/time` (the time filter key) and set a default preset with `$/filters/time = \"last_30d\"`."},
289
+ "presets": {
290
+ "type": "array",
291
+ "minItems": 1,
292
+ "description": "Optional. The presets offered; leave it out to offer all.",
293
+ "items": {"type": "string", "enum": ["last_7d", "last_30d", "last_90d", "last_12m", "all"]}
294
+ }
295
+ },
296
+ "required": ["component", "label", "value"]
297
+ },
298
+ "FilterSelect": {
299
+ "type": "object",
300
+ "description": "A pick-one filter over the values of one column. Null means All.",
301
+ "allowedParents": ["FilterBar"],
302
+ "properties": {
303
+ "component": {"const": "FilterSelect"},
304
+ "label": {"type": "string", "description": "The picker's label, e.g. `Team`."},
305
+ "value": {"$ref": "common_types.json#/$defs/DynamicString", "description": "Bind to `$/filters/<key>`, where `<key>` is a filter declared with define_query."},
306
+ "options": {"$ref": "common_types.json#/$defs/DynamicValue", "description": "Always `filterOptions(\"<key>\")` with the same key as `value`."}
307
+ },
308
+ "required": ["component", "label", "value", "options"]
309
+ }
310
+ },
311
+ "functions": {
312
+ "runQuery": {
313
+ "type": "object",
314
+ "description": "The rows of a query registered with define_query, run on the server with the current filters. Use it only as a data widget's `data`. It re-runs when the filters change.",
315
+ "returnType": "array",
316
+ "properties": {
317
+ "@call": {"const": "runQuery"},
318
+ "args": {
319
+ "type": "object",
320
+ "properties": {
321
+ "queryId": {"type": "string", "description": "The id given to define_query."},
322
+ "filters": {"$ref": "common_types.json#/$defs/DynamicValue", "description": "Optional. Always `$/filters` when the widget follows the dashboard's filters."}
323
+ },
324
+ "required": ["queryId"],
325
+ "unevaluatedProperties": false
326
+ }
327
+ },
328
+ "required": ["@call", "args"]
329
+ },
330
+ "filterOptions": {
331
+ "type": "object",
332
+ "description": "The values a FilterSelect offers, read on the server. Use it only as a FilterSelect's `options`.",
333
+ "returnType": "array",
334
+ "properties": {
335
+ "@call": {"const": "filterOptions"},
336
+ "args": {
337
+ "type": "object",
338
+ "properties": {
339
+ "key": {"type": "string", "description": "The filter key declared with define_query."}
340
+ },
341
+ "required": ["key"],
342
+ "unevaluatedProperties": false
343
+ }
344
+ },
345
+ "required": ["@call", "args"]
346
+ },
347
+ "formatNumber": {
348
+ "type": "object",
349
+ "description": "Formats a number with the specified grouping and decimal precision.",
350
+ "returnType": "string",
351
+ "properties": {
352
+ "@call": {"const": "formatNumber"},
353
+ "args": {
354
+ "type": "object",
355
+ "properties": {
356
+ "value": {"$ref": "common_types.json#/$defs/DynamicNumber", "description": "The number to format."},
357
+ "decimals": {"$ref": "common_types.json#/$defs/DynamicNumber", "description": "Optional. The number of decimal places to show. Defaults to 0 or 2 depending on locale."},
358
+ "grouping": {"$ref": "common_types.json#/$defs/DynamicBoolean", "description": "Optional. If true, uses locale-specific grouping separators (e.g. '1,000'). If false, returns raw digits (e.g. '1000'). Defaults to true."}
359
+ },
360
+ "required": ["value"],
361
+ "unevaluatedProperties": false
362
+ }
363
+ },
364
+ "required": ["@call", "args"]
365
+ },
366
+ "formatCurrency": {
367
+ "type": "object",
368
+ "description": "Formats a number as a currency string.",
369
+ "returnType": "string",
370
+ "properties": {
371
+ "@call": {"const": "formatCurrency"},
372
+ "args": {
373
+ "type": "object",
374
+ "properties": {
375
+ "value": {"$ref": "common_types.json#/$defs/DynamicNumber", "description": "The monetary amount."},
376
+ "currency": {"$ref": "common_types.json#/$defs/DynamicString", "description": "The ISO 4217 currency code (e.g., 'USD', 'EUR')."},
377
+ "decimals": {"$ref": "common_types.json#/$defs/DynamicNumber", "description": "Optional. The number of decimal places to show. Defaults to 0 or 2 depending on locale."},
378
+ "grouping": {"$ref": "common_types.json#/$defs/DynamicBoolean", "description": "Optional. If true, uses locale-specific grouping separators (e.g. '1,000'). If false, returns raw digits (e.g. '1000'). Defaults to true."}
379
+ },
380
+ "required": ["currency", "value"],
381
+ "unevaluatedProperties": false
382
+ }
383
+ },
384
+ "required": ["@call", "args"]
385
+ },
386
+ "formatDate": {
387
+ "type": "object",
388
+ "description": "Formats a timestamp into a string using a pattern.",
389
+ "returnType": "string",
390
+ "properties": {
391
+ "@call": {"const": "formatDate"},
392
+ "args": {
393
+ "type": "object",
394
+ "properties": {
395
+ "value": {"$ref": "common_types.json#/$defs/DynamicValue", "description": "The date to format."},
396
+ "format": {"$ref": "common_types.json#/$defs/DynamicString", "description": "A Unicode TR35 date pattern string, e.g. 'MMM dd, yyyy' -> 'Jan 16, 2026', 'HH:mm' -> '14:30'."}
397
+ },
398
+ "required": ["format", "value"],
399
+ "unevaluatedProperties": false
400
+ }
401
+ },
402
+ "required": ["@call", "args"]
403
+ }
404
+ },
405
+ "$defs": {
406
+ "anyComponent": {
407
+ "oneOf": [
408
+ {"$ref": "#/components/Dashboard"},
409
+ {"$ref": "#/components/Row"},
410
+ {"$ref": "#/components/Column"},
411
+ {"$ref": "#/components/DashboardGrid"},
412
+ {"$ref": "#/components/Card"},
413
+ {"$ref": "#/components/Tabs"},
414
+ {"$ref": "#/components/Divider"},
415
+ {"$ref": "#/components/Text"},
416
+ {"$ref": "#/components/Notice"},
417
+ {"$ref": "#/components/KpiCard"},
418
+ {"$ref": "#/components/BarChart"},
419
+ {"$ref": "#/components/LineChart"},
420
+ {"$ref": "#/components/AreaChart"},
421
+ {"$ref": "#/components/PieChart"},
422
+ {"$ref": "#/components/DataTable"},
423
+ {"$ref": "#/components/FilterBar"},
424
+ {"$ref": "#/components/PeriodPicker"},
425
+ {"$ref": "#/components/FilterSelect"}
426
+ ],
427
+ "discriminator": {"propertyName": "component"}
428
+ },
429
+ "anyFunction": {
430
+ "oneOf": [
431
+ {"$ref": "#/functions/runQuery"},
432
+ {"$ref": "#/functions/filterOptions"},
433
+ {"$ref": "#/functions/formatNumber"},
434
+ {"$ref": "#/functions/formatCurrency"},
435
+ {"$ref": "#/functions/formatDate"}
436
+ ]
437
+ },
438
+ "Weight": {
439
+ "type": "number",
440
+ "description": "Optional share of the parent Row or Column, like flex-grow."
441
+ },
442
+ "Gap": {
443
+ "type": "string",
444
+ "enum": ["none", "sm", "md", "lg"],
445
+ "default": "md",
446
+ "description": "Optional. Space between the children."
447
+ },
448
+ "Decimals": {
449
+ "type": "integer",
450
+ "minimum": 0,
451
+ "maximum": 6,
452
+ "description": "Optional. Decimal places shown (display rounding only)."
453
+ },
454
+ "Prefix": {
455
+ "type": "string",
456
+ "description": "Optional. Text before the value."
457
+ },
458
+ "Suffix": {
459
+ "type": "string",
460
+ "description": "Optional. Text after the value, e.g. `%` (38.9 shows 38.9%)."
461
+ },
462
+ "Currency": {
463
+ "type": "string",
464
+ "description": "Optional. ISO 4217 code; shows its symbol, never converts."
465
+ },
466
+ "Grouping": {
467
+ "type": "boolean",
468
+ "default": true,
469
+ "description": "Optional. false: no digit grouping (years, ids)."
470
+ },
471
+ "Height": {
472
+ "type": "string",
473
+ "enum": ["xs", "sm", "md", "lg", "xl"],
474
+ "description": "Height token; widgets in one Row share one."
475
+ },
476
+ "QueryData": {
477
+ "$ref": "common_types.json#/$defs/DynamicValue",
478
+ "description": "`runQuery(\"<queryId>\", $/filters)`, never literal rows."
479
+ },
480
+ "SeriesList": {
481
+ "type": "array",
482
+ "minItems": 1,
483
+ "maxItems": 4,
484
+ "description": "1 to 4 number columns to plot.",
485
+ "items": {
486
+ "type": "object",
487
+ "properties": {
488
+ "key": {"type": "string", "description": "Result column holding this series' numbers."},
489
+ "label": {"type": "string", "description": "Optional legend text."}
490
+ },
491
+ "required": ["key"],
492
+ "additionalProperties": false
493
+ }
494
+ }
495
+ }
496
+ }