@snaptrude/plugin-core 0.9.17 → 0.9.18-networks-20261016.1

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 (213) hide show
  1. package/AGENTS.md +231 -231
  2. package/CHANGELOG.md +408 -408
  3. package/CLAUDE.md +11 -11
  4. package/dist/api/analysis/daylight.d.ts +5 -5
  5. package/dist/api/analysis/solar.d.ts +2 -2
  6. package/dist/api/core/camera/index.d.ts +29 -0
  7. package/dist/api/core/camera/index.d.ts.map +1 -1
  8. package/dist/api/core/geom/create/index.d.ts +7 -1
  9. package/dist/api/core/geom/create/index.d.ts.map +1 -1
  10. package/dist/api/core/geom/update/contour.d.ts +8 -2
  11. package/dist/api/core/geom/update/contour.d.ts.map +1 -1
  12. package/dist/api/core/zoom/index.d.ts +13 -0
  13. package/dist/api/core/zoom/index.d.ts.map +1 -1
  14. package/dist/api/design/bim.d.ts +209 -0
  15. package/dist/api/design/bim.d.ts.map +1 -0
  16. package/dist/api/design/boolean/index.d.ts +2 -0
  17. package/dist/api/design/boolean/index.d.ts.map +1 -1
  18. package/dist/api/design/catalog.d.ts +320 -0
  19. package/dist/api/design/catalog.d.ts.map +1 -0
  20. package/dist/api/design/create/bulk-items.d.ts +65 -25
  21. package/dist/api/design/create/bulk-items.d.ts.map +1 -1
  22. package/dist/api/design/create/index.d.ts +272 -99
  23. package/dist/api/design/create/index.d.ts.map +1 -1
  24. package/dist/api/design/create/opening-fields.d.ts +13 -12
  25. package/dist/api/design/create/opening-fields.d.ts.map +1 -1
  26. package/dist/api/design/delete/index.d.ts +1 -0
  27. package/dist/api/design/delete/index.d.ts.map +1 -1
  28. package/dist/api/design/doors/index.d.ts +18 -24
  29. package/dist/api/design/doors/index.d.ts.map +1 -1
  30. package/dist/api/design/family.d.ts +797 -27
  31. package/dist/api/design/family.d.ts.map +1 -1
  32. package/dist/api/design/index.d.ts +16 -0
  33. package/dist/api/design/index.d.ts.map +1 -1
  34. package/dist/api/design/networks.d.ts +1763 -0
  35. package/dist/api/design/networks.d.ts.map +1 -0
  36. package/dist/api/design/query/index.d.ts +42 -32
  37. package/dist/api/design/query/index.d.ts.map +1 -1
  38. package/dist/api/design/selection/index.d.ts +10 -10
  39. package/dist/api/design/types/index.d.ts +40 -24
  40. package/dist/api/design/types/index.d.ts.map +1 -1
  41. package/dist/api/design/update/index.d.ts +43 -3
  42. package/dist/api/design/update/index.d.ts.map +1 -1
  43. package/dist/api/design/windows/index.d.ts +8 -8
  44. package/dist/api/design/windows/index.d.ts.map +1 -1
  45. package/dist/api/presentation/aiInspiration.d.ts +10 -10
  46. package/dist/api/presentation/annotate.d.ts +38 -22
  47. package/dist/api/presentation/annotate.d.ts.map +1 -1
  48. package/dist/api/presentation/drawingContract.d.ts +32 -0
  49. package/dist/api/presentation/drawingContract.d.ts.map +1 -0
  50. package/dist/api/presentation/drawings.d.ts +3523 -0
  51. package/dist/api/presentation/drawings.d.ts.map +1 -0
  52. package/dist/api/presentation/export.d.ts +23 -5
  53. package/dist/api/presentation/export.d.ts.map +1 -1
  54. package/dist/api/presentation/index.d.ts +32 -12
  55. package/dist/api/presentation/index.d.ts.map +1 -1
  56. package/dist/api/presentation/placedViews.d.ts +106 -6
  57. package/dist/api/presentation/placedViews.d.ts.map +1 -1
  58. package/dist/api/presentation/shapes.d.ts +2 -2
  59. package/dist/api/presentation/sheets.d.ts +175 -19
  60. package/dist/api/presentation/sheets.d.ts.map +1 -1
  61. package/dist/api/presentation/viewPresets.d.ts +222 -0
  62. package/dist/api/presentation/viewPresets.d.ts.map +1 -0
  63. package/dist/api/presentation/views.d.ts +103 -5
  64. package/dist/api/presentation/views.d.ts.map +1 -1
  65. package/dist/api/presentation/walkthroughs.d.ts +6 -6
  66. package/dist/errors/codes.d.ts +3 -1
  67. package/dist/errors/codes.d.ts.map +1 -1
  68. package/dist/index.cjs +3732 -2383
  69. package/dist/index.cjs.map +1 -1
  70. package/dist/index.js +3607 -2383
  71. package/dist/index.js.map +1 -1
  72. package/package.json +42 -42
  73. package/scripts/check-dist-fresh.mjs +22 -22
  74. package/scripts/generate-manifest.mjs +243 -238
  75. package/scripts/generate-manifest.test.mjs +303 -303
  76. package/src/api/analysis/daylight.ts +470 -470
  77. package/src/api/analysis/heatmaps.ts +683 -683
  78. package/src/api/analysis/illuminance.ts +155 -155
  79. package/src/api/analysis/index.ts +61 -61
  80. package/src/api/analysis/shadows.ts +183 -183
  81. package/src/api/analysis/solar.ts +237 -237
  82. package/src/api/analysis/sunlightHours.ts +211 -211
  83. package/src/api/analysis/sunpath.ts +83 -83
  84. package/src/api/analysis/weather.ts +179 -179
  85. package/src/api/core/buildings.ts +485 -485
  86. package/src/api/core/camera/index.ts +696 -667
  87. package/src/api/core/comment/index.ts +376 -376
  88. package/src/api/core/geom/create/index.ts +2139 -2133
  89. package/src/api/core/geom/delete/index.ts +84 -84
  90. package/src/api/core/geom/index.ts +35 -35
  91. package/src/api/core/geom/query/arc.ts +169 -169
  92. package/src/api/core/geom/query/brep.ts +621 -621
  93. package/src/api/core/geom/query/circle.ts +404 -404
  94. package/src/api/core/geom/query/contour.ts +540 -540
  95. package/src/api/core/geom/query/curve.ts +1102 -1102
  96. package/src/api/core/geom/query/edge.ts +130 -130
  97. package/src/api/core/geom/query/face.ts +508 -508
  98. package/src/api/core/geom/query/halfedge.ts +210 -210
  99. package/src/api/core/geom/query/index.ts +63 -63
  100. package/src/api/core/geom/query/profile.ts +473 -473
  101. package/src/api/core/geom/query/vertex.ts +205 -205
  102. package/src/api/core/geom/update/contour.ts +323 -317
  103. package/src/api/core/geom/update/curve.ts +209 -209
  104. package/src/api/core/geom/update/index.ts +29 -29
  105. package/src/api/core/geom/update/profile.ts +379 -379
  106. package/src/api/core/groups.ts +521 -521
  107. package/src/api/core/handles/index.ts +234 -234
  108. package/src/api/core/history/index.ts +84 -84
  109. package/src/api/core/index.ts +99 -99
  110. package/src/api/core/io/export/index.ts +126 -126
  111. package/src/api/core/io/import/index.ts +504 -504
  112. package/src/api/core/io/index.ts +42 -42
  113. package/src/api/core/io/job/index.ts +140 -140
  114. package/src/api/core/io/query/index.ts +71 -71
  115. package/src/api/core/io/terrain/index.ts +360 -360
  116. package/src/api/core/io/underlay/index.ts +705 -705
  117. package/src/api/core/layers.ts +540 -540
  118. package/src/api/core/math/index.ts +20 -20
  119. package/src/api/core/math/quat.ts +172 -172
  120. package/src/api/core/math/vec3.ts +179 -179
  121. package/src/api/core/mode/index.ts +108 -108
  122. package/src/api/core/project/index.ts +479 -479
  123. package/src/api/core/proposals/index.ts +570 -570
  124. package/src/api/core/storeys/index.ts +308 -308
  125. package/src/api/core/storeys/layers.ts +339 -339
  126. package/src/api/core/tags.ts +911 -911
  127. package/src/api/core/units/index.ts +164 -164
  128. package/src/api/core/user.ts +46 -46
  129. package/src/api/core/zoom/index.ts +64 -51
  130. package/src/api/design/bim.ts +121 -0
  131. package/src/api/design/boolean/index.ts +181 -179
  132. package/src/api/design/catalog.ts +203 -0
  133. package/src/api/design/create/bulk-items.ts +294 -254
  134. package/src/api/design/create/grids.ts +137 -137
  135. package/src/api/design/create/index.ts +2148 -1980
  136. package/src/api/design/create/opening-fields.ts +40 -37
  137. package/src/api/design/delete/index.ts +75 -74
  138. package/src/api/design/dimensions.ts +453 -453
  139. package/src/api/design/doors/index.ts +516 -500
  140. package/src/api/design/edit/index.ts +54 -54
  141. package/src/api/design/erase/index.ts +151 -151
  142. package/src/api/design/family.ts +1334 -704
  143. package/src/api/design/furniture/index.ts +319 -319
  144. package/src/api/design/grids.ts +237 -237
  145. package/src/api/design/index.ts +304 -274
  146. package/src/api/design/lock.ts +69 -69
  147. package/src/api/design/materials/index.ts +608 -608
  148. package/src/api/design/networks.ts +667 -0
  149. package/src/api/design/query/geometry/index.ts +319 -319
  150. package/src/api/design/query/grids.ts +197 -197
  151. package/src/api/design/query/index.ts +1236 -1226
  152. package/src/api/design/query/referenceLines.ts +52 -52
  153. package/src/api/design/query/spaces.ts +275 -275
  154. package/src/api/design/selection/index.ts +273 -273
  155. package/src/api/design/shared.ts +40 -40
  156. package/src/api/design/transform/index.ts +254 -254
  157. package/src/api/design/types/index.ts +163 -156
  158. package/src/api/design/update/index.ts +1024 -983
  159. package/src/api/design/visibility.ts +143 -143
  160. package/src/api/design/windows/index.ts +351 -333
  161. package/src/api/entity/buildableEnvelope.ts +322 -322
  162. package/src/api/entity/index.ts +30 -30
  163. package/src/api/entity/referenceLine.ts +235 -235
  164. package/src/api/entity/space.ts +612 -612
  165. package/src/api/entity/story.ts +517 -517
  166. package/src/api/index.ts +47 -47
  167. package/src/api/presentation/aiInspiration.ts +1116 -1116
  168. package/src/api/presentation/annotate.ts +417 -385
  169. package/src/api/presentation/camera.ts +289 -289
  170. package/src/api/presentation/diagrams.ts +194 -194
  171. package/src/api/presentation/drawingContract.ts +70 -0
  172. package/src/api/presentation/drawings.ts +1179 -0
  173. package/src/api/presentation/export.ts +134 -108
  174. package/src/api/presentation/import.ts +159 -159
  175. package/src/api/presentation/index.ts +160 -135
  176. package/src/api/presentation/placedViews.ts +1211 -1120
  177. package/src/api/presentation/sections.ts +420 -420
  178. package/src/api/presentation/shapes.ts +274 -274
  179. package/src/api/presentation/sheets.ts +746 -585
  180. package/src/api/presentation/slideshow.ts +134 -134
  181. package/src/api/presentation/tables.ts +84 -84
  182. package/src/api/presentation/viewPresets.ts +241 -0
  183. package/src/api/presentation/views.ts +713 -673
  184. package/src/api/presentation/walkthroughs.ts +1201 -1201
  185. package/src/api/program/adjacency.ts +164 -164
  186. package/src/api/program/areas.ts +408 -408
  187. package/src/api/program/classification.ts +138 -138
  188. package/src/api/program/cores.ts +83 -83
  189. package/src/api/program/departments.ts +517 -517
  190. package/src/api/program/index.ts +73 -73
  191. package/src/api/program/labels.ts +332 -332
  192. package/src/api/program/layout.ts +422 -422
  193. package/src/api/program/metadata.ts +364 -364
  194. package/src/api/program/metrics.ts +120 -120
  195. package/src/api/program/site.ts +748 -748
  196. package/src/api/program/spreadsheet.ts +2698 -2698
  197. package/src/api/workspace/index.ts +612 -612
  198. package/src/errors/codes.ts +143 -136
  199. package/src/errors/envelope.ts +75 -75
  200. package/src/errors/index.ts +21 -21
  201. package/src/errors/plugin-error.ts +134 -134
  202. package/src/handles.ts +297 -297
  203. package/src/host-utils.ts +67 -67
  204. package/src/index.ts +7 -7
  205. package/src/massParameters.ops.ts +246 -246
  206. package/src/massParameters.ts +427 -427
  207. package/src/types.ts +16 -16
  208. package/test/drawingContract.test.mjs +288 -0
  209. package/test/errors.test.mjs +185 -184
  210. package/test/massParameters.test.mjs +952 -952
  211. package/tsconfig.json +22 -22
  212. package/tsup.config.ts +12 -12
  213. package/api-manifest.json +0 -9711
