@snaptrude/plugin-core 0.0.0-dev-20260708130115 → 0.0.0-dev-20260827135706

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 (261) hide show
  1. package/CHANGELOG.md +152 -1
  2. package/api-manifest.json +3620 -276
  3. package/dist/api/analysis/daylight.d.ts +603 -0
  4. package/dist/api/analysis/daylight.d.ts.map +1 -0
  5. package/dist/api/analysis/heatmaps.d.ts +658 -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 +59 -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/solar.d.ts +249 -0
  14. package/dist/api/analysis/solar.d.ts.map +1 -0
  15. package/dist/api/analysis/sunlightHours.d.ts +208 -0
  16. package/dist/api/analysis/sunlightHours.d.ts.map +1 -0
  17. package/dist/api/analysis/sunpath.d.ts +80 -0
  18. package/dist/api/analysis/sunpath.d.ts.map +1 -0
  19. package/dist/api/analysis/weather.d.ts +193 -0
  20. package/dist/api/analysis/weather.d.ts.map +1 -0
  21. package/dist/api/core/camera/index.d.ts +261 -0
  22. package/dist/api/core/camera/index.d.ts.map +1 -0
  23. package/dist/api/core/comment/index.d.ts +105 -2
  24. package/dist/api/core/comment/index.d.ts.map +1 -1
  25. package/dist/api/core/geom/create/index.d.ts +840 -14
  26. package/dist/api/core/geom/create/index.d.ts.map +1 -1
  27. package/dist/api/core/geom/delete/index.d.ts +8 -2
  28. package/dist/api/core/geom/delete/index.d.ts.map +1 -1
  29. package/dist/api/core/geom/query/arc.d.ts +5 -5
  30. package/dist/api/core/geom/query/brep.d.ts +130 -18
  31. package/dist/api/core/geom/query/brep.d.ts.map +1 -1
  32. package/dist/api/core/geom/query/circle.d.ts +18 -18
  33. package/dist/api/core/geom/query/contour.d.ts +20 -20
  34. package/dist/api/core/geom/query/curve.d.ts +49 -49
  35. package/dist/api/core/geom/query/edge.d.ts +5 -5
  36. package/dist/api/core/geom/query/face.d.ts +16 -16
  37. package/dist/api/core/geom/query/halfedge.d.ts +8 -8
  38. package/dist/api/core/geom/query/profile.d.ts +19 -19
  39. package/dist/api/core/geom/query/vertex.d.ts +8 -8
  40. package/dist/api/core/geom/update/contour.d.ts +14 -14
  41. package/dist/api/core/geom/update/curve.d.ts +7 -7
  42. package/dist/api/core/geom/update/profile.d.ts +16 -16
  43. package/dist/api/core/handles/index.d.ts +210 -0
  44. package/dist/api/core/handles/index.d.ts.map +1 -0
  45. package/dist/api/core/index.d.ts +34 -0
  46. package/dist/api/core/index.d.ts.map +1 -1
  47. package/dist/api/core/io/export/index.d.ts +134 -0
  48. package/dist/api/core/io/export/index.d.ts.map +1 -0
  49. package/dist/api/core/io/import/index.d.ts +453 -0
  50. package/dist/api/core/io/import/index.d.ts.map +1 -0
  51. package/dist/api/core/io/index.d.ts +40 -0
  52. package/dist/api/core/io/index.d.ts.map +1 -0
  53. package/dist/api/core/io/job/index.d.ts +139 -0
  54. package/dist/api/core/io/job/index.d.ts.map +1 -0
  55. package/dist/api/core/io/query/index.d.ts +74 -0
  56. package/dist/api/core/io/query/index.d.ts.map +1 -0
  57. package/dist/api/core/io/terrain/index.d.ts +341 -0
  58. package/dist/api/core/io/terrain/index.d.ts.map +1 -0
  59. package/dist/api/core/io/underlay/index.d.ts +805 -0
  60. package/dist/api/core/io/underlay/index.d.ts.map +1 -0
  61. package/dist/api/core/layers.d.ts +7 -7
  62. package/dist/api/core/mode/index.d.ts +99 -0
  63. package/dist/api/core/mode/index.d.ts.map +1 -0
  64. package/dist/api/core/project/index.d.ts +68 -1
  65. package/dist/api/core/project/index.d.ts.map +1 -1
  66. package/dist/api/core/proposals/index.d.ts +531 -0
  67. package/dist/api/core/proposals/index.d.ts.map +1 -0
  68. package/dist/api/core/storeys/index.d.ts +265 -0
  69. package/dist/api/core/storeys/index.d.ts.map +1 -0
  70. package/dist/api/core/tags.d.ts +24 -0
  71. package/dist/api/core/tags.d.ts.map +1 -1
  72. package/dist/api/core/user.d.ts +44 -0
  73. package/dist/api/core/user.d.ts.map +1 -0
  74. package/dist/api/core/zoom/index.d.ts +4 -0
  75. package/dist/api/core/zoom/index.d.ts.map +1 -1
  76. package/dist/api/design/boolean/index.d.ts +4 -4
  77. package/dist/api/design/create/index.d.ts +568 -45
  78. package/dist/api/design/create/index.d.ts.map +1 -1
  79. package/dist/api/design/delete/index.d.ts +3 -0
  80. package/dist/api/design/delete/index.d.ts.map +1 -1
  81. package/dist/api/design/doors/index.d.ts +195 -0
  82. package/dist/api/design/doors/index.d.ts.map +1 -1
  83. package/dist/api/design/edit/index.d.ts +1 -1
  84. package/dist/api/design/erase/index.d.ts +2 -2
  85. package/dist/api/design/family.d.ts +349 -0
  86. package/dist/api/design/family.d.ts.map +1 -0
  87. package/dist/api/design/furniture/index.d.ts +181 -8
  88. package/dist/api/design/furniture/index.d.ts.map +1 -1
  89. package/dist/api/design/index.d.ts +98 -0
  90. package/dist/api/design/index.d.ts.map +1 -1
  91. package/dist/api/design/lock.d.ts +26 -0
  92. package/dist/api/design/lock.d.ts.map +1 -1
  93. package/dist/api/design/materials/index.d.ts +270 -16
  94. package/dist/api/design/materials/index.d.ts.map +1 -1
  95. package/dist/api/design/query/geometry/index.d.ts +112 -0
  96. package/dist/api/design/query/geometry/index.d.ts.map +1 -1
  97. package/dist/api/design/query/index.d.ts +282 -11
  98. package/dist/api/design/query/index.d.ts.map +1 -1
  99. package/dist/api/design/query/referenceLines.d.ts +45 -0
  100. package/dist/api/design/query/referenceLines.d.ts.map +1 -0
  101. package/dist/api/design/query/spaces.d.ts +181 -8
  102. package/dist/api/design/query/spaces.d.ts.map +1 -1
  103. package/dist/api/design/selection/index.d.ts +144 -0
  104. package/dist/api/design/selection/index.d.ts.map +1 -1
  105. package/dist/api/design/transform/index.d.ts +172 -10
  106. package/dist/api/design/transform/index.d.ts.map +1 -1
  107. package/dist/api/design/types/index.d.ts +181 -0
  108. package/dist/api/design/types/index.d.ts.map +1 -0
  109. package/dist/api/design/update/index.d.ts +553 -2
  110. package/dist/api/design/update/index.d.ts.map +1 -1
  111. package/dist/api/design/visibility.d.ts +126 -0
  112. package/dist/api/design/visibility.d.ts.map +1 -0
  113. package/dist/api/design/windows/index.d.ts +113 -2
  114. package/dist/api/design/windows/index.d.ts.map +1 -1
  115. package/dist/api/entity/buildableEnvelope.d.ts +4 -0
  116. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -1
  117. package/dist/api/entity/referenceLine.d.ts +10 -2
  118. package/dist/api/entity/referenceLine.d.ts.map +1 -1
  119. package/dist/api/entity/space.d.ts +21 -21
  120. package/dist/api/entity/story.d.ts +242 -15
  121. package/dist/api/entity/story.d.ts.map +1 -1
  122. package/dist/api/index.d.ts +10 -0
  123. package/dist/api/index.d.ts.map +1 -1
  124. package/dist/api/presentation/aiInspiration.d.ts +25 -25
  125. package/dist/api/presentation/annotate.d.ts +467 -0
  126. package/dist/api/presentation/annotate.d.ts.map +1 -0
  127. package/dist/api/presentation/diagrams.d.ts +111 -8
  128. package/dist/api/presentation/diagrams.d.ts.map +1 -1
  129. package/dist/api/presentation/export.d.ts +108 -0
  130. package/dist/api/presentation/export.d.ts.map +1 -0
  131. package/dist/api/presentation/import.d.ts +55 -4
  132. package/dist/api/presentation/import.d.ts.map +1 -1
  133. package/dist/api/presentation/index.d.ts +58 -1
  134. package/dist/api/presentation/index.d.ts.map +1 -1
  135. package/dist/api/presentation/placedViews.d.ts +1139 -0
  136. package/dist/api/presentation/placedViews.d.ts.map +1 -0
  137. package/dist/api/presentation/shapes.d.ts +481 -0
  138. package/dist/api/presentation/shapes.d.ts.map +1 -0
  139. package/dist/api/presentation/sheets.d.ts +452 -13
  140. package/dist/api/presentation/sheets.d.ts.map +1 -1
  141. package/dist/api/presentation/slideshow.d.ts +125 -0
  142. package/dist/api/presentation/slideshow.d.ts.map +1 -0
  143. package/dist/api/presentation/tables.d.ts +81 -0
  144. package/dist/api/presentation/tables.d.ts.map +1 -0
  145. package/dist/api/presentation/views.d.ts +367 -7
  146. package/dist/api/presentation/views.d.ts.map +1 -1
  147. package/dist/api/program/areas.d.ts +102 -12
  148. package/dist/api/program/areas.d.ts.map +1 -1
  149. package/dist/api/program/cores.d.ts +3 -99
  150. package/dist/api/program/cores.d.ts.map +1 -1
  151. package/dist/api/program/index.d.ts +7 -15
  152. package/dist/api/program/index.d.ts.map +1 -1
  153. package/dist/api/program/layout.d.ts +346 -11
  154. package/dist/api/program/layout.d.ts.map +1 -1
  155. package/dist/api/program/site.d.ts +469 -13
  156. package/dist/api/program/site.d.ts.map +1 -1
  157. package/dist/api/program/spreadsheet.d.ts +365 -41
  158. package/dist/api/program/spreadsheet.d.ts.map +1 -1
  159. package/dist/api/workspace/index.d.ts +505 -0
  160. package/dist/api/workspace/index.d.ts.map +1 -0
  161. package/dist/errors/codes.d.ts +34 -0
  162. package/dist/errors/codes.d.ts.map +1 -0
  163. package/dist/errors/envelope.d.ts +56 -0
  164. package/dist/errors/envelope.d.ts.map +1 -0
  165. package/dist/errors/index.d.ts +6 -0
  166. package/dist/errors/index.d.ts.map +1 -0
  167. package/dist/errors/plugin-error.d.ts +69 -0
  168. package/dist/errors/plugin-error.d.ts.map +1 -0
  169. package/dist/handles.d.ts +97 -25
  170. package/dist/handles.d.ts.map +1 -1
  171. package/dist/host-utils.d.ts +4 -0
  172. package/dist/host-utils.d.ts.map +1 -1
  173. package/dist/index.cjs +4582 -1422
  174. package/dist/index.cjs.map +1 -1
  175. package/dist/index.d.ts +1 -0
  176. package/dist/index.d.ts.map +1 -1
  177. package/dist/index.js +4171 -1411
  178. package/dist/index.js.map +1 -1
  179. package/package.json +4 -2
  180. package/scripts/generate-manifest.mjs +45 -0
  181. package/scripts/generate-manifest.test.mjs +103 -4
  182. package/src/api/analysis/daylight.ts +470 -0
  183. package/src/api/analysis/heatmaps.ts +683 -0
  184. package/src/api/analysis/illuminance.ts +155 -0
  185. package/src/api/analysis/index.ts +61 -0
  186. package/src/api/analysis/shadows.ts +183 -0
  187. package/src/api/analysis/solar.ts +237 -0
  188. package/src/api/analysis/sunlightHours.ts +211 -0
  189. package/src/api/analysis/sunpath.ts +83 -0
  190. package/src/api/analysis/weather.ts +179 -0
  191. package/src/api/core/camera/index.ts +268 -0
  192. package/src/api/core/comment/index.ts +120 -2
  193. package/src/api/core/geom/create/index.ts +912 -1
  194. package/src/api/core/geom/delete/index.ts +6 -0
  195. package/src/api/core/geom/query/brep.ts +119 -0
  196. package/src/api/core/handles/index.ts +233 -0
  197. package/src/api/core/index.ts +34 -0
  198. package/src/api/core/io/export/index.ts +126 -0
  199. package/src/api/core/io/import/index.ts +496 -0
  200. package/src/api/core/io/index.ts +42 -0
  201. package/src/api/core/io/job/index.ts +140 -0
  202. package/src/api/core/io/query/index.ts +71 -0
  203. package/src/api/core/io/terrain/index.ts +360 -0
  204. package/src/api/core/io/underlay/index.ts +705 -0
  205. package/src/api/core/mode/index.ts +96 -0
  206. package/src/api/core/project/index.ts +62 -1
  207. package/src/api/core/proposals/index.ts +569 -0
  208. package/src/api/core/storeys/index.ts +294 -0
  209. package/src/api/core/tags.ts +27 -0
  210. package/src/api/core/user.ts +46 -0
  211. package/src/api/core/zoom/index.ts +4 -0
  212. package/src/api/design/create/index.ts +670 -30
  213. package/src/api/design/delete/index.ts +3 -0
  214. package/src/api/design/doors/index.ts +208 -0
  215. package/src/api/design/erase/index.ts +1 -1
  216. package/src/api/design/family.ts +388 -0
  217. package/src/api/design/furniture/index.ts +197 -8
  218. package/src/api/design/index.ts +102 -0
  219. package/src/api/design/lock.ts +27 -0
  220. package/src/api/design/materials/index.ts +334 -27
  221. package/src/api/design/query/geometry/index.ts +125 -3
  222. package/src/api/design/query/index.ts +217 -7
  223. package/src/api/design/query/referenceLines.ts +52 -0
  224. package/src/api/design/query/spaces.ts +143 -0
  225. package/src/api/design/selection/index.ts +129 -0
  226. package/src/api/design/transform/index.ts +170 -9
  227. package/src/api/design/types/index.ts +156 -0
  228. package/src/api/design/update/index.ts +631 -3
  229. package/src/api/design/visibility.ts +143 -0
  230. package/src/api/design/windows/index.ts +128 -2
  231. package/src/api/entity/buildableEnvelope.ts +4 -0
  232. package/src/api/entity/referenceLine.ts +8 -0
  233. package/src/api/entity/story.ts +259 -15
  234. package/src/api/index.ts +10 -0
  235. package/src/api/presentation/annotate.ts +385 -0
  236. package/src/api/presentation/diagrams.ts +118 -8
  237. package/src/api/presentation/export.ts +108 -0
  238. package/src/api/presentation/import.ts +51 -4
  239. package/src/api/presentation/index.ts +66 -1
  240. package/src/api/presentation/placedViews.ts +1120 -0
  241. package/src/api/presentation/shapes.ts +274 -0
  242. package/src/api/presentation/sheets.ts +400 -13
  243. package/src/api/presentation/slideshow.ts +134 -0
  244. package/src/api/presentation/tables.ts +84 -0
  245. package/src/api/presentation/views.ts +376 -8
  246. package/src/api/program/areas.ts +88 -15
  247. package/src/api/program/cores.ts +3 -91
  248. package/src/api/program/index.ts +7 -15
  249. package/src/api/program/layout.ts +365 -11
  250. package/src/api/program/site.ts +435 -13
  251. package/src/api/program/spreadsheet.ts +376 -35
  252. package/src/api/workspace/index.ts +563 -0
  253. package/src/errors/codes.ts +136 -0
  254. package/src/errors/envelope.ts +75 -0
  255. package/src/errors/index.ts +21 -0
  256. package/src/errors/plugin-error.ts +134 -0
  257. package/src/handles.ts +123 -13
  258. package/src/host-utils.ts +4 -0
  259. package/src/index.ts +1 -0
  260. package/test/errors.test.mjs +184 -0
  261. package/tsconfig.json +7 -2
