@snaptrude/plugin-core 0.0.0-dev-20260708130115 → 0.0.0-dev-20260827135706
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 +152 -1
- package/api-manifest.json +3620 -276
- package/dist/api/analysis/daylight.d.ts +603 -0
- package/dist/api/analysis/daylight.d.ts.map +1 -0
- package/dist/api/analysis/heatmaps.d.ts +658 -0
- package/dist/api/analysis/heatmaps.d.ts.map +1 -0
- package/dist/api/analysis/illuminance.d.ts +145 -0
- package/dist/api/analysis/illuminance.d.ts.map +1 -0
- package/dist/api/analysis/index.d.ts +59 -0
- package/dist/api/analysis/index.d.ts.map +1 -0
- package/dist/api/analysis/shadows.d.ts +165 -0
- package/dist/api/analysis/shadows.d.ts.map +1 -0
- package/dist/api/analysis/solar.d.ts +249 -0
- package/dist/api/analysis/solar.d.ts.map +1 -0
- package/dist/api/analysis/sunlightHours.d.ts +208 -0
- package/dist/api/analysis/sunlightHours.d.ts.map +1 -0
- package/dist/api/analysis/sunpath.d.ts +80 -0
- package/dist/api/analysis/sunpath.d.ts.map +1 -0
- package/dist/api/analysis/weather.d.ts +193 -0
- package/dist/api/analysis/weather.d.ts.map +1 -0
- package/dist/api/core/camera/index.d.ts +261 -0
- package/dist/api/core/camera/index.d.ts.map +1 -0
- package/dist/api/core/comment/index.d.ts +105 -2
- package/dist/api/core/comment/index.d.ts.map +1 -1
- package/dist/api/core/geom/create/index.d.ts +840 -14
- package/dist/api/core/geom/create/index.d.ts.map +1 -1
- package/dist/api/core/geom/delete/index.d.ts +8 -2
- package/dist/api/core/geom/delete/index.d.ts.map +1 -1
- package/dist/api/core/geom/query/arc.d.ts +5 -5
- package/dist/api/core/geom/query/brep.d.ts +130 -18
- package/dist/api/core/geom/query/brep.d.ts.map +1 -1
- package/dist/api/core/geom/query/circle.d.ts +18 -18
- package/dist/api/core/geom/query/contour.d.ts +20 -20
- package/dist/api/core/geom/query/curve.d.ts +49 -49
- package/dist/api/core/geom/query/edge.d.ts +5 -5
- package/dist/api/core/geom/query/face.d.ts +16 -16
- package/dist/api/core/geom/query/halfedge.d.ts +8 -8
- package/dist/api/core/geom/query/profile.d.ts +19 -19
- package/dist/api/core/geom/query/vertex.d.ts +8 -8
- package/dist/api/core/geom/update/contour.d.ts +14 -14
- package/dist/api/core/geom/update/curve.d.ts +7 -7
- package/dist/api/core/geom/update/profile.d.ts +16 -16
- package/dist/api/core/handles/index.d.ts +210 -0
- package/dist/api/core/handles/index.d.ts.map +1 -0
- package/dist/api/core/index.d.ts +34 -0
- package/dist/api/core/index.d.ts.map +1 -1
- package/dist/api/core/io/export/index.d.ts +134 -0
- package/dist/api/core/io/export/index.d.ts.map +1 -0
- package/dist/api/core/io/import/index.d.ts +453 -0
- package/dist/api/core/io/import/index.d.ts.map +1 -0
- package/dist/api/core/io/index.d.ts +40 -0
- package/dist/api/core/io/index.d.ts.map +1 -0
- package/dist/api/core/io/job/index.d.ts +139 -0
- package/dist/api/core/io/job/index.d.ts.map +1 -0
- package/dist/api/core/io/query/index.d.ts +74 -0
- package/dist/api/core/io/query/index.d.ts.map +1 -0
- package/dist/api/core/io/terrain/index.d.ts +341 -0
- package/dist/api/core/io/terrain/index.d.ts.map +1 -0
- package/dist/api/core/io/underlay/index.d.ts +805 -0
- package/dist/api/core/io/underlay/index.d.ts.map +1 -0
- package/dist/api/core/layers.d.ts +7 -7
- package/dist/api/core/mode/index.d.ts +99 -0
- package/dist/api/core/mode/index.d.ts.map +1 -0
- package/dist/api/core/project/index.d.ts +68 -1
- package/dist/api/core/project/index.d.ts.map +1 -1
- package/dist/api/core/proposals/index.d.ts +531 -0
- package/dist/api/core/proposals/index.d.ts.map +1 -0
- package/dist/api/core/storeys/index.d.ts +265 -0
- package/dist/api/core/storeys/index.d.ts.map +1 -0
- package/dist/api/core/tags.d.ts +24 -0
- package/dist/api/core/tags.d.ts.map +1 -1
- package/dist/api/core/user.d.ts +44 -0
- package/dist/api/core/user.d.ts.map +1 -0
- package/dist/api/core/zoom/index.d.ts +4 -0
- package/dist/api/core/zoom/index.d.ts.map +1 -1
- package/dist/api/design/boolean/index.d.ts +4 -4
- package/dist/api/design/create/index.d.ts +568 -45
- package/dist/api/design/create/index.d.ts.map +1 -1
- package/dist/api/design/delete/index.d.ts +3 -0
- package/dist/api/design/delete/index.d.ts.map +1 -1
- package/dist/api/design/doors/index.d.ts +195 -0
- package/dist/api/design/doors/index.d.ts.map +1 -1
- package/dist/api/design/edit/index.d.ts +1 -1
- package/dist/api/design/erase/index.d.ts +2 -2
- package/dist/api/design/family.d.ts +349 -0
- package/dist/api/design/family.d.ts.map +1 -0
- package/dist/api/design/furniture/index.d.ts +181 -8
- package/dist/api/design/furniture/index.d.ts.map +1 -1
- package/dist/api/design/index.d.ts +98 -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 +270 -16
- package/dist/api/design/materials/index.d.ts.map +1 -1
- package/dist/api/design/query/geometry/index.d.ts +112 -0
- package/dist/api/design/query/geometry/index.d.ts.map +1 -1
- package/dist/api/design/query/index.d.ts +282 -11
- package/dist/api/design/query/index.d.ts.map +1 -1
- package/dist/api/design/query/referenceLines.d.ts +45 -0
- package/dist/api/design/query/referenceLines.d.ts.map +1 -0
- package/dist/api/design/query/spaces.d.ts +181 -8
- package/dist/api/design/query/spaces.d.ts.map +1 -1
- package/dist/api/design/selection/index.d.ts +144 -0
- package/dist/api/design/selection/index.d.ts.map +1 -1
- package/dist/api/design/transform/index.d.ts +172 -10
- package/dist/api/design/transform/index.d.ts.map +1 -1
- package/dist/api/design/types/index.d.ts +181 -0
- package/dist/api/design/types/index.d.ts.map +1 -0
- package/dist/api/design/update/index.d.ts +553 -2
- package/dist/api/design/update/index.d.ts.map +1 -1
- package/dist/api/design/visibility.d.ts +126 -0
- package/dist/api/design/visibility.d.ts.map +1 -0
- 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/buildableEnvelope.d.ts +4 -0
- package/dist/api/entity/buildableEnvelope.d.ts.map +1 -1
- package/dist/api/entity/referenceLine.d.ts +10 -2
- package/dist/api/entity/referenceLine.d.ts.map +1 -1
- package/dist/api/entity/space.d.ts +21 -21
- package/dist/api/entity/story.d.ts +242 -15
- package/dist/api/entity/story.d.ts.map +1 -1
- package/dist/api/index.d.ts +10 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/presentation/aiInspiration.d.ts +25 -25
- package/dist/api/presentation/annotate.d.ts +467 -0
- package/dist/api/presentation/annotate.d.ts.map +1 -0
- package/dist/api/presentation/diagrams.d.ts +111 -8
- package/dist/api/presentation/diagrams.d.ts.map +1 -1
- package/dist/api/presentation/export.d.ts +108 -0
- package/dist/api/presentation/export.d.ts.map +1 -0
- package/dist/api/presentation/import.d.ts +55 -4
- package/dist/api/presentation/import.d.ts.map +1 -1
- package/dist/api/presentation/index.d.ts +58 -1
- package/dist/api/presentation/index.d.ts.map +1 -1
- package/dist/api/presentation/placedViews.d.ts +1139 -0
- package/dist/api/presentation/placedViews.d.ts.map +1 -0
- package/dist/api/presentation/shapes.d.ts +481 -0
- package/dist/api/presentation/shapes.d.ts.map +1 -0
- package/dist/api/presentation/sheets.d.ts +452 -13
- package/dist/api/presentation/sheets.d.ts.map +1 -1
- package/dist/api/presentation/slideshow.d.ts +125 -0
- package/dist/api/presentation/slideshow.d.ts.map +1 -0
- package/dist/api/presentation/tables.d.ts +81 -0
- package/dist/api/presentation/tables.d.ts.map +1 -0
- package/dist/api/presentation/views.d.ts +367 -7
- package/dist/api/presentation/views.d.ts.map +1 -1
- package/dist/api/program/areas.d.ts +102 -12
- package/dist/api/program/areas.d.ts.map +1 -1
- package/dist/api/program/cores.d.ts +3 -99
- package/dist/api/program/cores.d.ts.map +1 -1
- package/dist/api/program/index.d.ts +7 -15
- package/dist/api/program/index.d.ts.map +1 -1
- package/dist/api/program/layout.d.ts +346 -11
- package/dist/api/program/layout.d.ts.map +1 -1
- package/dist/api/program/site.d.ts +469 -13
- package/dist/api/program/site.d.ts.map +1 -1
- package/dist/api/program/spreadsheet.d.ts +365 -41
- package/dist/api/program/spreadsheet.d.ts.map +1 -1
- package/dist/api/workspace/index.d.ts +505 -0
- package/dist/api/workspace/index.d.ts.map +1 -0
- 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/handles.d.ts +97 -25
- package/dist/handles.d.ts.map +1 -1
- package/dist/host-utils.d.ts +4 -0
- package/dist/host-utils.d.ts.map +1 -1
- package/dist/index.cjs +4582 -1422
- 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 +4171 -1411
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
- package/scripts/generate-manifest.mjs +45 -0
- package/scripts/generate-manifest.test.mjs +103 -4
- package/src/api/analysis/daylight.ts +470 -0
- package/src/api/analysis/heatmaps.ts +683 -0
- package/src/api/analysis/illuminance.ts +155 -0
- package/src/api/analysis/index.ts +61 -0
- package/src/api/analysis/shadows.ts +183 -0
- package/src/api/analysis/solar.ts +237 -0
- package/src/api/analysis/sunlightHours.ts +211 -0
- package/src/api/analysis/sunpath.ts +83 -0
- package/src/api/analysis/weather.ts +179 -0
- package/src/api/core/camera/index.ts +268 -0
- package/src/api/core/comment/index.ts +120 -2
- package/src/api/core/geom/create/index.ts +912 -1
- package/src/api/core/geom/delete/index.ts +6 -0
- package/src/api/core/geom/query/brep.ts +119 -0
- package/src/api/core/handles/index.ts +233 -0
- package/src/api/core/index.ts +34 -0
- package/src/api/core/io/export/index.ts +126 -0
- package/src/api/core/io/import/index.ts +496 -0
- package/src/api/core/io/index.ts +42 -0
- package/src/api/core/io/job/index.ts +140 -0
- package/src/api/core/io/query/index.ts +71 -0
- package/src/api/core/io/terrain/index.ts +360 -0
- package/src/api/core/io/underlay/index.ts +705 -0
- package/src/api/core/mode/index.ts +96 -0
- package/src/api/core/project/index.ts +62 -1
- package/src/api/core/proposals/index.ts +569 -0
- package/src/api/core/storeys/index.ts +294 -0
- package/src/api/core/tags.ts +27 -0
- package/src/api/core/user.ts +46 -0
- package/src/api/core/zoom/index.ts +4 -0
- package/src/api/design/create/index.ts +670 -30
- package/src/api/design/delete/index.ts +3 -0
- package/src/api/design/doors/index.ts +208 -0
- package/src/api/design/erase/index.ts +1 -1
- package/src/api/design/family.ts +388 -0
- package/src/api/design/furniture/index.ts +197 -8
- package/src/api/design/index.ts +102 -0
- package/src/api/design/lock.ts +27 -0
- package/src/api/design/materials/index.ts +334 -27
- package/src/api/design/query/geometry/index.ts +125 -3
- package/src/api/design/query/index.ts +217 -7
- package/src/api/design/query/referenceLines.ts +52 -0
- package/src/api/design/query/spaces.ts +143 -0
- package/src/api/design/selection/index.ts +129 -0
- package/src/api/design/transform/index.ts +170 -9
- package/src/api/design/types/index.ts +156 -0
- package/src/api/design/update/index.ts +631 -3
- package/src/api/design/visibility.ts +143 -0
- package/src/api/design/windows/index.ts +128 -2
- package/src/api/entity/buildableEnvelope.ts +4 -0
- package/src/api/entity/referenceLine.ts +8 -0
- package/src/api/entity/story.ts +259 -15
- package/src/api/index.ts +10 -0
- package/src/api/presentation/annotate.ts +385 -0
- package/src/api/presentation/diagrams.ts +118 -8
- package/src/api/presentation/export.ts +108 -0
- package/src/api/presentation/import.ts +51 -4
- package/src/api/presentation/index.ts +66 -1
- package/src/api/presentation/placedViews.ts +1120 -0
- package/src/api/presentation/shapes.ts +274 -0
- package/src/api/presentation/sheets.ts +400 -13
- package/src/api/presentation/slideshow.ts +134 -0
- package/src/api/presentation/tables.ts +84 -0
- package/src/api/presentation/views.ts +376 -8
- package/src/api/program/areas.ts +88 -15
- package/src/api/program/cores.ts +3 -91
- package/src/api/program/index.ts +7 -15
- package/src/api/program/layout.ts +365 -11
- package/src/api/program/site.ts +435 -13
- package/src/api/program/spreadsheet.ts +376 -35
- package/src/api/workspace/index.ts +563 -0
- 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/handles.ts +123 -13
- package/src/host-utils.ts +4 -0
- package/src/index.ts +1 -0
- package/test/errors.test.mjs +184 -0
- package/tsconfig.json +7 -2
|
@@ -9,8 +9,31 @@ import { PluginApiReturn } from "../../types"
|
|
|
9
9
|
* three of the space-planning workflow that starts with
|
|
10
10
|
* {@linkcode PluginProgramAdjacencyApi} (`program.adjacency`).
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* Both {@linkcode PluginProgramLayoutApi.arrange} and
|
|
13
|
+
* {@linkcode PluginProgramLayoutApi.pack} run as an **asynchronous backend
|
|
14
|
+
* job** on the space-solver service:
|
|
15
|
+
*
|
|
16
|
+
* 1. `arrange` / `pack` start the job and **return immediately** — they do
|
|
17
|
+
* not wait for the layout.
|
|
18
|
+
* 2. Poll {@linkcode PluginProgramLayoutApi.getState} until `status` is no
|
|
19
|
+
* longer `"running"` — a run can take up to 20 minutes.
|
|
20
|
+
* 3. {@linkcode PluginProgramLayoutApi.cancel} aborts an in-flight run.
|
|
21
|
+
*
|
|
22
|
+
* `arrange` produces several candidate layouts. By default it **auto-commits
|
|
23
|
+
* the first solution** as one undoable edit; pass `autoCommit: false` to hold
|
|
24
|
+
* the candidates for review instead — `getState` then reports
|
|
25
|
+
* `status: "pendingReview"` with `totalSolutions`, and
|
|
26
|
+
* {@linkcode PluginProgramLayoutApi.applySolution} commits the one you pick
|
|
27
|
+
* (the headless counterpart of the product's "Solution N of M → Apply" bar).
|
|
28
|
+
* `pack` re-shapes and applies its single result directly. Both are
|
|
29
|
+
* **Pro-plan-gated**, matching the product UI.
|
|
30
|
+
*
|
|
31
|
+
* {@linkcode PluginProgramLayoutApi.stack} is the **cross-storey** action —
|
|
32
|
+
* the product's *Pack in envelope* / auto-stack. It splits the building
|
|
33
|
+
* envelope by storey and packs each storey's departments into its slice as one
|
|
34
|
+
* undoable edit. Unlike `arrange` / `pack`, it is **not** the async-job model:
|
|
35
|
+
* it resolves inline when the whole multi-storey pack is done (no `getState`
|
|
36
|
+
* polling) and returns the storeys it had to skip. It is Pro-gated too.
|
|
14
37
|
*
|
|
15
38
|
* Accessed via `snaptrude.program.layout`.
|
|
16
39
|
*/
|
|
@@ -19,23 +42,86 @@ export abstract class PluginProgramLayoutApi {
|
|
|
19
42
|
|
|
20
43
|
/**
|
|
21
44
|
* Arrange the spaces inside the envelope using the computed adjacency data.
|
|
22
|
-
*
|
|
45
|
+
*
|
|
46
|
+
* Starts the backend job and **returns immediately** — poll
|
|
47
|
+
* {@linkcode PluginProgramLayoutApi.getState} until `status` leaves
|
|
48
|
+
* `"running"` (a run can take up to 20 minutes). The solver produces
|
|
49
|
+
* several candidate layouts; by default this **auto-commits the first
|
|
50
|
+
* solution** as one undoable edit. Pass `autoCommit: false` to review them
|
|
51
|
+
* instead: the run finishes with `status: "pendingReview"` and
|
|
52
|
+
* `totalSolutions` in `getState`, and
|
|
53
|
+
* {@linkcode PluginProgramLayoutApi.applySolution} commits the candidate you
|
|
54
|
+
* pick ({@linkcode PluginProgramLayoutApi.cancel} discards them). An
|
|
55
|
+
* arrange **without an envelope** applies directly (there is nothing to
|
|
56
|
+
* review) regardless of `autoCommit`. Starting a run while one is in flight
|
|
57
|
+
* replaces it; while solutions are pending review, new runs are refused —
|
|
58
|
+
* apply or cancel first.
|
|
59
|
+
*
|
|
60
|
+
* With no `options`, operates on the eligible Room/Department masses on the
|
|
61
|
+
* active storey and auto-detects the single buildable envelope there.
|
|
62
|
+
*
|
|
63
|
+
* @param options - Optional {@linkcode PluginProgramLayoutRunArgs} — the
|
|
64
|
+
* space / department masses to arrange and the envelope to fit them in.
|
|
65
|
+
* Omitted fields fall back to the active-storey defaults.
|
|
66
|
+
* @returns A {@linkcode PluginProgramLayoutRunResult} — `{ success: true }`
|
|
67
|
+
* when the job was started. Solver failures surface through
|
|
68
|
+
* {@linkcode PluginProgramLayoutApi.getState} (`status: "inactive"`), not
|
|
69
|
+
* as a rejected call.
|
|
70
|
+
* @throws When the project is not on a Pro plan.
|
|
71
|
+
* @throws When a `spaceId` / `departmentId` / `envelopeId` does not resolve.
|
|
72
|
+
* @throws When more than one envelope is on the active storey and none was
|
|
73
|
+
* given (ambiguous).
|
|
74
|
+
* @throws When arrange solutions are pending review (apply or cancel them
|
|
75
|
+
* first).
|
|
76
|
+
* @throws When plugin writes are disabled.
|
|
23
77
|
*
|
|
24
78
|
* @examplePrompt Arrange the rooms in the envelope
|
|
25
79
|
* @examplePrompt Lay out the departments inside the building envelope
|
|
26
80
|
* @examplePrompt Auto-arrange the program spaces
|
|
81
|
+
* @examplePrompt Arrange the rooms but let me pick the solution
|
|
27
82
|
*
|
|
28
83
|
* # Example
|
|
29
84
|
* ```ts
|
|
30
85
|
* const { success, error } = await snaptrude.program.layout.arrange()
|
|
31
|
-
* if (!success)
|
|
86
|
+
* if (!success) throw new Error(error)
|
|
87
|
+
* // poll until the layout is applied
|
|
88
|
+
* let job = await snaptrude.program.layout.getState()
|
|
89
|
+
* while (job?.status === "running") {
|
|
90
|
+
* await new Promise((r) => setTimeout(r, 5000))
|
|
91
|
+
* job = await snaptrude.program.layout.getState()
|
|
92
|
+
* }
|
|
32
93
|
* ```
|
|
33
94
|
*/
|
|
34
|
-
public arrange
|
|
95
|
+
public abstract arrange(
|
|
96
|
+
options?: PluginProgramLayoutRunArgs,
|
|
97
|
+
): PluginApiReturn<PluginProgramLayoutRunResult>
|
|
35
98
|
|
|
36
99
|
/**
|
|
37
100
|
* Pack the spaces into the envelope (a tighter fit than arrange).
|
|
38
|
-
*
|
|
101
|
+
*
|
|
102
|
+
* Like {@linkcode PluginProgramLayoutApi.arrange}, this starts the backend
|
|
103
|
+
* job and **returns immediately** — poll
|
|
104
|
+
* {@linkcode PluginProgramLayoutApi.getState} until `status` leaves
|
|
105
|
+
* `"running"` (up to 20 minutes). Pack re-shapes mass geometry to fit and
|
|
106
|
+
* **applies its single result directly** (no solution review). Starting a
|
|
107
|
+
* run while one is in flight replaces it.
|
|
108
|
+
*
|
|
109
|
+
* With no `options`, operates on the eligible Room/Department masses on the
|
|
110
|
+
* active storey and auto-detects the single buildable envelope there.
|
|
111
|
+
*
|
|
112
|
+
* @param options - Optional {@linkcode PluginProgramLayoutRunArgs} — same
|
|
113
|
+
* shape as `arrange`; omitted fields fall back to the active-storey
|
|
114
|
+
* defaults.
|
|
115
|
+
* @returns A {@linkcode PluginProgramLayoutRunResult} — `{ success: true }`
|
|
116
|
+
* when the job was started. Solver failures surface through
|
|
117
|
+
* {@linkcode PluginProgramLayoutApi.getState} (`status: "inactive"`).
|
|
118
|
+
* @throws When the project is not on a Pro plan.
|
|
119
|
+
* @throws When a `spaceId` / `departmentId` / `envelopeId` does not resolve.
|
|
120
|
+
* @throws When more than one envelope is on the active storey and none was
|
|
121
|
+
* given (ambiguous).
|
|
122
|
+
* @throws When arrange solutions are pending review (apply or cancel them
|
|
123
|
+
* first).
|
|
124
|
+
* @throws When plugin writes are disabled.
|
|
39
125
|
*
|
|
40
126
|
* @examplePrompt Pack the rooms into the envelope
|
|
41
127
|
* @examplePrompt Fit the program spaces tightly into the building
|
|
@@ -43,20 +129,193 @@ export abstract class PluginProgramLayoutApi {
|
|
|
43
129
|
*
|
|
44
130
|
* # Example
|
|
45
131
|
* ```ts
|
|
46
|
-
* const { success
|
|
47
|
-
*
|
|
132
|
+
* const { success } = await snaptrude.program.layout.pack({ envelopeId: "be_..." })
|
|
133
|
+
* let job = await snaptrude.program.layout.getState()
|
|
134
|
+
* while (job?.status === "running") {
|
|
135
|
+
* await new Promise((r) => setTimeout(r, 5000))
|
|
136
|
+
* job = await snaptrude.program.layout.getState()
|
|
137
|
+
* }
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
public abstract pack(
|
|
141
|
+
options?: PluginProgramLayoutRunArgs,
|
|
142
|
+
): PluginApiReturn<PluginProgramLayoutRunResult>
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Apply one of the pending arrange solutions.
|
|
146
|
+
*
|
|
147
|
+
* The headless counterpart of the product's **"Solution N of M → Apply"**
|
|
148
|
+
* review bar: after an {@linkcode PluginProgramLayoutApi.arrange} run
|
|
149
|
+
* started with `autoCommit: false` finishes with `status: "pendingReview"`,
|
|
150
|
+
* this commits the candidate at `index` (0-based,
|
|
151
|
+
* `0 ≤ index < totalSolutions` from
|
|
152
|
+
* {@linkcode PluginProgramLayoutApi.getState}) as **one undoable edit** and
|
|
153
|
+
* discards the other candidates. `getState` then reports
|
|
154
|
+
* `status: "active"`.
|
|
155
|
+
*
|
|
156
|
+
* @param index - 0-based index of the pending solution to apply.
|
|
157
|
+
* @returns A {@linkcode PluginProgramLayoutApplyResult} —
|
|
158
|
+
* `{ success: true }` when the solution was applied.
|
|
159
|
+
* @throws When no arrange solutions are pending review (no
|
|
160
|
+
* `arrange({ autoCommit: false })` run has finished, or its solutions were
|
|
161
|
+
* already applied / cancelled).
|
|
162
|
+
* @throws When `index` is out of range for the pending solutions.
|
|
163
|
+
* @throws When plugin writes are disabled.
|
|
164
|
+
*
|
|
165
|
+
* @examplePrompt Apply the second arrange solution
|
|
166
|
+
* @examplePrompt Pick layout solution 3 and commit it
|
|
167
|
+
* @examplePrompt Apply the arrange solution I chose
|
|
168
|
+
*
|
|
169
|
+
* # Example
|
|
170
|
+
* ```ts
|
|
171
|
+
* await snaptrude.program.layout.arrange({ autoCommit: false })
|
|
172
|
+
* let job = await snaptrude.program.layout.getState()
|
|
173
|
+
* while (job?.status === "running") {
|
|
174
|
+
* await new Promise((r) => setTimeout(r, 5000))
|
|
175
|
+
* job = await snaptrude.program.layout.getState()
|
|
176
|
+
* }
|
|
177
|
+
* if (job?.status === "pendingReview") {
|
|
178
|
+
* console.log(`${job.totalSolutions} candidate layouts`)
|
|
179
|
+
* await snaptrude.program.layout.applySolution(1) // commit the second one
|
|
180
|
+
* }
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
public abstract applySolution(
|
|
184
|
+
index: number,
|
|
185
|
+
): PluginApiReturn<PluginProgramLayoutApplyResult>
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Stack the program across **every storey** of the building — the product's
|
|
189
|
+
* *Pack in envelope* / auto-stack.
|
|
190
|
+
*
|
|
191
|
+
* Splits the building envelope massing into per-storey envelope slices, then
|
|
192
|
+
* packs each storey's departments into its slice, applying the whole
|
|
193
|
+
* multi-storey result as **one undoable edit**.
|
|
194
|
+
*
|
|
195
|
+
* Unlike {@linkcode PluginProgramLayoutApi.arrange} /
|
|
196
|
+
* {@linkcode PluginProgramLayoutApi.pack}, this **is not** the async-job
|
|
197
|
+
* model: `await` it and it resolves when the stack is done — there is no
|
|
198
|
+
* `getState` polling. It operates on the whole active model (no id / envelope
|
|
199
|
+
* arguments): it auto-discovers the departments and envelope on each storey.
|
|
200
|
+
*
|
|
201
|
+
* Storeys that have departments but **no envelope** are reported in
|
|
202
|
+
* `skippedStoreys` (nothing was packed there). A storey's departments must
|
|
203
|
+
* already be on that storey — `stack` does not move departments between
|
|
204
|
+
* floors, it lays out each floor's program into that floor's envelope.
|
|
205
|
+
*
|
|
206
|
+
* @returns A {@linkcode PluginProgramLayoutStackResult} — `success: true`
|
|
207
|
+
* with the (possibly empty) `skippedStoreys` when the stack was applied, or
|
|
208
|
+
* `success: false` with an `error` when the run failed (e.g. the adjacency
|
|
209
|
+
* service was unreachable).
|
|
210
|
+
* @throws When the project is not on a Pro plan.
|
|
211
|
+
* @throws When plugin writes are disabled.
|
|
212
|
+
* @throws When an `arrange` / `pack` run, or another `stack`, is already in
|
|
213
|
+
* flight, or arrange solutions are pending review (finish, apply, or
|
|
214
|
+
* `cancel` first).
|
|
215
|
+
*
|
|
216
|
+
* @examplePrompt Stack the program across all floors
|
|
217
|
+
* @examplePrompt Auto-stack the departments into the envelope on every storey
|
|
218
|
+
* @examplePrompt Pack the whole building's program into its envelope
|
|
219
|
+
*
|
|
220
|
+
* # Example
|
|
221
|
+
* ```ts
|
|
222
|
+
* const { success, skippedStoreys, error } = await snaptrude.program.layout.stack()
|
|
223
|
+
* if (!success) throw new Error(error)
|
|
224
|
+
* if (skippedStoreys.length)
|
|
225
|
+
* console.warn(`No envelope on storeys: ${skippedStoreys.join(", ")}`)
|
|
48
226
|
* ```
|
|
49
227
|
*/
|
|
50
|
-
public
|
|
228
|
+
public abstract stack(): PluginApiReturn<PluginProgramLayoutStackResult>
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Get the state of the layout run.
|
|
232
|
+
*
|
|
233
|
+
* The polling read for the async job started by
|
|
234
|
+
* {@linkcode PluginProgramLayoutApi.arrange} /
|
|
235
|
+
* {@linkcode PluginProgramLayoutApi.pack}. `status` values:
|
|
236
|
+
*
|
|
237
|
+
* | Status | Meaning |
|
|
238
|
+
* |---|---|
|
|
239
|
+
* | `"running"` | A run is in flight — keep polling |
|
|
240
|
+
* | `"active"` | The run finished and its layout is applied to the model |
|
|
241
|
+
* | `"inactive"` | A run finished without applying a layout (the solver failed or found no solution) |
|
|
242
|
+
* | `"pendingReview"` | An `arrange({ autoCommit: false })` run finished and its candidates await {@linkcode PluginProgramLayoutApi.applySolution} / {@linkcode PluginProgramLayoutApi.cancel} |
|
|
243
|
+
*
|
|
244
|
+
* While `status` is `"pendingReview"` the state also carries
|
|
245
|
+
* `totalSolutions` — the number of candidate layouts to pick from.
|
|
246
|
+
*
|
|
247
|
+
* @returns A {@linkcode PluginProgramLayoutStateResult} with the run
|
|
248
|
+
* `status`, or `null` when no run result is available (never ran or was
|
|
249
|
+
* cancelled).
|
|
250
|
+
*
|
|
251
|
+
* @examplePrompt Is the arrange done?
|
|
252
|
+
* @examplePrompt Check the status of the layout run
|
|
253
|
+
* @examplePrompt Did the pack finish?
|
|
254
|
+
*
|
|
255
|
+
* # Example
|
|
256
|
+
* ```ts
|
|
257
|
+
* const job = await snaptrude.program.layout.getState()
|
|
258
|
+
* if (job?.status === "active") console.log("layout applied")
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
public abstract getState(): PluginApiReturn<PluginProgramLayoutStateResult>
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Cancel the in-flight layout run.
|
|
265
|
+
*
|
|
266
|
+
* Aborts the backend job and discards any pending solution. Also discards
|
|
267
|
+
* a finished run's **pending-review** solutions (after
|
|
268
|
+
* `arrange({ autoCommit: false })`) without applying one. A no-op (returns
|
|
269
|
+
* `false`) when nothing is running and nothing is pending.
|
|
270
|
+
*
|
|
271
|
+
* @returns `true` when a run was cancelled or pending solutions were
|
|
272
|
+
* discarded, `false` when there was nothing to cancel.
|
|
273
|
+
* @throws When plugin writes are disabled.
|
|
274
|
+
*
|
|
275
|
+
* @examplePrompt Cancel the arrange
|
|
276
|
+
* @examplePrompt Stop the running layout job
|
|
277
|
+
* @examplePrompt Abort the pack in envelope
|
|
278
|
+
*
|
|
279
|
+
* # Example
|
|
280
|
+
* ```ts
|
|
281
|
+
* await snaptrude.program.layout.cancel()
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
public abstract cancel(): PluginApiReturn<boolean>
|
|
51
285
|
}
|
|
52
286
|
|
|
287
|
+
/**
|
|
288
|
+
* Arguments for {@linkcode PluginProgramLayoutApi.arrange} /
|
|
289
|
+
* {@linkcode PluginProgramLayoutApi.pack}. All fields are optional — omitted
|
|
290
|
+
* fields fall back to the eligible masses and the single envelope on the
|
|
291
|
+
* active storey.
|
|
292
|
+
*
|
|
293
|
+
* | Property | Type | Description |
|
|
294
|
+
* |---|---|---|
|
|
295
|
+
* | `spaceIds` | `string[] \| undefined` | Component ids of the Room masses to lay out |
|
|
296
|
+
* | `departmentIds` | `string[] \| undefined` | Component ids of the Department masses to lay out |
|
|
297
|
+
* | `envelopeId` | `string \| undefined` | The envelope to fit into — a mass component id or a buildable-envelope handle (`be_…`); omit to auto-detect the single envelope on the active storey |
|
|
298
|
+
* | `autoCommit` | `boolean \| undefined` | `arrange` only — `true` / omitted (default) auto-commits the first candidate solution; `false` holds the candidates for review via {@linkcode PluginProgramLayoutApi.applySolution}. Ignored by `pack` (it applies its single result directly) |
|
|
299
|
+
*/
|
|
300
|
+
export const PluginProgramLayoutRunArgs = z.object({
|
|
301
|
+
spaceIds: z.array(z.string()).optional(),
|
|
302
|
+
departmentIds: z.array(z.string()).optional(),
|
|
303
|
+
envelopeId: z.string().optional(),
|
|
304
|
+
autoCommit: z.boolean().optional(),
|
|
305
|
+
})
|
|
306
|
+
export type PluginProgramLayoutRunArgs = z.infer<
|
|
307
|
+
typeof PluginProgramLayoutRunArgs
|
|
308
|
+
>
|
|
309
|
+
|
|
53
310
|
/**
|
|
54
311
|
* Result of {@linkcode PluginProgramLayoutApi.arrange} /
|
|
55
|
-
* {@linkcode PluginProgramLayoutApi.pack}
|
|
312
|
+
* {@linkcode PluginProgramLayoutApi.pack} — reports whether the run was
|
|
313
|
+
* **started**, not whether the layout finished (poll
|
|
314
|
+
* {@linkcode PluginProgramLayoutApi.getState} for completion).
|
|
56
315
|
*
|
|
57
316
|
* | Property | Type | Description |
|
|
58
317
|
* |---|---|---|
|
|
59
|
-
* | `success` | `boolean` | Whether the layout run
|
|
318
|
+
* | `success` | `boolean` | Whether the layout run was started |
|
|
60
319
|
* | `error` | `string \| undefined` | Failure reason when `success` is `false` |
|
|
61
320
|
*/
|
|
62
321
|
export const PluginProgramLayoutRunResult = z.object({
|
|
@@ -66,3 +325,98 @@ export const PluginProgramLayoutRunResult = z.object({
|
|
|
66
325
|
export type PluginProgramLayoutRunResult = z.infer<
|
|
67
326
|
typeof PluginProgramLayoutRunResult
|
|
68
327
|
>
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* The status of a layout run.
|
|
331
|
+
*
|
|
332
|
+
* | Value | Meaning |
|
|
333
|
+
* |---|---|
|
|
334
|
+
* | `"running"` | A run is in flight — keep polling |
|
|
335
|
+
* | `"active"` | The run finished and its layout is applied to the model |
|
|
336
|
+
* | `"inactive"` | A run finished without applying a layout (the solver failed or found no solution) |
|
|
337
|
+
* | `"pendingReview"` | An `arrange({ autoCommit: false })` run finished and its candidate solutions await {@linkcode PluginProgramLayoutApi.applySolution} / {@linkcode PluginProgramLayoutApi.cancel} |
|
|
338
|
+
*/
|
|
339
|
+
export const PluginProgramLayoutJobStatus = z.enum([
|
|
340
|
+
"running",
|
|
341
|
+
"active",
|
|
342
|
+
"inactive",
|
|
343
|
+
"pendingReview",
|
|
344
|
+
])
|
|
345
|
+
export type PluginProgramLayoutJobStatus = z.infer<
|
|
346
|
+
typeof PluginProgramLayoutJobStatus
|
|
347
|
+
>
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* The state of a layout run.
|
|
351
|
+
*
|
|
352
|
+
* | Property | Type | Description |
|
|
353
|
+
* |---|---|---|
|
|
354
|
+
* | `status` | {@linkcode PluginProgramLayoutJobStatus} | `"running"` \| `"active"` \| `"inactive"` \| `"pendingReview"` |
|
|
355
|
+
* | `totalSolutions` | `number \| undefined` | Number of candidate solutions awaiting review — present only while `status` is `"pendingReview"` |
|
|
356
|
+
*/
|
|
357
|
+
export const PluginProgramLayoutJobState = z.object({
|
|
358
|
+
status: PluginProgramLayoutJobStatus,
|
|
359
|
+
totalSolutions: z.number().int().optional(),
|
|
360
|
+
})
|
|
361
|
+
export type PluginProgramLayoutJobState = z.infer<
|
|
362
|
+
typeof PluginProgramLayoutJobState
|
|
363
|
+
>
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Result of {@linkcode PluginProgramLayoutApi.getState} — the run state, or
|
|
367
|
+
* `null` when no run result is available (never ran or was cancelled).
|
|
368
|
+
*/
|
|
369
|
+
export const PluginProgramLayoutStateResult =
|
|
370
|
+
PluginProgramLayoutJobState.nullable()
|
|
371
|
+
export type PluginProgramLayoutStateResult = z.infer<
|
|
372
|
+
typeof PluginProgramLayoutStateResult
|
|
373
|
+
>
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Arguments for {@linkcode PluginProgramLayoutApi.applySolution}.
|
|
377
|
+
*
|
|
378
|
+
* | Property | Type | Description |
|
|
379
|
+
* |---|---|---|
|
|
380
|
+
* | `index` | `number` | 0-based index of the pending solution to apply (`0 ≤ index < totalSolutions`) |
|
|
381
|
+
*/
|
|
382
|
+
export const PluginProgramLayoutApplySolutionArgs = z.object({
|
|
383
|
+
index: z.number().int().min(0),
|
|
384
|
+
})
|
|
385
|
+
export type PluginProgramLayoutApplySolutionArgs = z.infer<
|
|
386
|
+
typeof PluginProgramLayoutApplySolutionArgs
|
|
387
|
+
>
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Result of {@linkcode PluginProgramLayoutApi.applySolution}.
|
|
391
|
+
*
|
|
392
|
+
* | Property | Type | Description |
|
|
393
|
+
* |---|---|---|
|
|
394
|
+
* | `success` | `boolean` | Whether the chosen solution was applied |
|
|
395
|
+
* | `error` | `string \| undefined` | Failure reason when `success` is `false` |
|
|
396
|
+
*/
|
|
397
|
+
export const PluginProgramLayoutApplyResult = z.object({
|
|
398
|
+
success: z.boolean(),
|
|
399
|
+
error: z.string().optional(),
|
|
400
|
+
})
|
|
401
|
+
export type PluginProgramLayoutApplyResult = z.infer<
|
|
402
|
+
typeof PluginProgramLayoutApplyResult
|
|
403
|
+
>
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Result of {@linkcode PluginProgramLayoutApi.stack} — reports whether the
|
|
407
|
+
* cross-storey stack was applied and which storeys were skipped.
|
|
408
|
+
*
|
|
409
|
+
* | Property | Type | Description |
|
|
410
|
+
* |---|---|---|
|
|
411
|
+
* | `success` | `boolean` | Whether the stack was applied |
|
|
412
|
+
* | `skippedStoreys` | `number[]` | Storey values that had departments but no envelope, so nothing was packed there |
|
|
413
|
+
* | `error` | `string \| undefined` | Failure reason when `success` is `false` |
|
|
414
|
+
*/
|
|
415
|
+
export const PluginProgramLayoutStackResult = z.object({
|
|
416
|
+
success: z.boolean(),
|
|
417
|
+
skippedStoreys: z.array(z.number()),
|
|
418
|
+
error: z.string().optional(),
|
|
419
|
+
})
|
|
420
|
+
export type PluginProgramLayoutStackResult = z.infer<
|
|
421
|
+
typeof PluginProgramLayoutStackResult
|
|
422
|
+
>
|