@nebulahome/integration-sdk 1.5.0 → 1.6.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 +26 -0
- package/FILES.md +191 -1
- package/README.md +7 -4
- package/dist/chunks/node-dist.js +1163 -47
- package/dist/chunks/node-index.d.ts +428 -21
- package/dist/chunks/node-project.js +928 -10
- package/dist/chunks/node-rolldown-runtime.js +10 -1
- package/dist/index.d.ts +509 -9
- package/dist/index.js +51 -1
- package/dist/schemas.d.ts +103 -18
- package/dist/schemas.js +1 -1
- package/dist/testing.d.ts +86 -2
- package/dist/testing.js +44 -2
- package/package.json +5 -5
- package/schemas/discovery.schema.json +394 -0
- package/schemas/driver.schema.json +76 -1
- package/schemas/manifest.schema.json +5 -2
- package/schemas/profile.schema.json +66 -0
package/dist/schemas.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { k as JsonObject, l as TemplateValue } from "./chunks/node-index.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region src/schemas.d.ts
|
|
4
4
|
/** Each file's schema, by the name its JSON Schema is written under. */
|
|
@@ -21,8 +21,8 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
21
21
|
}>>>;
|
|
22
22
|
internetRequired: z.ZodDefault<z.ZodBoolean>;
|
|
23
23
|
twins: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
24
|
-
mac: "mac";
|
|
25
24
|
serial: "serial";
|
|
25
|
+
mac: "mac";
|
|
26
26
|
}>>>;
|
|
27
27
|
setup: z.ZodOptional<z.ZodString>;
|
|
28
28
|
account: z.ZodOptional<z.ZodString>;
|
|
@@ -33,9 +33,12 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
33
33
|
matter: "matter";
|
|
34
34
|
mqtt: "mqtt";
|
|
35
35
|
modbus: "modbus";
|
|
36
|
+
serial: "serial";
|
|
36
37
|
http: "http";
|
|
37
38
|
ble: "ble";
|
|
38
39
|
zigbee: "zigbee";
|
|
40
|
+
thread: "thread";
|
|
41
|
+
ir: "ir";
|
|
39
42
|
}>>;
|
|
40
43
|
}, z.core.$strict>]>>>;
|
|
41
44
|
streams: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
@@ -118,6 +121,9 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
118
121
|
matter: "matter";
|
|
119
122
|
mqtt: "mqtt";
|
|
120
123
|
modbus: "modbus";
|
|
124
|
+
infrared: "infrared";
|
|
125
|
+
serial: "serial";
|
|
126
|
+
bluetooth: "bluetooth";
|
|
121
127
|
}>;
|
|
122
128
|
defaultIcon: z.ZodOptional<z.ZodString>;
|
|
123
129
|
webPagePort: z.ZodOptional<z.ZodInt>;
|
|
@@ -125,6 +131,23 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
125
131
|
profile: z.ZodOptional<z.ZodString>;
|
|
126
132
|
entry: z.ZodOptional<z.ZodString>;
|
|
127
133
|
template: z.ZodOptional<z.ZodString>;
|
|
134
|
+
serial: z.ZodOptional<z.ZodObject<{
|
|
135
|
+
baudRate: z.ZodInt;
|
|
136
|
+
dataBits: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<5>, z.ZodLiteral<6>, z.ZodLiteral<7>, z.ZodLiteral<8>]>>;
|
|
137
|
+
parity: z.ZodDefault<z.ZodEnum<{
|
|
138
|
+
none: "none";
|
|
139
|
+
even: "even";
|
|
140
|
+
odd: "odd";
|
|
141
|
+
mark: "mark";
|
|
142
|
+
space: "space";
|
|
143
|
+
}>>;
|
|
144
|
+
stopBits: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<1.5>, z.ZodLiteral<2>]>>;
|
|
145
|
+
flowControl: z.ZodDefault<z.ZodEnum<{
|
|
146
|
+
none: "none";
|
|
147
|
+
rtscts: "rtscts";
|
|
148
|
+
xonxoff: "xonxoff";
|
|
149
|
+
}>>;
|
|
150
|
+
}, z.core.$strict>>;
|
|
128
151
|
setup: z.ZodString;
|
|
129
152
|
id: z.ZodString;
|
|
130
153
|
name: z.ZodString;
|
|
@@ -409,24 +432,24 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
409
432
|
capabilities: z.ZodRecord<z.ZodEnum<{
|
|
410
433
|
number: "number";
|
|
411
434
|
custom: "custom";
|
|
412
|
-
|
|
413
|
-
button: "button";
|
|
414
|
-
sensor_numeric: "sensor_numeric";
|
|
415
|
-
sensor_text: "sensor_text";
|
|
416
|
-
sensor_binary: "sensor_binary";
|
|
417
|
-
on_off: "on_off";
|
|
435
|
+
image: "image";
|
|
418
436
|
level: "level";
|
|
437
|
+
on_off: "on_off";
|
|
419
438
|
color_hs: "color_hs";
|
|
420
439
|
color_temp: "color_temp";
|
|
421
440
|
cover: "cover";
|
|
422
441
|
lock: "lock";
|
|
423
442
|
thermostat: "thermostat";
|
|
443
|
+
sensor_numeric: "sensor_numeric";
|
|
444
|
+
sensor_binary: "sensor_binary";
|
|
445
|
+
sensor_text: "sensor_text";
|
|
424
446
|
media_player: "media_player";
|
|
425
447
|
camera: "camera";
|
|
448
|
+
button: "button";
|
|
426
449
|
update: "update";
|
|
427
450
|
lawn_mower: "lawn_mower";
|
|
451
|
+
select: "select";
|
|
428
452
|
vacuum: "vacuum";
|
|
429
|
-
image: "image";
|
|
430
453
|
}> & z.core.$partial, z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
431
454
|
state: z.ZodRecord<z.ZodEnum<{
|
|
432
455
|
number: "number";
|
|
@@ -561,6 +584,16 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
561
584
|
minIntervalMs: z.ZodDefault<z.ZodInt>;
|
|
562
585
|
}, z.core.$strict>>;
|
|
563
586
|
}, z.core.$strict>>;
|
|
587
|
+
infrared: z.ZodOptional<z.ZodObject<{
|
|
588
|
+
signals: z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"ir">], null>, z.ZodTuple<[z.ZodLiteral<"ir">, z.ZodLiteral<"rf">], null>]>;
|
|
589
|
+
receives: z.ZodBoolean;
|
|
590
|
+
}, z.core.$strict>>;
|
|
591
|
+
bluetoothProxy: z.ZodOptional<z.ZodObject<{
|
|
592
|
+
modes: z.ZodArray<z.ZodEnum<{
|
|
593
|
+
passive: "passive";
|
|
594
|
+
active: "active";
|
|
595
|
+
}>>;
|
|
596
|
+
}, z.core.$strict>>;
|
|
564
597
|
}, z.core.$strict>;
|
|
565
598
|
readonly discovery: z.ZodObject<{
|
|
566
599
|
listen: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -703,6 +736,58 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
703
736
|
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
704
737
|
}, z.core.$strict>>>;
|
|
705
738
|
}, z.core.$strict>>;
|
|
739
|
+
serial: z.ZodOptional<z.ZodObject<{
|
|
740
|
+
match: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
741
|
+
path: z.ZodString;
|
|
742
|
+
equals: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
743
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
744
|
+
path: z.ZodString;
|
|
745
|
+
exists: z.ZodLiteral<true>;
|
|
746
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
747
|
+
path: z.ZodString;
|
|
748
|
+
oneOf: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
749
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
750
|
+
path: z.ZodString;
|
|
751
|
+
startsWith: z.ZodString;
|
|
752
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
753
|
+
path: z.ZodString;
|
|
754
|
+
endsWith: z.ZodString;
|
|
755
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
756
|
+
path: z.ZodString;
|
|
757
|
+
contains: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
758
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
759
|
+
path: z.ZodString;
|
|
760
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
761
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
762
|
+
}, z.core.$strict>]>>;
|
|
763
|
+
model: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
764
|
+
}, z.core.$strict>>;
|
|
765
|
+
bluetooth: z.ZodOptional<z.ZodObject<{
|
|
766
|
+
match: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
767
|
+
path: z.ZodString;
|
|
768
|
+
equals: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
769
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
770
|
+
path: z.ZodString;
|
|
771
|
+
exists: z.ZodLiteral<true>;
|
|
772
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
773
|
+
path: z.ZodString;
|
|
774
|
+
oneOf: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
775
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
776
|
+
path: z.ZodString;
|
|
777
|
+
startsWith: z.ZodString;
|
|
778
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
779
|
+
path: z.ZodString;
|
|
780
|
+
endsWith: z.ZodString;
|
|
781
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
782
|
+
path: z.ZodString;
|
|
783
|
+
contains: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
784
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
785
|
+
path: z.ZodString;
|
|
786
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
787
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
788
|
+
}, z.core.$strict>]>>;
|
|
789
|
+
model: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
790
|
+
}, z.core.$strict>>;
|
|
706
791
|
adopt: z.ZodDefault<z.ZodEnum<{
|
|
707
792
|
owner: "owner";
|
|
708
793
|
automatic: "automatic";
|
|
@@ -834,22 +919,22 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
834
919
|
icon: z.ZodOptional<z.ZodString>;
|
|
835
920
|
domain: z.ZodEnum<{
|
|
836
921
|
number: "number";
|
|
837
|
-
|
|
838
|
-
|
|
922
|
+
button: "button";
|
|
923
|
+
select: "select";
|
|
839
924
|
switch: "switch";
|
|
840
925
|
light: "light";
|
|
841
|
-
|
|
842
|
-
|
|
926
|
+
binary_sensor: "binary_sensor";
|
|
927
|
+
sensor: "sensor";
|
|
843
928
|
}>;
|
|
844
929
|
capabilities: z.ZodRecord<z.ZodEnum<{
|
|
845
930
|
number: "number";
|
|
846
|
-
|
|
847
|
-
|
|
931
|
+
level: "level";
|
|
932
|
+
on_off: "on_off";
|
|
848
933
|
sensor_numeric: "sensor_numeric";
|
|
849
|
-
sensor_text: "sensor_text";
|
|
850
934
|
sensor_binary: "sensor_binary";
|
|
851
|
-
|
|
852
|
-
|
|
935
|
+
sensor_text: "sensor_text";
|
|
936
|
+
button: "button";
|
|
937
|
+
select: "select";
|
|
853
938
|
}> & z.core.$partial, z.ZodObject<{
|
|
854
939
|
read: z.ZodOptional<z.ZodObject<{
|
|
855
940
|
function: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
|
package/dist/schemas.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as integrationSetupSchema, d as accountDeclarationSchema, h as modbusTemplateSchema, l as vendorDiscoverySchema, m as vendorManifestSchema, p as driverManifestSchema, u as integrationProfileSchema } from "./chunks/node-dist.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region src/schemas.ts
|
|
4
4
|
/**
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { A as CapabilityName, C as TransportRequest, D as BluetoothAdvert, E as EntityId, O as BluetoothAdvertInput, S as Discovered, T as SerialLine, _ as UdpPeer, a as LoadedListenSource, b as Integration, c as SightingIdentity, d as BundleSdk, f as ManagedSocketClose, g as PlatformServices, h as ManagedUdpSocketOptions, i as LoadedDiscovery, j as CapabilityState, k as JsonObject, m as ManagedSocketOptions, n as LoadedAccount, o as LoadedVendor, p as ManagedSocketHeaders, r as LoadedBundle, s as Association, t as BundleFailure, u as BluetoothScannerOptions, v as Claim, w as TransportSubscription, x as ReportedState, y as DeviceDescriptor } from "./chunks/node-index.js";
|
|
2
2
|
//#region src/testing/fake-sdk.d.ts
|
|
3
3
|
/** The levels a bundle may log at. */
|
|
4
4
|
type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
|
|
@@ -69,6 +69,46 @@ type FakeWebSocket = {
|
|
|
69
69
|
*/
|
|
70
70
|
drop: (reason: string, details?: ManagedSocketClose) => void;
|
|
71
71
|
};
|
|
72
|
+
/** A serial port a bundle opened through the fake SDK. */
|
|
73
|
+
type FakeSerialPort = {
|
|
74
|
+
readonly portId: string;
|
|
75
|
+
/** The line it was opened at, the defaults filled in: `9600 8N1` unless said. */
|
|
76
|
+
readonly line: SerialLine;
|
|
77
|
+
/** What the bundle wrote, a buffer a write, in order. */
|
|
78
|
+
readonly written: readonly Buffer[];
|
|
79
|
+
/** Whether the bundle closed it, the test unplugged it, or the release let go of it. */
|
|
80
|
+
readonly isClosed: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Hands the bundle bytes, as if the port read them: one chunk, as a port reads one.
|
|
83
|
+
*
|
|
84
|
+
* @throws {Error} When the port is closed.
|
|
85
|
+
*/
|
|
86
|
+
feed: (bytes: Uint8Array | string) => void;
|
|
87
|
+
/**
|
|
88
|
+
* Takes the port away, as unplugging it or the owner taking it back would, and tells the
|
|
89
|
+
* bundle why; its writes then fail with `SerialClosed`.
|
|
90
|
+
*
|
|
91
|
+
* @param reason - Why; `Unplugged` when not said.
|
|
92
|
+
*/
|
|
93
|
+
unplug: (reason?: string) => void;
|
|
94
|
+
};
|
|
95
|
+
/** A Bluetooth proxy's scanner a bundle opened through the fake SDK. */
|
|
96
|
+
type FakeBluetoothScanner = {
|
|
97
|
+
/** Which proxy reports: its connection's key and its device key. */
|
|
98
|
+
readonly options: BluetoothScannerOptions;
|
|
99
|
+
/** Every report, as the bundle made it, an empty one too: that is the proxy saying it is alive. */
|
|
100
|
+
readonly reports: readonly (readonly BluetoothAdvertInput[])[];
|
|
101
|
+
/**
|
|
102
|
+
* The advertisements the house keeps of those, read as the broker reads them: 1024 a report at
|
|
103
|
+
* most, one that does not hold dropped, addresses upper case and hex lower case.
|
|
104
|
+
*
|
|
105
|
+
* shortcut: a 128-bit UUID on the Bluetooth base stays as reported, where the hub shortens it to
|
|
106
|
+
* 16 bits; shorten it here too if a vendor's test ever reads one.
|
|
107
|
+
*/
|
|
108
|
+
readonly adverts: readonly BluetoothAdvert[];
|
|
109
|
+
/** Whether the bundle closed it, or opened another for the same proxy. */
|
|
110
|
+
readonly isClosed: boolean;
|
|
111
|
+
};
|
|
72
112
|
/** What a test builds a fake SDK with. */
|
|
73
113
|
type FakeSdkOptions = {
|
|
74
114
|
/** What the platform runs that the bundle may use: no broker when not said. */
|
|
@@ -85,6 +125,10 @@ type FakeSdk = {
|
|
|
85
125
|
readonly udpSockets: readonly FakeUdpSocket[];
|
|
86
126
|
/** The WebSockets the bundle opened, in order; none is open until the test opens it. */
|
|
87
127
|
readonly webSockets: readonly FakeWebSocket[];
|
|
128
|
+
/** The serial ports the bundle opened, in order. */
|
|
129
|
+
readonly serialPorts: readonly FakeSerialPort[];
|
|
130
|
+
/** The Bluetooth scanners the bundle opened, in order. */
|
|
131
|
+
readonly bluetoothScanners: readonly FakeBluetoothScanner[];
|
|
88
132
|
/**
|
|
89
133
|
* Closes every socket the bundle left open, as the hub does when it lets go of a vendor.
|
|
90
134
|
*
|
|
@@ -266,6 +310,46 @@ type ModbusIdentification = {
|
|
|
266
310
|
* @throws {Error} When the vendor has no discovery that loaded.
|
|
267
311
|
*/
|
|
268
312
|
export declare function identifyModbus(vendor: LoadedVendor, identity: Readonly<Record<string, unknown>>): ModbusIdentification;
|
|
313
|
+
/** What discovery makes of one of the serial ports the server sees. */
|
|
314
|
+
type SerialIdentification = {
|
|
315
|
+
/** Whether the vendor's `serial` rules take it: every condition holds. */
|
|
316
|
+
readonly matches: boolean;
|
|
317
|
+
/** The `serial` driver and the model it names; null when no driver takes the port. */
|
|
318
|
+
readonly association: Association | null;
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* Says what discovery makes of one of the serial ports the server sees, by the vendor's `serial`
|
|
322
|
+
* rules: whether the Serial broker suggests it for the vendor - "Use with …?" - and as which of its
|
|
323
|
+
* drivers of kind `serial`. A port is never added on its own: the owner says which device it is.
|
|
324
|
+
*
|
|
325
|
+
* @param vendor - The vendor, loaded with `loadIntegration`.
|
|
326
|
+
* @param usb - What the port's USB adapter says it is: `{ vendorId: '10c4', productId: 'ea60',
|
|
327
|
+
* manufacturer, product, serialNumber }`, the ids four lower-case hex digits; a field left out is
|
|
328
|
+
* one it does not say.
|
|
329
|
+
* @returns What discovery makes of it.
|
|
330
|
+
* @throws {Error} When the vendor has no discovery that loaded.
|
|
331
|
+
*/
|
|
332
|
+
export declare function identifySerial(vendor: LoadedVendor, usb: Readonly<Record<string, unknown>>): SerialIdentification;
|
|
333
|
+
/** What discovery makes of one of the devices the house's Bluetooth hears. */
|
|
334
|
+
type BluetoothIdentification = {
|
|
335
|
+
/** Whether the vendor's `bluetooth` rules take it: every condition holds. */
|
|
336
|
+
readonly matches: boolean;
|
|
337
|
+
/** The driver on the `bluetooth` transport and the model it names; null when none takes it. */
|
|
338
|
+
readonly association: Association | null;
|
|
339
|
+
};
|
|
340
|
+
/**
|
|
341
|
+
* Says what discovery makes of one advertisement the house's Bluetooth heard - from the server's
|
|
342
|
+
* adapter or a proxy - by the vendor's `bluetooth` rules: whether the device is listed as found for
|
|
343
|
+
* the vendor, and as which of its drivers on the `bluetooth` transport. The owner adds it.
|
|
344
|
+
*
|
|
345
|
+
* @param vendor - The vendor, loaded with `loadIntegration`.
|
|
346
|
+
* @param advert - The advertisement, as the house keeps it: `address` upper case, `name`,
|
|
347
|
+
* `manufacturerData` by decimal company id, `serviceData` and `serviceUuids` lower case, a 16-bit
|
|
348
|
+
* UUID short (`fcd2`), every value hex in lower case; a field left out is one it does not carry.
|
|
349
|
+
* @returns What discovery makes of it.
|
|
350
|
+
* @throws {Error} When the vendor has no discovery that loaded.
|
|
351
|
+
*/
|
|
352
|
+
export declare function identifyBluetooth(vendor: LoadedVendor, advert: Readonly<Record<string, unknown>>): BluetoothIdentification;
|
|
269
353
|
//#endregion
|
|
270
354
|
//#region src/testing/load.d.ts
|
|
271
355
|
/** What loading takes. */
|
|
@@ -321,4 +405,4 @@ export declare class IntegrationError extends Error {
|
|
|
321
405
|
constructor(problems: readonly string[]);
|
|
322
406
|
}
|
|
323
407
|
//#endregion
|
|
324
|
-
export type { Association, BundleFailure, DriverHarness, DriverHarnessOptions, FakeSdk, FakeSdkOptions, FakeUdpSocket, FakeWebSocket, HarnessDevice, Identification, LoadIntegrationOptions, LoadedAccount, LoadedBundle, LoadedDiscovery, LoadedIntegration, LoadedListenSource, LoadedVendor, LogLevel, LogRecord, MatterIdentification, ModbusIdentification, MqttIdentification, SentDatagram, SightingIdentity };
|
|
408
|
+
export type { Association, BluetoothIdentification, BundleFailure, DriverHarness, DriverHarnessOptions, FakeBluetoothScanner, FakeSdk, FakeSdkOptions, FakeSerialPort, FakeUdpSocket, FakeWebSocket, HarnessDevice, Identification, LoadIntegrationOptions, LoadedAccount, LoadedBundle, LoadedDiscovery, LoadedIntegration, LoadedListenSource, LoadedVendor, LogLevel, LogRecord, MatterIdentification, ModbusIdentification, MqttIdentification, SentDatagram, SerialIdentification, SightingIdentity };
|
package/dist/testing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as associateModel, c as matchesBroker, i as associateBroker, n as readVendorDirectory, o as identifySighting, s as matchesAnnouncement, t as instantiateVendor, x as composeEntityId } from "./chunks/node-dist.js";
|
|
2
2
|
import { a as sourceModule, i as runtimeVersion, o as createFakeSdk, r as readProject, t as IntegrationError } from "./chunks/node-project.js";
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
//#region src/testing/harness.ts
|
|
@@ -240,6 +240,48 @@ function identifyModbus(vendor, identity) {
|
|
|
240
240
|
association: matches ? associateBroker(plan, "modbus", identity) : null
|
|
241
241
|
};
|
|
242
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* Says what discovery makes of one of the serial ports the server sees, by the vendor's `serial`
|
|
245
|
+
* rules: whether the Serial broker suggests it for the vendor - "Use with …?" - and as which of its
|
|
246
|
+
* drivers of kind `serial`. A port is never added on its own: the owner says which device it is.
|
|
247
|
+
*
|
|
248
|
+
* @param vendor - The vendor, loaded with `loadIntegration`.
|
|
249
|
+
* @param usb - What the port's USB adapter says it is: `{ vendorId: '10c4', productId: 'ea60',
|
|
250
|
+
* manufacturer, product, serialNumber }`, the ids four lower-case hex digits; a field left out is
|
|
251
|
+
* one it does not say.
|
|
252
|
+
* @returns What discovery makes of it.
|
|
253
|
+
* @throws {Error} When the vendor has no discovery that loaded.
|
|
254
|
+
*/
|
|
255
|
+
function identifySerial(vendor, usb) {
|
|
256
|
+
const plan = vendor.discovery?.plan;
|
|
257
|
+
if (plan === void 0) throw new Error(`${vendor.manifest.id} has no discovery.json that loaded`);
|
|
258
|
+
const matches = matchesBroker(plan, "serial", usb);
|
|
259
|
+
return {
|
|
260
|
+
matches,
|
|
261
|
+
association: matches ? associateBroker(plan, "serial", usb) : null
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Says what discovery makes of one advertisement the house's Bluetooth heard - from the server's
|
|
266
|
+
* adapter or a proxy - by the vendor's `bluetooth` rules: whether the device is listed as found for
|
|
267
|
+
* the vendor, and as which of its drivers on the `bluetooth` transport. The owner adds it.
|
|
268
|
+
*
|
|
269
|
+
* @param vendor - The vendor, loaded with `loadIntegration`.
|
|
270
|
+
* @param advert - The advertisement, as the house keeps it: `address` upper case, `name`,
|
|
271
|
+
* `manufacturerData` by decimal company id, `serviceData` and `serviceUuids` lower case, a 16-bit
|
|
272
|
+
* UUID short (`fcd2`), every value hex in lower case; a field left out is one it does not carry.
|
|
273
|
+
* @returns What discovery makes of it.
|
|
274
|
+
* @throws {Error} When the vendor has no discovery that loaded.
|
|
275
|
+
*/
|
|
276
|
+
function identifyBluetooth(vendor, advert) {
|
|
277
|
+
const plan = vendor.discovery?.plan;
|
|
278
|
+
if (plan === void 0) throw new Error(`${vendor.manifest.id} has no discovery.json that loaded`);
|
|
279
|
+
const matches = matchesBroker(plan, "bluetooth", advert);
|
|
280
|
+
return {
|
|
281
|
+
matches,
|
|
282
|
+
association: matches ? associateBroker(plan, "bluetooth", advert) : null
|
|
283
|
+
};
|
|
284
|
+
}
|
|
243
285
|
//#endregion
|
|
244
286
|
//#region src/testing/load.ts
|
|
245
287
|
/**
|
|
@@ -308,4 +350,4 @@ async function loadIntegration(options = {}) {
|
|
|
308
350
|
};
|
|
309
351
|
}
|
|
310
352
|
//#endregion
|
|
311
|
-
export { IntegrationError, createFakeSdk, driverHarness, identify, identifyMatter, identifyModbus, identifyMqtt, loadIntegration };
|
|
353
|
+
export { IntegrationError, createFakeSdk, driverHarness, identify, identifyBluetooth, identifyMatter, identifyModbus, identifyMqtt, identifySerial, loadIntegration };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nebulahome/integration-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Write a NebulaHome integration: check it, build it, test it and release it for the platform.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
"tsdown": "^0.23.0",
|
|
63
63
|
"typescript": "^6.0.3",
|
|
64
64
|
"vitest": "^4.1.11",
|
|
65
|
-
"@nebulahome/
|
|
66
|
-
"@nebulahome/
|
|
67
|
-
"@nebulahome/
|
|
68
|
-
"@nebulahome/eslint-config": "2026.10.0-alpha.
|
|
65
|
+
"@nebulahome/package-runtime": "2026.10.0-alpha.6",
|
|
66
|
+
"@nebulahome/contracts": "2026.10.0-alpha.6",
|
|
67
|
+
"@nebulahome/tsconfig": "2026.10.0-alpha.6",
|
|
68
|
+
"@nebulahome/eslint-config": "2026.10.0-alpha.6"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build": "tsdown && node scripts/build-schemas.js",
|