@camstack/types 1.1.19 → 1.1.21

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 (36) hide show
  1. package/dist/addon.js +1 -1
  2. package/dist/addon.mjs +1 -1
  3. package/dist/capabilities/battery.cap.d.ts +6 -0
  4. package/dist/capabilities/capability-definition.d.ts +39 -0
  5. package/dist/capabilities/consumables.cap.d.ts +35 -0
  6. package/dist/capabilities/device-manager.cap.d.ts +396 -15
  7. package/dist/capabilities/index.d.ts +1 -1
  8. package/dist/capabilities/pipeline-orchestrator.cap.d.ts +7 -3
  9. package/dist/device/device-binding.d.ts +9 -3
  10. package/dist/device/device-management.d.ts +87 -6
  11. package/dist/device/index.d.ts +2 -2
  12. package/dist/device/schema-fields.d.ts +13 -0
  13. package/dist/expression/ast.d.ts +56 -0
  14. package/dist/expression/builtins.d.ts +19 -0
  15. package/dist/expression/compile.d.ts +17 -0
  16. package/dist/expression/errors.d.ts +16 -0
  17. package/dist/expression/evaluator.d.ts +14 -0
  18. package/dist/expression/index.d.ts +25 -0
  19. package/dist/expression/limits.d.ts +30 -0
  20. package/dist/expression/link-expression.d.ts +44 -0
  21. package/dist/expression/parser.d.ts +12 -0
  22. package/dist/expression/tokenizer.d.ts +38 -0
  23. package/dist/generated/addon-api.d.ts +452 -4
  24. package/dist/generated/device-proxy.d.ts +1 -1
  25. package/dist/generated/method-access-map.d.ts +1 -1
  26. package/dist/generated/system-proxy.d.ts +1 -1
  27. package/dist/index.d.ts +5 -2
  28. package/dist/index.js +1342 -20
  29. package/dist/index.mjs +1313 -21
  30. package/dist/interfaces/agent.d.ts +21 -0
  31. package/dist/{sleep-MHm--th-.mjs → sleep-BO1nweKv.mjs} +1 -0
  32. package/dist/{sleep-BabrCASa.js → sleep-DaQgDq90.js} +1 -0
  33. package/dist/units/convert.d.ts +49 -0
  34. package/dist/units/index.d.ts +8 -0
  35. package/dist/units/unit-table.d.ts +270 -0
  36. package/package.json +1 -1
@@ -96,6 +96,13 @@ export interface HubHealthAgentCounts {
96
96
  readonly total: number;
97
97
  readonly online: number;
98
98
  readonly offline: number;
99
+ /**
100
+ * Node ids of the offline agents. Optional (added later) — consumers
101
+ * must tolerate absence on older hubs. Lets health surfaces name the
102
+ * degraded node ("node little-unraid not responding") instead of
103
+ * only counting it.
104
+ */
105
+ readonly offlineIds?: readonly string[];
99
106
  }
100
107
  /** Aggregate cluster health, returned by `GET /health/cluster`. */
