@snaptrude/plugin-core 0.5.0 → 0.7.0

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 (134) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/api-manifest.full.json +2644 -542
  3. package/api-manifest.json +2606 -424
  4. package/dist/api/analysis/heatmaps.d.ts +234 -0
  5. package/dist/api/analysis/heatmaps.d.ts.map +1 -0
  6. package/dist/api/analysis/illuminance.d.ts +145 -0
  7. package/dist/api/analysis/illuminance.d.ts.map +1 -0
  8. package/dist/api/analysis/index.d.ts +44 -0
  9. package/dist/api/analysis/index.d.ts.map +1 -0
  10. package/dist/api/analysis/shadows.d.ts +165 -0
  11. package/dist/api/analysis/shadows.d.ts.map +1 -0
  12. package/dist/api/analysis/sunlightHours.d.ts +208 -0
  13. package/dist/api/analysis/sunlightHours.d.ts.map +1 -0
  14. package/dist/api/analysis/sunpath.d.ts +80 -0
  15. package/dist/api/analysis/sunpath.d.ts.map +1 -0
  16. package/dist/api/core/index.d.ts +10 -0
  17. package/dist/api/core/index.d.ts.map +1 -1
  18. package/dist/api/core/io/import/index.d.ts +392 -0
  19. package/dist/api/core/io/import/index.d.ts.map +1 -0
  20. package/dist/api/core/io/index.d.ts +35 -0
  21. package/dist/api/core/io/index.d.ts.map +1 -0
  22. package/dist/api/core/io/job/index.d.ts +139 -0
  23. package/dist/api/core/io/job/index.d.ts.map +1 -0
  24. package/dist/api/core/io/query/index.d.ts +74 -0
  25. package/dist/api/core/io/query/index.d.ts.map +1 -0
  26. package/dist/api/core/io/terrain/index.d.ts +206 -0
  27. package/dist/api/core/io/terrain/index.d.ts.map +1 -0
  28. package/dist/api/core/io/underlay/index.d.ts +286 -0
  29. package/dist/api/core/io/underlay/index.d.ts.map +1 -0
  30. package/dist/api/core/layers.d.ts +7 -7
  31. package/dist/api/core/proposals/index.d.ts +475 -0
  32. package/dist/api/core/proposals/index.d.ts.map +1 -0
  33. package/dist/api/design/create/index.d.ts +218 -0
  34. package/dist/api/design/create/index.d.ts.map +1 -1
  35. package/dist/api/design/doors/index.d.ts +159 -0
  36. package/dist/api/design/doors/index.d.ts.map +1 -1
  37. package/dist/api/design/furniture/index.d.ts +34 -5
  38. package/dist/api/design/furniture/index.d.ts.map +1 -1
  39. package/dist/api/design/index.d.ts +83 -0
  40. package/dist/api/design/index.d.ts.map +1 -1
  41. package/dist/api/design/lock.d.ts +26 -0
  42. package/dist/api/design/lock.d.ts.map +1 -1
  43. package/dist/api/design/materials/index.d.ts +159 -2
  44. package/dist/api/design/materials/index.d.ts.map +1 -1
  45. package/dist/api/design/query/index.d.ts +115 -5
  46. package/dist/api/design/query/index.d.ts.map +1 -1
  47. package/dist/api/design/query/spaces.d.ts +3 -3
  48. package/dist/api/design/selection/index.d.ts +144 -0
  49. package/dist/api/design/selection/index.d.ts.map +1 -1
  50. package/dist/api/design/transform/index.d.ts +83 -2
  51. package/dist/api/design/transform/index.d.ts.map +1 -1
  52. package/dist/api/design/update/index.d.ts +168 -0
  53. package/dist/api/design/update/index.d.ts.map +1 -1
  54. package/dist/api/design/windows/index.d.ts +113 -2
  55. package/dist/api/design/windows/index.d.ts.map +1 -1
  56. package/dist/api/entity/space.d.ts +2 -2
  57. package/dist/api/entity/story.d.ts +101 -7
  58. package/dist/api/entity/story.d.ts.map +1 -1
  59. package/dist/api/index.d.ts +5 -0
  60. package/dist/api/index.d.ts.map +1 -1
  61. package/dist/api/presentation/import.d.ts +49 -4
  62. package/dist/api/presentation/import.d.ts.map +1 -1
  63. package/dist/api/presentation/views.d.ts +210 -5
  64. package/dist/api/presentation/views.d.ts.map +1 -1
  65. package/dist/api/program/areas.d.ts +42 -12
  66. package/dist/api/program/areas.d.ts.map +1 -1
  67. package/dist/api/program/index.d.ts +3 -11
  68. package/dist/api/program/index.d.ts.map +1 -1
  69. package/dist/api/program/layout.d.ts +186 -11
  70. package/dist/api/program/layout.d.ts.map +1 -1
  71. package/dist/api/program/site.d.ts +84 -0
  72. package/dist/api/program/site.d.ts.map +1 -1
  73. package/dist/errors/codes.d.ts +34 -0
  74. package/dist/errors/codes.d.ts.map +1 -0
  75. package/dist/errors/envelope.d.ts +56 -0
  76. package/dist/errors/envelope.d.ts.map +1 -0
  77. package/dist/errors/index.d.ts +6 -0
  78. package/dist/errors/index.d.ts.map +1 -0
  79. package/dist/errors/plugin-error.d.ts +69 -0
  80. package/dist/errors/plugin-error.d.ts.map +1 -0
  81. package/dist/handles.d.ts +33 -0
  82. package/dist/handles.d.ts.map +1 -1
  83. package/dist/host-utils.d.ts +4 -0
  84. package/dist/host-utils.d.ts.map +1 -1
  85. package/dist/index.cjs +1942 -998
  86. package/dist/index.cjs.map +1 -1
  87. package/dist/index.d.ts +1 -0
  88. package/dist/index.d.ts.map +1 -1
  89. package/dist/index.js +1810 -994
  90. package/dist/index.js.map +1 -1
  91. package/package.json +2 -1
  92. package/scripts/generate-manifest.test.mjs +103 -4
  93. package/src/api/analysis/heatmaps.ts +256 -0
  94. package/src/api/analysis/illuminance.ts +155 -0
  95. package/src/api/analysis/index.ts +46 -0
  96. package/src/api/analysis/shadows.ts +183 -0
  97. package/src/api/analysis/sunlightHours.ts +211 -0
  98. package/src/api/analysis/sunpath.ts +83 -0
  99. package/src/api/core/index.ts +10 -0
  100. package/src/api/core/io/import/index.ts +432 -0
  101. package/src/api/core/io/index.ts +37 -0
  102. package/src/api/core/io/job/index.ts +140 -0
  103. package/src/api/core/io/query/index.ts +71 -0
  104. package/src/api/core/io/terrain/index.ts +214 -0
  105. package/src/api/core/io/underlay/index.ts +295 -0
  106. package/src/api/core/proposals/index.ts +509 -0
  107. package/src/api/design/create/index.ts +258 -0
  108. package/src/api/design/doors/index.ts +168 -0
  109. package/src/api/design/erase/index.ts +1 -1
  110. package/src/api/design/furniture/index.ts +36 -5
  111. package/src/api/design/index.ts +87 -0
  112. package/src/api/design/lock.ts +27 -0
  113. package/src/api/design/materials/index.ts +182 -2
  114. package/src/api/design/query/index.ts +81 -0
  115. package/src/api/design/selection/index.ts +129 -0
  116. package/src/api/design/transform/index.ts +74 -2
  117. package/src/api/design/update/index.ts +167 -0
  118. package/src/api/design/windows/index.ts +128 -2
  119. package/src/api/entity/story.ts +105 -7
  120. package/src/api/index.ts +5 -0
  121. package/src/api/presentation/import.ts +45 -4
  122. package/src/api/presentation/views.ts +221 -5
  123. package/src/api/program/areas.ts +34 -12
  124. package/src/api/program/index.ts +3 -11
  125. package/src/api/program/layout.ts +195 -11
  126. package/src/api/program/site.ts +93 -0
  127. package/src/errors/codes.ts +136 -0
  128. package/src/errors/envelope.ts +75 -0
  129. package/src/errors/index.ts +21 -0
  130. package/src/errors/plugin-error.ts +134 -0
  131. package/src/handles.ts +46 -0
  132. package/src/host-utils.ts +4 -0
  133. package/src/index.ts +1 -0
  134. package/test/errors.test.mjs +184 -0
