@elaraai/e3-ui 1.0.84 → 1.0.86

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 (65) hide show
  1. package/dist/src/bind/data.d.ts +4 -3
  2. package/dist/src/bind/data.d.ts.map +1 -1
  3. package/dist/src/bind/data.js +4 -3
  4. package/dist/src/bind/data.js.map +1 -1
  5. package/dist/src/bind/record.d.ts +5 -2
  6. package/dist/src/bind/record.d.ts.map +1 -1
  7. package/dist/src/bind/record.js +5 -2
  8. package/dist/src/bind/record.js.map +1 -1
  9. package/dist/src/bind/sources.d.ts +148 -0
  10. package/dist/src/bind/sources.d.ts.map +1 -0
  11. package/dist/src/bind/sources.js +116 -0
  12. package/dist/src/bind/sources.js.map +1 -0
  13. package/dist/src/index.d.ts +2 -0
  14. package/dist/src/index.d.ts.map +1 -1
  15. package/dist/src/index.js +5 -0
  16. package/dist/src/index.js.map +1 -1
  17. package/dist/src/internal.d.ts +2 -0
  18. package/dist/src/internal.d.ts.map +1 -1
  19. package/dist/src/internal.js +6 -0
  20. package/dist/src/internal.js.map +1 -1
  21. package/dist/src/query/builder.d.ts +3257 -0
  22. package/dist/src/query/builder.d.ts.map +1 -0
  23. package/dist/src/query/builder.js +126 -0
  24. package/dist/src/query/builder.js.map +1 -0
  25. package/dist/src/query/index.d.ts +108 -0
  26. package/dist/src/query/index.d.ts.map +1 -0
  27. package/dist/src/query/index.js +76 -0
  28. package/dist/src/query/index.js.map +1 -0
  29. package/dist/src/query/library.d.ts +3241 -0
  30. package/dist/src/query/library.d.ts.map +1 -0
  31. package/dist/src/query/library.js +114 -0
  32. package/dist/src/query/library.js.map +1 -0
  33. package/dist/src/query/queries.d.ts +4696 -0
  34. package/dist/src/query/queries.d.ts.map +1 -0
  35. package/dist/src/query/queries.js +129 -0
  36. package/dist/src/query/queries.js.map +1 -0
  37. package/dist/src/query/saved.d.ts +72 -0
  38. package/dist/src/query/saved.d.ts.map +1 -0
  39. package/dist/src/query/saved.js +84 -0
  40. package/dist/src/query/saved.js.map +1 -0
  41. package/dist/src/query/steps.d.ts +613 -0
  42. package/dist/src/query/steps.d.ts.map +1 -0
  43. package/dist/src/query/steps.js +316 -0
  44. package/dist/src/query/steps.js.map +1 -0
  45. package/dist/src/query/types.d.ts +444 -0
  46. package/dist/src/query/types.d.ts.map +1 -0
  47. package/dist/src/query/types.js +113 -0
  48. package/dist/src/query/types.js.map +1 -0
  49. package/dist/src/ui.d.ts +16 -3
  50. package/dist/src/ui.d.ts.map +1 -1
  51. package/dist/src/ui.js +21 -1
  52. package/dist/src/ui.js.map +1 -1
  53. package/dist/test/bind/data/data.examples.d.ts +76 -1
  54. package/dist/test/bind/data/data.examples.d.ts.map +1 -1
  55. package/dist/test/bind/data/data.examples.js +176 -3
  56. package/dist/test/bind/data/data.examples.js.map +1 -1
  57. package/dist/test/bind/func/func.examples.d.ts +8 -0
  58. package/dist/test/bind/func/func.examples.d.ts.map +1 -1
  59. package/dist/test/bind/func/func.examples.js +4 -3
  60. package/dist/test/bind/func/func.examples.js.map +1 -1
  61. package/dist/test/query/query.examples.d.ts +5022 -0
  62. package/dist/test/query/query.examples.d.ts.map +1 -0
  63. package/dist/test/query/query.examples.js +467 -0
  64. package/dist/test/query/query.examples.js.map +1 -0
  65. package/package.json +9 -9
