@elaraai/e3-ui 1.0.103 → 1.0.105

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 (287) hide show
  1. package/dist/src/allocation/functions.d.ts +2 -1
  2. package/dist/src/allocation/functions.d.ts.map +1 -1
  3. package/dist/src/allocation/functions.js +3 -2
  4. package/dist/src/allocation/functions.js.map +1 -1
  5. package/dist/src/allocation/index.d.ts +120 -1
  6. package/dist/src/allocation/index.d.ts.map +1 -1
  7. package/dist/src/allocation/index.js +24 -4
  8. package/dist/src/allocation/index.js.map +1 -1
  9. package/dist/src/bind/data-indexed.d.ts +25 -4
  10. package/dist/src/bind/data-indexed.d.ts.map +1 -1
  11. package/dist/src/bind/data-indexed.js +58 -7
  12. package/dist/src/bind/data-indexed.js.map +1 -1
  13. package/dist/src/bind/data.d.ts +12 -14
  14. package/dist/src/bind/data.d.ts.map +1 -1
  15. package/dist/src/bind/data.js +11 -11
  16. package/dist/src/bind/data.js.map +1 -1
  17. package/dist/src/bind/func.d.ts +7 -2
  18. package/dist/src/bind/func.d.ts.map +1 -1
  19. package/dist/src/bind/func.js +10 -3
  20. package/dist/src/bind/func.js.map +1 -1
  21. package/dist/src/calendar/index.d.ts +148 -1
  22. package/dist/src/calendar/index.d.ts.map +1 -1
  23. package/dist/src/calendar/index.js +55 -5
  24. package/dist/src/calendar/index.js.map +1 -1
  25. package/dist/src/flowchart/canvas.d.ts +32 -14
  26. package/dist/src/flowchart/canvas.d.ts.map +1 -1
  27. package/dist/src/flowchart/canvas.js +21 -6
  28. package/dist/src/flowchart/canvas.js.map +1 -1
  29. package/dist/src/flowchart/details.d.ts +469 -0
  30. package/dist/src/flowchart/details.d.ts.map +1 -0
  31. package/dist/src/flowchart/details.js +1035 -0
  32. package/dist/src/flowchart/details.js.map +1 -0
  33. package/dist/src/flowchart/flowchart.d.ts +16 -72
  34. package/dist/src/flowchart/flowchart.d.ts.map +1 -1
  35. package/dist/src/flowchart/flowchart.js +10 -1
  36. package/dist/src/flowchart/flowchart.js.map +1 -1
  37. package/dist/src/flowchart/index.d.ts +282 -251
  38. package/dist/src/flowchart/index.d.ts.map +1 -1
  39. package/dist/src/flowchart/index.js +234 -220
  40. package/dist/src/flowchart/index.js.map +1 -1
  41. package/dist/src/flowchart/kinds.d.ts +438 -0
  42. package/dist/src/flowchart/kinds.d.ts.map +1 -0
  43. package/dist/src/flowchart/kinds.js +799 -0
  44. package/dist/src/flowchart/kinds.js.map +1 -0
  45. package/dist/src/flowchart/library.d.ts +154 -739
  46. package/dist/src/flowchart/library.d.ts.map +1 -1
  47. package/dist/src/flowchart/library.js +191 -673
  48. package/dist/src/flowchart/library.js.map +1 -1
  49. package/dist/src/flowchart/payload.d.ts +3652 -7843
  50. package/dist/src/flowchart/payload.d.ts.map +1 -1
  51. package/dist/src/flowchart/payload.js +331 -469
  52. package/dist/src/flowchart/payload.js.map +1 -1
  53. package/dist/src/flowchart/templates.d.ts +657 -0
  54. package/dist/src/flowchart/templates.d.ts.map +1 -0
  55. package/dist/src/flowchart/templates.js +658 -0
  56. package/dist/src/flowchart/templates.js.map +1 -0
  57. package/dist/src/flowchart/types.d.ts +2258 -214
  58. package/dist/src/flowchart/types.d.ts.map +1 -1
  59. package/dist/src/flowchart/types.js +374 -124
  60. package/dist/src/flowchart/types.js.map +1 -1
  61. package/dist/src/index.d.ts +13 -15
  62. package/dist/src/index.d.ts.map +1 -1
  63. package/dist/src/index.js +24 -29
  64. package/dist/src/index.js.map +1 -1
  65. package/dist/src/internal.d.ts +5 -7
  66. package/dist/src/internal.d.ts.map +1 -1
  67. package/dist/src/internal.js +12 -19
  68. package/dist/src/internal.js.map +1 -1
  69. package/dist/src/ontology/index.d.ts +44 -15
  70. package/dist/src/ontology/index.d.ts.map +1 -1
  71. package/dist/src/ontology/index.js +19 -11
  72. package/dist/src/ontology/index.js.map +1 -1
  73. package/dist/src/plan/event-rows.d.ts +2 -1
  74. package/dist/src/plan/event-rows.d.ts.map +1 -1
  75. package/dist/src/plan/event-rows.js +6 -4
  76. package/dist/src/plan/event-rows.js.map +1 -1
  77. package/dist/src/plan/ir.d.ts +1 -0
  78. package/dist/src/plan/ir.d.ts.map +1 -1
  79. package/dist/src/plan/plan.d.ts +145 -1
  80. package/dist/src/plan/plan.d.ts.map +1 -1
  81. package/dist/src/plan/plan.js +67 -3
  82. package/dist/src/plan/plan.js.map +1 -1
  83. package/dist/src/plan/types.d.ts +1 -0
  84. package/dist/src/plan/types.d.ts.map +1 -1
  85. package/dist/src/query/builder.d.ts +362 -315
  86. package/dist/src/query/builder.d.ts.map +1 -1
  87. package/dist/src/query/builder.js +12 -1
  88. package/dist/src/query/builder.js.map +1 -1
  89. package/dist/src/query/index.d.ts +5 -1
  90. package/dist/src/query/index.d.ts.map +1 -1
  91. package/dist/src/query/index.js +3 -1
  92. package/dist/src/query/index.js.map +1 -1
  93. package/dist/src/roster/fit.d.ts +5 -2
  94. package/dist/src/roster/fit.d.ts.map +1 -1
  95. package/dist/src/roster/fit.js +5 -3
  96. package/dist/src/roster/fit.js.map +1 -1
  97. package/dist/src/roster/index.d.ts +103 -2
  98. package/dist/src/roster/index.d.ts.map +1 -1
  99. package/dist/src/roster/index.js +45 -6
  100. package/dist/src/roster/index.js.map +1 -1
  101. package/dist/src/runtime/index.d.ts +1 -3
  102. package/dist/src/runtime/index.d.ts.map +1 -1
  103. package/dist/src/runtime/index.js +1 -3
  104. package/dist/src/runtime/index.js.map +1 -1
  105. package/dist/src/schedule/record-window.d.ts +1 -0
  106. package/dist/src/schedule/record-window.d.ts.map +1 -1
  107. package/dist/src/schematic/index.d.ts +1 -1
  108. package/dist/src/schematic/index.d.ts.map +1 -1
  109. package/dist/src/schematic/index.js +1 -1
  110. package/dist/src/schematic/index.js.map +1 -1
  111. package/dist/src/schematic/kinds.d.ts +4 -24
  112. package/dist/src/schematic/kinds.d.ts.map +1 -1
  113. package/dist/src/schematic/kinds.js +8 -212
  114. package/dist/src/schematic/kinds.js.map +1 -1
  115. package/dist/src/schematic/payload.d.ts +140 -1
  116. package/dist/src/schematic/payload.d.ts.map +1 -1
  117. package/dist/src/schematic/payload.js +38 -1
  118. package/dist/src/schematic/payload.js.map +1 -1
  119. package/dist/src/schematic/types.d.ts.map +1 -1
  120. package/dist/src/schematic/types.js +4 -36
  121. package/dist/src/schematic/types.js.map +1 -1
  122. package/dist/src/schematic/window.d.ts +9 -42
  123. package/dist/src/schematic/window.d.ts.map +1 -1
  124. package/dist/src/schematic/window.js +10 -115
  125. package/dist/src/schematic/window.js.map +1 -1
  126. package/dist/src/sheet/actions.d.ts +388 -0
  127. package/dist/src/sheet/actions.d.ts.map +1 -0
  128. package/dist/src/sheet/actions.js +594 -0
  129. package/dist/src/sheet/actions.js.map +1 -0
  130. package/dist/src/sheet/bridge.d.ts +12 -1
  131. package/dist/src/sheet/bridge.d.ts.map +1 -1
  132. package/dist/src/sheet/bridge.js +30 -6
  133. package/dist/src/sheet/bridge.js.map +1 -1
  134. package/dist/src/sheet/columns.d.ts +5 -2
  135. package/dist/src/sheet/columns.d.ts.map +1 -1
  136. package/dist/src/sheet/columns.js.map +1 -1
  137. package/dist/src/sheet/draft-bridge.d.ts +9 -4
  138. package/dist/src/sheet/draft-bridge.d.ts.map +1 -1
  139. package/dist/src/sheet/draft-bridge.js +22 -7
  140. package/dist/src/sheet/draft-bridge.js.map +1 -1
  141. package/dist/src/sheet/fields.d.ts +13 -0
  142. package/dist/src/sheet/fields.d.ts.map +1 -1
  143. package/dist/src/sheet/fields.js +3 -0
  144. package/dist/src/sheet/fields.js.map +1 -1
  145. package/dist/src/sheet/index.d.ts +32 -2
  146. package/dist/src/sheet/index.d.ts.map +1 -1
  147. package/dist/src/sheet/index.js +18 -3
  148. package/dist/src/sheet/index.js.map +1 -1
  149. package/dist/src/sheet/library.d.ts +8 -0
  150. package/dist/src/sheet/library.d.ts.map +1 -1
  151. package/dist/src/sheet/root.d.ts +23 -1
  152. package/dist/src/sheet/root.d.ts.map +1 -1
  153. package/dist/src/sheet/root.js +40 -5
  154. package/dist/src/sheet/root.js.map +1 -1
  155. package/dist/src/sheet/sheet.d.ts +7843 -4132
  156. package/dist/src/sheet/sheet.d.ts.map +1 -1
  157. package/dist/src/sheet/sheet.js +41 -2
  158. package/dist/src/sheet/sheet.js.map +1 -1
  159. package/dist/src/sheet/templates.d.ts +4 -0
  160. package/dist/src/sheet/templates.d.ts.map +1 -1
  161. package/dist/src/sheet/types.d.ts +12449 -5268
  162. package/dist/src/sheet/types.d.ts.map +1 -1
  163. package/dist/src/sheet/types.js +114 -2
  164. package/dist/src/sheet/types.js.map +1 -1
  165. package/dist/src/utils/derive.d.ts +1 -1
  166. package/dist/src/utils/derive.js +1 -1
  167. package/dist/src/utils/record-kind.d.ts +625 -0
  168. package/dist/src/utils/record-kind.d.ts.map +1 -0
  169. package/dist/src/utils/record-kind.js +450 -0
  170. package/dist/src/utils/record-kind.js.map +1 -0
  171. package/dist/src/utils/views.d.ts +55 -0
  172. package/dist/src/utils/views.d.ts.map +1 -0
  173. package/dist/src/utils/views.js +72 -0
  174. package/dist/src/utils/views.js.map +1 -0
  175. package/dist/src/utils/vocabulary.d.ts +48 -0
  176. package/dist/src/utils/vocabulary.d.ts.map +1 -0
  177. package/dist/src/utils/vocabulary.js +47 -0
  178. package/dist/src/utils/vocabulary.js.map +1 -0
  179. package/dist/test/allocation/allocation.examples.d.ts +2 -0
  180. package/dist/test/allocation/allocation.examples.d.ts.map +1 -1
  181. package/dist/test/allocation/allocation.examples.js +81 -2
  182. package/dist/test/allocation/allocation.examples.js.map +1 -1
  183. package/dist/test/bind/func/func.examples.d.ts +19 -1
  184. package/dist/test/bind/func/func.examples.d.ts.map +1 -1
  185. package/dist/test/bind/func/func.examples.js +36 -1
  186. package/dist/test/bind/func/func.examples.js.map +1 -1
  187. package/dist/test/calendar/calendar.examples.d.ts +2 -0
  188. package/dist/test/calendar/calendar.examples.d.ts.map +1 -1
  189. package/dist/test/calendar/calendar.examples.js +80 -2
  190. package/dist/test/calendar/calendar.examples.js.map +1 -1
  191. package/dist/test/decision/queue.examples.d.ts +1 -0
  192. package/dist/test/decision/queue.examples.d.ts.map +1 -1
  193. package/dist/test/decision/queue.examples.js +12 -0
  194. package/dist/test/decision/queue.examples.js.map +1 -1
  195. package/dist/test/examples-package.d.ts.map +1 -1
  196. package/dist/test/examples-package.js +5 -4
  197. package/dist/test/examples-package.js.map +1 -1
  198. package/dist/test/flowchart/flowchart.examples.d.ts +1250 -4605
  199. package/dist/test/flowchart/flowchart.examples.d.ts.map +1 -1
  200. package/dist/test/flowchart/flowchart.examples.js +861 -512
  201. package/dist/test/flowchart/flowchart.examples.js.map +1 -1
  202. package/dist/test/ontology/ontology.examples.d.ts +2 -3
  203. package/dist/test/ontology/ontology.examples.d.ts.map +1 -1
  204. package/dist/test/ontology/ontology.examples.js +32 -21
  205. package/dist/test/ontology/ontology.examples.js.map +1 -1
  206. package/dist/test/plan/plan-events.examples.d.ts +1 -0
  207. package/dist/test/plan/plan-events.examples.d.ts.map +1 -1
  208. package/dist/test/plan/plan-events.examples.js +44 -0
  209. package/dist/test/plan/plan-events.examples.js.map +1 -1
  210. package/dist/test/plan/plan-nested.examples.d.ts +2 -2
  211. package/dist/test/plan/plan-nested.examples.js +5 -5
  212. package/dist/test/plan/plan-nested.examples.js.map +1 -1
  213. package/dist/test/plan/plan-records.examples.d.ts.map +1 -1
  214. package/dist/test/plan/plan-records.examples.js +1 -1
  215. package/dist/test/plan/plan-records.examples.js.map +1 -1
  216. package/dist/test/query/query.examples.d.ts +2 -0
  217. package/dist/test/query/query.examples.d.ts.map +1 -1
  218. package/dist/test/query/query.examples.js +37 -1
  219. package/dist/test/query/query.examples.js.map +1 -1
  220. package/dist/test/roster/roster.examples.d.ts +2 -0
  221. package/dist/test/roster/roster.examples.d.ts.map +1 -1
  222. package/dist/test/roster/roster.examples.js +76 -15
  223. package/dist/test/roster/roster.examples.js.map +1 -1
  224. package/dist/test/schematic/schematic-records.examples.d.ts.map +1 -1
  225. package/dist/test/schematic/schematic-records.examples.js +6 -4
  226. package/dist/test/schematic/schematic-records.examples.js.map +1 -1
  227. package/dist/test/schematic/schematic.examples.d.ts +1 -0
  228. package/dist/test/schematic/schematic.examples.d.ts.map +1 -1
  229. package/dist/test/schematic/schematic.examples.js +144 -0
  230. package/dist/test/schematic/schematic.examples.js.map +1 -1
  231. package/dist/test/sheet/sheet-actions.examples.d.ts +1264 -0
  232. package/dist/test/sheet/sheet-actions.examples.d.ts.map +1 -0
  233. package/dist/test/sheet/sheet-actions.examples.js +394 -0
  234. package/dist/test/sheet/sheet-actions.examples.js.map +1 -0
  235. package/dist/test/sheet/sheet.examples.d.ts +1 -0
  236. package/dist/test/sheet/sheet.examples.d.ts.map +1 -1
  237. package/dist/test/sheet/sheet.examples.js +77 -0
  238. package/dist/test/sheet/sheet.examples.js.map +1 -1
  239. package/dist/test/studio/studio.examples.d.ts +1 -0
  240. package/dist/test/studio/studio.examples.d.ts.map +1 -1
  241. package/dist/test/studio/studio.examples.js +18 -8
  242. package/dist/test/studio/studio.examples.js.map +1 -1
  243. package/package.json +12 -12
  244. package/dist/src/diff/index.d.ts +0 -407
  245. package/dist/src/diff/index.d.ts.map +0 -1
  246. package/dist/src/diff/index.js +0 -203
  247. package/dist/src/diff/index.js.map +0 -1
  248. package/dist/src/experiment/index.d.ts +0 -1033
  249. package/dist/src/experiment/index.d.ts.map +0 -1
  250. package/dist/src/experiment/index.js +0 -197
  251. package/dist/src/experiment/index.js.map +0 -1
  252. package/dist/src/experiment/types.d.ts +0 -1093
  253. package/dist/src/experiment/types.d.ts.map +0 -1
  254. package/dist/src/experiment/types.js +0 -423
  255. package/dist/src/experiment/types.js.map +0 -1
  256. package/dist/src/flowchart/over.d.ts +0 -227
  257. package/dist/src/flowchart/over.d.ts.map +0 -1
  258. package/dist/src/flowchart/over.js +0 -213
  259. package/dist/src/flowchart/over.js.map +0 -1
  260. package/dist/src/flowchart/patch.d.ts +0 -64
  261. package/dist/src/flowchart/patch.d.ts.map +0 -1
  262. package/dist/src/flowchart/patch.js +0 -67
  263. package/dist/src/flowchart/patch.js.map +0 -1
  264. package/dist/src/flowchart/values.d.ts +0 -271
  265. package/dist/src/flowchart/values.d.ts.map +0 -1
  266. package/dist/src/flowchart/values.js +0 -220
  267. package/dist/src/flowchart/values.js.map +0 -1
  268. package/dist/src/flowchart/window.d.ts +0 -306
  269. package/dist/src/flowchart/window.d.ts.map +0 -1
  270. package/dist/src/flowchart/window.js +0 -63
  271. package/dist/src/flowchart/window.js.map +0 -1
  272. package/dist/src/runtime/diff.d.ts +0 -36
  273. package/dist/src/runtime/diff.d.ts.map +0 -1
  274. package/dist/src/runtime/diff.js +0 -34
  275. package/dist/src/runtime/diff.js.map +0 -1
  276. package/dist/src/runtime/experiment.d.ts +0 -48
  277. package/dist/src/runtime/experiment.d.ts.map +0 -1
  278. package/dist/src/runtime/experiment.js +0 -10
  279. package/dist/src/runtime/experiment.js.map +0 -1
  280. package/dist/test/diff/diff.examples.d.ts +0 -313
  281. package/dist/test/diff/diff.examples.d.ts.map +0 -1
  282. package/dist/test/diff/diff.examples.js +0 -452
  283. package/dist/test/diff/diff.examples.js.map +0 -1
  284. package/dist/test/experiment/experiment.examples.d.ts +0 -1512
  285. package/dist/test/experiment/experiment.examples.d.ts.map +0 -1
  286. package/dist/test/experiment/experiment.examples.js +0 -609
  287. package/dist/test/experiment/experiment.examples.js.map +0 -1
