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