@snaptrude/plugin-core 0.3.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/AGENTS.md +130 -48
  2. package/CHANGELOG.md +163 -0
  3. package/api-manifest.full.json +5600 -0
  4. package/api-manifest.json +5502 -0
  5. package/dist/api/analysis/heatmaps.d.ts +234 -0
  6. package/dist/api/analysis/heatmaps.d.ts.map +1 -0
  7. package/dist/api/analysis/illuminance.d.ts +145 -0
  8. package/dist/api/analysis/illuminance.d.ts.map +1 -0
  9. package/dist/api/analysis/index.d.ts +44 -0
  10. package/dist/api/analysis/index.d.ts.map +1 -0
  11. package/dist/api/analysis/shadows.d.ts +165 -0
  12. package/dist/api/analysis/shadows.d.ts.map +1 -0
  13. package/dist/api/analysis/sunlightHours.d.ts +208 -0
  14. package/dist/api/analysis/sunlightHours.d.ts.map +1 -0
  15. package/dist/api/analysis/sunpath.d.ts +80 -0
  16. package/dist/api/analysis/sunpath.d.ts.map +1 -0
  17. package/dist/api/core/buildings.d.ts +427 -0
  18. package/dist/api/core/buildings.d.ts.map +1 -0
  19. package/dist/api/core/comment/index.d.ts +230 -0
  20. package/dist/api/core/comment/index.d.ts.map +1 -0
  21. package/dist/api/core/geom/create/index.d.ts +247 -0
  22. package/dist/api/core/geom/create/index.d.ts.map +1 -0
  23. package/dist/api/core/geom/delete/index.d.ts +72 -0
  24. package/dist/api/core/geom/delete/index.d.ts.map +1 -0
  25. package/dist/api/core/geom/index.d.ts +24 -23
  26. package/dist/api/core/geom/index.d.ts.map +1 -1
  27. package/dist/api/core/geom/query/arc.d.ts +169 -0
  28. package/dist/api/core/geom/query/arc.d.ts.map +1 -0
  29. package/dist/api/core/geom/query/brep.d.ts +402 -0
  30. package/dist/api/core/geom/query/brep.d.ts.map +1 -0
  31. package/dist/api/core/geom/query/circle.d.ts +378 -0
  32. package/dist/api/core/geom/query/circle.d.ts.map +1 -0
  33. package/dist/api/core/geom/query/contour.d.ts +450 -0
  34. package/dist/api/core/geom/query/contour.d.ts.map +1 -0
  35. package/dist/api/core/geom/query/curve.d.ts +918 -0
  36. package/dist/api/core/geom/query/curve.d.ts.map +1 -0
  37. package/dist/api/core/geom/query/edge.d.ts +128 -0
  38. package/dist/api/core/geom/query/edge.d.ts.map +1 -0
  39. package/dist/api/core/geom/query/face.d.ts +363 -0
  40. package/dist/api/core/geom/query/face.d.ts.map +1 -0
  41. package/dist/api/core/geom/query/halfedge.d.ts +206 -0
  42. package/dist/api/core/geom/query/halfedge.d.ts.map +1 -0
  43. package/dist/api/core/geom/query/index.d.ts +61 -0
  44. package/dist/api/core/geom/query/index.d.ts.map +1 -0
  45. package/dist/api/core/geom/query/profile.d.ts +410 -0
  46. package/dist/api/core/geom/query/profile.d.ts.map +1 -0
  47. package/dist/api/core/geom/query/vertex.d.ts +187 -0
  48. package/dist/api/core/geom/query/vertex.d.ts.map +1 -0
  49. package/dist/api/core/geom/update/contour.d.ts +272 -0
  50. package/dist/api/core/geom/update/contour.d.ts.map +1 -0
  51. package/dist/api/core/geom/update/curve.d.ts +180 -0
  52. package/dist/api/core/geom/update/curve.d.ts.map +1 -0
  53. package/dist/api/core/geom/update/index.d.ts +27 -0
  54. package/dist/api/core/geom/update/index.d.ts.map +1 -0
  55. package/dist/api/core/geom/update/profile.d.ts +329 -0
  56. package/dist/api/core/geom/update/profile.d.ts.map +1 -0
  57. package/dist/api/core/groups.d.ts +485 -0
  58. package/dist/api/core/groups.d.ts.map +1 -0
  59. package/dist/api/core/history/index.d.ts +78 -0
  60. package/dist/api/core/history/index.d.ts.map +1 -0
  61. package/dist/api/core/index.d.ts +51 -1
  62. package/dist/api/core/index.d.ts.map +1 -1
  63. package/dist/api/core/io/import/index.d.ts +392 -0
  64. package/dist/api/core/io/import/index.d.ts.map +1 -0
  65. package/dist/api/core/io/index.d.ts +35 -0
  66. package/dist/api/core/io/index.d.ts.map +1 -0
  67. package/dist/api/core/io/job/index.d.ts +139 -0
  68. package/dist/api/core/io/job/index.d.ts.map +1 -0
  69. package/dist/api/core/io/query/index.d.ts +74 -0
  70. package/dist/api/core/io/query/index.d.ts.map +1 -0
  71. package/dist/api/core/io/terrain/index.d.ts +206 -0
  72. package/dist/api/core/io/terrain/index.d.ts.map +1 -0
  73. package/dist/api/core/io/underlay/index.d.ts +286 -0
  74. package/dist/api/core/io/underlay/index.d.ts.map +1 -0
  75. package/dist/api/core/layers.d.ts +402 -0
  76. package/dist/api/core/layers.d.ts.map +1 -0
  77. package/dist/api/core/math/quat.d.ts +111 -128
  78. package/dist/api/core/math/quat.d.ts.map +1 -1
  79. package/dist/api/core/math/vec3.d.ts +120 -102
  80. package/dist/api/core/math/vec3.d.ts.map +1 -1
  81. package/dist/api/core/project/index.d.ts +399 -0
  82. package/dist/api/core/project/index.d.ts.map +1 -0
  83. package/dist/api/core/tags.d.ts +755 -0
  84. package/dist/api/core/tags.d.ts.map +1 -0
  85. package/dist/api/core/units/index.d.ts +175 -0
  86. package/dist/api/core/units/index.d.ts.map +1 -0
  87. package/dist/api/core/zoom/index.d.ts +45 -0
  88. package/dist/api/core/zoom/index.d.ts.map +1 -0
  89. package/dist/api/design/boolean/index.d.ts +168 -0
  90. package/dist/api/design/boolean/index.d.ts.map +1 -0
  91. package/dist/api/design/create/index.d.ts +837 -0
  92. package/dist/api/design/create/index.d.ts.map +1 -0
  93. package/dist/api/design/delete/index.d.ts +63 -0
  94. package/dist/api/design/delete/index.d.ts.map +1 -0
  95. package/dist/api/design/doors/index.d.ts +268 -0
  96. package/dist/api/design/doors/index.d.ts.map +1 -0
  97. package/dist/api/design/edit/index.d.ts +49 -0
  98. package/dist/api/design/edit/index.d.ts.map +1 -0
  99. package/dist/api/design/erase/index.d.ts +160 -0
  100. package/dist/api/design/erase/index.d.ts.map +1 -0
  101. package/dist/api/design/furniture/index.d.ts +123 -0
  102. package/dist/api/design/furniture/index.d.ts.map +1 -0
  103. package/dist/api/design/index.d.ts +153 -0
  104. package/dist/api/design/index.d.ts.map +1 -0
  105. package/dist/api/design/lock.d.ts +41 -0
  106. package/dist/api/design/lock.d.ts.map +1 -0
  107. package/dist/api/design/materials/index.d.ts +297 -0
  108. package/dist/api/design/materials/index.d.ts.map +1 -0
  109. package/dist/api/design/query/geometry/index.d.ts +140 -0
  110. package/dist/api/design/query/geometry/index.d.ts.map +1 -0
  111. package/dist/api/design/query/index.d.ts +1011 -0
  112. package/dist/api/design/query/index.d.ts.map +1 -0
  113. package/dist/api/design/query/spaces.d.ts +221 -0
  114. package/dist/api/design/query/spaces.d.ts.map +1 -0
  115. package/dist/api/design/selection/index.d.ts +282 -0
  116. package/dist/api/design/selection/index.d.ts.map +1 -0
  117. package/dist/api/design/shared.d.ts +38 -0
  118. package/dist/api/design/shared.d.ts.map +1 -0
  119. package/dist/api/design/transform/index.d.ts +87 -0
  120. package/dist/api/design/transform/index.d.ts.map +1 -0
  121. package/dist/api/design/update/index.d.ts +178 -0
  122. package/dist/api/design/update/index.d.ts.map +1 -0
  123. package/dist/api/design/windows/index.d.ts +189 -0
  124. package/dist/api/design/windows/index.d.ts.map +1 -0
  125. package/dist/api/entity/buildableEnvelope.d.ts +261 -0
  126. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -0
  127. package/dist/api/entity/department.d.ts +0 -98
  128. package/dist/api/entity/department.d.ts.map +1 -1
  129. package/dist/api/entity/index.d.ts +9 -9
  130. package/dist/api/entity/index.d.ts.map +1 -1
  131. package/dist/api/entity/referenceLine.d.ts +49 -106
  132. package/dist/api/entity/referenceLine.d.ts.map +1 -1
  133. package/dist/api/entity/space.d.ts +484 -251
  134. package/dist/api/entity/space.d.ts.map +1 -1
  135. package/dist/api/entity/story.d.ts +49 -39
  136. package/dist/api/entity/story.d.ts.map +1 -1
  137. package/dist/api/index.d.ts +22 -12
  138. package/dist/api/index.d.ts.map +1 -1
  139. package/dist/api/presentation/aiInspiration.d.ts +440 -0
  140. package/dist/api/presentation/aiInspiration.d.ts.map +1 -0
  141. package/dist/api/presentation/diagrams.d.ts +81 -0
  142. package/dist/api/presentation/diagrams.d.ts.map +1 -0
  143. package/dist/api/presentation/import.d.ts +113 -0
  144. package/dist/api/presentation/import.d.ts.map +1 -0
  145. package/dist/api/presentation/index.d.ts +46 -0
  146. package/dist/api/presentation/index.d.ts.map +1 -0
  147. package/dist/api/presentation/sheets.d.ts +176 -0
  148. package/dist/api/presentation/sheets.d.ts.map +1 -0
  149. package/dist/api/presentation/views.d.ts +296 -0
  150. package/dist/api/presentation/views.d.ts.map +1 -0
  151. package/dist/api/program/adjacency.d.ts +155 -0
  152. package/dist/api/program/adjacency.d.ts.map +1 -0
  153. package/dist/api/program/areas.d.ts +360 -0
  154. package/dist/api/program/areas.d.ts.map +1 -0
  155. package/dist/api/program/classification.d.ts +135 -0
  156. package/dist/api/program/classification.d.ts.map +1 -0
  157. package/dist/api/program/cores.d.ts +174 -0
  158. package/dist/api/program/cores.d.ts.map +1 -0
  159. package/dist/api/program/departments.d.ts +431 -0
  160. package/dist/api/program/departments.d.ts.map +1 -0
  161. package/dist/api/program/index.d.ts +69 -0
  162. package/dist/api/program/index.d.ts.map +1 -0
  163. package/dist/api/program/layout.d.ts +63 -0
  164. package/dist/api/program/layout.d.ts.map +1 -0
  165. package/dist/api/program/metrics.d.ts +108 -0
  166. package/dist/api/program/metrics.d.ts.map +1 -0
  167. package/dist/api/program/site.d.ts +451 -0
  168. package/dist/api/program/site.d.ts.map +1 -0
  169. package/dist/api/program/spreadsheet.d.ts +2041 -0
  170. package/dist/api/program/spreadsheet.d.ts.map +1 -0
  171. package/dist/handles.d.ts +171 -0
  172. package/dist/handles.d.ts.map +1 -0
  173. package/dist/host-utils.d.ts +7 -5
  174. package/dist/host-utils.d.ts.map +1 -1
  175. package/dist/index.cjs +4344 -899
  176. package/dist/index.cjs.map +1 -1
  177. package/dist/index.d.ts +1 -0
  178. package/dist/index.d.ts.map +1 -1
  179. package/dist/index.js +3682 -865
  180. package/dist/index.js.map +1 -1
  181. package/package.json +6 -2
  182. package/scripts/generate-manifest.mjs +193 -0
  183. package/scripts/generate-manifest.test.mjs +215 -0
  184. package/src/api/analysis/heatmaps.ts +256 -0
  185. package/src/api/analysis/illuminance.ts +155 -0
  186. package/src/api/analysis/index.ts +46 -0
  187. package/src/api/analysis/shadows.ts +183 -0
  188. package/src/api/analysis/sunlightHours.ts +211 -0
  189. package/src/api/analysis/sunpath.ts +83 -0
  190. package/src/api/core/buildings.ts +485 -0
  191. package/src/api/core/comment/index.ts +258 -0
  192. package/src/api/core/geom/create/index.ts +293 -0
  193. package/src/api/core/geom/delete/index.ts +78 -0
  194. package/src/api/core/geom/index.ts +24 -23
  195. package/src/api/core/geom/query/arc.ts +169 -0
  196. package/src/api/core/geom/query/brep.ts +444 -0
  197. package/src/api/core/geom/query/circle.ts +404 -0
  198. package/src/api/core/geom/query/contour.ts +540 -0
  199. package/src/api/core/geom/query/curve.ts +1078 -0
  200. package/src/api/core/geom/query/edge.ts +130 -0
  201. package/src/api/core/geom/query/face.ts +403 -0
  202. package/src/api/core/geom/query/halfedge.ts +210 -0
  203. package/src/api/core/geom/query/index.ts +63 -0
  204. package/src/api/core/geom/query/profile.ts +473 -0
  205. package/src/api/core/geom/query/vertex.ts +205 -0
  206. package/src/api/core/geom/update/contour.ts +315 -0
  207. package/src/api/core/geom/update/curve.ts +209 -0
  208. package/src/api/core/geom/update/index.ts +29 -0
  209. package/src/api/core/geom/update/profile.ts +377 -0
  210. package/src/api/core/groups.ts +521 -0
  211. package/src/api/core/history/index.ts +84 -0
  212. package/src/api/core/index.ts +51 -1
  213. package/src/api/core/io/import/index.ts +432 -0
  214. package/src/api/core/io/index.ts +37 -0
  215. package/src/api/core/io/job/index.ts +140 -0
  216. package/src/api/core/io/query/index.ts +71 -0
  217. package/src/api/core/io/terrain/index.ts +214 -0
  218. package/src/api/core/io/underlay/index.ts +295 -0
  219. package/src/api/core/layers.ts +333 -0
  220. package/src/api/core/math/quat.ts +112 -235
  221. package/src/api/core/math/vec3.ts +124 -159
  222. package/src/api/core/project/index.ts +418 -0
  223. package/src/api/core/tags.ts +808 -0
  224. package/src/api/core/units/index.ts +164 -0
  225. package/src/api/core/zoom/index.ts +47 -0
  226. package/src/api/design/boolean/index.ts +179 -0
  227. package/src/api/design/create/index.ts +895 -0
  228. package/src/api/design/delete/index.ts +67 -0
  229. package/src/api/design/doors/index.ts +285 -0
  230. package/src/api/design/edit/index.ts +54 -0
  231. package/src/api/design/erase/index.ts +151 -0
  232. package/src/api/design/furniture/index.ts +130 -0
  233. package/src/api/design/index.ts +162 -0
  234. package/src/api/design/lock.ts +42 -0
  235. package/src/api/design/materials/index.ts +301 -0
  236. package/src/api/design/query/geometry/index.ts +166 -0
  237. package/src/api/design/query/index.ts +937 -0
  238. package/src/api/design/query/spaces.ts +132 -0
  239. package/src/api/design/selection/index.ts +273 -0
  240. package/src/api/design/shared.ts +40 -0
  241. package/src/api/design/transform/index.ts +93 -0
  242. package/src/api/design/update/index.ts +117 -0
  243. package/src/api/design/windows/index.ts +207 -0
  244. package/src/api/entity/buildableEnvelope.ts +318 -0
  245. package/src/api/entity/department.ts +0 -113
  246. package/src/api/entity/index.ts +9 -9
  247. package/src/api/entity/referenceLine.ts +50 -38
  248. package/src/api/entity/space.ts +285 -226
  249. package/src/api/entity/story.ts +53 -42
  250. package/src/api/index.ts +22 -12
  251. package/src/api/presentation/aiInspiration.ts +362 -0
  252. package/src/api/presentation/diagrams.ts +84 -0
  253. package/src/api/presentation/import.ts +112 -0
  254. package/src/api/presentation/index.ts +48 -0
  255. package/src/api/presentation/sheets.ts +198 -0
  256. package/src/api/presentation/views.ts +303 -0
  257. package/src/api/program/adjacency.ts +164 -0
  258. package/src/api/program/areas.ts +335 -0
  259. package/src/api/program/classification.ts +138 -0
  260. package/src/api/program/cores.ts +171 -0
  261. package/src/api/program/departments.ts +465 -0
  262. package/src/api/program/index.ts +71 -0
  263. package/src/api/program/layout.ts +68 -0
  264. package/src/api/program/metrics.ts +120 -0
  265. package/src/api/program/site.ts +419 -0
  266. package/src/api/program/spreadsheet.ts +2075 -0
  267. package/src/handles.ts +194 -0
  268. package/src/host-utils.ts +10 -6
  269. package/src/index.ts +1 -0
  270. package/dist/api/core/geom/arc.d.ts +0 -81
  271. package/dist/api/core/geom/arc.d.ts.map +0 -1
  272. package/dist/api/core/geom/curve.d.ts +0 -70
  273. package/dist/api/core/geom/curve.d.ts.map +0 -1
  274. package/dist/api/core/geom/line.d.ts +0 -56
  275. package/dist/api/core/geom/line.d.ts.map +0 -1
  276. package/dist/api/core/geom/profile.d.ts +0 -121
  277. package/dist/api/core/geom/profile.d.ts.map +0 -1
  278. package/dist/api/tools/copy.d.ts +0 -59
  279. package/dist/api/tools/copy.d.ts.map +0 -1
  280. package/dist/api/tools/index.d.ts +0 -33
  281. package/dist/api/tools/index.d.ts.map +0 -1
  282. package/dist/api/tools/material.d.ts +0 -51
  283. package/dist/api/tools/material.d.ts.map +0 -1
  284. package/dist/api/tools/offset.d.ts +0 -43
  285. package/dist/api/tools/offset.d.ts.map +0 -1
  286. package/dist/api/tools/selection.d.ts +0 -48
  287. package/dist/api/tools/selection.d.ts.map +0 -1
  288. package/dist/api/tools/transform.d.ts +0 -114
  289. package/dist/api/tools/transform.d.ts.map +0 -1
  290. package/dist/api/units/index.d.ts +0 -163
  291. package/dist/api/units/index.d.ts.map +0 -1
  292. package/src/api/core/geom/arc.ts +0 -70
  293. package/src/api/core/geom/curve.ts +0 -41
  294. package/src/api/core/geom/line.ts +0 -53
  295. package/src/api/core/geom/profile.ts +0 -94
  296. package/src/api/tools/copy.ts +0 -55
  297. package/src/api/tools/index.ts +0 -39
  298. package/src/api/tools/material.ts +0 -49
  299. package/src/api/tools/offset.ts +0 -43
  300. package/src/api/tools/selection.ts +0 -51
  301. package/src/api/tools/transform.ts +0 -117
  302. package/src/api/units/index.ts +0 -163
