@xpert-ai/plugin-live-dashboard 0.4.1 → 0.6.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.
Files changed (79) hide show
  1. package/.xpertai-plugin/plugin.json +1 -1
  2. package/README.md +8 -2
  3. package/dist/index.js +3 -1
  4. package/dist/lib/agent.schema.d.ts +177 -23
  5. package/dist/lib/agent.schema.js +11 -9
  6. package/dist/lib/archive.service.d.ts +169 -0
  7. package/dist/lib/archive.service.js +147 -0
  8. package/dist/lib/bounded-map.d.ts +2 -0
  9. package/dist/lib/bounded-map.js +25 -0
  10. package/dist/lib/capacity.d.ts +14 -0
  11. package/dist/lib/capacity.js +16 -0
  12. package/dist/lib/content.provider.d.ts +1 -1
  13. package/dist/lib/dashboard-archive.d.ts +70 -0
  14. package/dist/lib/dashboard-archive.js +118 -0
  15. package/dist/lib/dashboard-queries.d.ts +1 -1
  16. package/dist/lib/dashboard-queries.js +11 -6
  17. package/dist/lib/dashboard-receipt.js +1 -1
  18. package/dist/lib/dashboard-sources.d.ts +69 -0
  19. package/dist/lib/dashboard-sources.js +38 -0
  20. package/dist/lib/dashboard-view.schema.d.ts +422 -88
  21. package/dist/lib/dashboard.schema.d.ts +379 -58
  22. package/dist/lib/dashboard.schema.js +20 -2
  23. package/dist/lib/dashboard.service.d.ts +80 -15
  24. package/dist/lib/dashboard.service.js +65 -9
  25. package/dist/lib/definition-tools.d.ts +4 -4
  26. package/dist/lib/document-host.js +1 -1
  27. package/dist/lib/document-package.d.ts +19 -4
  28. package/dist/lib/editing-patch.d.ts +3 -0
  29. package/dist/lib/editing-patch.js +4 -2
  30. package/dist/lib/editing-session.d.ts +4 -4
  31. package/dist/lib/editing.d.ts +204 -20
  32. package/dist/lib/editing.js +10 -3
  33. package/dist/lib/filter-evidence.d.ts +28 -0
  34. package/dist/lib/filter-evidence.js +3 -2
  35. package/dist/lib/html-guidance.d.ts +1 -0
  36. package/dist/lib/html-guidance.js +2 -1
  37. package/dist/lib/html-validation-feedback.d.ts +7 -0
  38. package/dist/lib/html-validation-feedback.js +19 -0
  39. package/dist/lib/html-validation.js +3 -2
  40. package/dist/lib/inspection-host.d.ts +7 -0
  41. package/dist/lib/inspection-host.js +48 -0
  42. package/dist/lib/inspection-runtime.d.ts +2 -0
  43. package/dist/lib/inspection-runtime.js +77 -0
  44. package/dist/lib/json-input.d.ts +4 -0
  45. package/dist/lib/json-input.js +21 -0
  46. package/dist/lib/middleware.d.ts +3 -1
  47. package/dist/lib/middleware.js +92 -13
  48. package/dist/lib/plugin.js +3 -1
  49. package/dist/lib/presentation.provider.d.ts +24 -9
  50. package/dist/lib/presentation.provider.js +2 -1
  51. package/dist/lib/preview-retry.d.ts +4 -3
  52. package/dist/lib/preview-retry.js +13 -7
  53. package/dist/lib/prompt-workflows.js +1 -1
  54. package/dist/lib/query-session.d.ts +9 -0
  55. package/dist/lib/query-session.js +64 -0
  56. package/dist/lib/save-requests.d.ts +118 -0
  57. package/dist/lib/save-requests.js +199 -0
  58. package/dist/lib/source-executions.d.ts +437 -0
  59. package/dist/lib/source-executions.js +49 -0
  60. package/dist/lib/source-validation.d.ts +2 -0
  61. package/dist/lib/source-validation.js +21 -0
  62. package/dist/lib/view.provider.d.ts +213 -8
  63. package/dist/lib/view.provider.js +47 -5
  64. package/dist/remote/app.css +1 -1
  65. package/dist/remote/app.js +185 -63
  66. package/dist/remote/build-manifest.json +52 -33
  67. package/dist/sandbox-actions/action.json +1 -1
  68. package/dist/sandbox-actions/bundle/host.js +63 -14
  69. package/dist/sandbox-actions/bundle/validate.mjs +2 -2
  70. package/dist/validation/host-entry.d.ts +5 -1
  71. package/dist/validation/host-entry.js +21 -4
  72. package/docs/docs.json +5 -1
  73. package/docs/large-dashboards-acceptance.mdx +74 -0
  74. package/docs/large-dashboards.mdx +80 -0
  75. package/docs/sources-inspect-portability-acceptance.mdx +67 -0
  76. package/docs/sources-inspect-portability.mdx +115 -0
  77. package/package.json +8 -7
  78. package/skills/live-dashboard/SKILL.md +5 -4
  79. package/skills/live-dashboard/references/source-inspection.md +17 -0
