@snaptrude/plugin-core 0.0.0-dev-20260708130115
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/AGENTS.md +227 -0
- package/CHANGELOG.md +119 -0
- package/CLAUDE.md +11 -0
- package/api-manifest.json +5004 -0
- package/dist/api/core/buildings.d.ts +427 -0
- package/dist/api/core/buildings.d.ts.map +1 -0
- package/dist/api/core/comment/index.d.ts +230 -0
- package/dist/api/core/comment/index.d.ts.map +1 -0
- package/dist/api/core/geom/create/index.d.ts +247 -0
- package/dist/api/core/geom/create/index.d.ts.map +1 -0
- package/dist/api/core/geom/delete/index.d.ts +72 -0
- package/dist/api/core/geom/delete/index.d.ts.map +1 -0
- package/dist/api/core/geom/index.d.ts +33 -0
- package/dist/api/core/geom/index.d.ts.map +1 -0
- package/dist/api/core/geom/query/arc.d.ts +169 -0
- package/dist/api/core/geom/query/arc.d.ts.map +1 -0
- package/dist/api/core/geom/query/brep.d.ts +402 -0
- package/dist/api/core/geom/query/brep.d.ts.map +1 -0
- package/dist/api/core/geom/query/circle.d.ts +378 -0
- package/dist/api/core/geom/query/circle.d.ts.map +1 -0
- package/dist/api/core/geom/query/contour.d.ts +450 -0
- package/dist/api/core/geom/query/contour.d.ts.map +1 -0
- package/dist/api/core/geom/query/curve.d.ts +918 -0
- package/dist/api/core/geom/query/curve.d.ts.map +1 -0
- package/dist/api/core/geom/query/edge.d.ts +128 -0
- package/dist/api/core/geom/query/edge.d.ts.map +1 -0
- package/dist/api/core/geom/query/face.d.ts +363 -0
- package/dist/api/core/geom/query/face.d.ts.map +1 -0
- package/dist/api/core/geom/query/halfedge.d.ts +206 -0
- package/dist/api/core/geom/query/halfedge.d.ts.map +1 -0
- package/dist/api/core/geom/query/index.d.ts +61 -0
- package/dist/api/core/geom/query/index.d.ts.map +1 -0
- package/dist/api/core/geom/query/profile.d.ts +410 -0
- package/dist/api/core/geom/query/profile.d.ts.map +1 -0
- package/dist/api/core/geom/query/vertex.d.ts +187 -0
- package/dist/api/core/geom/query/vertex.d.ts.map +1 -0
- package/dist/api/core/geom/update/contour.d.ts +272 -0
- package/dist/api/core/geom/update/contour.d.ts.map +1 -0
- package/dist/api/core/geom/update/curve.d.ts +180 -0
- package/dist/api/core/geom/update/curve.d.ts.map +1 -0
- package/dist/api/core/geom/update/index.d.ts +27 -0
- package/dist/api/core/geom/update/index.d.ts.map +1 -0
- package/dist/api/core/geom/update/profile.d.ts +329 -0
- package/dist/api/core/geom/update/profile.d.ts.map +1 -0
- package/dist/api/core/groups.d.ts +485 -0
- package/dist/api/core/groups.d.ts.map +1 -0
- package/dist/api/core/history/index.d.ts +78 -0
- package/dist/api/core/history/index.d.ts.map +1 -0
- package/dist/api/core/index.d.ts +63 -0
- package/dist/api/core/index.d.ts.map +1 -0
- package/dist/api/core/layers.d.ts +402 -0
- package/dist/api/core/layers.d.ts.map +1 -0
- package/dist/api/core/math/index.d.ts +18 -0
- package/dist/api/core/math/index.d.ts.map +1 -0
- package/dist/api/core/math/quat.d.ts +170 -0
- package/dist/api/core/math/quat.d.ts.map +1 -0
- package/dist/api/core/math/vec3.d.ts +174 -0
- package/dist/api/core/math/vec3.d.ts.map +1 -0
- package/dist/api/core/project/index.d.ts +399 -0
- package/dist/api/core/project/index.d.ts.map +1 -0
- package/dist/api/core/tags.d.ts +755 -0
- package/dist/api/core/tags.d.ts.map +1 -0
- package/dist/api/core/units/index.d.ts +175 -0
- package/dist/api/core/units/index.d.ts.map +1 -0
- package/dist/api/core/zoom/index.d.ts +45 -0
- package/dist/api/core/zoom/index.d.ts.map +1 -0
- package/dist/api/design/boolean/index.d.ts +168 -0
- package/dist/api/design/boolean/index.d.ts.map +1 -0
- package/dist/api/design/create/index.d.ts +828 -0
- package/dist/api/design/create/index.d.ts.map +1 -0
- package/dist/api/design/delete/index.d.ts +63 -0
- package/dist/api/design/delete/index.d.ts.map +1 -0
- package/dist/api/design/doors/index.d.ts +268 -0
- package/dist/api/design/doors/index.d.ts.map +1 -0
- package/dist/api/design/edit/index.d.ts +49 -0
- package/dist/api/design/edit/index.d.ts.map +1 -0
- package/dist/api/design/erase/index.d.ts +160 -0
- package/dist/api/design/erase/index.d.ts.map +1 -0
- package/dist/api/design/furniture/index.d.ts +123 -0
- package/dist/api/design/furniture/index.d.ts.map +1 -0
- package/dist/api/design/index.d.ts +153 -0
- package/dist/api/design/index.d.ts.map +1 -0
- package/dist/api/design/lock.d.ts +41 -0
- package/dist/api/design/lock.d.ts.map +1 -0
- package/dist/api/design/materials/index.d.ts +297 -0
- package/dist/api/design/materials/index.d.ts.map +1 -0
- package/dist/api/design/query/geometry/index.d.ts +140 -0
- package/dist/api/design/query/geometry/index.d.ts.map +1 -0
- package/dist/api/design/query/index.d.ts +1011 -0
- package/dist/api/design/query/index.d.ts.map +1 -0
- package/dist/api/design/query/spaces.d.ts +221 -0
- package/dist/api/design/query/spaces.d.ts.map +1 -0
- package/dist/api/design/selection/index.d.ts +138 -0
- package/dist/api/design/selection/index.d.ts.map +1 -0
- package/dist/api/design/shared.d.ts +38 -0
- package/dist/api/design/shared.d.ts.map +1 -0
- package/dist/api/design/transform/index.d.ts +87 -0
- package/dist/api/design/transform/index.d.ts.map +1 -0
- package/dist/api/design/update/index.d.ts +178 -0
- package/dist/api/design/update/index.d.ts.map +1 -0
- package/dist/api/design/windows/index.d.ts +189 -0
- package/dist/api/design/windows/index.d.ts.map +1 -0
- package/dist/api/entity/buildableEnvelope.d.ts +261 -0
- package/dist/api/entity/buildableEnvelope.d.ts.map +1 -0
- package/dist/api/entity/department.d.ts +1 -0
- package/dist/api/entity/department.d.ts.map +1 -0
- package/dist/api/entity/index.d.ts +28 -0
- package/dist/api/entity/index.d.ts.map +1 -0
- package/dist/api/entity/referenceLine.d.ts +202 -0
- package/dist/api/entity/referenceLine.d.ts.map +1 -0
- package/dist/api/entity/space.d.ts +846 -0
- package/dist/api/entity/space.d.ts.map +1 -0
- package/dist/api/entity/story.d.ts +249 -0
- package/dist/api/entity/story.d.ts.map +1 -0
- package/dist/api/index.d.ts +35 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/presentation/aiInspiration.d.ts +2400 -0
- package/dist/api/presentation/aiInspiration.d.ts.map +1 -0
- package/dist/api/presentation/diagrams.d.ts +81 -0
- package/dist/api/presentation/diagrams.d.ts.map +1 -0
- package/dist/api/presentation/import.d.ts +113 -0
- package/dist/api/presentation/import.d.ts.map +1 -0
- package/dist/api/presentation/index.d.ts +45 -0
- package/dist/api/presentation/index.d.ts.map +1 -0
- package/dist/api/presentation/sheets.d.ts +176 -0
- package/dist/api/presentation/sheets.d.ts.map +1 -0
- package/dist/api/presentation/views.d.ts +296 -0
- package/dist/api/presentation/views.d.ts.map +1 -0
- package/dist/api/program/adjacency.d.ts +155 -0
- package/dist/api/program/adjacency.d.ts.map +1 -0
- package/dist/api/program/areas.d.ts +360 -0
- package/dist/api/program/areas.d.ts.map +1 -0
- package/dist/api/program/classification.d.ts +135 -0
- package/dist/api/program/classification.d.ts.map +1 -0
- package/dist/api/program/cores.d.ts +174 -0
- package/dist/api/program/cores.d.ts.map +1 -0
- package/dist/api/program/departments.d.ts +431 -0
- package/dist/api/program/departments.d.ts.map +1 -0
- package/dist/api/program/index.d.ts +69 -0
- package/dist/api/program/index.d.ts.map +1 -0
- package/dist/api/program/layout.d.ts +63 -0
- package/dist/api/program/layout.d.ts.map +1 -0
- package/dist/api/program/metrics.d.ts +108 -0
- package/dist/api/program/metrics.d.ts.map +1 -0
- package/dist/api/program/site.d.ts +367 -0
- package/dist/api/program/site.d.ts.map +1 -0
- package/dist/api/program/spreadsheet.d.ts +2041 -0
- package/dist/api/program/spreadsheet.d.ts.map +1 -0
- package/dist/handles.d.ts +138 -0
- package/dist/handles.d.ts.map +1 -0
- package/dist/host-utils.d.ts +43 -0
- package/dist/host-utils.d.ts.map +1 -0
- package/dist/index.cjs +4597 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3870 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +39 -0
- package/scripts/generate-manifest.mjs +193 -0
- package/scripts/generate-manifest.test.mjs +193 -0
- package/src/api/core/buildings.ts +485 -0
- package/src/api/core/comment/index.ts +258 -0
- package/src/api/core/geom/create/index.ts +293 -0
- package/src/api/core/geom/delete/index.ts +78 -0
- package/src/api/core/geom/index.ts +35 -0
- package/src/api/core/geom/query/arc.ts +169 -0
- package/src/api/core/geom/query/brep.ts +444 -0
- package/src/api/core/geom/query/circle.ts +404 -0
- package/src/api/core/geom/query/contour.ts +540 -0
- package/src/api/core/geom/query/curve.ts +1078 -0
- package/src/api/core/geom/query/edge.ts +130 -0
- package/src/api/core/geom/query/face.ts +403 -0
- package/src/api/core/geom/query/halfedge.ts +210 -0
- package/src/api/core/geom/query/index.ts +63 -0
- package/src/api/core/geom/query/profile.ts +473 -0
- package/src/api/core/geom/query/vertex.ts +205 -0
- package/src/api/core/geom/update/contour.ts +315 -0
- package/src/api/core/geom/update/curve.ts +209 -0
- package/src/api/core/geom/update/index.ts +29 -0
- package/src/api/core/geom/update/profile.ts +377 -0
- package/src/api/core/groups.ts +521 -0
- package/src/api/core/history/index.ts +84 -0
- package/src/api/core/index.ts +65 -0
- package/src/api/core/layers.ts +333 -0
- package/src/api/core/math/index.ts +20 -0
- package/src/api/core/math/quat.ts +172 -0
- package/src/api/core/math/vec3.ts +179 -0
- package/src/api/core/project/index.ts +418 -0
- package/src/api/core/tags.ts +808 -0
- package/src/api/core/units/index.ts +164 -0
- package/src/api/core/zoom/index.ts +47 -0
- package/src/api/design/boolean/index.ts +179 -0
- package/src/api/design/create/index.ts +886 -0
- package/src/api/design/delete/index.ts +67 -0
- package/src/api/design/doors/index.ts +285 -0
- package/src/api/design/edit/index.ts +54 -0
- package/src/api/design/erase/index.ts +151 -0
- package/src/api/design/furniture/index.ts +130 -0
- package/src/api/design/index.ts +162 -0
- package/src/api/design/lock.ts +42 -0
- package/src/api/design/materials/index.ts +301 -0
- package/src/api/design/query/geometry/index.ts +166 -0
- package/src/api/design/query/index.ts +937 -0
- package/src/api/design/query/spaces.ts +132 -0
- package/src/api/design/selection/index.ts +144 -0
- package/src/api/design/shared.ts +40 -0
- package/src/api/design/transform/index.ts +93 -0
- package/src/api/design/update/index.ts +117 -0
- package/src/api/design/windows/index.ts +207 -0
- package/src/api/entity/buildableEnvelope.ts +318 -0
- package/src/api/entity/department.ts +0 -0
- package/src/api/entity/index.ts +30 -0
- package/src/api/entity/referenceLine.ts +227 -0
- package/src/api/entity/space.ts +612 -0
- package/src/api/entity/story.ts +273 -0
- package/src/api/index.ts +37 -0
- package/src/api/presentation/aiInspiration.ts +1116 -0
- package/src/api/presentation/diagrams.ts +84 -0
- package/src/api/presentation/import.ts +112 -0
- package/src/api/presentation/index.ts +47 -0
- package/src/api/presentation/sheets.ts +198 -0
- package/src/api/presentation/views.ts +303 -0
- package/src/api/program/adjacency.ts +164 -0
- package/src/api/program/areas.ts +335 -0
- package/src/api/program/classification.ts +138 -0
- package/src/api/program/cores.ts +171 -0
- package/src/api/program/departments.ts +465 -0
- package/src/api/program/index.ts +71 -0
- package/src/api/program/layout.ts +68 -0
- package/src/api/program/metrics.ts +120 -0
- package/src/api/program/site.ts +326 -0
- package/src/api/program/spreadsheet.ts +2075 -0
- package/src/handles.ts +148 -0
- package/src/host-utils.ts +64 -0
- package/src/index.ts +4 -0
- package/src/types.ts +16 -0
- package/tsconfig.json +17 -0
- package/tsup.config.ts +12 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Presentation views — read the saved 2D/3D views used to prepare presentations.
|
|
6
|
+
*
|
|
7
|
+
* A **view** is a saved camera/plan: a sheet-ready 2D plan or a saved 3D view.
|
|
8
|
+
* A plugin can list and read views, capture them to images, activate one (move
|
|
9
|
+
* the camera to it), and save the current camera as a new view.
|
|
10
|
+
*
|
|
11
|
+
* `list`/`get`/`getActive`/`capture` are reads; `setActive`/`create` are writes
|
|
12
|
+
* (a view is a camera bookmark — not geometry). Members typed optional (`?`) are
|
|
13
|
+
* authored ahead of the host: declared for plugins/codegen but not yet on the
|
|
14
|
+
* live discovery surface until the host lands them.
|
|
15
|
+
*
|
|
16
|
+
* Accessed via `snaptrude.presentation.views`.
|
|
17
|
+
*/
|
|
18
|
+
export abstract class PluginPresentationViewsApi {
|
|
19
|
+
constructor() {}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* List the saved views in the active project.
|
|
23
|
+
*
|
|
24
|
+
* @returns A {@linkcode PluginPresentationViewsListResult} with a `views` array
|
|
25
|
+
* of 2D and 3D views (empty when the project has none).
|
|
26
|
+
*
|
|
27
|
+
* @examplePrompt List all the saved views
|
|
28
|
+
* @examplePrompt What 2D and 3D views are in this project?
|
|
29
|
+
* @examplePrompt Which view is currently active?
|
|
30
|
+
* @examplePrompt Get the names of every presentation view
|
|
31
|
+
* @examplePrompt Show me the 3D views I can put on a sheet
|
|
32
|
+
*
|
|
33
|
+
* # Example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const { views } = await snaptrude.presentation.views.list()
|
|
36
|
+
* const active = views.find((v) => v.isActive)
|
|
37
|
+
* const plans = views.filter((v) => v.type === "2d")
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
public abstract list(): PluginApiReturn<PluginPresentationViewsListResult>
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get a single saved view by id.
|
|
44
|
+
*
|
|
45
|
+
* @param viewId - The id of the view to read.
|
|
46
|
+
* @returns The matching {@linkcode PluginPresentationView}, or `null` if no view
|
|
47
|
+
* has that id.
|
|
48
|
+
*
|
|
49
|
+
* @examplePrompt Get the view with id view_12345
|
|
50
|
+
* @examplePrompt Find the saved view called Ground Floor Plan
|
|
51
|
+
* @examplePrompt Look up a presentation view by its id
|
|
52
|
+
*
|
|
53
|
+
* # Example
|
|
54
|
+
* ```ts
|
|
55
|
+
* const view = await snaptrude.presentation.views.get("view_123")
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
public abstract get(
|
|
59
|
+
viewId: string,
|
|
60
|
+
): PluginApiReturn<PluginPresentationViewsGetResult>
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Get the currently active view.
|
|
64
|
+
*
|
|
65
|
+
* @returns The active {@linkcode PluginPresentationView}, or `null` if none is
|
|
66
|
+
* active.
|
|
67
|
+
*
|
|
68
|
+
* @examplePrompt Which view is active right now?
|
|
69
|
+
* @examplePrompt Get the current view
|
|
70
|
+
* @examplePrompt What view am I looking at?
|
|
71
|
+
*
|
|
72
|
+
* # Example
|
|
73
|
+
* ```ts
|
|
74
|
+
* const active = await snaptrude.presentation.views.getActive()
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
public abstract getActive(): PluginApiReturn<PluginPresentationViewsGetResult>
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Capture a screenshot of a view as a base64 image.
|
|
81
|
+
*
|
|
82
|
+
* Captures the **current** viewport by default; pass `viewId` to capture a
|
|
83
|
+
* specific saved view (which briefly applies that view to the scene). Use
|
|
84
|
+
* `format`/`resolution` to control the output.
|
|
85
|
+
*
|
|
86
|
+
* @param options - All optional: `viewId` (capture this saved view; omit for the
|
|
87
|
+
* current viewport), `format` (default `"png"`), `resolution` (e.g. `"1280x720"`).
|
|
88
|
+
* @returns A {@linkcode PluginPresentationViewsCaptureResult} with the base64
|
|
89
|
+
* `image` data URL.
|
|
90
|
+
* @throws If a given `viewId` does not exist.
|
|
91
|
+
*
|
|
92
|
+
* @examplePrompt Take a screenshot of the current view
|
|
93
|
+
* @examplePrompt Capture this view as a PNG
|
|
94
|
+
* @examplePrompt Render the Site Plan view to an image
|
|
95
|
+
* @examplePrompt Export a high-res image of what I'm looking at
|
|
96
|
+
*
|
|
97
|
+
* # Example
|
|
98
|
+
* ```ts
|
|
99
|
+
* const { image } = await snaptrude.presentation.views.capture({ format: "png" })
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
public abstract capture(options?: {
|
|
103
|
+
viewId?: string
|
|
104
|
+
format?: "png" | "jpeg"
|
|
105
|
+
resolution?: string
|
|
106
|
+
}): PluginApiReturn<PluginPresentationViewsCaptureResult>
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Activate a saved view — move the camera to it and restore its scene state.
|
|
110
|
+
*
|
|
111
|
+
* Applies the view's camera, visibility, and storey state to the live scene.
|
|
112
|
+
* Paired with {@linkcode PluginPresentationViewsApi.getActive}.
|
|
113
|
+
*
|
|
114
|
+
* @param viewId - The id of the view to activate.
|
|
115
|
+
* @returns The id of the now-active view.
|
|
116
|
+
* @throws If no view has the given id.
|
|
117
|
+
*
|
|
118
|
+
* @examplePrompt Switch to the Ground Floor plan view
|
|
119
|
+
* @examplePrompt Make the 3D view active
|
|
120
|
+
* @examplePrompt Go to the view named Entrance
|
|
121
|
+
* @examplePrompt Load the site plan view
|
|
122
|
+
*
|
|
123
|
+
* # Example
|
|
124
|
+
* ```ts
|
|
125
|
+
* await snaptrude.presentation.views.setActive("view_123")
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
public abstract setActive(
|
|
129
|
+
viewId: string,
|
|
130
|
+
): PluginApiReturn<PluginPresentationViewsSetActiveResult>
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Save the current camera/scene state as a new named view.
|
|
134
|
+
*
|
|
135
|
+
* Creates a camera bookmark (not geometry) from where the camera is now.
|
|
136
|
+
*
|
|
137
|
+
* @param name - Name for the new view (a default is used when omitted).
|
|
138
|
+
* @param options - Optional `kind`: what kind of view to save (default `"view"`).
|
|
139
|
+
* @returns The newly created {@linkcode PluginPresentationView}.
|
|
140
|
+
* @throws If the view could not be saved.
|
|
141
|
+
*
|
|
142
|
+
* @examplePrompt Save the current view as Lobby Perspective
|
|
143
|
+
* @examplePrompt Create a new saved view from where I'm looking
|
|
144
|
+
* @examplePrompt Bookmark this camera angle
|
|
145
|
+
* @examplePrompt Save the current 2D plan as a view
|
|
146
|
+
*
|
|
147
|
+
* # Example
|
|
148
|
+
* ```ts
|
|
149
|
+
* const view = await snaptrude.presentation.views.create("Lobby")
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
public abstract create(
|
|
153
|
+
name?: string,
|
|
154
|
+
options?: { kind?: "view" | "sitePlan" },
|
|
155
|
+
): PluginApiReturn<PluginPresentationViewsCreateResult>
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* The kind of a saved view: a 2D plan view or a 3D view.
|
|
160
|
+
*/
|
|
161
|
+
export const PluginPresentationViewType = z.enum(["2d", "3d"])
|
|
162
|
+
export type PluginPresentationViewType = z.infer<
|
|
163
|
+
typeof PluginPresentationViewType
|
|
164
|
+
>
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* A saved presentation view.
|
|
168
|
+
*
|
|
169
|
+
* | Property | Type | Description |
|
|
170
|
+
* |---|---|---|
|
|
171
|
+
* | `id` | `string` | Unique view id |
|
|
172
|
+
* | `name` | `string` | Display name |
|
|
173
|
+
* | `type` | `"2d" \| "3d"` | Whether this is a 2D plan view or a 3D view |
|
|
174
|
+
* | `isActive` | `boolean` | Whether this view is the currently active view |
|
|
175
|
+
*/
|
|
176
|
+
export const PluginPresentationView = z.object({
|
|
177
|
+
id: z.string(),
|
|
178
|
+
name: z.string(),
|
|
179
|
+
type: PluginPresentationViewType,
|
|
180
|
+
isActive: z.boolean(),
|
|
181
|
+
})
|
|
182
|
+
export type PluginPresentationView = z.infer<typeof PluginPresentationView>
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Result of {@linkcode PluginPresentationViewsApi.list}.
|
|
186
|
+
*
|
|
187
|
+
* | Property | Type | Description |
|
|
188
|
+
* |---|---|---|
|
|
189
|
+
* | `views` | {@linkcode PluginPresentationView}`[]` | All saved views in the project |
|
|
190
|
+
*/
|
|
191
|
+
export const PluginPresentationViewsListResult = z.object({
|
|
192
|
+
views: z.array(PluginPresentationView),
|
|
193
|
+
})
|
|
194
|
+
export type PluginPresentationViewsListResult = z.infer<
|
|
195
|
+
typeof PluginPresentationViewsListResult
|
|
196
|
+
>
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Arguments for {@linkcode PluginPresentationViewsApi.get}.
|
|
200
|
+
*
|
|
201
|
+
* | Property | Type | Description |
|
|
202
|
+
* |---|---|---|
|
|
203
|
+
* | `id` | `string` | The id of the view to read |
|
|
204
|
+
*/
|
|
205
|
+
export const PluginPresentationViewsGetArgs = z.object({
|
|
206
|
+
id: z.string(),
|
|
207
|
+
})
|
|
208
|
+
export type PluginPresentationViewsGetArgs = z.infer<
|
|
209
|
+
typeof PluginPresentationViewsGetArgs
|
|
210
|
+
>
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Result of {@linkcode PluginPresentationViewsApi.get} and
|
|
214
|
+
* {@linkcode PluginPresentationViewsApi.getActive} — the view, or `null` when
|
|
215
|
+
* there is no match / no active view.
|
|
216
|
+
*/
|
|
217
|
+
export const PluginPresentationViewsGetResult =
|
|
218
|
+
PluginPresentationView.nullable()
|
|
219
|
+
export type PluginPresentationViewsGetResult = z.infer<
|
|
220
|
+
typeof PluginPresentationViewsGetResult
|
|
221
|
+
>
|
|
222
|
+
|
|
223
|
+
/** Image format for {@linkcode PluginPresentationViewsApi.capture}. */
|
|
224
|
+
export const PluginPresentationImageFormat = z.enum(["png", "jpeg"])
|
|
225
|
+
export type PluginPresentationImageFormat = z.infer<
|
|
226
|
+
typeof PluginPresentationImageFormat
|
|
227
|
+
>
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Arguments for {@linkcode PluginPresentationViewsApi.capture}. All optional.
|
|
231
|
+
*
|
|
232
|
+
* | Property | Type | Description |
|
|
233
|
+
* |---|---|---|
|
|
234
|
+
* | `viewId` | `string \| undefined` | Capture this saved view; omit to capture the current viewport |
|
|
235
|
+
* | `format` | `"png" \| "jpeg" \| undefined` | Output image format (default `"png"`) |
|
|
236
|
+
* | `resolution` | `string \| undefined` | Optional resolution hint (e.g. `"1280x720"`) |
|
|
237
|
+
*/
|
|
238
|
+
export const PluginPresentationViewsCaptureArgs = z.object({
|
|
239
|
+
viewId: z.string().optional(),
|
|
240
|
+
format: PluginPresentationImageFormat.optional(),
|
|
241
|
+
resolution: z.string().optional(),
|
|
242
|
+
})
|
|
243
|
+
export type PluginPresentationViewsCaptureArgs = z.infer<
|
|
244
|
+
typeof PluginPresentationViewsCaptureArgs
|
|
245
|
+
>
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Result of {@linkcode PluginPresentationViewsApi.capture}.
|
|
249
|
+
*
|
|
250
|
+
* | Property | Type | Description |
|
|
251
|
+
* |---|---|---|
|
|
252
|
+
* | `image` | `string` | The captured image as a base64 data URL |
|
|
253
|
+
*/
|
|
254
|
+
export const PluginPresentationViewsCaptureResult = z.object({
|
|
255
|
+
image: z.string(),
|
|
256
|
+
})
|
|
257
|
+
export type PluginPresentationViewsCaptureResult = z.infer<
|
|
258
|
+
typeof PluginPresentationViewsCaptureResult
|
|
259
|
+
>
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Arguments for {@linkcode PluginPresentationViewsApi.setActive}.
|
|
263
|
+
*
|
|
264
|
+
* | Property | Type | Description |
|
|
265
|
+
* |---|---|---|
|
|
266
|
+
* | `id` | `string` | The id of the view to activate |
|
|
267
|
+
*/
|
|
268
|
+
export const PluginPresentationViewsSetActiveArgs = z.object({
|
|
269
|
+
id: z.string(),
|
|
270
|
+
})
|
|
271
|
+
export type PluginPresentationViewsSetActiveArgs = z.infer<
|
|
272
|
+
typeof PluginPresentationViewsSetActiveArgs
|
|
273
|
+
>
|
|
274
|
+
|
|
275
|
+
/** Result of {@linkcode PluginPresentationViewsApi.setActive} — the active view's id. */
|
|
276
|
+
export const PluginPresentationViewsSetActiveResult = z.object({
|
|
277
|
+
id: z.string(),
|
|
278
|
+
})
|
|
279
|
+
export type PluginPresentationViewsSetActiveResult = z.infer<
|
|
280
|
+
typeof PluginPresentationViewsSetActiveResult
|
|
281
|
+
>
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Arguments for {@linkcode PluginPresentationViewsApi.create}. All optional.
|
|
285
|
+
*
|
|
286
|
+
* | Property | Type | Description |
|
|
287
|
+
* |---|---|---|
|
|
288
|
+
* | `name` | `string \| undefined` | Name for the new view (a default is used when omitted) |
|
|
289
|
+
* | `kind` | `"view" \| "sitePlan" \| undefined` | What kind of view to save (default `"view"`). `"plan"` is not offered — the host cannot create a plan view without a `planId` this API does not carry. |
|
|
290
|
+
*/
|
|
291
|
+
export const PluginPresentationViewsCreateArgs = z.object({
|
|
292
|
+
name: z.string().optional(),
|
|
293
|
+
kind: z.enum(["view", "sitePlan"]).optional(),
|
|
294
|
+
})
|
|
295
|
+
export type PluginPresentationViewsCreateArgs = z.infer<
|
|
296
|
+
typeof PluginPresentationViewsCreateArgs
|
|
297
|
+
>
|
|
298
|
+
|
|
299
|
+
/** Result of {@linkcode PluginPresentationViewsApi.create} — the saved view. */
|
|
300
|
+
export const PluginPresentationViewsCreateResult = PluginPresentationView
|
|
301
|
+
export type PluginPresentationViewsCreateResult = z.infer<
|
|
302
|
+
typeof PluginPresentationViewsCreateResult
|
|
303
|
+
>
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Program adjacency — the proximity relationships between departments or
|
|
6
|
+
* spaces.
|
|
7
|
+
*
|
|
8
|
+
* Adjacency is stage one of the product's space-planning workflow (compute →
|
|
9
|
+
* arrange → pack): the AI service scores which program elements need to be
|
|
10
|
+
* near each other, and the geometry contributes physical contact. Cell values:
|
|
11
|
+
*
|
|
12
|
+
* | Value | Meaning |
|
|
13
|
+
* |---|---|
|
|
14
|
+
* | `2` | Direct — adjacency required |
|
|
15
|
+
* | `1` | Indirect — nearby preferred, or physical contact |
|
|
16
|
+
* | `-1` | Restricted — must NOT be adjacent |
|
|
17
|
+
* | `0` | No relationship — or adjacency was never computed |
|
|
18
|
+
*
|
|
19
|
+
* Zeros are ambiguous **by design** (the engine cannot distinguish "no
|
|
20
|
+
* relationship" from "never computed"): call
|
|
21
|
+
* {@linkcode PluginProgramAdjacencyApi.compute} first when you need fresh
|
|
22
|
+
* data. Persisted matrices auto-hydrate on scene load, so warm reads are the
|
|
23
|
+
* common case. The arrange/pack stages of the workflow live in
|
|
24
|
+
* {@linkcode PluginProgramLayoutApi} (`program.layout`).
|
|
25
|
+
*
|
|
26
|
+
* Accessed via `snaptrude.program.adjacency`.
|
|
27
|
+
*/
|
|
28
|
+
export abstract class PluginProgramAdjacencyApi {
|
|
29
|
+
constructor() {}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Read the adjacency matrix at the department or space level.
|
|
33
|
+
*
|
|
34
|
+
* Returns a square `matrix` whose rows/columns are aligned to `ids`
|
|
35
|
+
* (component ids). Pass `ids` to read a sub-matrix in that order; omit it to
|
|
36
|
+
* get every eligible element at that level. Cell values:
|
|
37
|
+
*
|
|
38
|
+
* | Value | Meaning |
|
|
39
|
+
* |---|---|
|
|
40
|
+
* | `2` | Direct — adjacency required |
|
|
41
|
+
* | `1` | Indirect — nearby preferred, or physical contact |
|
|
42
|
+
* | `-1` | Restricted — must NOT be adjacent |
|
|
43
|
+
* | `0` | No relationship — or adjacency was never computed |
|
|
44
|
+
*
|
|
45
|
+
* Zeros are ambiguous by design — call
|
|
46
|
+
* {@linkcode PluginProgramAdjacencyApi.compute} first for fresh data
|
|
47
|
+
* (persisted matrices auto-hydrate on scene load, so warm reads are the
|
|
48
|
+
* common case). Space-level relationships are computed within a storey:
|
|
49
|
+
* cross-storey pairs always read `0`. At the `department` level the result
|
|
50
|
+
* also carries `departmentIds`, a parallel array joining each row to the
|
|
51
|
+
* department entity ids returned by `program.departments.list` (the row
|
|
52
|
+
* `ids` are department-mass component ids, not department entity ids).
|
|
53
|
+
*
|
|
54
|
+
* @param level - Read the `"department"` or `"space"` matrix.
|
|
55
|
+
* @param ids - Component ids to read a sub-matrix for, in this order
|
|
56
|
+
* (defaults to every eligible element at the level).
|
|
57
|
+
* @returns A {@linkcode PluginProgramAdjacencyGetMatrixResult} with `ids`,
|
|
58
|
+
* the square `matrix`, and (at department level) `departmentIds`.
|
|
59
|
+
* @throws If an id is unknown or does not match the requested level.
|
|
60
|
+
*
|
|
61
|
+
* @examplePrompt Get the space adjacency matrix
|
|
62
|
+
* @examplePrompt Which departments must be adjacent?
|
|
63
|
+
* @examplePrompt Show the adjacency relationships between departments
|
|
64
|
+
* @examplePrompt Read the adjacency matrix for these spaces
|
|
65
|
+
* @examplePrompt Which rooms are restricted from being next to each other?
|
|
66
|
+
*
|
|
67
|
+
* # Example
|
|
68
|
+
* ```ts
|
|
69
|
+
* const { ids, matrix } = await snaptrude.program.adjacency.getMatrix("department")
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
public abstract getMatrix(
|
|
73
|
+
level: PluginAdjacencyLevel,
|
|
74
|
+
ids?: string[],
|
|
75
|
+
): PluginApiReturn<PluginProgramAdjacencyGetMatrixResult>
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Compute (or refresh) the adjacency data for the project.
|
|
79
|
+
*
|
|
80
|
+
* Runs the AI adjacency precompute and persists the result; a no-op when
|
|
81
|
+
* the stored data is already fresh. A real run takes **~2s at minimum**
|
|
82
|
+
* (engine pacing) plus the AI service round-trip. This is a write (it
|
|
83
|
+
* mutates and persists project analysis data), so it is blocked when plugin
|
|
84
|
+
* writes are disabled.
|
|
85
|
+
*
|
|
86
|
+
* @returns A {@linkcode PluginProgramAdjacencyComputeResult} —
|
|
87
|
+
* `{ success: true }` when the data is fresh or the run completed;
|
|
88
|
+
* `{ success: false, error }` when the AI service could not be reached.
|
|
89
|
+
*
|
|
90
|
+
* @examplePrompt Refresh adjacency analysis
|
|
91
|
+
* @examplePrompt Compute the adjacency matrix for this project
|
|
92
|
+
* @examplePrompt Recalculate which departments should be adjacent
|
|
93
|
+
*
|
|
94
|
+
* # Example
|
|
95
|
+
* ```ts
|
|
96
|
+
* const { success } = await snaptrude.program.adjacency.compute()
|
|
97
|
+
* if (success) {
|
|
98
|
+
* const data = await snaptrude.program.adjacency.getMatrix("space")
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
public abstract compute(): PluginApiReturn<PluginProgramAdjacencyComputeResult>
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The level an adjacency matrix is read at.
|
|
107
|
+
*
|
|
108
|
+
* | Value | Description |
|
|
109
|
+
* |---|---|
|
|
110
|
+
* | `"department"` | One row/column per department mass |
|
|
111
|
+
* | `"space"` | One row/column per space (within a storey) |
|
|
112
|
+
*/
|
|
113
|
+
export const PluginAdjacencyLevel = z.enum(["department", "space"])
|
|
114
|
+
export type PluginAdjacencyLevel = z.infer<typeof PluginAdjacencyLevel>
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Arguments for {@linkcode PluginProgramAdjacencyApi.getMatrix}.
|
|
118
|
+
*
|
|
119
|
+
* | Property | Type | Description |
|
|
120
|
+
* |---|---|---|
|
|
121
|
+
* | `level` | {@linkcode PluginAdjacencyLevel} | Read the `"department"` or `"space"` matrix |
|
|
122
|
+
* | `ids` | `string[] \| undefined` | Component ids to read a sub-matrix for, in this order (defaults to every eligible element at the level) |
|
|
123
|
+
*/
|
|
124
|
+
export const PluginProgramAdjacencyGetMatrixArgs = z.object({
|
|
125
|
+
level: PluginAdjacencyLevel,
|
|
126
|
+
ids: z.array(z.string()).optional(),
|
|
127
|
+
})
|
|
128
|
+
export type PluginProgramAdjacencyGetMatrixArgs = z.infer<
|
|
129
|
+
typeof PluginProgramAdjacencyGetMatrixArgs
|
|
130
|
+
>
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Result of {@linkcode PluginProgramAdjacencyApi.getMatrix}.
|
|
134
|
+
*
|
|
135
|
+
* | Property | Type | Description |
|
|
136
|
+
* |---|---|---|
|
|
137
|
+
* | `ids` | `string[]` | Component ids, in matrix row/column order |
|
|
138
|
+
* | `departmentIds` | `(string \| null)[] \| undefined` | Department level only: parallel to `ids`, the department entity id each row belongs to (joinable against `program.departments.list`), `null` when unassigned |
|
|
139
|
+
* | `matrix` | `number[][]` | Square matrix aligned to `ids`; values in `{-1, 0, 1, 2}` |
|
|
140
|
+
*/
|
|
141
|
+
export const PluginProgramAdjacencyGetMatrixResult = z.object({
|
|
142
|
+
ids: z.array(z.string()),
|
|
143
|
+
departmentIds: z.array(z.string().nullable()).optional(),
|
|
144
|
+
matrix: z.array(z.array(z.number())),
|
|
145
|
+
})
|
|
146
|
+
export type PluginProgramAdjacencyGetMatrixResult = z.infer<
|
|
147
|
+
typeof PluginProgramAdjacencyGetMatrixResult
|
|
148
|
+
>
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Result of {@linkcode PluginProgramAdjacencyApi.compute}.
|
|
152
|
+
*
|
|
153
|
+
* | Property | Type | Description |
|
|
154
|
+
* |---|---|---|
|
|
155
|
+
* | `success` | `boolean` | `true` when the data is fresh or the run completed |
|
|
156
|
+
* | `error` | `string \| undefined` | Failure reason when `success` is `false` |
|
|
157
|
+
*/
|
|
158
|
+
export const PluginProgramAdjacencyComputeResult = z.object({
|
|
159
|
+
success: z.boolean(),
|
|
160
|
+
error: z.string().optional(),
|
|
161
|
+
})
|
|
162
|
+
export type PluginProgramAdjacencyComputeResult = z.infer<
|
|
163
|
+
typeof PluginProgramAdjacencyComputeResult
|
|
164
|
+
>
|