@@ -1,5 +1,6 @@
1
1
  import * as z from "zod"
2
2
  import { PluginApiReturn } from "../../types"
3
+ import { ComponentHandle } from "../../handles"
3
4
 
4
5
  /**
5
6
  * Story (floor/storey) management.
@@ -40,6 +41,8 @@ export abstract class PluginStoryApi {
40
41
  * const info = await snaptrude.entity.story.get(1, ["height", "name", "spacesCount"])
41
42
  * console.log(info.name, info.height, info.spacesCount)
42
43
  * ```
44
+ *
45
+ * @deprecated Use `core.storeys.get`
43
46
  */
44
47
  public abstract get(
45
48
  storyValue: number,
@@ -67,6 +70,8 @@ export abstract class PluginStoryApi {
67
70
  * console.log(`Story ${s.value}: ${s.name} (id: ${s.id})`)
68
71
  * }
69
72
  * ```
73
+ *
74
+ * @deprecated Use `core.storeys.list`
70
75
  */
71
76
  public abstract getAll(): PluginApiReturn<PluginStoryGetAllResult>
72
77
 
@@ -94,6 +99,8 @@ export abstract class PluginStoryApi {
94
99
  * // Create a new third floor with custom height
95
100
  * const { storyId } = await snaptrude.entity.story.create(3, 4.5)
96
101
  * ```
102
+ *
103
+ * @deprecated Use `core.storeys.create`
97
104
  */
98
105
  public abstract create(
99
106
  storyValue: number,
@@ -101,33 +108,171 @@ export abstract class PluginStoryApi {
101
108
  ): PluginApiReturn<PluginStoryCreateResult>
102
109
 
103
110
  /**
104
- * Update a story's height.
111
+ * Update a story's floor-to-floor `height` and/or `name`.
105
112
  *
106
- * Changes the floor-to-floor height of the specified story. This
107
- * operation is undoable.
113
+ * **Height** is the same operation as editing the height in the Stories panel:
114
+ * the walls, columns, and masses on the story are **stretched** to the new
115
+ * height, every story **above shifts up/down** by the delta so the stack stays
116
+ * contiguous, and coupled elements (staircases, parametric curtain walls,
117
+ * furniture offsets) are re-fitted. The whole height cascade is committed as
118
+ * **one undo step**. Height-locked elements are left untouched.
119
+ *
120
+ * **Name** is the same as renaming the story in the Stories panel: it is
121
+ * persisted immediately (saved to the project) but, mirroring the panel, is
122
+ * **not** part of the height undo step.
123
+ *
124
+ * At least one of `height` or `options.name` must be supplied. Omitting the
125
+ * `height` argument (e.g. for a rename-only update) leaves the height
126
+ * untouched.
108
127
  *
109
128
  * @param storyValue - Integer storey number
110
129
  * identifying the story to update
111
- * @param height - New height value in Babylon
112
- * units
113
- * @returns A {@linkcode PluginStoryUpdateResult} with the updated `storyValue` and `height`
114
- * @throws If the story does not exist or the update fails
130
+ * @param height - New floor-to-floor height in
131
+ * Babylon units. Omit to leave the height unchanged.
132
+ * @param options - `name` (new display name for the story)
133
+ * @returns A {@linkcode PluginStoryUpdateResult} with the story's
134
+ * `storyValue`, `height`, and `name` after the update
135
+ * @throws `PRECONDITION_FAILED` if no story has the given value;
136
+ * `VALIDATION` if neither `height` nor `options.name` is supplied;
137
+ * `STORY_HEIGHT_REJECTED` if the engine rejects the height (e.g. out of
138
+ * range — the change silently reverts host-side and is surfaced as this
139
+ * error); `STORY_UPDATE_FAILED` if the story cannot be re-read after the
140
+ * update
115
141
  *
116
142
  * @examplePrompt Change the ground floor height to 3.5 metres
117
143
  * @examplePrompt Make the second storey taller
144
+ * @examplePrompt Rename the ground floor to "Lobby"
118
145
  * @examplePrompt Set the floor-to-floor height of level 1
119
- * @examplePrompt Increase the height of the third floor
146
+ * @examplePrompt Rename storey 2 and make it taller in one go
120
147
  *
121
148
  * # Example
122
149
  * ```ts
123
- * // Set ground floor height to 5 Babylon units
150
+ * // Set ground floor height to 5 Babylon units — walls stretch and the
151
+ * // floors above move up to match, all in a single undo step.
124
152
  * const result = await snaptrude.entity.story.update(1, 5)
153
+ * // Rename only, leaving the height untouched.
154
+ * await snaptrude.entity.story.update(1, undefined, { name: "Lobby" })
125
155
  * ```
156
+ *
157
+ * @deprecated Use `core.storeys.update`
126
158
  */
127
159
  public abstract update(
128
160
  storyValue: number,
129
- height: number,
161
+ height?: number,
162
+ options?: { name?: string },
130
163
  ): PluginApiReturn<PluginStoryUpdateResult>
164
+
165
+ /**
166
+ * Make a story the active story — the same as clicking it in the storey/layer
167
+ * panel. Subsequent draws and creates target this story, and in 2D the
168
+ * viewport switches to it. This is a view/navigation change: it is **not**
169
+ * undoable and commits nothing to the model.
170
+ *
171
+ * @param storyValue - Integer storey number to activate
172
+ * @returns A {@linkcode PluginStorySetActiveResult} echoing the now-active `storyValue`
173
+ * @throws `PRECONDITION_FAILED` if no story has the given value
174
+ *
175
+ * @examplePrompt Switch to the second floor
176
+ * @examplePrompt Make the ground storey active
177
+ * @examplePrompt Go to the basement level
178
+ * @examplePrompt Set level 3 as the current storey
179
+ *
180
+ * # Example
181
+ * ```ts
182
+ * // Activate story 2, then draw a wall — it lands on story 2.
183
+ * await snaptrude.entity.story.setActive(2)
184
+ * ```
185
+ *
186
+ * @deprecated Use `core.storeys.setActive`
187
+ */
188
+ public abstract setActive(
189
+ storyValue: number,
190
+ ): PluginApiReturn<PluginStorySetActiveResult>
191
+
192
+ /**
193
+ * Delete a story and everything on it — the same as removing it from the
194
+ * storey panel. Every element placed on the story (walls, floors, masses, …)
195
+ * is deleted with it, the remaining stories are re-stacked, and the active
196
+ * story falls back to an adjacent one. Committed as a single undo step.
197
+ *
198
+ * @param storyValue - Integer storey number to delete
199
+ * @returns A {@linkcode PluginStoryDeleteResult} with the deleted `storyValue`
200
+ * and the `newActiveStory` the editor fell back to
201
+ * @throws `PRECONDITION_FAILED` if no story has the given value; or if plugin
202
+ * writes are disabled
203
+ *
204
+ * @examplePrompt Delete the top floor
205
+ * @examplePrompt Remove the basement level
206
+ * @examplePrompt Get rid of storey 3
207
+ * @examplePrompt Delete the second floor and everything on it
208
+ *
209
+ * # Example
210
+ * ```ts
211
+ * const { newActiveStory } = await snaptrude.entity.story.delete(3)
212
+ * console.log(`Deleted story 3; now on story ${newActiveStory}`)
213
+ * ```
214
+ *
215
+ * @deprecated Use `core.storeys.delete`
216
+ */
217
+ public abstract delete(
218
+ storyValue: number,
219
+ ): PluginApiReturn<PluginStoryDeleteResult>
220
+
221
+ /**
222
+ * Duplicate a story into the adjacent level, up or down.
223
+ *
224
+ * By default the **whole story** is duplicated: every eligible element on the
225
+ * active story (walls, floors, roofs, masses, columns, beams, staircases,
226
+ * ceilings, parametric curtain walls, and furniture) is copied into the story
227
+ * one level `"up"` or `"down"`. Pass `options.components` to duplicate only a
228
+ * subset instead. The target story is **created automatically** if it does not
229
+ * yet exist, inheriting the source story's height.
230
+ *
231
+ * Copies are **instanced** by default (`unique: false`) — they share geometry
232
+ * with the source, so later edits propagate. Set `unique: true` for independent
233
+ * geometry. Doors and windows are never duplicated on their own; they ride along
234
+ * with their host wall. Locked, throw-away, and unsupported elements are skipped
235
+ * and counted in `skipped`. The whole operation is a single undo step.
236
+ *
237
+ * @param direction - `"up"` to duplicate into the story above, `"down"` for below
238
+ * @param options - `components` (restrict to a subset of the story's elements;
239
+ * omit for the whole story) and `unique` (default `false` = instanced copies;
240
+ * `true` = independent geometry)
241
+ * @returns A {@linkcode PluginStoryDuplicateResult} with the `sourceStory`, the
242
+ * `targetStories` the copies landed on, the `created` component handles, the
243
+ * `createdStoryValues` for any stories generated to receive them, and the
244
+ * `skipped` count of ineligible elements
245
+ * @throws `NO_ACTIVE_STRUCTURE` if there is no active structure to duplicate
246
+ * into; `NO_ELIGIBLE_ELEMENTS` if nothing on the source story (or in
247
+ * `options.components`) is duplicable; `HANDLE_INVALID` for a stale or
248
+ * foreign supplied handle; or if plugin writes are disabled
249
+ *
250
+ * @examplePrompt Duplicate this floor to the storey above
251
+ * @examplePrompt Copy the ground floor down into a new basement
252
+ * @examplePrompt Repeat this level upwards with its own independent geometry
253
+ * @examplePrompt Duplicate just the selected walls onto the next floor up
254
+ *
255
+ * @performance For storeys that share a layout, duplicate the storey instead of recreating
256
+ * its contents floor by floor — this copies every eligible element in one call, and the
257
+ * default instanced copies keep the floors linked. To stack many identical floors, either
258
+ * call this per level or capture the storey's component ids and
259
+ * `design.create.copy(ids, oneFloorRise, { count })` to lay them all down in a single call.
260
+ *
261
+ * # Example
262
+ * ```ts
263
+ * // Duplicate the whole active story one level up (instanced copies).
264
+ * const { targetStories, created, skipped } =
265
+ * await snaptrude.entity.story.duplicate("up")
266
+ * console.log(`Copied ${created.length} elements onto story ${targetStories}`)
267
+ * if (skipped) console.log(`${skipped} elements were skipped`)
268
+ * ```
269
+ *
270
+ * @deprecated Use `core.storeys.copy`
271
+ */
272
+ public abstract duplicate(
273
+ direction: "up" | "down",
274
+ options?: { components?: ComponentHandle[]; unique?: boolean },
275
+ ): PluginApiReturn<PluginStoryDuplicateResult>
131
276
  }
132
277
 
133
278
  /**
@@ -243,31 +388,130 @@ export const PluginStoryCreateResult = z.object({
243
388
  export type PluginStoryCreateResult = z.infer<typeof PluginStoryCreateResult>
244
389
 
245
390
  /**
246
- * Arguments for {@linkcode PluginStoryApi.update}.
391
+ * Arguments for {@linkcode PluginStoryApi.update}. At least one of `height` or
392
+ * `name` must be supplied.
247
393
  *
248
394
  * | Property | Type | Description |
249
395
  * |---|---|---|
250
396
  * | `storyValue` | `number` (int) | Storey number of the story to update |
251
- * | `height` | `number` | New height in Babylon units |
397
+ * | `height` | `number?` | New height in Babylon units (omit to leave unchanged) |
398
+ * | `name` | `string?` | New display name for the story (omit to leave unchanged) |
252
399
  */
253
400
  export const PluginStoryUpdateArgs = z.object({
254
401
  storyValue: z.number().int(),
255
- height: z.number(),
402
+ height: z.number().optional(),
403
+ name: z.string().optional(),
256
404
  })
257
405
 
258
406
  export type PluginStoryUpdateArgs = z.infer<typeof PluginStoryUpdateArgs>
259
407
 
260
408
  /**
261
- * Result of {@linkcode PluginStoryApi.update}.
409
+ * Result of {@linkcode PluginStoryApi.update} — the story's state after the update.
262
410
  *
263
411
  * | Property | Type | Description |
264
412
  * |---|---|---|
265
413
  * | `storyValue` | `number` | The storey number of the updated story |
266
- * | `height` | `number` | The new height after the update |
414
+ * | `height` | `number` | The height after the update |
415
+ * | `name` | `string` | The name after the update |
267
416
  */
268
417
  export const PluginStoryUpdateResult = z.object({
269
418
  storyValue: z.number(),
270
419
  height: z.number(),
420
+ name: z.string(),
271
421
  })
272
422
 
273
423
  export type PluginStoryUpdateResult = z.infer<typeof PluginStoryUpdateResult>
424
+
425
+ /**
426
+ * Arguments for {@linkcode PluginStoryApi.setActive}.
427
+ *
428
+ * | Property | Type | Description |
429
+ * |---|---|---|
430
+ * | `storyValue` | `number` (int) | Storey number to activate |
431
+ */
432
+ export const PluginStorySetActiveArgs = z.object({
433
+ storyValue: z.number().int(),
434
+ })
435
+
436
+ export type PluginStorySetActiveArgs = z.infer<typeof PluginStorySetActiveArgs>
437
+
438
+ /**
439
+ * Result of {@linkcode PluginStoryApi.setActive}.
440
+ *
441
+ * | Property | Type | Description |
442
+ * |---|---|---|
443
+ * | `storyValue` | `number` | The storey number that is now active |
444
+ */
445
+ export const PluginStorySetActiveResult = z.object({
446
+ storyValue: z.number(),
447
+ })
448
+
449
+ export type PluginStorySetActiveResult = z.infer<typeof PluginStorySetActiveResult>
450
+
451
+ /**
452
+ * Arguments for {@linkcode PluginStoryApi.delete}.
453
+ *
454
+ * | Property | Type | Description |
455
+ * |---|---|---|
456
+ * | `storyValue` | `number` (int) | Storey number to delete |
457
+ */
458
+ export const PluginStoryDeleteArgs = z.object({
459
+ storyValue: z.number().int(),
460
+ })
461
+
462
+ export type PluginStoryDeleteArgs = z.infer<typeof PluginStoryDeleteArgs>
463
+
464
+ /**
465
+ * Result of {@linkcode PluginStoryApi.delete}.
466
+ *
467
+ * | Property | Type | Description |
468
+ * |---|---|---|
469
+ * | `storyValue` | `number` | The storey number that was deleted |
470
+ * | `newActiveStory` | `number` | The storey the editor fell back to as active |
471
+ */
472
+ export const PluginStoryDeleteResult = z.object({
473
+ storyValue: z.number(),
474
+ newActiveStory: z.number(),
475
+ })
476
+
477
+ export type PluginStoryDeleteResult = z.infer<typeof PluginStoryDeleteResult>
478
+
479
+ /**
480
+ * Arguments for {@linkcode PluginStoryApi.duplicate} (options flattened).
481
+ *
482
+ * | Property | Type | Description |
483
+ * |---|---|---|
484
+ * | `direction` | `'up' \| 'down'` | Which adjacent story to duplicate into |
485
+ * | `components` | {@linkcode ComponentHandle}`[]?` | Restrict to a subset; omit for the whole story |
486
+ * | `unique` | `boolean?` | `false` (default) = instanced copies; `true` = independent geometry |
487
+ */
488
+ export const PluginStoryDuplicateArgs = z.object({
489
+ direction: z.enum(["up", "down"]),
490
+ components: z.array(ComponentHandle).optional(),
491
+ unique: z.boolean().optional(),
492
+ })
493
+
494
+ export type PluginStoryDuplicateArgs = z.infer<typeof PluginStoryDuplicateArgs>
495
+
496
+ /**
497
+ * Result of {@linkcode PluginStoryApi.duplicate}.
498
+ *
499
+ * | Property | Type | Description |
500
+ * |---|---|---|
501
+ * | `sourceStory` | `number` | Storey value the copies were duplicated from |
502
+ * | `targetStories` | `number[]` | Storey values the copies landed on |
503
+ * | `created` | {@linkcode ComponentHandle}`[]` | Handles of the newly created components |
504
+ * | `createdStoryValues` | `number[]` | Storey values that were generated to receive the copies |
505
+ * | `skipped` | `number` | Count of ineligible elements that were skipped |
506
+ */
507
+ export const PluginStoryDuplicateResult = z.object({
508
+ sourceStory: z.number(),
509
+ targetStories: z.array(z.number()),
510
+ created: z.array(ComponentHandle),
511
+ createdStoryValues: z.array(z.number()),
512
+ skipped: z.number(),
513
+ })
514
+
515
+ export type PluginStoryDuplicateResult = z.infer<
516
+ typeof PluginStoryDuplicateResult
517
+ >
package/src/api/index.ts CHANGED
@@ -3,6 +3,8 @@ import { PluginDesignApi } from "./design"
3
3
  import { PluginEntityApi } from "./entity"
4
4
  import { PluginProgramApi } from "./program"
5
5
  import { PluginPresentationApi } from "./presentation"
6
+ import { PluginAnalysisApi } from "./analysis"
7
+ import { PluginWorkspaceApi } from "./workspace"
6
8
 
7
9
  /**
8
10
  * Root API surface for Snaptrude plugins.
@@ -14,6 +16,8 @@ import { PluginPresentationApi } from "./presentation"
14
16
  * - {@linkcode PluginApi.entity} — CRUD operations on Snaptrude entities (spaces, stories)
15
17
  * - {@linkcode PluginApi.program} — Program-mode planning reads (departments, metrics)
16
18
  * - {@linkcode PluginApi.presentation} — Presentation preparation (views, AI Inspiration)
19
+ * - {@linkcode PluginApi.analysis} — Sustainability analysis (sunpath, shadows, sunlight/illuminance heatmaps)
20
+ * - {@linkcode PluginApi.workspace} — Dashboard surface: projects and teams
17
21
  */
18
22
  export abstract class PluginApi {
19
23
  /** Core math, geometry, history, and units primitives. See {@linkcode PluginCoreApi}. */
@@ -26,6 +30,10 @@ export abstract class PluginApi {
26
30
  public abstract program: PluginProgramApi
27
31
  /** Presentation preparation reads — saved views. See {@linkcode PluginPresentationApi}. */
28
32
  public abstract presentation: PluginPresentationApi
33
+ /** Sustainability analysis — sun & daylight studies. See {@linkcode PluginAnalysisApi}. */
34
+ public abstract analysis: PluginAnalysisApi
35
+ /** Dashboard surface — projects and teams. See {@linkcode PluginWorkspaceApi}. */
36
+ public abstract workspace: PluginWorkspaceApi
29
37
 
30
38
  constructor() {}
31
39
  }
@@ -35,3 +43,5 @@ export * from "./design"
35
43
  export * from "./entity"
36
44
  export * from "./program"
37
45
  export * from "./presentation"
46
+ export * from "./analysis"
47
+ export * from "./workspace"