@@ -1,254 +1,294 @@
1
- import * as z from "zod"
2
- import { ContourHandle, ProfileHandle, Vec3Handle } from "../../../handles"
3
- import { PluginOpeningBaseOptions } from "./opening-fields"
4
-
5
- /**
6
- * Maximum items per bulk `design.create.*` call. A bounded request keeps
7
- * validation, command capture and rollback work finite; split a larger import
8
- * into separate awaited batches, each with its own undo entry.
9
- */
10
- export const PLUGIN_CREATE_BATCH_LIMIT = 1000
11
-
12
- // ---------------------------------------------------------------------------
13
- // wall top profile (raked / gabled walls)
14
- // ---------------------------------------------------------------------------
15
-
16
- /**
17
- * One break point of a wall's top edge — see {@linkcode PluginWallTopProfile}.
18
- *
19
- * | Property | Type | Description |
20
- * |---|---|---|
21
- * | `along` | `number` | Position along the wall centerline as a fraction: `0` = start of the curve, `1` = end |
22
- * | `height` | `number` | Top height above the wall base at that point (Snaptrude units, > 0) |
23
- */
24
- export const PluginWallTopProfilePoint = z.object({
25
- along: z.number().min(0).max(1),
26
- height: z.number().positive(),
27
- })
28
- export type PluginWallTopProfilePoint = z.infer<
29
- typeof PluginWallTopProfilePoint
30
- >
31
-
32
- /**
33
- * The top edge of ONE wall as a polyline over its centerline: at least two
34
- * points, `along` strictly increasing from `0` (curve start) to `1` (curve end),
35
- * straight segments between them. Two points give a single slope (a raked
36
- * wall), three give a gable, more give any stepped or folded ridge. Heights are
37
- * measured from the wall base, like `height`. Both long faces follow the same
38
- * profile, so the top stays a set of flat faces and the wall keeps its thickness
39
- * end to end.
40
- *
41
- * Only straight centerlines take a top profile (an arc curve with one is
42
- * rejected). A wall built this way is a real Wall — doors and windows host on
43
- * it, corners mitre, quantities and Revit export read its geometry — but it is
44
- * **non-parametric**: the parametric wall graph does not rebuild it, so a later
45
- * move of a neighbour does not re-mitre its corner, exactly like a wall whose
46
- * top edge was dragged by hand. `design.update.wall({ height })` scales it
47
- * proportionally.
48
- */
49
- export const PluginWallTopProfile = z
50
- .array(PluginWallTopProfilePoint)
51
- .min(2)
52
- .superRefine((points, ctx) => {
53
- if (points[0].along !== 0) {
54
- ctx.addIssue({
55
- code: "custom",
56
- message: "topProfile must start at along = 0",
57
- })
58
- }
59
- if (points[points.length - 1].along !== 1) {
60
- ctx.addIssue({
61
- code: "custom",
62
- message: "topProfile must end at along = 1",
63
- })
64
- }
65
- for (let i = 1; i < points.length; i++) {
66
- if (points[i].along <= points[i - 1].along) {
67
- ctx.addIssue({
68
- code: "custom",
69
- message:
70
- "topProfile points must be in strictly increasing `along` order",
71
- })
72
- break
73
- }
74
- }
75
- })
76
- export type PluginWallTopProfile = z.infer<typeof PluginWallTopProfile>
77
-
78
- // ---------------------------------------------------------------------------
79
- // wallRuns
80
- // ---------------------------------------------------------------------------
81
-
82
- /**
83
- * One wall run to create via {@linkcode PluginDesignCreateApi.wallRuns} — the
84
- * same inputs as {@linkcode PluginDesignCreateApi.walls}, one run per item.
85
- *
86
- * | Property | Type | Description |
87
- * |---|---|---|
88
- * | `profile` | {@linkcode ProfileHandle} | Ordered curve chain (wall centerlines) |
89
- * | `height` | `number`? | Wall height (Snaptrude units, > 0; default engine default) |
90
- * | `thickness` | `number`? | Wall thickness (Snaptrude units, > 0; default: `wallType`'s total layer thickness when given, else engine default) |
91
- * | `wallType` | `string`? | Wall type name from `design.types.list("wall")` — layers/material/thickness defaults (default generic) |
92
- * | `storey` | `number`? (int) | Target storey (must exist) — the run's walls are assigned + lifted to its base in the same undo entry (default: geometry-derived) |
93
- * | `topProfiles` | ({@linkcode PluginWallTopProfile} \| `null`)[]? | Top edge per curve of `profile`, same order; a `null` or missing entry keeps that wall flat at `height`. Raked / gabled walls (straight curves only) |
94
- */
95
- export const PluginCreateWallRunItem = z.object({
96
- profile: ProfileHandle,
97
- height: z.number().optional(),
98
- thickness: z.number().optional(),
99
- wallType: z.string().min(1).optional(),
100
- storey: z.number().int().optional(),
101
- topProfiles: z.array(PluginWallTopProfile.nullable()).optional(),
102
- })
103
- export type PluginCreateWallRunItem = z.infer<typeof PluginCreateWallRunItem>
104
-
105
- /** The `items` array of {@linkcode PluginDesignCreateApi.wallRuns} (1…1000). */
106
- export const PluginCreateWallRunItems = z
107
- .array(PluginCreateWallRunItem)
108
- .min(1)
109
- .max(PLUGIN_CREATE_BATCH_LIMIT)
110
- export type PluginCreateWallRunItems = z.infer<typeof PluginCreateWallRunItems>
111
-
112
- // ---------------------------------------------------------------------------
113
- // floors
114
- // ---------------------------------------------------------------------------
115
-
116
- /**
117
- * One floor to create via {@linkcode PluginDesignCreateApi.floors} — the same
118
- * footprint-extrude inputs as {@linkcode PluginDesignCreateApi.floor}.
119
- *
120
- * | Property | Type | Description |
121
- * |---|---|---|
122
- * | `contour` | {@linkcode ContourHandle} | Footprint (outer profile + holes) |
123
- * | `thickness` | `number` | Floor thickness (Snaptrude units, > 0) |
124
- * | `position` | {@linkcode Vec3Handle}? | Offset from origin (default origin) |
125
- */
126
- export const PluginCreateFloorItem = z.object({
127
- contour: ContourHandle,
128
- thickness: z.number(),
129
- position: Vec3Handle.optional(),
130
- })
131
- export type PluginCreateFloorItem = z.infer<typeof PluginCreateFloorItem>
132
-
133
- /** The `items` array of {@linkcode PluginDesignCreateApi.floors} (1…1000). */
134
- export const PluginCreateFloorItems = z
135
- .array(PluginCreateFloorItem)
136
- .min(1)
137
- .max(PLUGIN_CREATE_BATCH_LIMIT)
138
- export type PluginCreateFloorItems = z.infer<typeof PluginCreateFloorItems>
139
-
140
- // ---------------------------------------------------------------------------
141
- // doors / windows
142
- // ---------------------------------------------------------------------------
143
-
144
- /**
145
- * One door to place via {@linkcode PluginDesignCreateApi.doors} — the same
146
- * fields as a `"door"` {@linkcode PluginDesignCreateOpeningOptions}, so the
147
- * size overrides singular {@linkcode PluginDesignCreateApi.door} lacks are
148
- * available per item. `facing` and `hinge` are WORLD POINTS, not directions:
149
- * `facing` on the side of the wall the door swings open to, `hinge` near the
150
- * jamb it is hinged on. Rejects unknown fields.
151
- *
152
- * | Property | Type | Description |
153
- * |---|---|---|
154
- * | `catalogId` | `string` | Library id: team `_id` or general `fullName` |
155
- * | `hostWall` | {@linkcode ComponentHandle} | The wall to host the door |
156
- * | `position` | {@linkcode Vec3Handle} | World point projected onto the wall |
157
- * | `facing` | {@linkcode Vec3Handle}? | World point on the side the door swings open to (default engine-chosen) |
158
- * | `hinge` | {@linkcode Vec3Handle}? | World point near the jamb the door is hinged on (default the catalog item's authored side) |
159
- * | `label` | `string`? | Instance name (optional) |
160
- * | `width` | `number`? | Width override (Snaptrude units, > 0; default the catalog item's) |
161
- * | `height` | `number`? | Height override (Snaptrude units, > 0; default the catalog item's) |
162
- */
163
- export const PluginCreateDoorItem = z
164
- .object({ ...PluginOpeningBaseOptions })
165
- .strict()
166
- export type PluginCreateDoorItem = z.infer<typeof PluginCreateDoorItem>
167
-
168
- /** The `items` array of {@linkcode PluginDesignCreateApi.doors} (1…1000). */
169
- export const PluginCreateDoorItems = z
170
- .array(PluginCreateDoorItem)
171
- .min(1)
172
- .max(PLUGIN_CREATE_BATCH_LIMIT)
173
- export type PluginCreateDoorItems = z.infer<typeof PluginCreateDoorItems>
174
-
175
- /**
176
- * One window to place via {@linkcode PluginDesignCreateApi.windows} — the same
177
- * fields as a `"window"` {@linkcode PluginDesignCreateOpeningOptions}.
178
- * `sillHeight` is a nonnegative Snaptrude-unit distance from the host wall's
179
- * base to the BOTTOM of the window, not to its center. `facing` and `hinge`
180
- * are WORLD POINTS, not directions: `facing` on the side of the wall the
181
- * window opens to, `hinge` near the jamb it is hinged on. Rejects unknown
182
- * fields.
183
- *
184
- * | Property | Type | Description |
185
- * |---|---|---|
186
- * | `catalogId` | `string` | Library id: team `_id` or general `fullName` |
187
- * | `hostWall` | {@linkcode ComponentHandle} | The wall to host the window |
188
- * | `position` | {@linkcode Vec3Handle} | World point projected onto the wall |
189
- * | `facing` | {@linkcode Vec3Handle}? | World point on the side the window opens to (default engine-chosen) |
190
- * | `hinge` | {@linkcode Vec3Handle}? | World point near the jamb the window is hinged on (default the catalog item's authored side) |
191
- * | `label` | `string`? | Instance name (optional) |
192
- * | `width` | `number`? | Width override (Snaptrude units, > 0; default the catalog item's) |
193
- * | `height` | `number`? | Height override (Snaptrude units, > 0; default the catalog item's) |
194
- * | `sillHeight` | `number`? | Wall base to window bottom (Snaptrude units, ≥ 0; default the catalog item's) |
195
- */
196
- export const PluginCreateWindowItem = z
197
- .object({
198
- ...PluginOpeningBaseOptions,
199
- sillHeight: z.number().finite().nonnegative().optional(),
200
- })
201
- .strict()
202
- export type PluginCreateWindowItem = z.infer<typeof PluginCreateWindowItem>
203
-
204
- /** The `items` array of {@linkcode PluginDesignCreateApi.windows} (1…1000). */
205
- export const PluginCreateWindowItems = z
206
- .array(PluginCreateWindowItem)
207
- .min(1)
208
- .max(PLUGIN_CREATE_BATCH_LIMIT)
209
- export type PluginCreateWindowItems = z.infer<typeof PluginCreateWindowItems>
210
-
211
- // ---------------------------------------------------------------------------
212
- // furnitureItems
213
- // ---------------------------------------------------------------------------
214
-
215
- /**
216
- * One furniture instance to place via
217
- * {@linkcode PluginDesignCreateApi.furnitureItems} — the same inputs as
218
- * {@linkcode PluginDesignCreateApi.furniture} minus `createNewSourceMesh`: in a
219
- * batch the host owns source-mesh persistence (a source is recorded once per
220
- * call, however many items reuse it).
221
- *
222
- * `position.y` is the REST elevation: the item is grounded so its bounding-box
223
- * base sits exactly at `position.y` (the same surface-flush contract as
224
- * interactive drag-drop) — pass the floor/storey elevation to stand furniture
225
- * on it; never add half the item's height yourself.
226
- *
227
- * | Property | Type | Description |
228
- * |---|---|---|
229
- * | `catalogId` | `string` | Library id: team `_id` or general `fullName` |
230
- * | `position` | {@linkcode Vec3Handle} | Absolute world placement point (`y` = rest elevation) |
231
- * | `label` | `string`? | Instance name and readable label (default auto `${name}Ins${n}`) |
232
- * | `angleInDegrees` | `number`? | Rotation about the vertical axis, in degrees (default unrotated) |
233
- */
234
- export const PluginCreateFurnitureItem = z.object({
235
- catalogId: z.string().min(1),
236
- position: Vec3Handle,
237
- label: z.string().optional(),
238
- angleInDegrees: z.number().optional(),
239
- })
240
- export type PluginCreateFurnitureItem = z.infer<
241
- typeof PluginCreateFurnitureItem
242
- >
243
-
244
- /**
245
- * The `items` array of {@linkcode PluginDesignCreateApi.furnitureItems}
246
- * (1…1000).
247
- */
248
- export const PluginCreateFurnitureItems = z
249
- .array(PluginCreateFurnitureItem)
250
- .min(1)
251
- .max(PLUGIN_CREATE_BATCH_LIMIT)
252
- export type PluginCreateFurnitureItems = z.infer<
253
- typeof PluginCreateFurnitureItems
254
- >
1
+ import * as z from "zod"
2
+ import {
3
+ ComponentHandle,
4
+ ContourHandle,
5
+ ProfileHandle,
6
+ Vec3Handle,
7
+ } from "../../../handles"
8
+ import { PluginOpeningBaseOptions } from "./opening-fields"
9
+ import { PluginWallType } from "../types"
10
+ import { PluginFamilyValues } from "../catalog"
11
+
12
+ /**
13
+ * Maximum items per bulk `design.create.*` call. A bounded request keeps
14
+ * validation, command capture and rollback work finite; split a larger import
15
+ * into separate awaited batches, each with its own undo entry.
16
+ */
17
+ export const PLUGIN_CREATE_BATCH_LIMIT = 1000
18
+
19
+ // ---------------------------------------------------------------------------
20
+ // wall top profile (raked / gabled walls)
21
+ // ---------------------------------------------------------------------------
22
+
23
+ /**
24
+ * One break point of a wall's top edge — see {@linkcode PluginWallTopProfile}.
25
+ *
26
+ * | Property | Type | Description |
27
+ * |---|---|---|
28
+ * | `along` | `number` | Position along the wall centerline as a fraction: `0` = start of the curve, `1` = end |
29
+ * | `height` | `number` | Top height above the wall base at that point (Snaptrude units, > 0) |
30
+ */
31
+ export const PluginWallTopProfilePoint = z.object({
32
+ along: z.number().min(0).max(1),
33
+ height: z.number().positive(),
34
+ })
35
+ export type PluginWallTopProfilePoint = z.infer<
36
+ typeof PluginWallTopProfilePoint
37
+ >
38
+
39
+ /**
40
+ * The top edge of ONE wall as a polyline over its centerline: at least two
41
+ * points, `along` strictly increasing from `0` (curve start) to `1` (curve end),
42
+ * straight segments between them. Two points give a single slope (a raked
43
+ * wall), three give a gable, more give any stepped or folded ridge. Heights are
44
+ * measured from the wall base, like `height`. Both long faces follow the same
45
+ * profile, so the top stays a set of flat faces and the wall keeps its thickness
46
+ * end to end.
47
+ *
48
+ * Only straight centerlines take a top profile (an arc curve with one is
49
+ * rejected). A wall built this way is a real Wall — doors and windows host on
50
+ * it, corners mitre, quantities and Revit export read its geometry — but it is
51
+ * **non-parametric**: the parametric wall graph does not rebuild it, so a later
52
+ * move of a neighbour does not re-mitre its corner, exactly like a wall whose
53
+ * top edge was dragged by hand. `design.update.wall({ height })` scales it
54
+ * proportionally.
55
+ */
56
+ export const PluginWallTopProfile = z
57
+ .array(PluginWallTopProfilePoint)
58
+ .min(2)
59
+ .superRefine((points, ctx) => {
60
+ if (points[0].along !== 0) {
61
+ ctx.addIssue({
62
+ code: "custom",
63
+ message: "topProfile must start at along = 0",
64
+ })
65
+ }
66
+ if (points[points.length - 1].along !== 1) {
67
+ ctx.addIssue({
68
+ code: "custom",
69
+ message: "topProfile must end at along = 1",
70
+ })
71
+ }
72
+ for (let i = 1; i < points.length; i++) {
73
+ if (points[i].along <= points[i - 1].along) {
74
+ ctx.addIssue({
75
+ code: "custom",
76
+ message:
77
+ "topProfile points must be in strictly increasing `along` order",
78
+ })
79
+ break
80
+ }
81
+ }
82
+ })
83
+ export type PluginWallTopProfile = z.infer<typeof PluginWallTopProfile>
84
+
85
+ // ---------------------------------------------------------------------------
86
+ // wallRuns
87
+ // ---------------------------------------------------------------------------
88
+
89
+ /**
90
+ * One wall run to create via {@linkcode PluginDesignCreateApi.wallRuns} — the
91
+ * same inputs as {@linkcode PluginDesignCreateApi.walls}, one run per item.
92
+ *
93
+ * | Property | Type | Description |
94
+ * |---|---|---|
95
+ * | `profile` | {@linkcode ProfileHandle} | Ordered curve chain (wall centerlines) |
96
+ * | `height` | `number`? | Wall height (Snaptrude units, > 0; default engine default) |
97
+ * | `thickness` | `number`? | Wall thickness (Snaptrude units, > 0; default: `wallType`'s total layer thickness when given, else engine default) |
98
+ * | `wallType` | {@linkcode PluginWallType}? | Legacy name/id or exact native `{ id, version }` pin from `design.types.list("wall")` (default generic) |
99
+ * | `storey` | `number`? (int) | Target storey (must exist) — the run's walls are assigned + lifted to its base in the same undo entry (default: geometry-derived) |
100
+ * | `topProfiles` | ({@linkcode PluginWallTopProfile} \| `null`)[]? | Top edge per curve of `profile`, same order; a `null` or missing entry keeps that wall flat at `height`. Raked / gabled walls (straight curves only) |
101
+ */
102
+ export const PluginCreateWallRunItem = z.object({
103
+ profile: ProfileHandle,
104
+ height: z.number().optional(),
105
+ thickness: z.number().optional(),
106
+ wallType: PluginWallType.optional(),
107
+ storey: z.number().int().optional(),
108
+ topProfiles: z.array(PluginWallTopProfile.nullable()).optional(),
109
+ /** Optional family overrides in mm/degrees. Host length/height stay geometry inputs. */
110
+ values: PluginFamilyValues.optional(),
111
+ })
112
+ export type PluginCreateWallRunItem = z.infer<typeof PluginCreateWallRunItem>
113
+
114
+ /** The `items` array of {@linkcode PluginDesignCreateApi.wallRuns} (1…1000). */
115
+ export const PluginCreateWallRunItems = z
116
+ .array(PluginCreateWallRunItem)
117
+ .min(1)
118
+ .max(PLUGIN_CREATE_BATCH_LIMIT)
119
+ export type PluginCreateWallRunItems = z.infer<typeof PluginCreateWallRunItems>
120
+
121
+ // ---------------------------------------------------------------------------
122
+ // floors
123
+ // ---------------------------------------------------------------------------
124
+
125
+ /**
126
+ * One floor to create via {@linkcode PluginDesignCreateApi.floors} — the same
127
+ * footprint-extrude inputs as {@linkcode PluginDesignCreateApi.floor}.
128
+ *
129
+ * | Property | Type | Description |
130
+ * |---|---|---|
131
+ * | `contour` | {@linkcode ContourHandle} | Footprint (outer profile + holes) |
132
+ * | `thickness` | `number` | Floor thickness (Snaptrude units, > 0) |
133
+ * | `position` | {@linkcode Vec3Handle}? | Offset from origin (default origin) |
134
+ */
135
+ export const PluginCreateFloorItem = z.object({
136
+ contour: ContourHandle,
137
+ thickness: z.number(),
138
+ position: Vec3Handle.optional(),
139
+ })
140
+ export type PluginCreateFloorItem = z.infer<typeof PluginCreateFloorItem>
141
+
142
+ /** The `items` array of {@linkcode PluginDesignCreateApi.floors} (1…1000). */
143
+ export const PluginCreateFloorItems = z
144
+ .array(PluginCreateFloorItem)
145
+ .min(1)
146
+ .max(PLUGIN_CREATE_BATCH_LIMIT)
147
+ export type PluginCreateFloorItems = z.infer<typeof PluginCreateFloorItems>
148
+
149
+ // ---------------------------------------------------------------------------
150
+ // doors / windows
151
+ // ---------------------------------------------------------------------------
152
+
153
+ /**
154
+ * One door to place via {@linkcode PluginDesignCreateApi.doors} — the same
155
+ * fields as a `"door"` {@linkcode PluginDesignCreateOpeningOptions}.
156
+ * Values are evaluated before cutting. Numeric lengths use SU; unit strings
157
+ * are accepted in values. `facing` selects local +Z; `hinge` sets the declared
158
+ * hand enum (left = local -X, right = +X). Both are world points.
159
+ *
160
+ * | Property | Type | Description |
161
+ * |---|---|---|
162
+ * | `familyId` | `string` | Hosted door family definition ID |
163
+ * | `version` | `number`? | Exact version; newest known by default |
164
+ * | `values` | `Record<string, number \| string>`? | Authored parameter overrides |
165
+ * | `hostWall` | {@linkcode ComponentHandle} | The wall to host the door |
166
+ * | `position` | {@linkcode Vec3Handle} | World point projected onto the wall |
167
+ * | `facing` | {@linkcode Vec3Handle}? | World point on the side the door swings open to (default engine-chosen) |
168
+ * | `hinge` | {@linkcode Vec3Handle}? | World point near the hinged jamb; requires hand control |
169
+ * | `label` | `string`? | Instance name (optional) |
170
+ * | `width` | `number`? | Declared width parameter (SU, > 0), not evaluated hole width |
171
+ * | `height` | `number`? | Declared height parameter (SU, > 0) |
172
+ */
173
+ export const PluginCreateDoorItem = z
174
+ .object({ ...PluginOpeningBaseOptions })
175
+ .strict()
176
+ export type PluginCreateDoorItem = z.infer<typeof PluginCreateDoorItem>
177
+
178
+ /** The `items` array of {@linkcode PluginDesignCreateApi.doors} (1…1000). */
179
+ export const PluginCreateDoorItems = z
180
+ .array(PluginCreateDoorItem)
181
+ .min(1)
182
+ .max(PLUGIN_CREATE_BATCH_LIMIT)
183
+ export type PluginCreateDoorItems = z.infer<typeof PluginCreateDoorItems>
184
+
185
+ /**
186
+ * One window to place via {@linkcode PluginDesignCreateApi.windows} — the same
187
+ * fields as a `"window"` {@linkcode PluginDesignCreateOpeningOptions}.
188
+ * `sillHeight` is a nonnegative Snaptrude-unit distance from the host wall's
189
+ * base to the BOTTOM of the window, not to its center. `facing` and `hinge`
190
+ * are WORLD POINTS, not directions: `facing` on the side of the wall the
191
+ * window opens to, `hinge` near the jamb it is hinged on. Rejects unknown
192
+ * fields.
193
+ *
194
+ * | Property | Type | Description |
195
+ * |---|---|---|
196
+ * | `familyId` | `string` | Hosted window family definition ID |
197
+ * | `version` | `number`? | Exact version; newest known by default |
198
+ * | `values` | `Record<string, number \| string>`? | Authored parameter overrides; numeric lengths use SU |
199
+ * | `hostWall` | {@linkcode ComponentHandle} | The wall to host the window |
200
+ * | `position` | {@linkcode Vec3Handle} | World point projected onto the wall |
201
+ * | `facing` | {@linkcode Vec3Handle}? | World point on the side the window opens to (default engine-chosen) |
202
+ * | `hinge` | {@linkcode Vec3Handle}? | World point near the hinged jamb; requires hand control |
203
+ * | `label` | `string`? | Instance name (optional) |
204
+ * | `width` | `number`? | Declared width parameter (SU, > 0), not evaluated hole width |
205
+ * | `height` | `number`? | Declared height parameter (SU, > 0) |
206
+ * | `sillHeight` | `number`? | Declared sill parameter (SU, ≥ 0); position Y is ignored |
207
+ */
208
+ export const PluginCreateWindowItem = z
209
+ .object({
210
+ ...PluginOpeningBaseOptions,
211
+ sillHeight: z.number().finite().nonnegative().optional(),
212
+ })
213
+ .strict()
214
+ export type PluginCreateWindowItem = z.infer<typeof PluginCreateWindowItem>
215
+
216
+ /** The `items` array of {@linkcode PluginDesignCreateApi.windows} (1…1000). */
217
+ export const PluginCreateWindowItems = z
218
+ .array(PluginCreateWindowItem)
219
+ .min(1)
220
+ .max(PLUGIN_CREATE_BATCH_LIMIT)
221
+ export type PluginCreateWindowItems = z.infer<typeof PluginCreateWindowItems>
222
+
223
+ // ---------------------------------------------------------------------------
224
+ // furnitureItems
225
+ // ---------------------------------------------------------------------------
226
+
227
+ /**
228
+ * One furniture instance to place via
229
+ * {@linkcode PluginDesignCreateApi.furnitureItems} — the same inputs as
230
+ * {@linkcode PluginDesignCreateApi.furniture} minus `createNewSourceMesh`: in a
231
+ * batch the host owns source-mesh persistence (a source is recorded once per
232
+ * call, however many items reuse it).
233
+ *
234
+ * `position.y` is the REST elevation: the item is grounded so its bounding-box
235
+ * base sits exactly at `position.y` (the same surface-flush contract as
236
+ * interactive drag-drop) — pass the floor/storey elevation to stand furniture
237
+ * on it; never add half the item's height yourself.
238
+ *
239
+ * | Property | Type | Description |
240
+ * |---|---|---|
241
+ * | `catalogId` | `string` | Library id: team `_id` or general `fullName` |
242
+ * | `position` | {@linkcode Vec3Handle} | Absolute world placement point (`y` = rest elevation) |
243
+ * | `label` | `string`? | Instance name and readable label (default auto `${name}Ins${n}`) |
244
+ * | `angleInDegrees` | `number`? | Rotation about the vertical axis, in degrees (default unrotated) |
245
+ */
246
+ export const PluginCreateFurnitureItem = z.object({
247
+ catalogId: z.string().min(1),
248
+ position: Vec3Handle,
249
+ label: z.string().optional(),
250
+ angleInDegrees: z.number().optional(),
251
+ })
252
+ export type PluginCreateFurnitureItem = z.infer<
253
+ typeof PluginCreateFurnitureItem
254
+ >
255
+
256
+ /**
257
+ * The `items` array of {@linkcode PluginDesignCreateApi.furnitureItems}
258
+ * (1…1000).
259
+ */
260
+ export const PluginCreateFurnitureItems = z
261
+ .array(PluginCreateFurnitureItem)
262
+ .min(1)
263
+ .max(PLUGIN_CREATE_BATCH_LIMIT)
264
+ export type PluginCreateFurnitureItems = z.infer<
265
+ typeof PluginCreateFurnitureItems
266
+ >
267
+
268
+ // ---------------------------------------------------------------------------
269
+ // voids
270
+ // ---------------------------------------------------------------------------
271
+
272
+ /**
273
+ * One void to cut via {@linkcode PluginDesignCreateApi.voids} — the same fields as
274
+ * {@linkcode PluginDesignCreateApi.void}. Rejects unknown fields.
275
+ *
276
+ * | Property | Type | Description |
277
+ * | --- | --- | --- |
278
+ * | `host` | {@linkcode ComponentHandle} | The slab, floor, roof or ceiling to cut through. Not a wall. |
279
+ * | `outline` | {@linkcode ProfileHandle} | Closed, flat plan outline in world SU (all points at one height). That height is ignored: it is dropped straight onto the host's top face. |
280
+ */
281
+ export const PluginCreateVoidItem = z
282
+ .object({
283
+ host: ComponentHandle,
284
+ outline: ProfileHandle,
285
+ })
286
+ .strict()
287
+ export type PluginCreateVoidItem = z.infer<typeof PluginCreateVoidItem>
288
+
289
+ /** The `items` array of {@linkcode PluginDesignCreateApi.voids} (1…1000; the host takes at most 200, 50 per host). */
290
+ export const PluginCreateVoidItems = z
291
+ .array(PluginCreateVoidItem)
292
+ .min(1)
293
+ .max(PLUGIN_CREATE_BATCH_LIMIT)
294
+ export type PluginCreateVoidItems = z.infer<typeof PluginCreateVoidItems>