@camstack/types 1.2.417 → 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.
- package/dist/addon.js +1 -1
- package/dist/addon.mjs +1 -1
- package/dist/capabilities/capability-definition.d.ts +5 -0
- package/dist/capabilities/composer.cap.d.ts +198 -0
- package/dist/capabilities/core-blocks.cap.d.ts +1420 -0
- package/dist/capabilities/group-status.cap.d.ts +46 -0
- package/dist/capabilities/index.d.ts +3 -1
- package/dist/capabilities/motion.cap.d.ts +12 -4
- package/dist/client.js +3 -0
- package/dist/client.mjs +3 -0
- package/dist/composition/composition-report.d.ts +72 -0
- package/dist/composition/composition.d.ts +285 -5
- package/dist/composition/helpers/aggregate.d.ts +41 -0
- package/dist/composition/helpers/catalog.d.ts +42 -0
- package/dist/composition/helpers/compile.d.ts +22 -0
- package/dist/composition/helpers/index.d.ts +6 -0
- package/dist/composition/helpers/save.d.ts +18 -0
- package/dist/composition/helpers/source-pick.d.ts +40 -0
- package/dist/composition/helpers/spec.d.ts +38 -0
- package/dist/composition/index.d.ts +1 -0
- package/dist/composition/source-ref.d.ts +11 -0
- package/dist/composition/validate-composition.d.ts +5 -0
- package/dist/{composition-kEl9mevu.mjs → composition-B85l9j1M.mjs} +114 -8
- package/dist/{composition-DsmkwP9-.js → composition-OJKOJJD-.js} +179 -7
- package/dist/device/cap-vocabulary/entries/sensors.d.ts +1 -1
- package/dist/generated/addon-api.d.ts +14 -0
- package/dist/generated/addon-cap-facts.d.ts +1 -1
- package/dist/generated/cap-status-types.d.ts +3 -1
- package/dist/generated/capability-router-map.d.ts +5 -2
- package/dist/generated/device-local-state.d.ts +3 -0
- package/dist/generated/device-proxy.d.ts +3 -0
- package/dist/generated/history-catalog.d.ts +1 -1
- package/dist/generated/method-access-map.d.ts +1 -1
- package/dist/generated/method-device-selectors.d.ts +1 -1
- package/dist/generated/runtime-state-durability.d.ts +1 -1
- package/dist/index.js +706 -12
- package/dist/index.mjs +686 -13
- package/dist/node.js +1 -1
- package/dist/node.mjs +1 -1
- package/dist/{sleep-gtskVoMw.js → sleep-7Gw3GJ4n.js} +18 -0
- package/dist/{sleep-CARd6wZF.mjs → sleep-B81gwQuR.mjs} +18 -0
- package/package.json +1 -1
|
@@ -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
|
|
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[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The request the common source selector (#236) accepts for a helper (D944 §5).
|
|
3
|
+
* The selector's layout is not specified here. Groups ask for one device type
|
|
4
|
+
* and the catalog field; they do not opt into incompatible fields.
|
|
5
|
+
*/
|
|
6
|
+
import type { DeviceType } from '../../device/device-type.js';
|
|
7
|
+
import type { CompositionSourceRef } from '../source-ref.js';
|
|
8
|
+
import type { GroupTemplate } from './catalog.js';
|
|
9
|
+
export interface SourcePickAccept {
|
|
10
|
+
readonly cap: string;
|
|
11
|
+
readonly fieldPath: string;
|
|
12
|
+
readonly valueKind: 'number' | 'boolean';
|
|
13
|
+
}
|
|
14
|
+
export interface SourcePickHistory {
|
|
15
|
+
readonly required: boolean;
|
|
16
|
+
readonly minRetentionMs: number | null;
|
|
17
|
+
}
|
|
18
|
+
export interface SourcePickRequest {
|
|
19
|
+
readonly purpose: 'member' | 'reading' | 'historised';
|
|
20
|
+
readonly multiple: boolean;
|
|
21
|
+
readonly max: number;
|
|
22
|
+
readonly deviceTypes: readonly DeviceType[];
|
|
23
|
+
readonly accept: readonly SourcePickAccept[];
|
|
24
|
+
readonly history: SourcePickHistory;
|
|
25
|
+
readonly mustBindCaps: readonly string[];
|
|
26
|
+
readonly exclude: readonly CompositionSourceRef[];
|
|
27
|
+
}
|
|
28
|
+
export interface SourcePick {
|
|
29
|
+
readonly source: CompositionSourceRef;
|
|
30
|
+
readonly deviceId: number;
|
|
31
|
+
readonly parentName: string | null;
|
|
32
|
+
readonly cap: string;
|
|
33
|
+
readonly fieldPath: string;
|
|
34
|
+
/** Current reading. `null` is unknown, never a stand-in 0. */
|
|
35
|
+
readonly current: number | boolean | string | null;
|
|
36
|
+
readonly compatibility: 'direct' | 'convert' | 'incompatible';
|
|
37
|
+
readonly history: 'recorded' | 'absent' | 'unknown';
|
|
38
|
+
}
|
|
39
|
+
/** What the member step asks the selector for this template. */
|
|
40
|
+
export declare function sourcePickForTemplate(template: GroupTemplate): SourcePickRequest;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A helper spec is what the editor stores and reads back (D944). The compiled
|
|
3
|
+
* features are a projection; the editor never edits the expression.
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { CompositionSourceRefSchema } from '../source-ref.js';
|
|
7
|
+
/** A group may name more members than an expression call (the 16-arg cap). */
|
|
8
|
+
export declare const MAX_HELPER_MEMBERS: number;
|
|
9
|
+
export declare const GROUP_TEMPLATE_IDS: readonly ['temperature', 'humidity', 'pressure', 'illuminance', 'power', 'energy', 'battery', 'numeric', 'motion', 'contact', 'leak', 'smoke', 'occupancy', 'binary'];
|
|
10
|
+
export type GroupTemplateId = (typeof GROUP_TEMPLATE_IDS)[number];
|
|
11
|
+
export declare const NUMERIC_AGGREGATES: readonly ['mean', 'median', 'min', 'max', 'sum'];
|
|
12
|
+
export type NumericAggregate = (typeof NUMERIC_AGGREGATES)[number];
|
|
13
|
+
export declare const BINARY_AGGREGATES: readonly ['any', 'all'];
|
|
14
|
+
export type BinaryAggregate = (typeof BINARY_AGGREGATES)[number];
|
|
15
|
+
export declare const AGGREGATE_REDUCERS: readonly ['mean', 'median', 'min', 'max', 'sum', 'any', 'all'];
|
|
16
|
+
export type AggregateReducer = (typeof AGGREGATE_REDUCERS)[number];
|
|
17
|
+
export declare const GroupTemplateIdSchema: z.ZodType<GroupTemplateId>;
|
|
18
|
+
export declare const AggregateReducerSchema: z.ZodType<AggregateReducer>;
|
|
19
|
+
/** One member. The field is stored so occupancy can name motion or binary. */
|
|
20
|
+
export declare const HelperMemberSchema: z.ZodObject<{
|
|
21
|
+
source: typeof CompositionSourceRefSchema;
|
|
22
|
+
cap: z.ZodString;
|
|
23
|
+
fieldPath: z.ZodString;
|
|
24
|
+
}>;
|
|
25
|
+
export type HelperMember = z.infer<typeof HelperMemberSchema>;
|
|
26
|
+
/**
|
|
27
|
+
* Phase 1a is groups only. Math, integral and statistics stay off this union
|
|
28
|
+
* until the composer can run them — a control must not save a spec it cannot.
|
|
29
|
+
*/
|
|
30
|
+
export declare const GroupHelperSpecSchema: z.ZodObject<{
|
|
31
|
+
kind: z.ZodLiteral<'group'>;
|
|
32
|
+
templateId: typeof GroupTemplateIdSchema;
|
|
33
|
+
aggregate: typeof AggregateReducerSchema;
|
|
34
|
+
members: z.ZodArray<typeof HelperMemberSchema>;
|
|
35
|
+
}>;
|
|
36
|
+
export type GroupHelperSpec = z.infer<typeof GroupHelperSpecSchema>;
|
|
37
|
+
export declare const HelperSpecSchema: z.ZodDiscriminatedUnion<[typeof GroupHelperSpecSchema], 'kind'>;
|
|
38
|
+
export type HelperSpec = z.infer<typeof HelperSpecSchema>;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* inside @camstack/types import the deep modules, never this file.
|
|
4
4
|
*/
|
|
5
5
|
export * from './composable-caps.js';
|
|
6
|
+
export * from './helpers/index.js';
|
|
6
7
|
export * from './composition.js';
|
|
7
8
|
export * from './composition-events.js';
|
|
8
9
|
export * from './composition-graph.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A composition source identity: `(addonId, stableId)`, never a numeric device
|
|
3
|
+
* id. Split out so helper schemas can name it without a cycle through
|
|
4
|
+
* `composition.ts` (D659).
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export declare const CompositionSourceRefSchema: z.ZodObject<{
|
|
8
|
+
addonId: z.ZodString;
|
|
9
|
+
stableId: z.ZodString;
|
|
10
|
+
}>;
|
|
11
|
+
export type CompositionSourceRef = z.infer<typeof CompositionSourceRefSchema>;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import type { CapabilityDefinition } from '../capabilities/capability-definition.js';
|
|
12
12
|
import type { DeviceType } from '../device/device-type.js';
|
|
13
|
+
import type { ReadingQuantity } from '../units/quantity.js';
|
|
13
14
|
import { type Composition, type CompositionSourceRef } from './composition.js';
|
|
14
15
|
import { type CompositionPlanResult } from './plan-result.js';
|
|
15
16
|
import { type CompositionPeer } from './composition-graph.js';
|
|
@@ -22,6 +23,10 @@ export interface CompositionSourceFound {
|
|
|
22
23
|
readonly kind: 'found';
|
|
23
24
|
readonly deviceId: number;
|
|
24
25
|
readonly caps: ReadonlySet<string>;
|
|
26
|
+
/** Present when the row was read. A helper group requires this one type. */
|
|
27
|
+
readonly deviceType?: DeviceType;
|
|
28
|
+
/** Present when the device declares one. Mixed quantities are refused. */
|
|
29
|
+
readonly quantity?: ReadingQuantity;
|
|
25
30
|
}
|
|
26
31
|
export interface CompositionSourceAbsent {
|
|
27
32
|
readonly kind: 'absent';
|