@snaptrude/plugin-core 0.6.0 → 0.7.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.
- package/CHANGELOG.md +29 -0
- package/api-manifest.json +206 -704
- package/dist/api/core/index.d.ts +5 -0
- package/dist/api/core/index.d.ts.map +1 -1
- package/dist/api/core/proposals/index.d.ts +475 -0
- package/dist/api/core/proposals/index.d.ts.map +1 -0
- package/dist/api/design/create/index.d.ts +209 -0
- package/dist/api/design/create/index.d.ts.map +1 -1
- package/dist/api/design/doors/index.d.ts +159 -0
- package/dist/api/design/doors/index.d.ts.map +1 -1
- package/dist/api/design/furniture/index.d.ts +34 -5
- package/dist/api/design/furniture/index.d.ts.map +1 -1
- package/dist/api/design/index.d.ts +83 -0
- package/dist/api/design/index.d.ts.map +1 -1
- package/dist/api/design/lock.d.ts +26 -0
- package/dist/api/design/lock.d.ts.map +1 -1
- package/dist/api/design/materials/index.d.ts +159 -2
- package/dist/api/design/materials/index.d.ts.map +1 -1
- package/dist/api/design/query/index.d.ts +115 -5
- package/dist/api/design/query/index.d.ts.map +1 -1
- package/dist/api/design/selection/index.d.ts +2 -2
- package/dist/api/design/transform/index.d.ts +83 -2
- package/dist/api/design/transform/index.d.ts.map +1 -1
- package/dist/api/design/update/index.d.ts +168 -0
- package/dist/api/design/update/index.d.ts.map +1 -1
- package/dist/api/design/windows/index.d.ts +113 -2
- package/dist/api/design/windows/index.d.ts.map +1 -1
- package/dist/api/entity/story.d.ts +101 -7
- package/dist/api/entity/story.d.ts.map +1 -1
- package/dist/api/presentation/aiInspiration.d.ts +1967 -7
- package/dist/api/presentation/aiInspiration.d.ts.map +1 -1
- package/dist/api/presentation/import.d.ts +49 -4
- package/dist/api/presentation/import.d.ts.map +1 -1
- package/dist/api/presentation/index.d.ts +2 -3
- package/dist/api/presentation/index.d.ts.map +1 -1
- package/dist/api/presentation/views.d.ts +210 -5
- package/dist/api/presentation/views.d.ts.map +1 -1
- package/dist/api/program/areas.d.ts +42 -12
- package/dist/api/program/areas.d.ts.map +1 -1
- package/dist/api/program/index.d.ts +3 -11
- package/dist/api/program/index.d.ts.map +1 -1
- package/dist/api/program/layout.d.ts +186 -11
- package/dist/api/program/layout.d.ts.map +1 -1
- package/dist/errors/codes.d.ts +34 -0
- package/dist/errors/codes.d.ts.map +1 -0
- package/dist/errors/envelope.d.ts +56 -0
- package/dist/errors/envelope.d.ts.map +1 -0
- package/dist/errors/index.d.ts +6 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/plugin-error.d.ts +69 -0
- package/dist/errors/plugin-error.d.ts.map +1 -0
- package/dist/host-utils.d.ts +4 -0
- package/dist/host-utils.d.ts.map +1 -1
- package/dist/index.cjs +1993 -1033
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1874 -1030
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/scripts/generate-manifest.test.mjs +77 -0
- package/src/api/core/index.ts +5 -0
- package/src/api/core/proposals/index.ts +509 -0
- package/src/api/design/create/index.ts +249 -0
- package/src/api/design/doors/index.ts +168 -0
- package/src/api/design/furniture/index.ts +36 -5
- package/src/api/design/index.ts +87 -0
- package/src/api/design/lock.ts +27 -0
- package/src/api/design/materials/index.ts +182 -2
- package/src/api/design/query/index.ts +81 -0
- package/src/api/design/transform/index.ts +74 -2
- package/src/api/design/update/index.ts +167 -0
- package/src/api/design/windows/index.ts +128 -2
- package/src/api/entity/story.ts +105 -7
- package/src/api/presentation/aiInspiration.ts +761 -7
- package/src/api/presentation/import.ts +45 -4
- package/src/api/presentation/index.ts +2 -3
- package/src/api/presentation/views.ts +221 -5
- package/src/api/program/areas.ts +34 -12
- package/src/api/program/index.ts +3 -11
- package/src/api/program/layout.ts +195 -11
- package/src/errors/codes.ts +136 -0
- package/src/errors/envelope.ts +75 -0
- package/src/errors/index.ts +21 -0
- package/src/errors/plugin-error.ts +134 -0
- package/src/host-utils.ts +4 -0
- package/src/index.ts +1 -0
- package/test/errors.test.mjs +184 -0
- package/api-manifest.full.json +0 -5600
|
@@ -2,14 +2,21 @@ import * as z from "zod"
|
|
|
2
2
|
import { PluginApiReturn } from "../../../types"
|
|
3
3
|
import { ComponentHandle } from "../../../handles"
|
|
4
4
|
import { PluginDesignChangeResult } from "../lock"
|
|
5
|
+
import { PluginObjectCatalogGroup, PluginObjectCatalogItem } from "../doors"
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* `snaptrude.design.windows` — window-specific reads. Creation lives at
|
|
8
9
|
* `design.create.window`; generic reads (`listWindows`/`getHost`/`getProperties`) live
|
|
9
10
|
* at `design.query.*`. Window targets are {@linkcode ComponentHandle}s.
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
12
|
+
* The **catalog** reads (`listCatalogGroups`/`listCatalog`/`getCatalogItem`/`exists`)
|
|
13
|
+
* browse the placeable window library — plain value records keyed by a library id
|
|
14
|
+
* (team `_id` or general `fullName`), NOT handles — and feed `design.create.window`.
|
|
15
|
+
* They are network-backed but carry no `Async` suffix (§6.6) and never throw
|
|
16
|
+
* (`[]`/`null`). The {@linkcode PluginObjectCatalogGroup} / {@linkcode PluginObjectCatalogItem}
|
|
17
|
+
* DTOs are shared with `design.doors` (defined there, re-exported here).
|
|
18
|
+
*
|
|
19
|
+
* `getSillHeight` (bounds-derived) and the command-wired `mirror` land in a later pass.
|
|
13
20
|
*/
|
|
14
21
|
export abstract class PluginDesignWindowsApi {
|
|
15
22
|
constructor() {}
|
|
@@ -148,6 +155,91 @@ export abstract class PluginDesignWindowsApi {
|
|
|
148
155
|
window: ComponentHandle,
|
|
149
156
|
height: number
|
|
150
157
|
): PluginApiReturn<PluginDesignChangeResult>
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* List the window catalog **groups** — the placement families (Fixed,
|
|
161
|
+
* Casement, Sliding, Folding, …), built-in groups merged with any
|
|
162
|
+
* team-custom types.
|
|
163
|
+
*
|
|
164
|
+
* @returns The groups as {@linkcode PluginObjectCatalogGroup}`[]` (`[]` when empty)
|
|
165
|
+
*
|
|
166
|
+
* @examplePrompt What kinds of windows can I place?
|
|
167
|
+
* @examplePrompt List the window groups in the catalog
|
|
168
|
+
* @examplePrompt Show me the window families available in this project
|
|
169
|
+
* @examplePrompt Which window types does this project support?
|
|
170
|
+
*
|
|
171
|
+
* # Example
|
|
172
|
+
* ```ts
|
|
173
|
+
* const groups = await snaptrude.design.windows.listCatalogGroups()
|
|
174
|
+
* for (const g of groups) console.log(g.dbType, g.label, g.source)
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
public abstract listCatalogGroups(): PluginApiReturn<PluginObjectCatalogGroup[]>
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* List the placeable window catalog (team + general libraries), optionally
|
|
181
|
+
* restricted to one group by its `dbType` token.
|
|
182
|
+
*
|
|
183
|
+
* @param group Restrict to one group's `dbType` (optional; e.g. `"casementDouble"`)
|
|
184
|
+
* @returns The catalog as {@linkcode PluginObjectCatalogItem}`[]` (`[]` when empty)
|
|
185
|
+
*
|
|
186
|
+
* @examplePrompt What windows can I place in this project?
|
|
187
|
+
* @examplePrompt List every window in the library
|
|
188
|
+
* @examplePrompt Show me the casement windows I can add
|
|
189
|
+
* @examplePrompt Browse the window catalog
|
|
190
|
+
*
|
|
191
|
+
* # Example
|
|
192
|
+
* ```ts
|
|
193
|
+
* const [group] = await snaptrude.design.windows.listCatalogGroups()
|
|
194
|
+
* const items = await snaptrude.design.windows.listCatalog(group?.dbType)
|
|
195
|
+
* for (const item of items) console.log(item.id, item.name, item.thumbnailUrl)
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
public abstract listCatalog(
|
|
199
|
+
group?: string
|
|
200
|
+
): PluginApiReturn<PluginObjectCatalogItem[]>
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Get a single window catalog item by its library id.
|
|
204
|
+
*
|
|
205
|
+
* @param id The catalog library id
|
|
206
|
+
* @returns The item, or `null` if no catalog item matches
|
|
207
|
+
*
|
|
208
|
+
* @examplePrompt Get the details of this window from the library
|
|
209
|
+
* @examplePrompt Look up the catalog entry for this window id
|
|
210
|
+
* @examplePrompt What is the cost of this window item?
|
|
211
|
+
* @examplePrompt Show me the family name of this window in the catalog
|
|
212
|
+
*
|
|
213
|
+
* # Example
|
|
214
|
+
* ```ts
|
|
215
|
+
* const [entry] = await snaptrude.design.windows.listCatalog()
|
|
216
|
+
* const item = await snaptrude.design.windows.getCatalogItem(entry.id)
|
|
217
|
+
* if (item) console.log(item.name, item.source, item.dbType)
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
public abstract getCatalogItem(
|
|
221
|
+
id: string
|
|
222
|
+
): PluginApiReturn<PluginObjectCatalogItem | null>
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Test whether a window catalog item exists for the given library id.
|
|
226
|
+
*
|
|
227
|
+
* @param id The catalog library id
|
|
228
|
+
* @returns `true` if it exists, otherwise `false`
|
|
229
|
+
*
|
|
230
|
+
* @examplePrompt Is this window still in the library?
|
|
231
|
+
* @examplePrompt Check whether a window catalog item with this id exists
|
|
232
|
+
* @examplePrompt Does my team library have this window?
|
|
233
|
+
* @examplePrompt Verify the window is available before placing it
|
|
234
|
+
*
|
|
235
|
+
* # Example
|
|
236
|
+
* ```ts
|
|
237
|
+
* const [entry] = await snaptrude.design.windows.listCatalog()
|
|
238
|
+
* const stillAvailable = await snaptrude.design.windows.exists(entry.id)
|
|
239
|
+
* console.log(stillAvailable ? "safe to place" : "removed from library")
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
242
|
+
public abstract exists(id: string): PluginApiReturn<boolean>
|
|
151
243
|
}
|
|
152
244
|
|
|
153
245
|
/**
|
|
@@ -205,3 +297,37 @@ export const PluginDesignWindowSetHeightArgs = z.object({
|
|
|
205
297
|
height: z.number(),
|
|
206
298
|
})
|
|
207
299
|
export type PluginDesignWindowSetHeightArgs = z.infer<typeof PluginDesignWindowSetHeightArgs>
|
|
300
|
+
|
|
301
|
+
// ---------------------------------------------------------------------------
|
|
302
|
+
// catalog (shared DTOs defined in ../doors, re-exported here for symmetry)
|
|
303
|
+
// ---------------------------------------------------------------------------
|
|
304
|
+
|
|
305
|
+
// Re-export the shared catalog DTOs imported at the top of this file.
|
|
306
|
+
export { PluginObjectCatalogGroup, PluginObjectCatalogItem }
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Arguments for {@linkcode PluginDesignWindowsApi.listCatalog}.
|
|
310
|
+
*
|
|
311
|
+
* | Property | Type | Description |
|
|
312
|
+
* |---|---|---|
|
|
313
|
+
* | `group` | `string`? | Restrict to one group's `dbType` token (optional) |
|
|
314
|
+
*/
|
|
315
|
+
export const PluginDesignWindowListCatalogArgs = z.object({
|
|
316
|
+
group: z.string().optional(),
|
|
317
|
+
})
|
|
318
|
+
export type PluginDesignWindowListCatalogArgs = z.infer<typeof PluginDesignWindowListCatalogArgs>
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Arguments for {@linkcode PluginDesignWindowsApi.getCatalogItem} / {@linkcode PluginDesignWindowsApi.exists}.
|
|
322
|
+
*
|
|
323
|
+
* | Property | Type | Description |
|
|
324
|
+
* |---|---|---|
|
|
325
|
+
* | `id` | `string` | The catalog library id |
|
|
326
|
+
*/
|
|
327
|
+
export const PluginDesignWindowGetCatalogItemArgs = z.object({
|
|
328
|
+
id: z.string(),
|
|
329
|
+
})
|
|
330
|
+
export type PluginDesignWindowGetCatalogItemArgs = z.infer<typeof PluginDesignWindowGetCatalogItemArgs>
|
|
331
|
+
|
|
332
|
+
export const PluginDesignWindowExistsArgs = PluginDesignWindowGetCatalogItemArgs
|
|
333
|
+
export type PluginDesignWindowExistsArgs = z.infer<typeof PluginDesignWindowExistsArgs>
|
package/src/api/entity/story.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as z from "zod"
|
|
2
2
|
import { PluginApiReturn } from "../../types"
|
|
3
|
+
import { ComponentHandle } from "../../handles"
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Story (floor/storey) management.
|
|
@@ -101,17 +102,25 @@ export abstract class PluginStoryApi {
|
|
|
101
102
|
): PluginApiReturn<PluginStoryCreateResult>
|
|
102
103
|
|
|
103
104
|
/**
|
|
104
|
-
* Update a story's height.
|
|
105
|
+
* Update a story's floor-to-floor height, cascading the full geometry change.
|
|
105
106
|
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
107
|
+
* This is the same operation as editing the height in the Stories panel: the
|
|
108
|
+
* walls, columns, and masses on the story are **stretched** to the new height,
|
|
109
|
+
* every story **above shifts up/down** by the delta so the stack stays
|
|
110
|
+
* contiguous, and coupled elements (staircases, parametric curtain walls,
|
|
111
|
+
* furniture offsets) are re-fitted. The whole cascade is committed as **one
|
|
112
|
+
* undo step**. Height-locked elements are left untouched.
|
|
108
113
|
*
|
|
109
114
|
* @param storyValue - Integer storey number
|
|
110
115
|
* identifying the story to update
|
|
111
|
-
* @param height - New height
|
|
112
|
-
* units
|
|
116
|
+
* @param height - New floor-to-floor height in
|
|
117
|
+
* Babylon units
|
|
113
118
|
* @returns A {@linkcode PluginStoryUpdateResult} with the updated `storyValue` and `height`
|
|
114
|
-
* @throws
|
|
119
|
+
* @throws `PRECONDITION_FAILED` if no story has the given value;
|
|
120
|
+
* `STORY_HEIGHT_REJECTED` if the engine rejects the height (e.g. out of
|
|
121
|
+
* range — the change silently reverts host-side and is surfaced as this
|
|
122
|
+
* error); `STORY_UPDATE_FAILED` if the story cannot be re-read after the
|
|
123
|
+
* update
|
|
115
124
|
*
|
|
116
125
|
* @examplePrompt Change the ground floor height to 3.5 metres
|
|
117
126
|
* @examplePrompt Make the second storey taller
|
|
@@ -120,7 +129,8 @@ export abstract class PluginStoryApi {
|
|
|
120
129
|
*
|
|
121
130
|
* # Example
|
|
122
131
|
* ```ts
|
|
123
|
-
* // Set ground floor height to 5 Babylon units
|
|
132
|
+
* // Set ground floor height to 5 Babylon units — walls stretch and the
|
|
133
|
+
* // floors above move up to match, all in a single undo step.
|
|
124
134
|
* const result = await snaptrude.entity.story.update(1, 5)
|
|
125
135
|
* ```
|
|
126
136
|
*/
|
|
@@ -128,6 +138,54 @@ export abstract class PluginStoryApi {
|
|
|
128
138
|
storyValue: number,
|
|
129
139
|
height: number,
|
|
130
140
|
): PluginApiReturn<PluginStoryUpdateResult>
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Duplicate a story into the adjacent level, up or down.
|
|
144
|
+
*
|
|
145
|
+
* By default the **whole story** is duplicated: every eligible element on the
|
|
146
|
+
* active story (walls, floors, roofs, masses, columns, beams, staircases,
|
|
147
|
+
* ceilings, parametric curtain walls, and furniture) is copied into the story
|
|
148
|
+
* one level `"up"` or `"down"`. Pass `options.components` to duplicate only a
|
|
149
|
+
* subset instead. The target story is **created automatically** if it does not
|
|
150
|
+
* yet exist, inheriting the source story's height.
|
|
151
|
+
*
|
|
152
|
+
* Copies are **instanced** by default (`unique: false`) — they share geometry
|
|
153
|
+
* with the source, so later edits propagate. Set `unique: true` for independent
|
|
154
|
+
* geometry. Doors and windows are never duplicated on their own; they ride along
|
|
155
|
+
* with their host wall. Locked, throw-away, and unsupported elements are skipped
|
|
156
|
+
* and counted in `skipped`. The whole operation is a single undo step.
|
|
157
|
+
*
|
|
158
|
+
* @param direction - `"up"` to duplicate into the story above, `"down"` for below
|
|
159
|
+
* @param options - `components` (restrict to a subset of the story's elements;
|
|
160
|
+
* omit for the whole story) and `unique` (default `false` = instanced copies;
|
|
161
|
+
* `true` = independent geometry)
|
|
162
|
+
* @returns A {@linkcode PluginStoryDuplicateResult} with the `sourceStory`, the
|
|
163
|
+
* `targetStories` the copies landed on, the `created` component handles, the
|
|
164
|
+
* `createdStoryValues` for any stories generated to receive them, and the
|
|
165
|
+
* `skipped` count of ineligible elements
|
|
166
|
+
* @throws `NO_ACTIVE_STRUCTURE` if there is no active structure to duplicate
|
|
167
|
+
* into; `NO_ELIGIBLE_ELEMENTS` if nothing on the source story (or in
|
|
168
|
+
* `options.components`) is duplicable; `HANDLE_INVALID` for a stale or
|
|
169
|
+
* foreign supplied handle; or if plugin writes are disabled
|
|
170
|
+
*
|
|
171
|
+
* @examplePrompt Duplicate this floor to the storey above
|
|
172
|
+
* @examplePrompt Copy the ground floor down into a new basement
|
|
173
|
+
* @examplePrompt Repeat this level upwards with its own independent geometry
|
|
174
|
+
* @examplePrompt Duplicate just the selected walls onto the next floor up
|
|
175
|
+
*
|
|
176
|
+
* # Example
|
|
177
|
+
* ```ts
|
|
178
|
+
* // Duplicate the whole active story one level up (instanced copies).
|
|
179
|
+
* const { targetStories, created, skipped } =
|
|
180
|
+
* await snaptrude.entity.story.duplicate("up")
|
|
181
|
+
* console.log(`Copied ${created.length} elements onto story ${targetStories}`)
|
|
182
|
+
* if (skipped) console.log(`${skipped} elements were skipped`)
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
public abstract duplicate(
|
|
186
|
+
direction: "up" | "down",
|
|
187
|
+
options?: { components?: ComponentHandle[]; unique?: boolean },
|
|
188
|
+
): PluginApiReturn<PluginStoryDuplicateResult>
|
|
131
189
|
}
|
|
132
190
|
|
|
133
191
|
/**
|
|
@@ -271,3 +329,43 @@ export const PluginStoryUpdateResult = z.object({
|
|
|
271
329
|
})
|
|
272
330
|
|
|
273
331
|
export type PluginStoryUpdateResult = z.infer<typeof PluginStoryUpdateResult>
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Arguments for {@linkcode PluginStoryApi.duplicate} (options flattened).
|
|
335
|
+
*
|
|
336
|
+
* | Property | Type | Description |
|
|
337
|
+
* |---|---|---|
|
|
338
|
+
* | `direction` | `'up' \| 'down'` | Which adjacent story to duplicate into |
|
|
339
|
+
* | `components` | {@linkcode ComponentHandle}`[]?` | Restrict to a subset; omit for the whole story |
|
|
340
|
+
* | `unique` | `boolean?` | `false` (default) = instanced copies; `true` = independent geometry |
|
|
341
|
+
*/
|
|
342
|
+
export const PluginStoryDuplicateArgs = z.object({
|
|
343
|
+
direction: z.enum(["up", "down"]),
|
|
344
|
+
components: z.array(ComponentHandle).optional(),
|
|
345
|
+
unique: z.boolean().optional(),
|
|
346
|
+
})
|
|
347
|
+
|
|
348
|
+
export type PluginStoryDuplicateArgs = z.infer<typeof PluginStoryDuplicateArgs>
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Result of {@linkcode PluginStoryApi.duplicate}.
|
|
352
|
+
*
|
|
353
|
+
* | Property | Type | Description |
|
|
354
|
+
* |---|---|---|
|
|
355
|
+
* | `sourceStory` | `number` | Storey value the copies were duplicated from |
|
|
356
|
+
* | `targetStories` | `number[]` | Storey values the copies landed on |
|
|
357
|
+
* | `created` | {@linkcode ComponentHandle}`[]` | Handles of the newly created components |
|
|
358
|
+
* | `createdStoryValues` | `number[]` | Storey values that were generated to receive the copies |
|
|
359
|
+
* | `skipped` | `number` | Count of ineligible elements that were skipped |
|
|
360
|
+
*/
|
|
361
|
+
export const PluginStoryDuplicateResult = z.object({
|
|
362
|
+
sourceStory: z.number(),
|
|
363
|
+
targetStories: z.array(z.number()),
|
|
364
|
+
created: z.array(ComponentHandle),
|
|
365
|
+
createdStoryValues: z.array(z.number()),
|
|
366
|
+
skipped: z.number(),
|
|
367
|
+
})
|
|
368
|
+
|
|
369
|
+
export type PluginStoryDuplicateResult = z.infer<
|
|
370
|
+
typeof PluginStoryDuplicateResult
|
|
371
|
+
>
|