@camstack/types 1.1.20 → 1.1.22
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/base-addon.d.ts +30 -4
- package/dist/addon/per-node-store.d.ts +68 -0
- package/dist/addon.js +1 -1
- package/dist/addon.mjs +1 -1
- package/dist/capabilities/camera-streams.cap.d.ts +5 -5
- package/dist/capabilities/decoder.cap.d.ts +2 -0
- package/dist/capabilities/device-manager.cap.d.ts +269 -6
- package/dist/capabilities/index.d.ts +3 -1
- package/dist/capabilities/metrics-provider.cap.d.ts +2 -2
- package/dist/capabilities/motion-detection.cap.d.ts +20 -2
- package/dist/capabilities/pet-feeder.cap.d.ts +185 -0
- package/dist/capabilities/pipeline-executor.cap.d.ts +29 -2
- package/dist/capabilities/pipeline-orchestrator.cap.d.ts +7 -3
- package/dist/capabilities/platform-probe.cap.d.ts +1 -1
- package/dist/capabilities/schemas/streaming-shared.d.ts +2 -2
- package/dist/capabilities/stream-broker.cap.d.ts +1 -1
- package/dist/device/device-management.d.ts +61 -2
- package/dist/device/device-type.d.ts +8 -1
- package/dist/device/index.d.ts +1 -1
- package/dist/expression/ast.d.ts +56 -0
- package/dist/expression/builtins.d.ts +19 -0
- package/dist/expression/compile.d.ts +17 -0
- package/dist/expression/errors.d.ts +16 -0
- package/dist/expression/evaluator.d.ts +14 -0
- package/dist/expression/index.d.ts +25 -0
- package/dist/expression/limits.d.ts +30 -0
- package/dist/expression/link-expression.d.ts +44 -0
- package/dist/expression/parser.d.ts +12 -0
- package/dist/expression/tokenizer.d.ts +38 -0
- package/dist/generated/addon-api.d.ts +616 -12
- 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 +4 -1
- package/dist/generated/method-access-map.d.ts +1 -1
- package/dist/generated/system-proxy.d.ts +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1555 -37
- package/dist/index.mjs +1523 -38
- package/dist/interfaces/addon.d.ts +15 -2
- package/dist/interfaces/agent.d.ts +14 -0
- package/dist/interfaces/config-ui.d.ts +19 -1
- package/dist/interfaces/pipeline-executor-capability.d.ts +10 -0
- package/dist/{sleep-BabrCASa.js → sleep-B8cp-HUn.js} +193 -7
- package/dist/{sleep-MHm--th-.mjs → sleep-BiDFW0E7.mjs} +193 -7
- package/dist/units/convert.d.ts +49 -0
- package/dist/units/index.d.ts +8 -0
- package/dist/units/unit-table.d.ts +270 -0
- package/package.json +1 -1
|
@@ -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;
|