@nebulahome/integration-sdk 0.0.0-stage → 1.0.0
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/CHANGELOG.md +19 -0
- package/FILES.md +657 -0
- package/LICENSE +21 -0
- package/README.md +127 -2
- package/dist/chunks/node-dist.js +7866 -0
- package/dist/chunks/node-index.d.ts +2045 -0
- package/dist/chunks/node-project.js +545 -0
- package/dist/chunks/node-rolldown-runtime.js +24 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +3783 -0
- package/dist/index.d.ts +1427 -0
- package/dist/index.js +53 -0
- package/dist/schemas.d.ts +693 -0
- package/dist/schemas.js +53 -0
- package/dist/testing.d.ts +267 -0
- package/dist/testing.js +251 -0
- package/package.json +76 -3
- package/schemas/account.schema.json +595 -0
- package/schemas/discovery.schema.json +354 -0
- package/schemas/driver.schema.json +118 -0
- package/schemas/manifest.schema.json +556 -0
- package/schemas/profile.schema.json +1415 -0
- package/schemas/setup.schema.json +1166 -0
|
@@ -0,0 +1,2045 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region ../contracts/dist/capabilities.d.ts
|
|
3
|
+
/** Every capability an entity may declare. */
|
|
4
|
+
declare const CAPABILITIES: readonly ["on_off", "level", "color_hs", "color_temp", "cover", "lock", "thermostat", "sensor_numeric", "sensor_binary", "sensor_text", "media_player", "camera", "button", "update", "lawn_mower", "select", "number", "vacuum", "image", "custom"];
|
|
5
|
+
/** The name of a single capability. */
|
|
6
|
+
type CapabilityName = (typeof CAPABILITIES)[number];
|
|
7
|
+
/**
|
|
8
|
+
* The composite state of an entity: one entry per capability it declares.
|
|
9
|
+
*
|
|
10
|
+
* An entity is rarely one capability. A dimmable colour bulb is `on_off` plus `level` plus
|
|
11
|
+
* `color_hs`, and its state carries all three, which is why this is a partial record rather
|
|
12
|
+
* than a discriminated union - a union could only ever describe one of them at a time.
|
|
13
|
+
*/
|
|
14
|
+
declare const capabilityStateSchema: z.ZodObject<{
|
|
15
|
+
on_off: z.ZodOptional<z.ZodObject<{
|
|
16
|
+
isOn: z.ZodBoolean;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
level: z.ZodOptional<z.ZodObject<{
|
|
19
|
+
level: z.ZodNumber;
|
|
20
|
+
}, z.core.$strip>>;
|
|
21
|
+
color_hs: z.ZodOptional<z.ZodObject<{
|
|
22
|
+
hue: z.ZodNumber;
|
|
23
|
+
saturation: z.ZodNumber;
|
|
24
|
+
}, z.core.$strip>>;
|
|
25
|
+
color_temp: z.ZodOptional<z.ZodObject<{
|
|
26
|
+
mireds: z.ZodInt;
|
|
27
|
+
}, z.core.$strip>>;
|
|
28
|
+
cover: z.ZodOptional<z.ZodObject<{
|
|
29
|
+
position: z.ZodNumber;
|
|
30
|
+
tilt: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
motion: z.ZodEnum<{
|
|
32
|
+
opening: "opening";
|
|
33
|
+
closing: "closing";
|
|
34
|
+
stopped: "stopped";
|
|
35
|
+
}>;
|
|
36
|
+
}, z.core.$strip>>;
|
|
37
|
+
lock: z.ZodOptional<z.ZodObject<{
|
|
38
|
+
lockState: z.ZodEnum<{
|
|
39
|
+
locked: "locked";
|
|
40
|
+
unlocked: "unlocked";
|
|
41
|
+
jammed: "jammed";
|
|
42
|
+
}>;
|
|
43
|
+
}, z.core.$strip>>;
|
|
44
|
+
thermostat: z.ZodOptional<z.ZodObject<{
|
|
45
|
+
currentTemperature: z.ZodNumber;
|
|
46
|
+
targetTemperature: z.ZodNumber;
|
|
47
|
+
mode: z.ZodEnum<{
|
|
48
|
+
off: "off";
|
|
49
|
+
heat: "heat";
|
|
50
|
+
cool: "cool";
|
|
51
|
+
auto: "auto";
|
|
52
|
+
fan_only: "fan_only";
|
|
53
|
+
dry: "dry";
|
|
54
|
+
}>;
|
|
55
|
+
action: z.ZodEnum<{
|
|
56
|
+
off: "off";
|
|
57
|
+
idle: "idle";
|
|
58
|
+
heating: "heating";
|
|
59
|
+
cooling: "cooling";
|
|
60
|
+
drying: "drying";
|
|
61
|
+
fan: "fan";
|
|
62
|
+
}>;
|
|
63
|
+
humidity: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
}, z.core.$strip>>;
|
|
65
|
+
sensor_numeric: z.ZodOptional<z.ZodObject<{
|
|
66
|
+
value: z.ZodNumber;
|
|
67
|
+
}, z.core.$strip>>;
|
|
68
|
+
sensor_binary: z.ZodOptional<z.ZodObject<{
|
|
69
|
+
isOn: z.ZodBoolean;
|
|
70
|
+
}, z.core.$strip>>;
|
|
71
|
+
sensor_text: z.ZodOptional<z.ZodObject<{
|
|
72
|
+
value: z.ZodString;
|
|
73
|
+
}, z.core.$strip>>;
|
|
74
|
+
media_player: z.ZodOptional<z.ZodObject<{
|
|
75
|
+
playback: z.ZodEnum<{
|
|
76
|
+
stopped: "stopped";
|
|
77
|
+
idle: "idle";
|
|
78
|
+
playing: "playing";
|
|
79
|
+
paused: "paused";
|
|
80
|
+
buffering: "buffering";
|
|
81
|
+
}>;
|
|
82
|
+
volume: z.ZodNumber;
|
|
83
|
+
isMuted: z.ZodBoolean;
|
|
84
|
+
source: z.ZodOptional<z.ZodString>;
|
|
85
|
+
mediaTitle: z.ZodOptional<z.ZodString>;
|
|
86
|
+
mediaArtist: z.ZodOptional<z.ZodString>;
|
|
87
|
+
mediaDurationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
88
|
+
mediaPositionSeconds: z.ZodOptional<z.ZodNumber>;
|
|
89
|
+
}, z.core.$strip>>;
|
|
90
|
+
camera: z.ZodOptional<z.ZodObject<{
|
|
91
|
+
isStreamAvailable: z.ZodBoolean;
|
|
92
|
+
snapshotPath: z.ZodOptional<z.ZodString>;
|
|
93
|
+
isRecording: z.ZodDefault<z.ZodBoolean>;
|
|
94
|
+
}, z.core.$strip>>;
|
|
95
|
+
button: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
96
|
+
update: z.ZodOptional<z.ZodObject<{
|
|
97
|
+
installedVersion: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
98
|
+
latestVersion: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
99
|
+
isInstalling: z.ZodDefault<z.ZodBoolean>;
|
|
100
|
+
progress: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
101
|
+
}, z.core.$strip>>;
|
|
102
|
+
lawn_mower: z.ZodOptional<z.ZodObject<{
|
|
103
|
+
activity: z.ZodEnum<{
|
|
104
|
+
error: "error";
|
|
105
|
+
idle: "idle";
|
|
106
|
+
paused: "paused";
|
|
107
|
+
mowing: "mowing";
|
|
108
|
+
returning: "returning";
|
|
109
|
+
docked: "docked";
|
|
110
|
+
}>;
|
|
111
|
+
isResumable: z.ZodDefault<z.ZodBoolean>;
|
|
112
|
+
}, z.core.$strip>>;
|
|
113
|
+
select: z.ZodOptional<z.ZodObject<{
|
|
114
|
+
option: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
115
|
+
}, z.core.$strip>>;
|
|
116
|
+
number: z.ZodOptional<z.ZodObject<{
|
|
117
|
+
value: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
118
|
+
}, z.core.$strip>>;
|
|
119
|
+
vacuum: z.ZodOptional<z.ZodObject<{
|
|
120
|
+
activity: z.ZodEnum<{
|
|
121
|
+
error: "error";
|
|
122
|
+
idle: "idle";
|
|
123
|
+
paused: "paused";
|
|
124
|
+
returning: "returning";
|
|
125
|
+
docked: "docked";
|
|
126
|
+
cleaning: "cleaning";
|
|
127
|
+
}>;
|
|
128
|
+
rooms: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
129
|
+
id: z.ZodString;
|
|
130
|
+
name: z.ZodString;
|
|
131
|
+
}, z.core.$strip>>>;
|
|
132
|
+
isResumable: z.ZodDefault<z.ZodBoolean>;
|
|
133
|
+
}, z.core.$strip>>;
|
|
134
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
135
|
+
contentType: z.ZodEnum<{
|
|
136
|
+
"image/svg+xml": "image/svg+xml";
|
|
137
|
+
"image/png": "image/png";
|
|
138
|
+
"image/jpeg": "image/jpeg";
|
|
139
|
+
}>;
|
|
140
|
+
revision: z.ZodString;
|
|
141
|
+
width: z.ZodOptional<z.ZodInt>;
|
|
142
|
+
height: z.ZodOptional<z.ZodInt>;
|
|
143
|
+
}, z.core.$strip>>;
|
|
144
|
+
custom: z.ZodOptional<z.ZodObject<{
|
|
145
|
+
values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
|
|
146
|
+
}, z.core.$strip>>;
|
|
147
|
+
}, z.core.$strip>;
|
|
148
|
+
/** The composite state of an entity, keyed by capability. */
|
|
149
|
+
type CapabilityState = z.output<typeof capabilityStateSchema>;
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region ../contracts/dist/json.d.ts
|
|
152
|
+
/**
|
|
153
|
+
* A JSON object, the shape most `jsonb` columns actually hold.
|
|
154
|
+
*
|
|
155
|
+
* Written as an index signature rather than `Record<string, JsonValue>` because `Record` is a
|
|
156
|
+
* mapped type, which TypeScript resolves eagerly and therefore cannot use in the recursive
|
|
157
|
+
* definition below (TS2456). The index signature is deferred, so it can.
|
|
158
|
+
*/
|
|
159
|
+
type JsonObject = {
|
|
160
|
+
[key: string]: JsonValue;
|
|
161
|
+
};
|
|
162
|
+
/** Any value that survives a JSON round trip unchanged. */
|
|
163
|
+
type JsonValue = string | number | boolean | null | JsonValue[] | JsonObject;
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region ../contracts/dist/entity-id.d.ts
|
|
166
|
+
/** The kinds of thing an entity can be. The domain is the part before the dot. */
|
|
167
|
+
declare const ENTITY_DOMAINS: readonly ["light", "switch", "sensor", "binary_sensor", "cover", "lock", "climate", "media_player", "camera", "button", "update", "lawn_mower", "select", "number", "vacuum", "image", "custom", "alias"];
|
|
168
|
+
/** The kind of thing an entity is. */
|
|
169
|
+
type EntityDomain = (typeof ENTITY_DOMAINS)[number];
|
|
170
|
+
/**
|
|
171
|
+
* Validates an entity identifier and brands the result.
|
|
172
|
+
*
|
|
173
|
+
* The brand means an `EntityId` cannot be produced from a bare string without going through
|
|
174
|
+
* validation. Identifiers reach the database as primary lookups and NATS as subject tokens, so
|
|
175
|
+
* an unvalidated one does not fail where it was created - it fails somewhere else, later.
|
|
176
|
+
*/
|
|
177
|
+
declare const entityIdSchema: z.core.$ZodBranded<z.ZodString, "EntityId", "out">;
|
|
178
|
+
/** A validated `<domain>.<object_id>` identifier. */
|
|
179
|
+
type EntityId = z.output<typeof entityIdSchema>;
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region ../contracts/dist/registration.d.ts
|
|
182
|
+
/**
|
|
183
|
+
* How history should aggregate a numeric entity.
|
|
184
|
+
*
|
|
185
|
+
* `total_increasing` is the one that matters: energy consumed over a day is last minus first,
|
|
186
|
+
* not a sum of averages, and only the integration knows which kind of counter it is reading.
|
|
187
|
+
*/
|
|
188
|
+
declare const ENTITY_STATE_CLASSES: readonly ["measurement", "total", "total_increasing"];
|
|
189
|
+
/** How history should aggregate a numeric entity. */
|
|
190
|
+
type EntityStateClass = (typeof ENTITY_STATE_CLASSES)[number];
|
|
191
|
+
/**
|
|
192
|
+
* What an entity declares it can do, with the device's own limits for each.
|
|
193
|
+
*
|
|
194
|
+
* A partial record rather than a full one: an entity declares the capabilities it has, not every
|
|
195
|
+
* capability that exists. Each capability's parameters are checked against that capability's own
|
|
196
|
+
* schema, because `core` later validates commands against them - `color_temp` without its mired
|
|
197
|
+
* range would be accepted here and then reject every `set_color_temp` for a reason the owner
|
|
198
|
+
* cannot act on.
|
|
199
|
+
*/
|
|
200
|
+
declare const declaredCapabilitiesSchema: z.ZodRecord<z.ZodEnum<{
|
|
201
|
+
number: "number";
|
|
202
|
+
on_off: "on_off";
|
|
203
|
+
level: "level";
|
|
204
|
+
color_hs: "color_hs";
|
|
205
|
+
color_temp: "color_temp";
|
|
206
|
+
cover: "cover";
|
|
207
|
+
lock: "lock";
|
|
208
|
+
thermostat: "thermostat";
|
|
209
|
+
sensor_numeric: "sensor_numeric";
|
|
210
|
+
sensor_binary: "sensor_binary";
|
|
211
|
+
sensor_text: "sensor_text";
|
|
212
|
+
media_player: "media_player";
|
|
213
|
+
camera: "camera";
|
|
214
|
+
button: "button";
|
|
215
|
+
update: "update";
|
|
216
|
+
lawn_mower: "lawn_mower";
|
|
217
|
+
select: "select";
|
|
218
|
+
vacuum: "vacuum";
|
|
219
|
+
image: "image";
|
|
220
|
+
custom: "custom";
|
|
221
|
+
}> & z.core.$partial, z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
222
|
+
/** What an entity declares it can do, with the device's own limits for each. */
|
|
223
|
+
type DeclaredCapabilities = z.output<typeof declaredCapabilitiesSchema>;
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region ../contracts/dist/entity-state.d.ts
|
|
226
|
+
/**
|
|
227
|
+
* What an adapter publishes when a device reports.
|
|
228
|
+
*
|
|
229
|
+
* Deliberately smaller than {@link entityStateSchema}: an adapter reports what it observed, and
|
|
230
|
+
* `core` is the single writer that decides `lastChanged`, resolves the context and persists the
|
|
231
|
+
* result. An adapter that could set `lastChanged` itself would be a second writer of the
|
|
232
|
+
* registry's most load-bearing field.
|
|
233
|
+
*/
|
|
234
|
+
declare const stateReportSchema: z.ZodObject<{
|
|
235
|
+
entityId: z.core.$ZodBranded<z.ZodString, "EntityId", "out">;
|
|
236
|
+
state: z.ZodObject<{
|
|
237
|
+
on_off: z.ZodOptional<z.ZodObject<{
|
|
238
|
+
isOn: z.ZodBoolean;
|
|
239
|
+
}, z.core.$strip>>;
|
|
240
|
+
level: z.ZodOptional<z.ZodObject<{
|
|
241
|
+
level: z.ZodNumber;
|
|
242
|
+
}, z.core.$strip>>;
|
|
243
|
+
color_hs: z.ZodOptional<z.ZodObject<{
|
|
244
|
+
hue: z.ZodNumber;
|
|
245
|
+
saturation: z.ZodNumber;
|
|
246
|
+
}, z.core.$strip>>;
|
|
247
|
+
color_temp: z.ZodOptional<z.ZodObject<{
|
|
248
|
+
mireds: z.ZodInt;
|
|
249
|
+
}, z.core.$strip>>;
|
|
250
|
+
cover: z.ZodOptional<z.ZodObject<{
|
|
251
|
+
position: z.ZodNumber;
|
|
252
|
+
tilt: z.ZodOptional<z.ZodNumber>;
|
|
253
|
+
motion: z.ZodEnum<{
|
|
254
|
+
opening: "opening";
|
|
255
|
+
closing: "closing";
|
|
256
|
+
stopped: "stopped";
|
|
257
|
+
}>;
|
|
258
|
+
}, z.core.$strip>>;
|
|
259
|
+
lock: z.ZodOptional<z.ZodObject<{
|
|
260
|
+
lockState: z.ZodEnum<{
|
|
261
|
+
locked: "locked";
|
|
262
|
+
unlocked: "unlocked";
|
|
263
|
+
jammed: "jammed";
|
|
264
|
+
}>;
|
|
265
|
+
}, z.core.$strip>>;
|
|
266
|
+
thermostat: z.ZodOptional<z.ZodObject<{
|
|
267
|
+
currentTemperature: z.ZodNumber;
|
|
268
|
+
targetTemperature: z.ZodNumber;
|
|
269
|
+
mode: z.ZodEnum<{
|
|
270
|
+
off: "off";
|
|
271
|
+
heat: "heat";
|
|
272
|
+
cool: "cool";
|
|
273
|
+
auto: "auto";
|
|
274
|
+
fan_only: "fan_only";
|
|
275
|
+
dry: "dry";
|
|
276
|
+
}>;
|
|
277
|
+
action: z.ZodEnum<{
|
|
278
|
+
off: "off";
|
|
279
|
+
idle: "idle";
|
|
280
|
+
heating: "heating";
|
|
281
|
+
cooling: "cooling";
|
|
282
|
+
drying: "drying";
|
|
283
|
+
fan: "fan";
|
|
284
|
+
}>;
|
|
285
|
+
humidity: z.ZodOptional<z.ZodNumber>;
|
|
286
|
+
}, z.core.$strip>>;
|
|
287
|
+
sensor_numeric: z.ZodOptional<z.ZodObject<{
|
|
288
|
+
value: z.ZodNumber;
|
|
289
|
+
}, z.core.$strip>>;
|
|
290
|
+
sensor_binary: z.ZodOptional<z.ZodObject<{
|
|
291
|
+
isOn: z.ZodBoolean;
|
|
292
|
+
}, z.core.$strip>>;
|
|
293
|
+
sensor_text: z.ZodOptional<z.ZodObject<{
|
|
294
|
+
value: z.ZodString;
|
|
295
|
+
}, z.core.$strip>>;
|
|
296
|
+
media_player: z.ZodOptional<z.ZodObject<{
|
|
297
|
+
playback: z.ZodEnum<{
|
|
298
|
+
stopped: "stopped";
|
|
299
|
+
idle: "idle";
|
|
300
|
+
playing: "playing";
|
|
301
|
+
paused: "paused";
|
|
302
|
+
buffering: "buffering";
|
|
303
|
+
}>;
|
|
304
|
+
volume: z.ZodNumber;
|
|
305
|
+
isMuted: z.ZodBoolean;
|
|
306
|
+
source: z.ZodOptional<z.ZodString>;
|
|
307
|
+
mediaTitle: z.ZodOptional<z.ZodString>;
|
|
308
|
+
mediaArtist: z.ZodOptional<z.ZodString>;
|
|
309
|
+
mediaDurationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
310
|
+
mediaPositionSeconds: z.ZodOptional<z.ZodNumber>;
|
|
311
|
+
}, z.core.$strip>>;
|
|
312
|
+
camera: z.ZodOptional<z.ZodObject<{
|
|
313
|
+
isStreamAvailable: z.ZodBoolean;
|
|
314
|
+
snapshotPath: z.ZodOptional<z.ZodString>;
|
|
315
|
+
isRecording: z.ZodDefault<z.ZodBoolean>;
|
|
316
|
+
}, z.core.$strip>>;
|
|
317
|
+
button: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
318
|
+
update: z.ZodOptional<z.ZodObject<{
|
|
319
|
+
installedVersion: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
320
|
+
latestVersion: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
321
|
+
isInstalling: z.ZodDefault<z.ZodBoolean>;
|
|
322
|
+
progress: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
323
|
+
}, z.core.$strip>>;
|
|
324
|
+
lawn_mower: z.ZodOptional<z.ZodObject<{
|
|
325
|
+
activity: z.ZodEnum<{
|
|
326
|
+
error: "error";
|
|
327
|
+
idle: "idle";
|
|
328
|
+
paused: "paused";
|
|
329
|
+
mowing: "mowing";
|
|
330
|
+
returning: "returning";
|
|
331
|
+
docked: "docked";
|
|
332
|
+
}>;
|
|
333
|
+
isResumable: z.ZodDefault<z.ZodBoolean>;
|
|
334
|
+
}, z.core.$strip>>;
|
|
335
|
+
select: z.ZodOptional<z.ZodObject<{
|
|
336
|
+
option: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
337
|
+
}, z.core.$strip>>;
|
|
338
|
+
number: z.ZodOptional<z.ZodObject<{
|
|
339
|
+
value: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
340
|
+
}, z.core.$strip>>;
|
|
341
|
+
vacuum: z.ZodOptional<z.ZodObject<{
|
|
342
|
+
activity: z.ZodEnum<{
|
|
343
|
+
error: "error";
|
|
344
|
+
idle: "idle";
|
|
345
|
+
paused: "paused";
|
|
346
|
+
returning: "returning";
|
|
347
|
+
docked: "docked";
|
|
348
|
+
cleaning: "cleaning";
|
|
349
|
+
}>;
|
|
350
|
+
rooms: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
351
|
+
id: z.ZodString;
|
|
352
|
+
name: z.ZodString;
|
|
353
|
+
}, z.core.$strip>>>;
|
|
354
|
+
isResumable: z.ZodDefault<z.ZodBoolean>;
|
|
355
|
+
}, z.core.$strip>>;
|
|
356
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
357
|
+
contentType: z.ZodEnum<{
|
|
358
|
+
"image/svg+xml": "image/svg+xml";
|
|
359
|
+
"image/png": "image/png";
|
|
360
|
+
"image/jpeg": "image/jpeg";
|
|
361
|
+
}>;
|
|
362
|
+
revision: z.ZodString;
|
|
363
|
+
width: z.ZodOptional<z.ZodInt>;
|
|
364
|
+
height: z.ZodOptional<z.ZodInt>;
|
|
365
|
+
}, z.core.$strip>>;
|
|
366
|
+
custom: z.ZodOptional<z.ZodObject<{
|
|
367
|
+
values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
|
|
368
|
+
}, z.core.$strip>>;
|
|
369
|
+
}, z.core.$strip>;
|
|
370
|
+
attributes: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
371
|
+
isAvailable: z.ZodOptional<z.ZodBoolean>;
|
|
372
|
+
observedAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>]>>;
|
|
373
|
+
}, z.core.$strip>;
|
|
374
|
+
/** What an adapter publishes when a device reports. */
|
|
375
|
+
type StateReport = z.output<typeof stateReportSchema>;
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region ../contracts/dist/integration-setup.d.ts
|
|
378
|
+
/** Validates one field of a group. */
|
|
379
|
+
declare const setupFieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
380
|
+
type: z.ZodLiteral<"text">;
|
|
381
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
382
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
383
|
+
patternMessage: z.ZodOptional<z.ZodString>;
|
|
384
|
+
minLength: z.ZodOptional<z.ZodInt>;
|
|
385
|
+
maxLength: z.ZodDefault<z.ZodInt>;
|
|
386
|
+
default: z.ZodOptional<z.ZodString>;
|
|
387
|
+
key: z.ZodString;
|
|
388
|
+
label: z.ZodString;
|
|
389
|
+
help: z.ZodOptional<z.ZodString>;
|
|
390
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
391
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
392
|
+
key: z.ZodString;
|
|
393
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
394
|
+
}, z.core.$strict>>;
|
|
395
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
396
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
397
|
+
type: z.ZodLiteral<"secret">;
|
|
398
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
399
|
+
patternMessage: z.ZodOptional<z.ZodString>;
|
|
400
|
+
minLength: z.ZodOptional<z.ZodInt>;
|
|
401
|
+
maxLength: z.ZodDefault<z.ZodInt>;
|
|
402
|
+
key: z.ZodString;
|
|
403
|
+
label: z.ZodString;
|
|
404
|
+
help: z.ZodOptional<z.ZodString>;
|
|
405
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
406
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
407
|
+
key: z.ZodString;
|
|
408
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
409
|
+
}, z.core.$strict>>;
|
|
410
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
411
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
412
|
+
type: z.ZodLiteral<"number">;
|
|
413
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
414
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
415
|
+
isInteger: z.ZodDefault<z.ZodBoolean>;
|
|
416
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
417
|
+
default: z.ZodOptional<z.ZodNumber>;
|
|
418
|
+
warnBelow: z.ZodOptional<z.ZodNumber>;
|
|
419
|
+
warning: z.ZodOptional<z.ZodString>;
|
|
420
|
+
key: z.ZodString;
|
|
421
|
+
label: z.ZodString;
|
|
422
|
+
help: z.ZodOptional<z.ZodString>;
|
|
423
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
424
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
425
|
+
key: z.ZodString;
|
|
426
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
427
|
+
}, z.core.$strict>>;
|
|
428
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
429
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
430
|
+
type: z.ZodLiteral<"boolean">;
|
|
431
|
+
default: z.ZodOptional<z.ZodBoolean>;
|
|
432
|
+
key: z.ZodString;
|
|
433
|
+
label: z.ZodString;
|
|
434
|
+
help: z.ZodOptional<z.ZodString>;
|
|
435
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
436
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
437
|
+
key: z.ZodString;
|
|
438
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
439
|
+
}, z.core.$strict>>;
|
|
440
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
441
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
442
|
+
type: z.ZodLiteral<"choice">;
|
|
443
|
+
choices: z.ZodArray<z.ZodObject<{
|
|
444
|
+
value: z.ZodString;
|
|
445
|
+
label: z.ZodString;
|
|
446
|
+
}, z.core.$strict>>;
|
|
447
|
+
default: z.ZodOptional<z.ZodString>;
|
|
448
|
+
key: z.ZodString;
|
|
449
|
+
label: z.ZodString;
|
|
450
|
+
help: z.ZodOptional<z.ZodString>;
|
|
451
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
452
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
453
|
+
key: z.ZodString;
|
|
454
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
455
|
+
}, z.core.$strict>>;
|
|
456
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
457
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
458
|
+
type: z.ZodLiteral<"list">;
|
|
459
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
460
|
+
minItems: z.ZodDefault<z.ZodInt>;
|
|
461
|
+
maxItems: z.ZodDefault<z.ZodInt>;
|
|
462
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
463
|
+
patternMessage: z.ZodOptional<z.ZodString>;
|
|
464
|
+
key: z.ZodString;
|
|
465
|
+
label: z.ZodString;
|
|
466
|
+
help: z.ZodOptional<z.ZodString>;
|
|
467
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
468
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
469
|
+
key: z.ZodString;
|
|
470
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
471
|
+
}, z.core.$strict>>;
|
|
472
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
473
|
+
}, z.core.$strict>], "type">;
|
|
474
|
+
/** One field of a group. */
|
|
475
|
+
type SetupField = z.output<typeof setupFieldSchema>;
|
|
476
|
+
/** Validates a whole `setup.json`. */
|
|
477
|
+
declare const integrationSetupSchema: z.ZodObject<{
|
|
478
|
+
transport: z.ZodObject<{
|
|
479
|
+
constants: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
480
|
+
fields: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
481
|
+
type: z.ZodLiteral<"text">;
|
|
482
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
483
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
484
|
+
patternMessage: z.ZodOptional<z.ZodString>;
|
|
485
|
+
minLength: z.ZodOptional<z.ZodInt>;
|
|
486
|
+
maxLength: z.ZodDefault<z.ZodInt>;
|
|
487
|
+
default: z.ZodOptional<z.ZodString>;
|
|
488
|
+
key: z.ZodString;
|
|
489
|
+
label: z.ZodString;
|
|
490
|
+
help: z.ZodOptional<z.ZodString>;
|
|
491
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
492
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
493
|
+
key: z.ZodString;
|
|
494
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
495
|
+
}, z.core.$strict>>;
|
|
496
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
497
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
498
|
+
type: z.ZodLiteral<"secret">;
|
|
499
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
500
|
+
patternMessage: z.ZodOptional<z.ZodString>;
|
|
501
|
+
minLength: z.ZodOptional<z.ZodInt>;
|
|
502
|
+
maxLength: z.ZodDefault<z.ZodInt>;
|
|
503
|
+
key: z.ZodString;
|
|
504
|
+
label: z.ZodString;
|
|
505
|
+
help: z.ZodOptional<z.ZodString>;
|
|
506
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
507
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
508
|
+
key: z.ZodString;
|
|
509
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
510
|
+
}, z.core.$strict>>;
|
|
511
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
512
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
513
|
+
type: z.ZodLiteral<"number">;
|
|
514
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
515
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
516
|
+
isInteger: z.ZodDefault<z.ZodBoolean>;
|
|
517
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
518
|
+
default: z.ZodOptional<z.ZodNumber>;
|
|
519
|
+
warnBelow: z.ZodOptional<z.ZodNumber>;
|
|
520
|
+
warning: z.ZodOptional<z.ZodString>;
|
|
521
|
+
key: z.ZodString;
|
|
522
|
+
label: z.ZodString;
|
|
523
|
+
help: z.ZodOptional<z.ZodString>;
|
|
524
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
525
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
526
|
+
key: z.ZodString;
|
|
527
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
528
|
+
}, z.core.$strict>>;
|
|
529
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
530
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
531
|
+
type: z.ZodLiteral<"boolean">;
|
|
532
|
+
default: z.ZodOptional<z.ZodBoolean>;
|
|
533
|
+
key: z.ZodString;
|
|
534
|
+
label: z.ZodString;
|
|
535
|
+
help: z.ZodOptional<z.ZodString>;
|
|
536
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
537
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
538
|
+
key: z.ZodString;
|
|
539
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
540
|
+
}, z.core.$strict>>;
|
|
541
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
542
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
543
|
+
type: z.ZodLiteral<"choice">;
|
|
544
|
+
choices: z.ZodArray<z.ZodObject<{
|
|
545
|
+
value: z.ZodString;
|
|
546
|
+
label: z.ZodString;
|
|
547
|
+
}, z.core.$strict>>;
|
|
548
|
+
default: z.ZodOptional<z.ZodString>;
|
|
549
|
+
key: z.ZodString;
|
|
550
|
+
label: z.ZodString;
|
|
551
|
+
help: z.ZodOptional<z.ZodString>;
|
|
552
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
553
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
554
|
+
key: z.ZodString;
|
|
555
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
556
|
+
}, z.core.$strict>>;
|
|
557
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
558
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
559
|
+
type: z.ZodLiteral<"list">;
|
|
560
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
561
|
+
minItems: z.ZodDefault<z.ZodInt>;
|
|
562
|
+
maxItems: z.ZodDefault<z.ZodInt>;
|
|
563
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
564
|
+
patternMessage: z.ZodOptional<z.ZodString>;
|
|
565
|
+
key: z.ZodString;
|
|
566
|
+
label: z.ZodString;
|
|
567
|
+
help: z.ZodOptional<z.ZodString>;
|
|
568
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
569
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
570
|
+
key: z.ZodString;
|
|
571
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
572
|
+
}, z.core.$strict>>;
|
|
573
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
574
|
+
}, z.core.$strict>], "type">>>;
|
|
575
|
+
}, z.core.$strict>;
|
|
576
|
+
options: z.ZodDefault<z.ZodObject<{
|
|
577
|
+
constants: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
578
|
+
fields: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
579
|
+
type: z.ZodLiteral<"text">;
|
|
580
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
581
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
582
|
+
patternMessage: z.ZodOptional<z.ZodString>;
|
|
583
|
+
minLength: z.ZodOptional<z.ZodInt>;
|
|
584
|
+
maxLength: z.ZodDefault<z.ZodInt>;
|
|
585
|
+
default: z.ZodOptional<z.ZodString>;
|
|
586
|
+
key: z.ZodString;
|
|
587
|
+
label: z.ZodString;
|
|
588
|
+
help: z.ZodOptional<z.ZodString>;
|
|
589
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
590
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
591
|
+
key: z.ZodString;
|
|
592
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
593
|
+
}, z.core.$strict>>;
|
|
594
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
595
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
596
|
+
type: z.ZodLiteral<"secret">;
|
|
597
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
598
|
+
patternMessage: z.ZodOptional<z.ZodString>;
|
|
599
|
+
minLength: z.ZodOptional<z.ZodInt>;
|
|
600
|
+
maxLength: z.ZodDefault<z.ZodInt>;
|
|
601
|
+
key: z.ZodString;
|
|
602
|
+
label: z.ZodString;
|
|
603
|
+
help: z.ZodOptional<z.ZodString>;
|
|
604
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
605
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
606
|
+
key: z.ZodString;
|
|
607
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
608
|
+
}, z.core.$strict>>;
|
|
609
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
610
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
611
|
+
type: z.ZodLiteral<"number">;
|
|
612
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
613
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
614
|
+
isInteger: z.ZodDefault<z.ZodBoolean>;
|
|
615
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
616
|
+
default: z.ZodOptional<z.ZodNumber>;
|
|
617
|
+
warnBelow: z.ZodOptional<z.ZodNumber>;
|
|
618
|
+
warning: z.ZodOptional<z.ZodString>;
|
|
619
|
+
key: z.ZodString;
|
|
620
|
+
label: z.ZodString;
|
|
621
|
+
help: z.ZodOptional<z.ZodString>;
|
|
622
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
623
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
624
|
+
key: z.ZodString;
|
|
625
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
626
|
+
}, z.core.$strict>>;
|
|
627
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
628
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
629
|
+
type: z.ZodLiteral<"boolean">;
|
|
630
|
+
default: z.ZodOptional<z.ZodBoolean>;
|
|
631
|
+
key: z.ZodString;
|
|
632
|
+
label: z.ZodString;
|
|
633
|
+
help: z.ZodOptional<z.ZodString>;
|
|
634
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
635
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
636
|
+
key: z.ZodString;
|
|
637
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
638
|
+
}, z.core.$strict>>;
|
|
639
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
640
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
641
|
+
type: z.ZodLiteral<"choice">;
|
|
642
|
+
choices: z.ZodArray<z.ZodObject<{
|
|
643
|
+
value: z.ZodString;
|
|
644
|
+
label: z.ZodString;
|
|
645
|
+
}, z.core.$strict>>;
|
|
646
|
+
default: z.ZodOptional<z.ZodString>;
|
|
647
|
+
key: z.ZodString;
|
|
648
|
+
label: z.ZodString;
|
|
649
|
+
help: z.ZodOptional<z.ZodString>;
|
|
650
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
651
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
652
|
+
key: z.ZodString;
|
|
653
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
654
|
+
}, z.core.$strict>>;
|
|
655
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
656
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
657
|
+
type: z.ZodLiteral<"list">;
|
|
658
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
659
|
+
minItems: z.ZodDefault<z.ZodInt>;
|
|
660
|
+
maxItems: z.ZodDefault<z.ZodInt>;
|
|
661
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
662
|
+
patternMessage: z.ZodOptional<z.ZodString>;
|
|
663
|
+
key: z.ZodString;
|
|
664
|
+
label: z.ZodString;
|
|
665
|
+
help: z.ZodOptional<z.ZodString>;
|
|
666
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
667
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
668
|
+
key: z.ZodString;
|
|
669
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
670
|
+
}, z.core.$strict>>;
|
|
671
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
672
|
+
}, z.core.$strict>], "type">>>;
|
|
673
|
+
}, z.core.$strict>>;
|
|
674
|
+
polling: z.ZodOptional<z.ZodObject<{
|
|
675
|
+
default: z.ZodInt;
|
|
676
|
+
min: z.ZodDefault<z.ZodInt>;
|
|
677
|
+
max: z.ZodDefault<z.ZodInt>;
|
|
678
|
+
warnBelow: z.ZodOptional<z.ZodInt>;
|
|
679
|
+
}, z.core.$strict>>;
|
|
680
|
+
}, z.core.$strict>;
|
|
681
|
+
/** A whole `setup.json`, parsed. */
|
|
682
|
+
type IntegrationSetup = z.output<typeof integrationSetupSchema>;
|
|
683
|
+
//#endregion
|
|
684
|
+
//#region ../contracts/dist/integrations.d.ts
|
|
685
|
+
/**
|
|
686
|
+
* The wires the interface names on a vendor's card: what a person recognises on the box, whatever
|
|
687
|
+
* transport of the platform's or of the vendor's own carries it. `udp` is a device's own protocol
|
|
688
|
+
* over plain datagrams on the network (Govee's LAN API), `modbus` Modbus TCP.
|
|
689
|
+
*/
|
|
690
|
+
declare const TRANSPORT_WIRES: readonly ["http", "mqtt", "ble", "zigbee", "udp", "modbus"];
|
|
691
|
+
/** A wire the interface names. */
|
|
692
|
+
type TransportWire = (typeof TRANSPORT_WIRES)[number];
|
|
693
|
+
/**
|
|
694
|
+
* How the platform installed a vendor: the contents of the marker beside its builds,
|
|
695
|
+
* `hub/integrations/<vendor>/.nebula-install.json`, which names the build `hub` loads.
|
|
696
|
+
*/
|
|
697
|
+
declare const integrationInstallSchema: z.ZodObject<{
|
|
698
|
+
build: z.ZodString;
|
|
699
|
+
version: z.ZodString;
|
|
700
|
+
source: z.ZodEnum<{
|
|
701
|
+
local: "local";
|
|
702
|
+
index: "index";
|
|
703
|
+
}>;
|
|
704
|
+
artifactSha256: z.ZodString;
|
|
705
|
+
installedAt: z.ZodISODateTime;
|
|
706
|
+
installedBy: z.ZodNullable<z.ZodUUID>;
|
|
707
|
+
}, z.core.$strict>;
|
|
708
|
+
/** How the platform installed a vendor. */
|
|
709
|
+
type IntegrationInstall = z.output<typeof integrationInstallSchema>;
|
|
710
|
+
//#endregion
|
|
711
|
+
//#region ../package-runtime/dist/transport.d.ts
|
|
712
|
+
/** What an integration asks a transport to do, expressed as data. */
|
|
713
|
+
type TransportRequest = {
|
|
714
|
+
/** Which device, in whatever way this transport identifies one. */
|
|
715
|
+
readonly deviceKey: string;
|
|
716
|
+
/** The transport's own verb: `get` and `post` for HTTP, `publish` for MQTT. */
|
|
717
|
+
readonly op: string;
|
|
718
|
+
/** The verb's arguments, in the transport's own vocabulary. */
|
|
719
|
+
readonly args: JsonObject;
|
|
720
|
+
};
|
|
721
|
+
/**
|
|
722
|
+
* A standing interest an integration has in what a connection carries.
|
|
723
|
+
*
|
|
724
|
+
* No `deviceKey`: a subscription is usually broader than one device - a topic filter, a polling
|
|
725
|
+
* schedule - and the transport reports which device a message came from when it arrives.
|
|
726
|
+
*/
|
|
727
|
+
type TransportSubscription = {
|
|
728
|
+
readonly op: string;
|
|
729
|
+
readonly args: JsonObject;
|
|
730
|
+
};
|
|
731
|
+
/** Something a connection delivered without being asked. */
|
|
732
|
+
type TransportInbound = {
|
|
733
|
+
readonly connectionKey: string;
|
|
734
|
+
readonly deviceKey: string;
|
|
735
|
+
/** Raw, as it arrived. Making sense of it is the integration's job. */
|
|
736
|
+
readonly payload: unknown;
|
|
737
|
+
};
|
|
738
|
+
/** Something a scan found, before any integration has claimed it. */
|
|
739
|
+
type Discovered = {
|
|
740
|
+
readonly deviceKey: string;
|
|
741
|
+
/**
|
|
742
|
+
* What the scan saw.
|
|
743
|
+
*
|
|
744
|
+
* The blob an integration decides on and, if it claims the device, describes it from. Keeping
|
|
745
|
+
* it raw is what lets `describe` be a pure function of it.
|
|
746
|
+
*/
|
|
747
|
+
readonly payload: unknown;
|
|
748
|
+
};
|
|
749
|
+
/** Whether a connection is currently usable. */
|
|
750
|
+
type TransportStatus = 'up' | 'down';
|
|
751
|
+
/**
|
|
752
|
+
* What a transport is given when it opens a connection.
|
|
753
|
+
*
|
|
754
|
+
* The transport **calls** these. It is the one holding the socket, so it is the one that knows
|
|
755
|
+
* when something arrived and when the connection dropped; `hub` cannot poll for either.
|
|
756
|
+
*/
|
|
757
|
+
type TransportContext = {
|
|
758
|
+
readonly logger: BundleLogger;
|
|
759
|
+
/** Called for every message the connection delivered without being asked. */
|
|
760
|
+
deliver: (message: TransportInbound) => void;
|
|
761
|
+
/** Called when the connection comes up or goes down. */
|
|
762
|
+
report: (status: TransportStatus) => void;
|
|
763
|
+
/**
|
|
764
|
+
* The account the connection is for, when its configuration names one
|
|
765
|
+
* (`config.account`) of the transport's own vendor - the session to use, and how to keep a
|
|
766
|
+
* renewed one or say the owner must sign in again. Absent otherwise.
|
|
767
|
+
*/
|
|
768
|
+
readonly account?: AccountHandle;
|
|
769
|
+
};
|
|
770
|
+
/**
|
|
771
|
+
* What a scan or a probe is handed beside its arguments - the account its
|
|
772
|
+
* configuration names (`config.account`), as a connection is handed it. Absent otherwise.
|
|
773
|
+
*/
|
|
774
|
+
type TransportLookContext = {
|
|
775
|
+
readonly account?: AccountHandle;
|
|
776
|
+
};
|
|
777
|
+
/** One live connection, shared by every instance whose configuration resolves to it. */
|
|
778
|
+
type TransportConnection = {
|
|
779
|
+
/** What this connection is shared under. */
|
|
780
|
+
readonly key: string;
|
|
781
|
+
/**
|
|
782
|
+
* Performs one request.
|
|
783
|
+
*
|
|
784
|
+
* @param request - What to do.
|
|
785
|
+
* @param signal - Cancels the request.
|
|
786
|
+
* @returns Whatever the device answered, raw.
|
|
787
|
+
*/
|
|
788
|
+
send: (request: TransportRequest, signal: AbortSignal) => Promise<unknown>;
|
|
789
|
+
/**
|
|
790
|
+
* Replaces the set of standing subscriptions.
|
|
791
|
+
*
|
|
792
|
+
* Replaces rather than adds, so that `hub` can recompute the whole set when an instance is
|
|
793
|
+
* added or removed and apply it without tracking what it asked for last time.
|
|
794
|
+
*
|
|
795
|
+
* @param subscriptions - Everything this connection should now carry.
|
|
796
|
+
* @returns A promise that settles once the transport has applied them.
|
|
797
|
+
*/
|
|
798
|
+
apply: (subscriptions: readonly TransportSubscription[]) => Promise<void>;
|
|
799
|
+
/**
|
|
800
|
+
* Closes the connection.
|
|
801
|
+
*
|
|
802
|
+
* @returns A promise that settles once it is closed.
|
|
803
|
+
*/
|
|
804
|
+
close: () => Promise<void>;
|
|
805
|
+
};
|
|
806
|
+
/**
|
|
807
|
+
* How a kind of connection is opened, scanned and spoken to.
|
|
808
|
+
*
|
|
809
|
+
* Configuration arrives as `unknown` because this is what a registry holds, and a registry holds
|
|
810
|
+
* transports of every shape. Each one narrows its own with {@link defineTransport}, which is also
|
|
811
|
+
* the single place the settings an owner typed are validated.
|
|
812
|
+
*
|
|
813
|
+
* The alternative - a generic `Transport<TConfig>` - does not survive being put in a collection:
|
|
814
|
+
* a `Transport<HttpConfig>` is not a `Transport<JsonObject>`, because a function taking the
|
|
815
|
+
* narrower type cannot stand in for one taking the wider. Erasing the parameter here and
|
|
816
|
+
* restoring it in the helper keeps both ends honest without a cast anywhere.
|
|
817
|
+
*/
|
|
818
|
+
type Transport = {
|
|
819
|
+
/** `http`, `mqtt`, `esphome`. */
|
|
820
|
+
readonly id: string;
|
|
821
|
+
/** Validates the connection settings an owner supplied. */
|
|
822
|
+
readonly configSchema: z.ZodType;
|
|
823
|
+
/**
|
|
824
|
+
* What two configurations must agree on to share one connection.
|
|
825
|
+
*
|
|
826
|
+
* Derived from the configuration rather than declared, because the answer is the transport's:
|
|
827
|
+
* two MQTT instances share a connection when the broker matches, two HTTP ones never do.
|
|
828
|
+
*
|
|
829
|
+
* @param config - The connection settings.
|
|
830
|
+
* @returns The key this configuration's connection is shared under.
|
|
831
|
+
*/
|
|
832
|
+
connectionKey: (config: unknown) => string;
|
|
833
|
+
/**
|
|
834
|
+
* Opens a connection.
|
|
835
|
+
*
|
|
836
|
+
* @param config - The connection settings.
|
|
837
|
+
* @param context - Where inbound messages and status changes go.
|
|
838
|
+
* @returns The connection, once it is usable.
|
|
839
|
+
*/
|
|
840
|
+
connect: (config: unknown, context: TransportContext) => Promise<TransportConnection>;
|
|
841
|
+
/**
|
|
842
|
+
* Looks for devices this transport can reach.
|
|
843
|
+
*
|
|
844
|
+
* @param config - The connection settings.
|
|
845
|
+
* @param scan - The integration's search terms, in this transport's vocabulary.
|
|
846
|
+
* @param signal - Ends the scan.
|
|
847
|
+
* @param context - The account the configuration names.
|
|
848
|
+
* @returns Candidates as they are found, rather than a list once the scan is over: a scan of a
|
|
849
|
+
* house takes long enough that the interface should be filling in while it runs.
|
|
850
|
+
*/
|
|
851
|
+
scan: (config: unknown, scan: JsonObject, signal: AbortSignal, context?: TransportLookContext) => AsyncIterable<Discovered>;
|
|
852
|
+
/**
|
|
853
|
+
* Tries the settings against the world and lets go again.
|
|
854
|
+
*
|
|
855
|
+
* What "Test" in the interface does before an owner saves: open whatever the transport opens
|
|
856
|
+
* - a broker session, a request to each address - then close it, keeping nothing. Resolves
|
|
857
|
+
* with one sentence saying what worked, so the interface can show it; rejects with an error
|
|
858
|
+
* whose message names what did not, in the transport's own words, because "Not authorized"
|
|
859
|
+
* and "ECONNREFUSED" send an owner to different places.
|
|
860
|
+
*
|
|
861
|
+
* @param config - What the owner typed, complete and in the clear.
|
|
862
|
+
* @param signal - Gives up: a host that never answers must not hold the form open.
|
|
863
|
+
* @param context - The account the configuration names.
|
|
864
|
+
*/
|
|
865
|
+
probe: (config: unknown, signal: AbortSignal, context?: TransportLookContext) => Promise<string>;
|
|
866
|
+
};
|
|
867
|
+
/** A transport as its author writes it, with its own configuration type. */
|
|
868
|
+
type TransportSpec<TConfig> = {
|
|
869
|
+
readonly id: string;
|
|
870
|
+
readonly configSchema: z.ZodType<TConfig>;
|
|
871
|
+
connectionKey: (config: TConfig) => string;
|
|
872
|
+
connect: (config: TConfig, context: TransportContext) => Promise<TransportConnection>;
|
|
873
|
+
scan: (config: TConfig, scan: JsonObject, signal: AbortSignal, context?: TransportLookContext) => AsyncIterable<Discovered>;
|
|
874
|
+
probe: (config: TConfig, signal: AbortSignal, context?: TransportLookContext) => Promise<string>;
|
|
875
|
+
};
|
|
876
|
+
/**
|
|
877
|
+
* Turns a transport written against its own configuration into one a registry can hold.
|
|
878
|
+
*
|
|
879
|
+
* Validation happens here and only here. Everything above receives whatever an owner put in a
|
|
880
|
+
* `jsonb` column and passes it straight through, so a wrong setting fails once, with the
|
|
881
|
+
* transport's own message, instead of being parsed in every caller that happens to remember to.
|
|
882
|
+
*
|
|
883
|
+
* @param spec - The transport, written against the configuration it understands.
|
|
884
|
+
* @returns The same transport, with its configuration parameter erased.
|
|
885
|
+
*/
|
|
886
|
+
declare function defineTransport<TConfig>(spec: TransportSpec<TConfig>): Transport;
|
|
887
|
+
//#endregion
|
|
888
|
+
//#region ../package-runtime/dist/integration.d.ts
|
|
889
|
+
/** A device an integration has recognised as its own. */
|
|
890
|
+
type Claim = {
|
|
891
|
+
/** How the transport addresses it. */
|
|
892
|
+
readonly deviceKey: string;
|
|
893
|
+
/** How the integration identifies it, stable across restarts. */
|
|
894
|
+
readonly externalId: string;
|
|
895
|
+
/**
|
|
896
|
+
* What the integration recognised it from, kept for {@link Integration.describe}.
|
|
897
|
+
*
|
|
898
|
+
* Raw. For zigbee2mqtt this is the `exposes` tree, for ESPHome the entity list, for Matter the
|
|
899
|
+
* endpoint and cluster tree. All three are self-describing, which is exactly why `describe`
|
|
900
|
+
* can be a pure function of this and why those integrations cover thousands of devices each.
|
|
901
|
+
*/
|
|
902
|
+
readonly descriptor: unknown;
|
|
903
|
+
};
|
|
904
|
+
/** One entity a device exposes, before `hub` has given it an identifier. */
|
|
905
|
+
type EntityDescriptor = {
|
|
906
|
+
readonly domain: EntityDomain;
|
|
907
|
+
/** Distinguishes it from the device's other entities. Omitted when it is the only one. */
|
|
908
|
+
readonly objectId?: string;
|
|
909
|
+
readonly name: string;
|
|
910
|
+
/** The catalogue icon it starts with, when the bundle names one. */
|
|
911
|
+
readonly icon?: string;
|
|
912
|
+
readonly capabilities: DeclaredCapabilities;
|
|
913
|
+
readonly unitOfMeasurement?: string;
|
|
914
|
+
readonly deviceClass?: string;
|
|
915
|
+
readonly stateClass?: EntityStateClass;
|
|
916
|
+
readonly displayPrecision?: number;
|
|
917
|
+
};
|
|
918
|
+
/** What a claimed device turns out to be. */
|
|
919
|
+
type DeviceDescriptor = {
|
|
920
|
+
readonly externalId: string;
|
|
921
|
+
readonly name: string;
|
|
922
|
+
readonly manufacturer?: string;
|
|
923
|
+
readonly model?: string;
|
|
924
|
+
readonly swVersion?: string;
|
|
925
|
+
readonly hwVersion?: string;
|
|
926
|
+
/**
|
|
927
|
+
* The device this one is reached through, named the way this integration names devices.
|
|
928
|
+
*
|
|
929
|
+
* A BLE thermometer reached through an ESPHome proxy names the proxy here. It is what lets the
|
|
930
|
+
* interface answer "why did six things go offline at once" with the one that actually did.
|
|
931
|
+
*/
|
|
932
|
+
readonly viaExternalId?: string;
|
|
933
|
+
readonly entities: readonly EntityDescriptor[];
|
|
934
|
+
};
|
|
935
|
+
/** What a mapper may look at besides its own arguments. */
|
|
936
|
+
type MappingContext = {
|
|
937
|
+
/** The instance's own settings, already validated against the integration's schema. */
|
|
938
|
+
readonly options: JsonObject;
|
|
939
|
+
/** The device being mapped. */
|
|
940
|
+
readonly claim: Claim;
|
|
941
|
+
/** The entity identifiers `hub` gave this device, keyed by descriptor `objectId`. */
|
|
942
|
+
readonly entities: ReadonlyMap<string, EntityId>;
|
|
943
|
+
/**
|
|
944
|
+
* The last state `hub` published for an entity.
|
|
945
|
+
*
|
|
946
|
+
* Present so that a command needing the current value can be built without asking the device.
|
|
947
|
+
* Undefined before the entity has ever reported.
|
|
948
|
+
*
|
|
949
|
+
* @param entityId - The entity to look up.
|
|
950
|
+
* @returns Its last known state, or undefined.
|
|
951
|
+
*/
|
|
952
|
+
lastState: (entityId: EntityId) => CapabilityState | undefined;
|
|
953
|
+
};
|
|
954
|
+
/** A command, resolved to the device and entity it is for. */
|
|
955
|
+
type CommandTarget = {
|
|
956
|
+
readonly entityId: EntityId;
|
|
957
|
+
readonly capability: CapabilityName;
|
|
958
|
+
/** Already validated by `core` against the capability's command schema. */
|
|
959
|
+
readonly command: JsonObject;
|
|
960
|
+
};
|
|
961
|
+
/**
|
|
962
|
+
* The picture an image entity's report carries beside its state - an SVG, a PNG - which
|
|
963
|
+
* the hub keeps and never publishes: the state says which picture it is (`revision`), and the
|
|
964
|
+
* bytes are asked for by whoever shows it.
|
|
965
|
+
*/
|
|
966
|
+
type ImageBlob = {
|
|
967
|
+
readonly contentType: 'image/svg+xml' | 'image/png' | 'image/jpeg';
|
|
968
|
+
/** The picture: an SVG's text, or bytes. */
|
|
969
|
+
readonly data: string | Buffer;
|
|
970
|
+
/** How often at most a new picture of the entity is announced; 2 s unless said. */
|
|
971
|
+
readonly minIntervalMs?: number;
|
|
972
|
+
};
|
|
973
|
+
/** A report as an integration makes it: the state, and the picture of an image entity. */
|
|
974
|
+
type ReportedState = StateReport & {
|
|
975
|
+
readonly blob?: ImageBlob;
|
|
976
|
+
};
|
|
977
|
+
/** What a kind of device means, in terms of the canonical model. */
|
|
978
|
+
type Integration<TOptions = JsonObject> = {
|
|
979
|
+
/** The bundle kind: `zigbee2mqtt`, `shelly-gen2`. An instance of it gets its own id. */
|
|
980
|
+
readonly id: string;
|
|
981
|
+
/** Which transport carries it. */
|
|
982
|
+
readonly transport: string;
|
|
983
|
+
/** Validates the settings an owner supplied for an instance. */
|
|
984
|
+
readonly optionsSchema: z.ZodType<TOptions>;
|
|
985
|
+
/**
|
|
986
|
+
* What to tell the transport to look for during a scan.
|
|
987
|
+
*
|
|
988
|
+
* The transport's own vocabulary - an mDNS service name, an MQTT topic filter - and opaque
|
|
989
|
+
* here. An empty object means "whatever you would find anyway", which is what a code
|
|
990
|
+
* integration on a transport that enumerates broadly uses.
|
|
991
|
+
*/
|
|
992
|
+
readonly discovery: JsonObject;
|
|
993
|
+
/**
|
|
994
|
+
* Decides whether a discovered device is this integration's to own.
|
|
995
|
+
*
|
|
996
|
+
* @param discovered - What the scan found.
|
|
997
|
+
* @param options - The instance's settings.
|
|
998
|
+
* @returns The claim, or null when the device belongs to someone else.
|
|
999
|
+
*/
|
|
1000
|
+
claim: (discovered: Discovered, options: TOptions) => Claim | null;
|
|
1001
|
+
/**
|
|
1002
|
+
* States what the transport must carry for these devices.
|
|
1003
|
+
*
|
|
1004
|
+
* Data rather than an action: `hub` collects the answers from every instance sharing a
|
|
1005
|
+
* connection, deduplicates them, and applies the set once.
|
|
1006
|
+
*
|
|
1007
|
+
* @param claims - The devices this instance owns.
|
|
1008
|
+
* @param options - The instance's settings.
|
|
1009
|
+
* @returns Everything the transport should subscribe to or poll.
|
|
1010
|
+
*/
|
|
1011
|
+
subscriptions: (claims: readonly Claim[], options: TOptions) => TransportSubscription[];
|
|
1012
|
+
/**
|
|
1013
|
+
* Says what a claimed device is and what it exposes.
|
|
1014
|
+
*
|
|
1015
|
+
* @param claim - The device.
|
|
1016
|
+
* @param options - The instance's settings.
|
|
1017
|
+
* @returns Its identity and its entities.
|
|
1018
|
+
*/
|
|
1019
|
+
describe: (claim: Claim, options: TOptions) => DeviceDescriptor;
|
|
1020
|
+
/**
|
|
1021
|
+
* Turns something the device sent into canonical state.
|
|
1022
|
+
*
|
|
1023
|
+
* @param message - What arrived.
|
|
1024
|
+
* @param context - The claim, the settings and the last known state.
|
|
1025
|
+
* @returns One report per entity the message says something about, which may be none.
|
|
1026
|
+
*/
|
|
1027
|
+
toState: (message: TransportInbound, context: MappingContext) => ReportedState[];
|
|
1028
|
+
/**
|
|
1029
|
+
* Turns a canonical command into something the transport can perform.
|
|
1030
|
+
*
|
|
1031
|
+
* @param target - The entity, the capability and the command.
|
|
1032
|
+
* @param context - The claim, the settings and the last known state.
|
|
1033
|
+
* @returns The request. Performing it is the transport's job.
|
|
1034
|
+
*/
|
|
1035
|
+
toCommand: (target: CommandTarget, context: MappingContext) => TransportRequest;
|
|
1036
|
+
/**
|
|
1037
|
+
* Reads what a message says about the device itself, beyond its entities: the firmware it runs
|
|
1038
|
+
* now, which changes when it is updated and is otherwise only known from when it was found.
|
|
1039
|
+
*
|
|
1040
|
+
* Optional: an integration whose messages say nothing of the kind leaves it out.
|
|
1041
|
+
*
|
|
1042
|
+
* @param message - What arrived.
|
|
1043
|
+
* @param context - The claim, the settings and the last known state.
|
|
1044
|
+
* @returns What the message says, field by field; undefined, or a field left out, when it says
|
|
1045
|
+
* nothing about it.
|
|
1046
|
+
*/
|
|
1047
|
+
deviceInfo?: (message: TransportInbound, context: MappingContext) => DeviceInfo | undefined;
|
|
1048
|
+
/**
|
|
1049
|
+
* Says how a camera entity's picture is read, when it is one.
|
|
1050
|
+
*
|
|
1051
|
+
* Optional: an integration with no camera leaves it out.
|
|
1052
|
+
*
|
|
1053
|
+
* @param entityId - The entity.
|
|
1054
|
+
* @param context - The claim, the settings and the last known state.
|
|
1055
|
+
* @returns The stream source and what it is told to read, or undefined for an entity with none.
|
|
1056
|
+
*/
|
|
1057
|
+
streamOf?: (entityId: EntityId, context: MappingContext) => StreamRequest | undefined;
|
|
1058
|
+
};
|
|
1059
|
+
/** How one camera's picture is read: which source, told what. */
|
|
1060
|
+
type StreamRequest = {
|
|
1061
|
+
readonly source: string;
|
|
1062
|
+
readonly args: JsonObject;
|
|
1063
|
+
};
|
|
1064
|
+
/** What a message says about the device itself. */
|
|
1065
|
+
type DeviceInfo = {
|
|
1066
|
+
readonly swVersion?: string;
|
|
1067
|
+
readonly hwVersion?: string;
|
|
1068
|
+
};
|
|
1069
|
+
//#endregion
|
|
1070
|
+
//#region ../package-runtime/dist/stream.d.ts
|
|
1071
|
+
/** What a stream carries: stills, or H.264 with the codec string its decoder is set up with. */
|
|
1072
|
+
type StreamTrack = {
|
|
1073
|
+
readonly kind: 'jpeg';
|
|
1074
|
+
} | {
|
|
1075
|
+
readonly kind: 'h264';
|
|
1076
|
+
readonly codec: string;
|
|
1077
|
+
};
|
|
1078
|
+
/** One frame of a stream. */
|
|
1079
|
+
type StreamFrame = {
|
|
1080
|
+
/** A JPEG, or an H.264 access unit in Annex B with its parameter sets before a key frame. */
|
|
1081
|
+
readonly data: Uint8Array;
|
|
1082
|
+
/** Whether a decoder can start from it. */
|
|
1083
|
+
readonly isKey: boolean;
|
|
1084
|
+
/** When it was taken, in microseconds from the start of the stream. */
|
|
1085
|
+
readonly timestampUs: number;
|
|
1086
|
+
};
|
|
1087
|
+
/** Where a source puts what it reads. */
|
|
1088
|
+
type StreamSink = {
|
|
1089
|
+
/** Says what the stream carries; called once, before the first frame. */
|
|
1090
|
+
describe: (track: StreamTrack) => void;
|
|
1091
|
+
/** Hands over one frame. */
|
|
1092
|
+
frame: (frame: StreamFrame) => void;
|
|
1093
|
+
};
|
|
1094
|
+
/** How a camera's picture is read. */
|
|
1095
|
+
type StreamSource = {
|
|
1096
|
+
/** `<vendor>/<name>`, as the profile names it. */
|
|
1097
|
+
readonly id: string;
|
|
1098
|
+
/** Validates the settings it reads the camera with: the instance's transport settings. */
|
|
1099
|
+
readonly configSchema: z.ZodType;
|
|
1100
|
+
/**
|
|
1101
|
+
* Reads the stream until the signal ends it or the camera does.
|
|
1102
|
+
*
|
|
1103
|
+
* @param config - The instance's transport settings, secrets opened.
|
|
1104
|
+
* @param args - What the profile's camera entity says to read.
|
|
1105
|
+
* @param sink - Where the track and the frames go.
|
|
1106
|
+
* @param signal - Ends the stream.
|
|
1107
|
+
* @returns A promise that settles when the stream ended; rejects with why, when it failed.
|
|
1108
|
+
*/
|
|
1109
|
+
open: (config: unknown, args: JsonObject, sink: StreamSink, signal: AbortSignal) => Promise<void>;
|
|
1110
|
+
};
|
|
1111
|
+
/** A stream source as its author writes it, with its own configuration type. */
|
|
1112
|
+
type StreamSourceSpec<TConfig> = {
|
|
1113
|
+
readonly id: string;
|
|
1114
|
+
readonly configSchema: z.ZodType<TConfig>;
|
|
1115
|
+
open: (config: TConfig, args: JsonObject, sink: StreamSink, signal: AbortSignal) => Promise<void>;
|
|
1116
|
+
};
|
|
1117
|
+
/**
|
|
1118
|
+
* Turns a stream source written against its own configuration into one a registry can hold,
|
|
1119
|
+
* validating the settings on the way in as {@link defineTransport} does.
|
|
1120
|
+
*
|
|
1121
|
+
* @param spec - The source.
|
|
1122
|
+
* @returns The same source, its configuration parameter erased.
|
|
1123
|
+
*/
|
|
1124
|
+
declare function defineStreamSource<TConfig>(spec: StreamSourceSpec<TConfig>): StreamSource;
|
|
1125
|
+
/** One access unit an RTSP session delivered. */
|
|
1126
|
+
type RtspFrame = StreamFrame & {
|
|
1127
|
+
/** The codec string of the stream, from its sequence parameters. */
|
|
1128
|
+
readonly codec: string;
|
|
1129
|
+
};
|
|
1130
|
+
/** What opening an RTSP session takes. */
|
|
1131
|
+
type RtspOptions = {
|
|
1132
|
+
/** `rtsp://user:password@host:port/path`, or `rtsps://` over TLS. */
|
|
1133
|
+
readonly url: string;
|
|
1134
|
+
/** Whether a TLS camera's certificate must chain to an authority this machine trusts. */
|
|
1135
|
+
readonly rejectUnauthorized?: boolean;
|
|
1136
|
+
/** Ends the session. */
|
|
1137
|
+
readonly signal: AbortSignal;
|
|
1138
|
+
};
|
|
1139
|
+
/**
|
|
1140
|
+
* Plays an RTSP stream over TCP and yields its H.264 access units.
|
|
1141
|
+
*
|
|
1142
|
+
* @throws {Error} From the iteration, when the camera refused or the session failed.
|
|
1143
|
+
*/
|
|
1144
|
+
type OpenRtsp = (options: RtspOptions) => AsyncIterable<RtspFrame>;
|
|
1145
|
+
//#endregion
|
|
1146
|
+
//#region ../package-runtime/dist/sdk.d.ts
|
|
1147
|
+
/**
|
|
1148
|
+
* One level of a bundle's log: fields and a message, or a message alone - pino's way, which is the
|
|
1149
|
+
* logger `hub` hands over.
|
|
1150
|
+
*/
|
|
1151
|
+
type BundleLogFn = {
|
|
1152
|
+
(fields: object, message?: string): void;
|
|
1153
|
+
(message: string): void;
|
|
1154
|
+
};
|
|
1155
|
+
/**
|
|
1156
|
+
* The hub's logger, as far as a bundle's code may use it: named here rather than as the platform's
|
|
1157
|
+
* logger type, so that what a bundle is written against says nothing of how the platform logs.
|
|
1158
|
+
*/
|
|
1159
|
+
type BundleLogger = {
|
|
1160
|
+
readonly trace: BundleLogFn;
|
|
1161
|
+
readonly debug: BundleLogFn;
|
|
1162
|
+
readonly info: BundleLogFn;
|
|
1163
|
+
readonly warn: BundleLogFn;
|
|
1164
|
+
readonly error: BundleLogFn;
|
|
1165
|
+
readonly fatal: BundleLogFn;
|
|
1166
|
+
/**
|
|
1167
|
+
* A logger whose every line carries these fields too.
|
|
1168
|
+
*
|
|
1169
|
+
* @param fields - The fields.
|
|
1170
|
+
* @returns The logger.
|
|
1171
|
+
*/
|
|
1172
|
+
child: (fields: Record<string, unknown>) => BundleLogger;
|
|
1173
|
+
};
|
|
1174
|
+
/** HTTP headers for a WebSocket's opening handshake. */
|
|
1175
|
+
type ManagedSocketHeaders = Readonly<Record<string, string>>;
|
|
1176
|
+
/** What a drop says beyond its reason. */
|
|
1177
|
+
type ManagedSocketClose = {
|
|
1178
|
+
/** The WebSocket close code: the peer's, or 1006 for a socket that ended without one. */
|
|
1179
|
+
readonly code?: number;
|
|
1180
|
+
/**
|
|
1181
|
+
* The HTTP status of a handshake the server refused - 401, 403 - so that credentials it turned
|
|
1182
|
+
* down can be told from a network that failed. Absent for any other drop.
|
|
1183
|
+
*/
|
|
1184
|
+
readonly status?: number;
|
|
1185
|
+
};
|
|
1186
|
+
/** What opening a managed WebSocket takes. */
|
|
1187
|
+
type ManagedSocketOptions = {
|
|
1188
|
+
/** `ws://host/path` or `wss://…`. */
|
|
1189
|
+
readonly url: string;
|
|
1190
|
+
/**
|
|
1191
|
+
* Headers sent on the opening handshake, the first and every reconnect's, for a
|
|
1192
|
+
* server that authenticates the socket by them. Never logged. A function is called before each
|
|
1193
|
+
* attempt and may answer with a promise - for a token that expires; one that throws fails that
|
|
1194
|
+
* attempt as a refused connection would, and the next comes on the usual schedule.
|
|
1195
|
+
*/
|
|
1196
|
+
readonly headers?: ManagedSocketHeaders | (() => ManagedSocketHeaders | Promise<ManagedSocketHeaders>);
|
|
1197
|
+
/**
|
|
1198
|
+
* A ping every `everyMs`, and the socket dropped - then reconnected - when no pong
|
|
1199
|
+
* comes within `timeoutMs`. For a peer that may say nothing for hours, whose silence would
|
|
1200
|
+
* otherwise hide a dead connection. Off unless said.
|
|
1201
|
+
*/
|
|
1202
|
+
readonly ping?: {
|
|
1203
|
+
readonly everyMs: number;
|
|
1204
|
+
readonly timeoutMs: number;
|
|
1205
|
+
};
|
|
1206
|
+
/**
|
|
1207
|
+
* TLS for a `wss://` server: whether its certificate must chain to an authority
|
|
1208
|
+
* this machine trusts (on unless said).
|
|
1209
|
+
*/
|
|
1210
|
+
readonly tls?: {
|
|
1211
|
+
readonly rejectUnauthorized?: boolean;
|
|
1212
|
+
};
|
|
1213
|
+
readonly logger: BundleLogger;
|
|
1214
|
+
/** Called after every connection, the first and each one after a drop. */
|
|
1215
|
+
readonly onOpen: () => void;
|
|
1216
|
+
/** Called with each text frame. */
|
|
1217
|
+
readonly onMessage: (text: string) => void;
|
|
1218
|
+
/**
|
|
1219
|
+
* Called when the socket dropped or failed to connect; the helper reconnects by itself unless
|
|
1220
|
+
* the socket is closed here. The hub also says the close code and, for a handshake
|
|
1221
|
+
* the server refused, its HTTP status.
|
|
1222
|
+
*/
|
|
1223
|
+
readonly onClose: (reason: string, details?: ManagedSocketClose) => void;
|
|
1224
|
+
/**
|
|
1225
|
+
* How to come back after a drop: doubling from `minMs` (1 s) to `maxMs` (30 s), reset by a
|
|
1226
|
+
* connection that opens. `false` is one attempt and no more, for a probe or a scan.
|
|
1227
|
+
*/
|
|
1228
|
+
readonly reconnect?: {
|
|
1229
|
+
readonly minMs?: number;
|
|
1230
|
+
readonly maxMs?: number;
|
|
1231
|
+
} | false;
|
|
1232
|
+
};
|
|
1233
|
+
/** A WebSocket the hub keeps open on a bundle's behalf. */
|
|
1234
|
+
type ManagedSocket = {
|
|
1235
|
+
/** Whether a frame can be sent right now. */
|
|
1236
|
+
readonly isOpen: boolean;
|
|
1237
|
+
/**
|
|
1238
|
+
* Sends one text frame.
|
|
1239
|
+
*
|
|
1240
|
+
* @throws {Error} When the socket is not open.
|
|
1241
|
+
*/
|
|
1242
|
+
send: (text: string) => void;
|
|
1243
|
+
/** Drops the socket so the helper reconnects - after a request that timed out. */
|
|
1244
|
+
reset: (reason: string) => void;
|
|
1245
|
+
/** Closes for good. */
|
|
1246
|
+
close: () => Promise<void>;
|
|
1247
|
+
};
|
|
1248
|
+
/** Opens a managed WebSocket. */
|
|
1249
|
+
type OpenWebSocket = (options: ManagedSocketOptions) => ManagedSocket;
|
|
1250
|
+
/** Where a datagram came from. */
|
|
1251
|
+
type UdpPeer = {
|
|
1252
|
+
readonly address: string;
|
|
1253
|
+
readonly port: number;
|
|
1254
|
+
};
|
|
1255
|
+
/** What opening a managed UDP socket takes. */
|
|
1256
|
+
type ManagedUdpSocketOptions = {
|
|
1257
|
+
/** The port to listen on; absent, whatever port the system picks. */
|
|
1258
|
+
readonly port?: number;
|
|
1259
|
+
/** Whether another socket may bind the same port, as a multicast listener must allow. */
|
|
1260
|
+
readonly reuseAddr?: boolean;
|
|
1261
|
+
/** A multicast group to join, and whether to hear what this host itself sends to it. */
|
|
1262
|
+
readonly multicast?: {
|
|
1263
|
+
readonly group: string;
|
|
1264
|
+
readonly loopback?: boolean;
|
|
1265
|
+
};
|
|
1266
|
+
/** Whether the socket may send to a broadcast address. */
|
|
1267
|
+
readonly broadcast?: boolean;
|
|
1268
|
+
/** Called with each datagram, as bytes: some protocols are text and some are not. */
|
|
1269
|
+
readonly onMessage: (message: Buffer, from: UdpPeer) => void;
|
|
1270
|
+
/** Called when the socket fails after it opened. The hub has logged it already. */
|
|
1271
|
+
readonly onError?: (error: Error) => void;
|
|
1272
|
+
};
|
|
1273
|
+
/** A UDP socket the hub holds on a bundle's behalf. */
|
|
1274
|
+
type ManagedUdpSocket = {
|
|
1275
|
+
/** The port it is bound to, known once it has opened. */
|
|
1276
|
+
readonly port: number;
|
|
1277
|
+
/**
|
|
1278
|
+
* Sends one datagram.
|
|
1279
|
+
*
|
|
1280
|
+
* @throws {Error} When the socket is closed or the send fails.
|
|
1281
|
+
*/
|
|
1282
|
+
send: (message: Buffer | string, port: number, address: string) => Promise<void>;
|
|
1283
|
+
/** Closes for good, leaving the group. */
|
|
1284
|
+
close: () => Promise<void>;
|
|
1285
|
+
};
|
|
1286
|
+
/** Opens a managed UDP socket. */
|
|
1287
|
+
type OpenUdpSocket = (options: ManagedUdpSocketOptions) => ManagedUdpSocket;
|
|
1288
|
+
/** What opening a managed MQTT session takes. */
|
|
1289
|
+
type ManagedMqttOptions = {
|
|
1290
|
+
/** `mqtt://host:1883`, or `mqtts://host:8883` behind TLS. */
|
|
1291
|
+
readonly url: string;
|
|
1292
|
+
/** The client id to connect as; one the client makes up when absent. */
|
|
1293
|
+
readonly clientId?: string;
|
|
1294
|
+
readonly username?: string;
|
|
1295
|
+
readonly password?: string;
|
|
1296
|
+
/**
|
|
1297
|
+
* TLS for an `mqtts://` broker: a client certificate as a PKCS#12 bundle and its passphrase,
|
|
1298
|
+
* for a broker that authenticates the client by certificate, and whether the broker's own
|
|
1299
|
+
* certificate must chain to an authority this machine trusts (on unless said).
|
|
1300
|
+
*/
|
|
1301
|
+
readonly tls?: {
|
|
1302
|
+
readonly pfx?: Buffer;
|
|
1303
|
+
readonly passphrase?: string;
|
|
1304
|
+
readonly rejectUnauthorized?: boolean;
|
|
1305
|
+
};
|
|
1306
|
+
readonly logger: BundleLogger;
|
|
1307
|
+
/** Called after every connection, the first and each one after a drop. */
|
|
1308
|
+
readonly onConnect?: () => void;
|
|
1309
|
+
/** Called with each message on a topic subscribed to. */
|
|
1310
|
+
readonly onMessage: (topic: string, payload: Buffer) => void;
|
|
1311
|
+
/** Called when the session dropped or failed to come up; the helper reconnects by itself. */
|
|
1312
|
+
readonly onClose?: (reason: string) => void;
|
|
1313
|
+
};
|
|
1314
|
+
/** An MQTT session the hub keeps up on a bundle's behalf. */
|
|
1315
|
+
type ManagedMqtt = {
|
|
1316
|
+
/** Whether a message can be published right now. */
|
|
1317
|
+
readonly isConnected: boolean;
|
|
1318
|
+
/** Subscribes, now and after every reconnect, until unsubscribed. */
|
|
1319
|
+
subscribe: (topic: string) => void;
|
|
1320
|
+
/** Stops hearing a topic. */
|
|
1321
|
+
unsubscribe: (topic: string) => void;
|
|
1322
|
+
/**
|
|
1323
|
+
* Publishes one message, at most once.
|
|
1324
|
+
*
|
|
1325
|
+
* @throws {Error} When the session is not up.
|
|
1326
|
+
*/
|
|
1327
|
+
publish: (topic: string, payload: string | Buffer) => Promise<void>;
|
|
1328
|
+
/** Closes for good. */
|
|
1329
|
+
close: () => Promise<void>;
|
|
1330
|
+
};
|
|
1331
|
+
/** Opens a managed MQTT session. */
|
|
1332
|
+
type OpenMqtt = (options: ManagedMqttOptions) => ManagedMqtt;
|
|
1333
|
+
/**
|
|
1334
|
+
* The house's MQTT broker, as the hub reaches it: the package that provides `mqtt-broker`, with
|
|
1335
|
+
* the hub's own username - or the broker `NEBULA_MQTT_URL` names. Read again each time it is needed: the broker may start after
|
|
1336
|
+
* the hub, and a bundle that opens a session later finds it then.
|
|
1337
|
+
*/
|
|
1338
|
+
type PlatformMqtt = {
|
|
1339
|
+
readonly url: string;
|
|
1340
|
+
readonly username?: string;
|
|
1341
|
+
readonly password?: string;
|
|
1342
|
+
};
|
|
1343
|
+
/** What the platform offers a bundle beyond the pieces to build a transport from. */
|
|
1344
|
+
type PlatformServices = {
|
|
1345
|
+
/**
|
|
1346
|
+
* The house's broker, for a vendor whose devices report through it - zigbee2mqtt - and which
|
|
1347
|
+
* runs its own program beside the platform. Null on an installation without one.
|
|
1348
|
+
*/
|
|
1349
|
+
readonly mqtt: PlatformMqtt | null;
|
|
1350
|
+
};
|
|
1351
|
+
/** One colour of a palette: red, green, blue and, optionally, how opaque, each 0 to 255. */
|
|
1352
|
+
type PaletteColour = readonly [number, number, number] | readonly [number, number, number, number];
|
|
1353
|
+
/** A picture of a few colours: a robot's map, one palette index per cell. */
|
|
1354
|
+
type PalettedPicture = {
|
|
1355
|
+
readonly width: number;
|
|
1356
|
+
readonly height: number;
|
|
1357
|
+
/** At most 256 colours. */
|
|
1358
|
+
readonly palette: readonly PaletteColour[];
|
|
1359
|
+
/** One index into the palette per pixel, row after row from the top left. */
|
|
1360
|
+
readonly pixels: Uint8Array;
|
|
1361
|
+
};
|
|
1362
|
+
/** What a bundle drawing a picture needs, and could not bring as a dependency. */
|
|
1363
|
+
type BundleCodecs = {
|
|
1364
|
+
/**
|
|
1365
|
+
* Unpacks an LZMA stream in the alone format (`.lzma`): a 13-byte header - the properties and
|
|
1366
|
+
* the size, eight bytes of ones when unknown - then the stream. ECOVACS packs its maps so.
|
|
1367
|
+
*
|
|
1368
|
+
* @throws {Error} When the stream is corrupt.
|
|
1369
|
+
*/
|
|
1370
|
+
readonly lzma: (bytes: Uint8Array) => Buffer;
|
|
1371
|
+
};
|
|
1372
|
+
/** Pictures a bundle draws, for an image entity. */
|
|
1373
|
+
type BundleImages = {
|
|
1374
|
+
/**
|
|
1375
|
+
* Encodes a paletted picture as a PNG, a colour with an alpha below 255 transparent.
|
|
1376
|
+
*
|
|
1377
|
+
* @throws {Error} When the size, the palette and the pixels do not fit together.
|
|
1378
|
+
*/
|
|
1379
|
+
readonly png: (picture: PalettedPicture) => Buffer;
|
|
1380
|
+
};
|
|
1381
|
+
/** What the hub hands a bundle's transport factory. */
|
|
1382
|
+
type BundleSdk = {
|
|
1383
|
+
/** The runtime version, the same string `manifest.sdk` was matched against. */
|
|
1384
|
+
readonly version: string;
|
|
1385
|
+
/** The runtime's zod, so a bundle's schemas validate under the one instance the hub uses. */
|
|
1386
|
+
readonly z: typeof z;
|
|
1387
|
+
/** The hub's logger, for what happens outside a connection: a probe, a scan. */
|
|
1388
|
+
readonly logger: BundleLogger;
|
|
1389
|
+
readonly defineTransport: typeof defineTransport;
|
|
1390
|
+
readonly openWebSocket: OpenWebSocket;
|
|
1391
|
+
readonly openUdpSocket: OpenUdpSocket;
|
|
1392
|
+
/** An MQTT session, for a vendor whose devices report through a broker of its own. */
|
|
1393
|
+
readonly openMqtt: OpenMqtt;
|
|
1394
|
+
/** How a camera's stream source is written, as defineTransport is for a transport. */
|
|
1395
|
+
readonly defineStreamSource: typeof defineStreamSource;
|
|
1396
|
+
/** An RTSP session over TCP, yielding a camera's H.264 as it comes. */
|
|
1397
|
+
readonly openRtsp: OpenRtsp;
|
|
1398
|
+
/** What the platform itself runs that a bundle may use - its MQTT broker. */
|
|
1399
|
+
readonly platform: PlatformServices;
|
|
1400
|
+
/** How an account's sign-in module is written, as defineTransport is for a transport. */
|
|
1401
|
+
readonly defineAccount: typeof defineAccount;
|
|
1402
|
+
/** Unpacking what a vendor's cloud packs. */
|
|
1403
|
+
readonly codecs: BundleCodecs;
|
|
1404
|
+
/** Drawing pictures, for an image entity. */
|
|
1405
|
+
readonly images: BundleImages;
|
|
1406
|
+
};
|
|
1407
|
+
//#endregion
|
|
1408
|
+
//#region ../package-runtime/dist/account.d.ts
|
|
1409
|
+
/** The contents of `account.json`. */
|
|
1410
|
+
declare const accountDeclarationSchema: z.ZodObject<{
|
|
1411
|
+
name: z.ZodString;
|
|
1412
|
+
help: z.ZodOptional<z.ZodString>;
|
|
1413
|
+
fields: z.ZodObject<{
|
|
1414
|
+
constants: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
1415
|
+
fields: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1416
|
+
type: z.ZodLiteral<"text">;
|
|
1417
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
1418
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
1419
|
+
patternMessage: z.ZodOptional<z.ZodString>;
|
|
1420
|
+
minLength: z.ZodOptional<z.ZodInt>;
|
|
1421
|
+
maxLength: z.ZodDefault<z.ZodInt>;
|
|
1422
|
+
default: z.ZodOptional<z.ZodString>;
|
|
1423
|
+
key: z.ZodString;
|
|
1424
|
+
label: z.ZodString;
|
|
1425
|
+
help: z.ZodOptional<z.ZodString>;
|
|
1426
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
1427
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
1428
|
+
key: z.ZodString;
|
|
1429
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
1430
|
+
}, z.core.$strict>>;
|
|
1431
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
1432
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1433
|
+
type: z.ZodLiteral<"secret">;
|
|
1434
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
1435
|
+
patternMessage: z.ZodOptional<z.ZodString>;
|
|
1436
|
+
minLength: z.ZodOptional<z.ZodInt>;
|
|
1437
|
+
maxLength: z.ZodDefault<z.ZodInt>;
|
|
1438
|
+
key: z.ZodString;
|
|
1439
|
+
label: z.ZodString;
|
|
1440
|
+
help: z.ZodOptional<z.ZodString>;
|
|
1441
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
1442
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
1443
|
+
key: z.ZodString;
|
|
1444
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
1445
|
+
}, z.core.$strict>>;
|
|
1446
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
1447
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1448
|
+
type: z.ZodLiteral<"number">;
|
|
1449
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
1450
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
1451
|
+
isInteger: z.ZodDefault<z.ZodBoolean>;
|
|
1452
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
1453
|
+
default: z.ZodOptional<z.ZodNumber>;
|
|
1454
|
+
warnBelow: z.ZodOptional<z.ZodNumber>;
|
|
1455
|
+
warning: z.ZodOptional<z.ZodString>;
|
|
1456
|
+
key: z.ZodString;
|
|
1457
|
+
label: z.ZodString;
|
|
1458
|
+
help: z.ZodOptional<z.ZodString>;
|
|
1459
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
1460
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
1461
|
+
key: z.ZodString;
|
|
1462
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
1463
|
+
}, z.core.$strict>>;
|
|
1464
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
1465
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1466
|
+
type: z.ZodLiteral<"boolean">;
|
|
1467
|
+
default: z.ZodOptional<z.ZodBoolean>;
|
|
1468
|
+
key: z.ZodString;
|
|
1469
|
+
label: z.ZodString;
|
|
1470
|
+
help: z.ZodOptional<z.ZodString>;
|
|
1471
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
1472
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
1473
|
+
key: z.ZodString;
|
|
1474
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
1475
|
+
}, z.core.$strict>>;
|
|
1476
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
1477
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1478
|
+
type: z.ZodLiteral<"choice">;
|
|
1479
|
+
choices: z.ZodArray<z.ZodObject<{
|
|
1480
|
+
value: z.ZodString;
|
|
1481
|
+
label: z.ZodString;
|
|
1482
|
+
}, z.core.$strict>>;
|
|
1483
|
+
default: z.ZodOptional<z.ZodString>;
|
|
1484
|
+
key: z.ZodString;
|
|
1485
|
+
label: z.ZodString;
|
|
1486
|
+
help: z.ZodOptional<z.ZodString>;
|
|
1487
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
1488
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
1489
|
+
key: z.ZodString;
|
|
1490
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
1491
|
+
}, z.core.$strict>>;
|
|
1492
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
1493
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1494
|
+
type: z.ZodLiteral<"list">;
|
|
1495
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
1496
|
+
minItems: z.ZodDefault<z.ZodInt>;
|
|
1497
|
+
maxItems: z.ZodDefault<z.ZodInt>;
|
|
1498
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
1499
|
+
patternMessage: z.ZodOptional<z.ZodString>;
|
|
1500
|
+
key: z.ZodString;
|
|
1501
|
+
label: z.ZodString;
|
|
1502
|
+
help: z.ZodOptional<z.ZodString>;
|
|
1503
|
+
isRequired: z.ZodDefault<z.ZodBoolean>;
|
|
1504
|
+
shownWhen: z.ZodOptional<z.ZodObject<{
|
|
1505
|
+
key: z.ZodString;
|
|
1506
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
1507
|
+
}, z.core.$strict>>;
|
|
1508
|
+
isLive: z.ZodOptional<z.ZodBoolean>;
|
|
1509
|
+
}, z.core.$strict>], "type">>>;
|
|
1510
|
+
}, z.core.$strict>;
|
|
1511
|
+
identity: z.ZodString;
|
|
1512
|
+
module: z.ZodString;
|
|
1513
|
+
}, z.core.$strict>;
|
|
1514
|
+
/** The contents of `account.json`. */
|
|
1515
|
+
type AccountDeclaration = z.output<typeof accountDeclarationSchema>;
|
|
1516
|
+
/** Who an account signed in as: the cloud's id for it, and what its card calls it. */
|
|
1517
|
+
type AccountIdentity = {
|
|
1518
|
+
/** Stable across sign-ins: the account's id at the cloud. What a device remembers. */
|
|
1519
|
+
readonly id: string;
|
|
1520
|
+
/** What its card calls it: the email it was made with. */
|
|
1521
|
+
readonly label: string;
|
|
1522
|
+
};
|
|
1523
|
+
/** Where a sign-in stands, as the module answers it. */
|
|
1524
|
+
type AccountModuleStep =
|
|
1525
|
+
/** Done: who it is, and what to keep - tokens, a user id - for the next start. */
|
|
1526
|
+
{
|
|
1527
|
+
readonly kind: 'connected';
|
|
1528
|
+
readonly identity: AccountIdentity;
|
|
1529
|
+
readonly session: JsonObject;
|
|
1530
|
+
} |
|
|
1531
|
+
/**
|
|
1532
|
+
* The cloud wants something more - a code it emailed, a second factor. `pending` is whatever
|
|
1533
|
+
* the module needs to carry on; it comes back with the answers.
|
|
1534
|
+
*/
|
|
1535
|
+
{
|
|
1536
|
+
readonly kind: 'ask';
|
|
1537
|
+
readonly message: string;
|
|
1538
|
+
readonly fields: readonly SetupField[];
|
|
1539
|
+
readonly pending: JsonObject;
|
|
1540
|
+
} |
|
|
1541
|
+
/** The owner approves on a page of the cloud's; asked again every `pollMs`. */
|
|
1542
|
+
{
|
|
1543
|
+
readonly kind: 'link';
|
|
1544
|
+
readonly message: string;
|
|
1545
|
+
readonly url: string;
|
|
1546
|
+
readonly code?: string;
|
|
1547
|
+
readonly pollMs: number;
|
|
1548
|
+
readonly pending: JsonObject;
|
|
1549
|
+
} |
|
|
1550
|
+
/** It did not work, and why; `field` is the one to correct, when one is to blame. */
|
|
1551
|
+
{
|
|
1552
|
+
readonly kind: 'failed';
|
|
1553
|
+
readonly message: string;
|
|
1554
|
+
readonly field?: string;
|
|
1555
|
+
};
|
|
1556
|
+
/** What a sign-in step is handed beside its arguments. */
|
|
1557
|
+
type AccountStepContext = {
|
|
1558
|
+
/** Ends the step: the owner gave up, or it took too long. */
|
|
1559
|
+
readonly signal: AbortSignal;
|
|
1560
|
+
};
|
|
1561
|
+
/** What signing in to a vendor's account does, as its module writes it. */
|
|
1562
|
+
type AccountModule = {
|
|
1563
|
+
/**
|
|
1564
|
+
* Signs in with what the owner typed, secrets opened.
|
|
1565
|
+
*
|
|
1566
|
+
* @returns Where it stands.
|
|
1567
|
+
*/
|
|
1568
|
+
readonly signIn: (values: JsonObject, context: AccountStepContext) => Promise<AccountModuleStep>;
|
|
1569
|
+
/**
|
|
1570
|
+
* Carries on after a question, with its answers.
|
|
1571
|
+
*
|
|
1572
|
+
* @returns Where it stands now; the same question again, with why, for a wrong answer.
|
|
1573
|
+
*/
|
|
1574
|
+
readonly answer: (pending: JsonObject, answers: JsonObject, context: AccountStepContext) => Promise<AccountModuleStep>;
|
|
1575
|
+
/**
|
|
1576
|
+
* Asks whether the page the owner was sent to was approved.
|
|
1577
|
+
*
|
|
1578
|
+
* @returns `link` again while it was not.
|
|
1579
|
+
*/
|
|
1580
|
+
readonly poll?: (pending: JsonObject, context: AccountStepContext) => Promise<AccountModuleStep>;
|
|
1581
|
+
/**
|
|
1582
|
+
* Tells the cloud the account is forgotten, when the cloud has a way to: a token revoked.
|
|
1583
|
+
* Failing is not refusing - the account is forgotten here all the same.
|
|
1584
|
+
*/
|
|
1585
|
+
readonly signOut?: (session: JsonObject, context: AccountStepContext) => Promise<void>;
|
|
1586
|
+
};
|
|
1587
|
+
/**
|
|
1588
|
+
* Declares what signing in to a vendor's account does. The identity function, as
|
|
1589
|
+
* `defineTransport` is: what it adds is the type, for a module written in JavaScript.
|
|
1590
|
+
*
|
|
1591
|
+
* @param module - The steps.
|
|
1592
|
+
* @returns The same steps.
|
|
1593
|
+
*/
|
|
1594
|
+
declare function defineAccount(module: AccountModule): AccountModule;
|
|
1595
|
+
/**
|
|
1596
|
+
* One account signed in to, as a vendor's transport and listener are handed it.
|
|
1597
|
+
*
|
|
1598
|
+
* `credentials` are what the owner typed, secrets opened - for a module that signs in again with
|
|
1599
|
+
* the password when the session expired; `session` is what the last sign-in kept. A transport
|
|
1600
|
+
* that finds the session refused signs in again and keeps the new one (`update`); one that cannot
|
|
1601
|
+
* - the cloud wants the owner again - says so (`needsSignIn`), and the account's card asks.
|
|
1602
|
+
*/
|
|
1603
|
+
type AccountHandle = {
|
|
1604
|
+
readonly id: string;
|
|
1605
|
+
readonly label: string;
|
|
1606
|
+
readonly status: 'connected' | 'needs-sign-in' | 'failed';
|
|
1607
|
+
readonly credentials: JsonObject;
|
|
1608
|
+
readonly session: JsonObject;
|
|
1609
|
+
/**
|
|
1610
|
+
* Keeps a new session - tokens renewed - for this run and the next.
|
|
1611
|
+
*
|
|
1612
|
+
* @returns Once it is stored.
|
|
1613
|
+
*/
|
|
1614
|
+
readonly update: (session: JsonObject) => Promise<void>;
|
|
1615
|
+
/**
|
|
1616
|
+
* Says the account needs the owner to sign in again, and why; its devices stop until then.
|
|
1617
|
+
*
|
|
1618
|
+
* @returns Once it is recorded.
|
|
1619
|
+
*/
|
|
1620
|
+
readonly needsSignIn: (message: string) => Promise<void>;
|
|
1621
|
+
};
|
|
1622
|
+
//#endregion
|
|
1623
|
+
//#region ../package-runtime/dist/bundle.d.ts
|
|
1624
|
+
/**
|
|
1625
|
+
* The contents of `manifest.json`: what a vendor says about itself.
|
|
1626
|
+
*
|
|
1627
|
+
* Nothing here is about how a device is reached. Which transports the vendor speaks is
|
|
1628
|
+
* derived from its drivers when the bundle is loaded rather than declared, because a declared
|
|
1629
|
+
* `hasMqtt` is a second statement of a fact the drivers already make, and one that can be wrong.
|
|
1630
|
+
*/
|
|
1631
|
+
declare const vendorManifestSchema: z.ZodObject<{
|
|
1632
|
+
id: z.ZodString;
|
|
1633
|
+
version: z.ZodString;
|
|
1634
|
+
sdk: z.ZodString;
|
|
1635
|
+
name: z.ZodString;
|
|
1636
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1637
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
1638
|
+
color: z.ZodOptional<z.ZodString>;
|
|
1639
|
+
logo: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
1640
|
+
path: z.ZodString;
|
|
1641
|
+
padding: z.ZodDefault<z.ZodInt>;
|
|
1642
|
+
}, z.core.$strict>]>, z.ZodTransform<{
|
|
1643
|
+
path: string;
|
|
1644
|
+
padding: number;
|
|
1645
|
+
}, string | {
|
|
1646
|
+
path: string;
|
|
1647
|
+
padding: number;
|
|
1648
|
+
}>>>;
|
|
1649
|
+
internetRequired: z.ZodDefault<z.ZodBoolean>;
|
|
1650
|
+
setup: z.ZodOptional<z.ZodString>;
|
|
1651
|
+
account: z.ZodOptional<z.ZodString>;
|
|
1652
|
+
transports: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
1653
|
+
module: z.ZodString;
|
|
1654
|
+
wires: z.ZodArray<z.ZodEnum<{
|
|
1655
|
+
http: "http";
|
|
1656
|
+
mqtt: "mqtt";
|
|
1657
|
+
ble: "ble";
|
|
1658
|
+
zigbee: "zigbee";
|
|
1659
|
+
udp: "udp";
|
|
1660
|
+
modbus: "modbus";
|
|
1661
|
+
}>>;
|
|
1662
|
+
}, z.core.$strict>]>>>;
|
|
1663
|
+
streams: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1664
|
+
containers: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1665
|
+
id: z.ZodString;
|
|
1666
|
+
name: z.ZodString;
|
|
1667
|
+
image: z.ZodString;
|
|
1668
|
+
minVersion: z.ZodString;
|
|
1669
|
+
volumes: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1670
|
+
name: z.ZodString;
|
|
1671
|
+
path: z.ZodString;
|
|
1672
|
+
cache: z.ZodDefault<z.ZodBoolean>;
|
|
1673
|
+
}, z.core.$strict>>>;
|
|
1674
|
+
env: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1675
|
+
name: z.ZodString;
|
|
1676
|
+
value: z.ZodString;
|
|
1677
|
+
when: z.ZodOptional<z.ZodObject<{
|
|
1678
|
+
key: z.ZodString;
|
|
1679
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
1680
|
+
}, z.core.$strict>>;
|
|
1681
|
+
}, z.core.$strict>>>;
|
|
1682
|
+
devices: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1683
|
+
host: z.ZodString;
|
|
1684
|
+
container: z.ZodString;
|
|
1685
|
+
when: z.ZodOptional<z.ZodObject<{
|
|
1686
|
+
key: z.ZodString;
|
|
1687
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
1688
|
+
}, z.core.$strict>>;
|
|
1689
|
+
}, z.core.$strict>>>;
|
|
1690
|
+
ports: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1691
|
+
container: z.ZodUnion<readonly [z.ZodInt, z.ZodString]>;
|
|
1692
|
+
host: z.ZodUnion<readonly [z.ZodInt, z.ZodString]>;
|
|
1693
|
+
protocol: z.ZodDefault<z.ZodEnum<{
|
|
1694
|
+
tcp: "tcp";
|
|
1695
|
+
udp: "udp";
|
|
1696
|
+
}>>;
|
|
1697
|
+
when: z.ZodOptional<z.ZodObject<{
|
|
1698
|
+
key: z.ZodString;
|
|
1699
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
1700
|
+
}, z.core.$strict>>;
|
|
1701
|
+
}, z.core.$strict>>>;
|
|
1702
|
+
seed: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1703
|
+
volume: z.ZodString;
|
|
1704
|
+
path: z.ZodString;
|
|
1705
|
+
content: z.ZodString;
|
|
1706
|
+
}, z.core.$strict>>>;
|
|
1707
|
+
mqttTopics: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1708
|
+
webPort: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodString]>>;
|
|
1709
|
+
webPortWhen: z.ZodOptional<z.ZodObject<{
|
|
1710
|
+
key: z.ZodString;
|
|
1711
|
+
equals: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
1712
|
+
}, z.core.$strict>>;
|
|
1713
|
+
command: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1714
|
+
healthcheck: z.ZodOptional<z.ZodObject<{
|
|
1715
|
+
test: z.ZodArray<z.ZodString>;
|
|
1716
|
+
intervalMs: z.ZodOptional<z.ZodInt>;
|
|
1717
|
+
timeoutMs: z.ZodOptional<z.ZodInt>;
|
|
1718
|
+
retries: z.ZodOptional<z.ZodInt>;
|
|
1719
|
+
startPeriodMs: z.ZodOptional<z.ZodInt>;
|
|
1720
|
+
}, z.core.$strict>>;
|
|
1721
|
+
dependsOn: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
1722
|
+
started: "started";
|
|
1723
|
+
healthy: "healthy";
|
|
1724
|
+
}>>>;
|
|
1725
|
+
}, z.core.$strict>>>;
|
|
1726
|
+
requires: z.ZodDefault<z.ZodObject<{
|
|
1727
|
+
platform: z.ZodOptional<z.ZodString>;
|
|
1728
|
+
packages: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1729
|
+
services: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
1730
|
+
}, z.core.$strict>>;
|
|
1731
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
1732
|
+
signature: z.ZodOptional<z.ZodString>;
|
|
1733
|
+
}, z.core.$strict>;
|
|
1734
|
+
/** The contents of `manifest.json`. */
|
|
1735
|
+
type VendorManifest = z.output<typeof vendorManifestSchema>;
|
|
1736
|
+
/**
|
|
1737
|
+
* A driver as the runtime reads it: its own manifest joined with its vendor's.
|
|
1738
|
+
*
|
|
1739
|
+
* This is what every other part of the runtime and `hub` is written against, and what a test
|
|
1740
|
+
* builds by hand when it wants an integration without a directory. It is never read from a
|
|
1741
|
+
* file; {@link resolveManifest} composes it.
|
|
1742
|
+
*/
|
|
1743
|
+
declare const bundleManifestSchema: z.ZodObject<{
|
|
1744
|
+
transport: z.ZodString;
|
|
1745
|
+
models: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
1746
|
+
modelCodes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
|
|
1747
|
+
modelSeries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1748
|
+
kind: z.ZodEnum<{
|
|
1749
|
+
declarative: "declarative";
|
|
1750
|
+
code: "code";
|
|
1751
|
+
}>;
|
|
1752
|
+
defaultIcon: z.ZodOptional<z.ZodString>;
|
|
1753
|
+
webPagePort: z.ZodOptional<z.ZodInt>;
|
|
1754
|
+
webPagePath: z.ZodOptional<z.ZodString>;
|
|
1755
|
+
profile: z.ZodOptional<z.ZodString>;
|
|
1756
|
+
entry: z.ZodOptional<z.ZodString>;
|
|
1757
|
+
setup: z.ZodString;
|
|
1758
|
+
id: z.ZodString;
|
|
1759
|
+
version: z.ZodString;
|
|
1760
|
+
sdk: z.ZodString;
|
|
1761
|
+
name: z.ZodString;
|
|
1762
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1763
|
+
vendor: z.ZodObject<{
|
|
1764
|
+
id: z.ZodString;
|
|
1765
|
+
name: z.ZodString;
|
|
1766
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
1767
|
+
}, z.core.$strict>;
|
|
1768
|
+
}, z.core.$strict>;
|
|
1769
|
+
/** A driver as the runtime reads it. */
|
|
1770
|
+
type BundleManifest = z.output<typeof bundleManifestSchema>;
|
|
1771
|
+
//#endregion
|
|
1772
|
+
//#region ../package-runtime/dist/profile.d.ts
|
|
1773
|
+
/**
|
|
1774
|
+
* A value in a request template: a literal, or a path into the command.
|
|
1775
|
+
*
|
|
1776
|
+
* Recursive, so a nested query object can carry a path at any depth. Declared with an explicit
|
|
1777
|
+
* annotation for the same reason `jsonValueSchema` is: TypeScript cannot infer the type of a
|
|
1778
|
+
* schema that refers to itself.
|
|
1779
|
+
*/
|
|
1780
|
+
type TemplateValue = string | number | boolean | null | TemplateReference | TemplateValue[] | {
|
|
1781
|
+
readonly [key: string]: TemplateValue;
|
|
1782
|
+
};
|
|
1783
|
+
/** A path into the command, with what to do to what it names; see `templateReferenceSchema`. */
|
|
1784
|
+
type TemplateReference = {
|
|
1785
|
+
readonly $: string;
|
|
1786
|
+
readonly scale?: number | undefined;
|
|
1787
|
+
readonly decimals?: number | undefined;
|
|
1788
|
+
readonly min?: number | undefined;
|
|
1789
|
+
readonly max?: number | undefined;
|
|
1790
|
+
readonly optional?: boolean | undefined;
|
|
1791
|
+
};
|
|
1792
|
+
//#endregion
|
|
1793
|
+
//#region ../package-runtime/dist/discovery.d.ts
|
|
1794
|
+
/** Validates a whole `discovery.json`. */
|
|
1795
|
+
declare const vendorDiscoverySchema: z.ZodObject<{
|
|
1796
|
+
listen: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
1797
|
+
mdns: z.ZodString;
|
|
1798
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1799
|
+
module: z.ZodString;
|
|
1800
|
+
lan: z.ZodDefault<z.ZodBoolean>;
|
|
1801
|
+
}, z.core.$strict>]>>;
|
|
1802
|
+
match: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
1803
|
+
path: z.ZodString;
|
|
1804
|
+
equals: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
1805
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1806
|
+
path: z.ZodString;
|
|
1807
|
+
exists: z.ZodLiteral<true>;
|
|
1808
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1809
|
+
path: z.ZodString;
|
|
1810
|
+
oneOf: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
1811
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1812
|
+
path: z.ZodString;
|
|
1813
|
+
startsWith: z.ZodString;
|
|
1814
|
+
}, z.core.$strict>]>>>;
|
|
1815
|
+
probe: z.ZodOptional<z.ZodObject<{
|
|
1816
|
+
transport: z.ZodString;
|
|
1817
|
+
op: z.ZodString;
|
|
1818
|
+
args: z.ZodDefault<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
1819
|
+
timeoutMs: z.ZodOptional<z.ZodInt>;
|
|
1820
|
+
}, z.core.$strict>>;
|
|
1821
|
+
identity: z.ZodObject<{
|
|
1822
|
+
model: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
1823
|
+
externalId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
1824
|
+
name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
1825
|
+
swVersion: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
1826
|
+
}, z.core.$strict>;
|
|
1827
|
+
adopt: z.ZodDefault<z.ZodEnum<{
|
|
1828
|
+
owner: "owner";
|
|
1829
|
+
automatic: "automatic";
|
|
1830
|
+
}>>;
|
|
1831
|
+
pairing: z.ZodOptional<z.ZodObject<{
|
|
1832
|
+
driver: z.ZodString;
|
|
1833
|
+
open: z.ZodString;
|
|
1834
|
+
close: z.ZodString;
|
|
1835
|
+
state: z.ZodString;
|
|
1836
|
+
}, z.core.$strict>>;
|
|
1837
|
+
}, z.core.$strict>;
|
|
1838
|
+
/** A whole `discovery.json`, parsed. */
|
|
1839
|
+
type VendorDiscovery = z.output<typeof vendorDiscoverySchema>;
|
|
1840
|
+
/** A driver, as far as discovery needs one: its name, its models and their codes. */
|
|
1841
|
+
type DiscoveryDriver = {
|
|
1842
|
+
readonly id: string;
|
|
1843
|
+
/** The driver's own name, offered as its one model when it lists none. */
|
|
1844
|
+
readonly name: string;
|
|
1845
|
+
readonly models: readonly string[];
|
|
1846
|
+
readonly modelCodes?: Readonly<Record<string, string | readonly string[]>> | undefined;
|
|
1847
|
+
};
|
|
1848
|
+
/** A vendor's discovery, checked against its drivers and ready to answer. */
|
|
1849
|
+
type DiscoveryPlan = {
|
|
1850
|
+
readonly vendorId: string;
|
|
1851
|
+
readonly discovery: VendorDiscovery;
|
|
1852
|
+
readonly drivers: readonly DiscoveryDriver[];
|
|
1853
|
+
/** Every code any driver maps, and the drivers and models it names, in load order. */
|
|
1854
|
+
readonly codes: ReadonlyMap<string, readonly CodedModels[]>;
|
|
1855
|
+
};
|
|
1856
|
+
/** What one driver maps one code onto. */
|
|
1857
|
+
type CodedModels = {
|
|
1858
|
+
readonly driverId: string;
|
|
1859
|
+
readonly models: readonly string[];
|
|
1860
|
+
};
|
|
1861
|
+
/** Who a sighted device says it is. Each field is null when it did not say. */
|
|
1862
|
+
type SightingIdentity = {
|
|
1863
|
+
readonly externalId: string | null;
|
|
1864
|
+
readonly name: string | null;
|
|
1865
|
+
readonly modelCode: string | null;
|
|
1866
|
+
readonly swVersion: string | null;
|
|
1867
|
+
};
|
|
1868
|
+
/** The driver a device belongs to, and which of its models it is. */
|
|
1869
|
+
type Association = {
|
|
1870
|
+
readonly driverId: string;
|
|
1871
|
+
/** The model, when it is certain; null when the owner has to pick among the choices. */
|
|
1872
|
+
readonly model: string | null;
|
|
1873
|
+
/** What the owner may pick from: the family a code names, or every model of the driver. */
|
|
1874
|
+
readonly modelChoices: readonly string[];
|
|
1875
|
+
};
|
|
1876
|
+
/**
|
|
1877
|
+
* What a listening source heard: a device, how to reach it, and what it said.
|
|
1878
|
+
*
|
|
1879
|
+
* `config` is what reaches it in the transport's own terms - `{ host }` - and becomes the
|
|
1880
|
+
* device's connection once adopted. `payload` is what identity and match read.
|
|
1881
|
+
*/
|
|
1882
|
+
type Sighting = {
|
|
1883
|
+
readonly config: JsonObject;
|
|
1884
|
+
readonly payload: JsonObject;
|
|
1885
|
+
};
|
|
1886
|
+
/** How a listener is getting on, as the vendor's page says it. */
|
|
1887
|
+
type ListenerStatus = {
|
|
1888
|
+
/** `ok` hears what it listens to; `warning` listens but hears nothing; `error` cannot listen. */
|
|
1889
|
+
readonly level: 'ok' | 'warning' | 'error';
|
|
1890
|
+
/** A sentence for the owner: where it listens, and what to look at when it hears nothing. */
|
|
1891
|
+
readonly message: string;
|
|
1892
|
+
};
|
|
1893
|
+
/**
|
|
1894
|
+
* A device a listener heard and does not report, and why: one its vendor does not support, one
|
|
1895
|
+
* still being paired. The vendor's page lists them, so "why is my device not here" has an answer.
|
|
1896
|
+
*/
|
|
1897
|
+
type PassedOverSighting = {
|
|
1898
|
+
/** What tells it from the others: its IEEE address, its id on the account. */
|
|
1899
|
+
readonly id: string;
|
|
1900
|
+
readonly name: string;
|
|
1901
|
+
readonly model?: string | null;
|
|
1902
|
+
/** Why it is not added, in a sentence: `Zigbee2MQTT is still pairing it`. */
|
|
1903
|
+
readonly reason: string;
|
|
1904
|
+
};
|
|
1905
|
+
/** What the hub hands a listener beside the signal. */
|
|
1906
|
+
type DiscoveryListenContext = {
|
|
1907
|
+
/**
|
|
1908
|
+
* Reads what the owner saved for the vendor - an account, a key - secrets opened, for a
|
|
1909
|
+
* listener that asks a cloud which devices the account has. Read it at every pass rather than
|
|
1910
|
+
* once: a change the owner saves is then heard without the listener being started again.
|
|
1911
|
+
*
|
|
1912
|
+
* @returns The vendor's settings; empty while it is not set up.
|
|
1913
|
+
*/
|
|
1914
|
+
readonly settings: () => Promise<JsonObject>;
|
|
1915
|
+
/**
|
|
1916
|
+
* Says how listening goes - connected to a broker but hearing nothing, unable to
|
|
1917
|
+
* reach it - which the vendor's page shows. The last one said stands until the next. Optional
|
|
1918
|
+
* for the hub to offer, so a listener calls it as `context.status?.(…)`.
|
|
1919
|
+
*/
|
|
1920
|
+
readonly status?: (status: ListenerStatus) => void;
|
|
1921
|
+
/**
|
|
1922
|
+
* Every device the listener hears and does not report, the whole list each time -
|
|
1923
|
+
* it replaces the last one. Optional for the hub to offer, like `status`.
|
|
1924
|
+
*/
|
|
1925
|
+
readonly passedOver?: (devices: readonly PassedOverSighting[]) => void;
|
|
1926
|
+
/**
|
|
1927
|
+
* Every account of the vendor signed in to, for a listener that asks each which
|
|
1928
|
+
* devices it has. Read it at every pass, like the settings: an account added is heard then.
|
|
1929
|
+
*
|
|
1930
|
+
* @returns The accounts; none for a vendor without, or before one is signed in to.
|
|
1931
|
+
*/
|
|
1932
|
+
readonly accounts?: () => Promise<readonly AccountHandle[]>;
|
|
1933
|
+
};
|
|
1934
|
+
/** A vendor's own listener, for a protocol the platform does not speak. */
|
|
1935
|
+
type DiscoverySource = {
|
|
1936
|
+
/**
|
|
1937
|
+
* Listens until the signal ends it, reporting every device heard.
|
|
1938
|
+
*
|
|
1939
|
+
* @param signal - Ends the listening.
|
|
1940
|
+
* @param context - The vendor's settings, for a listener that needs them.
|
|
1941
|
+
* @returns Every sighting, as it happens. The same device may be reported again.
|
|
1942
|
+
*/
|
|
1943
|
+
listen: (signal: AbortSignal, context: DiscoveryListenContext) => AsyncIterable<Sighting>;
|
|
1944
|
+
/**
|
|
1945
|
+
* Asks the network again now, rather than at the listener's own next pass: what the owner's
|
|
1946
|
+
* "look for devices" reaches. Optional, for a listener that only ever hears announcements and
|
|
1947
|
+
* has nothing to ask. Answers arrive through `listen`, like every other sighting.
|
|
1948
|
+
*/
|
|
1949
|
+
scan?: () => void;
|
|
1950
|
+
};
|
|
1951
|
+
//#endregion
|
|
1952
|
+
//#region ../package-runtime/dist/install-marker.d.ts
|
|
1953
|
+
/** The contents of `.nebula-install.json`. */
|
|
1954
|
+
type InstallMarker = IntegrationInstall;
|
|
1955
|
+
//#endregion
|
|
1956
|
+
//#region ../package-runtime/dist/loader.d.ts
|
|
1957
|
+
/** A driver that loaded. */
|
|
1958
|
+
type LoadedBundle = {
|
|
1959
|
+
/** The driver's manifest joined with its vendor's, keyed by the kind. */
|
|
1960
|
+
readonly manifest: BundleManifest;
|
|
1961
|
+
readonly vendorId: string;
|
|
1962
|
+
readonly driverId: string;
|
|
1963
|
+
/** The driver's own name, without the vendor's in front: `Gen2`, `Printer`. */
|
|
1964
|
+
readonly driverName: string;
|
|
1965
|
+
readonly integration: Integration;
|
|
1966
|
+
/** What setting up an instance asks, for the catalogue to serve and the API to check against. */
|
|
1967
|
+
readonly setup: IntegrationSetup;
|
|
1968
|
+
/** Where it was read from, for a message that has to name it. */
|
|
1969
|
+
readonly directory: string;
|
|
1970
|
+
};
|
|
1971
|
+
/**
|
|
1972
|
+
* Which of the two places a vendor was read from.
|
|
1973
|
+
*
|
|
1974
|
+
* `installed` is the data directory's `hub/integrations`: where the platform installs a vendor
|
|
1975
|
+
* from the integrations index or its local folder, and the only place a production hub reads.
|
|
1976
|
+
* `development` is a directory of bundles under development - an integration repository's
|
|
1977
|
+
* `dist/`, named in the hub's `HUB_DEV_BUNDLE_DIR` - read beside it.
|
|
1978
|
+
*/
|
|
1979
|
+
type BundleOrigin = 'development' | 'installed';
|
|
1980
|
+
/** Where a vendor's devices announce themselves, ready to listen to. */
|
|
1981
|
+
type LoadedListenSource = {
|
|
1982
|
+
readonly kind: 'mdns';
|
|
1983
|
+
readonly service: string;
|
|
1984
|
+
} | {
|
|
1985
|
+
readonly kind: 'module';
|
|
1986
|
+
readonly file: string;
|
|
1987
|
+
readonly source: DiscoverySource;
|
|
1988
|
+
/** Whether it listens on the house's network, and is off where the hub cannot hear it. */
|
|
1989
|
+
readonly lan: boolean;
|
|
1990
|
+
};
|
|
1991
|
+
/** How a vendor's devices are found: its plan, checked against its drivers, and its sources. */
|
|
1992
|
+
type LoadedDiscovery = {
|
|
1993
|
+
readonly plan: DiscoveryPlan;
|
|
1994
|
+
readonly sources: readonly LoadedListenSource[];
|
|
1995
|
+
};
|
|
1996
|
+
/** A vendor's account: what signing in asks, and the module that does it. */
|
|
1997
|
+
type LoadedAccount = {
|
|
1998
|
+
readonly declaration: AccountDeclaration;
|
|
1999
|
+
readonly module: AccountModule;
|
|
2000
|
+
};
|
|
2001
|
+
/** A vendor that loaded, with the drivers of it that did. */
|
|
2002
|
+
type LoadedVendor = {
|
|
2003
|
+
readonly manifest: VendorManifest;
|
|
2004
|
+
/** Which of the two places it was read from. */
|
|
2005
|
+
readonly origin: BundleOrigin;
|
|
2006
|
+
/** How the platform installed it, for one it did: its marker. */
|
|
2007
|
+
readonly install?: InstallMarker;
|
|
2008
|
+
/** What setting the vendor up asks; empty groups when it asks for nothing. */
|
|
2009
|
+
readonly setup: IntegrationSetup;
|
|
2010
|
+
/** The logo as an image data URL, when the bundle ships one. */
|
|
2011
|
+
readonly logo?: string;
|
|
2012
|
+
/** Every transport one of its drivers speaks, each once, in the drivers' order. */
|
|
2013
|
+
readonly transports: readonly string[];
|
|
2014
|
+
/** The wires its devices are reached over, for its card: see {@link wiresOf}. */
|
|
2015
|
+
readonly wires: readonly TransportWire[];
|
|
2016
|
+
/** The transports the vendor ships itself, ready to register: `shelly/rpc`. */
|
|
2017
|
+
readonly ownTransports: readonly Transport[];
|
|
2018
|
+
/** The stream sources the vendor ships, ready to register: `bambulab/camera`. */
|
|
2019
|
+
readonly streams: readonly StreamSource[];
|
|
2020
|
+
readonly drivers: readonly LoadedBundle[];
|
|
2021
|
+
/** How its devices are found, when it has a `discovery.json` that loaded. */
|
|
2022
|
+
readonly discovery?: LoadedDiscovery;
|
|
2023
|
+
/**
|
|
2024
|
+
* The account its devices are reached through, when it has an `account.json` - what
|
|
2025
|
+
* signing in asks, and the module that signs in.
|
|
2026
|
+
*/
|
|
2027
|
+
readonly account?: LoadedAccount;
|
|
2028
|
+
/** Where it was read from, for a message that has to name it. */
|
|
2029
|
+
readonly directory: string;
|
|
2030
|
+
/**
|
|
2031
|
+
* Lets go of what the vendor's code holds: every UDP socket it opened.
|
|
2032
|
+
*
|
|
2033
|
+
* @returns A promise that settles once every port it held is free.
|
|
2034
|
+
*/
|
|
2035
|
+
readonly release: () => Promise<void>;
|
|
2036
|
+
};
|
|
2037
|
+
/** A vendor or a driver that did not load, and why. */
|
|
2038
|
+
type BundleFailure = {
|
|
2039
|
+
readonly directory: string;
|
|
2040
|
+
readonly message: string;
|
|
2041
|
+
/** The vendor it belongs to - its folder's name - when the failure is inside one. */
|
|
2042
|
+
readonly vendorId?: string;
|
|
2043
|
+
};
|
|
2044
|
+
//#endregion
|
|
2045
|
+
export { TransportSubscription as C, CapabilityState as D, CapabilityName as E, TransportRequest as S, JsonObject as T, Claim as _, LoadedListenSource as a, ReportedState as b, SightingIdentity as c, ManagedSocketClose as d, ManagedSocketHeaders as f, UdpPeer as g, PlatformServices as h, LoadedDiscovery as i, TemplateValue as l, ManagedUdpSocketOptions as m, LoadedAccount as n, LoadedVendor as o, ManagedSocketOptions as p, LoadedBundle as r, Association as s, BundleFailure as t, BundleSdk as u, DeviceDescriptor as v, EntityId as w, Discovered as x, Integration as y };
|