@snaptrude/plugin-core 0.9.16 → 0.9.18-edgesetbacks-20261021.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 (221) hide show
  1. package/AGENTS.md +231 -231
  2. package/CHANGELOG.md +408 -402
  3. package/CLAUDE.md +11 -11
  4. package/api-manifest.json +1510 -701
  5. package/dist/api/analysis/daylight.d.ts +5 -5
  6. package/dist/api/analysis/solar.d.ts +2 -2
  7. package/dist/api/core/camera/index.d.ts +29 -0
  8. package/dist/api/core/camera/index.d.ts.map +1 -1
  9. package/dist/api/core/geom/create/index.d.ts +7 -1
  10. package/dist/api/core/geom/create/index.d.ts.map +1 -1
  11. package/dist/api/core/geom/update/contour.d.ts +8 -2
  12. package/dist/api/core/geom/update/contour.d.ts.map +1 -1
  13. package/dist/api/core/storeys/index.d.ts +5 -2
  14. package/dist/api/core/storeys/index.d.ts.map +1 -1
  15. package/dist/api/core/zoom/index.d.ts +13 -0
  16. package/dist/api/core/zoom/index.d.ts.map +1 -1
  17. package/dist/api/design/bim.d.ts +299 -0
  18. package/dist/api/design/bim.d.ts.map +1 -0
  19. package/dist/api/design/boolean/index.d.ts +2 -0
  20. package/dist/api/design/boolean/index.d.ts.map +1 -1
  21. package/dist/api/design/catalog.d.ts +320 -0
  22. package/dist/api/design/catalog.d.ts.map +1 -0
  23. package/dist/api/design/create/bulk-items.d.ts +65 -25
  24. package/dist/api/design/create/bulk-items.d.ts.map +1 -1
  25. package/dist/api/design/create/index.d.ts +299 -100
  26. package/dist/api/design/create/index.d.ts.map +1 -1
  27. package/dist/api/design/create/opening-fields.d.ts +13 -12
  28. package/dist/api/design/create/opening-fields.d.ts.map +1 -1
  29. package/dist/api/design/delete/index.d.ts +1 -0
  30. package/dist/api/design/delete/index.d.ts.map +1 -1
  31. package/dist/api/design/doors/index.d.ts +18 -24
  32. package/dist/api/design/doors/index.d.ts.map +1 -1
  33. package/dist/api/design/family.d.ts +813 -35
  34. package/dist/api/design/family.d.ts.map +1 -1
  35. package/dist/api/design/index.d.ts +16 -0
  36. package/dist/api/design/index.d.ts.map +1 -1
  37. package/dist/api/design/networks.d.ts +1703 -0
  38. package/dist/api/design/networks.d.ts.map +1 -0
  39. package/dist/api/design/query/grids.d.ts +2 -2
  40. package/dist/api/design/query/index.d.ts +42 -32
  41. package/dist/api/design/query/index.d.ts.map +1 -1
  42. package/dist/api/design/selection/index.d.ts +10 -10
  43. package/dist/api/design/types/index.d.ts +40 -24
  44. package/dist/api/design/types/index.d.ts.map +1 -1
  45. package/dist/api/design/update/index.d.ts +111 -6
  46. package/dist/api/design/update/index.d.ts.map +1 -1
  47. package/dist/api/design/windows/index.d.ts +8 -8
  48. package/dist/api/design/windows/index.d.ts.map +1 -1
  49. package/dist/api/entity/buildableEnvelope.d.ts +84 -2
  50. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -1
  51. package/dist/api/presentation/aiInspiration.d.ts +10 -10
  52. package/dist/api/presentation/annotate.d.ts +38 -22
  53. package/dist/api/presentation/annotate.d.ts.map +1 -1
  54. package/dist/api/presentation/drawingContract.d.ts +32 -0
  55. package/dist/api/presentation/drawingContract.d.ts.map +1 -0
  56. package/dist/api/presentation/drawings.d.ts +3523 -0
  57. package/dist/api/presentation/drawings.d.ts.map +1 -0
  58. package/dist/api/presentation/export.d.ts +23 -5
  59. package/dist/api/presentation/export.d.ts.map +1 -1
  60. package/dist/api/presentation/index.d.ts +41 -12
  61. package/dist/api/presentation/index.d.ts.map +1 -1
  62. package/dist/api/presentation/placedViews.d.ts +106 -6
  63. package/dist/api/presentation/placedViews.d.ts.map +1 -1
  64. package/dist/api/presentation/sections.d.ts +461 -0
  65. package/dist/api/presentation/sections.d.ts.map +1 -0
  66. package/dist/api/presentation/shapes.d.ts +2 -2
  67. package/dist/api/presentation/sheets.d.ts +175 -19
  68. package/dist/api/presentation/sheets.d.ts.map +1 -1
  69. package/dist/api/presentation/viewPresets.d.ts +222 -0
  70. package/dist/api/presentation/viewPresets.d.ts.map +1 -0
  71. package/dist/api/presentation/views.d.ts +141 -8
  72. package/dist/api/presentation/views.d.ts.map +1 -1
  73. package/dist/api/presentation/walkthroughs.d.ts +6 -6
  74. package/dist/errors/codes.d.ts +3 -1
  75. package/dist/errors/codes.d.ts.map +1 -1
  76. package/dist/index.cjs +3883 -2385
  77. package/dist/index.cjs.map +1 -1
  78. package/dist/index.js +3744 -2385
  79. package/dist/index.js.map +1 -1
  80. package/package.json +1 -1
  81. package/scripts/check-dist-fresh.mjs +22 -22
  82. package/scripts/generate-manifest.mjs +243 -238
  83. package/scripts/generate-manifest.test.mjs +303 -303
  84. package/src/api/analysis/daylight.ts +470 -470
  85. package/src/api/analysis/heatmaps.ts +683 -683
  86. package/src/api/analysis/illuminance.ts +155 -155
  87. package/src/api/analysis/index.ts +61 -61
  88. package/src/api/analysis/shadows.ts +183 -183
  89. package/src/api/analysis/solar.ts +237 -237
  90. package/src/api/analysis/sunlightHours.ts +211 -211
  91. package/src/api/analysis/sunpath.ts +83 -83
  92. package/src/api/analysis/weather.ts +179 -179
  93. package/src/api/core/buildings.ts +485 -485
  94. package/src/api/core/camera/index.ts +696 -667
  95. package/src/api/core/comment/index.ts +376 -376
  96. package/src/api/core/geom/create/index.ts +2139 -2133
  97. package/src/api/core/geom/delete/index.ts +84 -84
  98. package/src/api/core/geom/index.ts +35 -35
  99. package/src/api/core/geom/query/arc.ts +169 -169
  100. package/src/api/core/geom/query/brep.ts +621 -621
  101. package/src/api/core/geom/query/circle.ts +404 -404
  102. package/src/api/core/geom/query/contour.ts +540 -540
  103. package/src/api/core/geom/query/curve.ts +1102 -1102
  104. package/src/api/core/geom/query/edge.ts +130 -130
  105. package/src/api/core/geom/query/face.ts +508 -508
  106. package/src/api/core/geom/query/halfedge.ts +210 -210
  107. package/src/api/core/geom/query/index.ts +63 -63
  108. package/src/api/core/geom/query/profile.ts +473 -473
  109. package/src/api/core/geom/query/vertex.ts +205 -205
  110. package/src/api/core/geom/update/contour.ts +323 -317
  111. package/src/api/core/geom/update/curve.ts +209 -209
  112. package/src/api/core/geom/update/index.ts +29 -29
  113. package/src/api/core/geom/update/profile.ts +379 -379
  114. package/src/api/core/groups.ts +521 -521
  115. package/src/api/core/handles/index.ts +234 -234
  116. package/src/api/core/history/index.ts +84 -84
  117. package/src/api/core/index.ts +99 -99
  118. package/src/api/core/io/export/index.ts +126 -126
  119. package/src/api/core/io/import/index.ts +504 -504
  120. package/src/api/core/io/index.ts +42 -42
  121. package/src/api/core/io/job/index.ts +140 -140
  122. package/src/api/core/io/query/index.ts +71 -71
  123. package/src/api/core/io/terrain/index.ts +360 -360
  124. package/src/api/core/io/underlay/index.ts +705 -705
  125. package/src/api/core/layers.ts +540 -540
  126. package/src/api/core/math/index.ts +20 -20
  127. package/src/api/core/math/quat.ts +172 -172
  128. package/src/api/core/math/vec3.ts +179 -179
  129. package/src/api/core/mode/index.ts +108 -108
  130. package/src/api/core/project/index.ts +479 -479
  131. package/src/api/core/proposals/index.ts +570 -570
  132. package/src/api/core/storeys/index.ts +311 -308
  133. package/src/api/core/storeys/layers.ts +339 -339
  134. package/src/api/core/tags.ts +911 -911
  135. package/src/api/core/units/index.ts +164 -164
  136. package/src/api/core/user.ts +46 -46
  137. package/src/api/core/zoom/index.ts +64 -51
  138. package/src/api/design/bim.ts +210 -0
  139. package/src/api/design/boolean/index.ts +181 -179
  140. package/src/api/design/catalog.ts +203 -0
  141. package/src/api/design/create/bulk-items.ts +294 -254
  142. package/src/api/design/create/grids.ts +137 -137
  143. package/src/api/design/create/index.ts +2178 -1980
  144. package/src/api/design/create/opening-fields.ts +40 -37
  145. package/src/api/design/delete/index.ts +75 -74
  146. package/src/api/design/dimensions.ts +453 -453
  147. package/src/api/design/doors/index.ts +516 -500
  148. package/src/api/design/edit/index.ts +54 -54
  149. package/src/api/design/erase/index.ts +151 -151
  150. package/src/api/design/family.ts +1342 -704
  151. package/src/api/design/furniture/index.ts +319 -319
  152. package/src/api/design/grids.ts +237 -237
  153. package/src/api/design/index.ts +304 -274
  154. package/src/api/design/lock.ts +69 -69
  155. package/src/api/design/materials/index.ts +608 -608
  156. package/src/api/design/networks.ts +607 -0
  157. package/src/api/design/query/geometry/index.ts +319 -319
  158. package/src/api/design/query/grids.ts +197 -197
  159. package/src/api/design/query/index.ts +1236 -1226
  160. package/src/api/design/query/referenceLines.ts +52 -52
  161. package/src/api/design/query/spaces.ts +275 -275
  162. package/src/api/design/selection/index.ts +273 -273
  163. package/src/api/design/shared.ts +40 -40
  164. package/src/api/design/transform/index.ts +254 -254
  165. package/src/api/design/types/index.ts +163 -156
  166. package/src/api/design/update/index.ts +1096 -983
  167. package/src/api/design/visibility.ts +143 -143
  168. package/src/api/design/windows/index.ts +351 -333
  169. package/src/api/entity/buildableEnvelope.ts +397 -322
  170. package/src/api/entity/index.ts +30 -30
  171. package/src/api/entity/referenceLine.ts +235 -235
  172. package/src/api/entity/space.ts +612 -612
  173. package/src/api/entity/story.ts +517 -517
  174. package/src/api/index.ts +47 -47
  175. package/src/api/presentation/aiInspiration.ts +1116 -1116
  176. package/src/api/presentation/annotate.ts +417 -385
  177. package/src/api/presentation/camera.ts +289 -289
  178. package/src/api/presentation/diagrams.ts +194 -194
  179. package/src/api/presentation/drawingContract.ts +70 -0
  180. package/src/api/presentation/drawings.ts +1179 -0
  181. package/src/api/presentation/export.ts +134 -108
  182. package/src/api/presentation/import.ts +159 -159
  183. package/src/api/presentation/index.ts +160 -126
  184. package/src/api/presentation/placedViews.ts +1211 -1120
  185. package/src/api/presentation/sections.ts +420 -0
  186. package/src/api/presentation/shapes.ts +274 -274
  187. package/src/api/presentation/sheets.ts +746 -585
  188. package/src/api/presentation/slideshow.ts +134 -134
  189. package/src/api/presentation/tables.ts +84 -84
  190. package/src/api/presentation/viewPresets.ts +241 -0
  191. package/src/api/presentation/views.ts +742 -673
  192. package/src/api/presentation/walkthroughs.ts +1201 -1201
  193. package/src/api/program/adjacency.ts +164 -164
  194. package/src/api/program/areas.ts +408 -408
  195. package/src/api/program/classification.ts +138 -138
  196. package/src/api/program/cores.ts +83 -83
  197. package/src/api/program/departments.ts +517 -517
  198. package/src/api/program/index.ts +73 -73
  199. package/src/api/program/labels.ts +332 -332
  200. package/src/api/program/layout.ts +422 -422
  201. package/src/api/program/metadata.ts +364 -364
  202. package/src/api/program/metrics.ts +120 -120
  203. package/src/api/program/site.ts +748 -748
  204. package/src/api/program/spreadsheet.ts +2698 -2698
  205. package/src/api/workspace/index.ts +612 -612
  206. package/src/errors/codes.ts +143 -136
  207. package/src/errors/envelope.ts +75 -75
  208. package/src/errors/index.ts +21 -21
  209. package/src/errors/plugin-error.ts +134 -134
  210. package/src/handles.ts +297 -297
  211. package/src/host-utils.ts +67 -67
  212. package/src/index.ts +7 -7
  213. package/src/massParameters.ops.ts +246 -246
  214. package/src/massParameters.ts +427 -427
  215. package/src/types.ts +16 -16
  216. package/test/drawingContract.test.mjs +288 -0
  217. package/test/errors.test.mjs +185 -184
  218. package/test/massParameters.test.mjs +952 -952
  219. package/test/presentationViewSettings.test.mjs +85 -0
  220. package/tsconfig.json +22 -22
  221. package/tsup.config.ts +12 -12
