@snaptrude/plugin-core 0.0.0-dev-20260708130115 → 0.0.0-dev-20260827135706
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +152 -1
- package/api-manifest.json +3620 -276
- package/dist/api/analysis/daylight.d.ts +603 -0
- package/dist/api/analysis/daylight.d.ts.map +1 -0
- package/dist/api/analysis/heatmaps.d.ts +658 -0
- package/dist/api/analysis/heatmaps.d.ts.map +1 -0
- package/dist/api/analysis/illuminance.d.ts +145 -0
- package/dist/api/analysis/illuminance.d.ts.map +1 -0
- package/dist/api/analysis/index.d.ts +59 -0
- package/dist/api/analysis/index.d.ts.map +1 -0
- package/dist/api/analysis/shadows.d.ts +165 -0
- package/dist/api/analysis/shadows.d.ts.map +1 -0
- package/dist/api/analysis/solar.d.ts +249 -0
- package/dist/api/analysis/solar.d.ts.map +1 -0
- package/dist/api/analysis/sunlightHours.d.ts +208 -0
- package/dist/api/analysis/sunlightHours.d.ts.map +1 -0
- package/dist/api/analysis/sunpath.d.ts +80 -0
- package/dist/api/analysis/sunpath.d.ts.map +1 -0
- package/dist/api/analysis/weather.d.ts +193 -0
- package/dist/api/analysis/weather.d.ts.map +1 -0
- package/dist/api/core/camera/index.d.ts +261 -0
- package/dist/api/core/camera/index.d.ts.map +1 -0
- package/dist/api/core/comment/index.d.ts +105 -2
- package/dist/api/core/comment/index.d.ts.map +1 -1
- package/dist/api/core/geom/create/index.d.ts +840 -14
- package/dist/api/core/geom/create/index.d.ts.map +1 -1
- package/dist/api/core/geom/delete/index.d.ts +8 -2
- package/dist/api/core/geom/delete/index.d.ts.map +1 -1
- package/dist/api/core/geom/query/arc.d.ts +5 -5
- package/dist/api/core/geom/query/brep.d.ts +130 -18
- package/dist/api/core/geom/query/brep.d.ts.map +1 -1
- package/dist/api/core/geom/query/circle.d.ts +18 -18
- package/dist/api/core/geom/query/contour.d.ts +20 -20
- package/dist/api/core/geom/query/curve.d.ts +49 -49
- package/dist/api/core/geom/query/edge.d.ts +5 -5
- package/dist/api/core/geom/query/face.d.ts +16 -16
- package/dist/api/core/geom/query/halfedge.d.ts +8 -8
- package/dist/api/core/geom/query/profile.d.ts +19 -19
- package/dist/api/core/geom/query/vertex.d.ts +8 -8
- package/dist/api/core/geom/update/contour.d.ts +14 -14
- package/dist/api/core/geom/update/curve.d.ts +7 -7
- package/dist/api/core/geom/update/profile.d.ts +16 -16
- package/dist/api/core/handles/index.d.ts +210 -0
- package/dist/api/core/handles/index.d.ts.map +1 -0
- package/dist/api/core/index.d.ts +34 -0
- package/dist/api/core/index.d.ts.map +1 -1
- package/dist/api/core/io/export/index.d.ts +134 -0
- package/dist/api/core/io/export/index.d.ts.map +1 -0
- package/dist/api/core/io/import/index.d.ts +453 -0
- package/dist/api/core/io/import/index.d.ts.map +1 -0
- package/dist/api/core/io/index.d.ts +40 -0
- package/dist/api/core/io/index.d.ts.map +1 -0
- package/dist/api/core/io/job/index.d.ts +139 -0
- package/dist/api/core/io/job/index.d.ts.map +1 -0
- package/dist/api/core/io/query/index.d.ts +74 -0
- package/dist/api/core/io/query/index.d.ts.map +1 -0
- package/dist/api/core/io/terrain/index.d.ts +341 -0
- package/dist/api/core/io/terrain/index.d.ts.map +1 -0
- package/dist/api/core/io/underlay/index.d.ts +805 -0
- package/dist/api/core/io/underlay/index.d.ts.map +1 -0
- package/dist/api/core/layers.d.ts +7 -7
- package/dist/api/core/mode/index.d.ts +99 -0
- package/dist/api/core/mode/index.d.ts.map +1 -0
- package/dist/api/core/project/index.d.ts +68 -1
- package/dist/api/core/project/index.d.ts.map +1 -1
- package/dist/api/core/proposals/index.d.ts +531 -0
- package/dist/api/core/proposals/index.d.ts.map +1 -0
- package/dist/api/core/storeys/index.d.ts +265 -0
- package/dist/api/core/storeys/index.d.ts.map +1 -0
- package/dist/api/core/tags.d.ts +24 -0
- package/dist/api/core/tags.d.ts.map +1 -1
- package/dist/api/core/user.d.ts +44 -0
- package/dist/api/core/user.d.ts.map +1 -0
- package/dist/api/core/zoom/index.d.ts +4 -0
- package/dist/api/core/zoom/index.d.ts.map +1 -1
- package/dist/api/design/boolean/index.d.ts +4 -4
- package/dist/api/design/create/index.d.ts +568 -45
- package/dist/api/design/create/index.d.ts.map +1 -1
- package/dist/api/design/delete/index.d.ts +3 -0
- package/dist/api/design/delete/index.d.ts.map +1 -1
- package/dist/api/design/doors/index.d.ts +195 -0
- package/dist/api/design/doors/index.d.ts.map +1 -1
- package/dist/api/design/edit/index.d.ts +1 -1
- package/dist/api/design/erase/index.d.ts +2 -2
- package/dist/api/design/family.d.ts +349 -0
- package/dist/api/design/family.d.ts.map +1 -0
- package/dist/api/design/furniture/index.d.ts +181 -8
- package/dist/api/design/furniture/index.d.ts.map +1 -1
- package/dist/api/design/index.d.ts +98 -0
- package/dist/api/design/index.d.ts.map +1 -1
- package/dist/api/design/lock.d.ts +26 -0
- package/dist/api/design/lock.d.ts.map +1 -1
- package/dist/api/design/materials/index.d.ts +270 -16
- package/dist/api/design/materials/index.d.ts.map +1 -1
- package/dist/api/design/query/geometry/index.d.ts +112 -0
- package/dist/api/design/query/geometry/index.d.ts.map +1 -1
- package/dist/api/design/query/index.d.ts +282 -11
- package/dist/api/design/query/index.d.ts.map +1 -1
- package/dist/api/design/query/referenceLines.d.ts +45 -0
- package/dist/api/design/query/referenceLines.d.ts.map +1 -0
- package/dist/api/design/query/spaces.d.ts +181 -8
- package/dist/api/design/query/spaces.d.ts.map +1 -1
- package/dist/api/design/selection/index.d.ts +144 -0
- package/dist/api/design/selection/index.d.ts.map +1 -1
- package/dist/api/design/transform/index.d.ts +172 -10
- package/dist/api/design/transform/index.d.ts.map +1 -1
- package/dist/api/design/types/index.d.ts +181 -0
- package/dist/api/design/types/index.d.ts.map +1 -0
- package/dist/api/design/update/index.d.ts +553 -2
- package/dist/api/design/update/index.d.ts.map +1 -1
- package/dist/api/design/visibility.d.ts +126 -0
- package/dist/api/design/visibility.d.ts.map +1 -0
- package/dist/api/design/windows/index.d.ts +113 -2
- package/dist/api/design/windows/index.d.ts.map +1 -1
- package/dist/api/entity/buildableEnvelope.d.ts +4 -0
- package/dist/api/entity/buildableEnvelope.d.ts.map +1 -1
- package/dist/api/entity/referenceLine.d.ts +10 -2
- package/dist/api/entity/referenceLine.d.ts.map +1 -1
- package/dist/api/entity/space.d.ts +21 -21
- package/dist/api/entity/story.d.ts +242 -15
- package/dist/api/entity/story.d.ts.map +1 -1
- package/dist/api/index.d.ts +10 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/presentation/aiInspiration.d.ts +25 -25
- package/dist/api/presentation/annotate.d.ts +467 -0
- package/dist/api/presentation/annotate.d.ts.map +1 -0
- package/dist/api/presentation/diagrams.d.ts +111 -8
- package/dist/api/presentation/diagrams.d.ts.map +1 -1
- package/dist/api/presentation/export.d.ts +108 -0
- package/dist/api/presentation/export.d.ts.map +1 -0
- package/dist/api/presentation/import.d.ts +55 -4
- package/dist/api/presentation/import.d.ts.map +1 -1
- package/dist/api/presentation/index.d.ts +58 -1
- package/dist/api/presentation/index.d.ts.map +1 -1
- package/dist/api/presentation/placedViews.d.ts +1139 -0
- package/dist/api/presentation/placedViews.d.ts.map +1 -0
- package/dist/api/presentation/shapes.d.ts +481 -0
- package/dist/api/presentation/shapes.d.ts.map +1 -0
- package/dist/api/presentation/sheets.d.ts +452 -13
- package/dist/api/presentation/sheets.d.ts.map +1 -1
- package/dist/api/presentation/slideshow.d.ts +125 -0
- package/dist/api/presentation/slideshow.d.ts.map +1 -0
- package/dist/api/presentation/tables.d.ts +81 -0
- package/dist/api/presentation/tables.d.ts.map +1 -0
- package/dist/api/presentation/views.d.ts +367 -7
- package/dist/api/presentation/views.d.ts.map +1 -1
- package/dist/api/program/areas.d.ts +102 -12
- package/dist/api/program/areas.d.ts.map +1 -1
- package/dist/api/program/cores.d.ts +3 -99
- package/dist/api/program/cores.d.ts.map +1 -1
- package/dist/api/program/index.d.ts +7 -15
- package/dist/api/program/index.d.ts.map +1 -1
- package/dist/api/program/layout.d.ts +346 -11
- package/dist/api/program/layout.d.ts.map +1 -1
- package/dist/api/program/site.d.ts +469 -13
- package/dist/api/program/site.d.ts.map +1 -1
- package/dist/api/program/spreadsheet.d.ts +365 -41
- package/dist/api/program/spreadsheet.d.ts.map +1 -1
- package/dist/api/workspace/index.d.ts +505 -0
- package/dist/api/workspace/index.d.ts.map +1 -0
- package/dist/errors/codes.d.ts +34 -0
- package/dist/errors/codes.d.ts.map +1 -0
- package/dist/errors/envelope.d.ts +56 -0
- package/dist/errors/envelope.d.ts.map +1 -0
- package/dist/errors/index.d.ts +6 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/plugin-error.d.ts +69 -0
- package/dist/errors/plugin-error.d.ts.map +1 -0
- package/dist/handles.d.ts +97 -25
- package/dist/handles.d.ts.map +1 -1
- package/dist/host-utils.d.ts +4 -0
- package/dist/host-utils.d.ts.map +1 -1
- package/dist/index.cjs +4582 -1422
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4171 -1411
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
- package/scripts/generate-manifest.mjs +45 -0
- package/scripts/generate-manifest.test.mjs +103 -4
- package/src/api/analysis/daylight.ts +470 -0
- package/src/api/analysis/heatmaps.ts +683 -0
- package/src/api/analysis/illuminance.ts +155 -0
- package/src/api/analysis/index.ts +61 -0
- package/src/api/analysis/shadows.ts +183 -0
- package/src/api/analysis/solar.ts +237 -0
- package/src/api/analysis/sunlightHours.ts +211 -0
- package/src/api/analysis/sunpath.ts +83 -0
- package/src/api/analysis/weather.ts +179 -0
- package/src/api/core/camera/index.ts +268 -0
- package/src/api/core/comment/index.ts +120 -2
- package/src/api/core/geom/create/index.ts +912 -1
- package/src/api/core/geom/delete/index.ts +6 -0
- package/src/api/core/geom/query/brep.ts +119 -0
- package/src/api/core/handles/index.ts +233 -0
- package/src/api/core/index.ts +34 -0
- package/src/api/core/io/export/index.ts +126 -0
- package/src/api/core/io/import/index.ts +496 -0
- package/src/api/core/io/index.ts +42 -0
- package/src/api/core/io/job/index.ts +140 -0
- package/src/api/core/io/query/index.ts +71 -0
- package/src/api/core/io/terrain/index.ts +360 -0
- package/src/api/core/io/underlay/index.ts +705 -0
- package/src/api/core/mode/index.ts +96 -0
- package/src/api/core/project/index.ts +62 -1
- package/src/api/core/proposals/index.ts +569 -0
- package/src/api/core/storeys/index.ts +294 -0
- package/src/api/core/tags.ts +27 -0
- package/src/api/core/user.ts +46 -0
- package/src/api/core/zoom/index.ts +4 -0
- package/src/api/design/create/index.ts +670 -30
- package/src/api/design/delete/index.ts +3 -0
- package/src/api/design/doors/index.ts +208 -0
- package/src/api/design/erase/index.ts +1 -1
- package/src/api/design/family.ts +388 -0
- package/src/api/design/furniture/index.ts +197 -8
- package/src/api/design/index.ts +102 -0
- package/src/api/design/lock.ts +27 -0
- package/src/api/design/materials/index.ts +334 -27
- package/src/api/design/query/geometry/index.ts +125 -3
- package/src/api/design/query/index.ts +217 -7
- package/src/api/design/query/referenceLines.ts +52 -0
- package/src/api/design/query/spaces.ts +143 -0
- package/src/api/design/selection/index.ts +129 -0
- package/src/api/design/transform/index.ts +170 -9
- package/src/api/design/types/index.ts +156 -0
- package/src/api/design/update/index.ts +631 -3
- package/src/api/design/visibility.ts +143 -0
- package/src/api/design/windows/index.ts +128 -2
- package/src/api/entity/buildableEnvelope.ts +4 -0
- package/src/api/entity/referenceLine.ts +8 -0
- package/src/api/entity/story.ts +259 -15
- package/src/api/index.ts +10 -0
- package/src/api/presentation/annotate.ts +385 -0
- package/src/api/presentation/diagrams.ts +118 -8
- package/src/api/presentation/export.ts +108 -0
- package/src/api/presentation/import.ts +51 -4
- package/src/api/presentation/index.ts +66 -1
- package/src/api/presentation/placedViews.ts +1120 -0
- package/src/api/presentation/shapes.ts +274 -0
- package/src/api/presentation/sheets.ts +400 -13
- package/src/api/presentation/slideshow.ts +134 -0
- package/src/api/presentation/tables.ts +84 -0
- package/src/api/presentation/views.ts +376 -8
- package/src/api/program/areas.ts +88 -15
- package/src/api/program/cores.ts +3 -91
- package/src/api/program/index.ts +7 -15
- package/src/api/program/layout.ts +365 -11
- package/src/api/program/site.ts +435 -13
- package/src/api/program/spreadsheet.ts +376 -35
- package/src/api/workspace/index.ts +563 -0
- package/src/errors/codes.ts +136 -0
- package/src/errors/envelope.ts +75 -0
- package/src/errors/index.ts +21 -0
- package/src/errors/plugin-error.ts +134 -0
- package/src/handles.ts +123 -13
- package/src/host-utils.ts +4 -0
- package/src/index.ts +1 -0
- package/test/errors.test.mjs +184 -0
- package/tsconfig.json +7 -2
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Analysis sunlightHours — the direct-sunlight-hours heatmap study.
|
|
6
|
+
*
|
|
7
|
+
* Computes, for every space surface (Room or Department Mass — generic
|
|
8
|
+
* Masses are not enough), how many hours of direct sunlight
|
|
9
|
+
* it receives over a date range, and renders the result as a heatmap on the
|
|
10
|
+
* scene. The computation is an **asynchronous backend job**:
|
|
11
|
+
*
|
|
12
|
+
* 1. {@linkcode PluginAnalysisSunlightHoursApi.compute} starts the job and
|
|
13
|
+
* returns immediately.
|
|
14
|
+
* 2. Poll {@linkcode PluginAnalysisSunlightHoursApi.get} until `status` is
|
|
15
|
+
* `"active"` (heatmap rendered) — a run typically takes minutes. There is
|
|
16
|
+
* no completion event; polling is the pattern.
|
|
17
|
+
* 3. {@linkcode PluginAnalysisSunlightHoursApi.cancel} aborts an in-flight
|
|
18
|
+
* run; {@linkcode PluginAnalysisSunlightHoursApi.reset} clears a rendered
|
|
19
|
+
* heatmap.
|
|
20
|
+
*
|
|
21
|
+
* Heatmaps are invalidated by scene-mutating edits — re-run the study after
|
|
22
|
+
* changing the model. Dates cross as ISO 8601 date strings (`"YYYY-MM-DD"`).
|
|
23
|
+
*
|
|
24
|
+
* Accessed via `snaptrude.analysis.sunlightHours`.
|
|
25
|
+
*/
|
|
26
|
+
export abstract class PluginAnalysisSunlightHoursApi {
|
|
27
|
+
constructor() {}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Start a direct-sunlight-hours run for a date range.
|
|
31
|
+
*
|
|
32
|
+
* Starts the backend job and **returns immediately** — it does not wait
|
|
33
|
+
* for the heatmap. Poll {@linkcode PluginAnalysisSunlightHoursApi.get}
|
|
34
|
+
* until `status` is `"active"`. Starting a new run while one is in flight
|
|
35
|
+
* replaces it. Shadows and the heatmap analyses are mutually exclusive in
|
|
36
|
+
* the product: starting a run disables real-time shadows and resets/cancels
|
|
37
|
+
* any {@linkcode PluginAnalysisIlluminanceApi} (`analysis.illuminance`)
|
|
38
|
+
* study.
|
|
39
|
+
*
|
|
40
|
+
* @param startDate - Start of the study range, ISO date `"YYYY-MM-DD"`.
|
|
41
|
+
* @param endDate - End of the study range, ISO date `"YYYY-MM-DD"` (on or
|
|
42
|
+
* after `startDate`).
|
|
43
|
+
* @returns A {@linkcode PluginAnalysisComputeResult} — `{ success: true }`
|
|
44
|
+
* when the job was started. The `{ success: false, error }` arm is
|
|
45
|
+
* reserved — not yet emitted (start failures currently throw).
|
|
46
|
+
* @throws When the project has no geo-located site/terrain (no location to
|
|
47
|
+
* compute sun exposure for — there is no fallback location).
|
|
48
|
+
* @throws When the scene has no space (Room or Department Mass) to analyse
|
|
49
|
+
* or the editor is not in the 3D view.
|
|
50
|
+
* @throws When a date is not a parseable ISO date or the range is inverted.
|
|
51
|
+
* @throws When plugin writes are disabled.
|
|
52
|
+
*
|
|
53
|
+
* @examplePrompt Run a sunlight hours analysis for June
|
|
54
|
+
* @examplePrompt Compute direct sunlight hours between March and September
|
|
55
|
+
* @examplePrompt How much sun does my building get over the summer?
|
|
56
|
+
*
|
|
57
|
+
* # Example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const { success } = await snaptrude.analysis.sunlightHours.compute(
|
|
60
|
+
* "2026-06-01",
|
|
61
|
+
* "2026-06-30",
|
|
62
|
+
* )
|
|
63
|
+
* // poll until the heatmap is rendered
|
|
64
|
+
* let job = await snaptrude.analysis.sunlightHours.get()
|
|
65
|
+
* while (job?.status === "running") {
|
|
66
|
+
* await new Promise((r) => setTimeout(r, 5000))
|
|
67
|
+
* job = await snaptrude.analysis.sunlightHours.get()
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
public abstract compute(
|
|
72
|
+
startDate: string,
|
|
73
|
+
endDate: string,
|
|
74
|
+
): PluginApiReturn<PluginAnalysisComputeResult>
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Get the state of the sunlight-hours study.
|
|
78
|
+
*
|
|
79
|
+
* The polling read for the async job started by
|
|
80
|
+
* {@linkcode PluginAnalysisSunlightHoursApi.compute}. `status` values:
|
|
81
|
+
*
|
|
82
|
+
* | Status | Meaning |
|
|
83
|
+
* |---|---|
|
|
84
|
+
* | `"running"` | A run is in flight — keep polling |
|
|
85
|
+
* | `"active"` | The heatmap is rendered on the scene |
|
|
86
|
+
* | `"inactive"` | A previous run exists but its heatmap is not showing |
|
|
87
|
+
*
|
|
88
|
+
* @returns A {@linkcode PluginAnalysisJobStateResult} with the `status` and
|
|
89
|
+
* the run's ISO `startDate`/`endDate`, or `null` when no run result is
|
|
90
|
+
* available (the study never ran, was cancelled, or the last run failed).
|
|
91
|
+
*
|
|
92
|
+
* @examplePrompt Is the sunlight analysis done?
|
|
93
|
+
* @examplePrompt Check the status of the sunlight hours run
|
|
94
|
+
* @examplePrompt What date range was the sunlight heatmap computed for?
|
|
95
|
+
*
|
|
96
|
+
* # Example
|
|
97
|
+
* ```ts
|
|
98
|
+
* const job = await snaptrude.analysis.sunlightHours.get()
|
|
99
|
+
* if (job?.status === "active") console.log(job.startDate, job.endDate)
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
public abstract get(): PluginApiReturn<PluginAnalysisJobStateResult>
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Cancel the in-flight sunlight-hours run.
|
|
106
|
+
*
|
|
107
|
+
* Aborts the backend job. A no-op (returns `false`) when nothing is
|
|
108
|
+
* running.
|
|
109
|
+
*
|
|
110
|
+
* @returns `true` when a run was cancelled, `false` when nothing was
|
|
111
|
+
* running.
|
|
112
|
+
* @throws When plugin writes are disabled.
|
|
113
|
+
*
|
|
114
|
+
* @examplePrompt Cancel the sunlight analysis
|
|
115
|
+
* @examplePrompt Stop the running sunlight hours computation
|
|
116
|
+
* @examplePrompt Abort the sun study
|
|
117
|
+
*
|
|
118
|
+
* # Example
|
|
119
|
+
* ```ts
|
|
120
|
+
* await snaptrude.analysis.sunlightHours.cancel()
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
public abstract cancel(): PluginApiReturn<boolean>
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Clear the sunlight-hours heatmap from the scene.
|
|
127
|
+
*
|
|
128
|
+
* Un-applies the rendered heatmap and restores the normal material view.
|
|
129
|
+
* A no-op (returns `false`) when no heatmap is showing. Does not cancel an
|
|
130
|
+
* in-flight run — use {@linkcode PluginAnalysisSunlightHoursApi.cancel}.
|
|
131
|
+
*
|
|
132
|
+
* @returns `true` when a heatmap was cleared, `false` when none was
|
|
133
|
+
* showing.
|
|
134
|
+
* @throws When plugin writes are disabled.
|
|
135
|
+
*
|
|
136
|
+
* @examplePrompt Clear the sunlight heatmap
|
|
137
|
+
* @examplePrompt Remove the sun hours colours from the model
|
|
138
|
+
* @examplePrompt Reset the sunlight analysis view
|
|
139
|
+
*
|
|
140
|
+
* # Example
|
|
141
|
+
* ```ts
|
|
142
|
+
* await snaptrude.analysis.sunlightHours.reset()
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
public abstract reset(): PluginApiReturn<boolean>
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Result of starting an analysis job
|
|
150
|
+
* ({@linkcode PluginAnalysisSunlightHoursApi.compute} /
|
|
151
|
+
* {@linkcode PluginAnalysisIlluminanceApi.compute}).
|
|
152
|
+
*
|
|
153
|
+
* The `success: false` arm is **reserved — not yet emitted**: the current
|
|
154
|
+
* host always returns `{ success: true }` (start failures throw instead); a
|
|
155
|
+
* failure indicator may be added additively later.
|
|
156
|
+
*
|
|
157
|
+
* | Property | Type | Description |
|
|
158
|
+
* |---|---|---|
|
|
159
|
+
* | `success` | `boolean` | `true` when the backend job was started |
|
|
160
|
+
* | `error` | `string \| undefined` | Failure reason when `success` is `false` (reserved — not yet emitted) |
|
|
161
|
+
*/
|
|
162
|
+
export const PluginAnalysisComputeResult = z.object({
|
|
163
|
+
success: z.boolean(),
|
|
164
|
+
error: z.string().optional(),
|
|
165
|
+
})
|
|
166
|
+
export type PluginAnalysisComputeResult = z.infer<
|
|
167
|
+
typeof PluginAnalysisComputeResult
|
|
168
|
+
>
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* The status of an analysis heatmap job.
|
|
172
|
+
*
|
|
173
|
+
* | Value | Meaning |
|
|
174
|
+
* |---|---|
|
|
175
|
+
* | `"running"` | A run is in flight — keep polling |
|
|
176
|
+
* | `"active"` | The heatmap is rendered on the scene |
|
|
177
|
+
* | `"inactive"` | A previous run exists but its heatmap is not showing |
|
|
178
|
+
*/
|
|
179
|
+
export const PluginAnalysisJobStatus = z.enum([
|
|
180
|
+
"running",
|
|
181
|
+
"active",
|
|
182
|
+
"inactive",
|
|
183
|
+
])
|
|
184
|
+
export type PluginAnalysisJobStatus = z.infer<typeof PluginAnalysisJobStatus>
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* The state of an analysis heatmap job.
|
|
188
|
+
*
|
|
189
|
+
* | Property | Type | Description |
|
|
190
|
+
* |---|---|---|
|
|
191
|
+
* | `status` | {@linkcode PluginAnalysisJobStatus} | `"running"` \| `"active"` \| `"inactive"` |
|
|
192
|
+
* | `startDate` | `string` | ISO date (`"YYYY-MM-DD"`) the run was computed from |
|
|
193
|
+
* | `endDate` | `string` | ISO date (`"YYYY-MM-DD"`) the run was computed to |
|
|
194
|
+
*/
|
|
195
|
+
export const PluginAnalysisJobState = z.object({
|
|
196
|
+
status: PluginAnalysisJobStatus,
|
|
197
|
+
startDate: z.string(),
|
|
198
|
+
endDate: z.string(),
|
|
199
|
+
})
|
|
200
|
+
export type PluginAnalysisJobState = z.infer<typeof PluginAnalysisJobState>
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Result of {@linkcode PluginAnalysisSunlightHoursApi.get} /
|
|
204
|
+
* {@linkcode PluginAnalysisIlluminanceApi.get} — the job state, or `null`
|
|
205
|
+
* when no run result is available (the study never ran, was cancelled, or
|
|
206
|
+
* the last run failed).
|
|
207
|
+
*/
|
|
208
|
+
export const PluginAnalysisJobStateResult = PluginAnalysisJobState.nullable()
|
|
209
|
+
export type PluginAnalysisJobStateResult = z.infer<
|
|
210
|
+
typeof PluginAnalysisJobStateResult
|
|
211
|
+
>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { PluginApiReturn } from "../../types"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Analysis sunpath — the sun-path diagram overlay.
|
|
5
|
+
*
|
|
6
|
+
* The sun-path diagram draws the sun's annual/daily trajectory arcs over the
|
|
7
|
+
* scene for the project's geographic location, so daylight behaviour can be
|
|
8
|
+
* read directly off the model. Toggling it is an **undoable** action (it goes
|
|
9
|
+
* through the command stack, so `core.history.undo` reverts it).
|
|
10
|
+
*
|
|
11
|
+
* The overlay is computed for the project's geo-location. Enabling **throws**
|
|
12
|
+
* when the project has no geo-located site/terrain — there is no fallback
|
|
13
|
+
* location. Set the site location first (Import terrain / site context);
|
|
14
|
+
* read it via `program.site.getLocation`.
|
|
15
|
+
*
|
|
16
|
+
* Accessed via `snaptrude.analysis.sunpath`.
|
|
17
|
+
*/
|
|
18
|
+
export abstract class PluginAnalysisSunpathApi {
|
|
19
|
+
constructor() {}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Turn the sun-path diagram overlay ON.
|
|
23
|
+
*
|
|
24
|
+
* Undoable: the toggle is committed through the command stack. A no-op
|
|
25
|
+
* (returns `true`) when the overlay is already active.
|
|
26
|
+
*
|
|
27
|
+
* @returns `true` — the overlay is active after the call.
|
|
28
|
+
* @throws When the project has no geo-located site/terrain (no location to
|
|
29
|
+
* compute the sun trajectory for).
|
|
30
|
+
* @throws When plugin writes are disabled.
|
|
31
|
+
*
|
|
32
|
+
* @examplePrompt Show the sun path diagram
|
|
33
|
+
* @examplePrompt Turn on the sunpath overlay
|
|
34
|
+
* @examplePrompt Visualize the sun's trajectory over my building
|
|
35
|
+
*
|
|
36
|
+
* # Example
|
|
37
|
+
* ```ts
|
|
38
|
+
* await snaptrude.analysis.sunpath.enable()
|
|
39
|
+
* const active = await snaptrude.analysis.sunpath.isActive() // true
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
public abstract enable(): PluginApiReturn<boolean>
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Turn the sun-path diagram overlay OFF.
|
|
46
|
+
*
|
|
47
|
+
* Undoable: the toggle is committed through the command stack. A no-op
|
|
48
|
+
* (returns `false`) when the overlay is already off.
|
|
49
|
+
*
|
|
50
|
+
* @returns `false` — the overlay is inactive after the call.
|
|
51
|
+
* @throws When plugin writes are disabled.
|
|
52
|
+
*
|
|
53
|
+
* @examplePrompt Hide the sun path diagram
|
|
54
|
+
* @examplePrompt Turn off the sunpath overlay
|
|
55
|
+
* @examplePrompt Remove the sun trajectory arcs from the scene
|
|
56
|
+
*
|
|
57
|
+
* # Example
|
|
58
|
+
* ```ts
|
|
59
|
+
* await snaptrude.analysis.sunpath.disable()
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
public abstract disable(): PluginApiReturn<boolean>
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Whether the sun-path diagram overlay is currently active.
|
|
66
|
+
*
|
|
67
|
+
* A pure read — never mutates, never throws.
|
|
68
|
+
*
|
|
69
|
+
* @returns `true` when the overlay is showing.
|
|
70
|
+
*
|
|
71
|
+
* @examplePrompt Is the sun path diagram on?
|
|
72
|
+
* @examplePrompt Check whether the sunpath overlay is active
|
|
73
|
+
* @examplePrompt Am I looking at the sun trajectory right now?
|
|
74
|
+
*
|
|
75
|
+
* # Example
|
|
76
|
+
* ```ts
|
|
77
|
+
* if (!(await snaptrude.analysis.sunpath.isActive())) {
|
|
78
|
+
* await snaptrude.analysis.sunpath.enable()
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
public abstract isActive(): PluginApiReturn<boolean>
|
|
83
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Analysis weather — read the project site's typical-year weather series.
|
|
6
|
+
*
|
|
7
|
+
* Returns the hourly weather rows (temperature, humidity, wind, solar
|
|
8
|
+
* irradiance) of the EPW file the sustainability analyses compute against,
|
|
9
|
+
* resolved from the project's geo-located site. This is a **synchronous,
|
|
10
|
+
* paged read** of an already-resolved weather file — not a job: call
|
|
11
|
+
* {@linkcode PluginAnalysisWeatherApi.getSeries} for a date range, then follow
|
|
12
|
+
* `nextCursor` until it is `null`.
|
|
13
|
+
*
|
|
14
|
+
* The weather file is resolved by the **same** code path the daylight /
|
|
15
|
+
* sunlight-hours analyses use, so the `source.weatherFileId` here matches the
|
|
16
|
+
* provenance a {@linkcode PluginAnalysisDaylightApi} run echoes. Dates cross as
|
|
17
|
+
* ISO 8601 date strings (`"YYYY-MM-DD"`); each row's `timestamp` is a local
|
|
18
|
+
* ISO 8601 string **with** its UTC offset, and `utcOffsetMinutes` restates the
|
|
19
|
+
* offset so consumers never re-derive it.
|
|
20
|
+
*
|
|
21
|
+
* Reads never throw for "no data": when the project has no geo-located site
|
|
22
|
+
* (no weather file to resolve) the host surfaces that per its read contract.
|
|
23
|
+
*
|
|
24
|
+
* Accessed via `snaptrude.analysis.weather`.
|
|
25
|
+
*/
|
|
26
|
+
export abstract class PluginAnalysisWeatherApi {
|
|
27
|
+
constructor() {}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get the hourly weather series for a date range, paged.
|
|
31
|
+
*
|
|
32
|
+
* Returns the resolved weather file's provenance (`source`) plus the weather
|
|
33
|
+
* `rows` for the requested range. The page size is backend-chosen; when
|
|
34
|
+
* `nextCursor` is a string, pass it back as `args.cursor` to fetch the next
|
|
35
|
+
* page, and stop when it is `null`.
|
|
36
|
+
*
|
|
37
|
+
* @param args - {@linkcode PluginWeatherGetSeriesArgs}: the inclusive
|
|
38
|
+
* `startDate`/`endDate` ISO dates, an optional `interval` (`"hourly"` is
|
|
39
|
+
* the only v1 value), and an optional `cursor` for paging.
|
|
40
|
+
* @returns A {@linkcode PluginWeatherSeriesResult} — the resolved weather
|
|
41
|
+
* `source`, the `rows` for this page, and `nextCursor` (`null` at the end).
|
|
42
|
+
*
|
|
43
|
+
* @examplePrompt Get the weather series for June at my site
|
|
44
|
+
* @examplePrompt Pull the hourly temperature and irradiance for this location
|
|
45
|
+
* @examplePrompt What EPW weather file is my project using?
|
|
46
|
+
*
|
|
47
|
+
* # Example
|
|
48
|
+
* ```ts
|
|
49
|
+
* let cursor: string | undefined = undefined
|
|
50
|
+
* const rows = []
|
|
51
|
+
* do {
|
|
52
|
+
* const page = await snaptrude.analysis.weather.getSeries({
|
|
53
|
+
* startDate: "2026-06-01",
|
|
54
|
+
* endDate: "2026-06-30",
|
|
55
|
+
* cursor,
|
|
56
|
+
* })
|
|
57
|
+
* rows.push(...page.rows)
|
|
58
|
+
* cursor = page.nextCursor ?? undefined
|
|
59
|
+
* } while (cursor)
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
public abstract getSeries(
|
|
63
|
+
args: PluginWeatherGetSeriesArgs,
|
|
64
|
+
): PluginApiReturn<PluginWeatherSeriesResult>
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* How the weather file was matched to the project site.
|
|
69
|
+
*
|
|
70
|
+
* | Value | Meaning |
|
|
71
|
+
* |---|---|
|
|
72
|
+
* | `"nearest-station"` | Auto-resolved to the closest weather station |
|
|
73
|
+
* | `"user-upload"` | A weather file the user uploaded (`core.io.import.epw`) |
|
|
74
|
+
* | `"project-override"` | A station pinned for the project regardless of distance |
|
|
75
|
+
*/
|
|
76
|
+
export const PluginWeatherSelectionMethod = z.enum([
|
|
77
|
+
"nearest-station",
|
|
78
|
+
"user-upload",
|
|
79
|
+
"project-override",
|
|
80
|
+
])
|
|
81
|
+
export type PluginWeatherSelectionMethod = z.infer<
|
|
82
|
+
typeof PluginWeatherSelectionMethod
|
|
83
|
+
>
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Provenance of the resolved weather file — where the numbers came from.
|
|
87
|
+
*
|
|
88
|
+
* | Property | Type | Description |
|
|
89
|
+
* |---|---|---|
|
|
90
|
+
* | `weatherFileId` | `string` | Catalog id (same key as `core.io.import.epw`'s `weatherFileId`) |
|
|
91
|
+
* | `station` | `string` | Station/file name, e.g. `"USA_IL_Chicago-OHare.Intl.AP.725300_TMY3"` |
|
|
92
|
+
* | `sourceId` | `string` | WMO/station identifier from the EPW header |
|
|
93
|
+
* | `distanceKm` | `number \| null` | Station → project site distance, km; `null` for pinned project-override files |
|
|
94
|
+
* | `selectionMethod` | {@linkcode PluginWeatherSelectionMethod} | How the file was matched |
|
|
95
|
+
* | `checksum` | `string` | sha256 of the EPW file — the provenance key |
|
|
96
|
+
* | `windReferenceHeightM` | `number` | Anemometer height the wind rows are valid at |
|
|
97
|
+
*/
|
|
98
|
+
export const PluginWeatherSourceMeta = z.object({
|
|
99
|
+
weatherFileId: z.string(),
|
|
100
|
+
station: z.string(),
|
|
101
|
+
sourceId: z.string(),
|
|
102
|
+
distanceKm: z.number().nullable(),
|
|
103
|
+
selectionMethod: PluginWeatherSelectionMethod,
|
|
104
|
+
checksum: z.string(),
|
|
105
|
+
windReferenceHeightM: z.number(),
|
|
106
|
+
})
|
|
107
|
+
export type PluginWeatherSourceMeta = z.infer<typeof PluginWeatherSourceMeta>
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* One hourly weather reading.
|
|
111
|
+
*
|
|
112
|
+
* `flags` is empty for a clean measured/typical value; known flag strings are
|
|
113
|
+
* `"missing"`, `"substituted"`, and `"interpolated"` (kept as `string[]` so the
|
|
114
|
+
* backend can add flag kinds without a contract break).
|
|
115
|
+
*
|
|
116
|
+
* | Property | Type | Description |
|
|
117
|
+
* |---|---|---|
|
|
118
|
+
* | `timestamp` | `string` | Local ISO 8601 with offset, e.g. `"2026-06-21T14:00:00+05:30"` |
|
|
119
|
+
* | `utcOffsetMinutes` | `number` | UTC offset in minutes (restates the timestamp's offset) |
|
|
120
|
+
* | `dryBulbC` | `number` | Dry-bulb temperature, °C |
|
|
121
|
+
* | `relativeHumidityPercent` | `number` | Relative humidity, % |
|
|
122
|
+
* | `windSpeedMps` | `number` | Wind speed, m/s (at `source.windReferenceHeightM`) |
|
|
123
|
+
* | `ghiWm2` | `number` | Global horizontal irradiance, W/m² |
|
|
124
|
+
* | `dniWm2` | `number` | Direct normal irradiance, W/m² |
|
|
125
|
+
* | `dhiWm2` | `number` | Diffuse horizontal irradiance, W/m² |
|
|
126
|
+
* | `flags` | `string[]` | Quality flags; `[]` = clean value |
|
|
127
|
+
*/
|
|
128
|
+
export const PluginWeatherRow = z.object({
|
|
129
|
+
timestamp: z.string(),
|
|
130
|
+
utcOffsetMinutes: z.number(),
|
|
131
|
+
dryBulbC: z.number(),
|
|
132
|
+
relativeHumidityPercent: z.number(),
|
|
133
|
+
windSpeedMps: z.number(),
|
|
134
|
+
ghiWm2: z.number(),
|
|
135
|
+
dniWm2: z.number(),
|
|
136
|
+
dhiWm2: z.number(),
|
|
137
|
+
flags: z.array(z.string()),
|
|
138
|
+
})
|
|
139
|
+
export type PluginWeatherRow = z.infer<typeof PluginWeatherRow>
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Arguments for {@linkcode PluginAnalysisWeatherApi.getSeries}.
|
|
143
|
+
*
|
|
144
|
+
* | Property | Type | Description |
|
|
145
|
+
* |---|---|---|
|
|
146
|
+
* | `startDate` | `string` | Inclusive range start, ISO `"YYYY-MM-DD"` |
|
|
147
|
+
* | `endDate` | `string` | Inclusive range end, ISO `"YYYY-MM-DD"` |
|
|
148
|
+
* | `interval` | `"hourly"`? | Sampling interval; `"hourly"` is the only v1 value |
|
|
149
|
+
* | `cursor` | `string`? | Paging cursor from a prior page's `nextCursor` |
|
|
150
|
+
*/
|
|
151
|
+
export const PluginWeatherGetSeriesArgs = z.object({
|
|
152
|
+
startDate: z.string(),
|
|
153
|
+
endDate: z.string(),
|
|
154
|
+
interval: z.enum(["hourly"]).optional(),
|
|
155
|
+
cursor: z.string().optional(),
|
|
156
|
+
})
|
|
157
|
+
export type PluginWeatherGetSeriesArgs = z.infer<
|
|
158
|
+
typeof PluginWeatherGetSeriesArgs
|
|
159
|
+
>
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Result of {@linkcode PluginAnalysisWeatherApi.getSeries} — one page.
|
|
163
|
+
*
|
|
164
|
+
* | Property | Type | Description |
|
|
165
|
+
* |---|---|---|
|
|
166
|
+
* | `source` | {@linkcode PluginWeatherSourceMeta} | The resolved weather file's provenance |
|
|
167
|
+
* | `rows` | {@linkcode PluginWeatherRow}`[]` | Weather rows for this page |
|
|
168
|
+
* | `nextCursor` | `string \| null` | Pass back as `args.cursor`; `null` = last page |
|
|
169
|
+
* | `warnings` | `string[]`? | Degradation notices (e.g. `"override lookup failed; served nearest-station"`); omitted when the page is clean |
|
|
170
|
+
*/
|
|
171
|
+
export const PluginWeatherSeriesResult = z.object({
|
|
172
|
+
source: PluginWeatherSourceMeta,
|
|
173
|
+
rows: z.array(PluginWeatherRow),
|
|
174
|
+
nextCursor: z.string().nullable(),
|
|
175
|
+
warnings: z.array(z.string()).optional(),
|
|
176
|
+
})
|
|
177
|
+
export type PluginWeatherSeriesResult = z.infer<
|
|
178
|
+
typeof PluginWeatherSeriesResult
|
|
179
|
+
>
|