@camstack/types 1.2.416 → 1.2.418

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 (79) hide show
  1. package/dist/addon.js +1 -1
  2. package/dist/addon.mjs +1 -1
  3. package/dist/capabilities/air-quality-sensor.cap.d.ts +2 -8
  4. package/dist/capabilities/ambient-light-sensor.cap.d.ts +3 -14
  5. package/dist/capabilities/battery.cap.d.ts +9 -2
  6. package/dist/capabilities/binary.cap.d.ts +0 -5
  7. package/dist/capabilities/capability-definition.d.ts +11 -6
  8. package/dist/capabilities/composer.cap.d.ts +198 -0
  9. package/dist/capabilities/consumables.cap.d.ts +30 -41
  10. package/dist/capabilities/control.cap.d.ts +3 -25
  11. package/dist/capabilities/core-blocks.cap.d.ts +1421 -0
  12. package/dist/capabilities/customize-catalog.d.ts +0 -8
  13. package/dist/capabilities/customize-spec.d.ts +2 -3
  14. package/dist/capabilities/device-manager.cap.d.ts +79 -0
  15. package/dist/capabilities/device-provider.cap.d.ts +36 -0
  16. package/dist/capabilities/enum-sensor.cap.d.ts +5 -17
  17. package/dist/capabilities/group-status.cap.d.ts +46 -0
  18. package/dist/capabilities/humidity-sensor.cap.d.ts +3 -14
  19. package/dist/capabilities/index.d.ts +4 -2
  20. package/dist/capabilities/motion.cap.d.ts +13 -5
  21. package/dist/capabilities/numeric-sensor.cap.d.ts +8 -16
  22. package/dist/capabilities/pet-feeder.cap.d.ts +1 -1
  23. package/dist/capabilities/power-meter.cap.d.ts +0 -11
  24. package/dist/capabilities/pressure-sensor.cap.d.ts +3 -9
  25. package/dist/capabilities/running-state.cap.d.ts +1 -2
  26. package/dist/capabilities/runtime-field-unit.d.ts +1 -0
  27. package/dist/capabilities/runtime-field-units.d.ts +8 -0
  28. package/dist/capabilities/switch.cap.d.ts +0 -5
  29. package/dist/capabilities/temperature-sensor.cap.d.ts +5 -20
  30. package/dist/capabilities/weather.cap.d.ts +4 -13
  31. package/dist/client.d.ts +2 -1
  32. package/dist/client.js +57 -5
  33. package/dist/client.mjs +55 -6
  34. package/dist/composition/composition-report.d.ts +80 -3
  35. package/dist/composition/composition.d.ts +285 -5
  36. package/dist/composition/helpers/aggregate.d.ts +41 -0
  37. package/dist/composition/helpers/catalog.d.ts +42 -0
  38. package/dist/composition/helpers/compile.d.ts +22 -0
  39. package/dist/composition/helpers/index.d.ts +6 -0
  40. package/dist/composition/helpers/save.d.ts +18 -0
  41. package/dist/composition/helpers/source-pick.d.ts +40 -0
  42. package/dist/composition/helpers/spec.d.ts +38 -0
  43. package/dist/composition/index.d.ts +1 -0
  44. package/dist/composition/source-ref.d.ts +11 -0
  45. package/dist/composition/state-fields.d.ts +1 -1
  46. package/dist/composition/validate-composition.d.ts +8 -2
  47. package/dist/{composition-kEl9mevu.mjs → composition-B85l9j1M.mjs} +114 -8
  48. package/dist/{composition-DsmkwP9-.js → composition-OJKOJJD-.js} +179 -7
  49. package/dist/device/cap-vocabulary/entries/sensors.d.ts +1 -1
  50. package/dist/device/cap-vocabulary/types.d.ts +2 -2
  51. package/dist/device/schema-fields.d.ts +3 -0
  52. package/dist/device/source-info.d.ts +12 -6
  53. package/dist/generated/addon-api.d.ts +14 -0
  54. package/dist/generated/addon-cap-facts.d.ts +1 -1
  55. package/dist/generated/cap-status-types.d.ts +3 -1
  56. package/dist/generated/capability-router-map.d.ts +5 -2
  57. package/dist/generated/customize-catalog.d.ts +11 -87
  58. package/dist/generated/device-local-state.d.ts +3 -0
  59. package/dist/generated/device-proxy.d.ts +3 -0
  60. package/dist/generated/history-catalog.d.ts +1 -1
  61. package/dist/generated/method-access-map.d.ts +1 -1
  62. package/dist/generated/method-device-selectors.d.ts +1 -1
  63. package/dist/generated/runtime-state-durability.d.ts +1 -1
  64. package/dist/index.d.ts +3 -1
  65. package/dist/index.js +1458 -499
  66. package/dist/index.mjs +1420 -499
  67. package/dist/node.js +1 -1
  68. package/dist/node.mjs +1 -1
  69. package/dist/{sleep-BPQ2ZyaI.js → sleep-7Gw3GJ4n.js} +232 -127
  70. package/dist/{sleep-BErAxhul.mjs → sleep-B81gwQuR.mjs} +179 -128
  71. package/dist/units/convert.d.ts +5 -0
  72. package/dist/units/format-reading.d.ts +15 -0
  73. package/dist/units/index.d.ts +8 -1
  74. package/dist/units/ingest-reading.d.ts +21 -0
  75. package/dist/units/quantity.d.ts +47 -0
  76. package/dist/units/threshold.d.ts +6 -0
  77. package/dist/units/unit-table.d.ts +2 -228
  78. package/package.json +1 -1
  79. package/dist/capabilities/advanced-parameters.d.ts +0 -17
