@elaraai/e3-ui 1.0.96 → 1.0.98

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 (304) hide show
  1. package/dist/src/allocation/index.d.ts +258 -7
  2. package/dist/src/allocation/index.d.ts.map +1 -1
  3. package/dist/src/allocation/index.js +30 -1
  4. package/dist/src/allocation/index.js.map +1 -1
  5. package/dist/src/allocation/types.d.ts +41 -0
  6. package/dist/src/allocation/types.d.ts.map +1 -1
  7. package/dist/src/allocation/types.js +35 -0
  8. package/dist/src/allocation/types.js.map +1 -1
  9. package/dist/src/bind/data-indexed.d.ts +31 -4
  10. package/dist/src/bind/data-indexed.d.ts.map +1 -1
  11. package/dist/src/bind/data-indexed.js +54 -10
  12. package/dist/src/bind/data-indexed.js.map +1 -1
  13. package/dist/src/calendar/index.d.ts +540 -14
  14. package/dist/src/calendar/index.d.ts.map +1 -1
  15. package/dist/src/calendar/index.js +43 -7
  16. package/dist/src/calendar/index.js.map +1 -1
  17. package/dist/src/calendar/paged.d.ts +89 -0
  18. package/dist/src/calendar/paged.d.ts.map +1 -0
  19. package/dist/src/calendar/paged.js +148 -0
  20. package/dist/src/calendar/paged.js.map +1 -0
  21. package/dist/src/flowchart/payload.d.ts +156 -0
  22. package/dist/src/flowchart/payload.d.ts.map +1 -1
  23. package/dist/src/flowchart/window.d.ts +12 -0
  24. package/dist/src/flowchart/window.d.ts.map +1 -1
  25. package/dist/src/index.d.ts +11 -2
  26. package/dist/src/index.d.ts.map +1 -1
  27. package/dist/src/index.js +19 -0
  28. package/dist/src/index.js.map +1 -1
  29. package/dist/src/internal.d.ts +11 -5
  30. package/dist/src/internal.d.ts.map +1 -1
  31. package/dist/src/internal.js +28 -7
  32. package/dist/src/internal.js.map +1 -1
  33. package/dist/src/plan/builders.d.ts +12 -8
  34. package/dist/src/plan/builders.d.ts.map +1 -1
  35. package/dist/src/plan/builders.js +12 -8
  36. package/dist/src/plan/builders.js.map +1 -1
  37. package/dist/src/plan/event-rows.d.ts +228 -156
  38. package/dist/src/plan/event-rows.d.ts.map +1 -1
  39. package/dist/src/plan/event-rows.js +239 -54
  40. package/dist/src/plan/event-rows.js.map +1 -1
  41. package/dist/src/plan/index.d.ts +5 -0
  42. package/dist/src/plan/index.d.ts.map +1 -1
  43. package/dist/src/plan/index.js +3 -0
  44. package/dist/src/plan/index.js.map +1 -1
  45. package/dist/src/plan/ir.d.ts +70 -0
  46. package/dist/src/plan/ir.d.ts.map +1 -1
  47. package/dist/src/plan/ordered-source.d.ts +2038 -1
  48. package/dist/src/plan/ordered-source.d.ts.map +1 -1
  49. package/dist/src/plan/ordered-source.js +19 -11
  50. package/dist/src/plan/ordered-source.js.map +1 -1
  51. package/dist/src/plan/plan.d.ts +513 -32
  52. package/dist/src/plan/plan.d.ts.map +1 -1
  53. package/dist/src/plan/plan.js +119 -32
  54. package/dist/src/plan/plan.js.map +1 -1
  55. package/dist/src/plan/root.d.ts +4 -2
  56. package/dist/src/plan/root.d.ts.map +1 -1
  57. package/dist/src/plan/root.js +6 -4
  58. package/dist/src/plan/root.js.map +1 -1
  59. package/dist/src/plan/series.d.ts +13 -0
  60. package/dist/src/plan/series.d.ts.map +1 -1
  61. package/dist/src/plan/series.js +61 -7
  62. package/dist/src/plan/series.js.map +1 -1
  63. package/dist/src/plan/types.d.ts +14 -0
  64. package/dist/src/plan/types.d.ts.map +1 -1
  65. package/dist/src/plan/types.js +8 -0
  66. package/dist/src/plan/types.js.map +1 -1
  67. package/dist/src/roster/index.d.ts +608 -20
  68. package/dist/src/roster/index.d.ts.map +1 -1
  69. package/dist/src/roster/index.js +103 -29
  70. package/dist/src/roster/index.js.map +1 -1
  71. package/dist/src/roster/library.d.ts +12 -2
  72. package/dist/src/roster/library.d.ts.map +1 -1
  73. package/dist/src/roster/library.js +8 -0
  74. package/dist/src/roster/library.js.map +1 -1
  75. package/dist/src/roster/lists.d.ts +59 -12
  76. package/dist/src/roster/lists.d.ts.map +1 -1
  77. package/dist/src/roster/lists.js +51 -58
  78. package/dist/src/roster/lists.js.map +1 -1
  79. package/dist/src/roster/times.d.ts +402 -0
  80. package/dist/src/roster/times.d.ts.map +1 -1
  81. package/dist/src/roster/types.d.ts +913 -1
  82. package/dist/src/roster/types.d.ts.map +1 -1
  83. package/dist/src/roster/types.js +43 -3
  84. package/dist/src/roster/types.js.map +1 -1
  85. package/dist/src/schedule/cell-checks.d.ts +85 -0
  86. package/dist/src/schedule/cell-checks.d.ts.map +1 -0
  87. package/dist/src/schedule/cell-checks.js +211 -0
  88. package/dist/src/schedule/cell-checks.js.map +1 -0
  89. package/dist/src/schedule/events.d.ts +42 -10
  90. package/dist/src/schedule/events.d.ts.map +1 -1
  91. package/dist/src/schedule/events.js +349 -155
  92. package/dist/src/schedule/events.js.map +1 -1
  93. package/dist/src/schedule/fields.d.ts +134 -0
  94. package/dist/src/schedule/fields.d.ts.map +1 -0
  95. package/dist/src/schedule/fields.js +207 -0
  96. package/dist/src/schedule/fields.js.map +1 -0
  97. package/dist/src/schedule/library.d.ts +11 -3
  98. package/dist/src/schedule/library.d.ts.map +1 -1
  99. package/dist/src/schedule/library.js +9 -6
  100. package/dist/src/schedule/library.js.map +1 -1
  101. package/dist/src/schedule/optimise.d.ts +124 -0
  102. package/dist/src/schedule/optimise.d.ts.map +1 -0
  103. package/dist/src/schedule/optimise.js +140 -0
  104. package/dist/src/schedule/optimise.js.map +1 -0
  105. package/dist/src/schedule/pages.d.ts +76 -0
  106. package/dist/src/schedule/pages.d.ts.map +1 -0
  107. package/dist/src/schedule/pages.js +86 -0
  108. package/dist/src/schedule/pages.js.map +1 -0
  109. package/dist/src/schedule/record-window.d.ts +119 -6
  110. package/dist/src/schedule/record-window.d.ts.map +1 -1
  111. package/dist/src/schedule/record-window.js +139 -60
  112. package/dist/src/schedule/record-window.js.map +1 -1
  113. package/dist/src/schedule/resources.d.ts +8 -4
  114. package/dist/src/schedule/resources.d.ts.map +1 -1
  115. package/dist/src/schedule/resources.js +35 -15
  116. package/dist/src/schedule/resources.js.map +1 -1
  117. package/dist/src/schedule/session.d.ts +14 -0
  118. package/dist/src/schedule/session.d.ts.map +1 -1
  119. package/dist/src/schedule/session.js +29 -17
  120. package/dist/src/schedule/session.js.map +1 -1
  121. package/dist/src/schedule/types.d.ts +426 -36
  122. package/dist/src/schedule/types.d.ts.map +1 -1
  123. package/dist/src/schedule/types.js +63 -17
  124. package/dist/src/schedule/types.js.map +1 -1
  125. package/dist/src/schedule/window.d.ts +30 -9
  126. package/dist/src/schedule/window.d.ts.map +1 -1
  127. package/dist/src/schedule/window.js +101 -49
  128. package/dist/src/schedule/window.js.map +1 -1
  129. package/dist/src/schematic/index.d.ts +277 -0
  130. package/dist/src/schematic/index.d.ts.map +1 -0
  131. package/dist/src/schematic/index.js +206 -0
  132. package/dist/src/schematic/index.js.map +1 -0
  133. package/dist/src/schematic/kinds.d.ts +501 -0
  134. package/dist/src/schematic/kinds.d.ts.map +1 -0
  135. package/dist/src/schematic/kinds.js +1027 -0
  136. package/dist/src/schematic/kinds.js.map +1 -0
  137. package/dist/src/schematic/layers.d.ts +74 -0
  138. package/dist/src/schematic/layers.d.ts.map +1 -0
  139. package/dist/src/schematic/layers.js +99 -0
  140. package/dist/src/schematic/layers.js.map +1 -0
  141. package/dist/src/schematic/library.d.ts +202 -0
  142. package/dist/src/schematic/library.d.ts.map +1 -0
  143. package/dist/src/schematic/library.js +244 -0
  144. package/dist/src/schematic/library.js.map +1 -0
  145. package/dist/src/schematic/payload.d.ts +8360 -0
  146. package/dist/src/schematic/payload.d.ts.map +1 -0
  147. package/dist/src/schematic/payload.js +446 -0
  148. package/dist/src/schematic/payload.js.map +1 -0
  149. package/dist/src/schematic/schematic.d.ts +27 -0
  150. package/dist/src/schematic/schematic.d.ts.map +1 -0
  151. package/dist/src/schematic/schematic.js +17 -0
  152. package/dist/src/schematic/schematic.js.map +1 -0
  153. package/dist/src/schematic/shapes.d.ts +150 -0
  154. package/dist/src/schematic/shapes.d.ts.map +1 -0
  155. package/dist/src/schematic/shapes.js +171 -0
  156. package/dist/src/schematic/shapes.js.map +1 -0
  157. package/dist/src/schematic/templates.d.ts +96 -0
  158. package/dist/src/schematic/templates.d.ts.map +1 -0
  159. package/dist/src/schematic/templates.js +91 -0
  160. package/dist/src/schematic/templates.js.map +1 -0
  161. package/dist/src/schematic/types.d.ts +5766 -0
  162. package/dist/src/schematic/types.d.ts.map +1 -0
  163. package/dist/src/schematic/types.js +688 -0
  164. package/dist/src/schematic/types.js.map +1 -0
  165. package/dist/src/schematic/window.d.ts +212 -0
  166. package/dist/src/schematic/window.d.ts.map +1 -0
  167. package/dist/src/schematic/window.js +337 -0
  168. package/dist/src/schematic/window.js.map +1 -0
  169. package/dist/src/sheet/editing-bridge.d.ts +4 -2
  170. package/dist/src/sheet/editing-bridge.d.ts.map +1 -1
  171. package/dist/src/sheet/editing-bridge.js +8 -2
  172. package/dist/src/sheet/editing-bridge.js.map +1 -1
  173. package/dist/src/sheet/editing-types.d.ts +9 -5
  174. package/dist/src/sheet/editing-types.d.ts.map +1 -1
  175. package/dist/src/sheet/editing-types.js +9 -5
  176. package/dist/src/sheet/editing-types.js.map +1 -1
  177. package/dist/src/sheet/index.d.ts +18 -8
  178. package/dist/src/sheet/index.d.ts.map +1 -1
  179. package/dist/src/sheet/index.js +15 -7
  180. package/dist/src/sheet/index.js.map +1 -1
  181. package/dist/src/sheet/optimise.d.ts +69 -0
  182. package/dist/src/sheet/optimise.d.ts.map +1 -0
  183. package/dist/src/sheet/optimise.js +81 -0
  184. package/dist/src/sheet/optimise.js.map +1 -0
  185. package/dist/src/sheet/registers.d.ts +5 -5
  186. package/dist/src/sheet/registers.js +5 -5
  187. package/dist/src/sheet/root.d.ts +2 -0
  188. package/dist/src/sheet/root.d.ts.map +1 -1
  189. package/dist/src/sheet/root.js +2 -2
  190. package/dist/src/sheet/root.js.map +1 -1
  191. package/dist/src/sheet/sheet.d.ts +753 -573
  192. package/dist/src/sheet/sheet.d.ts.map +1 -1
  193. package/dist/src/sheet/sheet.js +45 -13
  194. package/dist/src/sheet/sheet.js.map +1 -1
  195. package/dist/src/sheet/types.d.ts +92 -12
  196. package/dist/src/sheet/types.d.ts.map +1 -1
  197. package/dist/src/sheet/types.js +4 -8
  198. package/dist/src/sheet/types.js.map +1 -1
  199. package/dist/src/utils/keyed-rows.d.ts +41 -0
  200. package/dist/src/utils/keyed-rows.d.ts.map +1 -0
  201. package/dist/src/utils/keyed-rows.js +64 -0
  202. package/dist/src/utils/keyed-rows.js.map +1 -0
  203. package/dist/src/utils/optimise.d.ts +79 -0
  204. package/dist/src/utils/optimise.d.ts.map +1 -0
  205. package/dist/src/utils/optimise.js +46 -0
  206. package/dist/src/utils/optimise.js.map +1 -0
  207. package/dist/test/allocation/allocation.examples.d.ts +6 -18
  208. package/dist/test/allocation/allocation.examples.d.ts.map +1 -1
  209. package/dist/test/allocation/allocation.examples.js +3 -3
  210. package/dist/test/allocation/allocation.examples.js.map +1 -1
  211. package/dist/test/allocation/optimise.examples.d.ts +109 -0
  212. package/dist/test/allocation/optimise.examples.d.ts.map +1 -0
  213. package/dist/test/allocation/optimise.examples.js +223 -0
  214. package/dist/test/allocation/optimise.examples.js.map +1 -0
  215. package/dist/test/bind/data/data.examples.d.ts +540 -36
  216. package/dist/test/bind/data/data.examples.d.ts.map +1 -1
  217. package/dist/test/bind/data/data.examples.js +66 -2
  218. package/dist/test/bind/data/data.examples.js.map +1 -1
  219. package/dist/test/bind/record/record.examples.d.ts +1 -3
  220. package/dist/test/bind/record/record.examples.d.ts.map +1 -1
  221. package/dist/test/calendar/calendar-records.examples.d.ts.map +1 -1
  222. package/dist/test/calendar/calendar-records.examples.js +3 -3
  223. package/dist/test/calendar/calendar-records.examples.js.map +1 -1
  224. package/dist/test/calendar/calendar-windows.examples.d.ts +9 -0
  225. package/dist/test/calendar/calendar-windows.examples.d.ts.map +1 -0
  226. package/dist/test/calendar/calendar-windows.examples.js +111 -0
  227. package/dist/test/calendar/calendar-windows.examples.js.map +1 -0
  228. package/dist/test/calendar/calendar.examples.d.ts +7 -21
  229. package/dist/test/calendar/calendar.examples.d.ts.map +1 -1
  230. package/dist/test/calendar/calendar.examples.js +7 -7
  231. package/dist/test/calendar/calendar.examples.js.map +1 -1
  232. package/dist/test/calendar/optimise.examples.d.ts +132 -0
  233. package/dist/test/calendar/optimise.examples.d.ts.map +1 -0
  234. package/dist/test/calendar/optimise.examples.js +75 -0
  235. package/dist/test/calendar/optimise.examples.js.map +1 -0
  236. package/dist/test/examples-package.d.ts +46 -10
  237. package/dist/test/examples-package.d.ts.map +1 -1
  238. package/dist/test/examples-package.js +142 -32
  239. package/dist/test/examples-package.js.map +1 -1
  240. package/dist/test/flowchart/flowchart.examples.d.ts +10 -30
  241. package/dist/test/flowchart/flowchart.examples.d.ts.map +1 -1
  242. package/dist/test/plan/optimise.examples.d.ts +207 -0
  243. package/dist/test/plan/optimise.examples.d.ts.map +1 -0
  244. package/dist/test/plan/optimise.examples.js +98 -0
  245. package/dist/test/plan/optimise.examples.js.map +1 -0
  246. package/dist/test/plan/plan-events.examples.d.ts +8 -24
  247. package/dist/test/plan/plan-events.examples.d.ts.map +1 -1
  248. package/dist/test/plan/plan-events.examples.js +3 -3
  249. package/dist/test/plan/plan-events.examples.js.map +1 -1
  250. package/dist/test/plan/plan-records.examples.d.ts +200 -19
  251. package/dist/test/plan/plan-records.examples.d.ts.map +1 -1
  252. package/dist/test/plan/plan-records.examples.js +125 -28
  253. package/dist/test/plan/plan-records.examples.js.map +1 -1
  254. package/dist/test/plan/plan-windows.examples.d.ts +853 -36
  255. package/dist/test/plan/plan-windows.examples.d.ts.map +1 -1
  256. package/dist/test/plan/plan-windows.examples.js +166 -29
  257. package/dist/test/plan/plan-windows.examples.js.map +1 -1
  258. package/dist/test/plan/plan.examples.d.ts +7 -21
  259. package/dist/test/plan/plan.examples.d.ts.map +1 -1
  260. package/dist/test/plan/plan.examples.js +11 -9
  261. package/dist/test/plan/plan.examples.js.map +1 -1
  262. package/dist/test/roster/domain.examples.d.ts +804 -0
  263. package/dist/test/roster/domain.examples.d.ts.map +1 -1
  264. package/dist/test/roster/domain.examples.js +3 -3
  265. package/dist/test/roster/domain.examples.js.map +1 -1
  266. package/dist/test/roster/optimise.examples.d.ts +485 -0
  267. package/dist/test/roster/optimise.examples.d.ts.map +1 -0
  268. package/dist/test/roster/optimise.examples.js +155 -0
  269. package/dist/test/roster/optimise.examples.js.map +1 -0
  270. package/dist/test/roster/roster-records.examples.d.ts +6 -18
  271. package/dist/test/roster/roster-records.examples.d.ts.map +1 -1
  272. package/dist/test/roster/roster-records.examples.js +1 -1
  273. package/dist/test/roster/roster-records.examples.js.map +1 -1
  274. package/dist/test/roster/roster.examples.d.ts +3391 -21
  275. package/dist/test/roster/roster.examples.d.ts.map +1 -1
  276. package/dist/test/roster/roster.examples.js +54 -7
  277. package/dist/test/roster/roster.examples.js.map +1 -1
  278. package/dist/test/roster/warehouse.d.ts +150 -7
  279. package/dist/test/roster/warehouse.d.ts.map +1 -1
  280. package/dist/test/roster/warehouse.js +36 -11
  281. package/dist/test/roster/warehouse.js.map +1 -1
  282. package/dist/test/schedule/schedule.examples.d.ts +1 -3
  283. package/dist/test/schedule/schedule.examples.d.ts.map +1 -1
  284. package/dist/test/schematic/schematic-records.examples.d.ts +444 -0
  285. package/dist/test/schematic/schematic-records.examples.d.ts.map +1 -0
  286. package/dist/test/schematic/schematic-records.examples.js +205 -0
  287. package/dist/test/schematic/schematic-records.examples.js.map +1 -0
  288. package/dist/test/schematic/schematic.examples.d.ts +2289 -0
  289. package/dist/test/schematic/schematic.examples.d.ts.map +1 -0
  290. package/dist/test/schematic/schematic.examples.js +453 -0
  291. package/dist/test/schematic/schematic.examples.js.map +1 -0
  292. package/dist/test/sheet/optimise.examples.d.ts +177 -0
  293. package/dist/test/sheet/optimise.examples.d.ts.map +1 -0
  294. package/dist/test/sheet/optimise.examples.js +75 -0
  295. package/dist/test/sheet/optimise.examples.js.map +1 -0
  296. package/dist/test/sheet/sheet-records.examples.d.ts +95 -204
  297. package/dist/test/sheet/sheet-records.examples.d.ts.map +1 -1
  298. package/dist/test/sheet/sheet-records.examples.js +42 -17
  299. package/dist/test/sheet/sheet-records.examples.js.map +1 -1
  300. package/dist/test/sheet/sheet.examples.d.ts +17 -33
  301. package/dist/test/sheet/sheet.examples.d.ts.map +1 -1
  302. package/dist/test/sheet/sheet.examples.js +18 -15
  303. package/dist/test/sheet/sheet.examples.js.map +1 -1
  304. package/package.json +11 -11