@@ -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,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
+ }
@@ -9,6 +9,8 @@ import { PluginCoreGroupsApi } from "./groups"
9
9
  import { PluginCoreBuildingsApi } from "./buildings"
10
10
  import { PluginCoreLayersApi } from "./layers"
11
11
  import { PluginCoreTagsApi } from "./tags"
12
+ import { PluginCoreIoApi } from "./io"
13
+ import { PluginCoreProposalsApi } from "./proposals"
12
14
 
13
15
  /**
14
16
  * Core primitives and infrastructure used across the plugin API.
@@ -24,6 +26,8 @@ import { PluginCoreTagsApi } from "./tags"
24
26
  * - {@linkcode PluginCoreApi.buildings} — Read & edit buildings and their storeys
25
27
  * - {@linkcode PluginCoreApi.layers} — Read & toggle storey drawing/reference layers
26
28
  * - {@linkcode PluginCoreApi.tags} — Tag catalog + assignment
29
+ * - {@linkcode PluginCoreApi.io} — Import files (image/pdf/cad/model/terrain), poll jobs, manage underlays
30
+ * - {@linkcode PluginCoreApi.proposals} — Design options: read, create, rename, switch, delete
27
31
  */
28
32
  export abstract class PluginCoreApi {
29
33
  /** Vector and quaternion math utilities. See {@linkcode PluginMathApi}. */
@@ -48,6 +52,10 @@ export abstract class PluginCoreApi {
48
52
  public abstract layers: PluginCoreLayersApi
49
53
  /** Tags — tag catalog + assignment. See {@linkcode PluginCoreTagsApi}. */
50
54
  public abstract tags: PluginCoreTagsApi
55
+ /** I/O — file import, import jobs, and underlay management. See {@linkcode PluginCoreIoApi}. */
56
+ public abstract io: PluginCoreIoApi
57
+ /** Proposals — design options: read, create, rename, switch, delete. See {@linkcode PluginCoreProposalsApi}. */
58
+ public abstract proposals: PluginCoreProposalsApi
51
59
 
52
60
  constructor() {}
53
61
  }
@@ -63,3 +71,5 @@ export * from "./groups"
63
71
  export * from "./buildings"
64
72
  export * from "./layers"
65
73
  export * from "./tags"
74
+ export * from "./io"
75
+ export * from "./proposals"