@@ -0,0 +1,444 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ /**
6
+ * The query builder's records and answers (#935): the saved queries a
7
+ * solution declares as one record, the data sources a query reads, and what a
8
+ * run of a query answers.
9
+ *
10
+ * A saved query is its program as written — a `JqType` tree, never text to
11
+ * parse again and never the IR the builder translates it to on each run — and
12
+ * the data sources it reads. Its types are never stored: they are what
13
+ * checking the program against those data sources gives (#1138). A solution
14
+ * declares the record as Studio's pages are declared, empty or with its value
15
+ * from `Query.value`, the queries it ships, checked:
16
+ *
17
+ * ```ts
18
+ * export const queries = e3.record("queries", Query.Types.Saved, new Map());
19
+ * export const queriesPatch = e3.mutation.patch(queries);
20
+ * ```
21
+ *
22
+ * The types never depend on the data sources, so a deploy that adds or
23
+ * changes one runs no migration.
24
+ *
25
+ * @packageDocumentation
26
+ */
27
+ import { ArrayType, BlobType, BooleanType, DateTimeType, DictType, IntegerType, OptionType, StringType, StructType, VariantType } from "@elaraai/east";
28
+ /**
29
+ * A data source of a query's root: the root field a query reads it by, and
30
+ * the dataset it is.
31
+ *
32
+ * @property name - The root field: `orders` for `.orders`
33
+ * @property path - The dataset's path in the workspace
34
+ */
35
+ export declare const QueryRootEntryType: StructType<{
36
+ readonly name: StringType;
37
+ readonly path: ArrayType<VariantType<{
38
+ readonly field: StringType;
39
+ }>>;
40
+ }>;
41
+ /** Type representing a data source of a query's root. */
42
+ export type QueryRootEntryType = typeof QueryRootEntryType;
43
+ /**
44
+ * A dataset a run read: its root field, its path, and the hash it was pinned
45
+ * at, so an answer can be reproduced and a stale one noticed.
46
+ *
47
+ * @property hash - The dataset's content hash when the run read it
48
+ * @property name - Its root field
49
+ * @property path - Its path in the workspace
50
+ */
51
+ export declare const QueryInputType: StructType<{
52
+ readonly hash: StringType;
53
+ readonly name: StringType;
54
+ readonly path: ArrayType<VariantType<{
55
+ readonly field: StringType;
56
+ }>>;
57
+ }>;
58
+ /** Type representing a dataset a run read. */
59
+ export type QueryInputType = typeof QueryInputType;
60
+ /**
61
+ * What a run of a query answered.
62
+ *
63
+ * @property inputs - The datasets it read, each pinned at its hash, in the
64
+ * order the query reads them; empty when nothing ran
65
+ * @property outcome - How it ended:
66
+ * - `error` — the checker's problems, or the error the query raised as it
67
+ * ran (`runtime`, located in the jq), or a dataset with no value yet;
68
+ * - `needs_platform` — it calls functions this server cannot run;
69
+ * - `ok` — `result` is the answer, self-describing beast2; `outputs` counts
70
+ * the outputs it holds, and `truncated` says a `many` query gave more than
71
+ * it was allowed, the rest left out;
72
+ * - `timed_out` — it ran out of time after `ms`;
73
+ * - `too_large` — its answer was `bytes` long, over `limit`
74
+ */
75
+ export declare const QueryResultType: StructType<{
76
+ readonly inputs: ArrayType<StructType<{
77
+ readonly hash: StringType;
78
+ readonly name: StringType;
79
+ readonly path: ArrayType<VariantType<{
80
+ readonly field: StringType;
81
+ }>>;
82
+ }>>;
83
+ readonly outcome: VariantType<{
84
+ readonly error: ArrayType<StructType<{
85
+ readonly code: StringType;
86
+ readonly fixes: ArrayType<StructType<{
87
+ readonly edits: ArrayType<StructType<{
88
+ readonly insert: StringType;
89
+ readonly length: IntegerType;
90
+ readonly offset: IntegerType;
91
+ }>>;
92
+ readonly label: StringType;
93
+ }>>;
94
+ readonly message: StringType;
95
+ readonly severity: VariantType<{
96
+ readonly error: import("@elaraai/east").NullType;
97
+ readonly warning: import("@elaraai/east").NullType;
98
+ }>;
99
+ readonly span: OptionType<StructType<{
100
+ readonly column: IntegerType;
101
+ readonly length: IntegerType;
102
+ readonly line: IntegerType;
103
+ readonly offset: IntegerType;
104
+ }>>;
105
+ readonly suggestions: ArrayType<StringType>;
106
+ }>>;
107
+ readonly needs_platform: StructType<{
108
+ readonly functions: ArrayType<StringType>;
109
+ }>;
110
+ readonly ok: StructType<{
111
+ readonly outputs: IntegerType;
112
+ readonly result: BlobType;
113
+ readonly truncated: BooleanType;
114
+ }>;
115
+ readonly timed_out: StructType<{
116
+ readonly ms: IntegerType;
117
+ }>;
118
+ readonly too_large: StructType<{
119
+ readonly bytes: IntegerType;
120
+ readonly limit: IntegerType;
121
+ }>;
122
+ }>;
123
+ }>;
124
+ /** Type representing what a run of a query answered. */
125
+ export type QueryResultType = typeof QueryResultType;
126
+ /**
127
+ * A saved query.
128
+ *
129
+ * @property name - Its name, which is its key in the record
130
+ * @property description - One sentence, at most 140 characters; with none,
131
+ * the sentence generated from its steps shows instead
132
+ * @property program - The program as written, checked against the whole root
133
+ * it was saved on: a query saves only once it checks. Its types are what
134
+ * checking it against its data sources gives, and are never stored.
135
+ * @property root - The data sources it reads, in root order. It opens only
136
+ * where each is bound, by the same name and at the same path, so it never
137
+ * reads another page's dataset of the same name.
138
+ * @property saved_at - When it was last saved
139
+ */
140
+ export declare const SavedQueryType: StructType<{
141
+ readonly name: StringType;
142
+ readonly description: OptionType<StringType>;
143
+ readonly program: import("@elaraai/east").RecursiveType<VariantType<{
144
+ readonly alternative: StructType<{
145
+ readonly left: import("@elaraai/east").RecursiveTypeMarker;
146
+ readonly right: import("@elaraai/east").RecursiveTypeMarker;
147
+ }>;
148
+ readonly array: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
149
+ readonly binary: StructType<{
150
+ readonly left: import("@elaraai/east").RecursiveTypeMarker;
151
+ readonly op: StringType;
152
+ readonly right: import("@elaraai/east").RecursiveTypeMarker;
153
+ }>;
154
+ readonly bind: StructType<{
155
+ readonly body: import("@elaraai/east").RecursiveTypeMarker;
156
+ readonly patterns: ArrayType<import("@elaraai/east").RecursiveType<VariantType<{
157
+ readonly array: ArrayType<import("@elaraai/east").RecursiveTypeMarker>;
158
+ readonly object: ArrayType<StructType<{
159
+ readonly key: StringType;
160
+ readonly value: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
161
+ }>>;
162
+ readonly variable: StringType;
163
+ }>>>;
164
+ readonly source: import("@elaraai/east").RecursiveTypeMarker;
165
+ }>;
166
+ readonly break: StringType;
167
+ readonly call: StructType<{
168
+ readonly args: ArrayType<import("@elaraai/east").RecursiveTypeMarker>;
169
+ readonly name: StringType;
170
+ }>;
171
+ readonly comma: StructType<{
172
+ readonly left: import("@elaraai/east").RecursiveTypeMarker;
173
+ readonly right: import("@elaraai/east").RecursiveTypeMarker;
174
+ }>;
175
+ readonly def: StructType<{
176
+ readonly body: import("@elaraai/east").RecursiveTypeMarker;
177
+ readonly name: StringType;
178
+ readonly params: ArrayType<StringType>;
179
+ readonly rest: import("@elaraai/east").RecursiveTypeMarker;
180
+ }>;
181
+ readonly descend: import("@elaraai/east").NullType;
182
+ readonly field: StructType<{
183
+ readonly name: StringType;
184
+ readonly optional: BooleanType;
185
+ readonly target: import("@elaraai/east").RecursiveTypeMarker;
186
+ }>;
187
+ readonly foreach: StructType<{
188
+ readonly extract: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
189
+ readonly init: import("@elaraai/east").RecursiveTypeMarker;
190
+ readonly pattern: import("@elaraai/east").RecursiveType<VariantType<{
191
+ readonly array: ArrayType<import("@elaraai/east").RecursiveTypeMarker>;
192
+ readonly object: ArrayType<StructType<{
193
+ readonly key: StringType;
194
+ readonly value: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
195
+ }>>;
196
+ readonly variable: StringType;
197
+ }>>;
198
+ readonly source: import("@elaraai/east").RecursiveTypeMarker;
199
+ readonly update: import("@elaraai/east").RecursiveTypeMarker;
200
+ }>;
201
+ readonly format: StructType<{
202
+ readonly name: StringType;
203
+ readonly string: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
204
+ }>;
205
+ readonly identity: import("@elaraai/east").NullType;
206
+ readonly if: StructType<{
207
+ readonly branches: ArrayType<StructType<{
208
+ readonly condition: import("@elaraai/east").RecursiveTypeMarker;
209
+ readonly then: import("@elaraai/east").RecursiveTypeMarker;
210
+ }>>;
211
+ readonly otherwise: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
212
+ }>;
213
+ readonly index: StructType<{
214
+ readonly index: import("@elaraai/east").RecursiveTypeMarker;
215
+ readonly optional: BooleanType;
216
+ readonly target: import("@elaraai/east").RecursiveTypeMarker;
217
+ }>;
218
+ readonly iterate: StructType<{
219
+ readonly optional: BooleanType;
220
+ readonly target: import("@elaraai/east").RecursiveTypeMarker;
221
+ }>;
222
+ readonly label: StructType<{
223
+ readonly body: import("@elaraai/east").RecursiveTypeMarker;
224
+ readonly name: StringType;
225
+ }>;
226
+ readonly literal: VariantType<{
227
+ readonly boolean: BooleanType;
228
+ readonly float: import("@elaraai/east").FloatType;
229
+ readonly integer: IntegerType;
230
+ readonly null: import("@elaraai/east").NullType;
231
+ readonly string: StringType;
232
+ }>;
233
+ readonly negate: import("@elaraai/east").RecursiveTypeMarker;
234
+ readonly object: ArrayType<StructType<{
235
+ readonly key: VariantType<{
236
+ readonly computed: import("@elaraai/east").RecursiveTypeMarker;
237
+ readonly name: StringType;
238
+ readonly variable: StringType;
239
+ }>;
240
+ readonly value: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
241
+ }>>;
242
+ readonly pipe: StructType<{
243
+ readonly left: import("@elaraai/east").RecursiveTypeMarker;
244
+ readonly right: import("@elaraai/east").RecursiveTypeMarker;
245
+ }>;
246
+ readonly reduce: StructType<{
247
+ readonly init: import("@elaraai/east").RecursiveTypeMarker;
248
+ readonly pattern: import("@elaraai/east").RecursiveType<VariantType<{
249
+ readonly array: ArrayType<import("@elaraai/east").RecursiveTypeMarker>;
250
+ readonly object: ArrayType<StructType<{
251
+ readonly key: StringType;
252
+ readonly value: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
253
+ }>>;
254
+ readonly variable: StringType;
255
+ }>>;
256
+ readonly source: import("@elaraai/east").RecursiveTypeMarker;
257
+ readonly update: import("@elaraai/east").RecursiveTypeMarker;
258
+ }>;
259
+ readonly slice: StructType<{
260
+ readonly from: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
261
+ readonly optional: BooleanType;
262
+ readonly target: import("@elaraai/east").RecursiveTypeMarker;
263
+ readonly to: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
264
+ }>;
265
+ readonly string: ArrayType<VariantType<{
266
+ readonly interpolate: import("@elaraai/east").RecursiveTypeMarker;
267
+ readonly text: StringType;
268
+ }>>;
269
+ readonly try: StructType<{
270
+ readonly body: import("@elaraai/east").RecursiveTypeMarker;
271
+ readonly catch: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
272
+ }>;
273
+ readonly update: StructType<{
274
+ readonly op: StringType;
275
+ readonly path: import("@elaraai/east").RecursiveTypeMarker;
276
+ readonly value: import("@elaraai/east").RecursiveTypeMarker;
277
+ }>;
278
+ readonly variable: StringType;
279
+ }>>;
280
+ readonly root: ArrayType<StructType<{
281
+ readonly name: StringType;
282
+ readonly path: ArrayType<VariantType<{
283
+ readonly field: StringType;
284
+ }>>;
285
+ }>>;
286
+ readonly saved_at: DateTimeType;
287
+ }>;
288
+ /** Type representing a saved query. */
289
+ export type SavedQueryType = typeof SavedQueryType;
290
+ /**
291
+ * The saved queries record's type — every saved query, by name. A solution
292
+ * declares its record with it: `e3.record("queries", Query.Types.Saved, new Map())`.
293
+ */
294
+ export declare const SavedQueriesType: DictType<StringType, StructType<{
295
+ readonly name: StringType;
296
+ readonly description: OptionType<StringType>;
297
+ readonly program: import("@elaraai/east").RecursiveType<VariantType<{
298
+ readonly alternative: StructType<{
299
+ readonly left: import("@elaraai/east").RecursiveTypeMarker;
300
+ readonly right: import("@elaraai/east").RecursiveTypeMarker;
301
+ }>;
302
+ readonly array: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
303
+ readonly binary: StructType<{
304
+ readonly left: import("@elaraai/east").RecursiveTypeMarker;
305
+ readonly op: StringType;
306
+ readonly right: import("@elaraai/east").RecursiveTypeMarker;
307
+ }>;
308
+ readonly bind: StructType<{
309
+ readonly body: import("@elaraai/east").RecursiveTypeMarker;
310
+ readonly patterns: ArrayType<import("@elaraai/east").RecursiveType<VariantType<{
311
+ readonly array: ArrayType<import("@elaraai/east").RecursiveTypeMarker>;
312
+ readonly object: ArrayType<StructType<{
313
+ readonly key: StringType;
314
+ readonly value: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
315
+ }>>;
316
+ readonly variable: StringType;
317
+ }>>>;
318
+ readonly source: import("@elaraai/east").RecursiveTypeMarker;
319
+ }>;
320
+ readonly break: StringType;
321
+ readonly call: StructType<{
322
+ readonly args: ArrayType<import("@elaraai/east").RecursiveTypeMarker>;
323
+ readonly name: StringType;
324
+ }>;
325
+ readonly comma: StructType<{
326
+ readonly left: import("@elaraai/east").RecursiveTypeMarker;
327
+ readonly right: import("@elaraai/east").RecursiveTypeMarker;
328
+ }>;
329
+ readonly def: StructType<{
330
+ readonly body: import("@elaraai/east").RecursiveTypeMarker;
331
+ readonly name: StringType;
332
+ readonly params: ArrayType<StringType>;
333
+ readonly rest: import("@elaraai/east").RecursiveTypeMarker;
334
+ }>;
335
+ readonly descend: import("@elaraai/east").NullType;
336
+ readonly field: StructType<{
337
+ readonly name: StringType;
338
+ readonly optional: BooleanType;
339
+ readonly target: import("@elaraai/east").RecursiveTypeMarker;
340
+ }>;
341
+ readonly foreach: StructType<{
342
+ readonly extract: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
343
+ readonly init: import("@elaraai/east").RecursiveTypeMarker;
344
+ readonly pattern: import("@elaraai/east").RecursiveType<VariantType<{
345
+ readonly array: ArrayType<import("@elaraai/east").RecursiveTypeMarker>;
346
+ readonly object: ArrayType<StructType<{
347
+ readonly key: StringType;
348
+ readonly value: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
349
+ }>>;
350
+ readonly variable: StringType;
351
+ }>>;
352
+ readonly source: import("@elaraai/east").RecursiveTypeMarker;
353
+ readonly update: import("@elaraai/east").RecursiveTypeMarker;
354
+ }>;
355
+ readonly format: StructType<{
356
+ readonly name: StringType;
357
+ readonly string: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
358
+ }>;
359
+ readonly identity: import("@elaraai/east").NullType;
360
+ readonly if: StructType<{
361
+ readonly branches: ArrayType<StructType<{
362
+ readonly condition: import("@elaraai/east").RecursiveTypeMarker;
363
+ readonly then: import("@elaraai/east").RecursiveTypeMarker;
364
+ }>>;
365
+ readonly otherwise: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
366
+ }>;
367
+ readonly index: StructType<{
368
+ readonly index: import("@elaraai/east").RecursiveTypeMarker;
369
+ readonly optional: BooleanType;
370
+ readonly target: import("@elaraai/east").RecursiveTypeMarker;
371
+ }>;
372
+ readonly iterate: StructType<{
373
+ readonly optional: BooleanType;
374
+ readonly target: import("@elaraai/east").RecursiveTypeMarker;
375
+ }>;
376
+ readonly label: StructType<{
377
+ readonly body: import("@elaraai/east").RecursiveTypeMarker;
378
+ readonly name: StringType;
379
+ }>;
380
+ readonly literal: VariantType<{
381
+ readonly boolean: BooleanType;
382
+ readonly float: import("@elaraai/east").FloatType;
383
+ readonly integer: IntegerType;
384
+ readonly null: import("@elaraai/east").NullType;
385
+ readonly string: StringType;
386
+ }>;
387
+ readonly negate: import("@elaraai/east").RecursiveTypeMarker;
388
+ readonly object: ArrayType<StructType<{
389
+ readonly key: VariantType<{
390
+ readonly computed: import("@elaraai/east").RecursiveTypeMarker;
391
+ readonly name: StringType;
392
+ readonly variable: StringType;
393
+ }>;
394
+ readonly value: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
395
+ }>>;
396
+ readonly pipe: StructType<{
397
+ readonly left: import("@elaraai/east").RecursiveTypeMarker;
398
+ readonly right: import("@elaraai/east").RecursiveTypeMarker;
399
+ }>;
400
+ readonly reduce: StructType<{
401
+ readonly init: import("@elaraai/east").RecursiveTypeMarker;
402
+ readonly pattern: import("@elaraai/east").RecursiveType<VariantType<{
403
+ readonly array: ArrayType<import("@elaraai/east").RecursiveTypeMarker>;
404
+ readonly object: ArrayType<StructType<{
405
+ readonly key: StringType;
406
+ readonly value: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
407
+ }>>;
408
+ readonly variable: StringType;
409
+ }>>;
410
+ readonly source: import("@elaraai/east").RecursiveTypeMarker;
411
+ readonly update: import("@elaraai/east").RecursiveTypeMarker;
412
+ }>;
413
+ readonly slice: StructType<{
414
+ readonly from: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
415
+ readonly optional: BooleanType;
416
+ readonly target: import("@elaraai/east").RecursiveTypeMarker;
417
+ readonly to: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
418
+ }>;
419
+ readonly string: ArrayType<VariantType<{
420
+ readonly interpolate: import("@elaraai/east").RecursiveTypeMarker;
421
+ readonly text: StringType;
422
+ }>>;
423
+ readonly try: StructType<{
424
+ readonly body: import("@elaraai/east").RecursiveTypeMarker;
425
+ readonly catch: OptionType<import("@elaraai/east").RecursiveTypeMarker>;
426
+ }>;
427
+ readonly update: StructType<{
428
+ readonly op: StringType;
429
+ readonly path: import("@elaraai/east").RecursiveTypeMarker;
430
+ readonly value: import("@elaraai/east").RecursiveTypeMarker;
431
+ }>;
432
+ readonly variable: StringType;
433
+ }>>;
434
+ readonly root: ArrayType<StructType<{
435
+ readonly name: StringType;
436
+ readonly path: ArrayType<VariantType<{
437
+ readonly field: StringType;
438
+ }>>;
439
+ }>>;
440
+ readonly saved_at: DateTimeType;
441
+ }>>;
442
+ /** Type representing the saved queries record. */
443
+ export type SavedQueriesType = typeof SavedQueriesType;
444
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/query/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EACH,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,WAAW,EAEX,UAAU,EAEV,UAAU,EACV,UAAU,EACV,WAAW,EACd,MAAM,eAAe,CAAC;AAOvB;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;;;;;EAG7B,CAAC;AAEH,yDAAyD;AACzD,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC;AAE3D;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;;;;;;EAIzB,CAAC;AAEH,8CAA8C;AAC9C,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC;AAMnD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS1B,CAAC;AAEH,wDAAwD;AACxD,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC;AAMrD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMzB,CAAC;AAEH,uCAAuC;AACvC,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAuC,CAAC;AAErE,kDAAkD;AAClD,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ /**
6
+ * The query builder's records and answers (#935): the saved queries a
7
+ * solution declares as one record, the data sources a query reads, and what a
8
+ * run of a query answers.
9
+ *
10
+ * A saved query is its program as written — a `JqType` tree, never text to
11
+ * parse again and never the IR the builder translates it to on each run — and
12
+ * the data sources it reads. Its types are never stored: they are what
13
+ * checking the program against those data sources gives (#1138). A solution
14
+ * declares the record as Studio's pages are declared, empty or with its value
15
+ * from `Query.value`, the queries it ships, checked:
16
+ *
17
+ * ```ts
18
+ * export const queries = e3.record("queries", Query.Types.Saved, new Map());
19
+ * export const queriesPatch = e3.mutation.patch(queries);
20
+ * ```
21
+ *
22
+ * The types never depend on the data sources, so a deploy that adds or
23
+ * changes one runs no migration.
24
+ *
25
+ * @packageDocumentation
26
+ */
27
+ import { ArrayType, BlobType, BooleanType, DateTimeType, DictType, IntegerType, JqType, OptionType, QueryErrorType, StringType, StructType, VariantType, } from "@elaraai/east";
28
+ import { TreePathType } from "@elaraai/e3-types";
29
+ // ============================================================================
30
+ // The root
31
+ // ============================================================================
32
+ /**
33
+ * A data source of a query's root: the root field a query reads it by, and
34
+ * the dataset it is.
35
+ *
36
+ * @property name - The root field: `orders` for `.orders`
37
+ * @property path - The dataset's path in the workspace
38
+ */
39
+ export const QueryRootEntryType = StructType({
40
+ name: StringType,
41
+ path: TreePathType,
42
+ });
43
+ /**
44
+ * A dataset a run read: its root field, its path, and the hash it was pinned
45
+ * at, so an answer can be reproduced and a stale one noticed.
46
+ *
47
+ * @property hash - The dataset's content hash when the run read it
48
+ * @property name - Its root field
49
+ * @property path - Its path in the workspace
50
+ */
51
+ export const QueryInputType = StructType({
52
+ hash: StringType,
53
+ name: StringType,
54
+ path: TreePathType,
55
+ });
56
+ // ============================================================================
57
+ // A run's answer
58
+ // ============================================================================
59
+ /**
60
+ * What a run of a query answered.
61
+ *
62
+ * @property inputs - The datasets it read, each pinned at its hash, in the
63
+ * order the query reads them; empty when nothing ran
64
+ * @property outcome - How it ended:
65
+ * - `error` — the checker's problems, or the error the query raised as it
66
+ * ran (`runtime`, located in the jq), or a dataset with no value yet;
67
+ * - `needs_platform` — it calls functions this server cannot run;
68
+ * - `ok` — `result` is the answer, self-describing beast2; `outputs` counts
69
+ * the outputs it holds, and `truncated` says a `many` query gave more than
70
+ * it was allowed, the rest left out;
71
+ * - `timed_out` — it ran out of time after `ms`;
72
+ * - `too_large` — its answer was `bytes` long, over `limit`
73
+ */
74
+ export const QueryResultType = StructType({
75
+ inputs: ArrayType(QueryInputType),
76
+ outcome: VariantType({
77
+ error: ArrayType(QueryErrorType),
78
+ needs_platform: StructType({ functions: ArrayType(StringType) }),
79
+ ok: StructType({ outputs: IntegerType, result: BlobType, truncated: BooleanType }),
80
+ timed_out: StructType({ ms: IntegerType }),
81
+ too_large: StructType({ bytes: IntegerType, limit: IntegerType }),
82
+ }),
83
+ });
84
+ // ============================================================================
85
+ // The saved queries
86
+ // ============================================================================
87
+ /**
88
+ * A saved query.
89
+ *
90
+ * @property name - Its name, which is its key in the record
91
+ * @property description - One sentence, at most 140 characters; with none,
92
+ * the sentence generated from its steps shows instead
93
+ * @property program - The program as written, checked against the whole root
94
+ * it was saved on: a query saves only once it checks. Its types are what
95
+ * checking it against its data sources gives, and are never stored.
96
+ * @property root - The data sources it reads, in root order. It opens only
97
+ * where each is bound, by the same name and at the same path, so it never
98
+ * reads another page's dataset of the same name.
99
+ * @property saved_at - When it was last saved
100
+ */
101
+ export const SavedQueryType = StructType({
102
+ name: StringType,
103
+ description: OptionType(StringType),
104
+ program: JqType,
105
+ root: ArrayType(QueryRootEntryType),
106
+ saved_at: DateTimeType,
107
+ });
108
+ /**
109
+ * The saved queries record's type — every saved query, by name. A solution
110
+ * declares its record with it: `e3.record("queries", Query.Types.Saved, new Map())`.
111
+ */
112
+ export const SavedQueriesType = DictType(StringType, SavedQueryType);
113
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/query/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EACH,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,MAAM,EACN,UAAU,EACV,cAAc,EACd,UAAU,EACV,UAAU,EACV,WAAW,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,+EAA+E;AAC/E,WAAW;AACX,+EAA+E;AAE/E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;IACzC,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,YAAY;CACrB,CAAC,CAAC;AAKH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;IACrC,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,YAAY;CACrB,CAAC,CAAC;AAKH,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC;IACtC,MAAM,EAAE,SAAS,CAAC,cAAc,CAAC;IACjC,OAAO,EAAE,WAAW,CAAC;QACjB,KAAK,EAAE,SAAS,CAAC,cAAc,CAAC;QAChC,cAAc,EAAE,UAAU,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;QAChE,EAAE,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;QAClF,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC;QAC1C,SAAS,EAAE,UAAU,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;KACpE,CAAC;CACL,CAAC,CAAC;AAKH,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;IACrC,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,UAAU,CAAC,UAAU,CAAC;IACnC,OAAO,EAAE,MAAM;IACf,IAAI,EAAE,SAAS,CAAC,kBAAkB,CAAC;IACnC,QAAQ,EAAE,YAAY;CACzB,CAAC,CAAC;AAKH;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC"}
package/dist/src/ui.d.ts CHANGED
@@ -13,10 +13,15 @@
13
13
  */
