@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,155 @@
1
+ import { PluginApiReturn } from "../../types"
2
+ import {
3
+ PluginAnalysisComputeResult,
4
+ PluginAnalysisJobStateResult,
5
+ } from "./sunlightHours"
6
+
7
+ /**
8
+ * Analysis illuminance — the daylight illuminance (lux) heatmap study.
9
+ *
10
+ * Computes interior daylight illuminance over a date range and renders the
11
+ * result as a heatmap on the scene. **Pro-gated**: every method that starts
12
+ * a run throws when the workspace is not on a Pro plan.
13
+ *
14
+ * Like {@linkcode PluginAnalysisSunlightHoursApi} (`analysis.sunlightHours`),
15
+ * this is an **asynchronous backend job**:
16
+ *
17
+ * 1. {@linkcode PluginAnalysisIlluminanceApi.compute} starts the job and
18
+ * returns immediately.
19
+ * 2. Poll {@linkcode PluginAnalysisIlluminanceApi.get} until `status` is
20
+ * `"active"` (heatmap rendered) — a run typically takes minutes. There is
21
+ * no completion event; polling is the pattern.
22
+ * 3. {@linkcode PluginAnalysisIlluminanceApi.cancel} aborts an in-flight
23
+ * run; {@linkcode PluginAnalysisIlluminanceApi.reset} clears a rendered
24
+ * heatmap.
25
+ *
26
+ * Illuminance analyses BIM slab and roof objects (floors, roofs, …) — walls
27
+ * or bare Masses are not enough — and requires the 3D view. Heatmaps are invalidated by
28
+ * scene-mutating edits. Dates cross as ISO 8601 date strings
29
+ * (`"YYYY-MM-DD"`).
30
+ *
31
+ * Accessed via `snaptrude.analysis.illuminance`.
32
+ */
33
+ export abstract class PluginAnalysisIlluminanceApi {
34
+ constructor() {}
35
+
36
+ /**
37
+ * Start a daylight-illuminance run for a date range.
38
+ *
39
+ * Starts the backend job and **returns immediately** — it does not wait
40
+ * for the heatmap. Poll {@linkcode PluginAnalysisIlluminanceApi.get} until
41
+ * `status` is `"active"`. Starting a new run while one is in flight
42
+ * replaces it. Shadows and the heatmap analyses are mutually exclusive in
43
+ * the product: starting a run disables real-time shadows and resets/cancels
44
+ * any {@linkcode PluginAnalysisSunlightHoursApi}
45
+ * (`analysis.sunlightHours`) study.
46
+ *
47
+ * @param startDate - Start of the study range, ISO date `"YYYY-MM-DD"`.
48
+ * @param endDate - End of the study range, ISO date `"YYYY-MM-DD"` (on or
49
+ * after `startDate`).
50
+ * @returns A {@linkcode PluginAnalysisComputeResult} — `{ success: true }`
51
+ * when the job was started. The `{ success: false, error }` arm is
52
+ * reserved — not yet emitted (start failures currently throw).
53
+ * @throws When the workspace is not on a **Pro** plan (illuminance is a
54
+ * Pro feature).
55
+ * @throws When the project has no geo-located site/terrain (no location to
56
+ * compute daylight for — there is no fallback location).
57
+ * @throws When the scene has no slab or roof BIM object to analyse (walls
58
+ * or bare Masses are not enough) or the editor is not in the 3D view.
59
+ * @throws When a date is not a parseable ISO date or the range is inverted.
60
+ * @throws When plugin writes are disabled.
61
+ *
62
+ * @examplePrompt Run a daylight illuminance analysis for December
63
+ * @examplePrompt Compute the lux levels inside the building for winter
64
+ * @examplePrompt How much daylight do the interior floors get?
65
+ *
66
+ * # Example
67
+ * ```ts
68
+ * const { success } = await snaptrude.analysis.illuminance.compute(
69
+ * "2026-12-01",
70
+ * "2026-12-31",
71
+ * )
72
+ * // poll until the heatmap is rendered
73
+ * let job = await snaptrude.analysis.illuminance.get()
74
+ * while (job?.status === "running") {
75
+ * await new Promise((r) => setTimeout(r, 5000))
76
+ * job = await snaptrude.analysis.illuminance.get()
77
+ * }
78
+ * ```
79
+ */
80
+ public abstract compute(
81
+ startDate: string,
82
+ endDate: string,
83
+ ): PluginApiReturn<PluginAnalysisComputeResult>
84
+
85
+ /**
86
+ * Get the state of the illuminance study.
87
+ *
88
+ * The polling read for the async job started by
89
+ * {@linkcode PluginAnalysisIlluminanceApi.compute}. `status` values:
90
+ *
91
+ * | Status | Meaning |
92
+ * |---|---|
93
+ * | `"running"` | A run is in flight — keep polling |
94
+ * | `"active"` | The heatmap is rendered on the scene |
95
+ * | `"inactive"` | A previous run exists but its heatmap is not showing |
96
+ *
97
+ * @returns A {@linkcode PluginAnalysisJobStateResult} with the `status` and
98
+ * the run's ISO `startDate`/`endDate`, or `null` when no run result is
99
+ * available (the study never ran, was cancelled, or the last run failed).
100
+ *
101
+ * @examplePrompt Is the illuminance analysis done?
102
+ * @examplePrompt Check the status of the daylight lux run
103
+ * @examplePrompt What date range was the illuminance heatmap computed for?
104
+ *
105
+ * # Example
106
+ * ```ts
107
+ * const job = await snaptrude.analysis.illuminance.get()
108
+ * if (job?.status === "active") console.log(job.startDate, job.endDate)
109
+ * ```
110
+ */
111
+ public abstract get(): PluginApiReturn<PluginAnalysisJobStateResult>
112
+
113
+ /**
114
+ * Cancel the in-flight illuminance run.
115
+ *
116
+ * Aborts the backend job. A no-op (returns `false`) when nothing is
117
+ * running.
118
+ *
119
+ * @returns `true` when a run was cancelled, `false` when nothing was
120
+ * running.
121
+ * @throws When plugin writes are disabled.
122
+ *
123
+ * @examplePrompt Cancel the illuminance analysis
124
+ * @examplePrompt Stop the running daylight computation
125
+ * @examplePrompt Abort the lux study
126
+ *
127
+ * # Example
128
+ * ```ts
129
+ * await snaptrude.analysis.illuminance.cancel()
130
+ * ```
131
+ */
132
+ public abstract cancel(): PluginApiReturn<boolean>
133
+
134
+ /**
135
+ * Clear the illuminance heatmap from the scene.
136
+ *
137
+ * Un-applies the rendered heatmap and restores the normal material view.
138
+ * A no-op (returns `false`) when no heatmap is showing. Does not cancel an
139
+ * in-flight run — use {@linkcode PluginAnalysisIlluminanceApi.cancel}.
140
+ *
141
+ * @returns `true` when a heatmap was cleared, `false` when none was
142
+ * showing.
143
+ * @throws When plugin writes are disabled.
144
+ *
145
+ * @examplePrompt Clear the illuminance heatmap
146
+ * @examplePrompt Remove the daylight lux colours from the model
147
+ * @examplePrompt Reset the illuminance analysis view
148
+ *
149
+ * # Example
150
+ * ```ts
151
+ * await snaptrude.analysis.illuminance.reset()
152
+ * ```
153
+ */
154
+ public abstract reset(): PluginApiReturn<boolean>
155
+ }
@@ -0,0 +1,61 @@
1
+ import { PluginAnalysisSunpathApi } from "./sunpath"
2
+ import { PluginAnalysisShadowsApi } from "./shadows"
3
+ import { PluginAnalysisSunlightHoursApi } from "./sunlightHours"
4
+ import { PluginAnalysisIlluminanceApi } from "./illuminance"
5
+ import { PluginAnalysisHeatmapsApi } from "./heatmaps"
6
+ import { PluginAnalysisWeatherApi } from "./weather"
7
+ import { PluginAnalysisSolarApi } from "./solar"
8
+ import { PluginAnalysisDaylightApi } from "./daylight"
9
+
10
+ /**
11
+ * Sustainability-analysis APIs.
12
+ *
13
+ * Analysis is the environmental-performance layer: sun and daylight studies
14
+ * computed for the project's geo-located site. The synchronous visual
15
+ * overlays (sun-path diagram, real-time shadows) toggle instantly; the
16
+ * heatmap studies (direct sunlight hours, daylight illuminance) are
17
+ * asynchronous backend jobs — start them, poll their state, and cancel or
18
+ * clear them. Shadows and the heatmap analyses are **mutually exclusive**
19
+ * (enabling one resets the other), exactly as in the sustainability sidebar.
20
+ * Site inputs (location, true north) are read via `program.site`.
21
+ *
22
+ * - {@linkcode PluginAnalysisApi.sunpath} — Toggle & query the sun-path diagram overlay
23
+ * - {@linkcode PluginAnalysisApi.shadows} — Toggle real-time shadows and scrub the sun's date-time
24
+ * - {@linkcode PluginAnalysisApi.sunlightHours} — Direct-sunlight-hours heatmap job (start / poll / cancel / clear)
25
+ * - {@linkcode PluginAnalysisApi.illuminance} — Daylight-illuminance heatmap job, Pro-gated (start / poll / cancel / clear)
26
+ * - {@linkcode PluginAnalysisApi.heatmaps} — Render plugin-computed scalar data as a heatmap (per-space / grid)
27
+ * - {@linkcode PluginAnalysisApi.weather} — Read the site's typical-year weather series (numeric, paged)
28
+ * - {@linkcode PluginAnalysisApi.solar} — Sample solar exposure at caller-chosen points (numeric)
29
+ * - {@linkcode PluginAnalysisApi.daylight} — Standards-grade annual daylight metrics (IES LM-83, numeric)
30
+ *
31
+ * Accessed via `snaptrude.analysis`.
32
+ */
33
+ export abstract class PluginAnalysisApi {
34
+ /** Sun-path diagram overlay — enable/disable/isActive. See {@linkcode PluginAnalysisSunpathApi}. */
35
+ public abstract sunpath: PluginAnalysisSunpathApi
36
+ /** Real-time sun shadows + sun date-time. See {@linkcode PluginAnalysisShadowsApi}. */
37
+ public abstract shadows: PluginAnalysisShadowsApi
38
+ /** Direct-sunlight-hours heatmap job. See {@linkcode PluginAnalysisSunlightHoursApi}. */
39
+ public abstract sunlightHours: PluginAnalysisSunlightHoursApi
40
+ /** Daylight-illuminance heatmap job (Pro). See {@linkcode PluginAnalysisIlluminanceApi}. */
41
+ public abstract illuminance: PluginAnalysisIlluminanceApi
42
+ /** Plugin-supplied scalar-data heatmaps. See {@linkcode PluginAnalysisHeatmapsApi}. */
43
+ public abstract heatmaps: PluginAnalysisHeatmapsApi
44
+ /** Site typical-year weather series (numeric, paged). See {@linkcode PluginAnalysisWeatherApi}. */
45
+ public abstract weather: PluginAnalysisWeatherApi
46
+ /** Per-point solar exposure sampling (numeric). See {@linkcode PluginAnalysisSolarApi}. */
47
+ public abstract solar: PluginAnalysisSolarApi
48
+ /** IES LM-83 annual daylight metrics (numeric). See {@linkcode PluginAnalysisDaylightApi}. */
49
+ public abstract daylight: PluginAnalysisDaylightApi
50
+
51
+ constructor() {}
52
+ }
53
+
54
+ export * from "./sunpath"
55
+ export * from "./shadows"
56
+ export * from "./sunlightHours"
57
+ export * from "./illuminance"
58
+ export * from "./heatmaps"
59
+ export * from "./weather"
60
+ export * from "./solar"
61
+ export * from "./daylight"
@@ -0,0 +1,183 @@
1
+ import * as z from "zod"
2
+ import { PluginApiReturn } from "../../types"
3
+
4
+ /**
5
+ * Analysis shadows — real-time sun shadows in the scene.
6
+ *
7
+ * Shadows are cast for the sun position at a specific date and time at the
8
+ * project's geographic location. The date-time crosses this API as an **ISO
9
+ * 8601 date-time string** in the project's local time (e.g.
10
+ * `"2026-06-21T14:30"`); the engine snaps the time **down** to its half-hour
11
+ * grid (`14:59` → `14:30`); seconds, if provided, are discarded. The
12
+ * timezone is derived from the site location by the engine — do not append
13
+ * a UTC offset.
14
+ *
15
+ * Methods that position the sun **throw** when the project has no geo-located
16
+ * site/terrain — there is no fallback location. Set the site location first;
17
+ * read it via `program.site.getLocation`.
18
+ *
19
+ * Accessed via `snaptrude.analysis.shadows`.
20
+ */
21
+ export abstract class PluginAnalysisShadowsApi {
22
+ constructor() {}
23
+
24
+ /**
25
+ * Turn real-time sun shadows ON, optionally at a specific date and time.
26
+ *
27
+ * Without `options.dateTime` the shadows use the current stored sun
28
+ * position; with it, the sun is moved first (same as
29
+ * {@linkcode PluginAnalysisShadowsApi.setDateTime}). Enabling shadows
30
+ * resets any active heatmap analysis (`sunlightHours` / `illuminance`) —
31
+ * they are mutually exclusive in the product.
32
+ *
33
+ * @param options - Optional `dateTime`: ISO 8601 local date-time to
34
+ * position the sun at (snapped to the engine's half-hour grid).
35
+ * @returns `true` — shadows are enabled after the call.
36
+ * @throws When the project has no geo-located site/terrain.
37
+ * @throws When `options.dateTime` is not a parseable ISO date-time.
38
+ * @throws When plugin writes are disabled.
39
+ *
40
+ * @examplePrompt Turn on shadows
41
+ * @examplePrompt Show the shadows at 3pm on June 21st
42
+ * @examplePrompt Enable sun shadows for the summer solstice afternoon
43
+ *
44
+ * # Example
45
+ * ```ts
46
+ * await snaptrude.analysis.shadows.enable({ dateTime: "2026-06-21T15:00" })
47
+ * ```
48
+ */
49
+ public abstract enable(
50
+ options?: PluginAnalysisShadowsEnableOptions,
51
+ ): PluginApiReturn<boolean>
52
+
53
+ /**
54
+ * Turn real-time sun shadows OFF.
55
+ *
56
+ * A no-op (returns `false`) when shadows are already off. The stored sun
57
+ * date-time is kept for the next enable.
58
+ *
59
+ * @returns `false` — shadows are disabled after the call.
60
+ * @throws When plugin writes are disabled.
61
+ *
62
+ * @examplePrompt Turn off shadows
63
+ * @examplePrompt Hide the sun shadows
64
+ * @examplePrompt Disable shadow rendering in the scene
65
+ *
66
+ * # Example
67
+ * ```ts
68
+ * await snaptrude.analysis.shadows.disable()
69
+ * ```
70
+ */
71
+ public abstract disable(): PluginApiReturn<boolean>
72
+
73
+ /**
74
+ * Whether real-time sun shadows are currently enabled.
75
+ *
76
+ * A pure read — never mutates, never throws.
77
+ *
78
+ * @returns `true` when shadows are rendering.
79
+ *
80
+ * @examplePrompt Are shadows on?
81
+ * @examplePrompt Check whether sun shadows are enabled
82
+ * @examplePrompt Is the scene showing shadows right now?
83
+ *
84
+ * # Example
85
+ * ```ts
86
+ * const on = await snaptrude.analysis.shadows.isEnabled()
87
+ * ```
88
+ */
89
+ public abstract isEnabled(): PluginApiReturn<boolean>
90
+
91
+ /**
92
+ * Move the sun to a specific date and time.
93
+ *
94
+ * Takes an ISO 8601 date-time string in the project's local time; the
95
+ * engine snaps the time down to its half-hour grid and re-renders the shadows
96
+ * (when they are enabled). The engine stores no year — only the month, day,
97
+ * and time are applied, and the returned date-time always carries the
98
+ * **current year** (setting `"2020-12-21T09:30"` returns
99
+ * `"2026-12-21T09:30"` in 2026). Paired with
100
+ * {@linkcode PluginAnalysisShadowsApi.getDateTime}.
101
+ *
102
+ * @param dateTime - ISO 8601 local date-time, e.g. `"2026-12-21T09:30"`.
103
+ * @returns A {@linkcode PluginAnalysisShadowsDateTimeResult} — the applied
104
+ * ISO date-time after half-hour snapping.
105
+ * @throws When the project has no geo-located site/terrain.
106
+ * @throws When `dateTime` is not a parseable ISO date-time.
107
+ * @throws When plugin writes are disabled.
108
+ *
109
+ * @examplePrompt Set the shadow time to 9:30 am on the winter solstice
110
+ * @examplePrompt Move the sun to noon on March 1st
111
+ * @examplePrompt Change the shadow study date to December 21
112
+ *
113
+ * # Example
114
+ * ```ts
115
+ * const applied = await snaptrude.analysis.shadows.setDateTime("2026-12-21T09:30")
116
+ * console.log(applied) // "2026-12-21T09:30" (snapped to the half-hour grid)
117
+ * ```
118
+ */
119
+ public abstract setDateTime(
120
+ dateTime: string,
121
+ ): PluginApiReturn<PluginAnalysisShadowsDateTimeResult>
122
+
123
+ /**
124
+ * Get the sun's current date and time.
125
+ *
126
+ * Returns the stored sun position as an ISO 8601 local date-time string —
127
+ * the value shadows render at (whether or not they are enabled). The engine
128
+ * stores no year, so the returned string always carries the **current
129
+ * year**, whatever year was passed to
130
+ * {@linkcode PluginAnalysisShadowsApi.setDateTime} (its pair).
131
+ *
132
+ * @returns A {@linkcode PluginAnalysisShadowsDateTimeResult} — the current
133
+ * ISO local date-time of the sun.
134
+ *
135
+ * @examplePrompt What date and time are the shadows set to?
136
+ * @examplePrompt Get the current sun position date
137
+ * @examplePrompt Which time of day is the shadow study showing?
138
+ *
139
+ * # Example
140
+ * ```ts
141
+ * const dateTime = await snaptrude.analysis.shadows.getDateTime()
142
+ * ```
143
+ */
144
+ public abstract getDateTime(): PluginApiReturn<PluginAnalysisShadowsDateTimeResult>
145
+ }
146
+
147
+ /**
148
+ * Options for {@linkcode PluginAnalysisShadowsApi.enable}.
149
+ *
150
+ * | Property | Type | Description |
151
+ * |---|---|---|
152
+ * | `dateTime` | `string \| undefined` | ISO 8601 local date-time to position the sun at (snapped to the half-hour grid) |
153
+ */
154
+ export const PluginAnalysisShadowsEnableOptions = z.object({
155
+ dateTime: z.string().optional(),
156
+ })
157
+ export type PluginAnalysisShadowsEnableOptions = z.infer<
158
+ typeof PluginAnalysisShadowsEnableOptions
159
+ >
160
+
161
+ /**
162
+ * Arguments for {@linkcode PluginAnalysisShadowsApi.setDateTime}.
163
+ *
164
+ * | Property | Type | Description |
165
+ * |---|---|---|
166
+ * | `dateTime` | `string` | ISO 8601 local date-time, e.g. `"2026-06-21T14:30"` |
167
+ */
168
+ export const PluginAnalysisShadowsSetDateTimeArgs = z.object({
169
+ dateTime: z.string(),
170
+ })
171
+ export type PluginAnalysisShadowsSetDateTimeArgs = z.infer<
172
+ typeof PluginAnalysisShadowsSetDateTimeArgs
173
+ >
174
+
175
+ /**
176
+ * Result of {@linkcode PluginAnalysisShadowsApi.setDateTime} /
177
+ * {@linkcode PluginAnalysisShadowsApi.getDateTime} — the sun's ISO 8601
178
+ * local date-time (minute precision, on the engine's half-hour grid).
179
+ */
180
+ export const PluginAnalysisShadowsDateTimeResult = z.string()
181
+ export type PluginAnalysisShadowsDateTimeResult = z.infer<
182
+ typeof PluginAnalysisShadowsDateTimeResult
183
+ >
@@ -0,0 +1,237 @@
1
+ import * as z from "zod"
2
+ import { PluginApiReturn } from "../../types"
3
+ import { PluginWeatherSourceMeta } from "./weather"
4
+
5
+ /**
6
+ * Analysis solar — sample solar exposure at caller-chosen points.
7
+ *
8
+ * Unlike the heatmap studies (which raster the model's own surfaces), this
9
+ * samples solar exposure at **points you supply** — an instant (sun visible? /
10
+ * irradiance now) or aggregated over a date range (shaded fraction / cumulative
11
+ * irradiance). Positions are **world plan-space** coordinates, the same units
12
+ * and frame as plugin geometry reads; the backend echoes them verbatim and
13
+ * never re-projects.
14
+ *
15
+ * Raw numbers only: this renders no heatmap, mutates no geometry, and writes no
16
+ * save commands — visualization is the plugin's job. Large grids run as a job
17
+ * (`status: "running"` until complete); every result carries `modelRevision` +
18
+ * `inputHash` so the caller can mark it stale after a geometry change.
19
+ *
20
+ * Accessed via `snaptrude.analysis.solar`.
21
+ */
22
+ export abstract class PluginAnalysisSolarApi {
23
+ constructor() {}
24
+
25
+ /**
26
+ * Sample solar exposure at a set of points.
27
+ *
28
+ * Provide **exactly one** timing mode: `dateTime` (a single instant →
29
+ * `mode: "instant"`, results in `W/m²`), or `startDate` + `endDate` (a range
30
+ * → `mode: "range"`, results aggregated in `kWh/m²`). `results` is paged —
31
+ * follow `nextCursor` until it is `null`. Each point's optional `normal`
32
+ * gives plane-of-array irradiance; omit it for a horizontal sample.
33
+ *
34
+ * @param args - {@linkcode PluginSolarSampleGridArgs}: the `points`, exactly
35
+ * one timing mode (`dateTime` XOR `startDate`+`endDate`), and an optional
36
+ * `includeHourlyArtifact` to attach a downloadable per-hour series.
37
+ * @returns A {@linkcode PluginSolarSampleGridResult} — the run `status`,
38
+ * `mode`/`units`, provenance (`weather`, `modelRevision`, `inputHash`),
39
+ * this page of `results`, an optional `hourlyArtifact`, and `nextCursor`.
40
+ * @throws When the project has no geo-located site (no location to sample
41
+ * solar exposure for).
42
+ *
43
+ * @examplePrompt What's the irradiance at these facade points at noon on June 21?
44
+ * @examplePrompt How shaded are these balcony points across the summer?
45
+ * @examplePrompt Sample direct sun visibility at these roof points right now
46
+ *
47
+ * # Example
48
+ * ```ts
49
+ * const grid = await snaptrude.analysis.solar.sampleGrid({
50
+ * points: [
51
+ * { id: "a", position: [0, 3, 0] },
52
+ * { id: "b", position: [5, 3, 0], normal: [0, 0, 1] },
53
+ * ],
54
+ * dateTime: "2026-06-21T12:00:00+05:30",
55
+ * })
56
+ * for (const r of grid.results) {
57
+ * console.log(r.id, r.directSunVisible, r.totalIrradiance, grid.units)
58
+ * }
59
+ * ```
60
+ */
61
+ public abstract sampleGrid(
62
+ args: PluginSolarSampleGridArgs,
63
+ ): PluginApiReturn<PluginSolarSampleGridResult>
64
+ }
65
+
66
+ /**
67
+ * Status of a {@linkcode PluginAnalysisSolarApi.sampleGrid} run.
68
+ *
69
+ * | Value | Meaning |
70
+ * |---|---|
71
+ * | `"running"` | The job is in flight — poll again |
72
+ * | `"complete"` | Results are final |
73
+ * | `"cancelled"` | The run was cancelled |
74
+ * | `"failed"` | The run failed |
75
+ */
76
+ export const PluginSolarRunStatus = z.enum([
77
+ "running",
78
+ "complete",
79
+ "cancelled",
80
+ "failed",
81
+ ])
82
+ export type PluginSolarRunStatus = z.infer<typeof PluginSolarRunStatus>
83
+
84
+ /**
85
+ * Timing mode of the run — chosen by which timing args were supplied.
86
+ *
87
+ * | Value | Meaning |
88
+ * |---|---|
89
+ * | `"instant"` | Single `dateTime` — irradiance in `W/m²` |
90
+ * | `"range"` | `startDate`+`endDate` — irradiance aggregated in `kWh/m²` |
91
+ */
92
+ export const PluginSolarSampleMode = z.enum(["instant", "range"])
93
+ export type PluginSolarSampleMode = z.infer<typeof PluginSolarSampleMode>
94
+
95
+ /**
96
+ * Irradiance units of the results — `W/m²` (instant) or `kWh/m²` (range).
97
+ */
98
+ export const PluginSolarUnits = z.enum(["W/m2", "kWh/m2"])
99
+ export type PluginSolarUnits = z.infer<typeof PluginSolarUnits>
100
+
101
+ /**
102
+ * Downloadable per-hour artifact (present only when `includeHourlyArtifact`).
103
+ *
104
+ * | Property | Type | Description |
105
+ * |---|---|---|
106
+ * | `url` | `string` | Signed download URL |
107
+ * | `format` | `"parquet" \| "csv-gz"` | File format |
108
+ * | `expiresAt` | `string` | ISO 8601 expiry of the signed URL |
109
+ */
110
+ export const PluginSolarHourlyArtifact = z.object({
111
+ url: z.string(),
112
+ format: z.enum(["parquet", "csv-gz"]),
113
+ expiresAt: z.string(),
114
+ })
115
+ export type PluginSolarHourlyArtifact = z.infer<
116
+ typeof PluginSolarHourlyArtifact
117
+ >
118
+
119
+ /**
120
+ * A caller-supplied point to sample.
121
+ *
122
+ * | Property | Type | Description |
123
+ * |---|---|---|
124
+ * | `id` | `string` | Caller-chosen id, echoed back verbatim on the result |
125
+ * | `position` | `[number, number, number]` | World plan-space `[x, y, z]` |
126
+ * | `normal` | `[number, number, number]`? | Surface normal for plane-of-array; omit = horizontal |
127
+ */
128
+ export const PluginSolarSamplePoint = z.object({
129
+ id: z.string(),
130
+ position: z.tuple([z.number(), z.number(), z.number()]),
131
+ normal: z.tuple([z.number(), z.number(), z.number()]).optional(),
132
+ })
133
+ export type PluginSolarSamplePoint = z.infer<typeof PluginSolarSamplePoint>
134
+
135
+ /**
136
+ * Arguments for {@linkcode PluginAnalysisSolarApi.sampleGrid}.
137
+ *
138
+ * Provide **exactly one** timing mode: `dateTime` (instant) XOR
139
+ * `startDate`+`endDate` (range).
140
+ *
141
+ * | Property | Type | Description |
142
+ * |---|---|---|
143
+ * | `points` | {@linkcode PluginSolarSamplePoint}`[]` | Points to sample |
144
+ * | `dateTime` | `string`? | Instant mode: local ISO 8601 with offset |
145
+ * | `startDate` | `string`? | Range mode: inclusive start `"YYYY-MM-DD"` |
146
+ * | `endDate` | `string`? | Range mode: inclusive end `"YYYY-MM-DD"` |
147
+ * | `includeHourlyArtifact` | `boolean`? | Attach a downloadable per-hour series |
148
+ */
149
+ export const PluginSolarSampleGridArgs = z
150
+ .object({
151
+ points: z.array(PluginSolarSamplePoint),
152
+ dateTime: z.string().optional(),
153
+ startDate: z.string().optional(),
154
+ endDate: z.string().optional(),
155
+ includeHourlyArtifact: z.boolean().optional(),
156
+ })
157
+ .superRefine((a, ctx) => {
158
+ const hasInstant = a.dateTime !== undefined
159
+ const hasStart = a.startDate !== undefined
160
+ const hasEnd = a.endDate !== undefined
161
+ const hasRange = hasStart || hasEnd
162
+ if (hasInstant === hasRange) {
163
+ ctx.addIssue({
164
+ code: z.ZodIssueCode.custom,
165
+ message:
166
+ "provide exactly one timing mode: dateTime (instant), or startDate+endDate (range)",
167
+ })
168
+ }
169
+ if (hasRange && !(hasStart && hasEnd)) {
170
+ ctx.addIssue({
171
+ code: z.ZodIssueCode.custom,
172
+ message: "range mode requires both startDate and endDate",
173
+ })
174
+ }
175
+ })
176
+ export type PluginSolarSampleGridArgs = z.infer<
177
+ typeof PluginSolarSampleGridArgs
178
+ >
179
+
180
+ /**
181
+ * One sampled point's result. Irradiance fields are in the enclosing result's
182
+ * `units` and are omitted when the backend did not compute them.
183
+ *
184
+ * | Property | Type | Description |
185
+ * |---|---|---|
186
+ * | `id` | `string` | The point's caller-chosen id |
187
+ * | `directSunVisible` | `boolean` | Instant mode: sun disc visible from the point |
188
+ * | `shadeFraction` | `number` | `0`..`1`; range mode: fraction of sun-up hours shaded |
189
+ * | `directIrradiance` | `number`? | Direct component, in the result's `units` |
190
+ * | `diffuseIrradiance` | `number`? | Diffuse component, in the result's `units` |
191
+ * | `totalIrradiance` | `number`? | Total (direct + diffuse), in the result's `units` |
192
+ */
193
+ export const PluginSolarSampleResult = z.object({
194
+ id: z.string(),
195
+ directSunVisible: z.boolean(),
196
+ shadeFraction: z.number(),
197
+ directIrradiance: z.number().optional(),
198
+ diffuseIrradiance: z.number().optional(),
199
+ totalIrradiance: z.number().optional(),
200
+ })
201
+ export type PluginSolarSampleResult = z.infer<typeof PluginSolarSampleResult>
202
+
203
+ /**
204
+ * Result of {@linkcode PluginAnalysisSolarApi.sampleGrid} — one page.
205
+ *
206
+ * | Property | Type | Description |
207
+ * |---|---|---|
208
+ * | `status` | {@linkcode PluginSolarRunStatus} | Run status |
209
+ * | `mode` | {@linkcode PluginSolarSampleMode} | `"instant"` or `"range"` |
210
+ * | `coordinateSystem` | `"world-plan-space"` | Echo of the input frame |
211
+ * | `modelRevision` | `string` | Geometry revision sampled against (staleness key) |
212
+ * | `inputHash` | `string` | Hash of points+dates+geometry (staleness key) |
213
+ * | `units` | {@linkcode PluginSolarUnits} | `"W/m2"` (instant) or `"kWh/m2"` (range) |
214
+ * | `sunUpHours` | `number` | Sun-up hours over the sampled window |
215
+ * | `weather` | {@linkcode PluginWeatherSourceMeta} \| `null` | Resolved weather file, or `null` |
216
+ * | `weatherQuality` | `string[]` | Deduped quality flags present in the consumed rows |
217
+ * | `results` | {@linkcode PluginSolarSampleResult}`[]` | This page of per-point results |
218
+ * | `hourlyArtifact` | {@linkcode PluginSolarHourlyArtifact} \| `null` | Per-hour download, or `null` |
219
+ * | `nextCursor` | `string \| null` | Next page cursor; `null` = last page |
220
+ */
221
+ export const PluginSolarSampleGridResult = z.object({
222
+ status: PluginSolarRunStatus,
223
+ mode: PluginSolarSampleMode,
224
+ coordinateSystem: z.literal("world-plan-space"),
225
+ modelRevision: z.string(),
226
+ inputHash: z.string(),
227
+ units: PluginSolarUnits,
228
+ sunUpHours: z.number(),
229
+ weather: PluginWeatherSourceMeta.nullable(),
230
+ weatherQuality: z.array(z.string()),
231
+ results: z.array(PluginSolarSampleResult),
232
+ hourlyArtifact: PluginSolarHourlyArtifact.nullable(),
233
+ nextCursor: z.string().nullable(),
234
+ })
235
+ export type PluginSolarSampleGridResult = z.infer<
236
+ typeof PluginSolarSampleGridResult
237
+ >