@@ -0,0 +1,437 @@
1
+ import { z } from 'zod/v3';
2
+ export declare const sourceDatasetSchema: z.ZodObject<{
3
+ schema: z.ZodLiteral<"xpert.analytics.dataset">;
4
+ datasetId: z.ZodString;
5
+ fields: z.ZodArray<z.ZodObject<{
6
+ id: z.ZodString;
7
+ label: z.ZodOptional<z.ZodString>;
8
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
9
+ id: z.ZodString;
10
+ label: z.ZodOptional<z.ZodString>;
11
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
12
+ id: z.ZodString;
13
+ label: z.ZodOptional<z.ZodString>;
14
+ }, z.ZodTypeAny, "passthrough">>, "many">;
15
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, "many">;
16
+ completeness: z.ZodObject<{
17
+ truncated: z.ZodBoolean;
18
+ returnedRows: z.ZodNumber;
19
+ scope: z.ZodString;
20
+ totalAccuracy: z.ZodString;
21
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
22
+ truncated: z.ZodBoolean;
23
+ returnedRows: z.ZodNumber;
24
+ scope: z.ZodString;
25
+ totalAccuracy: z.ZodString;
26
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
27
+ truncated: z.ZodBoolean;
28
+ returnedRows: z.ZodNumber;
29
+ scope: z.ZodString;
30
+ totalAccuracy: z.ZodString;
31
+ }, z.ZodTypeAny, "passthrough">>;
32
+ freshness: z.ZodObject<{
33
+ sourceFetchedAt: z.ZodString;
34
+ executedAt: z.ZodOptional<z.ZodString>;
35
+ dataAsOf: z.ZodOptional<z.ZodString>;
36
+ }, "strip", z.ZodTypeAny, {
37
+ sourceFetchedAt: string;
38
+ executedAt?: string | undefined;
39
+ dataAsOf?: string | undefined;
40
+ }, {
41
+ sourceFetchedAt: string;
42
+ executedAt?: string | undefined;
43
+ dataAsOf?: string | undefined;
44
+ }>;
45
+ provenance: z.ZodObject<{
46
+ executionId: z.ZodString;
47
+ bindingId: z.ZodString;
48
+ providerId: z.ZodString;
49
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
50
+ executionId: z.ZodString;
51
+ bindingId: z.ZodString;
52
+ providerId: z.ZodString;
53
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
54
+ executionId: z.ZodString;
55
+ bindingId: z.ZodString;
56
+ providerId: z.ZodString;
57
+ }, z.ZodTypeAny, "passthrough">>;
58
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
59
+ schema: z.ZodLiteral<"xpert.analytics.dataset">;
60
+ datasetId: z.ZodString;
61
+ fields: z.ZodArray<z.ZodObject<{
62
+ id: z.ZodString;
63
+ label: z.ZodOptional<z.ZodString>;
64
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
65
+ id: z.ZodString;
66
+ label: z.ZodOptional<z.ZodString>;
67
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
68
+ id: z.ZodString;
69
+ label: z.ZodOptional<z.ZodString>;
70
+ }, z.ZodTypeAny, "passthrough">>, "many">;
71
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, "many">;
72
+ completeness: z.ZodObject<{
73
+ truncated: z.ZodBoolean;
74
+ returnedRows: z.ZodNumber;
75
+ scope: z.ZodString;
76
+ totalAccuracy: z.ZodString;
77
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
78
+ truncated: z.ZodBoolean;
79
+ returnedRows: z.ZodNumber;
80
+ scope: z.ZodString;
81
+ totalAccuracy: z.ZodString;
82
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
83
+ truncated: z.ZodBoolean;
84
+ returnedRows: z.ZodNumber;
85
+ scope: z.ZodString;
86
+ totalAccuracy: z.ZodString;
87
+ }, z.ZodTypeAny, "passthrough">>;
88
+ freshness: z.ZodObject<{
89
+ sourceFetchedAt: z.ZodString;
90
+ executedAt: z.ZodOptional<z.ZodString>;
91
+ dataAsOf: z.ZodOptional<z.ZodString>;
92
+ }, "strip", z.ZodTypeAny, {
93
+ sourceFetchedAt: string;
94
+ executedAt?: string | undefined;
95
+ dataAsOf?: string | undefined;
96
+ }, {
97
+ sourceFetchedAt: string;
98
+ executedAt?: string | undefined;
99
+ dataAsOf?: string | undefined;
100
+ }>;
101
+ provenance: z.ZodObject<{
102
+ executionId: z.ZodString;
103
+ bindingId: z.ZodString;
104
+ providerId: z.ZodString;
105
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
106
+ executionId: z.ZodString;
107
+ bindingId: z.ZodString;
108
+ providerId: z.ZodString;
109
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
110
+ executionId: z.ZodString;
111
+ bindingId: z.ZodString;
112
+ providerId: z.ZodString;
113
+ }, z.ZodTypeAny, "passthrough">>;
114
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
115
+ schema: z.ZodLiteral<"xpert.analytics.dataset">;
116
+ datasetId: z.ZodString;
117
+ fields: z.ZodArray<z.ZodObject<{
118
+ id: z.ZodString;
119
+ label: z.ZodOptional<z.ZodString>;
120
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
121
+ id: z.ZodString;
122
+ label: z.ZodOptional<z.ZodString>;
123
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
124
+ id: z.ZodString;
125
+ label: z.ZodOptional<z.ZodString>;
126
+ }, z.ZodTypeAny, "passthrough">>, "many">;
127
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, "many">;
128
+ completeness: z.ZodObject<{
129
+ truncated: z.ZodBoolean;
130
+ returnedRows: z.ZodNumber;
131
+ scope: z.ZodString;
132
+ totalAccuracy: z.ZodString;
133
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
134
+ truncated: z.ZodBoolean;
135
+ returnedRows: z.ZodNumber;
136
+ scope: z.ZodString;
137
+ totalAccuracy: z.ZodString;
138
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
139
+ truncated: z.ZodBoolean;
140
+ returnedRows: z.ZodNumber;
141
+ scope: z.ZodString;
142
+ totalAccuracy: z.ZodString;
143
+ }, z.ZodTypeAny, "passthrough">>;
144
+ freshness: z.ZodObject<{
145
+ sourceFetchedAt: z.ZodString;
146
+ executedAt: z.ZodOptional<z.ZodString>;
147
+ dataAsOf: z.ZodOptional<z.ZodString>;
148
+ }, "strip", z.ZodTypeAny, {
149
+ sourceFetchedAt: string;
150
+ executedAt?: string | undefined;
151
+ dataAsOf?: string | undefined;
152
+ }, {
153
+ sourceFetchedAt: string;
154
+ executedAt?: string | undefined;
155
+ dataAsOf?: string | undefined;
156
+ }>;
157
+ provenance: z.ZodObject<{
158
+ executionId: z.ZodString;
159
+ bindingId: z.ZodString;
160
+ providerId: z.ZodString;
161
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
162
+ executionId: z.ZodString;
163
+ bindingId: z.ZodString;
164
+ providerId: z.ZodString;
165
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
166
+ executionId: z.ZodString;
167
+ bindingId: z.ZodString;
168
+ providerId: z.ZodString;
169
+ }, z.ZodTypeAny, "passthrough">>;
170
+ }, z.ZodTypeAny, "passthrough">>;
171
+ export type SourceDataset = z.infer<typeof sourceDatasetSchema>;
172
+ /** Rendering needs the complete typed contract; inspection deliberately accepts a smaller projection. */
173
+ export declare const renderDatasetSchema: z.ZodObject<{
174
+ schema: z.ZodLiteral<"xpert.analytics.dataset">;
175
+ datasetId: z.ZodString;
176
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, "many">;
177
+ provenance: z.ZodObject<{
178
+ executionId: z.ZodString;
179
+ bindingId: z.ZodString;
180
+ providerId: z.ZodString;
181
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
182
+ executionId: z.ZodString;
183
+ bindingId: z.ZodString;
184
+ providerId: z.ZodString;
185
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
186
+ executionId: z.ZodString;
187
+ bindingId: z.ZodString;
188
+ providerId: z.ZodString;
189
+ }, z.ZodTypeAny, "passthrough">>;
190
+ } & {
191
+ fields: z.ZodArray<z.ZodObject<{
192
+ id: z.ZodString;
193
+ label: z.ZodString;
194
+ sourceField: z.ZodString;
195
+ logicalType: z.ZodEnum<["string", "boolean", "int64", "float64", "decimal", "date", "timestamp"]>;
196
+ nullable: z.ZodBoolean;
197
+ role: z.ZodEnum<["dimension", "measure", "time", "identifier"]>;
198
+ semanticRef: z.ZodOptional<z.ZodString>;
199
+ unit: z.ZodOptional<z.ZodString>;
200
+ }, "strict", z.ZodTypeAny, {
201
+ id: string;
202
+ label: string;
203
+ sourceField: string;
204
+ logicalType: "string" | "boolean" | "date" | "float64" | "int64" | "decimal" | "timestamp";
205
+ nullable: boolean;
206
+ role: "time" | "dimension" | "measure" | "identifier";
207
+ semanticRef?: string | undefined;
208
+ unit?: string | undefined;
209
+ }, {
210
+ id: string;
211
+ label: string;
212
+ sourceField: string;
213
+ logicalType: "string" | "boolean" | "date" | "float64" | "int64" | "decimal" | "timestamp";
214
+ nullable: boolean;
215
+ role: "time" | "dimension" | "measure" | "identifier";
216
+ semanticRef?: string | undefined;
217
+ unit?: string | undefined;
218
+ }>, "many">;
219
+ grain: z.ZodArray<z.ZodString, "many">;
220
+ completeness: z.ZodObject<{
221
+ returnedRows: z.ZodNumber;
222
+ totalRows: z.ZodOptional<z.ZodNumber>;
223
+ totalAccuracy: z.ZodEnum<["exact", "estimated", "unknown"]>;
224
+ scope: z.ZodEnum<["full_query_result", "page", "sample", "top_n"]>;
225
+ truncated: z.ZodBoolean;
226
+ }, "strip", z.ZodTypeAny, {
227
+ scope: "page" | "full_query_result" | "sample" | "top_n";
228
+ truncated: boolean;
229
+ returnedRows: number;
230
+ totalAccuracy: "exact" | "unknown" | "estimated";
231
+ totalRows?: number | undefined;
232
+ }, {
233
+ scope: "page" | "full_query_result" | "sample" | "top_n";
234
+ truncated: boolean;
235
+ returnedRows: number;
236
+ totalAccuracy: "exact" | "unknown" | "estimated";
237
+ totalRows?: number | undefined;
238
+ }>;
239
+ freshness: z.ZodObject<{
240
+ executedAt: z.ZodString;
241
+ sourceFetchedAt: z.ZodString;
242
+ dataAsOf: z.ZodOptional<z.ZodString>;
243
+ }, "strip", z.ZodTypeAny, {
244
+ sourceFetchedAt: string;
245
+ executedAt: string;
246
+ dataAsOf?: string | undefined;
247
+ }, {
248
+ sourceFetchedAt: string;
249
+ executedAt: string;
250
+ dataAsOf?: string | undefined;
251
+ }>;
252
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
253
+ schema: z.ZodLiteral<"xpert.analytics.dataset">;
254
+ datasetId: z.ZodString;
255
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, "many">;
256
+ provenance: z.ZodObject<{
257
+ executionId: z.ZodString;
258
+ bindingId: z.ZodString;
259
+ providerId: z.ZodString;
260
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
261
+ executionId: z.ZodString;
262
+ bindingId: z.ZodString;
263
+ providerId: z.ZodString;
264
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
265
+ executionId: z.ZodString;
266
+ bindingId: z.ZodString;
267
+ providerId: z.ZodString;
268
+ }, z.ZodTypeAny, "passthrough">>;
269
+ } & {
270
+ fields: z.ZodArray<z.ZodObject<{
271
+ id: z.ZodString;
272
+ label: z.ZodString;
273
+ sourceField: z.ZodString;
274
+ logicalType: z.ZodEnum<["string", "boolean", "int64", "float64", "decimal", "date", "timestamp"]>;
275
+ nullable: z.ZodBoolean;
276
+ role: z.ZodEnum<["dimension", "measure", "time", "identifier"]>;
277
+ semanticRef: z.ZodOptional<z.ZodString>;
278
+ unit: z.ZodOptional<z.ZodString>;
279
+ }, "strict", z.ZodTypeAny, {
280
+ id: string;
281
+ label: string;
282
+ sourceField: string;
283
+ logicalType: "string" | "boolean" | "date" | "float64" | "int64" | "decimal" | "timestamp";
284
+ nullable: boolean;
285
+ role: "time" | "dimension" | "measure" | "identifier";
286
+ semanticRef?: string | undefined;
287
+ unit?: string | undefined;
288
+ }, {
289
+ id: string;
290
+ label: string;
291
+ sourceField: string;
292
+ logicalType: "string" | "boolean" | "date" | "float64" | "int64" | "decimal" | "timestamp";
293
+ nullable: boolean;
294
+ role: "time" | "dimension" | "measure" | "identifier";
295
+ semanticRef?: string | undefined;
296
+ unit?: string | undefined;
297
+ }>, "many">;
298
+ grain: z.ZodArray<z.ZodString, "many">;
299
+ completeness: z.ZodObject<{
300
+ returnedRows: z.ZodNumber;
301
+ totalRows: z.ZodOptional<z.ZodNumber>;
302
+ totalAccuracy: z.ZodEnum<["exact", "estimated", "unknown"]>;
303
+ scope: z.ZodEnum<["full_query_result", "page", "sample", "top_n"]>;
304
+ truncated: z.ZodBoolean;
305
+ }, "strip", z.ZodTypeAny, {
306
+ scope: "page" | "full_query_result" | "sample" | "top_n";
307
+ truncated: boolean;
308
+ returnedRows: number;
309
+ totalAccuracy: "exact" | "unknown" | "estimated";
310
+ totalRows?: number | undefined;
311
+ }, {
312
+ scope: "page" | "full_query_result" | "sample" | "top_n";
313
+ truncated: boolean;
314
+ returnedRows: number;
315
+ totalAccuracy: "exact" | "unknown" | "estimated";
316
+ totalRows?: number | undefined;
317
+ }>;
318
+ freshness: z.ZodObject<{
319
+ executedAt: z.ZodString;
320
+ sourceFetchedAt: z.ZodString;
321
+ dataAsOf: z.ZodOptional<z.ZodString>;
322
+ }, "strip", z.ZodTypeAny, {
323
+ sourceFetchedAt: string;
324
+ executedAt: string;
325
+ dataAsOf?: string | undefined;
326
+ }, {
327
+ sourceFetchedAt: string;
328
+ executedAt: string;
329
+ dataAsOf?: string | undefined;
330
+ }>;
331
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
332
+ schema: z.ZodLiteral<"xpert.analytics.dataset">;
333
+ datasetId: z.ZodString;
334
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, "many">;
335
+ provenance: z.ZodObject<{
336
+ executionId: z.ZodString;
337
+ bindingId: z.ZodString;
338
+ providerId: z.ZodString;
339
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
340
+ executionId: z.ZodString;
341
+ bindingId: z.ZodString;
342
+ providerId: z.ZodString;
343
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
344
+ executionId: z.ZodString;
345
+ bindingId: z.ZodString;
346
+ providerId: z.ZodString;
347
+ }, z.ZodTypeAny, "passthrough">>;
348
+ } & {
349
+ fields: z.ZodArray<z.ZodObject<{
350
+ id: z.ZodString;
351
+ label: z.ZodString;
352
+ sourceField: z.ZodString;
353
+ logicalType: z.ZodEnum<["string", "boolean", "int64", "float64", "decimal", "date", "timestamp"]>;
354
+ nullable: z.ZodBoolean;
355
+ role: z.ZodEnum<["dimension", "measure", "time", "identifier"]>;
356
+ semanticRef: z.ZodOptional<z.ZodString>;
357
+ unit: z.ZodOptional<z.ZodString>;
358
+ }, "strict", z.ZodTypeAny, {
359
+ id: string;
360
+ label: string;
361
+ sourceField: string;
362
+ logicalType: "string" | "boolean" | "date" | "float64" | "int64" | "decimal" | "timestamp";
363
+ nullable: boolean;
364
+ role: "time" | "dimension" | "measure" | "identifier";
365
+ semanticRef?: string | undefined;
366
+ unit?: string | undefined;
367
+ }, {
368
+ id: string;
369
+ label: string;
370
+ sourceField: string;
371
+ logicalType: "string" | "boolean" | "date" | "float64" | "int64" | "decimal" | "timestamp";
372
+ nullable: boolean;
373
+ role: "time" | "dimension" | "measure" | "identifier";
374
+ semanticRef?: string | undefined;
375
+ unit?: string | undefined;
376
+ }>, "many">;
377
+ grain: z.ZodArray<z.ZodString, "many">;
378
+ completeness: z.ZodObject<{
379
+ returnedRows: z.ZodNumber;
380
+ totalRows: z.ZodOptional<z.ZodNumber>;
381
+ totalAccuracy: z.ZodEnum<["exact", "estimated", "unknown"]>;
382
+ scope: z.ZodEnum<["full_query_result", "page", "sample", "top_n"]>;
383
+ truncated: z.ZodBoolean;
384
+ }, "strip", z.ZodTypeAny, {
385
+ scope: "page" | "full_query_result" | "sample" | "top_n";
386
+ truncated: boolean;
387
+ returnedRows: number;
388
+ totalAccuracy: "exact" | "unknown" | "estimated";
389
+ totalRows?: number | undefined;
390
+ }, {
391
+ scope: "page" | "full_query_result" | "sample" | "top_n";
392
+ truncated: boolean;
393
+ returnedRows: number;
394
+ totalAccuracy: "exact" | "unknown" | "estimated";
395
+ totalRows?: number | undefined;
396
+ }>;
397
+ freshness: z.ZodObject<{
398
+ executedAt: z.ZodString;
399
+ sourceFetchedAt: z.ZodString;
400
+ dataAsOf: z.ZodOptional<z.ZodString>;
401
+ }, "strip", z.ZodTypeAny, {
402
+ sourceFetchedAt: string;
403
+ executedAt: string;
404
+ dataAsOf?: string | undefined;
405
+ }, {
406
+ sourceFetchedAt: string;
407
+ executedAt: string;
408
+ dataAsOf?: string | undefined;
409
+ }>;
410
+ }, z.ZodTypeAny, "passthrough">>;
411
+ export interface SourceExecution {
412
+ requestId: string;
413
+ state: 'queued' | 'running' | 'succeeded' | 'failed';
414
+ controls: Record<string, string | number | boolean | null>;
415
+ requestedAt: string;
416
+ startedAt?: string;
417
+ finishedAt?: string;
418
+ result?: SourceDataset;
419
+ resultControls?: SourceExecution['controls'];
420
+ previewEvicted?: boolean;
421
+ }
422
+ export type SourceEvent = {
423
+ bindingId: string;
424
+ requestId: string;
425
+ } & ({
426
+ type: 'queue' | 'start';
427
+ controls: SourceExecution['controls'];
428
+ at: string;
429
+ } | {
430
+ type: 'success';
431
+ result: SourceDataset;
432
+ at: string;
433
+ } | {
434
+ type: 'failure';
435
+ at: string;
436
+ });
437
+ export declare function reduceSourceExecutions(state: Record<string, SourceExecution>, event: SourceEvent): Record<string, SourceExecution>;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderDatasetSchema = exports.sourceDatasetSchema = void 0;
4
+ exports.reduceSourceExecutions = reduceSourceExecutions;
5
+ const v3_1 = require("zod/v3");
6
+ const analytics_1 = require("@xpert-ai/plugin-sdk/analytics");
7
+ const scalar = v3_1.z.union([v3_1.z.string(), v3_1.z.number(), v3_1.z.boolean(), v3_1.z.null()]);
8
+ exports.sourceDatasetSchema = v3_1.z.object({
9
+ schema: v3_1.z.literal('xpert.analytics.dataset'), datasetId: v3_1.z.string(),
10
+ fields: v3_1.z.array(v3_1.z.object({ id: v3_1.z.string(), label: v3_1.z.string().optional() }).passthrough()), rows: v3_1.z.array(v3_1.z.record(scalar)),
11
+ completeness: v3_1.z.object({ truncated: v3_1.z.boolean(), returnedRows: v3_1.z.number(), scope: v3_1.z.string(), totalAccuracy: v3_1.z.string() }).passthrough(),
12
+ freshness: v3_1.z.object({ sourceFetchedAt: v3_1.z.string(), executedAt: v3_1.z.string().optional(), dataAsOf: v3_1.z.string().optional() }),
13
+ provenance: v3_1.z.object({ executionId: v3_1.z.string(), bindingId: v3_1.z.string(), providerId: v3_1.z.string() }).passthrough()
14
+ }).passthrough();
15
+ /** Rendering needs the complete typed contract; inspection deliberately accepts a smaller projection. */
16
+ exports.renderDatasetSchema = exports.sourceDatasetSchema.extend({
17
+ fields: v3_1.z.array(analytics_1.analyticsFieldSchema.required({ id: true, sourceField: true, label: true, logicalType: true, nullable: true, role: true })), grain: v3_1.z.array(v3_1.z.string()),
18
+ completeness: v3_1.z.object({ returnedRows: v3_1.z.number(), totalRows: v3_1.z.number().optional(), totalAccuracy: v3_1.z.enum(['exact', 'estimated', 'unknown']),
19
+ scope: v3_1.z.enum(['full_query_result', 'page', 'sample', 'top_n']), truncated: v3_1.z.boolean() }),
20
+ freshness: v3_1.z.object({ executedAt: v3_1.z.string(), sourceFetchedAt: v3_1.z.string(), dataAsOf: v3_1.z.string().optional() })
21
+ });
22
+ function reduceSourceExecutions(state, event) {
23
+ const previous = state[event.bindingId];
24
+ if (event.type === 'start' || event.type === 'queue')
25
+ return { ...state, [event.bindingId]: {
26
+ requestId: event.requestId, state: event.type === 'queue' ? 'queued' : 'running', controls: event.controls,
27
+ requestedAt: previous?.requestId === event.requestId ? previous.requestedAt : event.at,
28
+ ...(event.type === 'start' ? { startedAt: event.at } : {}),
29
+ result: previous?.result, resultControls: previous?.resultControls
30
+ } };
31
+ if (!previous || previous.requestId !== event.requestId)
32
+ return state;
33
+ const next = { ...state, [event.bindingId]: { ...previous, state: event.type === 'success' ? 'succeeded' : 'failed', finishedAt: event.at,
34
+ ...(event.type === 'success' ? { result: preview(event.result), resultControls: previous.controls, previewEvicted: false } : {}) } };
35
+ // Limit inspection snapshots independently of the rendering result budget.
36
+ const byAge = Object.values(next).filter(item => item.result).sort((a, b) => (a.finishedAt ?? '').localeCompare(b.finishedAt ?? ''));
37
+ while (new TextEncoder().encode(JSON.stringify(Object.values(next).map(item => item.result ?? null))).byteLength > 2_000_000 && byAge.length) {
38
+ const oldest = byAge.shift();
39
+ const id = Object.keys(next).find(id => next[id] === oldest);
40
+ next[id] = { ...oldest, result: undefined, resultControls: undefined, previewEvicted: true };
41
+ }
42
+ return next;
43
+ }
44
+ function preview(result) {
45
+ const rows = result.rows.slice(0, 50);
46
+ while (new TextEncoder().encode(JSON.stringify(rows)).byteLength > 64_000)
47
+ rows.pop();
48
+ return { ...result, rows };
49
+ }
@@ -0,0 +1,2 @@
1
+ import type { DashboardManifest } from './dashboard.schema';
2
+ export declare function assertComponentElements(manifest: DashboardManifest): void;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertComponentElements = assertComponentElements;
4
+ const parse5_1 = require("parse5");
5
+ function assertComponentElements(manifest) {
6
+ if (!manifest.presentation || !manifest.components?.length)
7
+ return;
8
+ const ids = new Map();
9
+ const visit = (node) => {
10
+ if ('attrs' in node)
11
+ for (const attr of node.attrs)
12
+ if (attr.name === 'id')
13
+ ids.set(attr.value, (ids.get(attr.value) ?? 0) + 1);
14
+ if ('childNodes' in node)
15
+ node.childNodes.forEach(visit);
16
+ };
17
+ visit((0, parse5_1.parse)(manifest.presentation.html));
18
+ for (const component of manifest.components)
19
+ if (ids.get(component.elementId) !== 1)
20
+ throw new Error(`DASHBOARD_COMPONENT_ELEMENT_INVALID: ${component.id}`);
21
+ }