@nebulahome/integration-sdk 1.7.0 → 1.9.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 +33 -0
- package/FILES.md +75 -9
- package/dist/chunks/node-dist.js +122 -8
- package/dist/chunks/node-index.d.ts +183 -8
- package/dist/chunks/node-project.js +1 -1
- package/dist/index.d.ts +40 -4
- package/dist/index.js +3 -1
- package/dist/schemas.d.ts +150 -9
- package/dist/testing.d.ts +12 -0
- package/dist/testing.js +47 -2
- package/package.json +5 -5
- package/schemas/discovery.schema.json +558 -180
- package/schemas/manifest.schema.json +10 -0
package/dist/index.d.ts
CHANGED
|
@@ -278,9 +278,8 @@ type EntityStateClass = (typeof ENTITY_STATE_CLASSES)[number];
|
|
|
278
278
|
declare const declaredCapabilitiesSchema: z.ZodRecord<z.ZodEnum<{
|
|
279
279
|
number: "number";
|
|
280
280
|
custom: "custom";
|
|
281
|
-
image: "image";
|
|
282
|
-
level: "level";
|
|
283
281
|
on_off: "on_off";
|
|
282
|
+
level: "level";
|
|
284
283
|
color_hs: "color_hs";
|
|
285
284
|
color_temp: "color_temp";
|
|
286
285
|
cover: "cover";
|
|
@@ -296,6 +295,7 @@ declare const declaredCapabilitiesSchema: z.ZodRecord<z.ZodEnum<{
|
|
|
296
295
|
lawn_mower: "lawn_mower";
|
|
297
296
|
select: "select";
|
|
298
297
|
vacuum: "vacuum";
|
|
298
|
+
image: "image";
|
|
299
299
|
}> & z.core.$partial, z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
300
300
|
/** What an entity declares it can do, with the device's own limits for each. */
|
|
301
301
|
type DeclaredCapabilities = z.output<typeof declaredCapabilitiesSchema>;
|
|
@@ -787,6 +787,8 @@ export declare const BLUETOOTH_GATT_OPS: {
|
|
|
787
787
|
readonly read: "gatt.read";
|
|
788
788
|
readonly write: "gatt.write";
|
|
789
789
|
readonly notify: "gatt.notify";
|
|
790
|
+
/** Writes a request and answers what the device notifies back. */
|
|
791
|
+
readonly exchange: "gatt.exchange";
|
|
790
792
|
};
|
|
791
793
|
declare namespace infrared_codes_d_exports {
|
|
792
794
|
export { BROADLINK_TICK_US, DEFAULT_IR_CARRIER_HZ, FlipperIrCode, FlipperIrFile, InfraredImportProblem, decodeBroadlink, decodeInfraredProtocol, decodePronto, decodeRawTimings, encodeBroadlink, encodeInfraredProtocol, encodePronto, encodeRawTimings, parseFlipperIr, withInfraredProtocol };
|
|
@@ -1154,6 +1156,13 @@ type MappingContext = {
|
|
|
1154
1156
|
*/
|
|
1155
1157
|
lastState: (entityId: EntityId) => CapabilityState | undefined;
|
|
1156
1158
|
};
|
|
1159
|
+
/** One request of a command already sent, and what the transport answered. */
|
|
1160
|
+
type CommandStep = {
|
|
1161
|
+
readonly request: TransportRequest;
|
|
1162
|
+
readonly answer: unknown;
|
|
1163
|
+
/** Its place in the command: 0 for the request `toCommand` built. */
|
|
1164
|
+
readonly index: number;
|
|
1165
|
+
};
|
|
1157
1166
|
/** A command, resolved to the device and entity it is for. */
|
|
1158
1167
|
type CommandTarget = {
|
|
1159
1168
|
readonly entityId: EntityId;
|
|
@@ -1236,9 +1245,25 @@ type Integration<TOptions = JsonObject> = {
|
|
|
1236
1245
|
* @returns The request. Performing it is the transport's job.
|
|
1237
1246
|
*/
|
|
1238
1247
|
toCommand: (target: CommandTarget, context: MappingContext) => TransportRequest;
|
|
1248
|
+
/**
|
|
1249
|
+
* Carries a command on once the transport answered its last request - for a device spoken to in
|
|
1250
|
+
* a conversation: a Bluetooth lock asked for a session first, then sent the command sealed with
|
|
1251
|
+
* it. Each step is a pure function of what came back; the hub sends what it returns, at most
|
|
1252
|
+
* {@link MAX_COMMAND_STEPS} requests in all, and stops at null. A throw fails the command with
|
|
1253
|
+
* its message.
|
|
1254
|
+
*
|
|
1255
|
+
* Optional: without it a command is the one request `toCommand` builds.
|
|
1256
|
+
*
|
|
1257
|
+
* @param target - The entity, the capability and the command.
|
|
1258
|
+
* @param step - The request just sent, what the transport answered, and its place (0 first).
|
|
1259
|
+
* @param context - The claim, the settings and the last known state.
|
|
1260
|
+
* @returns The next request, or null when the command is done.
|
|
1261
|
+
*/
|
|
1262
|
+
continueCommand?: (target: CommandTarget, step: CommandStep, context: MappingContext) => TransportRequest | null;
|
|
1239
1263
|
/**
|
|
1240
1264
|
* Reads what a message says about the device itself, beyond its entities: the firmware it runs
|
|
1241
|
-
* now, which changes when it is updated and is otherwise only known from when it was found
|
|
1265
|
+
* now, which changes when it is updated and is otherwise only known from when it was found;
|
|
1266
|
+
* and how it is set up, when that decides its entities (`descriptor`).
|
|
1242
1267
|
*
|
|
1243
1268
|
* Optional: an integration whose messages say nothing of the kind leaves it out.
|
|
1244
1269
|
*
|
|
@@ -1268,6 +1293,17 @@ type StreamRequest = {
|
|
|
1268
1293
|
type DeviceInfo = {
|
|
1269
1294
|
readonly swVersion?: string;
|
|
1270
1295
|
readonly hwVersion?: string;
|
|
1296
|
+
/**
|
|
1297
|
+
* What the device is now, for a device whose entities depend on how it is set up - a Bot in
|
|
1298
|
+
* switch or in press mode: the claim's own descriptor while it is still that, a new one to
|
|
1299
|
+
* describe it from once it changed. Left out when the message does not say.
|
|
1300
|
+
*
|
|
1301
|
+
* A new one is taken when the device still says it thirty seconds later - a message saying
|
|
1302
|
+
* the claim's own again drops it. The device is then described again: an entity
|
|
1303
|
+
* described both times stays, with its history; one no longer described is removed, with its
|
|
1304
|
+
* history; one described only now is added.
|
|
1305
|
+
*/
|
|
1306
|
+
readonly descriptor?: unknown;
|
|
1271
1307
|
};
|
|
1272
1308
|
//#endregion
|
|
1273
1309
|
//#region ../package-runtime/dist/stream.d.ts
|
|
@@ -2003,4 +2039,4 @@ export declare function defineAccountModule(factory: AccountFactory): AccountFac
|
|
|
2003
2039
|
*/
|
|
2004
2040
|
export declare function defineStreamModule(factory: StreamFactory): StreamFactory;
|
|
2005
2041
|
//#endregion
|
|
2006
|
-
export type { AccountFactory, AccountHandle, AccountIdentity, AccountModule, AccountModuleStep, AccountStepContext, BluetoothAdvert, BluetoothAdvertInput, BluetoothProxyFilterArgs, BluetoothProxyInstallArgs, BluetoothProxyProfile, BluetoothProxyState, BluetoothScanMode, BluetoothScanner, BluetoothScannerOptions, BluetoothSighting, BundleBluetooth, BundleCodecs, BundleImages, BundleLogFn, BundleLogger, BundleSdk, Claim, CommandTarget, DeviceDescriptor, DeviceInfo, Discovered, DiscoveryListenContext, DiscoverySource, DiscoverySourceFactory, EntityDescriptor, FlipperIrCode, FlipperIrFile, ImageBlob, InfraredCode, InfraredCodec, InfraredImportProblem, InfraredLearnArgs, InfraredProfile, InfraredProtocol, InfraredProtocolName, InfraredSendArgs, InfraredSignal, InfraredSweepArgs, InfraredSweepResult, Integration, IntegrationFactory, ListenerStatus, ManagedMqtt, ManagedMqttOptions, ManagedSocket, ManagedSocketClose, ManagedSocketHeaders, ManagedSocketOptions, ManagedUdpSocket, ManagedUdpSocketOptions, MappingContext, MdnsAnnouncement, OpenMqtt, OpenRtsp, OpenSerial, OpenUdpSocket, OpenWebSocket, PaletteColour, PalettedPicture, PassedOverSighting, PlatformMqtt, PlatformServices, ReportedState, RtspFrame, RtspOptions, SerialDeviceConfig, SerialLine, SerialLineInput, SerialSession, SerialSighting, Sighting, StreamFactory, StreamFrame, StreamRequest, StreamSink, StreamSource, StreamSourceSpec, StreamTrack, Transport, TransportConnection, TransportContext, TransportFactory, TransportInbound, TransportLookContext, TransportRequest, TransportSpec, TransportStatus, TransportSubscription, UdpPeer };
|
|
2042
|
+
export type { AccountFactory, AccountHandle, AccountIdentity, AccountModule, AccountModuleStep, AccountStepContext, BluetoothAdvert, BluetoothAdvertInput, BluetoothProxyFilterArgs, BluetoothProxyInstallArgs, BluetoothProxyProfile, BluetoothProxyState, BluetoothScanMode, BluetoothScanner, BluetoothScannerOptions, BluetoothSighting, BundleBluetooth, BundleCodecs, BundleImages, BundleLogFn, BundleLogger, BundleSdk, Claim, CommandStep, CommandTarget, DeviceDescriptor, DeviceInfo, Discovered, DiscoveryListenContext, DiscoverySource, DiscoverySourceFactory, EntityDescriptor, FlipperIrCode, FlipperIrFile, ImageBlob, InfraredCode, InfraredCodec, InfraredImportProblem, InfraredLearnArgs, InfraredProfile, InfraredProtocol, InfraredProtocolName, InfraredSendArgs, InfraredSignal, InfraredSweepArgs, InfraredSweepResult, Integration, IntegrationFactory, ListenerStatus, ManagedMqtt, ManagedMqttOptions, ManagedSocket, ManagedSocketClose, ManagedSocketHeaders, ManagedSocketOptions, ManagedUdpSocket, ManagedUdpSocketOptions, MappingContext, MdnsAnnouncement, OpenMqtt, OpenRtsp, OpenSerial, OpenUdpSocket, OpenWebSocket, PaletteColour, PalettedPicture, PassedOverSighting, PlatformMqtt, PlatformServices, ReportedState, RtspFrame, RtspOptions, SerialDeviceConfig, SerialLine, SerialLineInput, SerialSession, SerialSighting, Sighting, StreamFactory, StreamFrame, StreamRequest, StreamSink, StreamSource, StreamSourceSpec, StreamTrack, Transport, TransportConnection, TransportContext, TransportFactory, TransportInbound, TransportLookContext, TransportRequest, TransportSpec, TransportStatus, TransportSubscription, UdpPeer };
|
package/dist/index.js
CHANGED
|
@@ -97,7 +97,9 @@ const BLUETOOTH_PROXY_OPS = {
|
|
|
97
97
|
const BLUETOOTH_GATT_OPS = {
|
|
98
98
|
read: "gatt.read",
|
|
99
99
|
write: "gatt.write",
|
|
100
|
-
notify: "gatt.notify"
|
|
100
|
+
notify: "gatt.notify",
|
|
101
|
+
/** Writes a request and answers what the device notifies back. */
|
|
102
|
+
exchange: "gatt.exchange"
|
|
101
103
|
};
|
|
102
104
|
//#endregion
|
|
103
105
|
export { BLUETOOTH_GATT_OPS, BLUETOOTH_PROXY_OPS, INFRARED_OPS, defineAccountModule, defineDiscoveryModule, defineDriverModule, defineStreamModule, defineTransportModule };
|
package/dist/schemas.d.ts
CHANGED
|
@@ -24,13 +24,14 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
24
24
|
serial: "serial";
|
|
25
25
|
mac: "mac";
|
|
26
26
|
}>>>;
|
|
27
|
+
twinsPrefer: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
28
|
setup: z.ZodOptional<z.ZodString>;
|
|
28
29
|
account: z.ZodOptional<z.ZodString>;
|
|
29
30
|
transports: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
30
31
|
module: z.ZodString;
|
|
31
32
|
wires: z.ZodArray<z.ZodEnum<{
|
|
32
|
-
udp: "udp";
|
|
33
33
|
matter: "matter";
|
|
34
|
+
udp: "udp";
|
|
34
35
|
mqtt: "mqtt";
|
|
35
36
|
modbus: "modbus";
|
|
36
37
|
serial: "serial";
|
|
@@ -116,9 +117,9 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
116
117
|
modelCodes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
|
|
117
118
|
modelSeries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
118
119
|
kind: z.ZodEnum<{
|
|
120
|
+
matter: "matter";
|
|
119
121
|
declarative: "declarative";
|
|
120
122
|
code: "code";
|
|
121
|
-
matter: "matter";
|
|
122
123
|
mqtt: "mqtt";
|
|
123
124
|
modbus: "modbus";
|
|
124
125
|
infrared: "infrared";
|
|
@@ -408,8 +409,6 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
408
409
|
entities: z.ZodArray<z.ZodObject<{
|
|
409
410
|
domain: z.ZodEnum<{
|
|
410
411
|
number: "number";
|
|
411
|
-
image: "image";
|
|
412
|
-
custom: "custom";
|
|
413
412
|
light: "light";
|
|
414
413
|
switch: "switch";
|
|
415
414
|
sensor: "sensor";
|
|
@@ -424,6 +423,8 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
424
423
|
lawn_mower: "lawn_mower";
|
|
425
424
|
select: "select";
|
|
426
425
|
vacuum: "vacuum";
|
|
426
|
+
image: "image";
|
|
427
|
+
custom: "custom";
|
|
427
428
|
alias: "alias";
|
|
428
429
|
}>;
|
|
429
430
|
objectId: z.ZodOptional<z.ZodString>;
|
|
@@ -432,9 +433,8 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
432
433
|
capabilities: z.ZodRecord<z.ZodEnum<{
|
|
433
434
|
number: "number";
|
|
434
435
|
custom: "custom";
|
|
435
|
-
image: "image";
|
|
436
|
-
level: "level";
|
|
437
436
|
on_off: "on_off";
|
|
437
|
+
level: "level";
|
|
438
438
|
color_hs: "color_hs";
|
|
439
439
|
color_temp: "color_temp";
|
|
440
440
|
cover: "cover";
|
|
@@ -450,6 +450,7 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
450
450
|
lawn_mower: "lawn_mower";
|
|
451
451
|
select: "select";
|
|
452
452
|
vacuum: "vacuum";
|
|
453
|
+
image: "image";
|
|
453
454
|
}> & z.core.$partial, z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
454
455
|
state: z.ZodRecord<z.ZodEnum<{
|
|
455
456
|
number: "number";
|
|
@@ -762,7 +763,7 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
762
763
|
}, z.core.$strict>]>>;
|
|
763
764
|
model: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
764
765
|
}, z.core.$strict>>;
|
|
765
|
-
bluetooth: z.ZodOptional<z.ZodObject<{
|
|
766
|
+
bluetooth: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodObject<{
|
|
766
767
|
match: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
767
768
|
path: z.ZodString;
|
|
768
769
|
equals: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
@@ -786,8 +787,148 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
786
787
|
min: z.ZodOptional<z.ZodNumber>;
|
|
787
788
|
max: z.ZodOptional<z.ZodNumber>;
|
|
788
789
|
}, z.core.$strict>]>>;
|
|
789
|
-
model: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.
|
|
790
|
-
|
|
790
|
+
model: z.ZodDefault<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
791
|
+
path: z.ZodString;
|
|
792
|
+
bytes: z.ZodTuple<[z.ZodInt, z.ZodInt], null>;
|
|
793
|
+
mask: z.ZodOptional<z.ZodInt>;
|
|
794
|
+
}, z.core.$strict>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
795
|
+
path: z.ZodString;
|
|
796
|
+
bytes: z.ZodTuple<[z.ZodInt, z.ZodInt], null>;
|
|
797
|
+
mask: z.ZodOptional<z.ZodInt>;
|
|
798
|
+
}, z.core.$strict>]>>]>>;
|
|
799
|
+
}, z.core.$strict>, z.ZodArray<z.ZodObject<{
|
|
800
|
+
match: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
801
|
+
path: z.ZodString;
|
|
802
|
+
equals: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
803
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
804
|
+
path: z.ZodString;
|
|
805
|
+
exists: z.ZodLiteral<true>;
|
|
806
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
807
|
+
path: z.ZodString;
|
|
808
|
+
oneOf: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
809
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
810
|
+
path: z.ZodString;
|
|
811
|
+
startsWith: z.ZodString;
|
|
812
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
813
|
+
path: z.ZodString;
|
|
814
|
+
endsWith: z.ZodString;
|
|
815
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
816
|
+
path: z.ZodString;
|
|
817
|
+
contains: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
818
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
819
|
+
path: z.ZodString;
|
|
820
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
821
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
822
|
+
}, z.core.$strict>]>>;
|
|
823
|
+
model: z.ZodDefault<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
824
|
+
path: z.ZodString;
|
|
825
|
+
bytes: z.ZodTuple<[z.ZodInt, z.ZodInt], null>;
|
|
826
|
+
mask: z.ZodOptional<z.ZodInt>;
|
|
827
|
+
}, z.core.$strict>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
828
|
+
path: z.ZodString;
|
|
829
|
+
bytes: z.ZodTuple<[z.ZodInt, z.ZodInt], null>;
|
|
830
|
+
mask: z.ZodOptional<z.ZodInt>;
|
|
831
|
+
}, z.core.$strict>]>>]>>;
|
|
832
|
+
}, z.core.$strict>>]>, z.ZodTransform<{
|
|
833
|
+
match: ({
|
|
834
|
+
path: string;
|
|
835
|
+
min?: number | undefined;
|
|
836
|
+
max?: number | undefined;
|
|
837
|
+
} | {
|
|
838
|
+
path: string;
|
|
839
|
+
equals: string | number | boolean;
|
|
840
|
+
} | {
|
|
841
|
+
path: string;
|
|
842
|
+
exists: true;
|
|
843
|
+
} | {
|
|
844
|
+
path: string;
|
|
845
|
+
oneOf: (string | number | boolean)[];
|
|
846
|
+
} | {
|
|
847
|
+
path: string;
|
|
848
|
+
startsWith: string;
|
|
849
|
+
} | {
|
|
850
|
+
path: string;
|
|
851
|
+
endsWith: string;
|
|
852
|
+
} | {
|
|
853
|
+
path: string;
|
|
854
|
+
contains: string | number | boolean;
|
|
855
|
+
})[];
|
|
856
|
+
model: string | {
|
|
857
|
+
path: string;
|
|
858
|
+
bytes: [number, number];
|
|
859
|
+
mask?: number | undefined;
|
|
860
|
+
} | (string | {
|
|
861
|
+
path: string;
|
|
862
|
+
bytes: [number, number];
|
|
863
|
+
mask?: number | undefined;
|
|
864
|
+
})[];
|
|
865
|
+
}[], {
|
|
866
|
+
match: ({
|
|
867
|
+
path: string;
|
|
868
|
+
min?: number | undefined;
|
|
869
|
+
max?: number | undefined;
|
|
870
|
+
} | {
|
|
871
|
+
path: string;
|
|
872
|
+
equals: string | number | boolean;
|
|
873
|
+
} | {
|
|
874
|
+
path: string;
|
|
875
|
+
exists: true;
|
|
876
|
+
} | {
|
|
877
|
+
path: string;
|
|
878
|
+
oneOf: (string | number | boolean)[];
|
|
879
|
+
} | {
|
|
880
|
+
path: string;
|
|
881
|
+
startsWith: string;
|
|
882
|
+
} | {
|
|
883
|
+
path: string;
|
|
884
|
+
endsWith: string;
|
|
885
|
+
} | {
|
|
886
|
+
path: string;
|
|
887
|
+
contains: string | number | boolean;
|
|
888
|
+
})[];
|
|
889
|
+
model: string | {
|
|
890
|
+
path: string;
|
|
891
|
+
bytes: [number, number];
|
|
892
|
+
mask?: number | undefined;
|
|
893
|
+
} | (string | {
|
|
894
|
+
path: string;
|
|
895
|
+
bytes: [number, number];
|
|
896
|
+
mask?: number | undefined;
|
|
897
|
+
})[];
|
|
898
|
+
} | {
|
|
899
|
+
match: ({
|
|
900
|
+
path: string;
|
|
901
|
+
min?: number | undefined;
|
|
902
|
+
max?: number | undefined;
|
|
903
|
+
} | {
|
|
904
|
+
path: string;
|
|
905
|
+
equals: string | number | boolean;
|
|
906
|
+
} | {
|
|
907
|
+
path: string;
|
|
908
|
+
exists: true;
|
|
909
|
+
} | {
|
|
910
|
+
path: string;
|
|
911
|
+
oneOf: (string | number | boolean)[];
|
|
912
|
+
} | {
|
|
913
|
+
path: string;
|
|
914
|
+
startsWith: string;
|
|
915
|
+
} | {
|
|
916
|
+
path: string;
|
|
917
|
+
endsWith: string;
|
|
918
|
+
} | {
|
|
919
|
+
path: string;
|
|
920
|
+
contains: string | number | boolean;
|
|
921
|
+
})[];
|
|
922
|
+
model: string | {
|
|
923
|
+
path: string;
|
|
924
|
+
bytes: [number, number];
|
|
925
|
+
mask?: number | undefined;
|
|
926
|
+
} | (string | {
|
|
927
|
+
path: string;
|
|
928
|
+
bytes: [number, number];
|
|
929
|
+
mask?: number | undefined;
|
|
930
|
+
})[];
|
|
931
|
+
}[]>>>;
|
|
791
932
|
adopt: z.ZodDefault<z.ZodEnum<{
|
|
792
933
|
owner: "owner";
|
|
793
934
|
automatic: "automatic";
|
package/dist/testing.d.ts
CHANGED
|
@@ -207,6 +207,18 @@ type DriverHarness = {
|
|
|
207
207
|
* @returns The request.
|
|
208
208
|
*/
|
|
209
209
|
command: (entityId: string, capability: CapabilityName, command?: JsonObject) => TransportRequest;
|
|
210
|
+
/**
|
|
211
|
+
* Carries a command through a conversation, as the hub does for a driver with
|
|
212
|
+
* `continueCommand`: each request is answered with the next of `answers`, and the driver says
|
|
213
|
+
* what to send next.
|
|
214
|
+
*
|
|
215
|
+
* @param entityId - The entity.
|
|
216
|
+
* @param capability - The capability.
|
|
217
|
+
* @param command - The command, as `core` validated it.
|
|
218
|
+
* @param answers - What the transport answers each request, in turn.
|
|
219
|
+
* @returns Every request the command made; the last one unanswered when `answers` ran out.
|
|
220
|
+
*/
|
|
221
|
+
converse: (entityId: string, capability: CapabilityName, command: JsonObject, answers: readonly unknown[]) => TransportRequest[];
|
|
210
222
|
/**
|
|
211
223
|
* The last state an entity reported.
|
|
212
224
|
*
|
package/dist/testing.js
CHANGED
|
@@ -16,6 +16,8 @@ import { pathToFileURL } from "node:url";
|
|
|
16
16
|
* harness.command(device.entityIds[0], 'on_off', { command: 'turn_on' });
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
+
/** The most requests one command may take, as the hub allows. */
|
|
20
|
+
const MAX_STEPS = 8;
|
|
19
21
|
/**
|
|
20
22
|
* Sets a driver up to be driven.
|
|
21
23
|
*
|
|
@@ -50,6 +52,18 @@ function driverHarness(driver, settings = {}) {
|
|
|
50
52
|
lastState: (entityId) => lastStates.get(entityId)
|
|
51
53
|
});
|
|
52
54
|
/**
|
|
55
|
+
* The device added that has an entity.
|
|
56
|
+
*
|
|
57
|
+
* @param entityId - The entity.
|
|
58
|
+
* @returns The device.
|
|
59
|
+
* @throws {Error} When none has it.
|
|
60
|
+
*/
|
|
61
|
+
const deviceWith = (entityId) => {
|
|
62
|
+
const device = [...devices.values()].find((candidate) => candidate.entityIds.includes(entityId));
|
|
63
|
+
if (device === void 0) throw new Error(`No device added has the entity ${entityId}`);
|
|
64
|
+
return device;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
53
67
|
* The device added with a key.
|
|
54
68
|
*
|
|
55
69
|
* @param deviceKey - The key; the one added last when not said.
|
|
@@ -129,8 +143,7 @@ function driverHarness(driver, settings = {}) {
|
|
|
129
143
|
* @throws {Error} When no device added has the entity.
|
|
130
144
|
*/
|
|
131
145
|
command: (entityId, capability, command = {}) => {
|
|
132
|
-
const device =
|
|
133
|
-
if (device === void 0) throw new Error(`No device added has the entity ${entityId}`);
|
|
146
|
+
const device = deviceWith(entityId);
|
|
134
147
|
return integration.toCommand({
|
|
135
148
|
entityId,
|
|
136
149
|
capability,
|
|
@@ -138,6 +151,38 @@ function driverHarness(driver, settings = {}) {
|
|
|
138
151
|
}, contextFor(device));
|
|
139
152
|
},
|
|
140
153
|
/**
|
|
154
|
+
* Carries a command through its conversation.
|
|
155
|
+
*
|
|
156
|
+
* @param entityId - The entity.
|
|
157
|
+
* @param capability - The capability.
|
|
158
|
+
* @param command - The command.
|
|
159
|
+
* @param answers - The transport's answers, in turn.
|
|
160
|
+
* @returns The requests.
|
|
161
|
+
* @throws {Error} When no device added has the entity, or past eight requests.
|
|
162
|
+
*/
|
|
163
|
+
converse: (entityId, capability, command, answers) => {
|
|
164
|
+
const context = contextFor(deviceWith(entityId));
|
|
165
|
+
const target = {
|
|
166
|
+
entityId,
|
|
167
|
+
capability,
|
|
168
|
+
command
|
|
169
|
+
};
|
|
170
|
+
const requests = [integration.toCommand(target, context)];
|
|
171
|
+
for (const [index, answer] of answers.entries()) {
|
|
172
|
+
const request = requests[index];
|
|
173
|
+
if (request === void 0) break;
|
|
174
|
+
const next = integration.continueCommand?.(target, {
|
|
175
|
+
request,
|
|
176
|
+
answer,
|
|
177
|
+
index
|
|
178
|
+
}, context);
|
|
179
|
+
if (next === null || next === void 0) break;
|
|
180
|
+
if (requests.length === MAX_STEPS) throw new Error(`The command asked for more than ${String(MAX_STEPS)} requests`);
|
|
181
|
+
requests.push(next);
|
|
182
|
+
}
|
|
183
|
+
return requests;
|
|
184
|
+
},
|
|
185
|
+
/**
|
|
141
186
|
* The last state an entity reported.
|
|
142
187
|
*
|
|
143
188
|
* @param entityId - The entity.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nebulahome/integration-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.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/contracts": "2026.10.0-alpha.
|
|
66
|
-
"@nebulahome/
|
|
67
|
-
"@nebulahome/eslint-config": "2026.10.0-alpha.
|
|
68
|
-
"@nebulahome/
|
|
65
|
+
"@nebulahome/contracts": "2026.10.0-alpha.45",
|
|
66
|
+
"@nebulahome/package-runtime": "2026.10.0-alpha.45",
|
|
67
|
+
"@nebulahome/eslint-config": "2026.10.0-alpha.45",
|
|
68
|
+
"@nebulahome/tsconfig": "2026.10.0-alpha.45"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build": "tsdown && node scripts/build-schemas.js",
|