@snaptrude/plugin-core 0.0.0-dev-20260708130115 → 0.0.0-dev-20260827194031

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 (261) hide show
  1. package/CHANGELOG.md +152 -1
  2. package/api-manifest.json +3643 -276
  3. package/dist/api/analysis/daylight.d.ts +603 -0
  4. package/dist/api/analysis/daylight.d.ts.map +1 -0
  5. package/dist/api/analysis/heatmaps.d.ts +658 -0
  6. package/dist/api/analysis/heatmaps.d.ts.map +1 -0
  7. package/dist/api/analysis/illuminance.d.ts +145 -0
  8. package/dist/api/analysis/illuminance.d.ts.map +1 -0
  9. package/dist/api/analysis/index.d.ts +59 -0
  10. package/dist/api/analysis/index.d.ts.map +1 -0
  11. package/dist/api/analysis/shadows.d.ts +165 -0
  12. package/dist/api/analysis/shadows.d.ts.map +1 -0
  13. package/dist/api/analysis/solar.d.ts +249 -0
  14. package/dist/api/analysis/solar.d.ts.map +1 -0
  15. package/dist/api/analysis/sunlightHours.d.ts +208 -0
  16. package/dist/api/analysis/sunlightHours.d.ts.map +1 -0
  17. package/dist/api/analysis/sunpath.d.ts +80 -0
  18. package/dist/api/analysis/sunpath.d.ts.map +1 -0
  19. package/dist/api/analysis/weather.d.ts +193 -0
  20. package/dist/api/analysis/weather.d.ts.map +1 -0
  21. package/dist/api/core/camera/index.d.ts +261 -0
  22. package/dist/api/core/camera/index.d.ts.map +1 -0
  23. package/dist/api/core/comment/index.d.ts +105 -2
  24. package/dist/api/core/comment/index.d.ts.map +1 -1
  25. package/dist/api/core/geom/create/index.d.ts +840 -14
  26. package/dist/api/core/geom/create/index.d.ts.map +1 -1
  27. package/dist/api/core/geom/delete/index.d.ts +8 -2
  28. package/dist/api/core/geom/delete/index.d.ts.map +1 -1
  29. package/dist/api/core/geom/query/arc.d.ts +5 -5
  30. package/dist/api/core/geom/query/brep.d.ts +130 -18
  31. package/dist/api/core/geom/query/brep.d.ts.map +1 -1
  32. package/dist/api/core/geom/query/circle.d.ts +18 -18
  33. package/dist/api/core/geom/query/contour.d.ts +20 -20
  34. package/dist/api/core/geom/query/curve.d.ts +49 -49
  35. package/dist/api/core/geom/query/edge.d.ts +5 -5
  36. package/dist/api/core/geom/query/face.d.ts +16 -16
  37. package/dist/api/core/geom/query/halfedge.d.ts +8 -8
  38. package/dist/api/core/geom/query/profile.d.ts +19 -19
  39. package/dist/api/core/geom/query/vertex.d.ts +8 -8
  40. package/dist/api/core/geom/update/contour.d.ts +14 -14
  41. package/dist/api/core/geom/update/curve.d.ts +7 -7
  42. package/dist/api/core/geom/update/profile.d.ts +16 -16
  43. package/dist/api/core/handles/index.d.ts +210 -0
  44. package/dist/api/core/handles/index.d.ts.map +1 -0
  45. package/dist/api/core/index.d.ts +34 -0
  46. package/dist/api/core/index.d.ts.map +1 -1
  47. package/dist/api/core/io/export/index.d.ts +134 -0
  48. package/dist/api/core/io/export/index.d.ts.map +1 -0
  49. package/dist/api/core/io/import/index.d.ts +453 -0
  50. package/dist/api/core/io/import/index.d.ts.map +1 -0
  51. package/dist/api/core/io/index.d.ts +40 -0
  52. package/dist/api/core/io/index.d.ts.map +1 -0
  53. package/dist/api/core/io/job/index.d.ts +139 -0
  54. package/dist/api/core/io/job/index.d.ts.map +1 -0
  55. package/dist/api/core/io/query/index.d.ts +74 -0
  56. package/dist/api/core/io/query/index.d.ts.map +1 -0
  57. package/dist/api/core/io/terrain/index.d.ts +341 -0
  58. package/dist/api/core/io/terrain/index.d.ts.map +1 -0
  59. package/dist/api/core/io/underlay/index.d.ts +805 -0
  60. package/dist/api/core/io/underlay/index.d.ts.map +1 -0
  61. package/dist/api/core/layers.d.ts +7 -7
  62. package/dist/api/core/mode/index.d.ts +99 -0
  63. package/dist/api/core/mode/index.d.ts.map +1 -0
  64. package/dist/api/core/project/index.d.ts +68 -1
  65. package/dist/api/core/project/index.d.ts.map +1 -1
  66. package/dist/api/core/proposals/index.d.ts +531 -0
  67. package/dist/api/core/proposals/index.d.ts.map +1 -0
  68. package/dist/api/core/storeys/index.d.ts +265 -0
  69. package/dist/api/core/storeys/index.d.ts.map +1 -0
  70. package/dist/api/core/tags.d.ts +24 -0
  71. package/dist/api/core/tags.d.ts.map +1 -1
  72. package/dist/api/core/user.d.ts +44 -0
  73. package/dist/api/core/user.d.ts.map +1 -0
  74. package/dist/api/core/zoom/index.d.ts +4 -0
  75. package/dist/api/core/zoom/index.d.ts.map +1 -1
  76. package/dist/api/design/boolean/index.d.ts +4 -4
  77. package/dist/api/design/create/index.d.ts +568 -45
  78. package/dist/api/design/create/index.d.ts.map +1 -1
  79. package/dist/api/design/delete/index.d.ts +3 -0
  80. package/dist/api/design/delete/index.d.ts.map +1 -1
  81. package/dist/api/design/doors/index.d.ts +195 -0
  82. package/dist/api/design/doors/index.d.ts.map +1 -1
  83. package/dist/api/design/edit/index.d.ts +1 -1
  84. package/dist/api/design/erase/index.d.ts +2 -2
  85. package/dist/api/design/family.d.ts +493 -0
  86. package/dist/api/design/family.d.ts.map +1 -0
  87. package/dist/api/design/furniture/index.d.ts +181 -8
  88. package/dist/api/design/furniture/index.d.ts.map +1 -1
  89. package/dist/api/design/index.d.ts +98 -0
  90. package/dist/api/design/index.d.ts.map +1 -1
  91. package/dist/api/design/lock.d.ts +26 -0
  92. package/dist/api/design/lock.d.ts.map +1 -1
  93. package/dist/api/design/materials/index.d.ts +270 -16
  94. package/dist/api/design/materials/index.d.ts.map +1 -1
  95. package/dist/api/design/query/geometry/index.d.ts +112 -0
  96. package/dist/api/design/query/geometry/index.d.ts.map +1 -1
  97. package/dist/api/design/query/index.d.ts +289 -11
  98. package/dist/api/design/query/index.d.ts.map +1 -1
  99. package/dist/api/design/query/referenceLines.d.ts +45 -0
  100. package/dist/api/design/query/referenceLines.d.ts.map +1 -0
  101. package/dist/api/design/query/spaces.d.ts +181 -8
  102. package/dist/api/design/query/spaces.d.ts.map +1 -1
  103. package/dist/api/design/selection/index.d.ts +144 -0
  104. package/dist/api/design/selection/index.d.ts.map +1 -1
  105. package/dist/api/design/transform/index.d.ts +172 -10
  106. package/dist/api/design/transform/index.d.ts.map +1 -1
  107. package/dist/api/design/types/index.d.ts +181 -0
  108. package/dist/api/design/types/index.d.ts.map +1 -0
  109. package/dist/api/design/update/index.d.ts +553 -2
  110. package/dist/api/design/update/index.d.ts.map +1 -1
  111. package/dist/api/design/visibility.d.ts +126 -0
  112. package/dist/api/design/visibility.d.ts.map +1 -0
  113. package/dist/api/design/windows/index.d.ts +113 -2
  114. package/dist/api/design/windows/index.d.ts.map +1 -1
  115. package/dist/api/entity/buildableEnvelope.d.ts +4 -0
  116. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -1
  117. package/dist/api/entity/referenceLine.d.ts +10 -2
  118. package/dist/api/entity/referenceLine.d.ts.map +1 -1
  119. package/dist/api/entity/space.d.ts +21 -21
  120. package/dist/api/entity/story.d.ts +242 -15
  121. package/dist/api/entity/story.d.ts.map +1 -1
  122. package/dist/api/index.d.ts +10 -0
  123. package/dist/api/index.d.ts.map +1 -1
  124. package/dist/api/presentation/aiInspiration.d.ts +25 -25
  125. package/dist/api/presentation/annotate.d.ts +467 -0
  126. package/dist/api/presentation/annotate.d.ts.map +1 -0
  127. package/dist/api/presentation/diagrams.d.ts +111 -8
  128. package/dist/api/presentation/diagrams.d.ts.map +1 -1
  129. package/dist/api/presentation/export.d.ts +108 -0
  130. package/dist/api/presentation/export.d.ts.map +1 -0
  131. package/dist/api/presentation/import.d.ts +55 -4
  132. package/dist/api/presentation/import.d.ts.map +1 -1
  133. package/dist/api/presentation/index.d.ts +58 -1
  134. package/dist/api/presentation/index.d.ts.map +1 -1
  135. package/dist/api/presentation/placedViews.d.ts +1139 -0
  136. package/dist/api/presentation/placedViews.d.ts.map +1 -0
  137. package/dist/api/presentation/shapes.d.ts +481 -0
  138. package/dist/api/presentation/shapes.d.ts.map +1 -0
  139. package/dist/api/presentation/sheets.d.ts +452 -13
  140. package/dist/api/presentation/sheets.d.ts.map +1 -1
  141. package/dist/api/presentation/slideshow.d.ts +125 -0
  142. package/dist/api/presentation/slideshow.d.ts.map +1 -0
  143. package/dist/api/presentation/tables.d.ts +81 -0
  144. package/dist/api/presentation/tables.d.ts.map +1 -0
  145. package/dist/api/presentation/views.d.ts +367 -7
  146. package/dist/api/presentation/views.d.ts.map +1 -1
  147. package/dist/api/program/areas.d.ts +102 -12
  148. package/dist/api/program/areas.d.ts.map +1 -1
  149. package/dist/api/program/cores.d.ts +3 -99
  150. package/dist/api/program/cores.d.ts.map +1 -1
  151. package/dist/api/program/index.d.ts +7 -15
  152. package/dist/api/program/index.d.ts.map +1 -1
  153. package/dist/api/program/layout.d.ts +346 -11
  154. package/dist/api/program/layout.d.ts.map +1 -1
  155. package/dist/api/program/site.d.ts +469 -13
  156. package/dist/api/program/site.d.ts.map +1 -1
  157. package/dist/api/program/spreadsheet.d.ts +365 -41
  158. package/dist/api/program/spreadsheet.d.ts.map +1 -1
  159. package/dist/api/workspace/index.d.ts +505 -0
  160. package/dist/api/workspace/index.d.ts.map +1 -0
  161. package/dist/errors/codes.d.ts +34 -0
  162. package/dist/errors/codes.d.ts.map +1 -0
  163. package/dist/errors/envelope.d.ts +56 -0
  164. package/dist/errors/envelope.d.ts.map +1 -0
  165. package/dist/errors/index.d.ts +6 -0
  166. package/dist/errors/index.d.ts.map +1 -0
  167. package/dist/errors/plugin-error.d.ts +69 -0
  168. package/dist/errors/plugin-error.d.ts.map +1 -0
  169. package/dist/handles.d.ts +97 -25
  170. package/dist/handles.d.ts.map +1 -1
  171. package/dist/host-utils.d.ts +4 -0
  172. package/dist/host-utils.d.ts.map +1 -1
  173. package/dist/index.cjs +4605 -1423
  174. package/dist/index.cjs.map +1 -1
  175. package/dist/index.d.ts +1 -0
  176. package/dist/index.d.ts.map +1 -1
  177. package/dist/index.js +4191 -1412
  178. package/dist/index.js.map +1 -1
  179. package/package.json +4 -2
  180. package/scripts/generate-manifest.mjs +45 -0
  181. package/scripts/generate-manifest.test.mjs +103 -4
  182. package/src/api/analysis/daylight.ts +470 -0
  183. package/src/api/analysis/heatmaps.ts +683 -0
  184. package/src/api/analysis/illuminance.ts +155 -0
  185. package/src/api/analysis/index.ts +61 -0
  186. package/src/api/analysis/shadows.ts +183 -0
  187. package/src/api/analysis/solar.ts +237 -0
  188. package/src/api/analysis/sunlightHours.ts +211 -0
  189. package/src/api/analysis/sunpath.ts +83 -0
  190. package/src/api/analysis/weather.ts +179 -0
  191. package/src/api/core/camera/index.ts +268 -0
  192. package/src/api/core/comment/index.ts +120 -2
  193. package/src/api/core/geom/create/index.ts +912 -1
  194. package/src/api/core/geom/delete/index.ts +6 -0
  195. package/src/api/core/geom/query/brep.ts +119 -0
  196. package/src/api/core/handles/index.ts +233 -0
  197. package/src/api/core/index.ts +34 -0
  198. package/src/api/core/io/export/index.ts +126 -0
  199. package/src/api/core/io/import/index.ts +496 -0
  200. package/src/api/core/io/index.ts +42 -0
  201. package/src/api/core/io/job/index.ts +140 -0
  202. package/src/api/core/io/query/index.ts +71 -0
  203. package/src/api/core/io/terrain/index.ts +360 -0
  204. package/src/api/core/io/underlay/index.ts +705 -0
  205. package/src/api/core/mode/index.ts +96 -0
  206. package/src/api/core/project/index.ts +62 -1
  207. package/src/api/core/proposals/index.ts +569 -0
  208. package/src/api/core/storeys/index.ts +294 -0
  209. package/src/api/core/tags.ts +27 -0
  210. package/src/api/core/user.ts +46 -0
  211. package/src/api/core/zoom/index.ts +4 -0
  212. package/src/api/design/create/index.ts +670 -30
  213. package/src/api/design/delete/index.ts +3 -0
  214. package/src/api/design/doors/index.ts +208 -0
  215. package/src/api/design/erase/index.ts +1 -1
  216. package/src/api/design/family.ts +544 -0
  217. package/src/api/design/furniture/index.ts +197 -8
  218. package/src/api/design/index.ts +102 -0
  219. package/src/api/design/lock.ts +27 -0
  220. package/src/api/design/materials/index.ts +334 -27
  221. package/src/api/design/query/geometry/index.ts +125 -3
  222. package/src/api/design/query/index.ts +219 -7
  223. package/src/api/design/query/referenceLines.ts +52 -0
  224. package/src/api/design/query/spaces.ts +143 -0
  225. package/src/api/design/selection/index.ts +129 -0
  226. package/src/api/design/transform/index.ts +170 -9
  227. package/src/api/design/types/index.ts +156 -0
  228. package/src/api/design/update/index.ts +631 -3
  229. package/src/api/design/visibility.ts +143 -0
  230. package/src/api/design/windows/index.ts +128 -2
  231. package/src/api/entity/buildableEnvelope.ts +4 -0
  232. package/src/api/entity/referenceLine.ts +8 -0
  233. package/src/api/entity/story.ts +259 -15
  234. package/src/api/index.ts +10 -0
  235. package/src/api/presentation/annotate.ts +385 -0
  236. package/src/api/presentation/diagrams.ts +118 -8
  237. package/src/api/presentation/export.ts +108 -0
  238. package/src/api/presentation/import.ts +51 -4
  239. package/src/api/presentation/index.ts +66 -1
  240. package/src/api/presentation/placedViews.ts +1120 -0
  241. package/src/api/presentation/shapes.ts +274 -0
  242. package/src/api/presentation/sheets.ts +400 -13
  243. package/src/api/presentation/slideshow.ts +134 -0
  244. package/src/api/presentation/tables.ts +84 -0
  245. package/src/api/presentation/views.ts +376 -8
  246. package/src/api/program/areas.ts +88 -15
  247. package/src/api/program/cores.ts +3 -91
  248. package/src/api/program/index.ts +7 -15
  249. package/src/api/program/layout.ts +365 -11
  250. package/src/api/program/site.ts +435 -13
  251. package/src/api/program/spreadsheet.ts +376 -35
  252. package/src/api/workspace/index.ts +563 -0
  253. package/src/errors/codes.ts +136 -0
  254. package/src/errors/envelope.ts +75 -0
  255. package/src/errors/index.ts +21 -0
  256. package/src/errors/plugin-error.ts +134 -0
  257. package/src/handles.ts +123 -13
  258. package/src/host-utils.ts +4 -0
  259. package/src/index.ts +1 -0
  260. package/test/errors.test.mjs +184 -0
  261. package/tsconfig.json +7 -2