@@ -1,427 +1,427 @@
1
- import * as z from "zod"
2
- import { MAX_OPERATIONS, OperationRecord, ParameterPatchValue } from "./massParameters.ops"
3
-
4
- // The selectors, the operation record and the patch-value union live in
5
- // `massParameters.ops.ts` (split so each module stays small enough for the
6
- // agent to read in one go) and are re-exported here, so every import path
7
- // keeps working.
8
- export * from "./massParameters.ops"
9
-
10
- /**
11
- * Mass **creation-parameter records** — the recipe a parametric mass was built
12
- * from, shared verbatim by plugin-core, the Snaptrude host, and the agent
13
- * runtime. There is one schema, not three hand-kept copies.
14
- *
15
- * A record is present on a mass committed from a `core.geom.create` brep
16
- * constructor that carries a recipe (the four primitives, extrusion,
17
- * revolution, loft, sweep). A fillet, chamfer, shell or offset of a **recorded**
18
- * solid keeps the record: `kind` stays the base constructor and the step is
19
- * appended to the record's `operations` list (see {@linkcode OperationRecord}).
20
- * The record is absent — `null` — for everything
21
- * else: drawn masses, imported geometry, booleans, split parts,
22
- * `brepFromFaces`/`brepFromMesh`, and any operation on a solid that carried no
23
- * record. Geometry there is not a pure function of a legible parameter set, and
24
- * a record must never be a lie.
25
- *
26
- * Read one with `design.query.getParameters`.
27
- *
28
- * Everything here is **pure JSON** by construction — plain objects, numbers and
29
- * arrays only, one `{x, y, z}` point shape everywhere (no tuples, no class
30
- * instances): records are persisted by enumerable-field reflection, cloned with
31
- * `structuredClone`, and round-tripped through the collaboration wire.
32
- */
33
-
34
- /** A point in space. The single point shape used across every record. */
35
- export type XYZ = { x: number; y: number; z: number }
36
-
37
- /**
38
- * One boundary curve of a profile record.
39
- *
40
- * The two spline forms are either/or, never both: a curve authored through
41
- * points carries `splineThrough` (patch the points and the fit re-runs), and a
42
- * curve with no through-point provenance — read back off an edge, or authored
43
- * from control vertices — carries `splinePoles` and is re-minted verbatim.
44
- * There is no variant holding both, so a `throughPoints` edit can never leave
45
- * stale poles behind.
46
- */
47
- export type CurveRecord =
48
- | { type: "line"; start: XYZ; end: XYZ }
49
- | { type: "arc"; start: XYZ; end: XYZ; centre: XYZ; axis: XYZ }
50
- | { type: "circle"; centre: XYZ; axis: XYZ; radius: number }
51
- /** Authored via splineFromPoints / profileFromSplinePoints. The through-points
52
- * ARE the recipe; regeneration re-runs the fit version named by
53
- * `fitVersion`. Several chained runs in one contour re-fit as ONE loop; use
54
- * splinePoles to keep their tangents. */
55
- | { type: "splineThrough"; fitVersion: 1; throughPoints: XYZ[] }
56
- /** No through-points known (authored from control points, or read back off
57
- * an edge). Rebuilt verbatim from these exact poles, knots and
58
- * multiplicities. */
59
- | { type: "splinePoles"; degree: number; knots: number[]; mults: number[]; poles: XYZ[] }
60
-
61
- /** A closed boundary loop, as an ordered list of curves. */
62
- export type ProfileRecord = { curves: CurveRecord[] }
63
-
64
- /** An outer loop plus its holes — the cross-section shape of a recipe. */
65
- export type ContourRecord = { outer: ProfileRecord; holes: ProfileRecord[] }
66
-
67
- /** Optional loft behaviour switches, mirroring `core.geom.create.brepFromLoft`. */
68
- export type LoftOptions = {
69
- compatibility?: "strict" | "auto"
70
- seamAlignment?: "authored" | "auto"
71
- /** `"ruled"` (default) keeps the sides straight: every pair of sections
72
- * joined by flat sides. `"smooth"` lofts every section in ONE pass, so the
73
- * sides curve continuously through the intermediates. */
74
- smoothing?: "ruled" | "smooth"
75
- }
76
-
77
- /**
78
- * How a swept profile turns along its path, mirroring
79
- * `core.geom.create.brepFromSweepAlongCurve`. `"upright"` keeps the profile's up
80
- * aligned with world up, `"frenet"` lets it roll with the path's curvature, and
81
- * `"fixed"` carries the authored frame along unchanged.
82
- */
83
- export type SweepOrientation = "frenet" | "fixed" | "upright"
84
-
85
- /** Optional sweep-along-a-curve switches. Pure JSON: the creator's own bag also
86
- * takes a `rail` curve, which is a live handle and never reaches a record. */
87
- export type SweepAlongCurveRecordOptions = { orientation?: SweepOrientation }
88
-
89
- /** Optional sweep scale law and corner transition, mirroring `core.geom.create.brepFromSweep`. */
90
- export type SweepOptions = {
91
- startScale?: number
92
- endScale?: number
93
- scales?: number[]
94
- transition?: "miter" | "round" | { bevel: number }
95
- }
96
-
97
- /** A face's surface kind — the vocabulary of `core.geom.query.face.getSurfaceKind`. */
98
- export type SurfaceKind = "plane" | "cylinder" | "cone" | "sphere" | "torus" | "spline"
99
-
100
- /** An edge's curve kind. Both spline forms of {@linkcode CurveRecord} report `"spline"`. */
101
- export type CurveKind = "line" | "arc" | "circle" | "spline"
102
-
103
- /**
104
- * A mass's creation recipe: the constructor `kind`, a schema `version`, the
105
- * `values` that constructor was called with, and the kernel `operations`
106
- * (fillet / chamfer / shell / offset) applied on top, in order. Points and axes
107
- * are in the mass's own local frame when stored; `design.query.getParameters`
108
- * returns them in world coordinates. `operations` is frame-free. One variant
109
- * per constructor `kind`; its `values` are that constructor's own arguments.
110
- *
111
- * `kind` stays the base constructor even after operations: a shelled, filleted
112
- * sphere is still `{ kind: "sphere", operations: [shell, fillet] }`.
113
- */
114
- export type MassParametersRecord =
115
- | {
116
- kind: "sphere"
117
- version: 1
118
- values: { centre: XYZ; radius: number }
119
- operations?: OperationRecord[]
120
- }
121
- | {
122
- kind: "cylinder"
123
- version: 1
124
- values: { base: XYZ; axis: XYZ; radius: number; height: number }
125
- operations?: OperationRecord[]
126
- }
127
- | {
128
- kind: "cone"
129
- version: 1
130
- values: { base: XYZ; axis: XYZ; baseRadius: number; topRadius: number; height: number }
131
- operations?: OperationRecord[]
132
- }
133
- | {
134
- kind: "torus"
135
- version: 1
136
- values: { centre: XYZ; axis: XYZ; majorRadius: number; minorRadius: number }
137
- operations?: OperationRecord[]
138
- }
139
- | {
140
- kind: "extrusion"
141
- version: 1
142
- values: {
143
- contour: ContourRecord
144
- direction: XYZ
145
- amount: number
146
- /** Total rotation base → top about `direction`, through the base
147
- * contour's centroid, in DEGREES — an angle, never converted. Absent
148
- * or 0 is a straight extrusion. Positive turns the top CLOCKWISE seen
149
- * from the far end of `direction` looking back at the base — for the
150
- * usual upward extrusion, that is the plan view from above. */
151
- twistInDegrees?: number
152
- /** Top outline scale about the same axis, a ratio — never converted.
153
- * Absent or 1 is a straight extrusion. */
154
- topScale?: number
155
- /** How many sections the twist/taper was built from, a count (2..64).
156
- * Resolved and stamped at create time, so an existing mass regenerates
157
- * from the record and never from a heuristic that may change; it is
158
- * re-resolved (and an echoed value overridden) when an edit changes
159
- * `twistInDegrees`, so a retwisted mass matches a fresh build of the
160
- * same angle. Absent exactly when the mass is neither twisted nor
161
- * tapered. */
162
- levels?: number
163
- }
164
- operations?: OperationRecord[]
165
- }
166
- | {
167
- kind: "revolution"
168
- version: 1
169
- values: {
170
- contour: ContourRecord
171
- axisOrigin: XYZ
172
- axisDirection: XYZ
173
- angleInDegrees: number
174
- }
175
- operations?: OperationRecord[]
176
- }
177
- | {
178
- kind: "loft"
179
- version: 1
180
- values: { sections: ContourRecord[]; options?: LoftOptions }
181
- operations?: OperationRecord[]
182
- }
183
- | {
184
- kind: "sweep"
185
- version: 1
186
- values: { profile: ContourRecord; path: XYZ[]; options?: SweepOptions }
187
- operations?: OperationRecord[]
188
- }
189
- | {
190
- kind: "sweepAlongCurve"
191
- version: 1
192
- values: {
193
- profile: ContourRecord
194
- path: CurveRecord[]
195
- options?: SweepAlongCurveRecordOptions
196
- }
197
- operations?: OperationRecord[]
198
- }
199
-
200
- /**
201
- * The argument of `design.update.parameters`: either a **partial** of a
202
- * record's `values` (plus an optional `operations` list) — keys you leave out
203
- * stay as they are — or the **whole record** you read from
204
- * `design.query.getParameters`, edited. `kind` and `version` are immutable.
205
- */
206
- export type MassParametersPatch = MassParametersRecord | Record<string, ParameterPatchValue>
207
-
208
- // ── Schemas ─────────────────────────────────────────────────────────────────
209
- // Array bounds are CONTRACT, not silent truncation: a record beyond them fails
210
- // validation. They keep a record inside the serialization budget of the save
211
- // and collaboration payloads it rides in. They bind RECORDS only — the shipped
212
- // creator schemas (loft sections, sweep path, fillet/chamfer edges, shell faces)
213
- // stay uncapped; an over-cap call still builds and the host simply mints no
214
- // record for it (the mass is then ordinary, non-parametric geometry).
215
-
216
- /** Maximum through-points in one authored spline curve record. */
217
- export const MAX_SPLINE_THROUGH_POINTS = 256
218
- /** Maximum control points in one exact-NURBS spline curve record. */
219
- export const MAX_SPLINE_POLES = 512
220
- /** Maximum path points in a sweep record. */
221
- export const MAX_SWEEP_PATH_POINTS = 512
222
- /** Maximum path curves in a sweep-along-a-curve record. */
223
- export const MAX_PATH_CURVES = 64
224
- /** Maximum cross-sections in a loft record. */
225
- export const MAX_LOFT_SECTIONS = 32
226
- /** Maximum sections a twisted or tapered extrusion record is built from. */
227
- export const MAX_TWIST_LEVELS = 64
228
- /** Maximum boundary curves in one profile loop record. */
229
- export const MAX_PROFILE_CURVES = 256
230
- /** Maximum hole loops in one contour record. */
231
- export const MAX_CONTOUR_HOLES = 64
232
-
233
- /** A point in space — `{ x, y, z }`, all finite. */
234
- export const XYZ: z.ZodType<XYZ, XYZ> = z.strictObject({
235
- x: z.number().finite(),
236
- y: z.number().finite(),
237
- z: z.number().finite(),
238
- })
239
-
240
- /** One boundary curve of a profile record. See {@linkcode CurveRecord}. */
241
- export const CurveRecord: z.ZodType<CurveRecord, CurveRecord> = z.discriminatedUnion("type", [
242
- z.strictObject({ type: z.literal("line"), start: XYZ, end: XYZ }),
243
- z.strictObject({ type: z.literal("arc"), start: XYZ, end: XYZ, centre: XYZ, axis: XYZ }),
244
- z.strictObject({
245
- type: z.literal("circle"),
246
- centre: XYZ,
247
- axis: XYZ,
248
- radius: z.number().finite().positive(),
249
- }),
250
- z.strictObject({
251
- type: z.literal("splineThrough"),
252
- fitVersion: z.literal(1),
253
- throughPoints: z.array(XYZ).min(2).max(MAX_SPLINE_THROUGH_POINTS),
254
- }),
255
- z.strictObject({
256
- type: z.literal("splinePoles"),
257
- degree: z.number().int().positive(),
258
- knots: z.array(z.number().finite()).min(2),
259
- mults: z.array(z.number().int().positive()).min(2),
260
- poles: z.array(XYZ).min(2).max(MAX_SPLINE_POLES),
261
- }),
262
- ])
263
-
264
- /** A closed boundary loop. See {@linkcode ProfileRecord}. */
265
- export const ProfileRecord: z.ZodType<ProfileRecord, ProfileRecord> = z.strictObject({
266
- curves: z.array(CurveRecord).min(1).max(MAX_PROFILE_CURVES),
267
- })
268
-
269
- /** An outer loop plus its holes. See {@linkcode ContourRecord}. */
270
- export const ContourRecord: z.ZodType<ContourRecord, ContourRecord> = z.strictObject({
271
- outer: ProfileRecord,
272
- holes: z.array(ProfileRecord).max(MAX_CONTOUR_HOLES),
273
- })
274
-
275
- /** Optional loft behaviour switches. See {@linkcode LoftOptions}. */
276
- export const LoftOptions: z.ZodType<LoftOptions, LoftOptions> = z.strictObject({
277
- compatibility: z.enum(["strict", "auto"]).optional(),
278
- seamAlignment: z.enum(["authored", "auto"]).optional(),
279
- smoothing: z.enum(["ruled", "smooth"]).optional(),
280
- })
281
-
282
- /** See {@linkcode SweepAlongCurveRecordOptions}. */
283
- export const SweepAlongCurveRecordOptions: z.ZodType<
284
- SweepAlongCurveRecordOptions,
285
- SweepAlongCurveRecordOptions
286
- > = z.strictObject({
287
- orientation: z.enum(["frenet", "fixed", "upright"]).optional(),
288
- })
289
-
290
- /** Optional sweep scale law and corner transition. See {@linkcode SweepOptions}. */
291
- export const SweepOptions: z.ZodType<SweepOptions, SweepOptions> = z.strictObject({
292
- startScale: z.number().finite().optional(),
293
- endScale: z.number().finite().optional(),
294
- scales: z.array(z.number().finite()).optional(),
295
- transition: z
296
- .union([
297
- z.literal("miter"),
298
- z.literal("round"),
299
- z.strictObject({ bevel: z.number().finite() }),
300
- ])
301
- .optional(),
302
- })
303
-
304
- // `operations` rides beside `values` on every kind — additive and optional, so
305
- // `version` stays 1. An older reader that predates `operations` fails
306
- // `safeParse` on a record carrying it and degrades the mass to non-parametric;
307
- // it never blocks a load.
308
- // No `.min(1)`: `design.update.parameters` documents `{ operations: [] }` as the
309
- // drop-every-operation idiom, and the whole record you read back — edited to an
310
- // empty list — must patch the same way. The host normalises `[]` to an absent
311
- // key before storing, so a stored record never carries one.
312
- const RecordOperations = z.array(OperationRecord).max(MAX_OPERATIONS).optional()
313
-
314
- /**
315
- * A mass's creation recipe. See {@linkcode MassParametersRecord}.
316
- *
317
- * `version` is a literal `1`: a restore that reads an unknown version fails
318
- * `safeParse` and the mass degrades to non-parametric — editability is lost,
319
- * geometry never is, and load is never blocked. Future versions add a migration
320
- * at the restore site.
321
- */
322
- export const MassParametersRecord: z.ZodType<MassParametersRecord, MassParametersRecord> = z.discriminatedUnion("kind", [
323
- z.strictObject({
324
- kind: z.literal("sphere"),
325
- version: z.literal(1),
326
- values: z.strictObject({ centre: XYZ, radius: z.number().finite().positive() }),
327
- operations: RecordOperations,
328
- }),
329
- z.strictObject({
330
- kind: z.literal("cylinder"),
331
- version: z.literal(1),
332
- values: z.strictObject({
333
- base: XYZ,
334
- axis: XYZ,
335
- radius: z.number().finite().positive(),
336
- height: z.number().finite().positive(),
337
- }),
338
- operations: RecordOperations,
339
- }),
340
- z.strictObject({
341
- kind: z.literal("cone"),
342
- version: z.literal(1),
343
- values: z.strictObject({
344
- base: XYZ,
345
- axis: XYZ,
346
- baseRadius: z.number().finite().positive(),
347
- topRadius: z.number().finite().nonnegative(),
348
- height: z.number().finite().positive(),
349
- }),
350
- operations: RecordOperations,
351
- }),
352
- z.strictObject({
353
- kind: z.literal("torus"),
354
- version: z.literal(1),
355
- values: z.strictObject({
356
- centre: XYZ,
357
- axis: XYZ,
358
- majorRadius: z.number().finite().positive(),
359
- minorRadius: z.number().finite().positive(),
360
- }),
361
- operations: RecordOperations,
362
- }),
363
- z.strictObject({
364
- kind: z.literal("extrusion"),
365
- version: z.literal(1),
366
- values: z.strictObject({
367
- contour: ContourRecord,
368
- direction: XYZ,
369
- amount: z.number().finite(),
370
- twistInDegrees: z.number().finite().optional(),
371
- topScale: z.number().finite().positive().optional(),
372
- levels: z.number().int().min(2).max(MAX_TWIST_LEVELS).optional(),
373
- }),
374
- operations: RecordOperations,
375
- }),
376
- z.strictObject({
377
- kind: z.literal("revolution"),
378
- version: z.literal(1),
379
- values: z.strictObject({
380
- contour: ContourRecord,
381
- axisOrigin: XYZ,
382
- axisDirection: XYZ,
383
- angleInDegrees: z.number().finite().positive().max(360),
384
- }),
385
- operations: RecordOperations,
386
- }),
387
- z.strictObject({
388
- kind: z.literal("loft"),
389
- version: z.literal(1),
390
- values: z.strictObject({
391
- sections: z.array(ContourRecord).min(2).max(MAX_LOFT_SECTIONS),
392
- options: LoftOptions.optional(),
393
- }),
394
- operations: RecordOperations,
395
- }),
396
- z.strictObject({
397
- kind: z.literal("sweep"),
398
- version: z.literal(1),
399
- values: z.strictObject({
400
- profile: ContourRecord,
401
- path: z.array(XYZ).min(2).max(MAX_SWEEP_PATH_POINTS),
402
- options: SweepOptions.optional(),
403
- }),
404
- operations: RecordOperations,
405
- }),
406
- z.strictObject({
407
- kind: z.literal("sweepAlongCurve"),
408
- version: z.literal(1),
409
- values: z.strictObject({
410
- profile: ContourRecord,
411
- path: z.array(CurveRecord).min(1).max(MAX_PATH_CURVES),
412
- options: SweepAlongCurveRecordOptions.optional(),
413
- }),
414
- operations: RecordOperations,
415
- }),
416
- ])
417
-
418
- /**
419
- * The argument of `design.update.parameters`. See {@linkcode MassParametersPatch}.
420
- * The full-record form is recognised by carrying both `kind` and `values`;
421
- * which keys a kind actually has is checked host-side, where the error can name
422
- * them.
423
- */
424
- export const MassParametersPatch: z.ZodType<MassParametersPatch, MassParametersPatch> = z.union([
425
- MassParametersRecord,
426
- z.record(z.string(), ParameterPatchValue),
427
- ])
1
+ import * as z from "zod"
2
+ import { MAX_OPERATIONS, OperationRecord, ParameterPatchValue } from "./massParameters.ops"
3
+
4
+ // The selectors, the operation record and the patch-value union live in
5
+ // `massParameters.ops.ts` (split so each module stays small enough for the
6
+ // agent to read in one go) and are re-exported here, so every import path
7
+ // keeps working.
8
+ export * from "./massParameters.ops"
9
+
10
+ /**
11
+ * Mass **creation-parameter records** — the recipe a parametric mass was built
12
+ * from, shared verbatim by plugin-core, the Snaptrude host, and the agent
13
+ * runtime. There is one schema, not three hand-kept copies.
14
+ *
15
+ * A record is present on a mass committed from a `core.geom.create` brep
16
+ * constructor that carries a recipe (the four primitives, extrusion,
17
+ * revolution, loft, sweep). A fillet, chamfer, shell or offset of a **recorded**
18
+ * solid keeps the record: `kind` stays the base constructor and the step is
19
+ * appended to the record's `operations` list (see {@linkcode OperationRecord}).
20
+ * The record is absent — `null` — for everything
21
+ * else: drawn masses, imported geometry, booleans, split parts,
22
+ * `brepFromFaces`/`brepFromMesh`, and any operation on a solid that carried no
23
+ * record. Geometry there is not a pure function of a legible parameter set, and
24
+ * a record must never be a lie.
25
+ *
26
+ * Read one with `design.query.getParameters`.
27
+ *
28
+ * Everything here is **pure JSON** by construction — plain objects, numbers and
29
+ * arrays only, one `{x, y, z}` point shape everywhere (no tuples, no class
30
+ * instances): records are persisted by enumerable-field reflection, cloned with
31
+ * `structuredClone`, and round-tripped through the collaboration wire.
32
+ */
33
+
34
+ /** A point in space. The single point shape used across every record. */
35
+ export type XYZ = { x: number; y: number; z: number }
36
+
37
+ /**
38
+ * One boundary curve of a profile record.
39
+ *
40
+ * The two spline forms are either/or, never both: a curve authored through
41
+ * points carries `splineThrough` (patch the points and the fit re-runs), and a
42
+ * curve with no through-point provenance — read back off an edge, or authored
43
+ * from control vertices — carries `splinePoles` and is re-minted verbatim.
44
+ * There is no variant holding both, so a `throughPoints` edit can never leave
45
+ * stale poles behind.
46
+ */
47
+ export type CurveRecord =
48
+ | { type: "line"; start: XYZ; end: XYZ }
49
+ | { type: "arc"; start: XYZ; end: XYZ; centre: XYZ; axis: XYZ }
50
+ | { type: "circle"; centre: XYZ; axis: XYZ; radius: number }
51
+ /** Authored via splineFromPoints / profileFromSplinePoints. The through-points
52
+ * ARE the recipe; regeneration re-runs the fit version named by
53
+ * `fitVersion`. Several chained runs in one contour re-fit as ONE loop; use
54
+ * splinePoles to keep their tangents. */
55
+ | { type: "splineThrough"; fitVersion: 1; throughPoints: XYZ[] }
56
+ /** No through-points known (authored from control points, or read back off
57
+ * an edge). Rebuilt verbatim from these exact poles, knots and
58
+ * multiplicities. */
59
+ | { type: "splinePoles"; degree: number; knots: number[]; mults: number[]; poles: XYZ[] }
60
+
61
+ /** A closed boundary loop, as an ordered list of curves. */
62
+ export type ProfileRecord = { curves: CurveRecord[] }
63
+
64
+ /** An outer loop plus its holes — the cross-section shape of a recipe. */
65
+ export type ContourRecord = { outer: ProfileRecord; holes: ProfileRecord[] }
66
+
67
+ /** Optional loft behaviour switches, mirroring `core.geom.create.brepFromLoft`. */
68
+ export type LoftOptions = {
69
+ compatibility?: "strict" | "auto"
70
+ seamAlignment?: "authored" | "auto"
71
+ /** `"ruled"` (default) keeps the sides straight: every pair of sections
72
+ * joined by flat sides. `"smooth"` lofts every section in ONE pass, so the
73
+ * sides curve continuously through the intermediates. */
74
+ smoothing?: "ruled" | "smooth"
75
+ }
76
+
77
+ /**
78
+ * How a swept profile turns along its path, mirroring
79
+ * `core.geom.create.brepFromSweepAlongCurve`. `"upright"` keeps the profile's up
80
+ * aligned with world up, `"frenet"` lets it roll with the path's curvature, and
81
+ * `"fixed"` carries the authored frame along unchanged.
82
+ */
83
+ export type SweepOrientation = "frenet" | "fixed" | "upright"
84
+
85
+ /** Optional sweep-along-a-curve switches. Pure JSON: the creator's own bag also
86
+ * takes a `rail` curve, which is a live handle and never reaches a record. */
87
+ export type SweepAlongCurveRecordOptions = { orientation?: SweepOrientation }
88
+
89
+ /** Optional sweep scale law and corner transition, mirroring `core.geom.create.brepFromSweep`. */
90
+ export type SweepOptions = {
91
+ startScale?: number
92
+ endScale?: number
93
+ scales?: number[]
94
+ transition?: "miter" | "round" | { bevel: number }
95
+ }
96
+
97
+ /** A face's surface kind — the vocabulary of `core.geom.query.face.getSurfaceKind`. */
98
+ export type SurfaceKind = "plane" | "cylinder" | "cone" | "sphere" | "torus" | "spline"
99
+
100
+ /** An edge's curve kind. Both spline forms of {@linkcode CurveRecord} report `"spline"`. */
101
+ export type CurveKind = "line" | "arc" | "circle" | "spline"
102
+
103
+ /**
104
+ * A mass's creation recipe: the constructor `kind`, a schema `version`, the
105
+ * `values` that constructor was called with, and the kernel `operations`
106
+ * (fillet / chamfer / shell / offset) applied on top, in order. Points and axes
107
+ * are in the mass's own local frame when stored; `design.query.getParameters`
108
+ * returns them in world coordinates. `operations` is frame-free. One variant
109
+ * per constructor `kind`; its `values` are that constructor's own arguments.
110
+ *
111
+ * `kind` stays the base constructor even after operations: a shelled, filleted
112
+ * sphere is still `{ kind: "sphere", operations: [shell, fillet] }`.
113
+ */
114
+ export type MassParametersRecord =
115
+ | {
116
+ kind: "sphere"
117
+ version: 1
118
+ values: { centre: XYZ; radius: number }
119
+ operations?: OperationRecord[]
120
+ }
121
+ | {
122
+ kind: "cylinder"
123
+ version: 1
124
+ values: { base: XYZ; axis: XYZ; radius: number; height: number }
125
+ operations?: OperationRecord[]
126
+ }
127
+ | {
128
+ kind: "cone"
129
+ version: 1
130
+ values: { base: XYZ; axis: XYZ; baseRadius: number; topRadius: number; height: number }
131
+ operations?: OperationRecord[]
132
+ }
133
+ | {
134
+ kind: "torus"
135
+ version: 1
136
+ values: { centre: XYZ; axis: XYZ; majorRadius: number; minorRadius: number }
137
+ operations?: OperationRecord[]
138
+ }
139
+ | {
140
+ kind: "extrusion"
141
+ version: 1
142
+ values: {
143
+ contour: ContourRecord
144
+ direction: XYZ
145
+ amount: number
146
+ /** Total rotation base → top about `direction`, through the base
147
+ * contour's centroid, in DEGREES — an angle, never converted. Absent
148
+ * or 0 is a straight extrusion. Positive turns the top CLOCKWISE seen
149
+ * from the far end of `direction` looking back at the base — for the
150
+ * usual upward extrusion, that is the plan view from above. */
151
+ twistInDegrees?: number
152
+ /** Top outline scale about the same axis, a ratio — never converted.
153
+ * Absent or 1 is a straight extrusion. */
154
+ topScale?: number
155
+ /** How many sections the twist/taper was built from, a count (2..64).
156
+ * Resolved and stamped at create time, so an existing mass regenerates
157
+ * from the record and never from a heuristic that may change; it is
158
+ * re-resolved (and an echoed value overridden) when an edit changes
159
+ * `twistInDegrees`, so a retwisted mass matches a fresh build of the
160
+ * same angle. Absent exactly when the mass is neither twisted nor
161
+ * tapered. */
162
+ levels?: number
163
+ }
164
+ operations?: OperationRecord[]
165
+ }
166
+ | {
167
+ kind: "revolution"
168
+ version: 1
169
+ values: {
170
+ contour: ContourRecord
171
+ axisOrigin: XYZ
172
+ axisDirection: XYZ
173
+ angleInDegrees: number
174
+ }
175
+ operations?: OperationRecord[]
176
+ }
177
+ | {
178
+ kind: "loft"
179
+ version: 1
180
+ values: { sections: ContourRecord[]; options?: LoftOptions }
181
+ operations?: OperationRecord[]
182
+ }
183
+ | {
184
+ kind: "sweep"
185
+ version: 1
186
+ values: { profile: ContourRecord; path: XYZ[]; options?: SweepOptions }
187
+ operations?: OperationRecord[]
188
+ }
189
+ | {
190
+ kind: "sweepAlongCurve"
191
+ version: 1
192
+ values: {
193
+ profile: ContourRecord
194
+ path: CurveRecord[]
195
+ options?: SweepAlongCurveRecordOptions
196
+ }
197
+ operations?: OperationRecord[]
198
+ }
199
+
200
+ /**
201
+ * The argument of `design.update.parameters`: either a **partial** of a
202
+ * record's `values` (plus an optional `operations` list) — keys you leave out
203
+ * stay as they are — or the **whole record** you read from
204
+ * `design.query.getParameters`, edited. `kind` and `version` are immutable.
205
+ */
206
+ export type MassParametersPatch = MassParametersRecord | Record<string, ParameterPatchValue>
207
+
208
+ // ── Schemas ─────────────────────────────────────────────────────────────────
209
+ // Array bounds are CONTRACT, not silent truncation: a record beyond them fails
210
+ // validation. They keep a record inside the serialization budget of the save
211
+ // and collaboration payloads it rides in. They bind RECORDS only — the shipped
212
+ // creator schemas (loft sections, sweep path, fillet/chamfer edges, shell faces)
213
+ // stay uncapped; an over-cap call still builds and the host simply mints no
214
+ // record for it (the mass is then ordinary, non-parametric geometry).
215
+
216
+ /** Maximum through-points in one authored spline curve record. */
217
+ export const MAX_SPLINE_THROUGH_POINTS = 256
218
+ /** Maximum control points in one exact-NURBS spline curve record. */
219
+ export const MAX_SPLINE_POLES = 512
220
+ /** Maximum path points in a sweep record. */
221
+ export const MAX_SWEEP_PATH_POINTS = 512
222
+ /** Maximum path curves in a sweep-along-a-curve record. */
223
+ export const MAX_PATH_CURVES = 64
224
+ /** Maximum cross-sections in a loft record. */
225
+ export const MAX_LOFT_SECTIONS = 32
226
+ /** Maximum sections a twisted or tapered extrusion record is built from. */
227
+ export const MAX_TWIST_LEVELS = 64
228
+ /** Maximum boundary curves in one profile loop record. */
229
+ export const MAX_PROFILE_CURVES = 256
230
+ /** Maximum hole loops in one contour record. */
231
+ export const MAX_CONTOUR_HOLES = 64
232
+
233
+ /** A point in space — `{ x, y, z }`, all finite. */
234
+ export const XYZ: z.ZodType<XYZ, XYZ> = z.strictObject({
235
+ x: z.number().finite(),
236
+ y: z.number().finite(),
237
+ z: z.number().finite(),
238
+ })
239
+
240
+ /** One boundary curve of a profile record. See {@linkcode CurveRecord}. */
241
+ export const CurveRecord: z.ZodType<CurveRecord, CurveRecord> = z.discriminatedUnion("type", [
242
+ z.strictObject({ type: z.literal("line"), start: XYZ, end: XYZ }),
243
+ z.strictObject({ type: z.literal("arc"), start: XYZ, end: XYZ, centre: XYZ, axis: XYZ }),
244
+ z.strictObject({
245
+ type: z.literal("circle"),
246
+ centre: XYZ,
247
+ axis: XYZ,
248
+ radius: z.number().finite().positive(),
249
+ }),
250
+ z.strictObject({
251
+ type: z.literal("splineThrough"),
252
+ fitVersion: z.literal(1),
253
+ throughPoints: z.array(XYZ).min(2).max(MAX_SPLINE_THROUGH_POINTS),
254
+ }),
255
+ z.strictObject({
256
+ type: z.literal("splinePoles"),
257
+ degree: z.number().int().positive(),
258
+ knots: z.array(z.number().finite()).min(2),
259
+ mults: z.array(z.number().int().positive()).min(2),
260
+ poles: z.array(XYZ).min(2).max(MAX_SPLINE_POLES),
261
+ }),
262
+ ])
263
+
264
+ /** A closed boundary loop. See {@linkcode ProfileRecord}. */
265
+ export const ProfileRecord: z.ZodType<ProfileRecord, ProfileRecord> = z.strictObject({
266
+ curves: z.array(CurveRecord).min(1).max(MAX_PROFILE_CURVES),
267
+ })
268
+
269
+ /** An outer loop plus its holes. See {@linkcode ContourRecord}. */
270
+ export const ContourRecord: z.ZodType<ContourRecord, ContourRecord> = z.strictObject({
271
+ outer: ProfileRecord,
272
+ holes: z.array(ProfileRecord).max(MAX_CONTOUR_HOLES),
273
+ })
274
+
275
+ /** Optional loft behaviour switches. See {@linkcode LoftOptions}. */
276
+ export const LoftOptions: z.ZodType<LoftOptions, LoftOptions> = z.strictObject({
277
+ compatibility: z.enum(["strict", "auto"]).optional(),
278
+ seamAlignment: z.enum(["authored", "auto"]).optional(),
279
+ smoothing: z.enum(["ruled", "smooth"]).optional(),
280
+ })
281
+
282
+ /** See {@linkcode SweepAlongCurveRecordOptions}. */
283
+ export const SweepAlongCurveRecordOptions: z.ZodType<
284
+ SweepAlongCurveRecordOptions,
285
+ SweepAlongCurveRecordOptions
286
+ > = z.strictObject({
287
+ orientation: z.enum(["frenet", "fixed", "upright"]).optional(),
288
+ })
289
+
290
+ /** Optional sweep scale law and corner transition. See {@linkcode SweepOptions}. */
291
+ export const SweepOptions: z.ZodType<SweepOptions, SweepOptions> = z.strictObject({
292
+ startScale: z.number().finite().optional(),
293
+ endScale: z.number().finite().optional(),
294
+ scales: z.array(z.number().finite()).optional(),
295
+ transition: z
296
+ .union([
297
+ z.literal("miter"),
298
+ z.literal("round"),
299
+ z.strictObject({ bevel: z.number().finite() }),
300
+ ])
301
+ .optional(),
302
+ })
303
+
304
+ // `operations` rides beside `values` on every kind — additive and optional, so
305
+ // `version` stays 1. An older reader that predates `operations` fails
306
+ // `safeParse` on a record carrying it and degrades the mass to non-parametric;
307
+ // it never blocks a load.
308
+ // No `.min(1)`: `design.update.parameters` documents `{ operations: [] }` as the
309
+ // drop-every-operation idiom, and the whole record you read back — edited to an
310
+ // empty list — must patch the same way. The host normalises `[]` to an absent
311
+ // key before storing, so a stored record never carries one.
312
+ const RecordOperations = z.array(OperationRecord).max(MAX_OPERATIONS).optional()
313
+
314
+ /**
315
+ * A mass's creation recipe. See {@linkcode MassParametersRecord}.
316
+ *
317
+ * `version` is a literal `1`: a restore that reads an unknown version fails
318
+ * `safeParse` and the mass degrades to non-parametric — editability is lost,
319
+ * geometry never is, and load is never blocked. Future versions add a migration
320
+ * at the restore site.
321
+ */
322
+ export const MassParametersRecord: z.ZodType<MassParametersRecord, MassParametersRecord> = z.discriminatedUnion("kind", [
323
+ z.strictObject({
324
+ kind: z.literal("sphere"),
325
+ version: z.literal(1),
326
+ values: z.strictObject({ centre: XYZ, radius: z.number().finite().positive() }),
327
+ operations: RecordOperations,
328
+ }),
329
+ z.strictObject({
330
+ kind: z.literal("cylinder"),
331
+ version: z.literal(1),
332
+ values: z.strictObject({
333
+ base: XYZ,
334
+ axis: XYZ,
335
+ radius: z.number().finite().positive(),
336
+ height: z.number().finite().positive(),
337
+ }),
338
+ operations: RecordOperations,
339
+ }),
340
+ z.strictObject({
341
+ kind: z.literal("cone"),
342
+ version: z.literal(1),
343
+ values: z.strictObject({
344
+ base: XYZ,
345
+ axis: XYZ,
346
+ baseRadius: z.number().finite().positive(),
347
+ topRadius: z.number().finite().nonnegative(),
348
+ height: z.number().finite().positive(),
349
+ }),
350
+ operations: RecordOperations,
351
+ }),
352
+ z.strictObject({
353
+ kind: z.literal("torus"),
354
+ version: z.literal(1),
355
+ values: z.strictObject({
356
+ centre: XYZ,
357
+ axis: XYZ,
358
+ majorRadius: z.number().finite().positive(),
359
+ minorRadius: z.number().finite().positive(),
360
+ }),
361
+ operations: RecordOperations,
362
+ }),
363
+ z.strictObject({
364
+ kind: z.literal("extrusion"),
365
+ version: z.literal(1),
366
+ values: z.strictObject({
367
+ contour: ContourRecord,
368
+ direction: XYZ,
369
+ amount: z.number().finite(),
370
+ twistInDegrees: z.number().finite().optional(),
371
+ topScale: z.number().finite().positive().optional(),
372
+ levels: z.number().int().min(2).max(MAX_TWIST_LEVELS).optional(),
373
+ }),
374
+ operations: RecordOperations,
375
+ }),
376
+ z.strictObject({
377
+ kind: z.literal("revolution"),
378
+ version: z.literal(1),
379
+ values: z.strictObject({
380
+ contour: ContourRecord,
381
+ axisOrigin: XYZ,
382
+ axisDirection: XYZ,
383
+ angleInDegrees: z.number().finite().positive().max(360),
384
+ }),
385
+ operations: RecordOperations,
386
+ }),
387
+ z.strictObject({
388
+ kind: z.literal("loft"),
389
+ version: z.literal(1),
390
+ values: z.strictObject({
391
+ sections: z.array(ContourRecord).min(2).max(MAX_LOFT_SECTIONS),
392
+ options: LoftOptions.optional(),
393
+ }),
394
+ operations: RecordOperations,
395
+ }),
396
+ z.strictObject({
397
+ kind: z.literal("sweep"),
398
+ version: z.literal(1),
399
+ values: z.strictObject({
400
+ profile: ContourRecord,
401
+ path: z.array(XYZ).min(2).max(MAX_SWEEP_PATH_POINTS),
402
+ options: SweepOptions.optional(),
403
+ }),
404
+ operations: RecordOperations,
405
+ }),
406
+ z.strictObject({
407
+ kind: z.literal("sweepAlongCurve"),
408
+ version: z.literal(1),
409
+ values: z.strictObject({
410
+ profile: ContourRecord,
411
+ path: z.array(CurveRecord).min(1).max(MAX_PATH_CURVES),
412
+ options: SweepAlongCurveRecordOptions.optional(),
413
+ }),
414
+ operations: RecordOperations,
415
+ }),
416
+ ])
417
+
418
+ /**
419
+ * The argument of `design.update.parameters`. See {@linkcode MassParametersPatch}.
420
+ * The full-record form is recognised by carrying both `kind` and `values`;
421
+ * which keys a kind actually has is checked host-side, where the error can name
422
+ * them.
423
+ */
424
+ export const MassParametersPatch: z.ZodType<MassParametersPatch, MassParametersPatch> = z.union([
425
+ MassParametersRecord,
426
+ z.record(z.string(), ParameterPatchValue),
427
+ ])