@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.
Files changed (261) hide show
  1. package/CHANGELOG.md +152 -1
  2. package/api-manifest.json +3620 -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 +349 -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 +282 -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 +4582 -1422
  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 +4171 -1411
  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 +388 -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 +217 -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,496 @@
1
+ import * as z from "zod"
2
+ import { PluginApiReturn } from "../../../../types"
3
+ import {
4
+ Vec3Handle,
5
+ UnderlayHandle,
6
+ TerrainHandle,
7
+ ImportJobHandle,
8
+ ComponentHandle,
9
+ } from "../../../../handles"
10
+
11
+ /**
12
+ * A file `source` accepted by every importer: an `https://` URL or a `data:`
13
+ * URL (base64). Validated for shape at the boundary — other schemes (`http:`,
14
+ * `blob:`, `file:`) are rejected, since the host page (HTTPS) cannot fetch them.
15
+ */
16
+ export const ImportSource = z
17
+ .string()
18
+ .min(1)
19
+ .refine((s) => s.startsWith("https://") || s.startsWith("data:"), {
20
+ message: "source must be an https:// URL or a data: URL",
21
+ })
22
+
23
+ /**
24
+ * File import — bring external files into the Snaptrude **scene**.
25
+ *
26
+ * `core.io.import.*` ingests images, PDFs, CAD drawings, 3D models, and site
27
+ * terrain and commits them to the model as traceable underlays, placed geometry,
28
+ * or topography. It is the scene counterpart to `presentation.import.*` (which
29
+ * drops assets on the Present canvas, not the model).
30
+ *
31
+ * ## The `source` argument
32
+ * Every file importer takes a single `source` **string** — either an `https://`
33
+ * URL or a `data:` URL (base64). A plugin worker cannot hand a browser `File`
34
+ * across the boundary, so the host fetches `source` and rebuilds the `File`
35
+ * itself. Both forms go through the same path.
36
+ *
37
+ * ## Return values
38
+ * - `image` / `pdf` / `cadJson` → an {@linkcode UnderlayHandle} (a placed 2D
39
+ * reference plane; drive it with `core.io.underlay.*`).
40
+ * - `dwg` → an {@linkcode ImportJobHandle} — DWG conversion is a long server job,
41
+ * so `dwg` returns immediately and you poll it with `core.io.job.*`.
42
+ * - `model` → a {@linkcode ComponentHandle} (a placed 3D component).
43
+ * - `terrain` → a {@linkcode TerrainHandle} (the project's single site terrain).
44
+ *
45
+ * Every importer **throws** on failure (bad source, unsupported format, engine
46
+ * error). Accessed via `snaptrude.core.io.import`.
47
+ */
48
+ export abstract class PluginCoreIoImportApi {
49
+ constructor() {}
50
+
51
+ /**
52
+ * Import a raster image as a scene **underlay** — a flat, textured reference
53
+ * plane placed on a storey that you can trace over.
54
+ *
55
+ * Supported formats: PNG, JPG/JPEG, BMP. The image is placed on the target
56
+ * storey's "Image" layer at ~50% opacity by default.
57
+ *
58
+ * To place the image on a **Present-mode sheet** instead of the scene, use
59
+ * `presentation.import.image`.
60
+ *
61
+ * The plane is placed at the storey origin (the engine's import placement);
62
+ * there is no placement parameter — calibrate size with
63
+ * {@link PluginCoreIoUnderlayApi.setScale} after import.
64
+ *
65
+ * @param source - The image to import: an `https://` URL or a `data:` URL.
66
+ * @param storey - Target storey number. Defaults to the active storey.
67
+ * @param scale - Initial uniform scale factor applied to the plane. Calibrate
68
+ * precisely afterwards with {@link PluginCoreIoUnderlayApi.setScale}.
69
+ * @param opacity - Plane opacity, `0`..`1` (default ~`0.5`).
70
+ * @param label - A name for the created underlay.
71
+ * @returns the created {@linkcode UnderlayHandle}.
72
+ * @throws if writes are disabled, the source can't be loaded, the format is
73
+ * unsupported, or the engine fails to place the plane.
74
+ *
75
+ * @examplePrompt Import this floor plan image onto the ground floor to trace over
76
+ * @examplePrompt Drop this survey PNG in as a reference underlay at 30% opacity
77
+ * @examplePrompt Add a site plan image on storey 2
78
+ * @examplePrompt Bring in a sketch to trace, faded to half opacity
79
+ *
80
+ * # Example
81
+ * ```ts
82
+ * // Place a floor plan on storey 1, then calibrate it to a real-world size.
83
+ * const plan = await snaptrude.core.io.import.image(
84
+ * "https://example.com/floorplan.png",
85
+ * 1, // storey
86
+ * undefined, // scale
87
+ * 0.4, // opacity
88
+ * "Ground floor plan",
89
+ * )
90
+ * // Make the plan's longest side exactly 40 project-units:
91
+ * await snaptrude.core.io.underlay.setScale(plan, { planSize: 40 })
92
+ * ```
93
+ */
94
+ public abstract image(
95
+ source: string,
96
+ storey?: number,
97
+ scale?: number,
98
+ opacity?: number,
99
+ label?: string,
100
+ ): PluginApiReturn<UnderlayHandle>
101
+
102
+ /**
103
+ * Import one page of a PDF as a scene **underlay** (a traceable reference plane).
104
+ *
105
+ * One PDF per storey, one page per call. To bring in several pages, call once
106
+ * per page onto different storeys.
107
+ *
108
+ * @param source - The PDF to import: an `https://` URL or a `data:` URL.
109
+ * @param storey - Target storey number. Defaults to the active storey.
110
+ * @param page - 1-based page number to import (multi-page PDFs). Default `1`.
111
+ * @param scale - A drawing-scale **label** that sizes the page in real-world
112
+ * units, matching the project's unit mode: metric `"1:10"`..`"1:1000"` (e.g.
113
+ * `"1:100"`) or imperial `` `1/8" = 1'` `` / `` `1" = 10'` ``. Must be a valid
114
+ * label for the current unit mode (invalid → throws). Defaults to `"1:100"`
115
+ * in metric projects and `` `1" = 1'` `` in imperial projects. Re-calibrate
116
+ * afterwards with {@link PluginCoreIoUnderlayApi.setScale}.
117
+ * @param opacity - Plane opacity, `0`..`1` (default ~`0.5`).
118
+ * @returns the created {@linkcode UnderlayHandle}.
119
+ * @throws if writes are disabled, the source can't be loaded, the storey
120
+ * already has a PDF, the page is out of range, the scale label is invalid for
121
+ * the unit mode, or the engine fails.
122
+ *
123
+ * @examplePrompt Import page 1 of this PDF floor plan onto storey 1
124
+ * @examplePrompt Bring in the second page of this PDF as an underlay at 1:50
125
+ * @examplePrompt Add this PDF plan to the ground floor to trace over
126
+ * @examplePrompt Place page 3 of the drawing set on storey 3
127
+ *
128
+ * # Example
129
+ * ```ts
130
+ * const sheet = await snaptrude.core.io.import.pdf(
131
+ * "https://example.com/plans.pdf",
132
+ * 1, // storey
133
+ * 2, // page
134
+ * "1:100", // drawing scale
135
+ * )
136
+ * ```
137
+ */
138
+ public abstract pdf(
139
+ source: string,
140
+ storey?: number,
141
+ page?: number,
142
+ scale?: string,
143
+ opacity?: number,
144
+ ): PluginApiReturn<UnderlayHandle>
145
+
146
+ /**
147
+ * Import a **DWG** CAD drawing as a scene underlay. `.dwg` only (no DXF).
148
+ *
149
+ * DWG conversion runs on a server and can take minutes, so this **starts a job
150
+ * and returns immediately** with an {@linkcode ImportJobHandle}. One CAD
151
+ * import runs at a time: starting a second while one is in flight throws —
152
+ * poll the first job to completion first. Poll it with
153
+ * {@link PluginCoreIoJobApi.isComplete} / {@link PluginCoreIoJobApi.getStatus}, then call
154
+ * {@link PluginCoreIoJobApi.getResult} to get the placed {@linkcode UnderlayHandle}.
155
+ * For CAD you already have parsed as JSON, use {@link PluginCoreIoImportApi.cadJson}
156
+ * (synchronous, no server round-trip).
157
+ *
158
+ * All CAD layers are imported (there is no layer filter).
159
+ *
160
+ * @param source - The `.dwg` file: an `https://` URL or a `data:` URL.
161
+ * @param storey - Target storey number. Defaults to the active storey.
162
+ * @returns an {@linkcode ImportJobHandle} to poll via `core.io.job.*`.
163
+ * @throws if writes are disabled or the upload cannot be started. (Conversion
164
+ * failures surface later via {@link PluginCoreIoJobApi.getError}.)
165
+ *
166
+ * @examplePrompt Import this DWG floor plan onto storey 1
167
+ * @examplePrompt Bring in a CAD drawing as an underlay and tell me when it's ready
168
+ * @examplePrompt Start importing this CAD file onto the ground floor
169
+ *
170
+ * # Example
171
+ * ```ts
172
+ * const job = await snaptrude.core.io.import.dwg("https://example.com/plan.dwg", 1)
173
+ * // Poll until the server-side conversion finishes — always with a timeout
174
+ * // (a UI-cancelled import stays "processing" forever).
175
+ * const deadline = Date.now() + 5 * 60_000
176
+ * while (!(await snaptrude.core.io.job.isComplete(job))) {
177
+ * if (Date.now() > deadline) throw new Error("DWG import timed out")
178
+ * await new Promise((r) => setTimeout(r, 2000))
179
+ * }
180
+ * // The DWG lands as a CAD underlay. CAD scaling isn't supported; manage it
181
+ * // (list / fade / delete) via core.io.underlay.*.
182
+ * const cad = await snaptrude.core.io.job.getResult(job)
183
+ * if (cad) console.log("DWG imported as CAD underlay:", cad)
184
+ * ```
185
+ */
186
+ public abstract dwg(source: string, storey?: number): PluginApiReturn<ImportJobHandle>
187
+
188
+ /**
189
+ * Sketch a CAD underlay from **already-parsed CAD JSON** — synchronous, with no
190
+ * server round-trip. Use this when you hold parsed CAD data (e.g. produced by
191
+ * your own converter); use {@link PluginCoreIoImportApi.dwg} for raw `.dwg`
192
+ * files.
193
+ *
194
+ * All layers in the JSON are sketched (there is no layer filter), at the
195
+ * drawing's own coordinates.
196
+ *
197
+ * @param cad - The parsed CAD data: `{ unit, geometry: [...] }` describing the
198
+ * drawing's lines/arcs/layers.
199
+ * @param storey - Target storey number. Defaults to the active storey.
200
+ * @returns the created {@linkcode UnderlayHandle}.
201
+ * @throws if writes are disabled, the JSON yields no drawable geometry, or the
202
+ * drawing is out of bounds.
203
+ *
204
+ * @examplePrompt Sketch this parsed CAD JSON onto the active storey
205
+ * @examplePrompt Draw these CAD curves as an underlay on storey 2
206
+ * @examplePrompt Create a CAD sketch from this geometry data
207
+ * @examplePrompt Import my converted CAD JSON onto the ground floor
208
+ *
209
+ * # Example
210
+ * ```ts
211
+ * const cad = await snaptrude.core.io.import.cadJson(
212
+ * { unit: "mm", geometry: [{ type: "line", layer: "WALLS", ... }] },
213
+ * 1,
214
+ * )
215
+ * ```
216
+ */
217
+ public abstract cadJson(cad: CadJsonInput, storey?: number): PluginApiReturn<UnderlayHandle>
218
+
219
+ /**
220
+ * Import a **3D model** file and place it in the scene as a component.
221
+ *
222
+ * Supported formats: SketchUp (`.skp`), FBX (`.fbx`), OBJ (`.obj`), 3DS
223
+ * (`.3ds`), and zipped bundles (`.zip`). The file is converted on the server,
224
+ * then placed. `.glb`/`.gltf`/`.ifc`/`.stl` and Rhino/Revit are not supported.
225
+ *
226
+ * The model is placed at its source dimensions (interpreted in the file's own
227
+ * units); there is no import-time scale override.
228
+ *
229
+ * Unlike `dwg`, this call **waits for the server conversion**: a large model
230
+ * may exceed the 60-second call cap and reject at the API boundary while the
231
+ * import still completes in the background (the model then appears without a
232
+ * handle being returned — re-query the scene to find it). Keep sources small.
233
+ *
234
+ * @param source - The model file: an `https://` URL or a `data:` URL.
235
+ * @param storey - Target storey number. Defaults to the active storey.
236
+ * @param format - The file's format. Inferred from `source` when omitted.
237
+ * @param position - Where to place the model. Defaults to the storey origin.
238
+ * @param label - A name for the placed component.
239
+ * @returns the placed {@linkcode ComponentHandle}.
240
+ * @throws if writes are disabled, the source can't be loaded, the format is
241
+ * unsupported, conversion/placement fails, or the converted model cannot be
242
+ * found in the library after upload.
243
+ *
244
+ * @examplePrompt Import this SketchUp model onto storey 1
245
+ * @examplePrompt Bring in this OBJ file and place it at the origin
246
+ * @examplePrompt Add this 3D model to the ground floor
247
+ *
248
+ * # Example
249
+ * ```ts
250
+ * const model = await snaptrude.core.io.import.model(
251
+ * "https://example.com/tree.skp",
252
+ * 1, // storey
253
+ * "skp",
254
+ * )
255
+ * ```
256
+ */
257
+ public abstract model(
258
+ source: string,
259
+ storey?: number,
260
+ format?: ModelFormat,
261
+ position?: Vec3Handle,
262
+ label?: string,
263
+ ): PluginApiReturn<ComponentHandle>
264
+
265
+ /**
266
+ * Import **site terrain** for a location — Mapbox topography (elevation +
267
+ * satellite/streets imagery, optional neighborhood buildings and parcels).
268
+ *
269
+ * One terrain per project (a singleton). `width`/`length` describe the
270
+ * real-world extent of the area to load **in metres** (regardless of the
271
+ * project's unit mode); the host converts them to the right map zoom
272
+ * internally — you do not pass a zoom level.
273
+ *
274
+ * @param lat - Site latitude (degrees), `-90`..`90`.
275
+ * @param lng - Site longitude (degrees), `-180`..`180`.
276
+ * @param width - East–west extent of the area to load, in metres.
277
+ * @param length - North–south extent of the area to load, in metres.
278
+ * @param elevation - Include DEM elevation (a real terrain surface). Default `true`.
279
+ * @param satellite - Drape satellite imagery. Default `true`.
280
+ * @param neighborhood - Include surrounding context buildings. Default `false`.
281
+ * @param parcels - Include site parcel boundaries. Default `false`.
282
+ * @returns the created {@linkcode TerrainHandle}.
283
+ * @throws if writes are disabled, a terrain already exists, or the map/mesh
284
+ * generation fails.
285
+ *
286
+ * @examplePrompt Import the site terrain for this location, about 500m across
287
+ * @examplePrompt Load the topography at 40.7128, -74.0060 for a 300 by 300 meter site
288
+ * @examplePrompt Bring in satellite terrain for the site with the surrounding buildings
289
+ * @examplePrompt Add site elevation for a 1km by 1km area at these coordinates
290
+ *
291
+ * # Example
292
+ * ```ts
293
+ * // 300m × 300m site with elevation + satellite imagery.
294
+ * const terrain = await snaptrude.core.io.import.terrain(
295
+ * 40.7128, // lat
296
+ * -74.006, // lng
297
+ * 300, // width (metres)
298
+ * 300, // length (metres)
299
+ * true, // elevation
300
+ * true, // satellite
301
+ * )
302
+ * ```
303
+ */
304
+ public abstract terrain(
305
+ lat: number,
306
+ lng: number,
307
+ width: number,
308
+ length: number,
309
+ elevation?: boolean,
310
+ satellite?: boolean,
311
+ neighborhood?: boolean,
312
+ parcels?: boolean,
313
+ ): PluginApiReturn<TerrainHandle>
314
+
315
+ /**
316
+ * Import an **EPW weather file** into the project's weather catalog.
317
+ *
318
+ * Uploads an EnergyPlus Weather (`.epw`) file and registers it as the
319
+ * project's site weather, returning its catalog `weatherFileId` — the same id
320
+ * {@link PluginAnalysisWeatherApi.getSeries}, `program.site.getWeather`, and a
321
+ * daylight run's provenance report. Uploading a user file makes the site's
322
+ * `selectionMethod` `"user-upload"`, overriding nearest-station resolution.
323
+ *
324
+ * **Mutating**: this writes project state and is subject to the plugin
325
+ * write-gate — it throws when plugin writes are disabled. Unlike the file
326
+ * underlay/model importers it returns no scene handle (a weather file is not
327
+ * a scene object), only the catalog `{ weatherFileId, label }`.
328
+ *
329
+ * @param source - The `.epw` file to import: an `https://` URL or a `data:` URL.
330
+ * @returns A {@linkcode PluginImportEpwResult} — the catalog `weatherFileId`
331
+ * and a human-readable `label` (the station/file name).
332
+ * @throws if writes are disabled, the source can't be loaded, or the file is
333
+ * not a valid EPW.
334
+ *
335
+ * @examplePrompt Import this EPW weather file for the site
336
+ * @examplePrompt Upload a custom weather file for the daylight analysis
337
+ * @examplePrompt Use this .epw as the project's weather source
338
+ *
339
+ * # Example
340
+ * ```ts
341
+ * const { weatherFileId, label } = await snaptrude.core.io.import.epw(
342
+ * "https://example.com/Chicago-OHare.epw",
343
+ * )
344
+ * console.log(`Weather set to ${label} (${weatherFileId})`)
345
+ * ```
346
+ */
347
+ public abstract epw(source: string): PluginApiReturn<PluginImportEpwResult>
348
+ }
349
+
350
+ /**
351
+ * Supported 3D model import formats. `.glb`/`.gltf`/`.ifc`/`.stl` and Rhino/Revit
352
+ * are intentionally excluded (no in-app import path).
353
+ */
354
+ export const ModelFormat = z.enum(["skp", "fbx", "obj", "3ds", "zip"])
355
+ export type ModelFormat = z.infer<typeof ModelFormat>
356
+
357
+ /**
358
+ * Parsed CAD JSON accepted by {@link PluginCoreIoImportApi.cadJson}. `unit` sets
359
+ * the drawing's length unit; `geometry` is the array of CAD entities (lines,
360
+ * polylines, arcs, circles), each tagged with its CAD `layer`. Additional fields
361
+ * are passed through untouched.
362
+ */
363
+ export const CadJsonInput = z
364
+ .object({
365
+ unit: z.string().optional(),
366
+ geometry: z.array(z.record(z.string(), z.unknown())).optional(),
367
+ })
368
+ .passthrough()
369
+ export type CadJsonInput = z.infer<typeof CadJsonInput>
370
+
371
+ /**
372
+ * Arguments for {@link PluginCoreIoImportApi.image}.
373
+ *
374
+ * | Property | Type | Description |
375
+ * |---|---|---|
376
+ * | `source` | `string` | Image `https://` URL or `data:` URL (png/jpg/jpeg/bmp) |
377
+ * | `storey` | `number`? | Target storey (default: active) |
378
+ * | `scale` | `number`? | Initial uniform scale |
379
+ * | `opacity` | `number`? | `0`..`1` (default ~`0.5`) |
380
+ * | `label` | `string`? | Name for the underlay |
381
+ */
382
+ export const PluginImportImageArgs = z.object({
383
+ source: ImportSource,
384
+ storey: z.number().int().optional(),
385
+ scale: z.number().positive().optional(),
386
+ opacity: z.number().min(0).max(1).optional(),
387
+ label: z.string().optional(),
388
+ })
389
+ export type PluginImportImageArgs = z.infer<typeof PluginImportImageArgs>
390
+
391
+ /**
392
+ * Arguments for {@link PluginCoreIoImportApi.pdf}.
393
+ *
394
+ * | Property | Type | Description |
395
+ * |---|---|---|
396
+ * | `source` | `string` | PDF `https://` URL or `data:` URL |
397
+ * | `storey` | `number`? | Target storey (default: active) |
398
+ * | `page` | `number`? | 1-based page (default `1`) |
399
+ * | `scale` | `string`? | Drawing-scale label, e.g. `"1:100"` |
400
+ * | `opacity` | `number`? | `0`..`1` (default ~`0.5`) |
401
+ */
402
+ export const PluginImportPdfArgs = z.object({
403
+ source: ImportSource,
404
+ storey: z.number().int().optional(),
405
+ page: z.number().int().positive().optional(),
406
+ scale: z.string().optional(),
407
+ opacity: z.number().min(0).max(1).optional(),
408
+ })
409
+ export type PluginImportPdfArgs = z.infer<typeof PluginImportPdfArgs>
410
+
411
+ /** Arguments for {@link PluginCoreIoImportApi.dwg}. */
412
+ export const PluginImportDwgArgs = z.object({
413
+ source: ImportSource,
414
+ storey: z.number().int().optional(),
415
+ })
416
+ export type PluginImportDwgArgs = z.infer<typeof PluginImportDwgArgs>
417
+
418
+ /** Arguments for {@link PluginCoreIoImportApi.cadJson}. */
419
+ export const PluginImportCadJsonArgs = z.object({
420
+ cad: CadJsonInput,
421
+ storey: z.number().int().optional(),
422
+ })
423
+ export type PluginImportCadJsonArgs = z.infer<typeof PluginImportCadJsonArgs>
424
+
425
+ /**
426
+ * Arguments for {@link PluginCoreIoImportApi.model}.
427
+ *
428
+ * | Property | Type | Description |
429
+ * |---|---|---|
430
+ * | `source` | `string` | Model `https://` URL or `data:` URL |
431
+ * | `storey` | `number`? | Target storey (default: active) |
432
+ * | `format` | {@link ModelFormat}? | File format (inferred when omitted) |
433
+ * | `position` | {@link Vec3Handle}? | Placement (default: storey origin) |
434
+ * | `label` | `string`? | Name for the component |
435
+ */
436
+ export const PluginImportModelArgs = z.object({
437
+ source: ImportSource,
438
+ storey: z.number().int().optional(),
439
+ format: ModelFormat.optional(),
440
+ position: Vec3Handle.optional(),
441
+ label: z.string().optional(),
442
+ })
443
+ export type PluginImportModelArgs = z.infer<typeof PluginImportModelArgs>
444
+
445
+ /**
446
+ * Arguments for {@link PluginCoreIoImportApi.terrain}.
447
+ *
448
+ * | Property | Type | Description |
449
+ * |---|---|---|
450
+ * | `lat` | `number` | Latitude (degrees), `-90`..`90` |
451
+ * | `lng` | `number` | Longitude (degrees), `-180`..`180` |
452
+ * | `width` | `number` | East–west extent, metres |
453
+ * | `length` | `number` | North–south extent, metres |
454
+ * | `elevation` | `boolean`? | Include DEM elevation (default `true`) |
455
+ * | `satellite` | `boolean`? | Drape satellite imagery (default `true`) |
456
+ * | `neighborhood` | `boolean`? | Include context buildings (default `false`) |
457
+ * | `parcels` | `boolean`? | Include parcel boundaries (default `false`) |
458
+ */
459
+ export const PluginImportTerrainArgs = z.object({
460
+ lat: z.number().min(-90).max(90),
461
+ lng: z.number().min(-180).max(180),
462
+ width: z.number().positive().finite(),
463
+ length: z.number().positive().finite(),
464
+ elevation: z.boolean().optional(),
465
+ satellite: z.boolean().optional(),
466
+ neighborhood: z.boolean().optional(),
467
+ parcels: z.boolean().optional(),
468
+ })
469
+ export type PluginImportTerrainArgs = z.infer<typeof PluginImportTerrainArgs>
470
+
471
+ /**
472
+ * Arguments for {@link PluginCoreIoImportApi.epw}.
473
+ *
474
+ * | Property | Type | Description |
475
+ * |---|---|---|
476
+ * | `source` | `string` | EPW `https://` URL or `data:` URL |
477
+ */
478
+ export const PluginImportEpwArgs = z.object({
479
+ source: ImportSource,
480
+ })
481
+ export type PluginImportEpwArgs = z.infer<typeof PluginImportEpwArgs>
482
+
483
+ /**
484
+ * Result of {@link PluginCoreIoImportApi.epw} — the imported weather file's
485
+ * catalog entry.
486
+ *
487
+ * | Property | Type | Description |
488
+ * |---|---|---|
489
+ * | `weatherFileId` | `string` | Catalog id (same key as `analysis.weather`'s `weatherFileId`) |
490
+ * | `label` | `string` | Human-readable name (station / file name) |
491
+ */
492
+ export const PluginImportEpwResult = z.object({
493
+ weatherFileId: z.string(),
494
+ label: z.string(),
495
+ })
496
+ export type PluginImportEpwResult = z.infer<typeof PluginImportEpwResult>
@@ -0,0 +1,42 @@
1
+ import { PluginCoreIoImportApi } from "./import"
2
+ import { PluginCoreIoJobApi } from "./job"
3
+ import { PluginCoreIoUnderlayApi } from "./underlay"
4
+ import { PluginCoreIoTerrainApi } from "./terrain"
5
+ import { PluginCoreIoQueryApi } from "./query"
6
+ import { PluginCoreIoExportApi } from "./export"
7
+
8
+ /**
9
+ * I/O — bring external files into the project and manage what was imported.
10
+ *
11
+ * - {@linkcode PluginCoreIoApi.import} — import images, PDFs, CAD, 3D models, terrain
12
+ * - {@linkcode PluginCoreIoApi.query} — read source metadata before importing (pdf pages, cad layers)
13
+ * - {@linkcode PluginCoreIoApi.job} — poll long-running async imports (e.g. DWG)
14
+ * - {@linkcode PluginCoreIoApi.underlay} — inspect/scale/opacity/delete placed underlays
15
+ * - {@linkcode PluginCoreIoApi.terrain} — inspect/edit the site terrain (datum, layers, delete)
16
+ * - {@linkcode PluginCoreIoApi.export} — serialize the model to glb/obj (base64 bytes)
17
+ *
18
+ * Accessed via `snaptrude.core.io`.
19
+ */
20
+ export abstract class PluginCoreIoApi {
21
+ /** Import external files into the scene. See {@linkcode PluginCoreIoImportApi}. */
22
+ public abstract import: PluginCoreIoImportApi
23
+ /** Read source metadata before import. See {@linkcode PluginCoreIoQueryApi}. */
24
+ public abstract query: PluginCoreIoQueryApi
25
+ /** Poll long-running import jobs. See {@linkcode PluginCoreIoJobApi}. */
26
+ public abstract job: PluginCoreIoJobApi
27
+ /** Inspect and edit placed underlays. See {@linkcode PluginCoreIoUnderlayApi}. */
28
+ public abstract underlay: PluginCoreIoUnderlayApi
29
+ /** Inspect and manage the site terrain. See {@linkcode PluginCoreIoTerrainApi}. */
30
+ public abstract terrain: PluginCoreIoTerrainApi
31
+ /** Serialize the model to a downloadable 3D file. See {@linkcode PluginCoreIoExportApi}. */
32
+ public abstract export: PluginCoreIoExportApi
33
+
34
+ constructor() {}
35
+ }
36
+
37
+ export * from "./import"
38
+ export * from "./job"
39
+ export * from "./underlay"
40
+ export * from "./terrain"
41
+ export * from "./query"
42
+ export * from "./export"
@@ -0,0 +1,140 @@
1
+ import * as z from "zod"
2
+ import { PluginApiReturn } from "../../../../types"
3
+ import { ImportJobHandle, UnderlayHandle } from "../../../../handles"
4
+
5
+ /**
6
+ * Import jobs — poll a long-running asynchronous import.
7
+ *
8
+ * Some imports run on a server and take a while (today: `core.io.import.dwg`,
9
+ * whose DWG → Snaptrude conversion can take minutes). Those importers return an
10
+ * {@linkcode ImportJobHandle} immediately instead of blocking; you drive the job
11
+ * to completion here:
12
+ *
13
+ * 1. poll {@link PluginCoreIoJobApi.isComplete} (or read {@link PluginCoreIoJobApi.getStatus}),
14
+ * 2. once complete, call {@link PluginCoreIoJobApi.getResult} for the placed handle,
15
+ * 3. or read {@link PluginCoreIoJobApi.getError} if it failed.
16
+ *
17
+ * **Always poll with a timeout.** If the import is cancelled from the app UI
18
+ * (or the tab reloads mid-conversion), the job never reaches a terminal state
19
+ * and `getStatus` keeps returning `"processing"` — an unbounded poll loop would
20
+ * spin forever. Give up after a few minutes and surface that to the user.
21
+ *
22
+ * Accessed via `snaptrude.core.io.job`.
23
+ */
24
+ export abstract class PluginCoreIoJobApi {
25
+ constructor() {}
26
+
27
+ /**
28
+ * Read a job's current status: `"pending"` (queued), `"processing"` (running),
29
+ * `"complete"` (result ready), or `"failed"`.
30
+ *
31
+ * Limitation: a job cancelled from the app UI never turns `"failed"` — it
32
+ * stays `"processing"` indefinitely. Bound your poll loop with a timeout.
33
+ *
34
+ * @param job - The import job to inspect.
35
+ * @returns the {@linkcode ImportJobStatus}.
36
+ * @throws {@link HandleInvalidError} if the job handle is unknown.
37
+ *
38
+ * @examplePrompt What's the status of my DWG import?
39
+ * @examplePrompt Is the CAD import still processing?
40
+ * @examplePrompt Check where the import job is up to
41
+ * @examplePrompt Did the import job fail?
42
+ *
43
+ * # Example
44
+ * ```ts
45
+ * const job = await snaptrude.core.io.import.dwg(url, 1)
46
+ * console.log(await snaptrude.core.io.job.getStatus(job)) // "processing"
47
+ * ```
48
+ */
49
+ public abstract getStatus(job: ImportJobHandle): PluginApiReturn<ImportJobStatus>
50
+
51
+ /**
52
+ * Whether the job has finished successfully (status is `"complete"` and a
53
+ * result is ready). Returns `false` while pending/processing and on failure.
54
+ *
55
+ * @param job - The import job to inspect.
56
+ * @throws {@link HandleInvalidError} if the job handle is unknown.
57
+ *
58
+ * @examplePrompt Is the DWG import done yet?
59
+ * @examplePrompt Has the CAD import finished?
60
+ * @examplePrompt Tell me when the import job completes
61
+ * @examplePrompt Is my import ready?
62
+ *
63
+ * # Example
64
+ * ```ts
65
+ * const job = await snaptrude.core.io.import.dwg(url, 1)
66
+ * const deadline = Date.now() + 5 * 60_000 // cap the poll — see getStatus limitation
67
+ * while (!(await snaptrude.core.io.job.isComplete(job))) {
68
+ * if (Date.now() > deadline) throw new Error("DWG import timed out")
69
+ * await new Promise((r) => setTimeout(r, 2000))
70
+ * }
71
+ * ```
72
+ */
73
+ public abstract isComplete(job: ImportJobHandle): PluginApiReturn<boolean>
74
+
75
+ /**
76
+ * The imported result once the job is complete — the placed
77
+ * {@linkcode UnderlayHandle}. Returns `null` while the job is still
78
+ * pending/processing or if it failed (check {@link PluginCoreIoJobApi.getError}).
79
+ *
80
+ * @param job - The completed import job.
81
+ * @throws {@link HandleInvalidError} if the job handle is unknown.
82
+ *
83
+ * @examplePrompt Get the underlay from my finished DWG import
84
+ * @examplePrompt Give me the result of the CAD import job
85
+ * @examplePrompt Fetch the imported CAD sketch once it's ready
86
+ * @examplePrompt Return the handle for the completed import
87
+ *
88
+ * # Example
89
+ * ```ts
90
+ * const job = await snaptrude.core.io.import.dwg(url, 1)
91
+ * const deadline = Date.now() + 5 * 60_000
92
+ * while (!(await snaptrude.core.io.job.isComplete(job))) {
93
+ * if (Date.now() > deadline) throw new Error("DWG import timed out")
94
+ * await new Promise((r) => setTimeout(r, 2000))
95
+ * }
96
+ * // DWG results are CAD underlays (CAD scaling isn't supported); manage them
97
+ * // via core.io.underlay.* (list / setOpacity / delete).
98
+ * const cad = await snaptrude.core.io.job.getResult(job)
99
+ * if (cad) console.log("import complete:", cad)
100
+ * ```
101
+ */
102
+ public abstract getResult(job: ImportJobHandle): PluginApiReturn<UnderlayHandle | null>
103
+
104
+ /**
105
+ * The failure message if the job's status is `"failed"`; otherwise `null`.
106
+ *
107
+ * @param job - The import job to inspect.
108
+ * @throws {@link HandleInvalidError} if the job handle is unknown.
109
+ *
110
+ * @examplePrompt Why did my DWG import fail?
111
+ * @examplePrompt What went wrong with the CAD import?
112
+ * @examplePrompt Show the error from the failed import job
113
+ * @examplePrompt Did the import error out, and why?
114
+ *
115
+ * # Example
116
+ * ```ts
117
+ * const job = await snaptrude.core.io.import.dwg(url, 1)
118
+ * if ((await snaptrude.core.io.job.getStatus(job)) === "failed") {
119
+ * console.error(await snaptrude.core.io.job.getError(job))
120
+ * }
121
+ * ```
122
+ */
123
+ public abstract getError(job: ImportJobHandle): PluginApiReturn<string | null>
124
+ }
125
+
126
+ /** Lifecycle status of an asynchronous import job. */
127
+ export const ImportJobStatus = z.enum(["pending", "processing", "complete", "failed"])
128
+ export type ImportJobStatus = z.infer<typeof ImportJobStatus>
129
+
130
+ /**
131
+ * Arguments for the `core.io.job.*` readers.
132
+ *
133
+ * | Property | Type | Description |
134
+ * |---|---|---|
135
+ * | `job` | {@link ImportJobHandle} | The import job to inspect |
136
+ */
137
+ export const PluginImportJobArgs = z.object({
138
+ job: ImportJobHandle,
139
+ })
140
+ export type PluginImportJobArgs = z.infer<typeof PluginImportJobArgs>