@@ -0,0 +1,450 @@
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 kind over the app's own record: what the Schematic's kinds (#1386) and the
7
+ * Flowchart's (#1500) share. A kind maps the fields of the app's row to the
8
+ * builder's roles and closes the record behind East functions over beast2
9
+ * bytes — its stored rows a read holds, each one's roles beside its bytes; a
10
+ * drafted row's roles; the fields an author's card sets, any field at any
11
+ * depth; the shared editing session over the record with its patch door; the
12
+ * record read by key; its history, its form, its own Details and the app's
13
+ * check — so a builder's payload is one type whatever the rows hold, and its
14
+ * renderer needs no row type.
15
+ *
16
+ * A kind's record is bound three ways, as each builder's binding check tells
17
+ * them apart: `Record.bind(record)` with its patch door, editable — read
18
+ * whole, or through its source of the builder's slice with `entries:
19
+ * Data.bindPaged(record)` beside it; `Data.bind(record)`, read only and whole;
20
+ * or `Data.bindPaged(record)`, read only, through its source. Each builder
21
+ * keeps its own check and its own words; what this module holds is the same
22
+ * for every builder.
23
+ *
24
+ * @packageDocumentation
25
+ */
26
+ import { ArrayType, BlobType, BooleanType, DictType, East, EastTypeType, Expr, FunctionType, IntegerType, OptionType, StringType, StructType, isSubtype, isTypeEqual, none, some, toEastTypeValue, variant, } from "@elaraai/east";
27
+ import { RecordCommitInfoType } from "@elaraai/e3-types";
28
+ import { EditingReadinessType, EditingType, Fields, FieldSpecType, RecordSliceBindType, RecordSliceReadType, recordSliceReadPlatform, } from "@elaraai/east-ui/internal";
29
+ import { scheduleAccessor } from "../schedule/accessor.js";
30
+ import { fieldOf, fieldSetters } from "../schedule/fields.js";
31
+ import { scheduleEntriesSeam, scheduleRecordSession } from "../schedule/session.js";
32
+ import { ScheduleEntriesType, ScheduleFieldWriteType, ScheduleReadyEntryType } from "../schedule/types.js";
33
+ import { optionOf, scheduleEntryByKey, scheduleLastKey, typeText } from "../schedule/window.js";
34
+ import { RowInspectorType, rowInspector } from "./row-inspector.js";
35
+ // ============================================================================
36
+ // The wire
37
+ // ============================================================================
38
+ /** A record's commits, newest first, as its handle reads them. */
39
+ export const KindHistoryType = FunctionType([], OptionType(ArrayType(RecordCommitInfoType)));
40
+ /** The author's check over drafted entries, one result each. */
41
+ export const KindReadyType = FunctionType([ArrayType(ScheduleReadyEntryType)], ArrayType(EditingReadinessType));
42
+ /**
43
+ * What every kind over the app's record carries: how the record is read and
44
+ * written, and the inspector's form.
45
+ *
46
+ * @property editable - Whether the record is bound with its patch door: what its gestures, drops and edits write
47
+ * @property editing - The shared session over the record, with its patch door; `none` for a record bound read only
48
+ * @property entries - The record read by key, for a record read through its source or bound with `Data.bindPaged`; `none` for one read whole
49
+ * @property history - The record's commits, newest first; `none` for a record bound with `Data.bind` or `Data.bindPaged`
50
+ * @property fields - The inspector's form over the fields no role writes (`Fields`)
51
+ * @property inspector - The kind's own Details in place of its form, over bytes
52
+ * @property ready - The app's check on drafted rows, one result each
53
+ * @property set - The row with each field write applied in order — a field at any depth, its value as bytes at the field's type — and every other field as it was: what an author's card dropped on a row sets (#1390); `none` for a write naming no field of the row
54
+ * @property rowType - The record's row type
55
+ */
56
+ export const KindSideFields = {
57
+ editable: BooleanType,
58
+ editing: OptionType(EditingType),
59
+ entries: OptionType(ScheduleEntriesType),
60
+ history: OptionType(KindHistoryType),
61
+ fields: ArrayType(FieldSpecType),
62
+ inspector: OptionType(RowInspectorType),
63
+ ready: OptionType(KindReadyType),
64
+ set: FunctionType([BlobType, ArrayType(ScheduleFieldWriteType)], OptionType(BlobType)),
65
+ rowType: EastTypeType,
66
+ };
67
+ /**
68
+ * A kind's record read whole: its binding's `read()` — `Record.bind`'s or
69
+ * `Data.bind`'s — by key.
70
+ *
71
+ * @param handle - The record's binding
72
+ * @param rowType - Its row type
73
+ * @returns `()` → the record's rows, by key
74
+ */
75
+ export function kindWholeRows(handle, rowType) {
76
+ const Held = DictType(StringType, rowType);
77
+ const read = handle.read;
78
+ return East.function([], OptionType(Held), (_$) => East.value(some(read()), OptionType(Held)));
79
+ }
80
+ /**
81
+ * A kind's narrowing read complete through its source of the builder's slice
82
+ * — the record slice's `PagedScan`, over `recordSliceReadPlatform` — answering
83
+ * `none` while a search or a page is in flight.
84
+ *
85
+ * Through its source a kind reads what its narrowing holds and nothing else:
86
+ * the source's choices, each as the rail holds it. Read with `every`, it reads
87
+ * every row through its source instead, and never the narrowing, so a choice
88
+ * reads none of its rows again: the renderer draws the rows the narrowing
89
+ * leaves out as context, from the source's shown keys. An entry's row is its
90
+ * `row` — the source joins it — or its `value`, for an index that carries the
91
+ * whole row.
92
+ *
93
+ * @param part - The kind's source of the slice, bound once in the builder's payload (`recordSources(…).bind($)`)
94
+ * @param source - The source's name
95
+ * @param rowType - The kind's record's row type
96
+ * @param where - The kind, as a refusal names it
97
+ * @param every - Whether it reads every row, the narrowing read nowhere: what the narrowing leaves out draws as context
98
+ * @param remedy - How the refusal of a source over another record names the source to give
99
+ * @returns `()` → the rows the narrowing holds — or every row — by key; `none` while a search or a page is in flight
100
+ * @throws {Error} When the source narrows another record, or reads neither its rows nor an index carrying them
101
+ */
102
+ export function kindSourceRows(part, source, rowType, where, every, remedy) {
103
+ const type = Expr.type(part);
104
+ const fields = type.type === "Struct" ? type.fields : {};
105
+ const data = fields["data"];
106
+ const page = fields["pageWhere"];
107
+ const output = page?.type === "Function" ? page.output : undefined;
108
+ const collection = output === undefined ? undefined : optionOf(output);
109
+ const entry = collection?.type === "Array" ? collection.value : undefined;
110
+ const entryFields = entry?.type === "Struct" ? entry.fields : undefined;
111
+ const keyed = entryFields?.["key"] !== undefined && isTypeEqual(entryFields["key"], StringType);
112
+ // An entry's row: its `row`, which a joined read fills, or its `value`, when the index carries the whole row.
113
+ const joined = entryFields?.["row"] !== undefined && isTypeEqual(entryFields["row"], OptionType(rowType));
114
+ const carried = entryFields?.["value"] !== undefined && isTypeEqual(entryFields["value"], rowType);
115
+ const pages = page?.type === "Function" && page.inputs.length === 3 && isTypeEqual(page.inputs[0], RecordSliceReadType)
116
+ && isTypeEqual(page.inputs[1], IntegerType) && isTypeEqual(page.inputs[2], IntegerType);
117
+ const identified = data?.type === "Struct" && data.fields["id"] !== undefined && isTypeEqual(data.fields["id"], StringType)
118
+ && data.fields["revision"] !== undefined && data.fields["revision"].type === "Function";
119
+ const sliced = Object.entries(RecordSliceBindType.fields).every(([name, expected]) => fields[name] !== undefined && isSubtype(fields[name], expected));
120
+ if (!pages || !keyed || !(joined || carried) || !identified || !sliced) {
121
+ throw new Error(`${where}: the slice's source "${source}" narrows another record — ${remedy}: ` +
122
+ `Data.bindPaged(record, { indexes }), its rows joined or carried by its indexes`);
123
+ }
124
+ const Held = DictType(StringType, rowType);
125
+ const Entries = collection;
126
+ const noRows = `${where}: the slice's source "${source}" reads no rows — bind it with Data.bindPaged(record, { indexes, join: true })`;
127
+ return East.function([], OptionType(Held), ($) => {
128
+ // The source as the payload bound it, its members read here: the read captures the source alone.
129
+ const bound = $.const(part);
130
+ const countWhere = $.const(bound.countWhere);
131
+ const pageWhere = $.const(bound.pageWhere);
132
+ const id = $.const(bound.data.id);
133
+ const revision = $.const(bound.data.revision);
134
+ // The read: no narrowing with `every` — every row, the source's state read nowhere, so a choice reads nothing
135
+ // again and the renderer dims what it leaves out — else the rail's, each of the source's choices. Never a
136
+ // read by area.
137
+ let taken;
138
+ if (every) {
139
+ taken = $.const({ where: new Map(), area: none }, RecordSliceReadType);
140
+ }
141
+ else {
142
+ const read = $.const(bound.read);
143
+ const state = $.const(read());
144
+ taken = $.let({ where: state.where, area: none }, RecordSliceReadType);
145
+ }
146
+ const result = $.let(none, OptionType(Held));
147
+ $.match(recordSliceReadPlatform([Entries], id, revision, countWhere, pageWhere, taken), {
148
+ some: ($2, entries) => {
149
+ const held = $2.let(new Map(), Held);
150
+ $2.for(entries, ($3, e) => {
151
+ if (joined) {
152
+ $3.match(e.row, {
153
+ some: ($4, row) => { $4(held.insert(e.key, row)); },
154
+ none: ($4) => {
155
+ if (carried)
156
+ $4(held.insert(e.key, e.value));
157
+ else
158
+ $4.error(noRows);
159
+ },
160
+ });
161
+ }
162
+ else {
163
+ $3(held.insert(e.key, e.value));
164
+ }
165
+ });
166
+ $2.assign(result, some(held));
167
+ },
168
+ });
169
+ return result;
170
+ });
171
+ }
172
+ // ============================================================================
173
+ // The roles
174
+ // ============================================================================
175
+ /**
176
+ * A field's type by name, refused naming the role when the row lacks it.
177
+ *
178
+ * @param rowType - The kind's row type
179
+ * @param where - The kind, as a refusal names it
180
+ * @returns `(role, name)` → the field's type
181
+ */
182
+ export function fieldTypeOf(rowType, where) {
183
+ const fields = rowType.fields;
184
+ return (role, name) => {
185
+ const type = fields[name];
186
+ if (type === undefined)
187
+ throw new Error(`${where}: \`${role}\` names "${name}", a field the row does not have (${Object.keys(fields).join(", ")})`);
188
+ return type;
189
+ };
190
+ }
191
+ /**
192
+ * A role naming a field of one type: the field's name, refused naming the
193
+ * role, the field and its type.
194
+ *
195
+ * @param rowType - The kind's row type
196
+ * @param where - The kind, as a refusal names it
197
+ * @returns `(role, name, type, what)` → the field's name; `undefined` for a role not given
198
+ */
199
+ export function roleField(rowType, where) {
200
+ const typeOf = fieldTypeOf(rowType, where);
201
+ return (role, name, type, what) => {
202
+ if (name === undefined)
203
+ return undefined;
204
+ const held = typeOf(role, name);
205
+ if (!isTypeEqual(held, type))
206
+ throw new Error(`${where}: \`${role}\` names ${what} — "${name}" holds ${typeText(held)}`);
207
+ return name;
208
+ };
209
+ }
210
+ /**
211
+ * An accessor role, reified once and held to the type it returns, naming the
212
+ * role and what it returns.
213
+ *
214
+ * @typeParam T - The type it returns
215
+ * @param rowType - The kind's row type
216
+ * @param where - The kind, as a refusal names it
217
+ * @param role - The role, as the refusal names it
218
+ * @param out - The type it returns
219
+ * @param what - What it returns, as the refusal says it
220
+ * @param fn - What the kind was given
221
+ * @returns The accessor, reified; `undefined` when not given
222
+ * @throws {Error} When it is no function, or returns another type
223
+ */
224
+ export function accessorRole(rowType, where, role, out, what, fn) {
225
+ if (fn === undefined)
226
+ return undefined;
227
+ if (typeof fn !== "function")
228
+ throw new Error(`${where}: \`${role}\` is an accessor, (row, key) => ${what}`);
229
+ return scheduleAccessor(rowType, StringType, out, fn, (returns) => `${where}: \`${role}\` returns ${what} — and this one returns ${returns}`);
230
+ }
231
+ /**
232
+ * A row of the record's type, field by field: each field `set` names from it,
233
+ * every other from `source`.
234
+ *
235
+ * @param rowType - The record's row type
236
+ * @param source - The row, or a card's values, the other fields are read from
237
+ * @param set - The fields written, by name
238
+ * @returns The row
239
+ */
240
+ export function rowWith(rowType, source, set) {
241
+ return East.value(Object.fromEntries(Object.keys(rowType.fields).map((f) => [f, set[f] ?? fieldOf(source, f)])), rowType);
242
+ }
243
+ /**
244
+ * The row's fields less those its roles write on a drop: what a card's values
245
+ * give.
246
+ *
247
+ * @param rowType - The record's row type
248
+ * @param placed - The fields a drop writes
249
+ * @returns The values' type
250
+ */
251
+ export function valuesTypeOf(rowType, placed) {
252
+ return StructType(Object.fromEntries(Object.entries(rowType.fields).filter(([name]) => !placed.includes(name))));
253
+ }
254
+ /**
255
+ * An accessor's value for a row, bound in the block; `otherwise` for a kind
256
+ * with no such accessor.
257
+ *
258
+ * @typeParam T - The type the accessor returns
259
+ * @param $ - The block
260
+ * @param fn - The accessor, reified; `undefined` for none
261
+ * @param row - The row
262
+ * @param key - Its key
263
+ * @param wrap - What the value becomes
264
+ * @param otherwise - The value without the accessor
265
+ * @returns The value
266
+ */
267
+ export function called($, fn, row, key, wrap, otherwise) {
268
+ if (fn === undefined)
269
+ return otherwise;
270
+ const bound = $.const(fn);
271
+ return wrap(bound(row, key));
272
+ }
273
+ // ============================================================================
274
+ // The rows
275
+ // ============================================================================
276
+ /**
277
+ * A kind's stored rows a read holds, by key: each one's roles, read in the
278
+ * pass that reads the row, beside its bytes. The renderer puts its drafts in
279
+ * place itself.
280
+ *
281
+ * @param read - The kind's read: whole, or through its source
282
+ * @param rolesOf - A row's roles, from it and its key
283
+ * @param EntryType - A stored row's type: its roles beside its bytes
284
+ * @returns `()` → the rows, by key; `none` while the read is in flight
285
+ */
286
+ export function storedRows(read, rolesOf, EntryType) {
287
+ const Rows = DictType(StringType, EntryType);
288
+ return East.function([], OptionType(Rows), ($) => {
289
+ const readRows = $.const(read);
290
+ const roles = $.const(rolesOf);
291
+ const result = $.let(East.value(none, OptionType(Rows)), OptionType(Rows));
292
+ $.match(readRows(), {
293
+ some: ($2, held) => {
294
+ const out = $2.let(new Map(), Rows);
295
+ $2.for(held, ($3, row, key) => {
296
+ $3(out.insert(key, East.value({ roles: roles(row, key), row: East.Blob.encodeBeast(row, "v2") }, EntryType)));
297
+ });
298
+ $2.assign(result, some(out));
299
+ },
300
+ });
301
+ return result;
302
+ });
303
+ }
304
+ /**
305
+ * The rows a reader read of a record by area or by key, made its stored rows
306
+ * (#1393): each row's roles, read in the pass that reads it, beside its bytes,
307
+ * as `rows` gives them — from the rows as beast2 bytes of an `Array` of
308
+ * `{ key, row }` at the record's row type, which the reader encodes from what
309
+ * it read.
310
+ *
311
+ * @param rowType - The record's row type
312
+ * @param rolesOf - A row's roles, from it and its key
313
+ * @param EntryType - A stored row's type: its roles beside its bytes
314
+ * @returns `(bytes)` → the rows, by key
315
+ */
316
+ export function rowsReadOf(rowType, rolesOf, EntryType) {
317
+ const Read = ArrayType(StructType({ key: StringType, row: rowType }));
318
+ const Rows = DictType(StringType, EntryType);
319
+ return East.function([BlobType], Rows, ($, bytes) => {
320
+ const roles = $.const(rolesOf);
321
+ const read = $.const(bytes.decodeBeast(Read, "v2"));
322
+ const out = $.let(new Map(), Rows);
323
+ $.for(read, ($2, entry) => {
324
+ $2(out.insert(entry.key, East.value({ roles: roles(entry.row, entry.key), row: East.Blob.encodeBeast(entry.row, "v2") }, EntryType)));
325
+ });
326
+ return out;
327
+ });
328
+ }
329
+ /**
330
+ * A drafted row's roles, from its bytes and its key: what `rows` gives a
331
+ * stored one.
332
+ *
333
+ * @param rowType - The record's row type
334
+ * @param rolesOf - A row's roles, from it and its key
335
+ * @param RolesType - The roles' type
336
+ * @returns `(bytes, key)` → the roles
337
+ */
338
+ export function readOf(rowType, rolesOf, RolesType) {
339
+ return East.function([BlobType, StringType], RolesType, ($, bytes, key) => {
340
+ const roles = $.const(rolesOf);
341
+ return roles(bytes.decodeBeast(rowType, "v2"), key);
342
+ });
343
+ }
344
+ /**
345
+ * The app's check over drafted rows, one result each; a check that throws
346
+ * refuses its own row alone.
347
+ *
348
+ * @param rowType - The record's row type
349
+ * @param ready - The app's check over a row and its key
350
+ * @returns The check over bytes; `undefined` for none
351
+ */
352
+ export function readyOf(rowType, ready) {
353
+ if (ready === undefined)
354
+ return undefined;
355
+ const author = East.function([rowType, StringType], EditingReadinessType, ($, row, key) => $.const(ready(row, key), EditingReadinessType));
356
+ return East.function([ArrayType(ScheduleReadyEntryType)], ArrayType(EditingReadinessType), ($, batch) => {
357
+ const check = $.const(author);
358
+ return batch.map(($2, item) => {
359
+ const result = $2.let(variant("ready", null), EditingReadinessType);
360
+ $2.try(($3) => {
361
+ $3.assign(result, check(item.entry.decodeBeast(rowType, "v2"), item.id));
362
+ }).catch(($3, message) => {
363
+ $3.assign(result, variant("invalid", [{ field: "", message: East.str `Readiness check failed: ${message}` }]));
364
+ });
365
+ return result;
366
+ });
367
+ });
368
+ }
369
+ /**
370
+ * The row with each of a card's field writes applied in order, and every other
371
+ * field as it was (#1390): what an author's card dropped on a row sets — the
372
+ * fields its patch sets, each a field at any depth, its value as bytes at the
373
+ * field's type — through the setter Schedule's kinds write an inspector's edit
374
+ * with (`fieldSetters`).
375
+ *
376
+ * @param rowType - The record's row type
377
+ * @returns `(bytes, writes)` → the row written; `none` when a write names no field of the row
378
+ */
379
+ export function rowSetter(rowType) {
380
+ const setters = fieldSetters(rowType);
381
+ return East.function([BlobType, ArrayType(ScheduleFieldWriteType)], OptionType(BlobType), ($, bytes, writes) => {
382
+ // Each setter's path as East holds it: a field is named by its steps, never by text a dotted name could mimic.
383
+ const fns = setters.map((setter) => ({ path: $.const([...setter.path], ArrayType(StringType)), set: $.const(setter.set) }));
384
+ const row = $.let(bytes.decodeBeast(rowType, "v2"), rowType);
385
+ const named = $.let(true);
386
+ $.for(writes, ($2, write) => {
387
+ const found = $2.let(false);
388
+ for (const fn of fns) {
389
+ $2.if(East.equal(write.path, fn.path), ($3) => {
390
+ $3.assign(row, fn.set(row, write.value));
391
+ $3.assign(found, true);
392
+ });
393
+ }
394
+ $2.if(found.not(), ($3) => { $3.assign(named, false); });
395
+ });
396
+ return named.ifElse((_$2) => East.value(some(East.Blob.encodeBeast(row, "v2")), OptionType(BlobType)), (_$2) => East.value(none, OptionType(BlobType)));
397
+ });
398
+ }
399
+ /**
400
+ * A record's side of a kind on the wire ({@link KindSideFields}): whether it
401
+ * is editable, its session and its read by key, its history, its form, its
402
+ * own Details, the app's check, and the setter an author's card writes its
403
+ * fields through.
404
+ *
405
+ * @typeParam R - The record's row type
406
+ * @param bound - The record's binding
407
+ * @param entries - Its `entries`, checked
408
+ * @param byKey - The paged read its rows are read by key through, if any
409
+ * @param config - Its form's hints, its check and its own Details
410
+ * @param omitted - The fields its roles write, which its form leaves out
411
+ * @param where - The kind, as a refusal names it
412
+ * @returns The fields every kind carries
413
+ * @throws {Error} As `Fields.specs`, `rowInspector` and the patch door's check refuse
414
+ */
415
+ export function recordSide(bound, entries, byKey, config, omitted, where) {
416
+ const rowType = bound.rowType;
417
+ const form = Fields.specs(rowType, (config.fields ?? {}), [...new Set(omitted.filter((name) => name !== undefined))]);
418
+ const inspector = config.inspector === undefined ? undefined : rowInspector(config.inspector, rowType, `${where}: \`inspector\` is the kind's own Details — an East.function over the row and its writer: ` +
419
+ "East.function([RowType, FunctionType([RowType], NullType)], UIComponentType, ($, row, update) => …), RowType the record's row");
420
+ // Typed over the kind's row, as its author wrote it: called over the row the check decodes.
421
+ const ready = readyOf(rowType, config.ready);
422
+ let editing = none;
423
+ let seam;
424
+ let history = none;
425
+ if (bound.form === "record") {
426
+ // The shared session over the record (Schedule's `session.ts`): whole-entry drafts, keyed batches, Save through
427
+ // its patch door — its base the record's snapshot, or, read through a source, its revision.
428
+ const session = scheduleRecordSession(bound.handle, StringType, rowType, byKey === undefined ? undefined : entries);
429
+ const built = session.build();
430
+ editing = some(built.editing);
431
+ seam = built.entries;
432
+ history = some(session.history);
433
+ }
434
+ else if (byKey !== undefined) {
435
+ // Read only through `Data.bindPaged`: the record read by key through that binding itself.
436
+ seam = scheduleEntriesSeam(byKey, scheduleEntryByKey(byKey, StringType, rowType), scheduleLastKey(byKey, StringType));
437
+ }
438
+ return {
439
+ editable: bound.form === "record",
440
+ editing,
441
+ entries: seam ?? East.value(none, OptionType(ScheduleEntriesType)),
442
+ history,
443
+ fields: East.value(form, ArrayType(FieldSpecType)),
444
+ inspector: inspector === undefined ? East.value(none, OptionType(RowInspectorType)) : some(inspector),
445
+ ready: ready === undefined ? none : some(ready),
446
+ set: rowSetter(rowType),
447
+ rowType: toEastTypeValue(rowType),
448
+ };
449
+ }
450
+ //# sourceMappingURL=record-kind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-kind.js","sourceRoot":"","sources":["../../../src/utils/record-kind.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACH,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EACnI,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,GAE/D,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EACH,oBAAoB,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,uBAAuB,GAE9H,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC3G,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,u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See LICENSE for details.
4
+ */
5
+ /**
6
+ * The `views` prop of a component that switches between views: which of them an
7
+ * instance offers. Each entry is a literal tag (`"people"`) or a value or an
8
+ * expression of the component's view variant, or the whole list is an expression
9
+ * of an array of it, so a page's own state can choose them as it runs. The list
10
+ * chooses and the component orders: its switch shows in its own order, whatever
11
+ * order the entries come in. One view left, no switch shows at all.
12
+ *
13
+ * Nothing is left out by an empty list. Written in the code, one is refused, as
14
+ * saying nothing; read as a page runs — a multi-select with nothing chosen — it
15
+ * means every view, as leaving the prop out does.
16
+ *
17
+ * @packageDocumentation
18
+ */
19
+ import { ArrayType, type SubtypeExprOrValue, type VariantType } from "@elaraai/east";
20
+ /**
21
+ * Which views an instance offers: literal tags or variants, or an expression of an array of the variant.
22
+ *
23
+ * @typeParam V - The component's view variant
24
+ * @typeParam L - Its tags, as literals
25
+ */
26
+ export type ViewsProp<V extends VariantType, L extends string> = readonly (L | SubtypeExprOrValue<V>)[] | SubtypeExprOrValue<ArrayType<V>>;
27
+ /**
28
+ * The tags a `views` prop lists, where the code spells every one.
29
+ *
30
+ * @param given - The prop
31
+ * @returns Its tags; `undefined` for a prop left out, or one holding anything read as the page runs
32
+ */
33
+ export declare function literalViews(given: unknown): readonly string[] | undefined;
34
+ /**
35
+ * The first view a component opens on, where its author named none: the first of its own order the code's `views` lists.
36
+ *
37
+ * @param order - The component's views, in its switch's order
38
+ * @param given - The `views` prop
39
+ * @returns The view; the component's first where the prop lists no literal tags
40
+ */
41
+ export declare function firstView<L extends string>(order: readonly L[], given: unknown): L;
42
+ /**
43
+ * The `views` prop as the payload holds it: every entry a case of the variant, an empty array meaning every view.
44
+ *
45
+ * @param builder - The component's name, for what a refusal says
46
+ * @param type - The component's view variant
47
+ * @param given - The prop
48
+ * @param opening - The view the author opens the component on, when the code names one
49
+ * @param prop - The prop's name, for what a refusal says
50
+ * @returns The array of the variant
51
+ * @throws {Error} Naming the change to make: an empty list written in the code, a literal tag that is no view of the
52
+ * component, or an `opening` view the code's list leaves out
53
+ */
54
+ export declare function viewsProp<V extends VariantType, L extends string>(builder: string, type: V, given: ViewsProp<V, L> | undefined, opening?: L, prop?: string): SubtypeExprOrValue<ArrayType<V>>;
55
+ //# sourceMappingURL=views.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views.d.ts","sourceRoot":"","sources":["../../../src/utils/views.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,SAAS,EAAgC,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAEnH;;;;;GAKG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,WAAW,EAAE,CAAC,SAAS,MAAM,IAAI,SAAS,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3I;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,CAE1E;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAGlF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,WAAW,EAAE,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC,EAAE,IAAI,GAAE,MAAgB,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAetM"}
@@ -0,0 +1,72 @@
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 `views` prop of a component that switches between views: which of them an
7
+ * instance offers. Each entry is a literal tag (`"people"`) or a value or an
8
+ * expression of the component's view variant, or the whole list is an expression
9
+ * of an array of it, so a page's own state can choose them as it runs. The list
10
+ * chooses and the component orders: its switch shows in its own order, whatever
11
+ * order the entries come in. One view left, no switch shows at all.
12
+ *
13
+ * Nothing is left out by an empty list. Written in the code, one is refused, as
14
+ * saying nothing; read as a page runs — a multi-select with nothing chosen — it
15
+ * means every view, as leaving the prop out does.
16
+ *
17
+ * @packageDocumentation
18
+ */
19
+ import { ArrayType, East, variant } from "@elaraai/east";
20
+ /**
21
+ * The tags a `views` prop lists, where the code spells every one.
22
+ *
23
+ * @param given - The prop
24
+ * @returns Its tags; `undefined` for a prop left out, or one holding anything read as the page runs
25
+ */
26
+ export function literalViews(given) {
27
+ return Array.isArray(given) && given.every(entry => typeof entry === "string") ? given : undefined;
28
+ }
29
+ /**
30
+ * The first view a component opens on, where its author named none: the first of its own order the code's `views` lists.
31
+ *
32
+ * @param order - The component's views, in its switch's order
33
+ * @param given - The `views` prop
34
+ * @returns The view; the component's first where the prop lists no literal tags
35
+ */
36
+ export function firstView(order, given) {
37
+ const listed = literalViews(given);
38
+ return order.find(view => listed === undefined || listed.includes(view)) ?? order[0];
39
+ }
40
+ /**
41
+ * The `views` prop as the payload holds it: every entry a case of the variant, an empty array meaning every view.
42
+ *
43
+ * @param builder - The component's name, for what a refusal says
44
+ * @param type - The component's view variant
45
+ * @param given - The prop
46
+ * @param opening - The view the author opens the component on, when the code names one
47
+ * @param prop - The prop's name, for what a refusal says
48
+ * @returns The array of the variant
49
+ * @throws {Error} Naming the change to make: an empty list written in the code, a literal tag that is no view of the
50
+ * component, or an `opening` view the code's list leaves out
51
+ */
52
+ export function viewsProp(builder, type, given, opening, prop = "views") {
53
+ const arrayType = ArrayType(type);
54
+ if (given === undefined)
55
+ return East.value([], arrayType);
56
+ if (!Array.isArray(given))
57
+ return East.value(given, arrayType);
58
+ const cases = Object.keys(type.cases).map(tag => `"${tag}"`).join(", ");
59
+ if (given.length === 0)
60
+ throw new Error(`${builder}: \`${prop}\` lists at least one of ${cases} — leave it out to offer every view`);
61
+ for (const entry of given) {
62
+ if (typeof entry === "string" && !Object.hasOwn(type.cases, entry))
63
+ throw new Error(`${builder}: \`${prop}\` holds "${entry}", which is none of ${cases}`);
64
+ }
65
+ const listed = literalViews(given);
66
+ if (opening !== undefined && listed !== undefined && !listed.includes(opening)) {
67
+ throw new Error(`${builder}: it opens on "${opening}", and \`${prop}\` leaves it out — list it, or open on one of ${listed.map(tag => `"${tag}"`).join(", ")}`);
68
+ }
69
+ const entries = given.map(entry => typeof entry === "string" ? variant(entry, null) : entry);
70
+ return East.value(entries, arrayType);
71
+ }
72
+ //# sourceMappingURL=views.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views.js","sourceRoot":"","sources":["../../../src/utils/views.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAA4D,MAAM,eAAe,CAAC;AAUnH;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACvC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,KAA0B,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5H,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAmB,KAAmB,EAAE,KAAc;IAC3E,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,K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