101
108
  export interface ClusterHealth {
@@ -145,3 +152,17 @@ export interface AgentListItem {
145
152
  /** Local IP addresses visible on the network */
146
153
  readonly localIps?: readonly string[];
147
154
  }
155
+ /**
156
+ * Fan-out-free node liveness row for the `/health` surface, read from the
157
+ * hub's in-memory Moleculer node registry (`broker.registry.getNodeList`)
158
+ * — never a per-node RPC. `isOnline` is Moleculer's own availability
159
+ * verdict (`node.available`); a node that disconnected cleanly (or missed
160
+ * heartbeats) stays listed as offline until Moleculer purges it
161
+ * (~cleanOfflineNodesTimeout), which is what lets `/health` NAME the
162
+ * degraded node in `agents.offlineIds`.
163
+ */
164
+ export interface NodeLiveness {
165
+ readonly id: string;
166
+ readonly isHub: boolean;
167
+ readonly isOnline: boolean;
168
+ }
@@ -3280,6 +3280,7 @@ function createDeviceProxy(api, binding, opts) {
3280
3280
  setPrimaryChildEntityId: (input) => dispatchSystem("deviceManager", "setPrimaryChildEntityId", "mutation", input),
3281
3281
  setChildLayout: (input) => dispatchSystem("deviceManager", "setChildLayout", "mutation", input),
3282
3282
  setDeviceLinks: (input) => dispatchSystem("deviceManager", "setDeviceLinks", "mutation", input),
3283
+ setDisplay: (input) => dispatchSystem("deviceManager", "setDisplay", "mutation", input),
3283
3284
  getWireableFields: (input) => dispatchSystem("deviceManager", "getWireableFields", "query", input),
3284
3285
  setRole: (input) => dispatchSystem("deviceManager", "setRole", "mutation", input),
3285
3286
  applyInitialMeta: (input) => dispatchSystem("deviceManager", "applyInitialMeta", "mutation", input),
@@ -3280,6 +3280,7 @@ function createDeviceProxy(api, binding, opts) {
3280
3280
  setPrimaryChildEntityId: (input) => dispatchSystem("deviceManager", "setPrimaryChildEntityId", "mutation", input),
3281
3281
  setChildLayout: (input) => dispatchSystem("deviceManager", "setChildLayout", "mutation", input),
3282
3282
  setDeviceLinks: (input) => dispatchSystem("deviceManager", "setDeviceLinks", "mutation", input),
3283
+ setDisplay: (input) => dispatchSystem("deviceManager", "setDisplay", "mutation", input),
3283
3284
  getWireableFields: (input) => dispatchSystem("deviceManager", "getWireableFields", "query", input),
3284
3285
  setRole: (input) => dispatchSystem("deviceManager", "setRole", "mutation", input),
3285
3286
  applyInitialMeta: (input) => dispatchSystem("deviceManager", "applyInitialMeta", "mutation", input),
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Pure unit-conversion API over `UNIT_TABLE`. No dependencies, no side effects.
3
+ *
4
+ * Conversion is refused (throws `UnitConversionError`, or returns `undefined`
5
+ * from the `try*` variant) whenever a unit is unknown or the two units belong
6
+ * to different dimensions — cross-dimension conversion is deliberately
7
+ * impossible so a render override can never make the value and its unit label
8
+ * disagree.
9
+ *
10
+ * Callers pass units through `normalizeUnit` (`../device/source-info.ts`) BEFORE
11
+ * calling here — the table keys only canonical spellings.
12
+ */
13
+ import { type UnitDimension } from './unit-table.js';
14
+ /** Why a conversion could not be performed. */
15
+ export type UnitConversionReason = 'unknown-from' | 'unknown-to' | 'cross-dimension';
16
+ /** Thrown by `convertUnit` when a conversion is refused. Carries the offending
17
+ * units + a machine-readable `reason` for callers that branch on the cause. */
18
+ export declare class UnitConversionError extends Error {
19
+ readonly from: string;
20
+ readonly to: string;
21
+ readonly reason: UnitConversionReason;
22
+ constructor(from: string, to: string, reason: UnitConversionReason);
23
+ }
24
+ /** The dimension a unit belongs to, or `undefined` for an unknown unit. */
25
+ export declare function unitDimension(unit: string): UnitDimension | undefined;
26
+ /**
27
+ * Convert `value` from unit `from` to unit `to`. Identity when `from === to`.
28
+ * Throws `UnitConversionError` when either unit is unknown or the units belong
29
+ * to different dimensions.
30
+ */
31
+ export declare function convertUnit(value: number, from: string, to: string): number;
32
+ /**
33
+ * Graceful variant for the render path: returns the converted value, or
34
+ * `undefined` when the conversion is refused (unknown unit / cross-dimension).
35
+ * Never throws — a render caller falls back to the raw value + source unit.
36
+ */
37
+ export declare function tryConvertUnit(value: number, from: string, to: string): number | undefined;
38
+ /**
39
+ * Whether `value` can be converted between `from` and `to` (same dimension,
40
+ * both known). Cheap boolean probe for the UI's same-dimension unit picker and
41
+ * the resolver's convertibility branch — compute ONCE so a unit label and its
42
+ * value math can never disagree.
43
+ */
44
+ export declare function canConvertUnit(from: string, to: string): boolean;
45
+ /**
46
+ * Every known unit spelling in a dimension (table insertion order — canonical
47
+ * unit first). Powers the UI's same-dimension unit picker.
48
+ */
49
+ export declare function unitsForDimension(dimension: UnitDimension): readonly string[];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Pure unit-conversion module. Re-exported from the types barrel so both the
3
+ * render path and the future expression engine share one table.
4
+ */
5
+ export { UNIT_TABLE } from './unit-table.js';
6
+ export type { UnitDimension, UnitSpec, KnownUnit } from './unit-table.js';
7
+ export { UnitConversionError, unitDimension, convertUnit, tryConvertUnit, canConvertUnit, unitsForDimension, } from './convert.js';
8
+ export type { UnitConversionReason } from './convert.js';
@@ -0,0 +1,270 @@
1
+ /**
2
+ * Unit-of-measurement conversion table — the single source of truth shared by
3
+ * the render path (`resolveSensorDisplay` in `@camstack/ui-library`) and the
4
+ * future Stage-X expression engine's `convert()` builtin.
5
+ *
6
+ * Every unit maps to a `UnitSpec` describing the LINEAR transform to its
7
+ * dimension's canonical unit:
8
+ *
9
+ * canonical = value * factor + offset
10
+ *
11
+ * `offset` is non-zero ONLY for the temperature family (°F / K carry an
12
+ * additive term); every other dimension is a pure scale (`offset = 0`).
13
+ * Cross-dimension conversion is intentionally impossible: a lookup returns the
14
+ * unit's `dimension`, and `convertUnit` refuses any pair whose dimensions
15
+ * differ (see `convert.ts`).
16
+ *
17
+ * Keys are the CANONICAL spellings `normalizeUnit` (`../device/source-info.ts`)
18
+ * produces — callers pass a raw unit through `normalizeUnit` BEFORE lookup.
19
+ * Unknown spellings resolve to `undefined` and cause conversion to be refused
20
+ * (the render path falls back to the raw value + source unit — never silently
21
+ * wrong). Single-unit dimensions (illuminance, irradiance, percentage, …) exist
22
+ * so a same-unit identity conversion is well-defined while cross-family
23
+ * conversion stays refused.
24
+ */
25
+ /** The physical dimensions CamStack surfaces across HA + Ecowitt + vendors. */
26
+ export type UnitDimension = 'temperature' | 'pressure' | 'speed' | 'precipitation-rate' | 'length' | 'illuminance' | 'irradiance' | 'power' | 'apparent-power' | 'energy' | 'voltage' | 'current' | 'concentration-volume' | 'concentration-mass' | 'mass' | 'percentage';
27
+ /**
28
+ * Linear conversion spec: `canonical = value * factor + offset`. Temperature is
29
+ * the ONLY family using a non-zero `offset`.
30
+ */
31
+ export interface UnitSpec {
32
+ readonly dimension: UnitDimension;
33
+ readonly factor: number;
34
+ readonly offset: number;
35
+ }
36
+ /**
37
+ * Frozen unit → spec table. `•` in the doc marks each dimension's canonical
38
+ * unit (`factor: 1, offset: 0`). °F derives from `°C = (°F − 32) × 5/9` ⇒
39
+ * `factor = 5/9`, `offset = -160/9` (kept as exact expressions, not rounded
40
+ * decimals). K derives from `°C = K − 273.15`.
41
+ */
42
+ export declare const UNIT_TABLE: {
43
+ readonly '\u00B0C': {
44
+ readonly dimension: "temperature";
45
+ readonly factor: 1;
46
+ readonly offset: 0;
47
+ };
48
+ readonly '\u00B0F': {
49
+ readonly dimension: "temperature";
50
+ readonly factor: number;
51
+ readonly offset: number;
52
+ };
53
+ readonly K: {
54
+ readonly dimension: "temperature";
55
+ readonly factor: 1;
56
+ readonly offset: -273.15;
57
+ };
58
+ readonly hPa: {
59
+ readonly dimension: "pressure";
60
+ readonly factor: 1;
61
+ readonly offset: 0;
62
+ };
63
+ readonly kPa: {
64
+ readonly dimension: "pressure";
65
+ readonly factor: 10;
66
+ readonly offset: 0;
67
+ };
68
+ readonly Pa: {
69
+ readonly dimension: "pressure";
70
+ readonly factor: 0.01;
71
+ readonly offset: 0;
72
+ };
73
+ readonly mbar: {
74
+ readonly dimension: "pressure";
75
+ readonly factor: 1;
76
+ readonly offset: 0;
77
+ };
78
+ readonly bar: {
79
+ readonly dimension: "pressure";
80
+ readonly factor: 1000;
81
+ readonly offset: 0;
82
+ };
83
+ readonly inHg: {
84
+ readonly dimension: "pressure";
85
+ readonly factor: 33.8639;
86
+ readonly offset: 0;
87
+ };
88
+ readonly mmHg: {
89
+ readonly dimension: "pressure";
90
+ readonly factor: 1.33322;
91
+ readonly offset: 0;
92
+ };
93
+ readonly psi: {
94
+ readonly dimension: "pressure";
95
+ readonly factor: 68.9476;
96
+ readonly offset: 0;
97
+ };
98
+ readonly 'm/s': {
99
+ readonly dimension: "speed";
100
+ readonly factor: 1;
101
+ readonly offset: 0;
102
+ };
103
+ readonly 'km/h': {
104
+ readonly dimension: "speed";
105
+ readonly factor: number;
106
+ readonly offset: 0;
107
+ };
108
+ readonly mph: {
109
+ readonly dimension: "speed";
110
+ readonly factor: 0.44704;
111
+ readonly offset: 0;
112
+ };
113
+ readonly kn: {
114
+ readonly dimension: "speed";
115
+ readonly factor: 0.514444;
116
+ readonly offset: 0;
117
+ };
118
+ readonly 'mm/h': {
119
+ readonly dimension: "precipitation-rate";
120
+ readonly factor: 1;
121
+ readonly offset: 0;
122
+ };
123
+ readonly 'in/h': {
124
+ readonly dimension: "precipitation-rate";
125
+ readonly factor: 25.4;
126
+ readonly offset: 0;
127
+ };
128
+ readonly m: {
129
+ readonly dimension: "length";
130
+ readonly factor: 1;
131
+ readonly offset: 0;
132
+ };
133
+ readonly mm: {
134
+ readonly dimension: "length";
135
+ readonly factor: 0.001;
136
+ readonly offset: 0;
137
+ };
138
+ readonly cm: {
139
+ readonly dimension: "length";
140
+ readonly factor: 0.01;
141
+ readonly offset: 0;
142
+ };
143
+ readonly km: {
144
+ readonly dimension: "length";
145
+ readonly factor: 1000;
146
+ readonly offset: 0;
147
+ };
148
+ readonly in: {
149
+ readonly dimension: "length";
150
+ readonly factor: 0.0254;
151
+ readonly offset: 0;
152
+ };
153
+ readonly ft: {
154
+ readonly dimension: "length";
155
+ readonly factor: 0.3048;
156
+ readonly offset: 0;
157
+ };
158
+ readonly mi: {
159
+ readonly dimension: "length";
160
+ readonly factor: 1609.344;
161
+ readonly offset: 0;
162
+ };
163
+ readonly lx: {
164
+ readonly dimension: "illuminance";
165
+ readonly factor: 1;
166
+ readonly offset: 0;
167
+ };
168
+ readonly 'W/m\u00B2': {
169
+ readonly dimension: "irradiance";
170
+ readonly factor: 1;
171
+ readonly offset: 0;
172
+ };
173
+ readonly W: {
174
+ readonly dimension: "power";
175
+ readonly factor: 1;
176
+ readonly offset: 0;
177
+ };
178
+ readonly kW: {
179
+ readonly dimension: "power";
180
+ readonly factor: 1000;
181
+ readonly offset: 0;
182
+ };
183
+ readonly VA: {
184
+ readonly dimension: "apparent-power";
185
+ readonly factor: 1;
186
+ readonly offset: 0;
187
+ };
188
+ readonly Wh: {
189
+ readonly dimension: "energy";
190
+ readonly factor: 1;
191
+ readonly offset: 0;
192
+ };
193
+ readonly kWh: {
194
+ readonly dimension: "energy";
195
+ readonly factor: 1000;
196
+ readonly offset: 0;
197
+ };
198
+ readonly MWh: {
199
+ readonly dimension: "energy";
200
+ readonly factor: 1000000;
201
+ readonly offset: 0;
202
+ };
203
+ readonly V: {
204
+ readonly dimension: "voltage";
205
+ readonly factor: 1;
206
+ readonly offset: 0;
207
+ };
208
+ readonly mV: {
209
+ readonly dimension: "voltage";
210
+ readonly factor: 0.001;
211
+ readonly offset: 0;
212
+ };
213
+ readonly A: {
214
+ readonly dimension: "current";
215
+ readonly factor: 1;
216
+ readonly offset: 0;
217
+ };
218
+ readonly mA: {
219
+ readonly dimension: "current";
220
+ readonly factor: 0.001;
221
+ readonly offset: 0;
222
+ };
223
+ readonly ppm: {
224
+ readonly dimension: "concentration-volume";
225
+ readonly factor: 1;
226
+ readonly offset: 0;
227
+ };
228
+ readonly ppb: {
229
+ readonly dimension: "concentration-volume";
230
+ readonly factor: 0.001;
231
+ readonly offset: 0;
232
+ };
233
+ readonly '\u00B5g/m\u00B3': {
234
+ readonly dimension: "concentration-mass";
235
+ readonly factor: 1;
236
+ readonly offset: 0;
237
+ };
238
+ readonly 'mg/m\u00B3': {
239
+ readonly dimension: "concentration-mass";
240
+ readonly factor: 1000;
241
+ readonly offset: 0;
242
+ };
243
+ readonly kg: {
244
+ readonly dimension: "mass";
245
+ readonly factor: 1;
246
+ readonly offset: 0;
247
+ };
248
+ readonly g: {
249
+ readonly dimension: "mass";
250
+ readonly factor: 0.001;
251
+ readonly offset: 0;
252
+ };
253
+ readonly lb: {
254
+ readonly dimension: "mass";
255
+ readonly factor: 0.453592;
256
+ readonly offset: 0;
257
+ };
258
+ readonly oz: {
259
+ readonly dimension: "mass";
260
+ readonly factor: 0.0283495;
261
+ readonly offset: 0;
262
+ };
263
+ readonly '%': {
264
+ readonly dimension: "percentage";
265
+ readonly factor: 1;
266
+ readonly offset: 0;
267
+ };
268
+ };
269
+ /** Union of every canonical unit key present in `UNIT_TABLE`. */
270
+ export type KnownUnit = keyof typeof UNIT_TABLE;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/types",
3
- "version": "1.1.19",
3
+ "version": "1.1.21",
4
4
  "description": "Shared types, interfaces, and model catalogs for the CamStack detection ecosystem",
5
5
  "keywords": [
6
6
  "camstack",