@snaptrude/plugin-core 0.0.0-dev-20260908074328 → 0.0.0-dev-20260921132444

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 (95) hide show
  1. package/AGENTS.md +4 -0
  2. package/CHANGELOG.md +52 -16
  3. package/dist/api/core/io/import/index.d.ts +3 -1
  4. package/dist/api/core/io/import/index.d.ts.map +1 -1
  5. package/dist/api/core/mode/index.d.ts +19 -7
  6. package/dist/api/core/mode/index.d.ts.map +1 -1
  7. package/dist/api/core/tags.d.ts +81 -0
  8. package/dist/api/core/tags.d.ts.map +1 -1
  9. package/dist/api/design/create/bulk-items.d.ts +185 -0
  10. package/dist/api/design/create/bulk-items.d.ts.map +1 -0
  11. package/dist/api/design/create/grids.d.ts +132 -0
  12. package/dist/api/design/create/grids.d.ts.map +1 -0
  13. package/dist/api/design/create/index.d.ts +424 -51
  14. package/dist/api/design/create/index.d.ts.map +1 -1
  15. package/dist/api/design/create/opening-fields.d.ts +37 -0
  16. package/dist/api/design/create/opening-fields.d.ts.map +1 -0
  17. package/dist/api/design/delete/index.d.ts +6 -20
  18. package/dist/api/design/delete/index.d.ts.map +1 -1
  19. package/dist/api/design/dimensions.d.ts +427 -0
  20. package/dist/api/design/dimensions.d.ts.map +1 -0
  21. package/dist/api/design/doors/index.d.ts +20 -13
  22. package/dist/api/design/doors/index.d.ts.map +1 -1
  23. package/dist/api/design/family.d.ts +73 -5
  24. package/dist/api/design/family.d.ts.map +1 -1
  25. package/dist/api/design/grids.d.ts +237 -0
  26. package/dist/api/design/grids.d.ts.map +1 -0
  27. package/dist/api/design/index.d.ts +9 -0
  28. package/dist/api/design/index.d.ts.map +1 -1
  29. package/dist/api/design/query/grids.d.ts +287 -0
  30. package/dist/api/design/query/grids.d.ts.map +1 -0
  31. package/dist/api/design/query/index.d.ts +29 -2
  32. package/dist/api/design/query/index.d.ts.map +1 -1
  33. package/dist/api/design/query/spaces.d.ts +0 -61
  34. package/dist/api/design/query/spaces.d.ts.map +1 -1
  35. package/dist/api/design/update/index.d.ts +74 -0
  36. package/dist/api/design/update/index.d.ts.map +1 -1
  37. package/dist/api/entity/space.d.ts +0 -3
  38. package/dist/api/entity/space.d.ts.map +1 -1
  39. package/dist/api/presentation/annotate.d.ts +2 -2
  40. package/dist/api/presentation/placedViews.d.ts +1 -35
  41. package/dist/api/presentation/placedViews.d.ts.map +1 -1
  42. package/dist/api/presentation/shapes.d.ts +2 -2
  43. package/dist/api/presentation/sheets.d.ts +2 -20
  44. package/dist/api/presentation/sheets.d.ts.map +1 -1
  45. package/dist/api/program/departments.d.ts +58 -2
  46. package/dist/api/program/departments.d.ts.map +1 -1
  47. package/dist/api/program/index.d.ts +16 -6
  48. package/dist/api/program/index.d.ts.map +1 -1
  49. package/dist/api/program/labels.d.ts +355 -0
  50. package/dist/api/program/labels.d.ts.map +1 -0
  51. package/dist/api/program/metadata.d.ts +328 -0
  52. package/dist/api/program/metadata.d.ts.map +1 -0
  53. package/dist/api/program/spreadsheet.d.ts +263 -0
  54. package/dist/api/program/spreadsheet.d.ts.map +1 -1
  55. package/dist/api/workspace/index.d.ts +49 -2
  56. package/dist/api/workspace/index.d.ts.map +1 -1
  57. package/dist/errors/codes.d.ts +3 -8
  58. package/dist/errors/codes.d.ts.map +1 -1
  59. package/dist/handles.d.ts +19 -0
  60. package/dist/handles.d.ts.map +1 -1
  61. package/dist/index.cjs +2489 -1941
  62. package/dist/index.cjs.map +1 -1
  63. package/dist/index.js +2395 -1936
  64. package/dist/index.js.map +1 -1
  65. package/package.json +1 -1
  66. package/src/api/core/io/import/index.ts +11 -3
  67. package/src/api/core/mode/index.ts +19 -7
  68. package/src/api/core/tags.ts +76 -0
  69. package/src/api/design/create/bulk-items.ts +186 -0
  70. package/src/api/design/create/grids.ts +137 -0
  71. package/src/api/design/create/index.ts +472 -70
  72. package/src/api/design/create/opening-fields.ts +37 -0
  73. package/src/api/design/delete/index.ts +5 -20
  74. package/src/api/design/dimensions.ts +453 -0
  75. package/src/api/design/doors/index.ts +20 -13
  76. package/src/api/design/family.ts +51 -4
  77. package/src/api/design/grids.ts +237 -0
  78. package/src/api/design/index.ts +10 -0
  79. package/src/api/design/query/grids.ts +197 -0
  80. package/src/api/design/query/index.ts +27 -2
  81. package/src/api/design/query/spaces.ts +0 -68
  82. package/src/api/design/update/index.ts +53 -0
  83. package/src/api/entity/space.ts +0 -2
  84. package/src/api/presentation/placedViews.ts +1 -29
  85. package/src/api/presentation/sheets.ts +3 -19
  86. package/src/api/program/departments.ts +54 -2
  87. package/src/api/program/index.ts +16 -6
  88. package/src/api/program/labels.ts +332 -0
  89. package/src/api/program/metadata.ts +364 -0
  90. package/src/api/program/spreadsheet.ts +282 -0
  91. package/src/api/workspace/index.ts +51 -2
  92. package/src/errors/codes.ts +2 -30
  93. package/src/handles.ts +24 -0
  94. package/test/errors.test.mjs +0 -4
  95. package/snaptrude-plugin-core-0.11.0.tgz +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snaptrude/plugin-core",
