@elaraai/e3-ui 1.0.93 → 1.0.95

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 (303) hide show
  1. package/dist/src/allocation/adapters.d.ts +159 -0
  2. package/dist/src/allocation/adapters.d.ts.map +1 -0
  3. package/dist/src/allocation/adapters.js +241 -0
  4. package/dist/src/allocation/adapters.js.map +1 -0
  5. package/dist/src/allocation/functions.d.ts +664 -0
  6. package/dist/src/allocation/functions.d.ts.map +1 -0
  7. package/dist/src/allocation/functions.js +782 -0
  8. package/dist/src/allocation/functions.js.map +1 -0
  9. package/dist/src/allocation/index.d.ts +2985 -0
  10. package/dist/src/allocation/index.d.ts.map +1 -0
  11. package/dist/src/allocation/index.js +499 -0
  12. package/dist/src/allocation/index.js.map +1 -0
  13. package/dist/src/allocation/types.d.ts +832 -0
  14. package/dist/src/allocation/types.d.ts.map +1 -0
  15. package/dist/src/allocation/types.js +360 -0
  16. package/dist/src/allocation/types.js.map +1 -0
  17. package/dist/src/bind/func.d.ts +14 -0
  18. package/dist/src/bind/func.d.ts.map +1 -1
  19. package/dist/src/bind/func.js +22 -1
  20. package/dist/src/bind/func.js.map +1 -1
  21. package/dist/src/calendar/index.d.ts +510 -1639
  22. package/dist/src/calendar/index.d.ts.map +1 -1
  23. package/dist/src/calendar/index.js +56 -29
  24. package/dist/src/calendar/index.js.map +1 -1
  25. package/dist/src/flowchart/canvas.d.ts +9 -21
  26. package/dist/src/flowchart/canvas.d.ts.map +1 -1
  27. package/dist/src/flowchart/canvas.js +10 -22
  28. package/dist/src/flowchart/canvas.js.map +1 -1
  29. package/dist/src/flowchart/flowchart.d.ts +19 -13
  30. package/dist/src/flowchart/flowchart.d.ts.map +1 -1
  31. package/dist/src/flowchart/flowchart.js.map +1 -1
  32. package/dist/src/flowchart/index.d.ts +44 -21
  33. package/dist/src/flowchart/index.d.ts.map +1 -1
  34. package/dist/src/flowchart/index.js +43 -20
  35. package/dist/src/flowchart/index.js.map +1 -1
  36. package/dist/src/flowchart/library.d.ts +166 -81
  37. package/dist/src/flowchart/library.d.ts.map +1 -1
  38. package/dist/src/flowchart/library.js +232 -105
  39. package/dist/src/flowchart/library.js.map +1 -1
  40. package/dist/src/flowchart/over.d.ts +9 -16
  41. package/dist/src/flowchart/over.d.ts.map +1 -1
  42. package/dist/src/flowchart/over.js +9 -16
  43. package/dist/src/flowchart/over.js.map +1 -1
  44. package/dist/src/flowchart/payload.d.ts +710 -508
  45. package/dist/src/flowchart/payload.d.ts.map +1 -1
  46. package/dist/src/flowchart/payload.js +128 -74
  47. package/dist/src/flowchart/payload.js.map +1 -1
  48. package/dist/src/flowchart/window.d.ts +132 -347
  49. package/dist/src/flowchart/window.d.ts.map +1 -1
  50. package/dist/src/flowchart/window.js +48 -55
  51. package/dist/src/flowchart/window.js.map +1 -1
  52. package/dist/src/index.d.ts +11 -7
  53. package/dist/src/index.d.ts.map +1 -1
  54. package/dist/src/index.js +14 -6
  55. package/dist/src/index.js.map +1 -1
  56. package/dist/src/internal.d.ts +18 -7
  57. package/dist/src/internal.d.ts.map +1 -1
  58. package/dist/src/internal.js +28 -9
  59. package/dist/src/internal.js.map +1 -1
  60. package/dist/src/plan/event-rows.d.ts +26 -10
  61. package/dist/src/plan/event-rows.d.ts.map +1 -1
  62. package/dist/src/plan/event-rows.js +39 -13
  63. package/dist/src/plan/event-rows.js.map +1 -1
  64. package/dist/src/plan/ir.d.ts +244 -815
  65. package/dist/src/plan/ir.d.ts.map +1 -1
  66. package/dist/src/plan/ir.js +8 -6
  67. package/dist/src/plan/ir.js.map +1 -1
  68. package/dist/src/plan/library.d.ts +3 -0
  69. package/dist/src/plan/library.d.ts.map +1 -1
  70. package/dist/src/plan/library.js +1 -1
  71. package/dist/src/plan/library.js.map +1 -1
  72. package/dist/src/plan/ordered-source.d.ts +1 -0
  73. package/dist/src/plan/ordered-source.d.ts.map +1 -1
  74. package/dist/src/plan/plan.d.ts +559 -1667
  75. package/dist/src/plan/plan.d.ts.map +1 -1
  76. package/dist/src/plan/plan.js +123 -45
  77. package/dist/src/plan/plan.js.map +1 -1
  78. package/dist/src/plan/root.d.ts +16 -20
  79. package/dist/src/plan/root.d.ts.map +1 -1
  80. package/dist/src/plan/root.js +23 -33
  81. package/dist/src/plan/root.js.map +1 -1
  82. package/dist/src/roster/coverage.d.ts +17 -231
  83. package/dist/src/roster/coverage.d.ts.map +1 -1
  84. package/dist/src/roster/coverage.js +94 -90
  85. package/dist/src/roster/coverage.js.map +1 -1
  86. package/dist/src/roster/fit.d.ts +59 -0
  87. package/dist/src/roster/fit.d.ts.map +1 -0
  88. package/dist/src/roster/fit.js +155 -0
  89. package/dist/src/roster/fit.js.map +1 -0
  90. package/dist/src/roster/index.d.ts +2862 -3662
  91. package/dist/src/roster/index.d.ts.map +1 -1
  92. package/dist/src/roster/index.js +383 -81
  93. package/dist/src/roster/index.js.map +1 -1
  94. package/dist/src/roster/library.d.ts +37 -92
  95. package/dist/src/roster/library.d.ts.map +1 -1
  96. package/dist/src/roster/library.js +25 -64
  97. package/dist/src/roster/library.js.map +1 -1
  98. package/dist/src/roster/lists.d.ts +195 -0
  99. package/dist/src/roster/lists.d.ts.map +1 -0
  100. package/dist/src/roster/lists.js +233 -0
  101. package/dist/src/roster/lists.js.map +1 -0
  102. package/dist/src/roster/rules.d.ts +17 -260
  103. package/dist/src/roster/rules.d.ts.map +1 -1
  104. package/dist/src/roster/rules.js +135 -132
  105. package/dist/src/roster/rules.js.map +1 -1
  106. package/dist/src/roster/targets.d.ts +115 -0
  107. package/dist/src/roster/targets.d.ts.map +1 -0
  108. package/dist/src/roster/targets.js +213 -0
  109. package/dist/src/roster/targets.js.map +1 -0
  110. package/dist/src/roster/times.d.ts +251 -0
  111. package/dist/src/roster/times.d.ts.map +1 -0
  112. package/dist/src/roster/times.js +174 -0
  113. package/dist/src/roster/times.js.map +1 -0
  114. package/dist/src/roster/types.d.ts +828 -183
  115. package/dist/src/roster/types.d.ts.map +1 -1
  116. package/dist/src/roster/types.js +224 -97
  117. package/dist/src/roster/types.js.map +1 -1
  118. package/dist/src/schedule/accessor.d.ts +28 -0
  119. package/dist/src/schedule/accessor.d.ts.map +1 -0
  120. package/dist/src/schedule/accessor.js +39 -0
  121. package/dist/src/schedule/accessor.js.map +1 -0
  122. package/dist/src/schedule/events.d.ts +170 -42
  123. package/dist/src/schedule/events.d.ts.map +1 -1
  124. package/dist/src/schedule/events.js +431 -171
  125. package/dist/src/schedule/events.js.map +1 -1
  126. package/dist/src/schedule/index.d.ts +41 -4
  127. package/dist/src/schedule/index.d.ts.map +1 -1
  128. package/dist/src/schedule/index.js +35 -3
  129. package/dist/src/schedule/index.js.map +1 -1
  130. package/dist/src/schedule/library.d.ts +13 -3
  131. package/dist/src/schedule/library.d.ts.map +1 -1
  132. package/dist/src/schedule/library.js +11 -4
  133. package/dist/src/schedule/library.js.map +1 -1
  134. package/dist/src/schedule/periods.d.ts +115 -0
  135. package/dist/src/schedule/periods.d.ts.map +1 -0
  136. package/dist/src/schedule/periods.js +215 -0
  137. package/dist/src/schedule/periods.js.map +1 -0
  138. package/dist/src/schedule/record-window.d.ts +25 -3
  139. package/dist/src/schedule/record-window.d.ts.map +1 -1
  140. package/dist/src/schedule/record-window.js +31 -18
  141. package/dist/src/schedule/record-window.js.map +1 -1
  142. package/dist/src/schedule/resources.d.ts +82 -4
  143. package/dist/src/schedule/resources.d.ts.map +1 -1
  144. package/dist/src/schedule/resources.js +44 -14
  145. package/dist/src/schedule/resources.js.map +1 -1
  146. package/dist/src/schedule/session.d.ts +69 -0
  147. package/dist/src/schedule/session.d.ts.map +1 -0
  148. package/dist/src/schedule/session.js +121 -0
  149. package/dist/src/schedule/session.js.map +1 -0
  150. package/dist/src/schedule/templates.d.ts +14 -2
  151. package/dist/src/schedule/templates.d.ts.map +1 -1
  152. package/dist/src/schedule/templates.js +5 -3
  153. package/dist/src/schedule/templates.js.map +1 -1
  154. package/dist/src/schedule/types.d.ts +1671 -37
  155. package/dist/src/schedule/types.d.ts.map +1 -1
  156. package/dist/src/schedule/types.js +196 -5
  157. package/dist/src/schedule/types.js.map +1 -1
  158. package/dist/src/schedule/window.d.ts +14 -0
  159. package/dist/src/schedule/window.d.ts.map +1 -1
  160. package/dist/src/schedule/window.js +14 -4
  161. package/dist/src/schedule/window.js.map +1 -1
  162. package/dist/src/schedule/words.d.ts +22 -0
  163. package/dist/src/schedule/words.d.ts.map +1 -0
  164. package/dist/src/schedule/words.js +25 -0
  165. package/dist/src/schedule/words.js.map +1 -0
  166. package/dist/src/sheet/index.d.ts +61 -27
  167. package/dist/src/sheet/index.d.ts.map +1 -1
  168. package/dist/src/sheet/index.js +59 -25
  169. package/dist/src/sheet/index.js.map +1 -1
  170. package/dist/src/sheet/library.d.ts +21 -3
  171. package/dist/src/sheet/library.d.ts.map +1 -1
  172. package/dist/src/sheet/library.js +23 -6
  173. package/dist/src/sheet/library.js.map +1 -1
  174. package/dist/src/sheet/registers.d.ts +100 -85
  175. package/dist/src/sheet/registers.d.ts.map +1 -1
  176. package/dist/src/sheet/registers.js +100 -85
  177. package/dist/src/sheet/registers.js.map +1 -1
  178. package/dist/src/sheet/root.d.ts +8 -12
  179. package/dist/src/sheet/root.d.ts.map +1 -1
  180. package/dist/src/sheet/root.js +6 -40
  181. package/dist/src/sheet/root.js.map +1 -1
  182. package/dist/src/sheet/sheet.d.ts +598 -2349
  183. package/dist/src/sheet/sheet.d.ts.map +1 -1
  184. package/dist/src/sheet/sheet.js +124 -37
  185. package/dist/src/sheet/sheet.js.map +1 -1
  186. package/dist/src/sheet/sub-rows.d.ts +74 -28
  187. package/dist/src/sheet/sub-rows.d.ts.map +1 -1
  188. package/dist/src/sheet/sub-rows.js +74 -28
  189. package/dist/src/sheet/sub-rows.js.map +1 -1
  190. package/dist/src/sheet/templates.d.ts +98 -34
  191. package/dist/src/sheet/templates.d.ts.map +1 -1
  192. package/dist/src/sheet/templates.js +102 -58
  193. package/dist/src/sheet/templates.js.map +1 -1
  194. package/dist/src/sheet/types.d.ts +289 -1359
  195. package/dist/src/sheet/types.d.ts.map +1 -1
  196. package/dist/src/sheet/types.js +20 -26
  197. package/dist/src/sheet/types.js.map +1 -1
  198. package/dist/src/sheet/views.d.ts +10 -11
  199. package/dist/src/sheet/views.d.ts.map +1 -1
  200. package/dist/src/sheet/views.js +15 -20
  201. package/dist/src/sheet/views.js.map +1 -1
  202. package/dist/src/{roster/visibility.d.ts → utils/key-visibility.d.ts} +42 -7
  203. package/dist/src/utils/key-visibility.d.ts.map +1 -0
  204. package/dist/src/utils/key-visibility.js +36 -0
  205. package/dist/src/utils/key-visibility.js.map +1 -0
  206. package/dist/src/utils/ordered-source.d.ts +1 -0
  207. package/dist/src/utils/ordered-source.d.ts.map +1 -1
  208. package/dist/src/utils/ordered-source.js +8 -3
  209. package/dist/src/utils/ordered-source.js.map +1 -1
  210. package/dist/src/utils/record-sources.d.ts +107 -0
  211. package/dist/src/utils/record-sources.d.ts.map +1 -0
  212. package/dist/src/utils/record-sources.js +132 -0
  213. package/dist/src/utils/record-sources.js.map +1 -0
  214. package/dist/test/allocation/allocation.examples.d.ts +2902 -0
  215. package/dist/test/allocation/allocation.examples.d.ts.map +1 -0
  216. package/dist/test/allocation/allocation.examples.js +643 -0
  217. package/dist/test/allocation/allocation.examples.js.map +1 -0
  218. package/dist/test/allocation/fit.examples.d.ts +546 -0
  219. package/dist/test/allocation/fit.examples.d.ts.map +1 -0
  220. package/dist/test/allocation/fit.examples.js +171 -0
  221. package/dist/test/allocation/fit.examples.js.map +1 -0
  222. package/dist/test/allocation/kiln-yard.d.ts +181 -0
  223. package/dist/test/allocation/kiln-yard.d.ts.map +1 -0
  224. package/dist/test/allocation/kiln-yard.js +228 -0
  225. package/dist/test/allocation/kiln-yard.js.map +1 -0
  226. package/dist/test/bind/data/data.examples.d.ts +651 -1
  227. package/dist/test/bind/data/data.examples.d.ts.map +1 -1
  228. package/dist/test/bind/data/data.examples.js +140 -2
  229. package/dist/test/bind/data/data.examples.js.map +1 -1
  230. package/dist/test/bind/func/func.examples.d.ts +10 -1
  231. package/dist/test/bind/func/func.examples.d.ts.map +1 -1
  232. package/dist/test/bind/func/func.examples.js +8 -1
  233. package/dist/test/bind/func/func.examples.js.map +1 -1
  234. package/dist/test/bind/record/record.examples.d.ts +633 -1
  235. package/dist/test/bind/record/record.examples.d.ts.map +1 -1
  236. package/dist/test/bind/record/record.examples.js +26 -2
  237. package/dist/test/bind/record/record.examples.js.map +1 -1
  238. package/dist/test/calendar/calendar-records.examples.d.ts.map +1 -1
  239. package/dist/test/calendar/calendar-records.examples.js +18 -14
  240. package/dist/test/calendar/calendar-records.examples.js.map +1 -1
  241. package/dist/test/calendar/calendar.examples.d.ts +521 -16
  242. package/dist/test/calendar/calendar.examples.d.ts.map +1 -1
  243. package/dist/test/calendar/calendar.examples.js +182 -135
  244. package/dist/test/calendar/calendar.examples.js.map +1 -1
  245. package/dist/test/examples-package.d.ts +75 -0
  246. package/dist/test/examples-package.d.ts.map +1 -0
  247. package/dist/test/examples-package.js +263 -0
  248. package/dist/test/examples-package.js.map +1 -0
  249. package/dist/test/flowchart/flowchart.examples.d.ts +211 -19
  250. package/dist/test/flowchart/flowchart.examples.d.ts.map +1 -1
  251. package/dist/test/flowchart/flowchart.examples.js +102 -75
  252. package/dist/test/flowchart/flowchart.examples.js.map +1 -1
  253. package/dist/test/plan/plan-events.examples.d.ts +1439 -209
  254. package/dist/test/plan/plan-events.examples.d.ts.map +1 -1
  255. package/dist/test/plan/plan-events.examples.js +199 -59
  256. package/dist/test/plan/plan-events.examples.js.map +1 -1
  257. package/dist/test/plan/plan-records.examples.d.ts +420 -0
  258. package/dist/test/plan/plan-records.examples.d.ts.map +1 -1
  259. package/dist/test/plan/plan-records.examples.js +70 -19
  260. package/dist/test/plan/plan-records.examples.js.map +1 -1
  261. package/dist/test/plan/plan-windows.examples.d.ts +636 -55
  262. package/dist/test/plan/plan-windows.examples.d.ts.map +1 -1
  263. package/dist/test/plan/plan-windows.examples.js +69 -33
  264. package/dist/test/plan/plan-windows.examples.js.map +1 -1
  265. package/dist/test/plan/plan.examples.d.ts +153 -31
  266. package/dist/test/plan/plan.examples.d.ts.map +1 -1
  267. package/dist/test/plan/plan.examples.js +178 -101
  268. package/dist/test/plan/plan.examples.js.map +1 -1
  269. package/dist/test/roster/domain.examples.d.ts +467 -250
  270. package/dist/test/roster/domain.examples.d.ts.map +1 -1
  271. package/dist/test/roster/domain.examples.js +92 -29
  272. package/dist/test/roster/domain.examples.js.map +1 -1
  273. package/dist/test/roster/roster-records.examples.d.ts +430 -586
  274. package/dist/test/roster/roster-records.examples.d.ts.map +1 -1
  275. package/dist/test/roster/roster-records.examples.js +102 -43
  276. package/dist/test/roster/roster-records.examples.js.map +1 -1
  277. package/dist/test/roster/roster.examples.d.ts +2319 -606
  278. package/dist/test/roster/roster.examples.d.ts.map +1 -1
  279. package/dist/test/roster/roster.examples.js +456 -148
  280. package/dist/test/roster/roster.examples.js.map +1 -1
  281. package/dist/test/roster/warehouse.d.ts +172 -63
  282. package/dist/test/roster/warehouse.d.ts.map +1 -1
  283. package/dist/test/roster/warehouse.js +172 -39
  284. package/dist/test/roster/warehouse.js.map +1 -1
  285. package/dist/test/schedule/schedule.examples.d.ts +3499 -0
  286. package/dist/test/schedule/schedule.examples.d.ts.map +1 -0
  287. package/dist/test/schedule/schedule.examples.js +192 -0
  288. package/dist/test/schedule/schedule.examples.js.map +1 -0
  289. package/dist/test/sheet/sheet-records.examples.d.ts.map +1 -1
  290. package/dist/test/sheet/sheet-records.examples.js +22 -18
  291. package/dist/test/sheet/sheet-records.examples.js.map +1 -1
  292. package/dist/test/sheet/sheet.examples.d.ts +715 -26
  293. package/dist/test/sheet/sheet.examples.d.ts.map +1 -1
  294. package/dist/test/sheet/sheet.examples.js +204 -130
  295. package/dist/test/sheet/sheet.examples.js.map +1 -1
  296. package/package.json +17 -10
  297. package/dist/src/roster/people.d.ts +0 -50
  298. package/dist/src/roster/people.d.ts.map +0 -1
  299. package/dist/src/roster/people.js +0 -32
  300. package/dist/src/roster/people.js.map +0 -1
  301. package/dist/src/roster/visibility.d.ts.map +0 -1
  302. package/dist/src/roster/visibility.js +0 -25
  303. package/dist/src/roster/visibility.js.map +0 -1