@@ -0,0 +1,164 @@
1
+ import * as z from "zod"
2
+ import { PluginApiReturn } from "../../types"
3
+
4
+ /**
5
+ * Program adjacency — the proximity relationships between departments or
6
+ * spaces.
7
+ *
8
+ * Adjacency is stage one of the product's space-planning workflow (compute →
9
+ * arrange → pack): the AI service scores which program elements need to be
10
+ * near each other, and the geometry contributes physical contact. Cell values:
11
+ *
12
+ * | Value | Meaning |
13
+ * |---|---|
14
+ * | `2` | Direct — adjacency required |
15
+ * | `1` | Indirect — nearby preferred, or physical contact |
16
+ * | `-1` | Restricted — must NOT be adjacent |
17
+ * | `0` | No relationship — or adjacency was never computed |
18
+ *
19
+ * Zeros are ambiguous **by design** (the engine cannot distinguish "no
20
+ * relationship" from "never computed"): call
21
+ * {@linkcode PluginProgramAdjacencyApi.compute} first when you need fresh
22
+ * data. Persisted matrices auto-hydrate on scene load, so warm reads are the
23
+ * common case. The arrange/pack stages of the workflow live in
24
+ * {@linkcode PluginProgramLayoutApi} (`program.layout`).
25
+ *
26
+ * Accessed via `snaptrude.program.adjacency`.
27
+ */
28
+ export abstract class PluginProgramAdjacencyApi {
29
+ constructor() {}
30
+
31
+ /**
32
+ * Read the adjacency matrix at the department or space level.
33
+ *
34
+ * Returns a square `matrix` whose rows/columns are aligned to `ids`
35
+ * (component ids). Pass `ids` to read a sub-matrix in that order; omit it to
36
+ * get every eligible element at that level. Cell values:
37
+ *
38
+ * | Value | Meaning |
39
+ * |---|---|
40
+ * | `2` | Direct — adjacency required |
41
+ * | `1` | Indirect — nearby preferred, or physical contact |
42
+ * | `-1` | Restricted — must NOT be adjacent |
43
+ * | `0` | No relationship — or adjacency was never computed |
44
+ *
45
+ * Zeros are ambiguous by design — call
46
+ * {@linkcode PluginProgramAdjacencyApi.compute} first for fresh data
47
+ * (persisted matrices auto-hydrate on scene load, so warm reads are the
48
+ * common case). Space-level relationships are computed within a storey:
49
+ * cross-storey pairs always read `0`. At the `department` level the result
50
+ * also carries `departmentIds`, a parallel array joining each row to the
51
+ * department entity ids returned by `program.departments.list` (the row
52
+ * `ids` are department-mass component ids, not department entity ids).
53
+ *
54
+ * @param level - Read the `"department"` or `"space"` matrix.
55
+ * @param ids - Component ids to read a sub-matrix for, in this order
56
+ * (defaults to every eligible element at the level).
57
+ * @returns A {@linkcode PluginProgramAdjacencyGetMatrixResult} with `ids`,
58
+ * the square `matrix`, and (at department level) `departmentIds`.
59
+ * @throws If an id is unknown or does not match the requested level.
60
+ *
61
+ * @examplePrompt Get the space adjacency matrix
62
+ * @examplePrompt Which departments must be adjacent?
63
+ * @examplePrompt Show the adjacency relationships between departments
64
+ * @examplePrompt Read the adjacency matrix for these spaces
65
+ * @examplePrompt Which rooms are restricted from being next to each other?
66
+ *
67
+ * # Example
68
+ * ```ts
69
+ * const { ids, matrix } = await snaptrude.program.adjacency.getMatrix("department")
70
+ * ```
71
+ */
72
+ public abstract getMatrix(
73
+ level: PluginAdjacencyLevel,
74
+ ids?: string[],
75
+ ): PluginApiReturn<PluginProgramAdjacencyGetMatrixResult>
76
+
77
+ /**
78
+ * Compute (or refresh) the adjacency data for the project.
79
+ *
80
+ * Runs the AI adjacency precompute and persists the result; a no-op when
81
+ * the stored data is already fresh. A real run takes **~2s at minimum**
82
+ * (engine pacing) plus the AI service round-trip. This is a write (it
83
+ * mutates and persists project analysis data), so it is blocked when plugin
84
+ * writes are disabled.
85
+ *
86
+ * @returns A {@linkcode PluginProgramAdjacencyComputeResult} —
87
+ * `{ success: true }` when the data is fresh or the run completed;
88
+ * `{ success: false, error }` when the AI service could not be reached.
89
+ *
90
+ * @examplePrompt Refresh adjacency analysis
91
+ * @examplePrompt Compute the adjacency matrix for this project
92
+ * @examplePrompt Recalculate which departments should be adjacent
93
+ *
94
+ * # Example
95
+ * ```ts
96
+ * const { success } = await snaptrude.program.adjacency.compute()
97
+ * if (success) {
98
+ * const data = await snaptrude.program.adjacency.getMatrix("space")
99
+ * }
100
+ * ```
101
+ */
102
+ public abstract compute(): PluginApiReturn<PluginProgramAdjacencyComputeResult>
103
+ }
104
+
105
+ /**
106
+ * The level an adjacency matrix is read at.
107
+ *
108
+ * | Value | Description |
109
+ * |---|---|
110
+ * | `"department"` | One row/column per department mass |
111
+ * | `"space"` | One row/column per space (within a storey) |
112
+ */
113
+ export const PluginAdjacencyLevel = z.enum(["department", "space"])
114
+ export type PluginAdjacencyLevel = z.infer<typeof PluginAdjacencyLevel>
115
+
116
+ /**
117
+ * Arguments for {@linkcode PluginProgramAdjacencyApi.getMatrix}.
118
+ *
119
+ * | Property | Type | Description |
120
+ * |---|---|---|
121
+ * | `level` | {@linkcode PluginAdjacencyLevel} | Read the `"department"` or `"space"` matrix |
122
+ * | `ids` | `string[] \| undefined` | Component ids to read a sub-matrix for, in this order (defaults to every eligible element at the level) |
123
+ */
124
+ export const PluginProgramAdjacencyGetMatrixArgs = z.object({
125
+ level: PluginAdjacencyLevel,
126
+ ids: z.array(z.string()).optional(),
127
+ })
128
+ export type PluginProgramAdjacencyGetMatrixArgs = z.infer<
129
+ typeof PluginProgramAdjacencyGetMatrixArgs
130
+ >
131
+
132
+ /**
133
+ * Result of {@linkcode PluginProgramAdjacencyApi.getMatrix}.
134
+ *
135
+ * | Property | Type | Description |
136
+ * |---|---|---|
137
+ * | `ids` | `string[]` | Component ids, in matrix row/column order |
138
+ * | `departmentIds` | `(string \| null)[] \| undefined` | Department level only: parallel to `ids`, the department entity id each row belongs to (joinable against `program.departments.list`), `null` when unassigned |
139
+ * | `matrix` | `number[][]` | Square matrix aligned to `ids`; values in `{-1, 0, 1, 2}` |
140
+ */
141
+ export const PluginProgramAdjacencyGetMatrixResult = z.object({
142
+ ids: z.array(z.string()),
143
+ departmentIds: z.array(z.string().nullable()).optional(),
144
+ matrix: z.array(z.array(z.number())),
145
+ })
146
+ export type PluginProgramAdjacencyGetMatrixResult = z.infer<
147
+ typeof PluginProgramAdjacencyGetMatrixResult
148
+ >
149
+
150
+ /**
151
+ * Result of {@linkcode PluginProgramAdjacencyApi.compute}.
152
+ *
153
+ * | Property | Type | Description |
154
+ * |---|---|---|
155
+ * | `success` | `boolean` | `true` when the data is fresh or the run completed |
156
+ * | `error` | `string \| undefined` | Failure reason when `success` is `false` |
157
+ */
158
+ export const PluginProgramAdjacencyComputeResult = z.object({
159
+ success: z.boolean(),
160
+ error: z.string().optional(),
161
+ })
162
+ export type PluginProgramAdjacencyComputeResult = z.infer<
163
+ typeof PluginProgramAdjacencyComputeResult
164
+ >
@@ -0,0 +1,335 @@
1
+ import * as z from "zod"
2
+ import { PluginApiReturn } from "../../types"
3
+ import { PluginAreaUnit } from "./metrics"
4
+ import { ComponentHandle } from "../../handles"
5
+
6
+ /**
7
+ * Program areas — the FAR / built-up-area rollup for the active program.
8
+ *
9
+ * This is the zoning-compliance lens on the model: carpet / built-up / excluded
10
+ * area totals, the site area, and the achieved-vs-target **FAR** (Floor Area
11
+ * Ratio). It complements {@linkcode PluginProgramMetricsApi}, which is the
12
+ * department-allocation lens (targets vs allocated area per department); this
13
+ * namespace is the whole-program area/FAR summary and its groupings.
14
+ *
15
+ * `achievedFar` is **derived and read-only** — computed from built-up area and
16
+ * site area. `targetFar` is the goal you set (via {@linkcode
17
+ * PluginProgramAreasApi.update}); the two are the same ratio, one measured and
18
+ * one intended. The surface speaks **FAR only** — there is no FSI alias.
19
+ *
20
+ * Reads return plain records and never throw. The write member typed as optional
21
+ * (`?`) is **authored ahead of the host** — declared so plugins and codegen can
22
+ * see the shape, but kept out of the discovery manifest until the host lands it
23
+ * (at which point it is promoted to a required `abstract` member).
24
+ *
25
+ * Accessed via `snaptrude.program.areas`.
26
+ */
27
+ export abstract class PluginProgramAreasApi {
28
+ constructor() {}
29
+
30
+ /**
31
+ * Get the program area summary.
32
+ *
33
+ * Returns the whole-program totals — carpet / built-up / excluded area, site
34
+ * area, and achieved vs target FAR — with the area unit they are reported in.
35
+ *
36
+ * @returns A {@linkcode PluginProgramAreaSummary}. `achievedFar` is `null` when
37
+ * the site area or target FAR is not set.
38
+ *
39
+ * @examplePrompt What's my FAR right now?
40
+ * @examplePrompt Give me the program area summary
41
+ * @examplePrompt How much built-up area have I used against the site area?
42
+ * @examplePrompt Am I within my FAR target?
43
+ *
44
+ * # Example
45
+ * ```ts
46
+ * const s = await snaptrude.program.areas.get()
47
+ * console.log(s.builtUp, s.siteArea, s.achievedFar, s.targetFar, s.areaUnit)
48
+ * ```
49
+ */
50
+ public abstract get(): PluginApiReturn<PluginProgramAreasGetResult>
51
+
52
+ /**
53
+ * List the program area rollup grouped by a facet.
54
+ *
55
+ * Breaks the program's area totals into buckets — by label, storey, building,
56
+ * department, or tag category.
57
+ *
58
+ * @param groupBy - The facet to group by (a {@linkcode PluginProgramAreaGroupBy}).
59
+ * @param categoryId - The tag category to group by (required when `groupBy` is
60
+ * `"tagCategories"`).
61
+ * @returns A {@linkcode PluginProgramAreasListResult} with a `groups` array
62
+ * (empty when the program has no spaces).
63
+ *
64
+ * @examplePrompt Break down the area by storey
65
+ * @examplePrompt Show the area rollup per department
66
+ * @examplePrompt Group the built-up area by building
67
+ *
68
+ * # Example
69
+ * ```ts
70
+ * const { groups } = await snaptrude.program.areas.list("storeys")
71
+ * for (const g of groups) console.log(g.name, g.builtUp, g.count)
72
+ * ```
73
+ */
74
+ public abstract list(
75
+ groupBy: PluginProgramAreaGroupBy,
76
+ categoryId?: string,
77
+ ): PluginApiReturn<PluginProgramAreasListResult>
78
+
79
+ /**
80
+ * List the spaces that make up one area group.
81
+ *
82
+ * Drills into a single bucket returned by {@linkcode
83
+ * PluginProgramAreasApi.list} and returns its member spaces with their per-space
84
+ * area figures.
85
+ *
86
+ * @param groupBy - The same facet used to produce the group (a {@linkcode
87
+ * PluginProgramAreaGroupBy}).
88
+ * @param groupId - The id of the group to expand.
89
+ * @param categoryId - The tag category context (required when `groupBy` is
90
+ * `"tagCategories"`).
91
+ * @returns A {@linkcode PluginProgramAreasListMembersResult} with a `members`
92
+ * array (empty when the group is missing or empty).
93
+ *
94
+ * @examplePrompt List the spaces on this storey with their areas
95
+ * @examplePrompt What rooms are in the Bedrooms department bucket?
96
+ * @examplePrompt Break the storey area down into individual spaces
97
+ *
98
+ * # Example
99
+ * ```ts
100
+ * const { members } = await snaptrude.program.areas.listMembers("storeys", "st_2")
101
+ * for (const m of members) console.log(m.label, m.carpet)
102
+ * ```
103
+ */
104
+ public abstract listMembers(
105
+ groupBy: PluginProgramAreaGroupBy,
106
+ groupId: string,
107
+ categoryId?: string,
108
+ ): PluginApiReturn<PluginProgramAreasListMembersResult>
109
+
110
+ /**
111
+ * Update the program's FAR settings.
112
+ *
113
+ * A **sparse** update of the program-level FAR inputs — target FAR, the site
114
+ * area, and the allowed deviation. This is a **non-undoable settings write**
115
+ * (persisted with the project). `achievedFar` recomputes from these.
116
+ *
117
+ * @param options - Any of `targetFar`, `siteArea`, `deviation`; omitted fields
118
+ * are left unchanged.
119
+ * @returns The recomputed {@linkcode PluginProgramAreaSummary}.
120
+ * @throws If a value is out of range.
121
+ *
122
+ * @examplePrompt Set the target FAR to 2.5
123
+ * @examplePrompt Override the site area to 5000
124
+ * @examplePrompt Allow a 10 percent FAR deviation
125
+ *
126
+ * # Example
127
+ * ```ts
128
+ * const s = await snaptrude.program.areas.update({ targetFar: 2.5 })
129
+ * console.log(s.achievedFar, s.targetFar)
130
+ * ```
131
+ */
132
+ public abstract update(
133
+ options?: { targetFar?: number; siteArea?: number; deviation?: number },
134
+ ): PluginApiReturn<PluginProgramAreasUpdateResult>
135
+ }
136
+
137
+ /**
138
+ * The whole-program area / FAR summary. All area figures are in `areaUnit`;
139
+ * ratios (`achievedFar`, `targetFar`, `deviation`) are unitless.
140
+ *
141
+ * | Property | Type | Description |
142
+ * |---|---|---|
143
+ * | `count` | `number` | Number of spaces in the program (a count, not an area) |
144
+ * | `hiddenCount` | `number` | Number of those spaces that are currently hidden |
145
+ * | `carpet` | `number` | Total carpet area in `areaUnit` |
146
+ * | `builtUp` | `number` | Total built-up area in `areaUnit` |
147
+ * | `excluded` | `number` | Total excluded area in `areaUnit` |
148
+ * | `farBuiltUp` | `number` | Built-up area that counts toward FAR, in `areaUnit` |
149
+ * | `siteArea` | `number` | Site/plot area in `areaUnit` |
150
+ * | `achievedFar` | `number \| null` | Derived FAR (`farBuiltUp / siteArea`); `null` when site area or target FAR is unset |
151
+ * | `targetFar` | `number` | The target FAR goal (set via `update`) |
152
+ * | `deviation` | `number` | Allowed FAR deviation, as a percentage |
153
+ * | `areaUnit` | `"ft2" \| "m2"` | The unit every area figure above is reported in |
154
+ */
155
+ export const PluginProgramAreaSummary = z.object({
156
+ count: z.number().int(),
157
+ hiddenCount: z.number().int(),
158
+ carpet: z.number(),
159
+ builtUp: z.number(),
160
+ excluded: z.number(),
161
+ farBuiltUp: z.number(),
162
+ siteArea: z.number(),
163
+ achievedFar: z.number().nullable(),
164
+ targetFar: z.number(),
165
+ deviation: z.number(),
166
+ areaUnit: PluginAreaUnit,
167
+ })
168
+ export type PluginProgramAreaSummary = z.infer<typeof PluginProgramAreaSummary>
169
+
170
+ /**
171
+ * One bucket of the area rollup. Carpet / built-up / excluded figures are in the
172
+ * program's area unit (see {@linkcode PluginProgramAreaSummary.areaUnit});
173
+ * `targetArea` is in `targetUnit`.
174
+ *
175
+ * | Property | Type | Description |
176
+ * |---|---|---|
177
+ * | `groupId` | `string` | Stable id of the group (e.g. storey id, department id) |
178
+ * | `name` | `string` | Display name of the group |
179
+ * | `color` | `string` | CSS hex color string for the group |
180
+ * | `carpet` | `number` | Carpet area for this group |
181
+ * | `builtUp` | `number` | Built-up area for this group |
182
+ * | `excluded` | `number` | Excluded area for this group |
183
+ * | `count` | `number` | Number of spaces in this group |
184
+ * | `targetArea` | `number` | Target area for this group, in `targetUnit` |
185
+ * | `targetUnit` | `"ft2" \| "m2"` | The unit `targetArea` is reported in |
186
+ */
187
+ export const PluginProgramAreaGroup = z.object({
188
+ groupId: z.string(),
189
+ name: z.string(),
190
+ color: z.string(),
191
+ carpet: z.number(),
192
+ builtUp: z.number(),
193
+ excluded: z.number(),
194
+ count: z.number().int(),
195
+ targetArea: z.number(),
196
+ targetUnit: PluginAreaUnit,
197
+ })
198
+ export type PluginProgramAreaGroup = z.infer<typeof PluginProgramAreaGroup>
199
+
200
+ /**
201
+ * A single space within an area group. Area figures are in the program's area
202
+ * unit (see {@linkcode PluginProgramAreaSummary.areaUnit}).
203
+ *
204
+ * | Property | Type | Description |
205
+ * |---|---|---|
206
+ * | `id` | `ComponentHandle` | `Component.id` of the space (never a mesh handle) |
207
+ * | `label` | `string` | Display label of the space |
208
+ * | `carpet` | `number` | Carpet area of the space |
209
+ * | `builtUp` | `number` | Built-up area of the space |
210
+ * | `excluded` | `number` | Excluded area of the space |
211
+ * | `isVisible` | `boolean` | Whether the space is currently visible |
212
+ */
213
+ export const PluginProgramAreaMember = z.object({
214
+ id: ComponentHandle,
215
+ label: z.string(),
216
+ carpet: z.number(),
217
+ builtUp: z.number(),
218
+ excluded: z.number(),
219
+ isVisible: z.boolean(),
220
+ })
221
+ export type PluginProgramAreaMember = z.infer<typeof PluginProgramAreaMember>
222
+
223
+ /** The facet to group the area rollup by. */
224
+ export const PluginProgramAreaGroupBy = z.enum([
225
+ "labels",
226
+ "storeys",
227
+ "buildings",
228
+ "departments",
229
+ "tagCategories",
230
+ ])
231
+ export type PluginProgramAreaGroupBy = z.infer<typeof PluginProgramAreaGroupBy>
232
+
233
+ /** Result of {@linkcode PluginProgramAreasApi.get} — the program area summary. */
234
+ export const PluginProgramAreasGetResult = PluginProgramAreaSummary
235
+ export type PluginProgramAreasGetResult = z.infer<
236
+ typeof PluginProgramAreasGetResult
237
+ >
238
+
239
+ /**
240
+ * Arguments for {@linkcode PluginProgramAreasApi.list}.
241
+ *
242
+ * | Property | Type | Description |
243
+ * |---|---|---|
244
+ * | `groupBy` | {@linkcode PluginProgramAreaGroupBy} | The facet to group by |
245
+ * | `categoryId` | `string \| undefined` | Tag category to group by; required when `groupBy` is `"tagCategories"` |
246
+ */
247
+ export const PluginProgramAreasListArgs = z
248
+ .object({
249
+ groupBy: PluginProgramAreaGroupBy,
250
+ categoryId: z.string().optional(),
251
+ })
252
+ .refine((v) => v.groupBy !== "tagCategories" || v.categoryId != null, {
253
+ message: 'categoryId is required when groupBy is "tagCategories"',
254
+ })
255
+ export type PluginProgramAreasListArgs = z.infer<
256
+ typeof PluginProgramAreasListArgs
257
+ >
258
+
259
+ /**
260
+ * Result of {@linkcode PluginProgramAreasApi.list}.
261
+ *
262
+ * | Property | Type | Description |
263
+ * |---|---|---|
264
+ * | `groups` | {@linkcode PluginProgramAreaGroup}`[]` | The area buckets (empty when the program has no spaces) |
265
+ */
266
+ export const PluginProgramAreasListResult = z.object({
267
+ groups: z.array(PluginProgramAreaGroup),
268
+ })
269
+ export type PluginProgramAreasListResult = z.infer<
270
+ typeof PluginProgramAreasListResult
271
+ >
272
+
273
+ /**
274
+ * Arguments for {@linkcode PluginProgramAreasApi.listMembers}.
275
+ *
276
+ * | Property | Type | Description |
277
+ * |---|---|---|
278
+ * | `groupBy` | {@linkcode PluginProgramAreaGroupBy} | The facet the group came from |
279
+ * | `groupId` | `string` | The id of the group to expand |
280
+ * | `categoryId` | `string \| undefined` | Tag category context; required when `groupBy` is `"tagCategories"` |
281
+ */
282
+ export const PluginProgramAreasListMembersArgs = z
283
+ .object({
284
+ groupBy: PluginProgramAreaGroupBy,
285
+ groupId: z.string(),
286
+ categoryId: z.string().optional(),
287
+ })
288
+ .refine((v) => v.groupBy !== "tagCategories" || v.categoryId != null, {
289
+ message: 'categoryId is required when groupBy is "tagCategories"',
290
+ })
291
+ export type PluginProgramAreasListMembersArgs = z.infer<
292
+ typeof PluginProgramAreasListMembersArgs
293
+ >
294
+
295
+ /**
296
+ * Result of {@linkcode PluginProgramAreasApi.listMembers}.
297
+ *
298
+ * | Property | Type | Description |
299
+ * |---|---|---|
300
+ * | `members` | {@linkcode PluginProgramAreaMember}`[]` | The group's member spaces (empty when missing or empty) |
301
+ */
302
+ export const PluginProgramAreasListMembersResult = z.object({
303
+ members: z.array(PluginProgramAreaMember),
304
+ })
305
+ export type PluginProgramAreasListMembersResult = z.infer<
306
+ typeof PluginProgramAreasListMembersResult
307
+ >
308
+
309
+ /**
310
+ * Arguments for {@linkcode PluginProgramAreasApi.update}. Sparse — only the
311
+ * provided fields are changed.
312
+ *
313
+ * | Property | Type | Description |
314
+ * |---|---|---|
315
+ * | `targetFar` | `number \| undefined` | New target FAR (≥ 0) |
316
+ * | `siteArea` | `number \| undefined` | Site-area override (> 0), in the program's area unit |
317
+ * | `deviation` | `number \| undefined` | Allowed FAR deviation percentage (0–100) |
318
+ */
319
+ export const PluginProgramAreasUpdateArgs = z.object({
320
+ targetFar: z.number().min(0).optional(),
321
+ siteArea: z.number().positive().optional(),
322
+ deviation: z.number().min(0).max(100).optional(),
323
+ })
324
+ export type PluginProgramAreasUpdateArgs = z.infer<
325
+ typeof PluginProgramAreasUpdateArgs
326
+ >
327
+
328
+ /**
329
+ * Result of {@linkcode PluginProgramAreasApi.update} — the recomputed program
330
+ * area summary.
331
+ */
332
+ export const PluginProgramAreasUpdateResult = PluginProgramAreaSummary
333
+ export type PluginProgramAreasUpdateResult = z.infer<
334
+ typeof PluginProgramAreasUpdateResult
335
+ >
@@ -0,0 +1,138 @@
1
+ import * as z from "zod"
2
+ import { PluginApiReturn } from "../../types"
3
+
4
+ /**
5
+ * Program classification — the catalog of space-classification options, and a
6
+ * space's display tags.
7
+ *
8
+ * Only the genuinely program-specific reads live here: the selectable
9
+ * space-type / area-class / mass-type options, and a space's tags for display.
10
+ * Reading or changing a *single space's* classification (its type, label, area
11
+ * class, or department) is done through the space reads/writes, not duplicated
12
+ * here. Tag definitions are managed elsewhere — these methods are display-only.
13
+ *
14
+ * Both methods are reads.
15
+ *
16
+ * Accessed via `snaptrude.program.classification`.
17
+ */
18
+ export abstract class PluginProgramClassificationApi {
19
+ constructor() {}
20
+
21
+ /**
22
+ * List the selectable classification options for spaces.
23
+ *
24
+ * The static catalog (project-independent) of space types, area classes, and
25
+ * mass types a space can be classified as.
26
+ *
27
+ * @returns A {@linkcode PluginProgramClassificationTypesResult} with the
28
+ * `spaceTypes`, `areaClasses`, and `massTypes` option lists.
29
+ *
30
+ * @examplePrompt What space types can I assign?
31
+ * @examplePrompt List the available area classifications
32
+ * @examplePrompt What classification options exist?
33
+ * @examplePrompt Show me the valid space-type values
34
+ *
35
+ * # Example
36
+ * ```ts
37
+ * const { spaceTypes, areaClasses } = await snaptrude.program.classification.listTypes()
38
+ * ```
39
+ */
40
+ public abstract listTypes(): PluginApiReturn<PluginProgramClassificationTypesResult>
41
+
42
+ /**
43
+ * List a space's tags for display, grouped by category.
44
+ *
45
+ * @param id - The id of the space whose tags to read.
46
+ * @returns A {@linkcode PluginProgramClassificationTagsResult} with the space's
47
+ * `tagIds` and `tagsByCategory`.
48
+ *
49
+ * @examplePrompt What tags are on this space?
50
+ * @examplePrompt Show the tags grouped by category for sp_4
51
+ * @examplePrompt List this room's display tags
52
+ * @examplePrompt Which tags does this space have?
53
+ *
54
+ * # Example
55
+ * ```ts
56
+ * const { tagsByCategory } = await snaptrude.program.classification.listTags("sp_4")
57
+ * ```
58
+ */
59
+ public abstract listTags(
60
+ id: string,
61
+ ): PluginApiReturn<PluginProgramClassificationTagsResult>
62
+ }
63
+
64
+ /**
65
+ * A selectable classification option.
66
+ *
67
+ * | Property | Type | Description |
68
+ * |---|---|---|
69
+ * | `value` | `string` | Stored value |
70
+ * | `label` | `string` | Display label |
71
+ */
72
+ export const PluginClassificationOption = z.object({
73
+ value: z.string(),
74
+ label: z.string(),
75
+ })
76
+ export type PluginClassificationOption = z.infer<
77
+ typeof PluginClassificationOption
78
+ >
79
+
80
+ /**
81
+ * Result of {@linkcode PluginProgramClassificationApi.listTypes}.
82
+ *
83
+ * | Property | Type | Description |
84
+ * |---|---|---|
85
+ * | `spaceTypes` | {@linkcode PluginClassificationOption}`[]` | Selectable space types |
86
+ * | `areaClasses` | {@linkcode PluginClassificationOption}`[]` | Selectable area classes (NET/GROSS/EXCLUDED) |
87
+ * | `massTypes` | {@linkcode PluginClassificationOption}`[]` | Selectable mass/object types |
88
+ */
89
+ export const PluginProgramClassificationTypesResult = z.object({
90
+ spaceTypes: z.array(PluginClassificationOption),
91
+ areaClasses: z.array(PluginClassificationOption),
92
+ massTypes: z.array(PluginClassificationOption),
93
+ })
94
+ export type PluginProgramClassificationTypesResult = z.infer<
95
+ typeof PluginProgramClassificationTypesResult
96
+ >
97
+
98
+ /** Arguments for {@linkcode PluginProgramClassificationApi.listTags}. */
99
+ export const PluginProgramClassificationListTagsArgs = z.object({
100
+ id: z.string(),
101
+ })
102
+ export type PluginProgramClassificationListTagsArgs = z.infer<
103
+ typeof PluginProgramClassificationListTagsArgs
104
+ >
105
+
106
+ /**
107
+ * A display tag on a space.
108
+ *
109
+ * | Property | Type | Description |
110
+ * |---|---|---|
111
+ * | `tagId` | `string` | Tag id |
112
+ * | `tagName` | `string` | Tag display name |
113
+ * | `color` | `string` | CSS hex color string |
114
+ * | `categoryId` | `string` | Id of the tag's category |
115
+ */
116
+ export const PluginSpaceTag = z.object({
117
+ tagId: z.string(),
118
+ tagName: z.string(),
119
+ color: z.string(),
120
+ categoryId: z.string(),
121
+ })
122
+ export type PluginSpaceTag = z.infer<typeof PluginSpaceTag>
123
+
124
+ /**
125
+ * Result of {@linkcode PluginProgramClassificationApi.listTags}.
126
+ *
127
+ * | Property | Type | Description |
128
+ * |---|---|---|
129
+ * | `tagIds` | `string[]` | All tag ids on the space |
130
+ * | `tagsByCategory` | `Record<string, `{@linkcode PluginSpaceTag}`>` | Tags keyed by category name |
131
+ */
132
+ export const PluginProgramClassificationTagsResult = z.object({
133
+ tagIds: z.array(z.string()),
134
+ tagsByCategory: z.record(z.string(), PluginSpaceTag),
135
+ })
136
+ export type PluginProgramClassificationTagsResult = z.infer<
137
+ typeof PluginProgramClassificationTagsResult
138
+ >