14
14
  import { type DatasetDef, type Runner, type TaskDef } from '@elaraai/e3/browser';
15
15
  import { UIComponentType } from '@elaraai/east-ui';
16
- import { type EastType, type CallableFunctionExpr, type CallableAsyncFunctionExpr, variant } from '@elaraai/east';
16
+ import { type CallableFunctionExpr, type CallableAsyncFunctionExpr, variant } from '@elaraai/east';
17
17
  /**
18
18
  * Create a UI task — an e3 task that produces a UIComponentType value.
19
19
  *
20
+ * Its function returns `UIComponentType`, exactly: a task in the `ui` role is
21
+ * rendered by its role alone, so its output is never anything else. The
22
+ * signature takes no other function, and one that slips past it, through a
23
+ * cast, is refused here, so no package deploys one.
24
+ *
20
25
  * The task's manifest combines:
21
26
  * - **Compute-time reads** — every dataset in `inputs` (the runner passes
22
27
  * their values to `fn` as positional args).
@@ -27,6 +32,14 @@ import { type EastType, type CallableFunctionExpr, type CallableAsyncFunctionExp
27
32
  * Paths used in `Data.bind` must be JS-side constants captured at IR-build
28
33
  * time (typically `e3.input(name, T).path`). Dynamic paths throw.
29
34
  *
35
+ * @param name - The task's name
36
+ * @param inputs - The datasets the runner passes `fn`, in order
37
+ * @param fn - Builds the UI component: returns `UIComponentType`
38
+ * @param options - `runner`, which defaults to east-c with no platforms
39
+ * @returns The task, whose output is the UI component
40
+ * @throws {Error} When `fn` returns another type than `UIComponentType`,
41
+ * naming the task and the type.
42
+ *
30
43
  * @example
31
44
  * ```ts
32
45
  * import e3 from '@elaraai/e3';
@@ -51,7 +64,7 @@ import { type EastType, type CallableFunctionExpr, type CallableAsyncFunctionExp
51
64
  * // Manifest: { reads: [name.path], writes: [] }
52
65
  * ```
53
66
  */