3
- "version": "0.0.0-dev-20260908074328",
3
+ "version": "0.0.0-dev-20260921132444",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -183,7 +183,10 @@ export abstract class PluginCoreIoImportApi {
183
183
  * if (cad) console.log("DWG imported as CAD underlay:", cad)
184
184
  * ```
185
185
  */
186
- public abstract dwg(source: string, storey?: number): PluginApiReturn<ImportJobHandle>
186
+ public abstract dwg(
187
+ source: string,
188
+ storey?: number,
189
+ ): PluginApiReturn<ImportJobHandle>
187
190
 
188
191
  /**
189
192
  * Sketch a CAD underlay from **already-parsed CAD JSON** — synchronous, with no
@@ -214,7 +217,10 @@ export abstract class PluginCoreIoImportApi {
214
217
  * )
215
218
  * ```
216
219
  */
217
- public abstract cadJson(cad: CadJsonInput, storey?: number): PluginApiReturn<UnderlayHandle>
220
+ public abstract cadJson(
221
+ cad: CadJsonInput,
222
+ storey?: number,
223
+ ): PluginApiReturn<UnderlayHandle>
218
224
 
219
225
  /**
220
226
  * Import a **3D model** file and place it in the scene as a component.
@@ -239,7 +245,9 @@ export abstract class PluginCoreIoImportApi {
239
245
  * @returns the placed {@linkcode ComponentHandle}.
240
246
  * @throws if writes are disabled, the source can't be loaded, the format is
241
247
  * unsupported, conversion/placement fails, or the converted model cannot be
242
- * found in the library after upload.
248
+ * found in the library after upload; `PRECONDITION_FAILED`
249
+ * (`details.engineCode: "TOOL_ACTIVE"`) while the interactive furniture tool is
250
+ * active — finish or cancel it first.
243
251
  *
244
252
  * @examplePrompt Import this SketchUp model onto storey 1
245
253
  * @examplePrompt Bring in this OBJ file and place it at the origin
@@ -29,10 +29,14 @@ export interface PluginCoreModeSetResult {
29
29
  * Not to be confused with the viewport's 2D/3D camera mode
30
30
  * (`core.camera.setMode`) or saved presentation views (`presentation.views`).
31
31
  *
32
- * `set` covers `design`, `bim`, and `present` — in-page switches.
33
- * `program` opens in its own browser tab in the product, which a plugin worker
34
- * cannot do, so `set("program")` fails with `PRECONDITION_FAILED`; `get()`
35
- * still reports `"program"` for code running in the Program tab.
32
+ * `set` covers `design`, `bim`, and `present` — in-page switches — and
33
+ * `program`, which opens the Program tab (a paired browser window) through the
34
+ * same path as the top bar's Program button. Because the open happens outside a
35
+ * user gesture the browser may block the pop-up; the editor then shows its
36
+ * "Allow pop-up to continue" modal and the tab opens when the user confirms.
37
+ * `get()` reports `"program"` only for code running in the Program tab itself.
38
+ * Prefer {@linkcode PluginWorkspaceApi.openProgramMode} when you need to know
39
+ * the tab is ready before calling `program.spreadsheet.*`.
36
40
  */
37
41
  export abstract class PluginCoreModeApi {
38
42
  constructor() {}
@@ -74,16 +78,24 @@ export abstract class PluginCoreModeApi {
74
78
  * Switch the editor to another application mode — the same action as
75
79
  * clicking that tab in the top menu bar.
76
80
  *
77
- * Supported: `"design"`, `"bim"`, `"present"`. Switching to
78
- * `"program"` is rejected with `PRECONDITION_FAILED` (the Program surface
79
- * opens in its own browser tab in the product; a plugin cannot open one).
81
+ * `"design"`, `"bim"` and `"present"` switch in place. `"program"` opens
82
+ * the Program tab (a paired browser window) exactly as the top bar's Program
83
+ * button does, and resolves once that tab has connected to the editor (up to
84
+ * ~90s — the browser may block the pop-up, in which case the editor shows an
85
+ * "Allow pop-up to continue" modal and waits for the user to confirm).
86
+ * Idempotent when the Program tab is already open. Note `get()` in the model
87
+ * tab keeps reporting the model tab's own mode afterwards; the Program tab is
88
+ * a separate window.
80
89
  *
81
90
  * @param mode - Target mode token from {@linkcode PluginAppMode}
82
91
  * @returns The committed `{ mode }` after the switch.
92
+ * @throws `PRECONDITION_FAILED` for `"program"` when the user dismisses the
93
+ * pop-up modal or the tab does not connect within the timeout.
83
94
  *
84
95
  * @examplePrompt Switch to present mode
85
96
  * @examplePrompt Open BIM mode
86
97
  * @examplePrompt Go back to design mode
98
+ * @examplePrompt Open program mode
87
99
  *
88
100
  * # Example
89
101
  * ```ts
@@ -163,6 +163,40 @@ export abstract class PluginCoreTagsApi {
163
163
  componentId: ComponentHandle,
164
164
  ): PluginApiReturn<PluginCoreTagsGetTagsForComponentResult>
165
165
 
166
+ /**
167
+ * List the tags carried by many components in one call.
168
+ *
169
+ * The plural of {@linkcode PluginCoreTagsApi.listForComponent}: pass
170
+ * `componentIds` to read specific components (unknown ids are skipped), or
171
+ * omit it to read **every** taggable component (Mass/Floor space) in the
172
+ * project. Each entry carries the component id and its tags — one per tagged
173
+ * category, with the tag's `color` — so a plugin can color every space by a
174
+ * chosen category's tag in a single round-trip.
175
+ *
176
+ * @param componentIds - Optional `Component.id`s to read; omit for all spaces.
177
+ * @returns A {@linkcode PluginCoreTagsListForComponentsResult} with a
178
+ * `components` array, one entry per component (in input order when
179
+ * `componentIds` is given).
180
+ *
181
+ * @performance One round-trip for any number of components — use this instead of a `listForComponent` loop.
182
+ *
183
+ * @examplePrompt Get the tags of every space with their colors
184
+ * @examplePrompt List the tags on all rooms so I can color them by Occupancy
185
+ * @examplePrompt Which tag does each selected space carry?
186
+ *
187
+ * # Example
188
+ * ```ts
189
+ * const { components } = await snaptrude.core.tags.listForComponents()
190
+ * for (const c of components) {
191
+ * const occupancy = c.tags.find((t) => t.categoryName === "Occupancy")
192
+ * if (occupancy) paint(c.componentId, occupancy.color)
193
+ * }
194
+ * ```
195
+ */
196
+ public abstract listForComponents(
197
+ componentIds?: ComponentHandle[],
198
+ ): PluginApiReturn<PluginCoreTagsListForComponentsResult>
199
+
166
200
  /**
167
201
  * List the components carrying a given tag or category.
168
202
  *
@@ -588,6 +622,48 @@ export type PluginCoreTagsGetTagsForComponentResult = z.infer<
588
622
  typeof PluginCoreTagsGetTagsForComponentResult
589
623
  >
590
624
 
625
+ /**
626
+ * Arguments for {@linkcode PluginCoreTagsApi.listForComponents}.
627
+ *
628
+ * | Property | Type | Description |
629
+ * |---|---|---|
630
+ * | `componentIds` | `ComponentHandle[]?` | Components to read; omit for every taggable component |
631
+ */
632
+ export const PluginCoreTagsListForComponentsArgs = z.object({
633
+ componentIds: z.array(ComponentHandle).optional(),
634
+ })
635
+ export type PluginCoreTagsListForComponentsArgs = z.infer<
636
+ typeof PluginCoreTagsListForComponentsArgs
637
+ >
638
+
639
+ /**
640
+ * One component's tags, for {@linkcode PluginCoreTagsApi.listForComponents}.
641
+ *
642
+ * | Property | Type | Description |
643
+ * |---|---|---|
644
+ * | `componentId` | `ComponentHandle` | The component's id |
645
+ * | `tags` | {@linkcode PluginCoreComponentTag}`[]` | Its tags, one per tagged category (empty when none) |
646
+ */
647
+ export const PluginCoreComponentTags = z.object({
648
+ componentId: ComponentHandle,
649
+ tags: z.array(PluginCoreComponentTag),
650
+ })
651
+ export type PluginCoreComponentTags = z.infer<typeof PluginCoreComponentTags>
652
+
653
+ /**
654
+ * Result of {@linkcode PluginCoreTagsApi.listForComponents}.
655
+ *
656
+ * | Property | Type | Description |
657
+ * |---|---|---|
658
+ * | `components` | {@linkcode PluginCoreComponentTags}`[]` | One entry per component |
659
+ */
660
+ export const PluginCoreTagsListForComponentsResult = z.object({
661
+ components: z.array(PluginCoreComponentTags),
662
+ })
663
+ export type PluginCoreTagsListForComponentsResult = z.infer<
664
+ typeof PluginCoreTagsListForComponentsResult
665
+ >
666
+
591
667
  /**
592
668
  * Arguments for {@linkcode PluginCoreTagsApi.listComponents}. Provide exactly one
593
669
  * of `tagId`, `categoryId`. `untagged` is valid only with `categoryId`.
@@ -0,0 +1,186 @@
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
+ // wallRuns
14
+ // ---------------------------------------------------------------------------
15
+
16
+ /**
17
+ * One wall run to create via {@linkcode PluginDesignCreateApi.wallRuns} — the
18
+ * same inputs as {@linkcode PluginDesignCreateApi.walls}, one run per item.
19
+ *
20
+ * | Property | Type | Description |
21
+ * |---|---|---|
22
+ * | `profile` | {@linkcode ProfileHandle} | Ordered curve chain (wall centerlines) |
23
+ * | `height` | `number`? | Wall height (Snaptrude units, > 0; default engine default) |
24
+ * | `thickness` | `number`? | Wall thickness (Snaptrude units, > 0; default: `wallType`'s total layer thickness when given, else engine default) |
25
+ * | `wallType` | `string`? | Wall type name from `design.types.list("wall")` — layers/material/thickness defaults (default generic) |
26
+ * | `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) |
27
+ */
28
+ export const PluginCreateWallRunItem = z.object({
29
+ profile: ProfileHandle,
30
+ height: z.number().optional(),
31
+ thickness: z.number().optional(),
32
+ wallType: z.string().min(1).optional(),
33
+ storey: z.number().int().optional(),
34
+ })
35
+ export type PluginCreateWallRunItem = z.infer<typeof PluginCreateWallRunItem>
36
+
37
+ /** The `items` array of {@linkcode PluginDesignCreateApi.wallRuns} (1…1000). */
38
+ export const PluginCreateWallRunItems = z
39
+ .array(PluginCreateWallRunItem)
40
+ .min(1)
41
+ .max(PLUGIN_CREATE_BATCH_LIMIT)
42
+ export type PluginCreateWallRunItems = z.infer<typeof PluginCreateWallRunItems>
43
+
44
+ // ---------------------------------------------------------------------------
45
+ // floors
46
+ // ---------------------------------------------------------------------------
47
+
48
+ /**
49
+ * One floor to create via {@linkcode PluginDesignCreateApi.floors} — the same
50
+ * footprint-extrude inputs as {@linkcode PluginDesignCreateApi.floor}.
51
+ *
52
+ * | Property | Type | Description |
53
+ * |---|---|---|
54
+ * | `contour` | {@linkcode ContourHandle} | Footprint (outer profile + holes) |
55
+ * | `thickness` | `number` | Floor thickness (Snaptrude units, > 0) |
56
+ * | `position` | {@linkcode Vec3Handle}? | Offset from origin (default origin) |
57
+ */
58
+ export const PluginCreateFloorItem = z.object({
59
+ contour: ContourHandle,
60
+ thickness: z.number(),
61
+ position: Vec3Handle.optional(),
62
+ })
63
+ export type PluginCreateFloorItem = z.infer<typeof PluginCreateFloorItem>
64
+
65
+ /** The `items` array of {@linkcode PluginDesignCreateApi.floors} (1…1000). */
66
+ export const PluginCreateFloorItems = z
67
+ .array(PluginCreateFloorItem)
68
+ .min(1)
69
+ .max(PLUGIN_CREATE_BATCH_LIMIT)
70
+ export type PluginCreateFloorItems = z.infer<typeof PluginCreateFloorItems>
71
+
72
+ // ---------------------------------------------------------------------------
73
+ // doors / windows
74
+ // ---------------------------------------------------------------------------
75
+
76
+ /**
77
+ * One door to place via {@linkcode PluginDesignCreateApi.doors} — the same
78
+ * fields as a `"door"` {@linkcode PluginDesignCreateOpeningOptions}, so the
79
+ * size overrides singular {@linkcode PluginDesignCreateApi.door} lacks are
80
+ * available per item. `facing` and `hinge` are WORLD POINTS, not directions:
81
+ * `facing` on the side of the wall the door swings open to, `hinge` near the
82
+ * jamb it is hinged on. Rejects unknown fields.
83
+ *
84
+ * | Property | Type | Description |
85
+ * |---|---|---|
86
+ * | `catalogId` | `string` | Library id: team `_id` or general `fullName` |
87
+ * | `hostWall` | {@linkcode ComponentHandle} | The wall to host the door |
88
+ * | `position` | {@linkcode Vec3Handle} | World point projected onto the wall |
89
+ * | `facing` | {@linkcode Vec3Handle}? | World point on the side the door swings open to (default engine-chosen) |
90
+ * | `hinge` | {@linkcode Vec3Handle}? | World point near the jamb the door is hinged on (default the catalog item's authored side) |
91
+ * | `label` | `string`? | Instance name (optional) |
92
+ * | `width` | `number`? | Width override (Snaptrude units, > 0; default the catalog item's) |
93
+ * | `height` | `number`? | Height override (Snaptrude units, > 0; default the catalog item's) |
94
+ */
95
+ export const PluginCreateDoorItem = z
96
+ .object({ ...PluginOpeningBaseOptions })
97
+ .strict()
98
+ export type PluginCreateDoorItem = z.infer<typeof PluginCreateDoorItem>
99
+
100
+ /** The `items` array of {@linkcode PluginDesignCreateApi.doors} (1…1000). */
101
+ export const PluginCreateDoorItems = z
102
+ .array(PluginCreateDoorItem)
103
+ .min(1)
104
+ .max(PLUGIN_CREATE_BATCH_LIMIT)
105
+ export type PluginCreateDoorItems = z.infer<typeof PluginCreateDoorItems>
106
+
107
+ /**
108
+ * One window to place via {@linkcode PluginDesignCreateApi.windows} — the same
109
+ * fields as a `"window"` {@linkcode PluginDesignCreateOpeningOptions}.
110
+ * `sillHeight` is a nonnegative Snaptrude-unit distance from the host wall's
111
+ * base to the BOTTOM of the window, not to its center. `facing` and `hinge`
112
+ * are WORLD POINTS, not directions: `facing` on the side of the wall the
113
+ * window opens to, `hinge` near the jamb it is hinged on. Rejects unknown
114
+ * fields.
115
+ *
116
+ * | Property | Type | Description |
117
+ * |---|---|---|
118
+ * | `catalogId` | `string` | Library id: team `_id` or general `fullName` |
119
+ * | `hostWall` | {@linkcode ComponentHandle} | The wall to host the window |
120
+ * | `position` | {@linkcode Vec3Handle} | World point projected onto the wall |
121
+ * | `facing` | {@linkcode Vec3Handle}? | World point on the side the window opens to (default engine-chosen) |
122
+ * | `hinge` | {@linkcode Vec3Handle}? | World point near the jamb the window is hinged on (default the catalog item's authored side) |
123
+ * | `label` | `string`? | Instance name (optional) |
124
+ * | `width` | `number`? | Width override (Snaptrude units, > 0; default the catalog item's) |
125
+ * | `height` | `number`? | Height override (Snaptrude units, > 0; default the catalog item's) |
126
+ * | `sillHeight` | `number`? | Wall base to window bottom (Snaptrude units, ≥ 0; default the catalog item's) |
127
+ */
128
+ export const PluginCreateWindowItem = z
129
+ .object({
130
+ ...PluginOpeningBaseOptions,
131
+ sillHeight: z.number().finite().nonnegative().optional(),
132
+ })
133
+ .strict()
134
+ export type PluginCreateWindowItem = z.infer<typeof PluginCreateWindowItem>
135
+
136
+ /** The `items` array of {@linkcode PluginDesignCreateApi.windows} (1…1000). */
137
+ export const PluginCreateWindowItems = z
138
+ .array(PluginCreateWindowItem)
139
+ .min(1)
140
+ .max(PLUGIN_CREATE_BATCH_LIMIT)
141
+ export type PluginCreateWindowItems = z.infer<typeof PluginCreateWindowItems>
142
+
143
+ // ---------------------------------------------------------------------------
144
+ // furnitureItems
145
+ // ---------------------------------------------------------------------------
146
+
147
+ /**
148
+ * One furniture instance to place via
149
+ * {@linkcode PluginDesignCreateApi.furnitureItems} — the same inputs as
150
+ * {@linkcode PluginDesignCreateApi.furniture} minus `createNewSourceMesh`: in a
151
+ * batch the host owns source-mesh persistence (a source is recorded once per
152
+ * call, however many items reuse it).
153
+ *
154
+ * `position.y` is the REST elevation: the item is grounded so its bounding-box
155
+ * base sits exactly at `position.y` (the same surface-flush contract as
156
+ * interactive drag-drop) — pass the floor/storey elevation to stand furniture
157
+ * on it; never add half the item's height yourself.
158
+ *
159
+ * | Property | Type | Description |
160
+ * |---|---|---|
161
+ * | `catalogId` | `string` | Library id: team `_id` or general `fullName` |
162
+ * | `position` | {@linkcode Vec3Handle} | Absolute world placement point (`y` = rest elevation) |
163
+ * | `label` | `string`? | Instance name and readable label (default auto `${name}Ins${n}`) |
164
+ * | `angleInDegrees` | `number`? | Rotation about the vertical axis, in degrees (default unrotated) |
165
+ */
166
+ export const PluginCreateFurnitureItem = z.object({
167
+ catalogId: z.string().min(1),
168
+ position: Vec3Handle,
169
+ label: z.string().optional(),
170
+ angleInDegrees: z.number().optional(),
171
+ })
172
+ export type PluginCreateFurnitureItem = z.infer<
173
+ typeof PluginCreateFurnitureItem
174
+ >
175
+
176
+ /**
177
+ * The `items` array of {@linkcode PluginDesignCreateApi.furnitureItems}
178
+ * (1…1000).
179
+ */
180
+ export const PluginCreateFurnitureItems = z
181
+ .array(PluginCreateFurnitureItem)
182
+ .min(1)
183
+ .max(PLUGIN_CREATE_BATCH_LIMIT)
184
+ export type PluginCreateFurnitureItems = z.infer<
185
+ typeof PluginCreateFurnitureItems
186
+ >
@@ -0,0 +1,137 @@
1
+ import * as z from "zod"
2
+ import { ComponentHandle, CurveHandle, Vec3Handle } from "../../../handles"
3
+
4
+ // ---------------------------------------------------------------------------
5
+ // Shared grid style vocabulary
6
+ // ---------------------------------------------------------------------------
7
+
8
+ /**
9
+ * Grid line style (mirrors the engine `LineMode` values verbatim — the same
10
+ * vocabulary as {@linkcode PluginReferenceLineStyle}).
11
+ */
12
+ export const PluginGridLineStyle = z.enum(["SOLID", "DASHED", "DOT_DASH"])
13
+ export type PluginGridLineStyle = z.infer<typeof PluginGridLineStyle>
14
+
15
+ /**
16
+ * Optional visual styling shared by every grid creator (and reused as the
17
+ * patch shape by `design.update.grid`). All fields optional; engine defaults
18
+ * apply when omitted.
19
+ *
20
+ * | Property | Type | Description |
21
+ * |---|---|---|
22
+ * | `style` | {@linkcode PluginGridLineStyle}? | Line style |
23
+ * | `weight` | `number`? | Line weight (> 0) |
24
+ * | `color` | `string`? | Line color as a `#rrggbb` hex string |
25
+ * | `showStart` | `boolean`? | Show the start-end tag bubble |
26
+ * | `showEnd` | `boolean`? | Show the end-end tag bubble |
27
+ */
28
+ export const PluginGridStyleOptions = z.object({
29
+ style: PluginGridLineStyle.optional(),
30
+ weight: z.number().positive().optional(),
31
+ color: z
32
+ .string()
33
+ .regex(/^#[0-9a-fA-F]{6}$/, "color must be a #rrggbb hex string")
34
+ .optional(),
35
+ showStart: z.boolean().optional(),
36
+ showEnd: z.boolean().optional(),
37
+ })
38
+ export type PluginGridStyleOptions = z.infer<typeof PluginGridStyleOptions>
39
+
40
+ // ---------------------------------------------------------------------------
41
+ // create.grid — free rectangular grid
42
+ // ---------------------------------------------------------------------------
43
+
44
+ /**
45
+ * Arguments for {@linkcode PluginDesignCreateApi.grid}.
46
+ *
47
+ * | Property | Type | Description |
48
+ * |---|---|---|
49
+ * | `linesX` | `number` | Line count of the first family (integer ≥ 1) |
50
+ * | `linesY` | `number` | Line count of the second family (integer ≥ 1) |
51
+ * | `spacingX` | `number` | Spacing of the first family (Snaptrude units, > 0) |
52
+ * | `spacingY` | `number` | Spacing of the second family (Snaptrude units, > 0) |
53
+ * | `angle` | `number`? | Rotation in degrees, CCW about +Y (default 0) |
54
+ * | `center` | {@linkcode Vec3Handle}? | Placement centre; defaults to the native viewport-centre behavior |
55
+ * | …style | {@linkcode PluginGridStyleOptions} | Optional line styling |
56
+ */
57
+ export const PluginDesignCreateGridArgs = z
58
+ .object({
59
+ linesX: z.number().int().min(1),
60
+ linesY: z.number().int().min(1),
61
+ spacingX: z.number().positive().finite(),
62
+ spacingY: z.number().positive().finite(),
63
+ angle: z.number().finite().optional(),
64
+ center: Vec3Handle.optional(),
65
+ })
66
+ .merge(PluginGridStyleOptions)
67
+ export type PluginDesignCreateGridArgs = z.infer<typeof PluginDesignCreateGridArgs>
68
+
69
+ // ---------------------------------------------------------------------------
70
+ // create.gridFromCurve — single-curve grid
71
+ // ---------------------------------------------------------------------------
72
+
73
+ /**
74
+ * Arguments for {@linkcode PluginDesignCreateApi.gridFromCurve}.
75
+ *
76
+ * | Property | Type | Description |
77
+ * |---|---|---|
78
+ * | `curve` | {@linkcode CurveHandle} | The grid line's geometry — a line or arc (circles are rejected) |
79
+ * | `tag` | `string`? | The line's grid tag (defaults to the draw tool's next tag) |
80
+ * | …style | {@linkcode PluginGridStyleOptions} | Optional line styling |
81
+ */
82
+ export const PluginDesignCreateGridFromCurveArgs = z
83
+ .object({
84
+ curve: CurveHandle,
85
+ tag: z.string().min(1).optional(),
86
+ })
87
+ .merge(PluginGridStyleOptions)
88
+ export type PluginDesignCreateGridFromCurveArgs = z.infer<
89
+ typeof PluginDesignCreateGridFromCurveArgs
90
+ >
91
+
92
+ // ---------------------------------------------------------------------------
93
+ // create.gridsFromMasses — fitted grids
94
+ // ---------------------------------------------------------------------------
95
+
96
+ /**
97
+ * Arguments for {@linkcode PluginDesignCreateApi.gridsFromMasses}.
98
+ *
99
+ * | Property | Type | Description |
100
+ * |---|---|---|
101
+ * | `masses` | {@linkcode ComponentHandle}`[]` | Masses whose footprints seat the grids |
102
+ * | `spacingX` | `number` | First-family spacing (Snaptrude units, > 0) |
103
+ * | `spacingY` | `number` | Second-family spacing (Snaptrude units, > 0) |
104
+ * | …style | {@linkcode PluginGridStyleOptions} | Optional line styling |
105
+ */
106
+ export const PluginDesignCreateGridsFromMassesArgs = z
107
+ .object({
108
+ masses: z.array(ComponentHandle).min(1),
109
+ spacingX: z.number().positive().finite(),
110
+ spacingY: z.number().positive().finite(),
111
+ })
112
+ .merge(PluginGridStyleOptions)
113
+ export type PluginDesignCreateGridsFromMassesArgs = z.infer<
114
+ typeof PluginDesignCreateGridsFromMassesArgs
115
+ >
116
+
117
+ // ---------------------------------------------------------------------------
118
+ // create.columnsFromGrids — columns at line intersections
119
+ // ---------------------------------------------------------------------------
120
+
121
+ /**
122
+ * Arguments for {@linkcode PluginDesignCreateApi.columnsFromGrids}.
123
+ *
124
+ * | Property | Type | Description |
125
+ * |---|---|---|
126
+ * | `grids` | {@linkcode ComponentHandle}`[]` | Grid groups whose line intersections seat the columns |
127
+ * | `width` | `number` | Column width (Snaptrude units, > 0) |
128
+ * | `depth` | `number` | Column depth (Snaptrude units, > 0) |
129
+ */
130
+ export const PluginDesignCreateColumnsFromGridsArgs = z.object({
131
+ grids: z.array(ComponentHandle).min(1),
132
+ width: z.number().positive().finite(),
133
+ depth: z.number().positive().finite(),
134
+ })
135
+ export type PluginDesignCreateColumnsFromGridsArgs = z.infer<
136
+ typeof PluginDesignCreateColumnsFromGridsArgs
137
+ >