@@ -0,0 +1,569 @@
1
+ import * as z from "zod"
2
+ import { PluginApiReturn } from "../../../types"
3
+ import { ComponentHandle } from "../../../handles"
4
+
5
+ /**
6
+ * Proposals — read and edit the project's design options ("proposals").
7
+ *
8
+ * A **proposal** is a design option: one of several variants of the same
9
+ * project. Each proposal owns a set of buckets (a bucket == a drawing layer),
10
+ * and switching the active proposal shows/hides the buckets it owns. Proposals
11
+ * are **infrastructure**, not design — they own the buckets/layers geometry
12
+ * lives in — so they sit under `core`, not `design` (constitution §2A).
13
+ *
14
+ * Reads return plain records and never throw for a missing proposal (`get` and
15
+ * `getActive` return `null`, `list` / `listForComponent` return an empty list,
16
+ * `isActive` returns `false`). Ids are stable public strings.
17
+ *
18
+ * On legacy / no-proposal projects the scoping predicates degrade gracefully:
19
+ * `getActive` returns `null` and the reads return empty.
20
+ *
21
+ * Proposal writes are **not undoable** — create / rename / setActive / delete
22
+ * persist directly and bypass the undo stack; a `core.history.undo` will not
23
+ * reverse them. Each proposal keeps its own isolated undo stack for the
24
+ * geometry edits made inside it.
25
+ *
26
+ * Accessed via `snaptrude.core.proposals`.
27
+ */
28
+ export abstract class PluginCoreProposalsApi {
29
+ constructor() {}
30
+
31
+ /**
32
+ * List the design options (proposals) in the active project.
33
+ *
34
+ * @returns A {@linkcode PluginCoreProposalsListResult} with a `proposals`
35
+ * array (empty on a legacy / no-proposal project).
36
+ *
37
+ * @examplePrompt List all the design options in this project
38
+ * @examplePrompt How many proposals does this project have?
39
+ * @examplePrompt Show every design variant with its name
40
+ *
41
+ * # Example
42
+ * ```ts
43
+ * const { proposals } = await snaptrude.core.proposals.list()
44
+ * for (const p of proposals) console.log(p.id, p.name, p.isActive)
45
+ * ```
46
+ */
47
+ public abstract list(): PluginApiReturn<PluginCoreProposalsListResult>
48
+
49
+ /**
50
+ * Get a single proposal by id.
51
+ *
52
+ * @param proposalId - The id of the proposal to read.
53
+ * @returns The matching {@linkcode PluginCoreProposalRef}, or `null` if no
54
+ * proposal has that id.
55
+ *
56
+ * @examplePrompt Get the proposal with id prop_1
57
+ * @examplePrompt Look up a single design option by its id
58
+ * @examplePrompt Which buckets belong to proposal prop_2?
59
+ *
60
+ * # Example
61
+ * ```ts
62
+ * const proposal = await snaptrude.core.proposals.get("prop_1")
63
+ * if (proposal) console.log(proposal.name, proposal.bucketIds)
64
+ * ```
65
+ */
66
+ public abstract get(
67
+ proposalId: string,
68
+ ): PluginApiReturn<PluginCoreProposalsGetResult>
69
+
70
+ /**
71
+ * Get the active proposal.
72
+ *
73
+ * The active proposal is the design option currently shown and edited.
74
+ * Honors a present-mode capture override: while a present-mode capture is in
75
+ * flight this returns the captured proposal, not the redux-active one. Paired
76
+ * with {@linkcode PluginCoreProposalsApi.setActive}.
77
+ *
78
+ * @returns The active {@linkcode PluginCoreProposalRef}, or `null` on a legacy
79
+ * / no-proposal project where nothing is active.
80
+ *
81
+ * @examplePrompt Which design option is active?
82
+ * @examplePrompt Get the current proposal
83
+ * @examplePrompt What proposal am I working in?
84
+ *
85
+ * # Example
86
+ * ```ts
87
+ * const active = await snaptrude.core.proposals.getActive()
88
+ * if (active) console.log(active.id, active.name)
89
+ * ```
90
+ */
91
+ public abstract getActive(): PluginApiReturn<PluginCoreProposalsGetActiveResult>
92
+
93
+ /**
94
+ * List the proposals a component belongs to.
95
+ *
96
+ * Returns **every** proposal whose buckets include the component — a bucket
97
+ * can be shared across proposals, so a component may appear in more than one.
98
+ *
99
+ * @param component - The component to look up.
100
+ * @returns A {@linkcode PluginCoreProposalsListForComponentResult} with a
101
+ * `proposals` array (empty when the component is out of scope or the project
102
+ * has no proposals).
103
+ *
104
+ * @examplePrompt Which design options is this component part of?
105
+ * @examplePrompt List the proposals that contain this wall
106
+ * @examplePrompt Is this element shared across multiple design variants?
107
+ *
108
+ * # Example
109
+ * ```ts
110
+ * const { proposals } = await snaptrude.core.proposals.listForComponent(wall)
111
+ * console.log(`shared across ${proposals.length} proposals`)
112
+ * ```
113
+ */
114
+ public abstract listForComponent(
115
+ component: ComponentHandle,
116
+ ): PluginApiReturn<PluginCoreProposalsListForComponentResult>
117
+
118
+ /**
119
+ * Test whether a proposal is the active one.
120
+ *
121
+ * @param proposalId - The id of the proposal to test.
122
+ * @returns `true` if it is the active proposal, otherwise `false` (including
123
+ * when no proposal has that id).
124
+ *
125
+ * @examplePrompt Is proposal prop_2 the active one?
126
+ * @examplePrompt Check whether this design option is currently shown
127
+ * @examplePrompt Am I working in proposal prop_1?
128
+ *
129
+ * # Example
130
+ * ```ts
131
+ * if (await snaptrude.core.proposals.isActive("prop_1")) {
132
+ * console.log("prop_1 is active")
133
+ * }
134
+ * ```
135
+ */
136
+ public abstract isActive(proposalId: string): PluginApiReturn<boolean>
137
+
138
+ /**
139
+ * Create a new design option (proposal) — blank, or configured from a base
140
+ * proposal (the New Proposal modal's two paths).
141
+ *
142
+ * **Pro-gated** (creating proposals requires a Pro plan, matching the UI) and
143
+ * **not undoable**. The name is capped at 24 characters.
144
+ *
145
+ * **Blank** (no `options`) — creates a bare proposal with a single empty
146
+ * default bucket; it does **not** carry forward the current proposal's
147
+ * layers, views, or targets, and the active proposal does **not** change.
148
+ *
149
+ * **Configured** (`options.baseProposalId`) — the modal's Configure path:
150
+ * carries the base proposal's buckets (layers) forward per `options.layers`,
151
+ * where each entry names a bucket of the base proposal and an action —
152
+ * `"share"` (the new proposal references the same live bucket) or
153
+ * `"duplicate"` (an independent copy of the bucket and its contents).
154
+ * Buckets not listed are left behind. Omitting `layers` carries **every**
155
+ * base bucket forward as a `"duplicate"` (the modal's default). The base
156
+ * proposal's views and area targets are copied either way, and the new
157
+ * proposal becomes the **active** one (implicit switch — blocked with
158
+ * `PROPOSAL_SWITCH_BLOCKED` while an in-canvas agent run is in flight, like
159
+ * {@linkcode PluginCoreProposalsApi.setActive}).
160
+ *
161
+ * @param name - Display name of the new proposal (capped at 24 chars).
162
+ * @param options - Optional configure path: `baseProposalId` (the proposal to
163
+ * carry forward from) and `layers` (per-bucket `"share"` / `"duplicate"`
164
+ * actions; omitted buckets are excluded, omitted `layers` duplicates all).
165
+ * @returns The new proposal's id (read the full record back with
166
+ * {@linkcode PluginCoreProposalsApi.get}).
167
+ * @throws If the caller is not on a Pro plan, the name is empty/duplicate,
168
+ * `layers` is passed without `baseProposalId`, the base proposal or a
169
+ * listed bucket does not exist / does not belong to the base proposal, or
170
+ * (configured only) `PROPOSAL_SWITCH_BLOCKED` while a canvas-agent run is
171
+ * in flight.
172
+ *
173
+ * @examplePrompt Create a design option called Scheme B
174
+ * @examplePrompt Add a new proposal named Option 2
175
+ * @examplePrompt Duplicate the current proposal as Scheme C
176
+ * @examplePrompt Create a design option based on Proposal 1 that shares its site layer
177
+ *
178
+ * # Example
179
+ * ```ts
180
+ * // blank design option
181
+ * const { id } = await snaptrude.core.proposals.create("Scheme B")
182
+ *
183
+ * // configured from the active proposal: duplicate every layer
184
+ * const base = await snaptrude.core.proposals.getActive()
185
+ * if (base) {
186
+ * const { id: dup } = await snaptrude.core.proposals.create("Scheme C", {
187
+ * baseProposalId: base.id,
188
+ * })
189
+ * // …or share one layer and leave the rest behind
190
+ * const { id: shared } = await snaptrude.core.proposals.create("Scheme D", {
191
+ * baseProposalId: base.id,
192
+ * layers: [{ bucketId: base.defaultBucketId, action: "share" }],
193
+ * })
194
+ * }
195
+ * ```
196
+ */
197
+ public abstract create(
198
+ name: string,
199
+ options?: {
200
+ baseProposalId: string
201
+ layers?: { bucketId: string; action: "share" | "duplicate" }[]
202
+ },
203
+ ): PluginApiReturn<PluginCoreProposalsCreateResult>
204
+
205
+ /**
206
+ * Rename a proposal.
207
+ *
208
+ * **Not undoable.** The name is capped at 24 characters.
209
+ *
210
+ * @param proposalId - The id of the proposal to rename.
211
+ * @param name - The new display name (capped at 24 chars).
212
+ * @returns The updated {@linkcode PluginCoreProposalRef}.
213
+ * @throws If no proposal has the given id, or the name is empty / duplicates
214
+ * another proposal.
215
+ *
216
+ * @examplePrompt Rename proposal prop_1 to Final Scheme
217
+ * @examplePrompt Change the name of this design option
218
+ * @examplePrompt Call proposal prop_2 "Option A"
219
+ *
220
+ * # Example
221
+ * ```ts
222
+ * const proposal = await snaptrude.core.proposals.rename("prop_1", "Final Scheme")
223
+ * ```
224
+ */
225
+ public abstract rename(
226
+ proposalId: string,
227
+ name: string,
228
+ ): PluginApiReturn<PluginCoreProposalsRenameResult>
229
+
230
+ /**
231
+ * Switch the active proposal.
232
+ *
233
+ * A **heavy scene switch** and **not undoable**. Switching clears the current
234
+ * selection, resets AI / streaming state, cancels proposal-scoped operations,
235
+ * retoggles bucket visibility to the new proposal's owned set, restores its
236
+ * per-proposal site/FSI settings, and realigns the views panel. After the
237
+ * switch, **writes** are guarded to the new active proposal (edits targeting
238
+ * components outside it are rejected), but **list reads are NOT
239
+ * proposal-filtered** — `design.query.list*` and similar reads stay
240
+ * project-wide; filter their results via
241
+ * {@linkcode PluginCoreProposalsApi.listForComponent} if you need
242
+ * proposal-scoped sets.
243
+ *
244
+ * **Blocked while an in-canvas agent run is in flight** — throws
245
+ * `PROPOSAL_SWITCH_BLOCKED` if a canvas-agent run is active (matching the UI's
246
+ * hard block), because a switch would cancel the in-flight run.
247
+ *
248
+ * @param proposalId - The id of the proposal to activate.
249
+ * @returns The id of the now-active proposal.
250
+ * @throws `PROPOSAL_SWITCH_BLOCKED` while a canvas-agent run is in flight; or
251
+ * if no proposal has the given id.
252
+ *
253
+ * @examplePrompt Switch to proposal prop_2
254
+ * @examplePrompt Make Scheme B the active design option
255
+ * @examplePrompt Show me the other proposal
256
+ *
257
+ * # Example
258
+ * ```ts
259
+ * await snaptrude.core.proposals.setActive("prop_2")
260
+ * ```
261
+ */
262
+ public abstract setActive(
263
+ proposalId: string,
264
+ ): PluginApiReturn<PluginCoreProposalsSetActiveResult>
265
+
266
+ /**
267
+ * Delete a proposal.
268
+ *
269
+ * **DANGEROUS AND IRREVERSIBLE — not undoable.** You must choose **exactly
270
+ * one** explicit disposition (mirroring the product's delete dialog):
271
+ *
272
+ * - `{ deleteObjects: true }` — delete the proposal AND **permanently
273
+ * destroy the geometry** in its exclusive buckets. Buckets shared with
274
+ * other proposals are never destroyed.
275
+ * - `{ targetProposalId }` — transfer **all** of this proposal's buckets to
276
+ * another proposal first (keeping the geometry alive), then delete the
277
+ * emptied proposal — "merge and remove". The target must be a
278
+ * **different** proposal.
279
+ *
280
+ * A bare `delete(proposalId)` is **rejected**: there is no safe default —
281
+ * without a disposition the engine would drop the proposal's bucket records
282
+ * while leaving their components orphaned. Passing both dispositions at once
283
+ * is also rejected as ambiguous.
284
+ *
285
+ * It is **server-validated**: the backend refuses the delete (throws) if a
286
+ * collaborator is active in that proposal, and the check times out after
287
+ * ~10s. The project's **last remaining proposal cannot be deleted**. If the
288
+ * proposal is active, the host switches away first.
289
+ *
290
+ * @param proposalId - The id of the proposal to delete.
291
+ * @param options - Exactly one disposition: `{ deleteObjects: true }`
292
+ * (destroy exclusive-bucket geometry) or `{ targetProposalId }` (transfer
293
+ * buckets to that proposal, then delete).
294
+ * @returns Confirmation that the proposal was deleted.
295
+ * @throws If no disposition (or both) is given, `targetProposalId` equals
296
+ * `proposalId`, no proposal has the given id, it is the only proposal, a
297
+ * collaborator lock refuses the delete, or the server validation times out.
298
+ *
299
+ * @examplePrompt Delete proposal prop_2 and everything in it
300
+ * @examplePrompt Remove this design option and destroy its geometry
301
+ * @examplePrompt Merge prop_2's layers into prop_1 and delete prop_2
302
+ *
303
+ * # Example
304
+ * ```ts
305
+ * // destroy the proposal and its exclusive geometry
306
+ * await snaptrude.core.proposals.delete("prop_2", { deleteObjects: true })
307
+ * // …or keep the geometry by transferring its buckets to prop_1 first
308
+ * await snaptrude.core.proposals.delete("prop_2", { targetProposalId: "prop_1" })
309
+ * ```
310
+ */
311
+ public abstract delete(
312
+ proposalId: string,
313
+ options:
314
+ | { deleteObjects: true; targetProposalId?: never }
315
+ | { deleteObjects?: false; targetProposalId: string },
316
+ ): PluginApiReturn<PluginCoreProposalsDeleteResult>
317
+ }
318
+
319
+ /**
320
+ * A design option (proposal) in the active project.
321
+ *
322
+ * | Property | Type | Description |
323
+ * |---|---|---|
324
+ * | `id` | `string` | Stable public proposal id (e.g. `"prop_1"`) |
325
+ * | `name` | `string` | Display name (≤ 24 chars) |
326
+ * | `isActive` | `boolean` | Whether this is the active proposal |
327
+ * | `defaultBucketId` | `string` | Id of the proposal's default bucket (cannot be unshared) |
328
+ * | `bucketIds` | `string[]` | Ids of every bucket (layer) the proposal owns |
329
+ * | `createdAt` | `string` | ISO creation timestamp |
330
+ * | `createdBy` | `string` | User id of the creator |
331
+ */
332
+ export const PluginCoreProposalRef = z.object({
333
+ id: z.string(),
334
+ name: z.string(),
335
+ isActive: z.boolean(),
336
+ defaultBucketId: z.string(),
337
+ bucketIds: z.array(z.string()),
338
+ createdAt: z.string(),
339
+ createdBy: z.string(),
340
+ })
341
+ export type PluginCoreProposalRef = z.infer<typeof PluginCoreProposalRef>
342
+
343
+ /**
344
+ * Result of {@linkcode PluginCoreProposalsApi.list}.
345
+ *
346
+ * | Property | Type | Description |
347
+ * |---|---|---|
348
+ * | `proposals` | {@linkcode PluginCoreProposalRef}`[]` | Every proposal in the active project |
349
+ */
350
+ export const PluginCoreProposalsListResult = z.object({
351
+ proposals: z.array(PluginCoreProposalRef),
352
+ })
353
+ export type PluginCoreProposalsListResult = z.infer<
354
+ typeof PluginCoreProposalsListResult
355
+ >
356
+
357
+ /**
358
+ * Arguments for {@linkcode PluginCoreProposalsApi.get} /
359
+ * {@linkcode PluginCoreProposalsApi.isActive}.
360
+ *
361
+ * | Property | Type | Description |
362
+ * |---|---|---|
363
+ * | `proposalId` | `string` | The id of the proposal |
364
+ */
365
+ export const PluginCoreProposalsGetArgs = z.object({
366
+ proposalId: z.string(),
367
+ })
368
+ export type PluginCoreProposalsGetArgs = z.infer<
369
+ typeof PluginCoreProposalsGetArgs
370
+ >
371
+
372
+ /**
373
+ * Result of {@linkcode PluginCoreProposalsApi.get} — the proposal, or `null`
374
+ * when no proposal has the given id.
375
+ */
376
+ export const PluginCoreProposalsGetResult = PluginCoreProposalRef.nullable()
377
+ export type PluginCoreProposalsGetResult = z.infer<
378
+ typeof PluginCoreProposalsGetResult
379
+ >
380
+
381
+ /**
382
+ * Result of {@linkcode PluginCoreProposalsApi.getActive} — the active proposal,
383
+ * or `null` when nothing is active (legacy / no-proposal project).
384
+ */
385
+ export const PluginCoreProposalsGetActiveResult =
386
+ PluginCoreProposalRef.nullable()
387
+ export type PluginCoreProposalsGetActiveResult = z.infer<
388
+ typeof PluginCoreProposalsGetActiveResult
389
+ >
390
+
391
+ /**
392
+ * Arguments for {@linkcode PluginCoreProposalsApi.listForComponent}.
393
+ *
394
+ * | Property | Type | Description |
395
+ * |---|---|---|
396
+ * | `component` | {@linkcode ComponentHandle} | The component to look up |
397
+ */
398
+ export const PluginCoreProposalsListForComponentArgs = z.object({
399
+ component: ComponentHandle,
400
+ })
401
+ export type PluginCoreProposalsListForComponentArgs = z.infer<
402
+ typeof PluginCoreProposalsListForComponentArgs
403
+ >
404
+
405
+ /**
406
+ * Result of {@linkcode PluginCoreProposalsApi.listForComponent} — the proposals
407
+ * the component belongs to (empty when out of scope or none). Same shape as
408
+ * {@linkcode PluginCoreProposalsListResult}.
409
+ */
410
+ export const PluginCoreProposalsListForComponentResult =
411
+ PluginCoreProposalsListResult
412
+ export type PluginCoreProposalsListForComponentResult = z.infer<
413
+ typeof PluginCoreProposalsListForComponentResult
414
+ >
415
+
416
+ /**
417
+ * Arguments for {@linkcode PluginCoreProposalsApi.isActive}. Alias of
418
+ * {@linkcode PluginCoreProposalsGetArgs}.
419
+ */
420
+ export const PluginCoreProposalsIsActiveArgs = PluginCoreProposalsGetArgs
421
+ export type PluginCoreProposalsIsActiveArgs = z.infer<
422
+ typeof PluginCoreProposalsIsActiveArgs
423
+ >
424
+
425
+ /**
426
+ * Arguments for {@linkcode PluginCoreProposalsApi.create}. A bare `name` makes
427
+ * a blank proposal; `baseProposalId` switches to the configured (carry-forward)
428
+ * path. `layers` requires `baseProposalId` — each entry names a bucket of the
429
+ * base proposal; omitted buckets are excluded, and omitting `layers` entirely
430
+ * duplicates every base bucket.
431
+ *
432
+ * | Property | Type | Description |
433
+ * |---|---|---|
434
+ * | `name` | `string` | Display name of the new proposal (capped at 24 chars) |
435
+ * | `baseProposalId` | `string \| undefined` | Proposal to carry forward from (configured path) |
436
+ * | `layers` | `{ bucketId: string; action: "share" \| "duplicate" }[] \| undefined` | Per-bucket carry-forward actions (requires `baseProposalId`) |
437
+ */
438
+ export const PluginCoreProposalsCreateArgs = z
439
+ .object({
440
+ name: z.string(),
441
+ baseProposalId: z.string().optional(),
442
+ layers: z
443
+ .array(
444
+ z.object({
445
+ bucketId: z.string(),
446
+ action: z.enum(["share", "duplicate"]),
447
+ }),
448
+ )
449
+ .optional(),
450
+ })
451
+ .refine((v) => v.layers === undefined || v.baseProposalId !== undefined, {
452
+ message:
453
+ "layers requires baseProposalId — the layers describe how to carry the base proposal's buckets forward",
454
+ })
455
+ export type PluginCoreProposalsCreateArgs = z.infer<
456
+ typeof PluginCoreProposalsCreateArgs
457
+ >
458
+
459
+ /**
460
+ * Result of {@linkcode PluginCoreProposalsApi.create} — the id of the new
461
+ * proposal.
462
+ *
463
+ * | Property | Type | Description |
464
+ * |---|---|---|
465
+ * | `id` | `string` | The id of the newly created proposal |
466
+ */
467
+ export const PluginCoreProposalsCreateResult = z.object({
468
+ id: z.string(),
469
+ })
470
+ export type PluginCoreProposalsCreateResult = z.infer<
471
+ typeof PluginCoreProposalsCreateResult
472
+ >
473
+
474
+ /**
475
+ * Arguments for {@linkcode PluginCoreProposalsApi.rename}.
476
+ *
477
+ * | Property | Type | Description |
478
+ * |---|---|---|
479
+ * | `proposalId` | `string` | The id of the proposal to rename |
480
+ * | `name` | `string` | The new display name (capped at 24 chars) |
481
+ */
482
+ export const PluginCoreProposalsRenameArgs = z.object({
483
+ proposalId: z.string(),
484
+ name: z.string(),
485
+ })
486
+ export type PluginCoreProposalsRenameArgs = z.infer<
487
+ typeof PluginCoreProposalsRenameArgs
488
+ >
489
+
490
+ /** Result of {@linkcode PluginCoreProposalsApi.rename} — the updated record. */
491
+ export const PluginCoreProposalsRenameResult = PluginCoreProposalRef
492
+ export type PluginCoreProposalsRenameResult = z.infer<
493
+ typeof PluginCoreProposalsRenameResult
494
+ >
495
+
496
+ /**
497
+ * Arguments for {@linkcode PluginCoreProposalsApi.setActive}.
498
+ *
499
+ * | Property | Type | Description |
500
+ * |---|---|---|
501
+ * | `proposalId` | `string` | The id of the proposal to activate |
502
+ */
503
+ export const PluginCoreProposalsSetActiveArgs = z.object({
504
+ proposalId: z.string(),
505
+ })
506
+ export type PluginCoreProposalsSetActiveArgs = z.infer<
507
+ typeof PluginCoreProposalsSetActiveArgs
508
+ >
509
+
510
+ /**
511
+ * Result of {@linkcode PluginCoreProposalsApi.setActive} — the now-active
512
+ * proposal's id.
513
+ *
514
+ * | Property | Type | Description |
515
+ * |---|---|---|
516
+ * | `id` | `string` | The id of the now-active proposal |
517
+ */
518
+ export const PluginCoreProposalsSetActiveResult = z.object({
519
+ id: z.string(),
520
+ })
521
+ export type PluginCoreProposalsSetActiveResult = z.infer<
522
+ typeof PluginCoreProposalsSetActiveResult
523
+ >
524
+
525
+ /**
526
+ * Arguments for {@linkcode PluginCoreProposalsApi.delete}. Exactly one
527
+ * disposition is required: `deleteObjects: true` XOR `targetProposalId` (a
528
+ * **different** proposal). A bare delete with neither is rejected.
529
+ *
530
+ * | Property | Type | Description |
531
+ * |---|---|---|
532
+ * | `proposalId` | `string` | The id of the proposal to delete |
533
+ * | `deleteObjects` | `true \| undefined` | Destroy the geometry in exclusive buckets (mutually exclusive with `targetProposalId`) |
534
+ * | `targetProposalId` | `string \| undefined` | Transfer this proposal's buckets here before deleting (must differ from `proposalId`) |
535
+ */
536
+ export const PluginCoreProposalsDeleteArgs = z
537
+ .object({
538
+ proposalId: z.string(),
539
+ deleteObjects: z.boolean().optional(),
540
+ targetProposalId: z.string().optional(),
541
+ })
542
+ .refine((v) => (v.deleteObjects === true) !== (v.targetProposalId != null), {
543
+ message:
544
+ "Provide exactly one disposition: deleteObjects: true (destroy exclusive-bucket geometry) or targetProposalId (transfer buckets, then delete)",
545
+ })
546
+ .refine(
547
+ (v) => v.targetProposalId == null || v.targetProposalId !== v.proposalId,
548
+ {
549
+ message: "targetProposalId must be a different proposal than proposalId",
550
+ },
551
+ )
552
+ export type PluginCoreProposalsDeleteArgs = z.infer<
553
+ typeof PluginCoreProposalsDeleteArgs
554
+ >
555
+
556
+ /**
557
+ * Result of {@linkcode PluginCoreProposalsApi.delete} — confirmation that the
558
+ * proposal was deleted.
559
+ *
560
+ * | Property | Type | Description |
561
+ * |---|---|---|
562
+ * | `deleted` | `true` | Always `true` on success |
563
+ */
564
+ export const PluginCoreProposalsDeleteResult = z.object({
565
+ deleted: z.literal(true),
566
+ })
567
+ export type PluginCoreProposalsDeleteResult = z.infer<
568
+ typeof PluginCoreProposalsDeleteResult
569
+ >