54
- export declare function ui<Name extends string, Inputs extends readonly DatasetDef[], O extends EastType = typeof UIComponentType>(name: Name, inputs: [...Inputs], fn: CallableFunctionExpr<any, O> | CallableAsyncFunctionExpr<any, O>, options?: {
67
+ export declare function ui<Name extends string, Inputs extends readonly DatasetDef[]>(name: Name, inputs: [...Inputs], fn: CallableFunctionExpr<any, UIComponentType> | CallableAsyncFunctionExpr<any, UIComponentType>, options?: {
55
68
  runner?: Runner;
56
- }): TaskDef<O, [variant<'field', 'tasks'>, variant<'field', Name>, variant<'field', 'output'>]>;
69
+ }): TaskDef<UIComponentType, [variant<'field', 'tasks'>, variant<'field', Name>, variant<'field', 'output'>]>;
57
70
  //# sourceMappingURL=ui.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/ui.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AAMH,OAAO,EAAQ,KAAK,UAAU,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,OAAO,EACR,MAAM,eAAe,CAAC;AAIvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,EAAE,CAChB,IAAI,SAAS,MAAM,EACnB,MAAM,SAAS,SAAS,UAAU,EAAE,EACpC,CAAC,SAAS,QAAQ,GAAG,OAAO,eAAe,EAE3C,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,EACnB,EAAE,EAAE,oBAAoB,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,yBAAyB,CAAC,GAAG,EAAE,CAAC,CAAC,EACpE,OAAO,CAAC,EAAE;IACR,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACA,OAAO,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAK7F"}
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/ui.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AAMH,OAAO,EAAQ,KAAK,UAAU,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAKL,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,OAAO,EACR,MAAM,eAAe,CAAC;AAIvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAgB,EAAE,CAChB,IAAI,SAAS,MAAM,EACnB,MAAM,SAAS,SAAS,UAAU,EAAE,EAEpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,EACnB,EAAE,EAAE,oBAAoB,CAAC,GAAG,EAAE,eAAe,CAAC,GAAG,yBAAyB,CAAC,GAAG,EAAE,eAAe,CAAC,EAChG,OAAO,CAAC,EAAE;IACR,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACA,OAAO,CAAC,eAAe,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAK3G"}
package/dist/src/ui.js CHANGED
@@ -17,11 +17,16 @@
17
17
  // that reach `ui()` via this package's main barrel (issue #99).