@@ -8,10 +8,14 @@ export declare const CompositionProblemCodeSchema: z.ZodEnum<{
8
8
  "duplicate-target": "duplicate-target";
9
9
  "expression-invalid": "expression-invalid";
10
10
  "has-commands": "has-commands";
11
+ "helper-mismatch": "helper-mismatch";
11
12
  "item-field-reserved": "item-field-reserved";
12
13
  "kind-mismatch": "kind-mismatch";
13
14
  "may-be-null": "may-be-null";
15
+ "member-constraint": "member-constraint";
14
16
  "missing-field": "missing-field";
17
+ "mixed-quantity": "mixed-quantity";
18
+ "native-capability-replace": "native-capability-replace";
15
19
  "nested-field": "nested-field";
16
20
  "not-composable": "not-composable";
17
21
  "not-item-array": "not-item-array";
@@ -35,10 +39,14 @@ export declare const CompositionProblemSchema: z.ZodObject<{
35
39
  "duplicate-target": "duplicate-target";
36
40
  "expression-invalid": "expression-invalid";
37
41
  "has-commands": "has-commands";
42
+ "helper-mismatch": "helper-mismatch";
38
43
  "item-field-reserved": "item-field-reserved";
39
44
  "kind-mismatch": "kind-mismatch";
40
45
  "may-be-null": "may-be-null";
46
+ "member-constraint": "member-constraint";
41
47
  "missing-field": "missing-field";
48
+ "mixed-quantity": "mixed-quantity";
49
+ "native-capability-replace": "native-capability-replace";
42
50
  "nested-field": "nested-field";
43
51
  "not-composable": "not-composable";
44
52
  "not-item-array": "not-item-array";
@@ -74,6 +82,7 @@ export type CompositionFieldKind = z.infer<typeof CompositionFieldKindSchema>;
74
82
  export declare const CompositionUnavailableModeSchema: z.ZodEnum<{
75
83
  null: "null";
76
84
  offline: "offline";
85
+ omit: "omit";
77
86
  release: "release";
78
87
  unknown: "unknown";
79
88
  }>;
@@ -117,6 +126,7 @@ export declare const CompositionFieldPlanSchema: z.ZodObject<{
117
126
  unavailable: z.ZodEnum<{
118
127
  null: "null";
119
128
  offline: "offline";
129
+ omit: "omit";
120
130
  release: "release";
121
131
  unknown: "unknown";
122
132
  }>;
@@ -152,6 +162,36 @@ export declare const CompositionFieldPlanSchema: z.ZodObject<{
152
162
  }, z.core.$strip>, z.ZodObject<{
153
163
  kind: z.ZodLiteral<"code">;
154
164
  code: z.ZodString;
165
+ }, z.core.$strip>, z.ZodObject<{
166
+ kind: z.ZodLiteral<"aggregate">;
167
+ reducer: z.ZodEnum<{
168
+ all: "all";
169
+ any: "any";
170
+ max: "max";
171
+ mean: "mean";
172
+ median: "median";
173
+ min: "min";
174
+ sum: "sum";
175
+ }>;
176
+ reads: z.ZodArray<z.ZodObject<{
177
+ source: z.ZodObject<{
178
+ addonId: z.ZodString;
179
+ stableId: z.ZodString;
180
+ }, z.core.$strip>;
181
+ cap: z.ZodString;
182
+ fieldPath: z.ZodString;
183
+ }, z.core.$strip>>;
184
+ publish: z.ZodEnum<{
185
+ excluded: "excluded";
186
+ included: "included";
187
+ total: "total";
188
+ value: "value";
189
+ }>;
190
+ empty: z.ZodEnum<{
191
+ null: "null";
192
+ offline: "offline";
193
+ omit: "omit";
194
+ }>;
155
195
  }, z.core.$strip>], "kind">;
156
196
  reads: z.ZodArray<z.ZodObject<{
157
197
  source: z.ZodObject<{
@@ -166,9 +206,11 @@ export type CompositionFieldPlan = z.infer<typeof CompositionFieldPlanSchema>;
166
206
  /** The key every record map, log line and graph node uses for a planned field. Two items' `status` are two keys. */
167
207
  export declare function compositionFieldKey(plan: Pick<CompositionFieldPlan, 'cap' | 'path' | 'item'>): string;
168
208
  /**
169
- * What a feature does to its target (D663): `new` builds a capability on a new
170
- * device; on an existing device it `add`s a capability the device lacks, or
171
- * `replace`s named fields of one it has natively.
209
+ * What a feature does to its target (D663, D944): `new` builds a capability on a
210
+ * new device; on an existing device it `add`s a capability the device lacks.
211
+ * Replacing a capability the device already serves is refused
212
+ * (`native-capability-replace`), not planned. `replace` remains on the claim
213
+ * wire for a claim the hub already holds.
172
214
  */
173
215
  export declare const CompositionFeatureModeSchema: z.ZodEnum<{
174
216
  add: "add";
@@ -194,10 +236,14 @@ export declare const CompositionValidationSchema: z.ZodObject<{
194
236
  "duplicate-target": "duplicate-target";
195
237
  "expression-invalid": "expression-invalid";
196
238
  "has-commands": "has-commands";
239
+ "helper-mismatch": "helper-mismatch";
197
240
  "item-field-reserved": "item-field-reserved";
198
241
  "kind-mismatch": "kind-mismatch";
199
242
  "may-be-null": "may-be-null";
243
+ "member-constraint": "member-constraint";
200
244
  "missing-field": "missing-field";
245
+ "mixed-quantity": "mixed-quantity";
246
+ "native-capability-replace": "native-capability-replace";
201
247
  "nested-field": "nested-field";
202
248
  "not-composable": "not-composable";
203
249
  "not-item-array": "not-item-array";
@@ -236,6 +282,7 @@ export declare const CompositionValidationSchema: z.ZodObject<{
236
282
  unavailable: z.ZodEnum<{
237
283
  null: "null";
238
284
  offline: "offline";
285
+ omit: "omit";
239
286
  release: "release";
240
287
  unknown: "unknown";
241
288
  }>;
@@ -271,6 +318,36 @@ export declare const CompositionValidationSchema: z.ZodObject<{
271
318
  }, z.core.$strip>, z.ZodObject<{
272
319
  kind: z.ZodLiteral<"code">;
273
320
  code: z.ZodString;
321
+ }, z.core.$strip>, z.ZodObject<{
322
+ kind: z.ZodLiteral<"aggregate">;
323
+ reducer: z.ZodEnum<{
324
+ all: "all";
325
+ any: "any";
326
+ max: "max";
327
+ mean: "mean";
328
+ median: "median";
329
+ min: "min";
330
+ sum: "sum";
331
+ }>;
332
+ reads: z.ZodArray<z.ZodObject<{
333
+ source: z.ZodObject<{
334
+ addonId: z.ZodString;
335
+ stableId: z.ZodString;
336
+ }, z.core.$strip>;
337
+ cap: z.ZodString;
338
+ fieldPath: z.ZodString;
339
+ }, z.core.$strip>>;
340
+ publish: z.ZodEnum<{
341
+ excluded: "excluded";
342
+ included: "included";
343
+ total: "total";
344
+ value: "value";
345
+ }>;
346
+ empty: z.ZodEnum<{
347
+ null: "null";
348
+ offline: "offline";
349
+ omit: "omit";
350
+ }>;
274
351
  }, z.core.$strip>], "kind">;
275
352
  reads: z.ZodArray<z.ZodObject<{
276
353
  source: z.ZodObject<{
@@ -19,6 +19,7 @@
19
19
  */
20
20
  import { z } from 'zod';
21
21
  import { DeviceRole, DeviceType } from '../device/device-type.js';
22
+ import { type CompositionSourceRef } from './source-ref.js';
22
23
  /** The owner of every composed device: the `composer` builtin. */
23
24
  export declare const COMPOSER_ADDON_ID = "composer";
24
25
  /**
@@ -34,11 +35,7 @@ export declare const MAX_COMPOSITION_FEATURES = 16;
34
35
  export declare const MAX_COMPOSITION_FIELDS_PER_FEATURE = 32;
35
36
  /** Longest snippet a `code` source may carry (slice 4). */
36
37
  export declare const MAX_COMPOSITION_CODE_LENGTH = 20000;
37
- export declare const CompositionSourceRefSchema: z.ZodObject<{
38
- addonId: z.ZodString;
39
- stableId: z.ZodString;
40
- }, z.core.$strip>;
41
- export type CompositionSourceRef = z.infer<typeof CompositionSourceRefSchema>;
38
+ export { CompositionSourceRefSchema, type CompositionSourceRef } from './source-ref.js';
42
39
  /** One field of one capability of one source device. */
43
40
  export declare const CompositionFieldReadSchema: z.ZodObject<{
44
41
  source: z.ZodObject<{
@@ -107,6 +104,43 @@ export declare const CompositionCodeSourceSchema: z.ZodObject<{
107
104
  code: z.ZodString;
108
105
  }, z.core.$strip>;
109
106
  export type CompositionCodeSource = z.infer<typeof CompositionCodeSourceSchema>;
107
+ /**
108
+ * `aggregate`: a group reducer. Offline and unknown reads are excluded, not
109
+ * folded in as 0 or false (D944). Free expressions stay `expression` so a
110
+ * stale member is still included there.
111
+ */
112
+ export declare const CompositionAggregateSourceSchema: z.ZodObject<{
113
+ kind: z.ZodLiteral<"aggregate">;
114
+ reducer: z.ZodEnum<{
115
+ all: "all";
116
+ any: "any";
117
+ max: "max";
118
+ mean: "mean";
119
+ median: "median";
120
+ min: "min";
121
+ sum: "sum";
122
+ }>;
123
+ reads: z.ZodArray<z.ZodObject<{
124
+ source: z.ZodObject<{
125
+ addonId: z.ZodString;
126
+ stableId: z.ZodString;
127
+ }, z.core.$strip>;
128
+ cap: z.ZodString;
129
+ fieldPath: z.ZodString;
130
+ }, z.core.$strip>>;
131
+ publish: z.ZodEnum<{
132
+ excluded: "excluded";
133
+ included: "included";
134
+ total: "total";
135
+ value: "value";
136
+ }>;
137
+ empty: z.ZodEnum<{
138
+ null: "null";
139
+ offline: "offline";
140
+ omit: "omit";
141
+ }>;
142
+ }, z.core.$strip>;
143
+ export type CompositionAggregateSource = z.infer<typeof CompositionAggregateSourceSchema>;
110
144
  export declare const CompositionFieldSourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
111
145
  source: z.ZodObject<{
112
146
  addonId: z.ZodString;
@@ -133,6 +167,36 @@ export declare const CompositionFieldSourceSchema: z.ZodDiscriminatedUnion<[z.Zo
133
167
  }, z.core.$strip>, z.ZodObject<{
134
168
  kind: z.ZodLiteral<"code">;
135
169
  code: z.ZodString;
170
+ }, z.core.$strip>, z.ZodObject<{
171
+ kind: z.ZodLiteral<"aggregate">;
172
+ reducer: z.ZodEnum<{
173
+ all: "all";
174
+ any: "any";
175
+ max: "max";
176
+ mean: "mean";
177
+ median: "median";
178
+ min: "min";
179
+ sum: "sum";
180
+ }>;
181
+ reads: z.ZodArray<z.ZodObject<{
182
+ source: z.ZodObject<{
183
+ addonId: z.ZodString;
184
+ stableId: z.ZodString;
185
+ }, z.core.$strip>;
186
+ cap: z.ZodString;
187
+ fieldPath: z.ZodString;
188
+ }, z.core.$strip>>;
189
+ publish: z.ZodEnum<{
190
+ excluded: "excluded";
191
+ included: "included";
192
+ total: "total";
193
+ value: "value";
194
+ }>;
195
+ empty: z.ZodEnum<{
196
+ null: "null";
197
+ offline: "offline";
198
+ omit: "omit";
199
+ }>;
136
200
  }, z.core.$strip>], "kind">;
137
201
  export type CompositionFieldSource = z.infer<typeof CompositionFieldSourceSchema>;
138
202
  /** `forward`: RESERVED for slice 3. Argument mapping arrives there as an additive optional `args`. */
@@ -197,6 +261,36 @@ export declare const CompositionItemEntrySchema: z.ZodObject<{
197
261
  }, z.core.$strip>, z.ZodObject<{
198
262
  kind: z.ZodLiteral<"code">;
199
263
  code: z.ZodString;
264
+ }, z.core.$strip>, z.ZodObject<{
265
+ kind: z.ZodLiteral<"aggregate">;
266
+ reducer: z.ZodEnum<{
267
+ all: "all";
268
+ any: "any";
269
+ max: "max";
270
+ mean: "mean";
271
+ median: "median";
272
+ min: "min";
273
+ sum: "sum";
274
+ }>;
275
+ reads: z.ZodArray<z.ZodObject<{
276
+ source: z.ZodObject<{
277
+ addonId: z.ZodString;
278
+ stableId: z.ZodString;
279
+ }, z.core.$strip>;
280
+ cap: z.ZodString;
281
+ fieldPath: z.ZodString;
282
+ }, z.core.$strip>>;
283
+ publish: z.ZodEnum<{
284
+ excluded: "excluded";
285
+ included: "included";
286
+ total: "total";
287
+ value: "value";
288
+ }>;
289
+ empty: z.ZodEnum<{
290
+ null: "null";
291
+ offline: "offline";
292
+ omit: "omit";
293
+ }>;
200
294
  }, z.core.$strip>], "kind">>;
201
295
  }, z.core.$strip>;
202
296
  export type CompositionItemEntry = z.infer<typeof CompositionItemEntrySchema>;
@@ -230,6 +324,36 @@ export declare const CompositionFieldsFeatureSchema: z.ZodObject<{
230
324
  }, z.core.$strip>, z.ZodObject<{
231
325
  kind: z.ZodLiteral<"code">;
232
326
  code: z.ZodString;
327
+ }, z.core.$strip>, z.ZodObject<{
328
+ kind: z.ZodLiteral<"aggregate">;
329
+ reducer: z.ZodEnum<{
330
+ all: "all";
331
+ any: "any";
332
+ max: "max";
333
+ mean: "mean";
334
+ median: "median";
335
+ min: "min";
336
+ sum: "sum";
337
+ }>;
338
+ reads: z.ZodArray<z.ZodObject<{
339
+ source: z.ZodObject<{
340
+ addonId: z.ZodString;
341
+ stableId: z.ZodString;
342
+ }, z.core.$strip>;
343
+ cap: z.ZodString;
344
+ fieldPath: z.ZodString;
345
+ }, z.core.$strip>>;
346
+ publish: z.ZodEnum<{
347
+ excluded: "excluded";
348
+ included: "included";
349
+ total: "total";
350
+ value: "value";
351
+ }>;
352
+ empty: z.ZodEnum<{
353
+ null: "null";
354
+ offline: "offline";
355
+ omit: "omit";
356
+ }>;
233
357
  }, z.core.$strip>], "kind">>;
234
358
  items: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
235
359
  label: z.ZodString;
@@ -259,6 +383,36 @@ export declare const CompositionFieldsFeatureSchema: z.ZodObject<{
259
383
  }, z.core.$strip>, z.ZodObject<{
260
384
  kind: z.ZodLiteral<"code">;
261
385
  code: z.ZodString;
386
+ }, z.core.$strip>, z.ZodObject<{
387
+ kind: z.ZodLiteral<"aggregate">;
388
+ reducer: z.ZodEnum<{
389
+ all: "all";
390
+ any: "any";
391
+ max: "max";
392
+ mean: "mean";
393
+ median: "median";
394
+ min: "min";
395
+ sum: "sum";
396
+ }>;
397
+ reads: z.ZodArray<z.ZodObject<{
398
+ source: z.ZodObject<{
399
+ addonId: z.ZodString;
400
+ stableId: z.ZodString;
401
+ }, z.core.$strip>;
402
+ cap: z.ZodString;
403
+ fieldPath: z.ZodString;
404
+ }, z.core.$strip>>;
405
+ publish: z.ZodEnum<{
406
+ excluded: "excluded";
407
+ included: "included";
408
+ total: "total";
409
+ value: "value";
410
+ }>;
411
+ empty: z.ZodEnum<{
412
+ null: "null";
413
+ offline: "offline";
414
+ omit: "omit";
415
+ }>;
262
416
  }, z.core.$strip>], "kind">>;
263
417
  }, z.core.$strip>>>;
264
418
  commands: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -316,6 +470,36 @@ export declare const CompositionFeatureSchema: z.ZodDiscriminatedUnion<[z.ZodObj
316
470
  }, z.core.$strip>, z.ZodObject<{
317
471
  kind: z.ZodLiteral<"code">;
318
472
  code: z.ZodString;
473
+ }, z.core.$strip>, z.ZodObject<{
474
+ kind: z.ZodLiteral<"aggregate">;
475
+ reducer: z.ZodEnum<{
476
+ all: "all";
477
+ any: "any";
478
+ max: "max";
479
+ mean: "mean";
480
+ median: "median";
481
+ min: "min";
482
+ sum: "sum";
483
+ }>;
484
+ reads: z.ZodArray<z.ZodObject<{
485
+ source: z.ZodObject<{
486
+ addonId: z.ZodString;
487
+ stableId: z.ZodString;
488
+ }, z.core.$strip>;
489
+ cap: z.ZodString;
490
+ fieldPath: z.ZodString;
491
+ }, z.core.$strip>>;
492
+ publish: z.ZodEnum<{
493
+ excluded: "excluded";
494
+ included: "included";
495
+ total: "total";
496
+ value: "value";
497
+ }>;
498
+ empty: z.ZodEnum<{
499
+ null: "null";
500
+ offline: "offline";
501
+ omit: "omit";
502
+ }>;
319
503
  }, z.core.$strip>], "kind">>;
320
504
  items: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
321
505
  label: z.ZodString;
@@ -345,6 +529,36 @@ export declare const CompositionFeatureSchema: z.ZodDiscriminatedUnion<[z.ZodObj
345
529
  }, z.core.$strip>, z.ZodObject<{
346
530
  kind: z.ZodLiteral<"code">;
347
531
  code: z.ZodString;
532
+ }, z.core.$strip>, z.ZodObject<{
533
+ kind: z.ZodLiteral<"aggregate">;
534
+ reducer: z.ZodEnum<{
535
+ all: "all";
536
+ any: "any";
537
+ max: "max";
538
+ mean: "mean";
539
+ median: "median";
540
+ min: "min";
541
+ sum: "sum";
542
+ }>;
543
+ reads: z.ZodArray<z.ZodObject<{
544
+ source: z.ZodObject<{
545
+ addonId: z.ZodString;
546
+ stableId: z.ZodString;
547
+ }, z.core.$strip>;
548
+ cap: z.ZodString;
549
+ fieldPath: z.ZodString;
550
+ }, z.core.$strip>>;
551
+ publish: z.ZodEnum<{
552
+ excluded: "excluded";
553
+ included: "included";
554
+ total: "total";
555
+ value: "value";
556
+ }>;
557
+ empty: z.ZodEnum<{
558
+ null: "null";
559
+ offline: "offline";
560
+ omit: "omit";
561
+ }>;
348
562
  }, z.core.$strip>], "kind">>;
349
563
  }, z.core.$strip>>>;
350
564
  commands: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -444,6 +658,36 @@ export declare const CompositionSchema: z.ZodObject<{
444
658
  }, z.core.$strip>, z.ZodObject<{
445
659
  kind: z.ZodLiteral<"code">;
446
660
  code: z.ZodString;
661
+ }, z.core.$strip>, z.ZodObject<{
662
+ kind: z.ZodLiteral<"aggregate">;
663
+ reducer: z.ZodEnum<{
664
+ all: "all";
665
+ any: "any";
666
+ max: "max";
667
+ mean: "mean";
668
+ median: "median";
669
+ min: "min";
670
+ sum: "sum";
671
+ }>;
672
+ reads: z.ZodArray<z.ZodObject<{
673
+ source: z.ZodObject<{
674
+ addonId: z.ZodString;
675
+ stableId: z.ZodString;
676
+ }, z.core.$strip>;
677
+ cap: z.ZodString;
678
+ fieldPath: z.ZodString;
679
+ }, z.core.$strip>>;
680
+ publish: z.ZodEnum<{
681
+ excluded: "excluded";
682
+ included: "included";
683
+ total: "total";
684
+ value: "value";
685
+ }>;
686
+ empty: z.ZodEnum<{
687
+ null: "null";
688
+ offline: "offline";
689
+ omit: "omit";
690
+ }>;
447
691
  }, z.core.$strip>], "kind">>;
448
692
  items: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
449
693
  label: z.ZodString;
@@ -473,6 +717,36 @@ export declare const CompositionSchema: z.ZodObject<{
473
717
  }, z.core.$strip>, z.ZodObject<{
474
718
  kind: z.ZodLiteral<"code">;
475
719
  code: z.ZodString;
720
+ }, z.core.$strip>, z.ZodObject<{
721
+ kind: z.ZodLiteral<"aggregate">;
722
+ reducer: z.ZodEnum<{
723
+ all: "all";
724
+ any: "any";
725
+ max: "max";
726
+ mean: "mean";
727
+ median: "median";
728
+ min: "min";
729
+ sum: "sum";
730
+ }>;
731
+ reads: z.ZodArray<z.ZodObject<{
732
+ source: z.ZodObject<{
733
+ addonId: z.ZodString;
734
+ stableId: z.ZodString;
735
+ }, z.core.$strip>;
736
+ cap: z.ZodString;
737
+ fieldPath: z.ZodString;
738
+ }, z.core.$strip>>;
739
+ publish: z.ZodEnum<{
740
+ excluded: "excluded";
741
+ included: "included";
742
+ total: "total";
743
+ value: "value";
744
+ }>;
745
+ empty: z.ZodEnum<{
746
+ null: "null";
747
+ offline: "offline";
748
+ omit: "omit";
749
+ }>;
476
750
  }, z.core.$strip>], "kind">>;
