@snaptrude/plugin-core 0.9.16 → 0.9.18-voids-20261016.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/api-manifest.full.json +10406 -0
- package/api-manifest.json +827 -51
- package/dist/api/analysis/daylight.d.ts +5 -5
- package/dist/api/analysis/solar.d.ts +2 -2
- package/dist/api/core/camera/index.d.ts +29 -0
- package/dist/api/core/camera/index.d.ts.map +1 -1
- package/dist/api/core/geom/create/index.d.ts +7 -1
- package/dist/api/core/geom/create/index.d.ts.map +1 -1
- package/dist/api/core/geom/update/contour.d.ts +8 -2
- package/dist/api/core/geom/update/contour.d.ts.map +1 -1
- package/dist/api/core/zoom/index.d.ts +13 -0
- package/dist/api/core/zoom/index.d.ts.map +1 -1
- package/dist/api/design/bim.d.ts +209 -0
- package/dist/api/design/bim.d.ts.map +1 -0
- package/dist/api/design/boolean/index.d.ts +2 -0
- package/dist/api/design/boolean/index.d.ts.map +1 -1
- package/dist/api/design/catalog.d.ts +320 -0
- package/dist/api/design/catalog.d.ts.map +1 -0
- package/dist/api/design/create/bulk-items.d.ts +65 -25
- package/dist/api/design/create/bulk-items.d.ts.map +1 -1
- package/dist/api/design/create/index.d.ts +272 -99
- package/dist/api/design/create/index.d.ts.map +1 -1
- package/dist/api/design/create/opening-fields.d.ts +13 -12
- package/dist/api/design/create/opening-fields.d.ts.map +1 -1
- package/dist/api/design/delete/index.d.ts +1 -0
- package/dist/api/design/delete/index.d.ts.map +1 -1
- package/dist/api/design/doors/index.d.ts +18 -24
- package/dist/api/design/doors/index.d.ts.map +1 -1
- package/dist/api/design/family.d.ts +797 -27
- package/dist/api/design/family.d.ts.map +1 -1
- package/dist/api/design/index.d.ts +16 -0
- package/dist/api/design/index.d.ts.map +1 -1
- package/dist/api/design/networks.d.ts +1703 -0
- package/dist/api/design/networks.d.ts.map +1 -0
- package/dist/api/design/query/index.d.ts +42 -32
- package/dist/api/design/query/index.d.ts.map +1 -1
- package/dist/api/design/selection/index.d.ts +10 -10
- package/dist/api/design/types/index.d.ts +40 -24
- package/dist/api/design/types/index.d.ts.map +1 -1
- package/dist/api/design/update/index.d.ts +43 -3
- package/dist/api/design/update/index.d.ts.map +1 -1
- package/dist/api/design/windows/index.d.ts +8 -8
- package/dist/api/design/windows/index.d.ts.map +1 -1
- package/dist/api/presentation/aiInspiration.d.ts +10 -10
- package/dist/api/presentation/annotate.d.ts +38 -22
- package/dist/api/presentation/annotate.d.ts.map +1 -1
- package/dist/api/presentation/drawingContract.d.ts +32 -0
- package/dist/api/presentation/drawingContract.d.ts.map +1 -0
- package/dist/api/presentation/drawings.d.ts +3523 -0
- package/dist/api/presentation/drawings.d.ts.map +1 -0
- package/dist/api/presentation/export.d.ts +23 -5
- package/dist/api/presentation/export.d.ts.map +1 -1
- package/dist/api/presentation/index.d.ts +41 -12
- package/dist/api/presentation/index.d.ts.map +1 -1
- package/dist/api/presentation/placedViews.d.ts +106 -6
- package/dist/api/presentation/placedViews.d.ts.map +1 -1
- package/dist/api/presentation/sections.d.ts +461 -0
- package/dist/api/presentation/sections.d.ts.map +1 -0
- package/dist/api/presentation/shapes.d.ts +2 -2
- package/dist/api/presentation/sheets.d.ts +175 -19
- package/dist/api/presentation/sheets.d.ts.map +1 -1
- package/dist/api/presentation/viewPresets.d.ts +222 -0
- package/dist/api/presentation/viewPresets.d.ts.map +1 -0
- package/dist/api/presentation/views.d.ts +103 -5
- package/dist/api/presentation/views.d.ts.map +1 -1
- package/dist/api/presentation/walkthroughs.d.ts +6 -6
- package/dist/errors/codes.d.ts +3 -1
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/index.cjs +3749 -2328
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3616 -2328
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/generate-manifest.mjs +5 -0
- package/src/api/core/camera/index.ts +29 -0
- package/src/api/core/geom/create/index.ts +7 -1
- package/src/api/core/geom/update/contour.ts +8 -2
- package/src/api/core/zoom/index.ts +13 -0
- package/src/api/design/bim.ts +121 -0
- package/src/api/design/boolean/index.ts +2 -0
- package/src/api/design/catalog.ts +203 -0
- package/src/api/design/create/bulk-items.ts +57 -17
- package/src/api/design/create/index.ts +288 -120
- package/src/api/design/create/opening-fields.ts +15 -12
- package/src/api/design/delete/index.ts +1 -0
- package/src/api/design/doors/index.ts +58 -42
- package/src/api/design/family.ts +662 -32
- package/src/api/design/index.ts +34 -4
- package/src/api/design/networks.ts +607 -0
- package/src/api/design/query/index.ts +12 -2
- package/src/api/design/types/index.ts +31 -24
- package/src/api/design/update/index.ts +44 -3
- package/src/api/design/windows/index.ts +40 -22
- package/src/api/presentation/annotate.ts +90 -58
- package/src/api/presentation/drawingContract.ts +70 -0
- package/src/api/presentation/drawings.ts +1179 -0
- package/src/api/presentation/export.ts +32 -6
- package/src/api/presentation/index.ts +48 -14
- package/src/api/presentation/placedViews.ts +119 -28
- package/src/api/presentation/sections.ts +420 -0
- package/src/api/presentation/sheets.ts +181 -20
- package/src/api/presentation/viewPresets.ts +241 -0
- package/src/api/presentation/views.ts +46 -6
- package/src/errors/codes.ts +7 -0
- package/test/drawingContract.test.mjs +288 -0
- package/test/errors.test.mjs +1 -0
package/src/api/design/index.ts
CHANGED
|
@@ -18,7 +18,14 @@ import { PluginDesignDimensionsApi } from "./dimensions"
|
|
|
18
18
|
import { PluginDesignTypesApi } from "./types"
|
|
19
19
|
import { PluginDesignFamilyApi } from "./family"
|
|
20
20
|
import { PluginDesignGridsApi } from "./grids"
|
|
21
|
+
import { PluginDesignCatalogApi } from "./catalog"
|
|
22
|
+
import { PluginDesignBimApi } from "./bim"
|
|
21
23
|
import { PluginDesignChangeResult } from "./lock"
|
|
24
|
+
import {
|
|
25
|
+
PluginElectricalApi,
|
|
26
|
+
PluginPlumbingApi,
|
|
27
|
+
PluginMechanicalApi,
|
|
28
|
+
} from "./networks"
|
|
22
29
|
|
|
23
30
|
/**
|
|
24
31
|
* `snaptrude.design.*` — author, query & edit BIM geometry.
|
|
@@ -76,10 +83,22 @@ export abstract class PluginDesignApi {
|
|
|
76
83
|
public abstract types: PluginDesignTypesApi
|
|
77
84
|
/** Author parametric families from a JSON spec. See {@linkcode PluginDesignFamilyApi}. */
|
|
78
85
|
public abstract family: PluginDesignFamilyApi
|
|
86
|
+
/** Shared family and asset inventory, including supported placement and update paths. */
|
|
87
|
+
public abstract catalog: PluginDesignCatalogApi
|
|
88
|
+
|
|
89
|
+
/** Agent-driven Sketch-to-BIM with explicit per-edge constructions. */
|
|
90
|
+
public abstract bim: PluginDesignBimApi
|
|
79
91
|
|
|
80
92
|
/** Structural edits on a grid's line structure. See {@linkcode PluginDesignGridsApi}. */
|
|
81
93
|
public abstract grids: PluginDesignGridsApi
|
|
82
94
|
|
|
95
|
+
/** Persistent electrical equipment, routes and circuit graphs. */
|
|
96
|
+
public abstract electrical: PluginElectricalApi
|
|
97
|
+
/** Persistent plumbing equipment and directed pipe graphs. */
|
|
98
|
+
public abstract plumbing: PluginPlumbingApi
|
|
99
|
+
/** Persistent family-backed HVAC ducts, fittings and equipment. */
|
|
100
|
+
public abstract mechanical: PluginMechanicalApi
|
|
101
|
+
|
|
83
102
|
/**
|
|
84
103
|
* Lock entities so they cannot be edited. Undoable. Cascades to void/door/window
|
|
85
104
|
* children, stacked-wall companions, and terrain neighborhood; skips
|
|
@@ -100,7 +119,9 @@ export abstract class PluginDesignApi {
|
|
|
100
119
|
* // affected is post-cascade: hosted doors/windows are included
|
|
101
120
|
* ```
|
|
102
121
|
*/
|
|
103
|
-
public abstract lock(
|
|
122
|
+
public abstract lock(
|
|
123
|
+
components: ComponentHandle[],
|
|
124
|
+
): PluginApiReturn<PluginDesignChangeResult>
|
|
104
125
|
|
|
105
126
|
/**
|
|
106
127
|
* Unlock previously locked entities so they can be edited again. Undoable.
|
|
@@ -120,7 +141,9 @@ export abstract class PluginDesignApi {
|
|
|
120
141
|
* const { affected } = await snaptrude.design.unlock(locked)
|
|
121
142
|
* ```
|
|
122
143
|
*/
|
|
123
|
-
public abstract unlock(
|
|
144
|
+
public abstract unlock(
|
|
145
|
+
components: ComponentHandle[],
|
|
146
|
+
): PluginApiReturn<PluginDesignChangeResult>
|
|
124
147
|
|
|
125
148
|
/**
|
|
126
149
|
* Test whether an entity is locked (folds group + bucket lock unless `includeInherited: false`).
|
|
@@ -188,7 +211,9 @@ export abstract class PluginDesignApi {
|
|
|
188
211
|
* console.log("area-locked", affected.length, "spaces")
|
|
189
212
|
* ```
|
|
190
213
|
*/
|
|
191
|
-
public abstract lockArea(
|
|
214
|
+
public abstract lockArea(
|
|
215
|
+
spaces: ComponentHandle[],
|
|
216
|
+
): PluginApiReturn<PluginDesignChangeResult>
|
|
192
217
|
|
|
193
218
|
/**
|
|
194
219
|
* Unlock the footprint area of previously area-locked spaces so their area can
|
|
@@ -209,7 +234,9 @@ export abstract class PluginDesignApi {
|
|
|
209
234
|
* const { affected } = await snaptrude.design.unlockArea(locked)
|
|
210
235
|
* ```
|
|
211
236
|
*/
|
|
212
|
-
public abstract unlockArea(
|
|
237
|
+
public abstract unlockArea(
|
|
238
|
+
spaces: ComponentHandle[],
|
|
239
|
+
): PluginApiReturn<PluginDesignChangeResult>
|
|
213
240
|
|
|
214
241
|
/**
|
|
215
242
|
* Test whether a space's footprint area is locked. A read — never throws;
|
|
@@ -272,3 +299,6 @@ export * from "./dimensions"
|
|
|
272
299
|
export * from "./types"
|
|
273
300
|
export * from "./family"
|
|
274
301
|
export * from "./grids"
|
|
302
|
+
export * from "./networks"
|
|
303
|
+
export * from "./catalog"
|
|
304
|
+
export * from "./bim"
|
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import type { PluginApiReturn } from "../../types"
|
|
3
|
+
|
|
4
|
+
const id = z.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,79}$/)
|
|
5
|
+
const vector = z.tuple([
|
|
6
|
+
z.number().finite(),
|
|
7
|
+
z.number().finite(),
|
|
8
|
+
z.number().finite(),
|
|
9
|
+
])
|
|
10
|
+
const positive = z.number().finite().positive()
|
|
11
|
+
const endpoint = z.object({ node: id, port: id }).strict()
|
|
12
|
+
const relationships = z
|
|
13
|
+
.array(
|
|
14
|
+
z
|
|
15
|
+
.object({
|
|
16
|
+
node: id,
|
|
17
|
+
relation: z.enum(["mountedOn", "within", "serves", "penetrates"]),
|
|
18
|
+
target: z
|
|
19
|
+
.object({
|
|
20
|
+
kind: z.enum(["component", "topology"]),
|
|
21
|
+
id: z.string().min(1).max(200),
|
|
22
|
+
})
|
|
23
|
+
.strict(),
|
|
24
|
+
})
|
|
25
|
+
.strict(),
|
|
26
|
+
)
|
|
27
|
+
.max(4000)
|
|
28
|
+
|
|
29
|
+
/** Versioned metadata stored in a pinned FamilySpecBundle.network. Expressions use the
|
|
30
|
+
* family's parameter scope and SU, just like its geometry. No world-space port overrides.
|
|
31
|
+
* Pipe recipes run from local [0,0,0] to [length,0,0] along +X.
|
|
32
|
+
*/
|
|
33
|
+
export const NetworkFamilyContract = z
|
|
34
|
+
.object({
|
|
35
|
+
schemaVersion: z.literal(1),
|
|
36
|
+
role: z.enum([
|
|
37
|
+
"pipe",
|
|
38
|
+
"duct",
|
|
39
|
+
"wire",
|
|
40
|
+
"cable",
|
|
41
|
+
"conduit",
|
|
42
|
+
"cableDuct",
|
|
43
|
+
"cableTray",
|
|
44
|
+
"connector",
|
|
45
|
+
"equipment",
|
|
46
|
+
]),
|
|
47
|
+
lengthParameter: z.string().min(1).optional(),
|
|
48
|
+
ports: z
|
|
49
|
+
.array(
|
|
50
|
+
z
|
|
51
|
+
.object({
|
|
52
|
+
id,
|
|
53
|
+
position: z.tuple([z.string(), z.string(), z.string()]),
|
|
54
|
+
direction: z.tuple([z.string(), z.string(), z.string()]),
|
|
55
|
+
size: z.string(),
|
|
56
|
+
height: z.string().optional(),
|
|
57
|
+
/** Unit width axis in family coordinates, perpendicular to direction.
|
|
58
|
+
* Required with height for mechanical rectangular ports; prevents guessed roll.
|
|
59
|
+
*/
|
|
60
|
+
widthDirection: z
|
|
61
|
+
.tuple([z.string(), z.string(), z.string()])
|
|
62
|
+
.optional(),
|
|
63
|
+
systems: z.array(z.string().min(1)).min(1),
|
|
64
|
+
})
|
|
65
|
+
.strict(),
|
|
66
|
+
)
|
|
67
|
+
.min(1)
|
|
68
|
+
.max(64),
|
|
69
|
+
})
|
|
70
|
+
.strict()
|
|
71
|
+
export type NetworkFamilyContract = z.infer<typeof NetworkFamilyContract>
|
|
72
|
+
|
|
73
|
+
const familyPin = z
|
|
74
|
+
.object({
|
|
75
|
+
definitionId: z.string().min(1).max(200),
|
|
76
|
+
version: z.number().int().positive(),
|
|
77
|
+
values: z.record(
|
|
78
|
+
z.string(),
|
|
79
|
+
z.union([z.number().finite(), z.string(), z.boolean()]),
|
|
80
|
+
),
|
|
81
|
+
})
|
|
82
|
+
.strict()
|
|
83
|
+
|
|
84
|
+
/** Authored topology: vertices are pinned connector/equipment families; each edge is one
|
|
85
|
+
* line and one pinned straight-pipe family. Curved runs are not yet supported by this
|
|
86
|
+
* contract; bends require explicit connector vertices. World mm, Y up, rotations in degrees.
|
|
87
|
+
* Plumbing v2 accepts round ports only. Rectangular ports need a section-roll contract.
|
|
88
|
+
* The resolved component graph is retained for existing persistence, replay and queries.
|
|
89
|
+
*/
|
|
90
|
+
export const NetworkTopologyDocument = z
|
|
91
|
+
.object({
|
|
92
|
+
schemaVersion: z.literal(2),
|
|
93
|
+
domain: z.literal("plumbing"),
|
|
94
|
+
label: z.string().min(1).max(120),
|
|
95
|
+
architectureRevision: z.string().min(1).max(80),
|
|
96
|
+
relationships,
|
|
97
|
+
vertices: z
|
|
98
|
+
.array(
|
|
99
|
+
z
|
|
100
|
+
.object({
|
|
101
|
+
id,
|
|
102
|
+
kind: z.enum([
|
|
103
|
+
"fixture",
|
|
104
|
+
"equipment",
|
|
105
|
+
"tank",
|
|
106
|
+
"pump",
|
|
107
|
+
"valve",
|
|
108
|
+
"manifold",
|
|
109
|
+
"fitting",
|
|
110
|
+
]),
|
|
111
|
+
storey: z.number().int(),
|
|
112
|
+
family: familyPin,
|
|
113
|
+
positionMm: vector,
|
|
114
|
+
rotationDeg: vector,
|
|
115
|
+
systems: z.record(z.string(), z.string().min(1)),
|
|
116
|
+
})
|
|
117
|
+
.strict(),
|
|
118
|
+
)
|
|
119
|
+
.min(1)
|
|
120
|
+
.max(1000),
|
|
121
|
+
edges: z
|
|
122
|
+
.array(
|
|
123
|
+
z
|
|
124
|
+
.object({
|
|
125
|
+
id,
|
|
126
|
+
kind: z.enum(["pipe", "riser"]),
|
|
127
|
+
storey: z.number().int(),
|
|
128
|
+
family: familyPin,
|
|
129
|
+
from: endpoint,
|
|
130
|
+
to: endpoint,
|
|
131
|
+
system: z.string().min(1),
|
|
132
|
+
/** One line between evaluated connector ports, never a corner-bearing polyline. */
|
|
133
|
+
curve: z.object({ kind: z.literal("line") }).strict(),
|
|
134
|
+
})
|
|
135
|
+
.strict(),
|
|
136
|
+
)
|
|
137
|
+
.max(1000),
|
|
138
|
+
})
|
|
139
|
+
.strict()
|
|
140
|
+
export type NetworkTopologyDocument = z.infer<typeof NetworkTopologyDocument>
|
|
141
|
+
|
|
142
|
+
export const MechanicalAirSystem = z.enum([
|
|
143
|
+
"supplyAir",
|
|
144
|
+
"returnAir",
|
|
145
|
+
"exhaustAir",
|
|
146
|
+
"outsideAir",
|
|
147
|
+
"reliefAir",
|
|
148
|
+
])
|
|
149
|
+
const mechanicalVertexKind = z.enum([
|
|
150
|
+
"equipment",
|
|
151
|
+
"terminal",
|
|
152
|
+
"damper",
|
|
153
|
+
"fitting",
|
|
154
|
+
])
|
|
155
|
+
const mechanicalEdgeKind = z.enum(["duct", "riser"])
|
|
156
|
+
|
|
157
|
+
/** Air-side HVAC intent. Reuses the graph transport, not plumbing domain semantics.
|
|
158
|
+
* Every vertex and edge pins an existing family. Edges run from upstream to downstream.
|
|
159
|
+
* Rectangular duct ports use local +Y as their width axis. The host aligns this axis to
|
|
160
|
+
* the upstream connector's widthDirection and rejects incompatible downstream roll.
|
|
161
|
+
* Bends, branches and transitions are explicit fitting vertices. No flexible curves,
|
|
162
|
+
* hydronic/refrigerant design, airflow sizing or code-compliance inference is provided.
|
|
163
|
+
*/
|
|
164
|
+
export const MechanicalTopologyDocument = NetworkTopologyDocument.extend({
|
|
165
|
+
domain: z.literal("mechanical"),
|
|
166
|
+
vertices: z
|
|
167
|
+
.array(
|
|
168
|
+
NetworkTopologyDocument.shape.vertices.element.extend({
|
|
169
|
+
kind: mechanicalVertexKind,
|
|
170
|
+
systems: z.record(z.string(), MechanicalAirSystem),
|
|
171
|
+
}),
|
|
172
|
+
)
|
|
173
|
+
.min(1)
|
|
174
|
+
.max(1000),
|
|
175
|
+
edges: z
|
|
176
|
+
.array(
|
|
177
|
+
NetworkTopologyDocument.shape.edges.element.extend({
|
|
178
|
+
kind: mechanicalEdgeKind,
|
|
179
|
+
system: MechanicalAirSystem,
|
|
180
|
+
}),
|
|
181
|
+
)
|
|
182
|
+
.max(1000),
|
|
183
|
+
})
|
|
184
|
+
export type MechanicalTopologyDocument = z.infer<
|
|
185
|
+
typeof MechanicalTopologyDocument
|
|
186
|
+
>
|
|
187
|
+
|
|
188
|
+
const electricalVertexKind = z.enum([
|
|
189
|
+
"transformer",
|
|
190
|
+
"mainBoard",
|
|
191
|
+
"distributionBoard",
|
|
192
|
+
"mcbBox",
|
|
193
|
+
"junctionBox",
|
|
194
|
+
"switch",
|
|
195
|
+
"outlet",
|
|
196
|
+
"light",
|
|
197
|
+
"load",
|
|
198
|
+
"equipment",
|
|
199
|
+
"fitting",
|
|
200
|
+
])
|
|
201
|
+
const electricalEdgeKind = z.enum([
|
|
202
|
+
"wire",
|
|
203
|
+
"cable",
|
|
204
|
+
"conduit",
|
|
205
|
+
"cableDuct",
|
|
206
|
+
"cableTray",
|
|
207
|
+
])
|
|
208
|
+
const electricalCircuits = z
|
|
209
|
+
.array(
|
|
210
|
+
z
|
|
211
|
+
.object({
|
|
212
|
+
id,
|
|
213
|
+
source: id,
|
|
214
|
+
loads: z.array(id).min(1).max(1000),
|
|
215
|
+
routes: z.array(id).max(1000),
|
|
216
|
+
voltage: positive,
|
|
217
|
+
phases: z.number().int().min(1).max(3),
|
|
218
|
+
ratedAmps: positive,
|
|
219
|
+
})
|
|
220
|
+
.strict(),
|
|
221
|
+
)
|
|
222
|
+
.max(1000)
|
|
223
|
+
|
|
224
|
+
/** Physical electrical topology, independent of logical circuit membership.
|
|
225
|
+
* Each straight edge pins a family whose role matches its kind. Bends and branches
|
|
226
|
+
* require connector vertices. Junction boxes are equipment with explicit named ports.
|
|
227
|
+
* Rectangular containment uses the same section frame as mechanical ducts.
|
|
228
|
+
* Systems are authored labels which must be supported by the pinned ports.
|
|
229
|
+
* Direction is explicit, never inferred from circuits or spatial contact.
|
|
230
|
+
*/
|
|
231
|
+
export const ElectricalTopologyDocument = NetworkTopologyDocument.extend({
|
|
232
|
+
domain: z.literal("electrical"),
|
|
233
|
+
vertices: z
|
|
234
|
+
.array(
|
|
235
|
+
NetworkTopologyDocument.shape.vertices.element.extend({
|
|
236
|
+
kind: electricalVertexKind,
|
|
237
|
+
}),
|
|
238
|
+
)
|
|
239
|
+
.min(1)
|
|
240
|
+
.max(1000),
|
|
241
|
+
edges: z
|
|
242
|
+
.array(
|
|
243
|
+
NetworkTopologyDocument.shape.edges.element.extend({
|
|
244
|
+
kind: electricalEdgeKind,
|
|
245
|
+
directed: z.boolean(),
|
|
246
|
+
}),
|
|
247
|
+
)
|
|
248
|
+
.max(1000),
|
|
249
|
+
circuits: electricalCircuits,
|
|
250
|
+
})
|
|
251
|
+
export type ElectricalTopologyDocument = z.infer<
|
|
252
|
+
typeof ElectricalTopologyDocument
|
|
253
|
+
>
|
|
254
|
+
|
|
255
|
+
export const AuthoredNetworkTopologyDocument = z.discriminatedUnion("domain", [
|
|
256
|
+
NetworkTopologyDocument,
|
|
257
|
+
MechanicalTopologyDocument,
|
|
258
|
+
ElectricalTopologyDocument,
|
|
259
|
+
])
|
|
260
|
+
export type AuthoredNetworkTopologyDocument = z.infer<
|
|
261
|
+
typeof AuthoredNetworkTopologyDocument
|
|
262
|
+
>
|
|
263
|
+
|
|
264
|
+
/** Authored world-space connector. This is not a claim of certified family connector metadata. */
|
|
265
|
+
export const NetworkPort = z
|
|
266
|
+
.object({
|
|
267
|
+
id,
|
|
268
|
+
positionMm: vector,
|
|
269
|
+
direction: vector,
|
|
270
|
+
system: z.string().min(1).max(80),
|
|
271
|
+
/** Diameter for round ports; width when heightMm is supplied (rectangular port). */
|
|
272
|
+
sizeMm: positive,
|
|
273
|
+
heightMm: positive.optional(),
|
|
274
|
+
/** World-space unit width axis. Mechanical rectangular ports require this section frame. */
|
|
275
|
+
widthDirection: vector.optional(),
|
|
276
|
+
})
|
|
277
|
+
.strict()
|
|
278
|
+
|
|
279
|
+
/** The agent supplies every route and section. The host does not size or route a network. */
|
|
280
|
+
export const NetworkGeometry = z.discriminatedUnion("kind", [
|
|
281
|
+
z
|
|
282
|
+
.object({
|
|
283
|
+
kind: z.literal("family"),
|
|
284
|
+
definitionId: z.string().min(1).max(200),
|
|
285
|
+
version: z.number().int().positive(),
|
|
286
|
+
values: z.record(
|
|
287
|
+
z.string(),
|
|
288
|
+
z.union([z.number().finite(), z.string(), z.boolean()]),
|
|
289
|
+
),
|
|
290
|
+
positionMm: vector,
|
|
291
|
+
rotationDeg: vector,
|
|
292
|
+
ports: z.array(NetworkPort).max(64),
|
|
293
|
+
})
|
|
294
|
+
.strict(),
|
|
295
|
+
z
|
|
296
|
+
.object({
|
|
297
|
+
kind: z.literal("route"),
|
|
298
|
+
pathMm: z.array(vector).min(2).max(256),
|
|
299
|
+
system: z.string().min(1).max(80),
|
|
300
|
+
section: z.discriminatedUnion("kind", [
|
|
301
|
+
z
|
|
302
|
+
.object({
|
|
303
|
+
kind: z.literal("round"),
|
|
304
|
+
diameterMm: positive,
|
|
305
|
+
wallMm: z.number().finite().nonnegative(),
|
|
306
|
+
})
|
|
307
|
+
.strict(),
|
|
308
|
+
z
|
|
309
|
+
.object({
|
|
310
|
+
kind: z.literal("rectangular"),
|
|
311
|
+
widthMm: positive,
|
|
312
|
+
heightMm: positive,
|
|
313
|
+
wallMm: z.number().finite().nonnegative(),
|
|
314
|
+
})
|
|
315
|
+
.strict(),
|
|
316
|
+
]),
|
|
317
|
+
})
|
|
318
|
+
.strict(),
|
|
319
|
+
])
|
|
320
|
+
|
|
321
|
+
// Storey is scene membership, not a coordinate offset. A route can span multiple elevations.
|
|
322
|
+
const node = z
|
|
323
|
+
.object({ id, storey: z.number().int(), geometry: NetworkGeometry })
|
|
324
|
+
.strict()
|
|
325
|
+
const electricalNode = node.extend({
|
|
326
|
+
kind: z.enum([
|
|
327
|
+
...electricalVertexKind.options,
|
|
328
|
+
...electricalEdgeKind.options,
|
|
329
|
+
]),
|
|
330
|
+
})
|
|
331
|
+
const plumbingNode = node.extend({
|
|
332
|
+
kind: z.enum([
|
|
333
|
+
"fixture",
|
|
334
|
+
"equipment",
|
|
335
|
+
"tank",
|
|
336
|
+
"pump",
|
|
337
|
+
"valve",
|
|
338
|
+
"manifold",
|
|
339
|
+
"fitting",
|
|
340
|
+
"pipe",
|
|
341
|
+
"riser",
|
|
342
|
+
]),
|
|
343
|
+
})
|
|
344
|
+
const document = z
|
|
345
|
+
.object({
|
|
346
|
+
schemaVersion: z.literal(1),
|
|
347
|
+
label: z.string().min(1).max(120),
|
|
348
|
+
/** Revision from context(); invalidated when the source architectural graph changes. */
|
|
349
|
+
architectureRevision: z.string().min(1).max(80),
|
|
350
|
+
connections: z
|
|
351
|
+
.array(
|
|
352
|
+
z
|
|
353
|
+
.object({ id, from: endpoint, to: endpoint, directed: z.boolean() })
|
|
354
|
+
.strict(),
|
|
355
|
+
)
|
|
356
|
+
.max(4000),
|
|
357
|
+
relationships,
|
|
358
|
+
})
|
|
359
|
+
.strict()
|
|
360
|
+
|
|
361
|
+
/** Electrical connectivity and circuit membership are distinct from physical route occupancy. */
|
|
362
|
+
export const ElectricalGraphDocument = document.extend({
|
|
363
|
+
domain: z.literal("electrical"),
|
|
364
|
+
nodes: z.array(electricalNode).min(1).max(1000),
|
|
365
|
+
circuits: electricalCircuits,
|
|
366
|
+
/** Required for new authoring. Omitted only on saved legacy snapshots. */
|
|
367
|
+
authored: ElectricalTopologyDocument.optional(),
|
|
368
|
+
})
|
|
369
|
+
|
|
370
|
+
/** Plumbing uses explicit directed port connections; touching geometry never creates a connection. */
|
|
371
|
+
export const PlumbingGraphDocument = document.extend({
|
|
372
|
+
domain: z.literal("plumbing"),
|
|
373
|
+
nodes: z.array(plumbingNode).min(1).max(1000),
|
|
374
|
+
/** Original v2 intent. Nodes/connections are the resolved snapshot for replay.
|
|
375
|
+
* Kept inside the document so existing save services preserve it without envelope changes.
|
|
376
|
+
* Legacy v1 saves omit this field; new plumbing submissions require v2.
|
|
377
|
+
*/
|
|
378
|
+
authored: NetworkTopologyDocument.optional(),
|
|
379
|
+
})
|
|
380
|
+
/** Resolved HVAC snapshot for queries, commands and load. New submissions require v2 intent. */
|
|
381
|
+
export const MechanicalGraphDocument = document.extend({
|
|
382
|
+
domain: z.literal("mechanical"),
|
|
383
|
+
nodes: z
|
|
384
|
+
.array(
|
|
385
|
+
node.extend({
|
|
386
|
+
kind: z.enum([
|
|
387
|
+
...mechanicalVertexKind.options,
|
|
388
|
+
...mechanicalEdgeKind.options,
|
|
389
|
+
]),
|
|
390
|
+
geometry: NetworkGeometry.options[0],
|
|
391
|
+
}),
|
|
392
|
+
)
|
|
393
|
+
.min(1)
|
|
394
|
+
.max(1000),
|
|
395
|
+
authored: MechanicalTopologyDocument,
|
|
396
|
+
})
|
|
397
|
+
export const NetworkGraphDocument = z.discriminatedUnion("domain", [
|
|
398
|
+
ElectricalGraphDocument,
|
|
399
|
+
PlumbingGraphDocument,
|
|
400
|
+
MechanicalGraphDocument,
|
|
401
|
+
])
|
|
402
|
+
export type NetworkGraphDocument = z.infer<typeof NetworkGraphDocument>
|
|
403
|
+
export type NetworkNode = NetworkGraphDocument["nodes"][number]
|
|
404
|
+
export type NetworkPort = z.infer<typeof NetworkPort>
|
|
405
|
+
export type NetworkDomain = NetworkGraphDocument["domain"]
|
|
406
|
+
|
|
407
|
+
/** JSON is an authored document, not a transport for live geometry handles. Maximum 2 MB characters. */
|
|
408
|
+
export const NetworkValidateArgs = z
|
|
409
|
+
.object({ graphJson: z.string().max(2_000_000) })
|
|
410
|
+
.strict()
|
|
411
|
+
export const NetworkCreateArgs = NetworkValidateArgs.extend({
|
|
412
|
+
requestId: z.string().uuid(),
|
|
413
|
+
})
|
|
414
|
+
export const NetworkGetArgs = z.object({ graphId: z.string().uuid() }).strict()
|
|
415
|
+
export const NetworkContextArgs = z
|
|
416
|
+
.object({
|
|
417
|
+
offset: z.number().int().nonnegative().default(0),
|
|
418
|
+
limit: z.number().int().min(1).max(100).default(30),
|
|
419
|
+
/** Omit the legacy PG2 dump when using the routing view, to avoid duplicate geometry tokens. */
|
|
420
|
+
includeTopology: z.boolean().default(true),
|
|
421
|
+
})
|
|
422
|
+
.strict()
|
|
423
|
+
export const NetworkQueryArgs = NetworkGetArgs.extend({
|
|
424
|
+
revision: z.number().int().positive(),
|
|
425
|
+
queryJson: z.string().max(16000),
|
|
426
|
+
})
|
|
427
|
+
export const NetworkQuery = z
|
|
428
|
+
.object({
|
|
429
|
+
kind: z.enum([
|
|
430
|
+
"nodes",
|
|
431
|
+
"connected",
|
|
432
|
+
"upstream",
|
|
433
|
+
"downstream",
|
|
434
|
+
"ports",
|
|
435
|
+
"nearestPort",
|
|
436
|
+
"circuits",
|
|
437
|
+
"relationships",
|
|
438
|
+
]),
|
|
439
|
+
node: id.optional(),
|
|
440
|
+
pointMm: vector.optional(),
|
|
441
|
+
radiusMm: positive.optional(),
|
|
442
|
+
/** Filter nodes, ports and traversal links by system. Traversal always includes its start node. */
|
|
443
|
+
system: z.string().optional(),
|
|
444
|
+
sizeMm: positive.optional(),
|
|
445
|
+
heightMm: positive.optional(),
|
|
446
|
+
offset: z.number().int().nonnegative().default(0),
|
|
447
|
+
limit: z.number().int().min(1).max(100).default(30),
|
|
448
|
+
})
|
|
449
|
+
.strict()
|
|
450
|
+
export type NetworkQuery = z.infer<typeof NetworkQuery>
|
|
451
|
+
|
|
452
|
+
export interface NetworkDiagnostic {
|
|
453
|
+
path: string
|
|
454
|
+
message: string
|
|
455
|
+
}
|
|
456
|
+
export interface NetworkValidation {
|
|
457
|
+
ok: boolean
|
|
458
|
+
diagnostics: NetworkDiagnostic[]
|
|
459
|
+
nodeCount: number
|
|
460
|
+
}
|
|
461
|
+
/** Durable node-to-scene mapping. New family-backed nodes retain the original authorized pin;
|
|
462
|
+
* parameters and placement belong to the component, not a generated library family.
|
|
463
|
+
* Existing wrapper pins and v1 raw-route recipe pins remain readable, not newly authored.
|
|
464
|
+
*/
|
|
465
|
+
export const NetworkComponentBinding = z
|
|
466
|
+
.object({
|
|
467
|
+
nodeId: id,
|
|
468
|
+
componentId: z.string().min(1),
|
|
469
|
+
definitionId: z.string().min(1),
|
|
470
|
+
definitionVersion: z.number().int().positive(),
|
|
471
|
+
})
|
|
472
|
+
.strict()
|
|
473
|
+
export type NetworkComponentBinding = z.infer<typeof NetworkComponentBinding>
|
|
474
|
+
export interface SavedNetworkGraph {
|
|
475
|
+
id: string
|
|
476
|
+
domain: NetworkDomain
|
|
477
|
+
revision: 1
|
|
478
|
+
requestId: string
|
|
479
|
+
document: NetworkGraphDocument
|
|
480
|
+
components: NetworkComponentBinding[]
|
|
481
|
+
}
|
|
482
|
+
export interface NetworkCreateResult {
|
|
483
|
+
graphId: string
|
|
484
|
+
revision: number
|
|
485
|
+
components: NetworkComponentBinding[]
|
|
486
|
+
alreadyCreated: boolean
|
|
487
|
+
/** Queue acceptance is not a durable database acknowledgement. */
|
|
488
|
+
saveStatus: "queued" | "existing"
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/** Exact TopoGraph routing evidence, not a route planner or inferred enclosure.
|
|
492
|
+
* World mm, Y-up. A curve's axis is a unit direction, not a length.
|
|
493
|
+
* Shared region IDs mean a shared boundary, not permission to penetrate a wall.
|
|
494
|
+
* Regions preserve directed outer/hole loops. No vertical connectivity is inferred;
|
|
495
|
+
* use their curves and storey elevations to plan risers and explicit penetrations.
|
|
496
|
+
*/
|
|
497
|
+
export interface NetworkRoutingContext {
|
|
498
|
+
units: "mm"
|
|
499
|
+
edges: {
|
|
500
|
+
id: string
|
|
501
|
+
curve:
|
|
502
|
+
| { type: "line"; start: number[]; end: number[] }
|
|
503
|
+
| {
|
|
504
|
+
type: "arc"
|
|
505
|
+
start: number[]
|
|
506
|
+
end: number[]
|
|
507
|
+
centre: number[]
|
|
508
|
+
axis: number[]
|
|
509
|
+
}
|
|
510
|
+
wallId: string | null
|
|
511
|
+
regionIds: string[]
|
|
512
|
+
}[]
|
|
513
|
+
regions: {
|
|
514
|
+
id: string
|
|
515
|
+
/** Stable source component IDs; read label/storey from context.components. */
|
|
516
|
+
ownerIds: string[]
|
|
517
|
+
boundary: {
|
|
518
|
+
outer: { edgeId: string; direction: "forward" | "reverse" }[]
|
|
519
|
+
holes: { edgeId: string; direction: "forward" | "reverse" }[][]
|
|
520
|
+
}
|
|
521
|
+
floorId: string | null
|
|
522
|
+
slabId: string | null
|
|
523
|
+
}[]
|
|
524
|
+
/** Hosting is exact; bounds are only coarse avoidance data, not a penetration clearance check. */
|
|
525
|
+
openings: {
|
|
526
|
+
id: string
|
|
527
|
+
wallId: string
|
|
528
|
+
type: string
|
|
529
|
+
minMm: number[]
|
|
530
|
+
maxMm: number[]
|
|
531
|
+
}[]
|
|
532
|
+
}
|
|
533
|
+
export interface NetworkContextResult {
|
|
534
|
+
proposalId: string
|
|
535
|
+
buildingId: string | null
|
|
536
|
+
revision: string
|
|
537
|
+
/** PG2's native serialization uses Snaptrude units (1 SU = 254 mm). */
|
|
538
|
+
topologyUnits: "SU"
|
|
539
|
+
/** JSON array; empty when includeTopology is false. Prefer routing for network planning. */
|
|
540
|
+
topologyJson: string
|
|
541
|
+
/** Each collection uses offset/limit independently. Follow nextOffset before resolving references.
|
|
542
|
+
* Empty regions mean topology is unavailable, not that bounds can substitute for room boundaries.
|
|
543
|
+
*/
|
|
544
|
+
routing: NetworkRoutingContext
|
|
545
|
+
nextOffset: number | null
|
|
546
|
+
total: number
|
|
547
|
+
storeys: { number: number; elevationMm: number }[]
|
|
548
|
+
components: {
|
|
549
|
+
id: string
|
|
550
|
+
type: string
|
|
551
|
+
label: string
|
|
552
|
+
storey: number
|
|
553
|
+
minMm: number[]
|
|
554
|
+
maxMm: number[]
|
|
555
|
+
}[]
|
|
556
|
+
/** Saved graph inventory, paged with topology/components. Use these IDs after reopening a project. */
|
|
557
|
+
networks: {
|
|
558
|
+
graphId: string
|
|
559
|
+
domain: NetworkDomain
|
|
560
|
+
revision: number
|
|
561
|
+
label: string
|
|
562
|
+
componentCount: number
|
|
563
|
+
}[]
|
|
564
|
+
}
|
|
565
|
+
export interface NetworkQueryResult {
|
|
566
|
+
revision: number
|
|
567
|
+
resultJson: string
|
|
568
|
+
nextOffset: number | null
|
|
569
|
+
total: number
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/** Shared transport only. Each domain retains a separate schema and semantics. */
|
|
573
|
+
export abstract class PluginDomainNetworkApi {
|
|
574
|
+
/** Read the active proposal's architectural context before authoring. Keep one revision across pages. */
|
|
575
|
+
abstract context(
|
|
576
|
+
args?: z.input<typeof NetworkContextArgs>,
|
|
577
|
+
): PluginApiReturn<NetworkContextResult>
|
|
578
|
+
/** Validate authored JSON, pinned families and recipe evaluation without placing or saving anything.
|
|
579
|
+
* This does not build kernel meshes or certify engineering/code compliance.
|
|
580
|
+
*/
|
|
581
|
+
abstract validate(
|
|
582
|
+
args: z.input<typeof NetworkValidateArgs>,
|
|
583
|
+
): PluginApiReturn<NetworkValidation>
|
|
584
|
+
/** Construct each node on its authored storey, with one undo command and queued project persistence.
|
|
585
|
+
* Networks can span storeys. Reuse requestId on retry; components returns the durable node mapping.
|
|
586
|
+
* Coordinates are world millimetres, Y-up; rotations are degrees. No engineering rules are inferred.
|
|
587
|
+
* Throws for stale architecture, invalid references/geometry or conflicting retries.
|
|
588
|
+
*/
|
|
589
|
+
abstract create(
|
|
590
|
+
args: z.input<typeof NetworkCreateArgs>,
|
|
591
|
+
): PluginApiReturn<NetworkCreateResult>
|
|
592
|
+
/** Read one saved graph in the active proposal; null on miss. IDs are durable, not worker handles. */
|
|
593
|
+
abstract get(
|
|
594
|
+
args: z.input<typeof NetworkGetArgs>,
|
|
595
|
+
): PluginApiReturn<SavedNetworkGraph | null>
|
|
596
|
+
/** Read bounded authored topology in graph revision. Crossings do not connect. No clash/compliance claims. */
|
|
597
|
+
abstract query(
|
|
598
|
+
args: z.input<typeof NetworkQueryArgs>,
|
|
599
|
+
): PluginApiReturn<NetworkQueryResult>
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/** Electrical equipment, physical routes and logical circuits, constructed from agent-authored intent. */
|
|
603
|
+
export abstract class PluginElectricalApi extends PluginDomainNetworkApi {}
|
|
604
|
+
/** Plumbing equipment and routed pipe networks, constructed from agent-authored intent. */
|
|
605
|
+
export abstract class PluginPlumbingApi extends PluginDomainNetworkApi {}
|
|
606
|
+
/** Family-backed air-side HVAC networks. The agent authors engineering intent; the host constructs it. */
|
|
607
|
+
export abstract class PluginMechanicalApi extends PluginDomainNetworkApi {}
|