18
18
  import { task } from '@elaraai/e3/browser';
19
19
  import { UIComponentType } from '@elaraai/east-ui';
20
- import { variant, } from '@elaraai/east';
20
+ import { Expr, isTypeEqual, printTypeSummary, variant, } from '@elaraai/east';
21
21
  import { deriveManifest } from './utils/derive.js';
22
22
  /**
23
23
  * Create a UI task — an e3 task that produces a UIComponentType value.
24
24
  *
25
+ * Its function returns `UIComponentType`, exactly: a task in the `ui` role is
26
+ * rendered by its role alone, so its output is never anything else. The
27
+ * signature takes no other function, and one that slips past it, through a
28
+ * cast, is refused here, so no package deploys one.
29
+ *
25
30
  * The task's manifest combines:
26
31
  * - **Compute-time reads** — every dataset in `inputs` (the runner passes
27
32
  * their values to `fn` as positional args).
@@ -32,6 +37,14 @@ import { deriveManifest } from './utils/derive.js';
32
37
  * Paths used in `Data.bind` must be JS-side constants captured at IR-build
33
38
  * time (typically `e3.input(name, T).path`). Dynamic paths throw.
34
39
  *
40
+ * @param name - The task's name
41
+ * @param inputs - The datasets the runner passes `fn`, in order
42
+ * @param fn - Builds the UI component: returns `UIComponentType`
43
+ * @param options - `runner`, which defaults to east-c with no platforms
44
+ * @returns The task, whose output is the UI component
45
+ * @throws {Error} When `fn` returns another type than `UIComponentType`,
46
+ * naming the task and the type.
47
+ *
35
48
  * @example
36
49
  * ```ts
37
50
  * import e3 from '@elaraai/e3';
@@ -60,6 +73,13 @@ export function ui(name, inputs, fn, options) {
60
73
  return buildUiTask(name, inputs, fn, options);
61
74
  }
62
75
  function buildUiTask(name, inputs, fn, options) {
76
+ // A ui task is rendered by its role alone, so its output is UIComponentType,
77
+ // exactly: a function that slipped past the signature is refused (#1118).
78
+ const output = Expr.type(fn).output;
79
+ if (!isTypeEqual(output, UIComponentType)) {
80
+ throw new Error(`ui '${name}': its function returns ${printTypeSummary(output)}, not UIComponentType — ` +
81
+ `a ui() task's function returns UIComponentType`);
82
+ }
63
83
  const derived = deriveManifest(fn);
64
84
  const inputPaths = inputs.map(i => i.path);
65
85
  const seen = new Set();