@snaptrude/plugin-core 0.9.8 → 0.9.10

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.
@@ -0,0 +1,328 @@
1
+ import * as z from "zod";
2
+ import { PluginApiReturn } from "../../types";
3
+ import { ComponentHandle } from "../../handles";
4
+ import { PluginSpreadsheetCell } from "./spreadsheet";
5
+ /**
6
+ * Program metadata — the user-defined **custom columns** of the Program Data
7
+ * sheet and their per-space values.
8
+ *
9
+ * In program mode a **metadata header** is a custom column (e.g. "Department
10
+ * Code", "Occupancy", "Finish Level") added to the Program Data sheet; every
11
+ * space can then carry one **value** per header. This is the same store the
12
+ * Program tab reads and writes — values set here appear in the default Program
13
+ * Data sheet and in every custom sheet that shows the column, and values typed
14
+ * into the sheet are read back here. The store lives in the editor, so **no
15
+ * method in this namespace needs the Program tab open**.
16
+ *
17
+ * Headers are identified by a stable `headerId`. Values are plain cells
18
+ * (`string | number | boolean | null`); `null` clears a value. Departments and
19
+ * labels also carry metadata in the engine, but this namespace covers **spaces**
20
+ * (Mass/Floor components) — the per-space case plugins asked for.
21
+ *
22
+ * Reads never throw for a miss (`get` returns `null`, `list*` return `[]`).
23
+ * Writes are undoable and autosaved.
24
+ *
25
+ * Accessed via `snaptrude.program.metadata`.
26
+ */
27
+ export declare abstract class PluginProgramMetadataApi {
28
+ constructor();
29
+ /**
30
+ * List the metadata headers (custom columns) of the Program Data sheet.
31
+ *
32
+ * @returns A {@linkcode PluginProgramMetadataListHeadersResult} with a
33
+ * `headers` array (empty when the project has no custom columns).
34
+ *
35
+ * @examplePrompt List the custom metadata columns in program mode
36
+ * @examplePrompt What metadata headers does the program sheet have?
37
+ * @examplePrompt Show every custom column with its id
38
+ *
39
+ * # Example
40
+ * ```ts
41
+ * const { headers } = await snaptrude.program.metadata.listHeaders()
42
+ * for (const h of headers) console.log(h.headerId, h.name)
43
+ * ```
44
+ */
45
+ abstract listHeaders(): PluginApiReturn<PluginProgramMetadataListHeadersResult>;
46
+ /**
47
+ * Create a metadata header (a custom column on the Program Data sheet).
48
+ *
49
+ * Header names are unique per sheet: when a header with the same name already
50
+ * exists it is **reused** and returned (no duplicate column is created), so
51
+ * re-running a plugin is safe. The new column is appended after the sheet's
52
+ * existing custom columns.
53
+ *
54
+ * @param name - Column header text (non-empty).
55
+ * @param options - Optional `description` shown in the column's description
56
+ * row.
57
+ * @returns The created (or reused) {@linkcode PluginProgramMetadataHeader}.
58
+ * @throws If `name` is blank.
59
+ *
60
+ * @examplePrompt Add a custom column called Occupancy to the program sheet
61
+ * @examplePrompt Create a metadata header named Department Code
62
+ * @examplePrompt Make a new program-mode column for Finish Level
63
+ *
64
+ * # Example
65
+ * ```ts
66
+ * const header = await snaptrude.program.metadata.createHeader("Occupancy", {
67
+ * description: "People per room",
68
+ * })
69
+ * ```
70
+ */
71
+ abstract createHeader(name: string, options?: {
72
+ description?: string;
73
+ }): PluginApiReturn<PluginProgramMetadataCreateHeaderResult>;
74
+ /**
75
+ * Get one space's metadata values, keyed by header id.
76
+ *
77
+ * @param spaceId - The space (component id) to read.
78
+ * @returns A {@linkcode PluginProgramMetadataRecord} — `values` holds one entry
79
+ * per header the space has a value for — or `null` when no space has that id.
80
+ *
81
+ * @examplePrompt Get the metadata on this space
82
+ * @examplePrompt Read the custom column values for space sp_12
83
+ * @examplePrompt What is this room's Occupancy metadata?
84
+ *
85
+ * # Example
86
+ * ```ts
87
+ * const record = await snaptrude.program.metadata.get("sp_12")
88
+ * if (record) console.log(record.values)
89
+ * ```
90
+ */
91
+ abstract get(spaceId: ComponentHandle): PluginApiReturn<PluginProgramMetadataGetResult>;
92
+ /**
93
+ * List metadata values for many spaces at once.
94
+ *
95
+ * Pass `spaceIds` to read specific spaces (unknown ids are skipped), or omit
96
+ * it to read every space in the project. One host round-trip regardless of
97
+ * the number of spaces — prefer this over calling
98
+ * {@linkcode PluginProgramMetadataApi.get} in a loop.
99
+ *
100
+ * @param spaceIds - Optional space ids to read; omit for all spaces.
101
+ * @returns A {@linkcode PluginProgramMetadataListResult} with one
102
+ * {@linkcode PluginProgramMetadataRecord} per space.
103
+ *
104
+ * @performance One round-trip for any number of spaces — use this instead of a `get` loop.
105
+ *
106
+ * @examplePrompt List the metadata of every space
107
+ * @examplePrompt Read the custom column values for all rooms
108
+ * @examplePrompt Get the metadata for these three spaces in one call
109
+ *
110
+ * # Example
111
+ * ```ts
112
+ * const { records } = await snaptrude.program.metadata.list()
113
+ * const byId = Object.fromEntries(records.map((r) => [r.spaceId, r.values]))
114
+ * ```
115
+ */
116
+ abstract list(spaceIds?: ComponentHandle[]): PluginApiReturn<PluginProgramMetadataListResult>;
117
+ /**
118
+ * Update a space's metadata values (sparse).
119
+ *
120
+ * Only the headers present in `values` change; `null` clears a value. Every
121
+ * key must be an existing `headerId` (create columns first with
122
+ * {@linkcode PluginProgramMetadataApi.createHeader}). Undoable as one step.
123
+ *
124
+ * @param spaceId - The space (component id) to write.
125
+ * @param values - Header id → new cell value (`null` clears).
126
+ * @returns The space's full {@linkcode PluginProgramMetadataRecord} after the
127
+ * write.
128
+ * @throws If the space or any header id does not exist.
129
+ *
130
+ * @examplePrompt Set the Occupancy metadata of this space to 4
131
+ * @examplePrompt Store a department code on the selected rooms
132
+ * @examplePrompt Write custom column values onto space sp_12
133
+ * @examplePrompt Clear the Finish Level metadata on this space
134
+ *
135
+ * # Example
136
+ * ```ts
137
+ * const header = await snaptrude.program.metadata.createHeader("Occupancy")
138
+ * await snaptrude.program.metadata.update("sp_12", { [header.headerId]: 4 })
139
+ * ```
140
+ */
141
+ abstract update(spaceId: ComponentHandle, values: Record<string, PluginSpreadsheetCell>): PluginApiReturn<PluginProgramMetadataUpdateResult>;
142
+ /**
143
+ * Update metadata values on many spaces in one undoable step.
144
+ *
145
+ * The plural of {@linkcode PluginProgramMetadataApi.update}: each item names a
146
+ * space and its sparse `values`. Results are in input order. Capped at 1000
147
+ * items per call.
148
+ *
149
+ * @param items - The spaces and the values to write on each.
150
+ * @returns A {@linkcode PluginProgramMetadataUpdateManyResult} with one record
151
+ * per item, in input order.
152
+ * @throws If any space or header id does not exist (nothing is written).
153
+ *
154
+ * @performance One round-trip and one undo step for up to 1000 spaces — use this instead of an `update` loop.
155
+ *
156
+ * @examplePrompt Fill the Occupancy column for all bedrooms
157
+ * @examplePrompt Write metadata onto every selected space at once
158
+ * @examplePrompt Bulk-update custom column values
159
+ *
160
+ * # Example
161
+ * ```ts
162
+ * await snaptrude.program.metadata.updateMany([
163
+ * { spaceId: "sp_12", values: { [headerId]: 4 } },
164
+ * { spaceId: "sp_13", values: { [headerId]: 2 } },
165
+ * ])
166
+ * ```
167
+ */
168
+ abstract updateMany(items: PluginProgramMetadataUpdateItem[]): PluginApiReturn<PluginProgramMetadataUpdateManyResult>;
169
+ }
170
+ /**
171
+ * A metadata header — one custom column of the Program Data sheet.
172
+ *
173
+ * | Property | Type | Description |
174
+ * |---|---|---|
175
+ * | `headerId` | `string` | Stable header id (the key used in metadata `values`) |
176
+ * | `name` | `string` | Column header text |
177
+ * | `description` | `string` | Column description (`""` when none) |
178
+ * | `columnIndex` | `number` | Zero-based column index on the Program Data sheet |
179
+ */
180
+ export declare const PluginProgramMetadataHeader: z.ZodObject<{
181
+ headerId: z.ZodString;
182
+ name: z.ZodString;
183
+ description: z.ZodString;
184
+ columnIndex: z.ZodNumber;
185
+ }, z.core.$strip>;
186
+ export type PluginProgramMetadataHeader = z.infer<typeof PluginProgramMetadataHeader>;
187
+ /**
188
+ * Result of {@linkcode PluginProgramMetadataApi.listHeaders}.
189
+ *
190
+ * | Property | Type | Description |
191
+ * |---|---|---|
192
+ * | `headers` | {@linkcode PluginProgramMetadataHeader}`[]` | Every custom column, in sheet column order |
193
+ */
194
+ export declare const PluginProgramMetadataListHeadersResult: z.ZodObject<{
195
+ headers: z.ZodArray<z.ZodObject<{
196
+ headerId: z.ZodString;
197
+ name: z.ZodString;
198
+ description: z.ZodString;
199
+ columnIndex: z.ZodNumber;
200
+ }, z.core.$strip>>;
201
+ }, z.core.$strip>;
202
+ export type PluginProgramMetadataListHeadersResult = z.infer<typeof PluginProgramMetadataListHeadersResult>;
203
+ /**
204
+ * Arguments for {@linkcode PluginProgramMetadataApi.createHeader}.
205
+ *
206
+ * | Property | Type | Description |
207
+ * |---|---|---|
208
+ * | `name` | `string` | Column header text (non-empty) |
209
+ * | `description` | `string?` | Column description |
210
+ */
211
+ export declare const PluginProgramMetadataCreateHeaderArgs: z.ZodObject<{
212
+ name: z.ZodString;
213
+ description: z.ZodOptional<z.ZodString>;
214
+ }, z.core.$strip>;
215
+ export type PluginProgramMetadataCreateHeaderArgs = z.infer<typeof PluginProgramMetadataCreateHeaderArgs>;
216
+ /** Result of {@linkcode PluginProgramMetadataApi.createHeader} — the created or reused header. */
217
+ export declare const PluginProgramMetadataCreateHeaderResult: z.ZodObject<{
218
+ headerId: z.ZodString;
219
+ name: z.ZodString;
220
+ description: z.ZodString;
221
+ columnIndex: z.ZodNumber;
222
+ }, z.core.$strip>;
223
+ export type PluginProgramMetadataCreateHeaderResult = z.infer<typeof PluginProgramMetadataCreateHeaderResult>;
224
+ /**
225
+ * One space's metadata values.
226
+ *
227
+ * | Property | Type | Description |
228
+ * |---|---|---|
229
+ * | `spaceId` | `ComponentHandle` | The space's component id |
230
+ * | `values` | `Record<string, cell>` | Header id → value, one entry per header the space has a value for |
231
+ */
232
+ export declare const PluginProgramMetadataRecord: z.ZodObject<{
233
+ spaceId: z.ZodPipe<z.ZodString, z.ZodTransform<ComponentHandle, string>>;
234
+ values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
235
+ }, z.core.$strip>;
236
+ export type PluginProgramMetadataRecord = z.infer<typeof PluginProgramMetadataRecord>;
237
+ /** Arguments for {@linkcode PluginProgramMetadataApi.get}. */
238
+ export declare const PluginProgramMetadataGetArgs: z.ZodObject<{
239
+ spaceId: z.ZodPipe<z.ZodString, z.ZodTransform<ComponentHandle, string>>;
240
+ }, z.core.$strip>;
241
+ export type PluginProgramMetadataGetArgs = z.infer<typeof PluginProgramMetadataGetArgs>;
242
+ /** Result of {@linkcode PluginProgramMetadataApi.get} — the record, or `null` when the space does not exist. */
243
+ export declare const PluginProgramMetadataGetResult: z.ZodNullable<z.ZodObject<{
244
+ spaceId: z.ZodPipe<z.ZodString, z.ZodTransform<ComponentHandle, string>>;
245
+ values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
246
+ }, z.core.$strip>>;
247
+ export type PluginProgramMetadataGetResult = z.infer<typeof PluginProgramMetadataGetResult>;
248
+ /**
249
+ * Arguments for {@linkcode PluginProgramMetadataApi.list}.
250
+ *
251
+ * | Property | Type | Description |
252
+ * |---|---|---|
253
+ * | `spaceIds` | `ComponentHandle[]?` | Spaces to read; omit for every space |
254
+ */
255
+ export declare const PluginProgramMetadataListArgs: z.ZodObject<{
256
+ spaceIds: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<ComponentHandle, string>>>>;
257
+ }, z.core.$strip>;
258
+ export type PluginProgramMetadataListArgs = z.infer<typeof PluginProgramMetadataListArgs>;
259
+ /**
260
+ * Result of {@linkcode PluginProgramMetadataApi.list}.
261
+ *
262
+ * | Property | Type | Description |
263
+ * |---|---|---|
264
+ * | `records` | {@linkcode PluginProgramMetadataRecord}`[]` | One record per space (unknown ids skipped) |
265
+ */
266
+ export declare const PluginProgramMetadataListResult: z.ZodObject<{
267
+ records: z.ZodArray<z.ZodObject<{
268
+ spaceId: z.ZodPipe<z.ZodString, z.ZodTransform<ComponentHandle, string>>;
269
+ values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
270
+ }, z.core.$strip>>;
271
+ }, z.core.$strip>;
272
+ export type PluginProgramMetadataListResult = z.infer<typeof PluginProgramMetadataListResult>;
273
+ /**
274
+ * Arguments for {@linkcode PluginProgramMetadataApi.update}.
275
+ *
276
+ * | Property | Type | Description |
277
+ * |---|---|---|
278
+ * | `spaceId` | `ComponentHandle` | The space to write |
279
+ * | `values` | `Record<string, cell>` | Header id → new value (`null` clears); at least one entry |
280
+ */
281
+ export declare const PluginProgramMetadataUpdateArgs: z.ZodObject<{
282
+ spaceId: z.ZodPipe<z.ZodString, z.ZodTransform<ComponentHandle, string>>;
283
+ values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
284
+ }, z.core.$strip>;
285
+ export type PluginProgramMetadataUpdateArgs = z.infer<typeof PluginProgramMetadataUpdateArgs>;
286
+ /** Result of {@linkcode PluginProgramMetadataApi.update} — the space's record after the write. */
287
+ export declare const PluginProgramMetadataUpdateResult: z.ZodObject<{
288
+ spaceId: z.ZodPipe<z.ZodString, z.ZodTransform<ComponentHandle, string>>;
289
+ values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
290
+ }, z.core.$strip>;
291
+ export type PluginProgramMetadataUpdateResult = z.infer<typeof PluginProgramMetadataUpdateResult>;
292
+ /** One item of {@linkcode PluginProgramMetadataApi.updateMany} — mirrors the `update` args. */
293
+ export declare const PluginProgramMetadataUpdateItem: z.ZodObject<{
294
+ spaceId: z.ZodPipe<z.ZodString, z.ZodTransform<ComponentHandle, string>>;
295
+ values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
296
+ }, z.core.$strip>;
297
+ export type PluginProgramMetadataUpdateItem = z.infer<typeof PluginProgramMetadataUpdateItem>;
298
+ /** Maximum items per {@linkcode PluginProgramMetadataApi.updateMany} call. */
299
+ export declare const PLUGIN_PROGRAM_METADATA_BATCH_LIMIT = 1000;
300
+ /**
301
+ * Arguments for {@linkcode PluginProgramMetadataApi.updateMany}.
302
+ *
303
+ * | Property | Type | Description |
304
+ * |---|---|---|
305
+ * | `items` | {@linkcode PluginProgramMetadataUpdateItem}`[]` | 1–1000 space updates |
306
+ */
307
+ export declare const PluginProgramMetadataUpdateManyArgs: z.ZodObject<{
308
+ items: z.ZodArray<z.ZodObject<{
309
+ spaceId: z.ZodPipe<z.ZodString, z.ZodTransform<ComponentHandle, string>>;
310
+ values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
311
+ }, z.core.$strip>>;
312
+ }, z.core.$strip>;
313
+ export type PluginProgramMetadataUpdateManyArgs = z.infer<typeof PluginProgramMetadataUpdateManyArgs>;
314
+ /**
315
+ * Result of {@linkcode PluginProgramMetadataApi.updateMany}.
316
+ *
317
+ * | Property | Type | Description |
318
+ * |---|---|---|
319
+ * | `records` | {@linkcode PluginProgramMetadataRecord}`[]` | One record per item, in input order |
320
+ */
321
+ export declare const PluginProgramMetadataUpdateManyResult: z.ZodObject<{
322
+ records: z.ZodArray<z.ZodObject<{
323
+ spaceId: z.ZodPipe<z.ZodString, z.ZodTransform<ComponentHandle, string>>;
324
+ values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
325
+ }, z.core.$strip>>;
326
+ }, z.core.$strip>;
327
+ export type PluginProgramMetadataUpdateManyResult = z.infer<typeof PluginProgramMetadataUpdateManyResult>;
328
+ //# sourceMappingURL=metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../../src/api/program/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAErD;;;;;;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GAAG,CAAC,CAAC,KAAK,CACnD,OAAO,+BAA+B,CACvC,CAAA;AAED,8EAA8E;AAC9E,eAAO,MAAM,mCAAmC,OAAO,CAAA;AAEvD;;;;;;GAMG;AACH,eAAO,MAAM,mCAAmC;;;;;iBAK9C,CAAA;AACF,MAAM,MAAM,mCAAmC,GAAG,CAAC,CAAC,KAAK,CACvD,OAAO,mCAAmC,CAC3C,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,qCAAqC;;;;;iBAEhD,CAAA;AACF,MAAM,MAAM,qCAAqC,GAAG,CAAC,CAAC,KAAK,CACzD,OAAO,qCAAqC,CAC7C,CAAA"}
@@ -752,6 +752,129 @@ export declare abstract class PluginProgramSpreadsheetApi {
752
752
  * ```
753
753
  */
754
754
  abstract ping(): PluginApiReturn<PluginProgramSpreadsheetPingResult>;
755
+ /**
756
+ * Create a **custom program sheet** — a live view of the program grouped by a
757
+ * configurable hierarchy (the Program tab's "Custom" sheet with *Organize →
758
+ * Group by*).
759
+ *
760
+ * Unlike {@linkcode PluginProgramSpreadsheetApi.createSheet} (a blank sheet you
761
+ * write cells into), a custom sheet is data-bound: its rows are the project's
762
+ * spaces, re-rendered from the model, grouped by `groupBy` in order (e.g.
763
+ * `["departmentName", "<metadataHeaderId>", "label"]` for a healthcare
764
+ * department → sub-department → room hierarchy) and showing the `properties`
765
+ * columns. Valid property ids come from
766
+ * {@linkcode PluginProgramSpreadsheetApi.listCustomSheetProperties} — built-in
767
+ * properties plus every program metadata header id. The configuration is
768
+ * saved with the sheet.
769
+ *
770
+ * @param name - The sheet name to create (must not already exist).
771
+ * @param options - Optional `groupBy` (property ids, outermost first; default
772
+ * none), `properties` (column property ids, in order; default
773
+ * `["label", "areas"]`), and `groupColors` (property id → CSS hex fill for
774
+ * that level's group headers).
775
+ * @returns The sheet's {@linkcode PluginSpreadsheetCustomSheet} configuration.
776
+ * @throws If a sheet named `name` already exists, or a property id is unknown.
777
+ *
778
+ * @examplePrompt Create a custom sheet grouped by department then sub-department
779
+ * @examplePrompt Make a program view grouped by storey and label
780
+ * @examplePrompt Build a grouped program sheet for the healthcare hierarchy
781
+ * @examplePrompt Add a custom sheet with a department → room type group-by
782
+ *
783
+ * # Example
784
+ * ```ts
785
+ * const { headers } = await snaptrude.program.metadata.listHeaders()
786
+ * const subDept = headers.find((h) => h.name === "Sub-department")
787
+ * await snaptrude.program.spreadsheet.createCustomSheet("Clinical Program", {
788
+ * groupBy: ["departmentName", subDept.headerId, "label"],
789
+ * properties: ["label", "count", "areas", "netAreaAchieved"],
790
+ * })
791
+ * ```
792
+ */
793
+ abstract createCustomSheet(name: string, options?: {
794
+ groupBy?: string[];
795
+ properties?: string[];
796
+ groupColors?: Record<string, string>;
797
+ }): PluginApiReturn<PluginProgramSpreadsheetCustomSheetResult>;
798
+ /**
799
+ * Update a custom program sheet's group-by hierarchy, columns, or group colors.
800
+ *
801
+ * A **sparse** update: omitted fields are left unchanged. The sheet is
802
+ * re-rendered once and the configuration saved.
803
+ *
804
+ * @param sheetName - The custom sheet to update.
805
+ * @param options - Any of `groupBy`, `properties`, `groupColors` (see
806
+ * {@linkcode PluginProgramSpreadsheetApi.createCustomSheet}).
807
+ * @returns The sheet's updated {@linkcode PluginSpreadsheetCustomSheet}.
808
+ * @throws If `sheetName` is not a custom program sheet, or a property id is
809
+ * unknown.
810
+ *
811
+ * @examplePrompt Change the custom sheet to group by storey first
812
+ * @examplePrompt Add the Occupancy column to my grouped program sheet
813
+ * @examplePrompt Regroup the Clinical Program sheet by department only
814
+ *
815
+ * # Example
816
+ * ```ts
817
+ * await snaptrude.program.spreadsheet.updateCustomSheet("Clinical Program", {
818
+ * groupBy: ["storey", "departmentName"],
819
+ * })
820
+ * ```
821
+ */
822
+ abstract updateCustomSheet(sheetName: string, options: {
823
+ groupBy?: string[];
824
+ properties?: string[];
825
+ groupColors?: Record<string, string>;
826
+ }): PluginApiReturn<PluginProgramSpreadsheetCustomSheetResult>;
827
+ /**
828
+ * Get a custom program sheet's configuration.
829
+ *
830
+ * @param sheetName - The sheet to read.
831
+ * @returns Its {@linkcode PluginSpreadsheetCustomSheet}, or `null` when no
832
+ * custom program sheet has that name (plain sheets return `null` too).
833
+ *
834
+ * @examplePrompt How is the Clinical Program sheet grouped?
835
+ * @examplePrompt Get the group-by configuration of this custom sheet
836
+ *
837
+ * # Example
838
+ * ```ts
839
+ * const cfg = await snaptrude.program.spreadsheet.getCustomSheet("Clinical Program")
840
+ * if (cfg) console.log(cfg.groupBy, cfg.properties)
841
+ * ```
842
+ */
843
+ abstract getCustomSheet(sheetName: string): PluginApiReturn<PluginProgramSpreadsheetGetCustomSheetResult>;
844
+ /**
845
+ * List the custom program sheets in the workbook with their configurations.
846
+ *
847
+ * @returns A {@linkcode PluginProgramSpreadsheetListCustomSheetsResult} with a
848
+ * `sheets` array (empty when there are none).
849
+ *
850
+ * @examplePrompt List the custom program sheets
851
+ * @examplePrompt Which sheets are grouped program views?
852
+ *
853
+ * # Example
854
+ * ```ts
855
+ * const { sheets } = await snaptrude.program.spreadsheet.listCustomSheets()
856
+ * ```
857
+ */
858
+ abstract listCustomSheets(): PluginApiReturn<PluginProgramSpreadsheetListCustomSheetsResult>;
859
+ /**
860
+ * List the property ids a custom program sheet can show as columns or group by.
861
+ *
862
+ * Built-in properties (`label`, `departmentName`, `storey`, `areas`, …) plus
863
+ * one entry per program metadata header (its `headerId`). `groupable` is
864
+ * `false` for computed properties that can only be columns.
865
+ *
866
+ * @returns A {@linkcode PluginProgramSpreadsheetListCustomSheetPropertiesResult}.
867
+ *
868
+ * @examplePrompt What can I group a custom program sheet by?
869
+ * @examplePrompt List the columns available for a custom sheet
870
+ *
871
+ * # Example
872
+ * ```ts
873
+ * const { properties } = await snaptrude.program.spreadsheet.listCustomSheetProperties()
874
+ * const groupable = properties.filter((p) => p.groupable).map((p) => p.id)
875
+ * ```
876
+ */
877
+ abstract listCustomSheetProperties(): PluginApiReturn<PluginProgramSpreadsheetListCustomSheetPropertiesResult>;
755
878
  }
756
879
  /**
757
880
  * Program-spreadsheet templates — capture a sheet's layout as a named, reusable
@@ -2362,4 +2485,144 @@ export declare const PluginProgramSpreadsheetAddImageResult: z.ZodObject<{
2362
2485
  name: z.ZodString;
2363
2486
  }, z.core.$strip>;
2364
2487
  export type PluginProgramSpreadsheetAddImageResult = z.infer<typeof PluginProgramSpreadsheetAddImageResult>;
2488
+ /**
2489
+ * A custom program sheet's configuration — the grouped, data-bound program view
2490
+ * created by {@linkcode PluginProgramSpreadsheetApi.createCustomSheet}.
2491
+ *
2492
+ * | Property | Type | Description |
2493
+ * |---|---|---|
2494
+ * | `sheetName` | `string` | The sheet's name |
2495
+ * | `groupBy` | `string[]` | Group-by hierarchy, outermost first (property ids); `[]` when ungrouped |
2496
+ * | `properties` | `string[]` | Column property ids in column order (`""` marks an unassigned column) |
2497
+ * | `groupColors` | `Record<string, string>` | Property id → CSS hex fill of that level's group headers |
2498
+ * | `proposalId` | `string \| null` | The proposal the sheet belongs to, or `null` when the project has none |
2499
+ */
2500
+ export declare const PluginSpreadsheetCustomSheet: z.ZodObject<{
2501
+ sheetName: z.ZodString;
2502
+ groupBy: z.ZodArray<z.ZodString>;
2503
+ properties: z.ZodArray<z.ZodString>;
2504
+ groupColors: z.ZodRecord<z.ZodString, z.ZodString>;
2505
+ proposalId: z.ZodNullable<z.ZodString>;
2506
+ }, z.core.$strip>;
2507
+ export type PluginSpreadsheetCustomSheet = z.infer<typeof PluginSpreadsheetCustomSheet>;
2508
+ /**
2509
+ * The configurable part of a custom program sheet, for
2510
+ * {@linkcode PluginProgramSpreadsheetApi.createCustomSheet} /
2511
+ * {@linkcode PluginProgramSpreadsheetApi.updateCustomSheet}. All fields optional.
2512
+ *
2513
+ * | Property | Type | Description |
2514
+ * |---|---|---|
2515
+ * | `groupBy` | `string[]?` | Group-by hierarchy, outermost first (property ids) |
2516
+ * | `properties` | `string[]?` | Column property ids, in order |
2517
+ * | `groupColors` | `Record<string, string>?` | Property id → CSS hex fill for that level's group headers |
2518
+ */
2519
+ export declare const PluginSpreadsheetCustomSheetConfig: z.ZodObject<{
2520
+ groupBy: z.ZodOptional<z.ZodArray<z.ZodString>>;
2521
+ properties: z.ZodOptional<z.ZodArray<z.ZodString>>;
2522
+ groupColors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
2523
+ }, z.core.$strip>;
2524
+ export type PluginSpreadsheetCustomSheetConfig = z.infer<typeof PluginSpreadsheetCustomSheetConfig>;
2525
+ /**
2526
+ * Arguments for {@linkcode PluginProgramSpreadsheetApi.createCustomSheet}.
2527
+ *
2528
+ * | Property | Type | Description |
2529
+ * |---|---|---|
2530
+ * | `name` | `string` | The sheet name to create |
2531
+ * | `groupBy` / `properties` / `groupColors` | — | See {@linkcode PluginSpreadsheetCustomSheetConfig} |
2532
+ */
2533
+ export declare const PluginProgramSpreadsheetCreateCustomSheetArgs: z.ZodObject<{
2534
+ groupBy: z.ZodOptional<z.ZodArray<z.ZodString>>;
2535
+ properties: z.ZodOptional<z.ZodArray<z.ZodString>>;
2536
+ groupColors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
2537
+ name: z.ZodString;
2538
+ }, z.core.$strip>;
2539
+ export type PluginProgramSpreadsheetCreateCustomSheetArgs = z.infer<typeof PluginProgramSpreadsheetCreateCustomSheetArgs>;
2540
+ /**
2541
+ * Arguments for {@linkcode PluginProgramSpreadsheetApi.updateCustomSheet}.
2542
+ *
2543
+ * | Property | Type | Description |
2544
+ * |---|---|---|
2545
+ * | `sheetName` | `string` | The custom sheet to update |
2546
+ * | `groupBy` / `properties` / `groupColors` | — | Sparse; see {@linkcode PluginSpreadsheetCustomSheetConfig} |
2547
+ */
2548
+ export declare const PluginProgramSpreadsheetUpdateCustomSheetArgs: z.ZodObject<{
2549
+ groupBy: z.ZodOptional<z.ZodArray<z.ZodString>>;
2550
+ properties: z.ZodOptional<z.ZodArray<z.ZodString>>;
2551
+ groupColors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
2552
+ sheetName: z.ZodString;
2553
+ }, z.core.$strip>;
2554
+ export type PluginProgramSpreadsheetUpdateCustomSheetArgs = z.infer<typeof PluginProgramSpreadsheetUpdateCustomSheetArgs>;
2555
+ /** Result of `createCustomSheet` / `updateCustomSheet` — the sheet's configuration. */
2556
+ export declare const PluginProgramSpreadsheetCustomSheetResult: z.ZodObject<{
2557
+ sheetName: z.ZodString;
2558
+ groupBy: z.ZodArray<z.ZodString>;
2559
+ properties: z.ZodArray<z.ZodString>;
2560
+ groupColors: z.ZodRecord<z.ZodString, z.ZodString>;
2561
+ proposalId: z.ZodNullable<z.ZodString>;
2562
+ }, z.core.$strip>;
2563
+ export type PluginProgramSpreadsheetCustomSheetResult = z.infer<typeof PluginProgramSpreadsheetCustomSheetResult>;
2564
+ /** Arguments for {@linkcode PluginProgramSpreadsheetApi.getCustomSheet}. */
2565
+ export declare const PluginProgramSpreadsheetGetCustomSheetArgs: z.ZodObject<{
2566
+ sheetName: z.ZodString;
2567
+ }, z.core.$strip>;
2568
+ export type PluginProgramSpreadsheetGetCustomSheetArgs = z.infer<typeof PluginProgramSpreadsheetGetCustomSheetArgs>;
2569
+ /** Result of {@linkcode PluginProgramSpreadsheetApi.getCustomSheet} — the configuration, or `null`. */
2570
+ export declare const PluginProgramSpreadsheetGetCustomSheetResult: z.ZodNullable<z.ZodObject<{
2571
+ sheetName: z.ZodString;
2572
+ groupBy: z.ZodArray<z.ZodString>;
2573
+ properties: z.ZodArray<z.ZodString>;
2574
+ groupColors: z.ZodRecord<z.ZodString, z.ZodString>;
2575
+ proposalId: z.ZodNullable<z.ZodString>;
2576
+ }, z.core.$strip>>;
2577
+ export type PluginProgramSpreadsheetGetCustomSheetResult = z.infer<typeof PluginProgramSpreadsheetGetCustomSheetResult>;
2578
+ /**
2579
+ * Result of {@linkcode PluginProgramSpreadsheetApi.listCustomSheets}.
2580
+ *
2581
+ * | Property | Type | Description |
2582
+ * |---|---|---|
2583
+ * | `sheets` | {@linkcode PluginSpreadsheetCustomSheet}`[]` | Every custom program sheet |
2584
+ */
2585
+ export declare const PluginProgramSpreadsheetListCustomSheetsResult: z.ZodObject<{
2586
+ sheets: z.ZodArray<z.ZodObject<{
2587
+ sheetName: z.ZodString;
2588
+ groupBy: z.ZodArray<z.ZodString>;
2589
+ properties: z.ZodArray<z.ZodString>;
2590
+ groupColors: z.ZodRecord<z.ZodString, z.ZodString>;
2591
+ proposalId: z.ZodNullable<z.ZodString>;
2592
+ }, z.core.$strip>>;
2593
+ }, z.core.$strip>;
2594
+ export type PluginProgramSpreadsheetListCustomSheetsResult = z.infer<typeof PluginProgramSpreadsheetListCustomSheetsResult>;
2595
+ /**
2596
+ * A property a custom program sheet can show or group by.
2597
+ *
2598
+ * | Property | Type | Description |
2599
+ * |---|---|---|
2600
+ * | `id` | `string` | Property id (built-in key, or a metadata `headerId`) |
2601
+ * | `name` | `string` | Display name |
2602
+ * | `groupable` | `boolean` | Whether the sheet can group by it |
2603
+ * | `custom` | `boolean` | `true` for program metadata headers, `false` for built-ins |
2604
+ */
2605
+ export declare const PluginSpreadsheetCustomSheetProperty: z.ZodObject<{
2606
+ id: z.ZodString;
2607
+ name: z.ZodString;
2608
+ groupable: z.ZodBoolean;
2609
+ custom: z.ZodBoolean;
2610
+ }, z.core.$strip>;
2611
+ export type PluginSpreadsheetCustomSheetProperty = z.infer<typeof PluginSpreadsheetCustomSheetProperty>;
2612
+ /**
2613
+ * Result of {@linkcode PluginProgramSpreadsheetApi.listCustomSheetProperties}.
2614
+ *
2615
+ * | Property | Type | Description |
2616
+ * |---|---|---|
2617
+ * | `properties` | {@linkcode PluginSpreadsheetCustomSheetProperty}`[]` | Built-ins first, then metadata headers |
2618
+ */
2619
+ export declare const PluginProgramSpreadsheetListCustomSheetPropertiesResult: z.ZodObject<{
2620
+ properties: z.ZodArray<z.ZodObject<{
2621
+ id: z.ZodString;
2622
+ name: z.ZodString;
2623
+ groupable: z.ZodBoolean;
2624
+ custom: z.ZodBoolean;
2625
+ }, z.core.$strip>>;
2626
+ }, z.core.$strip>;
2627
+ export type PluginProgramSpreadsheetListCustomSheetPropertiesResult = z.infer<typeof PluginProgramSpreadsheetListCustomSheetPropertiesResult>;
2365
2628
  //# sourceMappingURL=spreadsheet.d.ts.map