@@ -0,0 +1,107 @@
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
+ * A builder's narrowing (#1340): its `slice` is one `Slice.bindRecords`, each
7
+ * source named after what it narrows, and each source filters every place its
8
+ * records appear — the main area, the Choosers and the Library tab that lists
9
+ * that record. The one check every builder's tag makes of its `slice`, the one
10
+ * binding of its sources in the builder's payload (#1356), the one check of a
11
+ * tab's `source`, and the one of a templates list's.
12
+ *
13
+ * @packageDocumentation
14
+ */
15
+ import { StringType, type ArrayType, type BlockBuilder, type EastType, type ExprType, type StructType, type option } from "@elaraai/east";
16
+ import { type RecordSlicesChromeOptions, type RecordSlicesChromeType, type RowSource } from "@elaraai/east-ui/internal";
17
+ /** What a builder's narrowing takes. */
18
+ export interface RecordSourcesSpec {
19
+ /** The builder, as its messages name it (`Allocation`). */
20
+ builder: string;
21
+ /** The sources it names in its messages, in their order (`lanes`, `resources`, `events`). */
22
+ names: readonly string[];
23
+ /** What its sources narrow, as its refusal says it (`its lanes, its resources and its events`). */
24
+ what: string;
25
+ /** Whether it takes a source of this name; by default, one of `names`. A builder whose sources are its own keys (the Calendar's event kinds) says so here. */
26
+ takes?: (name: string) => boolean;
27
+ }
28
+ /**
29
+ * A builder's sources, each bound once in its payload's block (#1356): its part of the slice, its narrowed data and
30
+ * its narrowed keys. A function captures what it reads, so one reading a source through these holds that source
31
+ * alone. One reading through the slice would hold every source's methods, and beast2 writes a captured value
32
+ * wherever a function holding it is written.
33
+ */
34
+ export interface BoundSources {
35
+ /** Each source's part of the slice, its typed record Slice handle: what a kind narrowed through it reads (a Calendar's event kind), and its record's identity. */
36
+ parts: Readonly<Record<string, ExprType<StructType>>>;
37
+ /** Each source's typed narrowed data, `Slice.rows(slice, name)`: what a main area that pages its rows reads. */
38
+ data: Readonly<Record<string, ExprType<StructType>>>;
39
+ /** Each source's narrowed keys, paged through its data: what the renderer reads to show its rows. */
40
+ keys: Readonly<Record<string, RowSource<ArrayType<StringType>>>>;
41
+ }
42
+ /** A builder's narrowing, checked: its chrome, its sources' names, and the one binding of its sources. */
43
+ export interface RecordSources {
44
+ /** The rail's chrome; `none` with no slice. */
45
+ chrome: option<ExprType<RecordSlicesChromeType>>;
46
+ /** The slice's sources, in their order. */
47
+ names: string[];
48
+ /**
49
+ * Binds each source once in the builder's payload block — its part, its narrowed data and its keys (#1356).
50
+ * Every builder calls it first and reads its sources only through what it returns.
51
+ *
52
+ * @typeParam T - The block's type
53
+ * @param $ - The builder's payload block
54
+ * @returns Each source's part, narrowed data and keys, bound
55
+ */
56
+ bind<T extends EastType>($: BlockBuilder<T>): BoundSources;
57
+ }
58
+ /**
59
+ * Checks a builder's `slice` and reads its sources (#1340): the slice is
60
+ * `Slice.bindRecords`, every source one the builder takes, each a record with
61
+ * String primary keys. `bind` binds each source once in the builder's payload
62
+ * (#1356).
63
+ *
64
+ * @param slice - The builder's `slice` prop, if given
65
+ * @param spec - What the builder takes, and its words
66
+ * @returns The chrome, the sources' names, and the binding of each one's part, data and keys
67
+ * @throws {Error} When `slice` is `Slice.bind` or `Slice.bindRecord`, names a source the builder does not take, or narrows a record whose keys are not Strings
68
+ */
69
+ export declare function recordSources(slice: RecordSlicesChromeOptions | undefined, spec: RecordSourcesSpec): RecordSources;
70
+ /**
71
+ * The sources a builder's `slice` names, read before it is checked: what a
72
+ * builder's templates check lists, so a list written in the code is refused
73
+ * with the change to make before a source no list names is (#1343, #1345).
74
+ *
75
+ * @param slice - The builder's `slice` prop, if given
76
+ * @returns Its sources, in their order; none when it is no `Slice.bindRecords`, which `recordSources` refuses
77
+ */
78
+ export declare function sliceSourceNames(slice: RecordSlicesChromeOptions | undefined): string[];
79
+ /**
80
+ * A tab's source (#1340): the slice's source whose shown keys filter the tab's
81
+ * cards, its rows that record's rows by key; `none` for a tab that names none,
82
+ * which lists its rows whole.
83
+ *
84
+ * @param builder - The builder, as its message names it
85
+ * @param tab - The tab, as its message names it (`Positions`)
86
+ * @param source - The source the tab names, if any
87
+ * @param names - The slice's sources
88
+ * @returns The source, as the payload carries it
89
+ * @throws {Error} When the tab names a source the slice lacks
90
+ */
91
+ export declare function tabSource(builder: string, tab: string, source: string | undefined, names: readonly string[]): option<string>;
92
+ /**
93
+ * A templates list's source (#1340, #1345): every builder's templates are a
94
+ * record of their own, each list a source of the builder's one
95
+ * `Slice.bindRecords`, its cards that record's rows by key. A list written in
96
+ * the code names no source, and is refused as one naming a source the slice
97
+ * lacks is, both with the change to make.
98
+ *
99
+ * @param builder - The builder, as its message names it (`Sheet`)
100
+ * @param what - The builder's templates declaration, as the refusal writes it (`Sheet.templates(rows, { …, source: "rowTemplates" })`)
101
+ * @param source - The source the list names; `undefined` for a list written in the code, or one that names none
102
+ * @param names - The slice's sources
103
+ * @returns The source's name
104
+ * @throws {Error} When the list names no source, or one the slice lacks, listing the slice's sources
105
+ */
106
+ export declare function templatesSource(builder: string, what: string, source: string | undefined, names: readonly string[]): string;
107
+ //# sourceMappingURL=record-sources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-sources.d.ts","sourceRoot":"","sources":["../../../src/utils/record-sources.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EACS,UAAU,EACtB,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,KAAK,MAAM,EAChG,MAAM,eAAe,CAAC;AACvB,OAAO,EACmD,KAAK,yBAAyB,EAAE,KAAK,sBAAsB,EAAE,KAAK,SAAS,EACpI,MAAM,2BAA2B,CAAC;AAGnC,wCAAwC;AACxC,MAAM,WAAW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AE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAM5H;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAI3H"}
@@ -0,0 +1,132 @@
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
+ * A builder's narrowing (#1340): its `slice` is one `Slice.bindRecords`, each
7
+ * source named after what it narrows, and each source filters every place its
8
+ * records appear — the main area, the Choosers and the Library tab that lists
9
+ * that record. The one check every builder's tag makes of its `slice`, the one
10
+ * binding of its sources in the builder's payload (#1356), the one check of a
11
+ * tab's `source`, and the one of a templates list's.
12
+ *
13
+ * @packageDocumentation
14
+ */
15
+ import { East, Expr, StringType, isTypeEqual, none, some, } from "@elaraai/east";
16
+ import { isRecordSlices, recordSlicesChrome, resolveRowSource, } from "@elaraai/east-ui/internal";
17
+ import { keyVisibility } from "./key-visibility.js";
18
+ /** `` `lanes`, `resources` and `events` ``. */
19
+ function quoted(names) {
20
+ const each = names.map(name => `\`${name}\``);
21
+ return each.length <= 1 ? each.join("") : `${each.slice(0, -1).join(", ")} and ${each.at(-1)}`;
22
+ }
23
+ /**
24
+ * Checks a builder's `slice` and reads its sources (#1340): the slice is
25
+ * `Slice.bindRecords`, every source one the builder takes, each a record with
26
+ * String primary keys. `bind` binds each source once in the builder's payload
27
+ * (#1356).
28
+ *
29
+ * @param slice - The builder's `slice` prop, if given
30
+ * @param spec - What the builder takes, and its words
31
+ * @returns The chrome, the sources' names, and the binding of each one's part, data and keys
32
+ * @throws {Error} When `slice` is `Slice.bind` or `Slice.bindRecord`, names a source the builder does not take, or narrows a record whose keys are not Strings
33
+ */
34
+ export function recordSources(slice, spec) {
35
+ if (slice === undefined)
36
+ return { chrome: none, names: [], bind: () => ({ parts: {}, data: {}, keys: {} }) };
37
+ if (!isRecordSlices(slice.slice)) {
38
+ throw new Error(`${spec.builder}: \`slice\` is Slice.bindRecords(key, { ${spec.names.join(", ")} }) — name each source after what it narrows; Slice.bind and Slice.bindRecord are not taken`);
39
+ }
40
+ const handle = East.value(slice.slice);
41
+ const sources = Expr.type(handle).fields["sources"];
42
+ const names = sources?.type === "Struct" ? Object.keys(sources.fields) : [];
43
+ const takes = spec.takes ?? ((name) => spec.names.includes(name));
44
+ const prop = (name) => `${spec.builder}.slice's ${name}`;
45
+ const unkeyed = (name) => new Error(`${spec.builder}: \`slice\`'s ${name} narrows a record whose keys are not Strings — each source is a record with String primary keys`);
46
+ for (const name of names) {
47
+ if (!takes(name)) {
48
+ throw new Error(`${spec.builder}: \`slice\` narrows ${spec.what} — its source '${name}' is none of them; name the sources ${quoted(spec.names)}`);
49
+ }
50
+ // A source's rows are keyed as its record is: a builder matches them by String key.
51
+ const resolved = resolveRowSource(handle.sources[name].data, prop(name));
52
+ if (resolved.kind !== "ordered" || !isTypeEqual(resolved.keyType, StringType))
53
+ throw unkeyed(name);
54
+ }
55
+ return {
56
+ chrome: some(recordSlicesChrome(slice)),
57
+ names,
58
+ bind: ($) => {
59
+ const parts = {};
60
+ const data = {};
61
+ const keys = {};
62
+ for (const name of names) {
63
+ const part = $.let(handle.sources[name]);
64
+ const rows = $.let(part.data);
65
+ // Its keys page through its own data.
66
+ const visible = keyVisibility(rows, prop(name));
67
+ if (visible.source === undefined)
68
+ throw unkeyed(name);
69
+ const shown = $.let(visible.source);
70
+ parts[name] = part;
71
+ data[name] = rows;
72
+ keys[name] = shown;
73
+ }
74
+ return { parts, data, keys };
75
+ },
76
+ };
77
+ }
78
+ /**
79
+ * The sources a builder's `slice` names, read before it is checked: what a
80
+ * builder's templates check lists, so a list written in the code is refused
81
+ * with the change to make before a source no list names is (#1343, #1345).
82
+ *
83
+ * @param slice - The builder's `slice` prop, if given
84
+ * @returns Its sources, in their order; none when it is no `Slice.bindRecords`, which `recordSources` refuses
85
+ */
86
+ export function sliceSourceNames(slice) {
87
+ if (slice === undefined || !isRecordSlices(slice.slice))
88
+ return [];
89
+ const sources = Expr.type(East.value(slice.slice)).fields["sources"];
90
+ return sources?.type === "Struct" ? Object.keys(sources.fields) : [];
91
+ }
92
+ /**
93
+ * A tab's source (#1340): the slice's source whose shown keys filter the tab's
94
+ * cards, its rows that record's rows by key; `none` for a tab that names none,
95
+ * which lists its rows whole.
96
+ *
97
+ * @param builder - The builder, as its message names it
98
+ * @param tab - The tab, as its message names it (`Positions`)
99
+ * @param source - The source the tab names, if any
100
+ * @param names - The slice's sources
101
+ * @returns The source, as the payload carries it
102
+ * @throws {Error} When the tab names a source the slice lacks
103
+ */
104
+ export function tabSource(builder, tab, source, names) {
105
+ if (source === undefined)
106
+ return none;
107
+ if (!names.includes(source)) {
108
+ throw new Error(`${builder}: the ${tab} tab's source '${source}' is not one of the slice's sources (${names.length === 0 ? "it has no slice" : names.join(", ")})`);
109
+ }
110
+ return some(source);
111
+ }
112
+ /**
113
+ * A templates list's source (#1340, #1345): every builder's templates are a
114
+ * record of their own, each list a source of the builder's one
115
+ * `Slice.bindRecords`, its cards that record's rows by key. A list written in
116
+ * the code names no source, and is refused as one naming a source the slice
117
+ * lacks is, both with the change to make.
118
+ *
119
+ * @param builder - The builder, as its message names it (`Sheet`)
120
+ * @param what - The builder's templates declaration, as the refusal writes it (`Sheet.templates(rows, { …, source: "rowTemplates" })`)
121
+ * @param source - The source the list names; `undefined` for a list written in the code, or one that names none
122
+ * @param names - The slice's sources
123
+ * @returns The source's name
124
+ * @throws {Error} When the list names no source, or one the slice lacks, listing the slice's sources
125
+ */
126
+ export function templatesSource(builder, what, source, names) {
127
+ if (source !== undefined && names.includes(source))
128
+ return source;
129
+ const missing = source === undefined ? "" : ` — '${source}' is not one of them`;
130
+ throw new Error(`${builder}: templates are records now — bind them in Slice.bindRecords and name the source, ${what} (${names.length === 0 ? "it has no slice" : `the slice's sources: ${names.join(", ")}`}${missing})`);
131
+ }
132
+ //# sourceMappingURL=record-sources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-sources.js","sourceRoot":"","sources":["../../../src/utils/record-sources.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EACH,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,GAElD,MAAM,eAAe,CAAC;AACvB,OAAO,EACH,cAAc,EAAE,kBAAkB,EAAE,gBAAgB,GACvD,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AA8CpD,+CAA+C;AAC/C,SAAS,MAAM,CAAC,KAAwB;IACpC,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;IAC9C,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACnG,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAAC,KAA4C,EAAE,IAAuB;IAC/F,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,E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