477
751
  }, z.core.$strip>>>;
478
752
  commands: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -496,6 +770,12 @@ export declare const CompositionSchema: z.ZodObject<{
496
770
  stableId: z.ZodString;
497
771
  }, z.core.$strip>;
498
772
  }, z.core.$strip>], "kind">>;
773
+ helper: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
774
+ kind: z.ZodLiteral<'group'>;
775
+ templateId: typeof import("./index.js").GroupTemplateIdSchema;
776
+ aggregate: typeof import("./index.js").AggregateReducerSchema;
777
+ members: z.ZodArray<typeof import("./index.js").HelperMemberSchema>;
778
+ }, z.core.$strip>], "kind">>;
499
779
  }, z.core.$strip>;
500
780
  export type Composition = z.infer<typeof CompositionSchema>;
501
781
  export declare function compositionSourceKey(ref: CompositionSourceRef): string;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * A group reducer (D944). Offline and unknown members are excluded and
3
+ * counted. They are never passed in as 0 or false (D393). A free expression
4
+ * does not use this — `avg` / `any` still include a stale value.
5
+ */
6
+ import type { ExpressionValue } from '../../expression/ast.js';
7
+ import type { AggregateReducer } from './spec.js';
8
+ export interface AggregateReadResult {
9
+ readonly state: 'fresh' | 'stale' | 'unavailable';
10
+ readonly value?: ExpressionValue;
11
+ /** Set when `state` is `unavailable` and the source is gone. */
12
+ readonly fatal?: boolean;
13
+ readonly reason?: string;
14
+ }
15
+ export interface AggregateCounts {
16
+ readonly included: number;
17
+ readonly excluded: number;
18
+ readonly total: number;
19
+ }
20
+ export type AggregatePublish = 'value' | 'included' | 'excluded' | 'total';
21
+ export type AggregateEmpty = 'null' | 'omit' | 'offline';
22
+ export interface EvaluateAggregateInput {
23
+ readonly reducer: AggregateReducer;
24
+ readonly members: readonly AggregateReadResult[];
25
+ readonly publish: AggregatePublish;
26
+ readonly empty: AggregateEmpty;
27
+ }
28
+ export interface AggregateValue {
29
+ readonly kind: 'value';
30
+ readonly value: number | boolean | null;
31
+ readonly counts: AggregateCounts;
32
+ }
33
+ export interface AggregateUnavailable {
34
+ readonly kind: 'unavailable';
35
+ readonly fatal: boolean;
36
+ readonly reason: string;
37
+ readonly counts: AggregateCounts;
38
+ }
39
+ export type AggregateOutcome = AggregateValue | AggregateUnavailable;
40
+ /** Pure. `members` is not mutated. An empty included set is null or unavailable, never 0 or false. */
41
+ export declare function evaluateAggregate(input: EvaluateAggregateInput): AggregateOutcome;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * One catalog row per base reading a group helper can build (D944 §3).
3
+ * Data, not a form default written into the block.
4
+ */
5
+ import { DeviceRole, DeviceType } from '../../device/device-type.js';
6
+ import { type ReadingQuantity } from '../../units/quantity.js';
7
+ import type { AggregateEmpty } from './aggregate.js';
8
+ import { type AggregateReducer, type GroupTemplateId } from './spec.js';
9
+ export interface HelperAccept {
10
+ readonly cap: string;
11
+ readonly fieldPath: string;
12
+ }
13
+ export interface HelperCompanion {
14
+ readonly fieldPath: string;
15
+ readonly expr: string;
16
+ }
17
+ export interface GroupTemplate {
18
+ readonly id: GroupTemplateId;
19
+ readonly family: 'numeric' | 'binary';
20
+ readonly summary: string;
21
+ readonly deviceType: DeviceType;
22
+ readonly role: DeviceRole;
23
+ /** Members are this one device type. */
24
+ readonly memberDeviceType: DeviceType;
25
+ readonly outputCap: string;
26
+ readonly outputField: string;
27
+ /** Quantity of the output reading. `device` is chosen per numeric sensor. */
28
+ readonly quantity: ReadingQuantity;
29
+ readonly baseUnit: string | undefined;
30
+ readonly aggregates: readonly AggregateReducer[];
31
+ readonly defaultAggregate: AggregateReducer;
32
+ /**
33
+ * No included member: `null` writes null and stays online; `omit` leaves an
34
+ * optional key out and stays online; `offline` takes the device offline
35
+ * rather than publishing false (D393).
36
+ */
37
+ readonly empty: AggregateEmpty;
38
+ readonly accept: readonly HelperAccept[];
39
+ readonly companions: readonly HelperCompanion[];
40
+ }
41
+ export declare const GROUP_TEMPLATES: readonly GroupTemplate[];
42
+ export declare function groupTemplate(id: GroupTemplateId): GroupTemplate | null;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Project a helper spec onto the composition the composer already runs (D944).
3
+ * Pure: it stores nothing. A group does not compile to `avg(...)` / `any(...)`.
4
+ */
5
+ import { DeviceType } from '../../device/device-type.js';
6
+ import { type Composition } from '../composition.js';
7
+ import type { CompositionProblem } from '../composition-report.js';
8
+ import { type HelperSpec } from './spec.js';
9
+ export interface HelperCompiled {
10
+ readonly ok: true;
11
+ readonly composition: Composition;
12
+ }
13
+ export interface HelperRefused {
14
+ readonly ok: false;
15
+ readonly problems: readonly CompositionProblem[];
16
+ }
17
+ export type HelperCompileResult = HelperCompiled | HelperRefused;
18
+ /** Compile a group template to a new-device composition. Refusals are named. */
19
+ export declare function compileHelper(spec: HelperSpec): HelperCompileResult;
20
+ /** The built body, ignoring `helper`, so a save can demand one writer. */
21
+ export declare function sameHelperBody(stored: Composition, compiled: Composition): boolean;
22
+ export declare function templateDeviceType(spec: HelperSpec): DeviceType | null;
@@ -0,0 +1,6 @@
1
+ export { type AggregateCounts, type AggregateEmpty, type AggregateOutcome, type AggregatePublish, type AggregateReadResult, type AggregateUnavailable, type AggregateValue, type EvaluateAggregateInput, evaluateAggregate, } from './aggregate.js';
2
+ export { type GroupTemplate, type HelperAccept, type HelperCompanion, GROUP_TEMPLATES, groupTemplate, } from './catalog.js';
3
+ export { type HelperCompileResult, type HelperCompiled, type HelperRefused, compileHelper, sameHelperBody, templateDeviceType, } from './compile.js';
4
+ export { type HelperMemberFact, helperSaveProblems, } from './save.js';
5
+ export { type SourcePick, type SourcePickAccept, type SourcePickHistory, type SourcePickRequest, sourcePickForTemplate, } from './source-pick.js';
6
+ export { AGGREGATE_REDUCERS, AggregateReducerSchema, BINARY_AGGREGATES, GROUP_TEMPLATE_IDS, GroupHelperSpecSchema, GroupTemplateIdSchema, HelperMemberSchema, HelperSpecSchema, MAX_HELPER_MEMBERS, NUMERIC_AGGREGATES, type AggregateReducer, type BinaryAggregate, type GroupHelperSpec, type GroupTemplateId, type HelperMember, type HelperSpec, type NumericAggregate, } from './spec.js';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Save-time checks a pure compile cannot make: the compiled features must be
3
+ * this spec's, and members that report a quantity must share one (D944 §4).
4
+ */
5
+ import type { DeviceType } from '../../device/device-type.js';
6
+ import type { ReadingQuantity } from '../../units/quantity.js';
7
+ import { type Composition } from '../composition.js';
8
+ import type { CompositionProblem } from '../composition-report.js';
9
+ /** What a save learned about one member device. Absent keys were not read. */
10
+ export interface HelperMemberFact {
11
+ readonly deviceType?: DeviceType;
12
+ readonly quantity?: ReadingQuantity;
13
+ }
14
+ /**
15
+ * Problems that refuse a save. No `helper` key means a free composition: this
16
+ * returns nothing, and expression semantics stay as they are.
17
+ */
18
+ export declare function helperSaveProblems(composition: Composition, facts: ReadonlyMap<string, HelperMemberFact>): readonly CompositionProblem[];