@@ -0,0 +1,150 @@
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 Schematic's pattern, style and geometry helpers (`Schematic Builder
7
+ * Spec.md` §4.7, D35): `Schematic.outline()`, `hatch()`, `solid()`,
8
+ * `dashed()`, `rect()`, `circle()`, `polyline()` and `polygon()`. An accessor
9
+ * builds a zone's pattern, a link's style, a footprint or a zone's shape with
10
+ * them from the row's own fields — `(unit) => some(Schematic.circle(unit.radius))`
11
+ * — so the app's record holds only its own types. Each returns an East value
12
+ * of its type, so an accessor's `match` arms may each return one.
13
+ *
14
+ * Geometry is drawn about its entity's anchor (D22): an item's centre, or a
15
+ * zone's box centre. A `circle` centres on it, and a `polyline`'s or a
16
+ * `polygon`'s vertices are offsets from it in world units: the row's own
17
+ * points, `{ x, y }` (a bulge of 0) or `{ x, y, bulge }`.
18
+ *
19
+ * @packageDocumentation
20
+ */
21
+ import { ArrayType, FloatType, StructType, variant, type ExprType, type SubtypeExprOrValue } from "@elaraai/east";
22
+ import { SchematicGeometryType, SchematicLinkStyleType, SchematicVertexType, SchematicZonePatternType } from "./types.js";
23
+ /** String literal form of `Schematic.Types.Tone`'s tags. */
24
+ export type SchematicToneLiteral = "brand" | "ink" | "muted" | "success" | "warning" | "danger";
25
+ /** Style configuration accepted by {@link SchematicShapes}' `outline`, `hatch`, `solid` and `dashed`. */
26
+ export interface SchematicPatternConfig {
27
+ /** Theme tone for the stroke or the hatch lines. */
28
+ tone?: SchematicToneLiteral;
29
+ /** Hatch line spacing in pixels (hatch only): a number, or a Float of the row's. */
30
+ spacing?: SubtypeExprOrValue<FloatType>;
31
+ /** Hatch line angle in degrees (hatch only): a number, or a Float of the row's. */
32
+ angle?: SubtypeExprOrValue<FloatType>;
33
+ /** Stroke width in pixels (links only): a number, or a Float of the row's. */
34
+ weight?: SubtypeExprOrValue<FloatType>;
35
+ }
36
+ /**
37
+ * A tone's option, from its literal.
38
+ *
39
+ * @param tone - The tone's tag, if any
40
+ * @returns `some` of the tone, or `none`
41
+ * @internal
42
+ */
43
+ export declare function toneValue(tone: SchematicToneLiteral | undefined): variant<"none", null> | variant<"some", variant<SchematicToneLiteral, null>>;
44
+ /**
45
+ * A polyline or polygon vertex for `polyline` and `polygon`: an offset from
46
+ * the entity's anchor, plus an optional DXF `bulge`.
47
+ *
48
+ * @property x - Offset from the anchor along x, in world units
49
+ * @property y - Offset from the anchor along y, in world units
50
+ * @property bulge - DXF bulge for the edge to the next vertex; `0` (default) is straight, nonzero is a circular arc (`tan(includedAngle / 4)`, sign = turn direction)
51
+ */
52
+ export interface SchematicVertexInput {
53
+ /** Offset from the anchor along x, in world units. */
54
+ x: SubtypeExprOrValue<FloatType>;
55
+ /** Offset from the anchor along y, in world units. */
56
+ y: SubtypeExprOrValue<FloatType>;
57
+ /** DXF bulge for the edge to the next vertex; `0` (default) = straight, nonzero = arc. */
58
+ bulge?: SubtypeExprOrValue<FloatType>;
59
+ }
60
+ /**
61
+ * Vertices accepted by `polyline` and `polygon`: a plain array of
62
+ * `{ x, y, bulge? }` (bulge defaults to `0`), or an East array of the row's own
63
+ * points — `{ x, y }` Floats, each with a bulge of 0, or `{ x, y, bulge }`
64
+ * ({@link SchematicVertexType}).
65
+ */
66
+ export type SchematicVertices = readonly SchematicVertexInput[] | ExprType<ArrayType<StructType<{
67
+ x: FloatType;
68
+ y: FloatType;
69
+ }>>> | SubtypeExprOrValue<ArrayType<SchematicVertexType>>;
70
+ /** Optional configuration for `polyline`. */
71
+ export interface SchematicPolylineConfig {
72
+ /** Band width in world units — the stroke widens into a duct bank or an aisle: a number, or a Float of the row's. */
73
+ width?: SubtypeExprOrValue<FloatType>;
74
+ }
75
+ /**
76
+ * The pattern, style and geometry helpers the `Schematic` namespace carries.
77
+ */
78
+ export declare const SchematicShapes: {
79
+ /**
80
+ * Builds an `outline` zone pattern value — the dashed boundary with an
81
+ * eyebrow label (halls, cages).
82
+ *
83
+ * @param config - Optional style configuration (`tone`)
84
+ * @returns A `Schematic.Types.ZonePattern` value
85
+ */
86
+ readonly outline: (config?: SchematicPatternConfig) => ExprType<SchematicZonePatternType>;
87
+ /**
88
+ * Builds a `hatch` zone pattern value — the hatched band (hot and cold
89
+ * aisles, exclusion zones): an annotation, holding no items and taking no
90
+ * tap.
91
+ *
92
+ * @param config - Optional style configuration (`tone`, `spacing`, `angle`)
93
+ * @returns A `Schematic.Types.ZonePattern` value
94
+ */
95
+ readonly hatch: (config?: SchematicPatternConfig) => ExprType<SchematicZonePatternType>;
96
+ /**
97
+ * Builds a `solid` link style value — a physical run (fibre, power cable).
98
+ *
99
+ * @param config - Optional stroke configuration (`tone`, `weight`)
100
+ * @returns A `Schematic.Types.LinkStyle` value
101
+ */
102
+ readonly solid: (config?: SchematicPatternConfig) => ExprType<SchematicLinkStyleType>;
103
+ /**
104
+ * Builds a `dashed` link style value — a routing or logical connection.
105
+ *
106
+ * @param config - Optional stroke configuration (`tone`, `weight`)
107
+ * @returns A `Schematic.Types.LinkStyle` value
108
+ */
109
+ readonly dashed: (config?: SchematicPatternConfig) => ExprType<SchematicLinkStyleType>;
110
+ /**
111
+ * Builds a `rect` geometry value — the entity's box itself: a zone's
112
+ * rect, an item's card and marker. Equals leaving the geometry out.
113
+ *
114
+ * @returns A `Schematic.Types.Geometry` value
115
+ */
116
+ readonly rect: () => ExprType<SchematicGeometryType>;
117
+ /**
118
+ * Builds a `circle` geometry value — a circle centred on the entity's
119
+ * anchor (an item's centre, or a zone's box centre): columns, cooling
120
+ * towers and other round equipment.
121
+ *
122
+ * @param radius - Circle radius in world units
123
+ * @returns A `Schematic.Types.Geometry` value
124
+ */
125
+ readonly circle: (radius: SubtypeExprOrValue<FloatType>) => ExprType<SchematicGeometryType>;
126
+ /**
127
+ * Builds a `polyline` geometry value — an open, arc-aware polyline about
128
+ * the entity's anchor, optionally widened into a band (a duct bank, an
129
+ * aisle). Each vertex is an offset from the anchor, and its `bulge` curves
130
+ * the edge to the next vertex (0 = straight).
131
+ *
132
+ * @param vertices - Vertices, offsets from the anchor in world units, in order: `{ x, y, bulge? }`, or the row's own points
133
+ * @param config - Optional `width` band in world units
134
+ * @returns A `Schematic.Types.Geometry` value
135
+ * @throws {Error} For an East array of neither `{ x, y }` nor `{ x, y, bulge }` Floats, naming its type
136
+ */
137
+ readonly polyline: (vertices: SchematicVertices, config?: SchematicPolylineConfig) => ExprType<SchematicGeometryType>;
138
+ /**
139
+ * Builds a `polygon` geometry value — a closed, arc-aware polygon about
140
+ * the entity's anchor (an L-shaped hall, an equipment footprint). Each
141
+ * vertex is an offset from the anchor; the last vertex's `bulge` curves
142
+ * the closing edge.
143
+ *
144
+ * @param vertices - Boundary vertices, offsets from the anchor in world units, in order (auto-closed): `{ x, y, bulge? }`, or the row's own points
145
+ * @returns A `Schematic.Types.Geometry` value
146
+ * @throws {Error} For an East array of neither `{ x, y }` nor `{ x, y, bulge }` Floats, naming its type
147
+ */
148
+ readonly polygon: (vertices: SchematicVertices) => ExprType<SchematicGeometryType>;
149
+ };
150
+ //# sourceMappingURL=shapes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shapes.d.ts","sourceRoot":"","sources":["../../../src/schematic/shapes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACH,SAAS,EAAc,SAAS,EAAE,UAAU,EAAsC,OAAO,EAC1E,KAA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AAqH;IACrH,KAAK,CAAC,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;CACzC;AAgCD;;GAEG;AACH,eAAO,MAAM,eAAe;IACxB;;;;;;OAMG;gCACc,sBAAsB,KAAG,QAAQ,CAAC,wBAAwB,CAAC;IAG5E;;;;;;;OAOG;8BACY,sBAAsB,KAAG,QAAQ,CAAC,wBAAwB,CAAC;IAO1E;;;;;OAKG;8BACY,sBAAsB,KAAG,QAAQ,CAAC,sBAAsB,CAAC;IAMxE;;;;;OAKG;+BACa,sBAAsB,KAAG,QAAQ,CAAC,sBAAsB,CAAC;IAMzE;;;;;OAKG;yBACK,QAAQ,CAAC,qBAAqB,CAAC;IAGvC;;;;;;;OAOG;8BACY,kBAAkB,CAAC,SAAS,CAAC,KAAG,QAAQ,CAAC,qBAAqB,CAAC;IAG9E;;;;;;;;;;OAUG;kCACgB,iBAAiB,WAAW,uBAAuB,KAAG,QAAQ,CAAC,qBAAqB,CAAC;IAMxG;;;;;;;;;OASG;iCACe,iBAAiB,KAAG,QAAQ,CAAC,qBAAqB,CAAC;CAG/D,CAAC"}
@@ -0,0 +1,171 @@
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 Schematic's pattern, style and geometry helpers (`Schematic Builder
7
+ * Spec.md` §4.7, D35): `Schematic.outline()`, `hatch()`, `solid()`,
8
+ * `dashed()`, `rect()`, `circle()`, `polyline()` and `polygon()`. An accessor
9
+ * builds a zone's pattern, a link's style, a footprint or a zone's shape with
10
+ * them from the row's own fields — `(unit) => some(Schematic.circle(unit.radius))`
11
+ * — so the app's record holds only its own types. Each returns an East value
12
+ * of its type, so an accessor's `match` arms may each return one.
13
+ *
14
+ * Geometry is drawn about its entity's anchor (D22): an item's centre, or a
15
+ * zone's box centre. A `circle` centres on it, and a `polyline`'s or a
16
+ * `polygon`'s vertices are offsets from it in world units: the row's own
17
+ * points, `{ x, y }` (a bulge of 0) or `{ x, y, bulge }`.
18
+ *
19
+ * @packageDocumentation
20
+ */
21
+ import { ArrayType, East, Expr, FloatType, StructType, isTypeEqual, none, printType, some, variant, } from "@elaraai/east";
22
+ import { SchematicGeometryType, SchematicLinkStyleType, SchematicVertexType, SchematicZonePatternType } from "./types.js";
23
+ /**
24
+ * A tone's option, from its literal.
25
+ *
26
+ * @param tone - The tone's tag, if any
27
+ * @returns `some` of the tone, or `none`
28
+ * @internal
29
+ */
30
+ export function toneValue(tone) {
31
+ return tone !== undefined ? some(variant(tone, null)) : none;
32
+ }
33
+ /** A point of the row's own: an `{ x, y }` of Floats, a vertex with a bulge of 0. */
34
+ const PointsType = ArrayType(StructType({ x: FloatType, y: FloatType }));
35
+ /** The vertices of a shape, on the wire. */
36
+ const VerticesType = ArrayType(SchematicVertexType);
37
+ /**
38
+ * Normalises {@link SchematicVertices} into an East-coercible array of
39
+ * {@link SchematicVertexType}: plain arrays get `bulge` defaulted to `0`, an
40
+ * East array of `{ x, y }` points each a bulge of 0, and an East array of
41
+ * vertices passes through as it is.
42
+ *
43
+ * @param vertices - The vertices
44
+ * @param where - The helper, as a refusal names it
45
+ * @returns The vertices, as the wire takes them
46
+ * @throws {Error} For an East array of another element type, naming it
47
+ */
48
+ function toVertices(vertices, where) {
49
+ if (Array.isArray(vertices)) {
50
+ return vertices.map(v => ({
51
+ x: v.x,
52
+ y: v.y,
53
+ bulge: v.bulge !== undefined ? v.bulge : 0,
54
+ }));
55
+ }
56
+ if (vertices instanceof Expr) {
57
+ const type = Expr.type(vertices);
58
+ if (isTypeEqual(type, VerticesType))
59
+ return vertices;
60
+ if (isTypeEqual(type, PointsType)) {
61
+ return vertices.map((_$, p) => East.value({ x: p.x, y: p.y, bulge: 0.0 }, SchematicVertexType));
62
+ }
63
+ throw new Error(`${where}: vertices are the row's own points, an Array of { x, y } or { x, y, bulge } Floats — and these are ${printType(type)}`);
64
+ }
65
+ return vertices;
66
+ }
67
+ /**
68
+ * The pattern, style and geometry helpers the `Schematic` namespace carries.
69
+ */
70
+ export const SchematicShapes = {
71
+ /**
72
+ * Builds an `outline` zone pattern value — the dashed boundary with an
73
+ * eyebrow label (halls, cages).
74
+ *
75
+ * @param config - Optional style configuration (`tone`)
76
+ * @returns A `Schematic.Types.ZonePattern` value
77
+ */
78
+ outline(config) {
79
+ return East.value(variant("outline", { tone: toneValue(config?.tone) }), SchematicZonePatternType);
80
+ },
81
+ /**
82
+ * Builds a `hatch` zone pattern value — the hatched band (hot and cold
83
+ * aisles, exclusion zones): an annotation, holding no items and taking no
84
+ * tap.
85
+ *
86
+ * @param config - Optional style configuration (`tone`, `spacing`, `angle`)
87
+ * @returns A `Schematic.Types.ZonePattern` value
88
+ */
89
+ hatch(config) {
90
+ return East.value(variant("hatch", {
91
+ tone: toneValue(config?.tone),
92
+ spacing: config?.spacing !== undefined ? some(config.spacing) : none,
93
+ angle: config?.angle !== undefined ? some(config.angle) : none,
94
+ }), SchematicZonePatternType);
95
+ },
96
+ /**
97
+ * Builds a `solid` link style value — a physical run (fibre, power cable).
98
+ *
99
+ * @param config - Optional stroke configuration (`tone`, `weight`)
100
+ * @returns A `Schematic.Types.LinkStyle` value
101
+ */
102
+ solid(config) {
103
+ return East.value(variant("solid", {
104
+ tone: toneValue(config?.tone),
105
+ weight: config?.weight !== undefined ? some(config.weight) : none,
106
+ }), SchematicLinkStyleType);
107
+ },
108
+ /**
109
+ * Builds a `dashed` link style value — a routing or logical connection.
110
+ *
111
+ * @param config - Optional stroke configuration (`tone`, `weight`)
112
+ * @returns A `Schematic.Types.LinkStyle` value
113
+ */
114
+ dashed(config) {
115
+ return East.value(variant("dashed", {
116
+ tone: toneValue(config?.tone),
117
+ weight: config?.weight !== undefined ? some(config.weight) : none,
118
+ }), SchematicLinkStyleType);
119
+ },
120
+ /**
121
+ * Builds a `rect` geometry value — the entity's box itself: a zone's
122
+ * rect, an item's card and marker. Equals leaving the geometry out.
123
+ *
124
+ * @returns A `Schematic.Types.Geometry` value
125
+ */
126
+ rect() {
127
+ return East.value(variant("rect", null), SchematicGeometryType);
128
+ },
129
+ /**
130
+ * Builds a `circle` geometry value — a circle centred on the entity's
131
+ * anchor (an item's centre, or a zone's box centre): columns, cooling
132
+ * towers and other round equipment.
133
+ *
134
+ * @param radius - Circle radius in world units
135
+ * @returns A `Schematic.Types.Geometry` value
136
+ */
137
+ circle(radius) {
138
+ return East.value(variant("circle", { radius }), SchematicGeometryType);
139
+ },
140
+ /**
141
+ * Builds a `polyline` geometry value — an open, arc-aware polyline about
142
+ * the entity's anchor, optionally widened into a band (a duct bank, an
143
+ * aisle). Each vertex is an offset from the anchor, and its `bulge` curves
144
+ * the edge to the next vertex (0 = straight).
145
+ *
146
+ * @param vertices - Vertices, offsets from the anchor in world units, in order: `{ x, y, bulge? }`, or the row's own points
147
+ * @param config - Optional `width` band in world units
148
+ * @returns A `Schematic.Types.Geometry` value
149
+ * @throws {Error} For an East array of neither `{ x, y }` nor `{ x, y, bulge }` Floats, naming its type
150
+ */
151
+ polyline(vertices, config) {
152
+ return East.value(variant("polyline", {
153
+ vertices: toVertices(vertices, "Schematic.polyline"),
154
+ width: config?.width !== undefined ? some(config.width) : none,
155
+ }), SchematicGeometryType);
156
+ },
157
+ /**
158
+ * Builds a `polygon` geometry value — a closed, arc-aware polygon about
159
+ * the entity's anchor (an L-shaped hall, an equipment footprint). Each
160
+ * vertex is an offset from the anchor; the last vertex's `bulge` curves
161
+ * the closing edge.
162
+ *
163
+ * @param vertices - Boundary vertices, offsets from the anchor in world units, in order (auto-closed): `{ x, y, bulge? }`, or the row's own points
164
+ * @returns A `Schematic.Types.Geometry` value
165
+ * @throws {Error} For an East array of neither `{ x, y }` nor `{ x, y, bulge }` Floats, naming its type
166
+ */
167
+ polygon(vertices) {
168
+ return East.value(variant("polygon", { vertices: toVertices(vertices, "Schematic.polygon") }), SchematicGeometryType);
169
+ },
170
+ };
171
+ //# sourceMappingURL=shapes.js.map
@@ -0,0 +1 @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AAC;YACpD,KAAK,EAAE,MAAM,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI;SACjE,CAAC,EAAE,qBAAqB,CAAC,CAAC;IAC/B,CAAC;IACD;;;;;;;;;OASG;IACH,OAAO,CAAC,QAA2B;QAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAE,mBAAmB,CAAC,EAAE,CAAC,EAAE,qBAAqB,CAAC,CAAC;IAC1H,CAAC;CACK,CAAC"}
@@ -0,0 +1,96 @@
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
+ * `Schematic.templates(rows, config)` (#1386, `Schematic Builder Spec.md`
7
+ * §4.6): the presets a kind's library tab lists. Templates are records
8
+ * (#1340, ruling 9), as Schedule's are: the rows are a record of the app's,
9
+ * usually read whole through `Data.bind(record).read()`, and each card is one
10
+ * of its rows, its key the record's key. A list names its source of the
11
+ * Schematic's `Slice.bindRecords`, whose shown keys filter its cards.
12
+ *
13
+ * - An item kind's template gives every field of the row but `x` and `y`:
14
+ * dropped on the canvas, it adds an item at the drop point, its key minted.
15
+ * - A link kind's gives every field but `from` and `to`: dropped on a link,
16
+ * it retypes it, writing its values and never the link's ends.
17
+ * - A net kind's gives every field but `sources` and `destinations`.
18
+ *
19
+ * Each accessor is reified once and called per row.
20
+ *
21
+ * @packageDocumentation
22
+ */
23
+ import { ArrayType, OptionType, StringType, type DictType, type EastType, type ExprType, type StructType, type SubtypeExprOrValue } from "@elaraai/east";
24
+ import { SchematicTemplateType } from "./types.js";
25
+ /** Identifies a declaration of templates read from a record. */
26
+ export declare const SCHEMATIC_TEMPLATES: unique symbol;
27
+ /**
28
+ * A kind's templates, read from a record (see the module docs).
29
+ *
30
+ * @typeParam V - The values' type: the row's fields less what a drop places
31
+ */
32
+ export interface SchematicTemplates<V extends StructType> {
33
+ /** Identifies the declaration. */
34
+ readonly [SCHEMATIC_TEMPLATES]: true;
35
+ /** The type of each template's values. */
36
+ readonly valuesType: V;
37
+ /** The templates, each its values encoded at their own type. */
38
+ readonly items: ExprType<ArrayType<SchematicTemplateType>>;
39
+ /** The Schematic's `Slice.bindRecords` source over the templates' record, whose shown keys filter the cards. */
40
+ readonly source: string | undefined;
41
+ }
42
+ /**
43
+ * How each row of a templates record shows, and what it creates.
44
+ *
45
+ * @typeParam K - The templates record's key type
46
+ * @typeParam R - Its row type
47
+ * @typeParam V - The values' type
48
+ */
49
+ export interface SchematicTemplatesConfig<K extends EastType, R extends EastType, V extends StructType> {
50
+ /** The card's name. */
51
+ name: (row: ExprType<R>, key: ExprType<K>) => SubtypeExprOrValue<StringType>;
52
+ /** The library's group it sits under. */
53
+ group?: (row: ExprType<R>, key: ExprType<K>) => SubtypeExprOrValue<OptionType<StringType>>;
54
+ /** The card's Font Awesome solid icon; omitted, its kind's. */
55
+ icon?: (row: ExprType<R>, key: ExprType<K>) => SubtypeExprOrValue<OptionType<StringType>>;
56
+ /** Every field of the row the template creates but what a drop places: an item's `x` and `y`, a link's `from` and `to`. */
57
+ values: (row: ExprType<R>, key: ExprType<K>) => ExprType<V>;
58
+ /**
59
+ * The Schematic's `Slice.bindRecords` source over the templates' record
60
+ * (`rackTemplates`): its shown keys filter the cards, each card's key its
61
+ * record key. A list naming no source of the slice is refused, naming the
62
+ * change.
63
+ */
64
+ source: string;
65
+ }
66
+ /**
67
+ * Declares a kind's templates over a record's rows (see the module docs).
68
+ *
69
+ * @typeParam K - The templates record's key type
70
+ * @typeParam R - Its row type
71
+ * @typeParam V - The values' struct type
72
+ * @param rows - The templates, keyed: a record's rows, usually `Data.bind(record).read()`
73
+ * @param config - Each card's name, group and icon, its values, and its source of the slice
74
+ * @returns The templates, which a kind's `templates` takes
75
+ * @throws {Error} When the rows are not a Dict keyed by String, or `values` returns no struct
76
+ */
77
+ export declare function schematicTemplates<K extends EastType, R extends EastType, V extends StructType>(rows: SubtypeExprOrValue<DictType<K, R>>, config: SchematicTemplatesConfig<K, R, V>): SchematicTemplates<V>;
78
+ /**
79
+ * Whether a kind's `templates` is a templates declaration over a record.
80
+ *
81
+ * @param templates - What a kind was given
82
+ * @returns Whether it is `Schematic.templates`'
83
+ */
84
+ export declare function isSchematicTemplates(templates: unknown): templates is SchematicTemplates<StructType>;
85
+ /**
86
+ * Checks a kind's templates against the values its drops take.
87
+ *
88
+ * @param templates - The kind's templates
89
+ * @param expected - The row's fields less what a drop places
90
+ * @param placed - What a drop places, as the refusal names them (`x and y`)
91
+ * @param where - The kind, as a refusal names it
92
+ * @returns The templates on the wire
93
+ * @throws {Error} When the values are of another type, naming both
94
+ */
95
+ export declare function checkedSchematicTemplates(templates: SchematicTemplates<StructType>, expected: StructType, placed: string, where: string): ExprType<ArrayType<SchematicTemplateType>>;
96
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../src/schematic/templates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACH,SAAS,EAAc,UAAU,EAAE,UAAU,EAC7C,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAqB,KAAK,UAAU,EAAE,KAAK,kBAAkB,EAC3G,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,gEAAgE;AAChE,eAAO,MAAM,mBAAmB,EAAE,OAAO,MAAsC,CAAC;AAEhF;;;;GAIG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,UAAU;IACpD,kCAAkC;IAClC,QAAQ,CAAC,CAAC,mBAAmB,CAAC,EAAE,IAAI,CAAC;IACrC,0CAA0C;IAC1C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AAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,wBAAwB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GACpF,kBAAkB,CAAC,CAAC,CAAC,CA0BvB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,IAAI,kBAAkB,CAAC,UAAU,CAAC,CAEpG;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,kBAAkB,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC,CAKpL"}
@@ -0,0 +1,91 @@
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
+ * `Schematic.templates(rows, config)` (#1386, `Schematic Builder Spec.md`
7
+ * §4.6): the presets a kind's library tab lists. Templates are records
8
+ * (#1340, ruling 9), as Schedule's are: the rows are a record of the app's,
9
+ * usually read whole through `Data.bind(record).read()`, and each card is one
10
+ * of its rows, its key the record's key. A list names its source of the
11
+ * Schematic's `Slice.bindRecords`, whose shown keys filter its cards.
12
+ *
13
+ * - An item kind's template gives every field of the row but `x` and `y`:
14
+ * dropped on the canvas, it adds an item at the drop point, its key minted.
15
+ * - A link kind's gives every field but `from` and `to`: dropped on a link,
16
+ * it retypes it, writing its values and never the link's ends.
17
+ * - A net kind's gives every field but `sources` and `destinations`.
18
+ *
19
+ * Each accessor is reified once and called per row.
20
+ *
21
+ * @packageDocumentation
22
+ */
23
+ import { ArrayType, East, Expr, OptionType, StringType, isTypeEqual, none, printType, } from "@elaraai/east";
24
+ import { SchematicTemplateType } from "./types.js";
25
+ /** Identifies a declaration of templates read from a record. */
26
+ export const SCHEMATIC_TEMPLATES = Symbol("Schematic.templates");
27
+ /**
28
+ * Declares a kind's templates over a record's rows (see the module docs).
29
+ *
30
+ * @typeParam K - The templates record's key type
31
+ * @typeParam R - Its row type
32
+ * @typeParam V - The values' struct type
33
+ * @param rows - The templates, keyed: a record's rows, usually `Data.bind(record).read()`
34
+ * @param config - Each card's name, group and icon, its values, and its source of the slice
35
+ * @returns The templates, which a kind's `templates` takes
36
+ * @throws {Error} When the rows are not a Dict keyed by String, or `values` returns no struct
37
+ */
38
+ export function schematicTemplates(rows, config) {
39
+ const source = East.value(rows);
40
+ const type = Expr.type(source);
41
+ if (type.type !== "Dict" || !isTypeEqual(type.key, StringType)) {
42
+ throw new Error(`Schematic.templates: the templates are a record's rows, keyed by String — a Dict, usually Data.bind(record).read() — and these are ${printType(type)}`);
43
+ }
44
+ const keyType = type.key;
45
+ const rowType = type.value;
46
+ const values = East.function([rowType, keyType], undefined, (_$, row, key) => config.values(row, key));
47
+ const valuesType = Expr.type(values).output;
48
+ if (valuesType.type !== "Struct")
49
+ throw new Error("Schematic.templates: `values` returns a struct, every field of the row the template creates but what a drop places");
50
+ const describe = East.function([rowType, keyType], SchematicTemplateType, ($, row, key) => {
51
+ const initial = $.const(values);
52
+ return {
53
+ key: key,
54
+ name: config.name(row, key),
55
+ group: config.group === undefined ? East.value(none, OptionType(StringType)) : config.group(row, key),
56
+ icon: config.icon === undefined ? East.value(none, OptionType(StringType)) : config.icon(row, key),
57
+ values: East.Blob.encodeBeast(initial(row, key), "v2"),
58
+ };
59
+ });
60
+ const items = source.toArray(($, row, key) => {
61
+ const card = $.const(describe);
62
+ return card(row, key);
63
+ });
64
+ return { [SCHEMATIC_TEMPLATES]: true, valuesType, items, source: config.source };
65
+ }
66
+ /**
67
+ * Whether a kind's `templates` is a templates declaration over a record.
68
+ *
69
+ * @param templates - What a kind was given
70
+ * @returns Whether it is `Schematic.templates`'
71
+ */
72
+ export function isSchematicTemplates(templates) {
73
+ return typeof templates === "object" && templates !== null && SCHEMATIC_TEMPLATES in templates;
74
+ }
75
+ /**
76
+ * Checks a kind's templates against the values its drops take.
77
+ *
78
+ * @param templates - The kind's templates
79
+ * @param expected - The row's fields less what a drop places
80
+ * @param placed - What a drop places, as the refusal names them (`x and y`)
81
+ * @param where - The kind, as a refusal names it
82
+ * @returns The templates on the wire
83
+ * @throws {Error} When the values are of another type, naming both
84
+ */
85
+ export function checkedSchematicTemplates(templates, expected, placed, where) {
86
+ if (!isTypeEqual(templates.valuesType, expected)) {
87
+ throw new Error(`${where}: its templates' \`values\` give every field of the row but ${placed} — ${printType(expected)} — and these give ${printType(templates.valuesType)}`);
88
+ }
89
+ return templates.items;
90
+ }
91
+ //# sourceMappingURL=templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/schematic/templates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACH,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,GAE9E,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,gEAAgE;AAChE,MAAM,CAAC,MAAM,mBAAmB,GAAkB,MAAM,CAAC,qBAAqB,CAAC,CAAC;AA2ChF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAC9B,IAAwC,EAAE,MAAyC;IAEnF,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAA6B,CAAC;IAC5D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAyB,CAAa,CAAC;IAC9D,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAe,EAAE,UAAU,CAAC,EAAE,CAAC;QACzE,MAAM,IAAI,KAAK,CAAC,sIAAsI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC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