@nebulahome/integration-sdk 1.6.1 → 1.8.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 +37 -0
- package/FILES.md +87 -25
- package/dist/chunks/node-dist.js +114 -20
- package/dist/chunks/node-index.d.ts +169 -6
- package/dist/chunks/node-project.js +1 -1
- package/dist/index.d.ts +33 -4
- package/dist/index.js +3 -1
- package/dist/schemas.d.ts +148 -7
- 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
|
@@ -185,7 +185,7 @@ type BluetoothAdvertInput = z.input<typeof bluetoothAdvertSchema>;
|
|
|
185
185
|
/** One advertisement heard. */
|
|
186
186
|
type BluetoothAdvert = z.output<typeof bluetoothAdvertSchema>;
|
|
187
187
|
/**
|
|
188
|
-
* What a device that can be a proxy declares in its profile: the scan modes
|
|
188
|
+
* What a device that can be a proxy declares in its profile: the scan modes its radio can run.
|
|
189
189
|
*/
|
|
190
190
|
declare const bluetoothProxyProfileSchema: z.ZodObject<{
|
|
191
191
|
modes: z.ZodArray<z.ZodEnum<{
|
|
@@ -1286,6 +1286,13 @@ type MappingContext = {
|
|
|
1286
1286
|
*/
|
|
1287
1287
|
lastState: (entityId: EntityId) => CapabilityState | undefined;
|
|
1288
1288
|
};
|
|
1289
|
+
/** One request of a command already sent, and what the transport answered. */
|
|
1290
|
+
type CommandStep = {
|
|
1291
|
+
readonly request: TransportRequest;
|
|
1292
|
+
readonly answer: unknown;
|
|
1293
|
+
/** Its place in the command: 0 for the request `toCommand` built. */
|
|
1294
|
+
readonly index: number;
|
|
1295
|
+
};
|
|
1289
1296
|
/** A command, resolved to the device and entity it is for. */
|
|
1290
1297
|
type CommandTarget = {
|
|
1291
1298
|
readonly entityId: EntityId;
|
|
@@ -1368,6 +1375,21 @@ type Integration<TOptions = JsonObject> = {
|
|
|
1368
1375
|
* @returns The request. Performing it is the transport's job.
|
|
1369
1376
|
*/
|
|
1370
1377
|
toCommand: (target: CommandTarget, context: MappingContext) => TransportRequest;
|
|
1378
|
+
/**
|
|
1379
|
+
* Carries a command on once the transport answered its last request - for a device spoken to in
|
|
1380
|
+
* a conversation: a Bluetooth lock asked for a session first, then sent the command sealed with
|
|
1381
|
+
* it. Each step is a pure function of what came back; the hub sends what it returns, at most
|
|
1382
|
+
* {@link MAX_COMMAND_STEPS} requests in all, and stops at null. A throw fails the command with
|
|
1383
|
+
* its message.
|
|
1384
|
+
*
|
|
1385
|
+
* Optional: without it a command is the one request `toCommand` builds.
|
|
1386
|
+
*
|
|
1387
|
+
* @param target - The entity, the capability and the command.
|
|
1388
|
+
* @param step - The request just sent, what the transport answered, and its place (0 first).
|
|
1389
|
+
* @param context - The claim, the settings and the last known state.
|
|
1390
|
+
* @returns The next request, or null when the command is done.
|
|
1391
|
+
*/
|
|
1392
|
+
continueCommand?: (target: CommandTarget, step: CommandStep, context: MappingContext) => TransportRequest | null;
|
|
1371
1393
|
/**
|
|
1372
1394
|
* Reads what a message says about the device itself, beyond its entities: the firmware it runs
|
|
1373
1395
|
* now, which changes when it is updated and is otherwise only known from when it was found.
|
|
@@ -2124,13 +2146,14 @@ declare const vendorManifestSchema: z.ZodObject<{
|
|
|
2124
2146
|
serial: "serial";
|
|
2125
2147
|
mac: "mac";
|
|
2126
2148
|
}>>>;
|
|
2149
|
+
twinsPrefer: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2127
2150
|
setup: z.ZodOptional<z.ZodString>;
|
|
2128
2151
|
account: z.ZodOptional<z.ZodString>;
|
|
2129
2152
|
transports: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
2130
2153
|
module: z.ZodString;
|
|
2131
2154
|
wires: z.ZodArray<z.ZodEnum<{
|
|
2132
|
-
udp: "udp";
|
|
2133
2155
|
matter: "matter";
|
|
2156
|
+
udp: "udp";
|
|
2134
2157
|
mqtt: "mqtt";
|
|
2135
2158
|
modbus: "modbus";
|
|
2136
2159
|
serial: "serial";
|
|
@@ -2227,9 +2250,9 @@ declare const bundleManifestSchema: z.ZodObject<{
|
|
|
2227
2250
|
modelCodes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
|
|
2228
2251
|
modelSeries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
2229
2252
|
kind: z.ZodEnum<{
|
|
2253
|
+
matter: "matter";
|
|
2230
2254
|
declarative: "declarative";
|
|
2231
2255
|
code: "code";
|
|
2232
|
-
matter: "matter";
|
|
2233
2256
|
mqtt: "mqtt";
|
|
2234
2257
|
modbus: "modbus";
|
|
2235
2258
|
infrared: "infrared";
|
|
@@ -2464,7 +2487,7 @@ declare const vendorDiscoverySchema: z.ZodObject<{
|
|
|
2464
2487
|
}, z.core.$strict>]>>;
|
|
2465
2488
|
model: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
2466
2489
|
}, z.core.$strict>>;
|
|
2467
|
-
bluetooth: z.ZodOptional<z.ZodObject<{
|
|
2490
|
+
bluetooth: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodObject<{
|
|
2468
2491
|
match: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
2469
2492
|
path: z.ZodString;
|
|
2470
2493
|
equals: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
@@ -2488,8 +2511,148 @@ declare const vendorDiscoverySchema: z.ZodObject<{
|
|
|
2488
2511
|
min: z.ZodOptional<z.ZodNumber>;
|
|
2489
2512
|
max: z.ZodOptional<z.ZodNumber>;
|
|
2490
2513
|
}, z.core.$strict>]>>;
|
|
2491
|
-
model: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.
|
|
2492
|
-
|
|
2514
|
+
model: z.ZodDefault<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
2515
|
+
path: z.ZodString;
|
|
2516
|
+
bytes: z.ZodTuple<[z.ZodInt, z.ZodInt], null>;
|
|
2517
|
+
mask: z.ZodOptional<z.ZodInt>;
|
|
2518
|
+
}, z.core.$strict>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
2519
|
+
path: z.ZodString;
|
|
2520
|
+
bytes: z.ZodTuple<[z.ZodInt, z.ZodInt], null>;
|
|
2521
|
+
mask: z.ZodOptional<z.ZodInt>;
|
|
2522
|
+
}, z.core.$strict>]>>]>>;
|
|
2523
|
+
}, z.core.$strict>, z.ZodArray<z.ZodObject<{
|
|
2524
|
+
match: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
2525
|
+
path: z.ZodString;
|
|
2526
|
+
equals: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
2527
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2528
|
+
path: z.ZodString;
|
|
2529
|
+
exists: z.ZodLiteral<true>;
|
|
2530
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2531
|
+
path: z.ZodString;
|
|
2532
|
+
oneOf: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
2533
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2534
|
+
path: z.ZodString;
|
|
2535
|
+
startsWith: z.ZodString;
|
|
2536
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2537
|
+
path: z.ZodString;
|
|
2538
|
+
endsWith: z.ZodString;
|
|
2539
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2540
|
+
path: z.ZodString;
|
|
2541
|
+
contains: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
2542
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2543
|
+
path: z.ZodString;
|
|
2544
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
2545
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
2546
|
+
}, z.core.$strict>]>>;
|
|
2547
|
+
model: z.ZodDefault<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
2548
|
+
path: z.ZodString;
|
|
2549
|
+
bytes: z.ZodTuple<[z.ZodInt, z.ZodInt], null>;
|
|
2550
|
+
mask: z.ZodOptional<z.ZodInt>;
|
|
2551
|
+
}, z.core.$strict>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
2552
|
+
path: z.ZodString;
|
|
2553
|
+
bytes: z.ZodTuple<[z.ZodInt, z.ZodInt], null>;
|
|
2554
|
+
mask: z.ZodOptional<z.ZodInt>;
|
|
2555
|
+
}, z.core.$strict>]>>]>>;
|
|
2556
|
+
}, z.core.$strict>>]>, z.ZodTransform<{
|
|
2557
|
+
match: ({
|
|
2558
|
+
path: string;
|
|
2559
|
+
min?: number | undefined;
|
|
2560
|
+
max?: number | undefined;
|
|
2561
|
+
} | {
|
|
2562
|
+
path: string;
|
|
2563
|
+
equals: string | number | boolean;
|
|
2564
|
+
} | {
|
|
2565
|
+
path: string;
|
|
2566
|
+
exists: true;
|
|
2567
|
+
} | {
|
|
2568
|
+
path: string;
|
|
2569
|
+
oneOf: (string | number | boolean)[];
|
|
2570
|
+
} | {
|
|
2571
|
+
path: string;
|
|
2572
|
+
startsWith: string;
|
|
2573
|
+
} | {
|
|
2574
|
+
path: string;
|
|
2575
|
+
endsWith: string;
|
|
2576
|
+
} | {
|
|
2577
|
+
path: string;
|
|
2578
|
+
contains: string | number | boolean;
|
|
2579
|
+
})[];
|
|
2580
|
+
model: string | {
|
|
2581
|
+
path: string;
|
|
2582
|
+
bytes: [number, number];
|
|
2583
|
+
mask?: number | undefined;
|
|
2584
|
+
} | (string | {
|
|
2585
|
+
path: string;
|
|
2586
|
+
bytes: [number, number];
|
|
2587
|
+
mask?: number | undefined;
|
|
2588
|
+
})[];
|
|
2589
|
+
}[], {
|
|
2590
|
+
match: ({
|
|
2591
|
+
path: string;
|
|
2592
|
+
min?: number | undefined;
|
|
2593
|
+
max?: number | undefined;
|
|
2594
|
+
} | {
|
|
2595
|
+
path: string;
|
|
2596
|
+
equals: string | number | boolean;
|
|
2597
|
+
} | {
|
|
2598
|
+
path: string;
|
|
2599
|
+
exists: true;
|
|
2600
|
+
} | {
|
|
2601
|
+
path: string;
|
|
2602
|
+
oneOf: (string | number | boolean)[];
|
|
2603
|
+
} | {
|
|
2604
|
+
path: string;
|
|
2605
|
+
startsWith: string;
|
|
2606
|
+
} | {
|
|
2607
|
+
path: string;
|
|
2608
|
+
endsWith: string;
|
|
2609
|
+
} | {
|
|
2610
|
+
path: string;
|
|
2611
|
+
contains: string | number | boolean;
|
|
2612
|
+
})[];
|
|
2613
|
+
model: string | {
|
|
2614
|
+
path: string;
|
|
2615
|
+
bytes: [number, number];
|
|
2616
|
+
mask?: number | undefined;
|
|
2617
|
+
} | (string | {
|
|
2618
|
+
path: string;
|
|
2619
|
+
bytes: [number, number];
|
|
2620
|
+
mask?: number | undefined;
|
|
2621
|
+
})[];
|
|
2622
|
+
} | {
|
|
2623
|
+
match: ({
|
|
2624
|
+
path: string;
|
|
2625
|
+
min?: number | undefined;
|
|
2626
|
+
max?: number | undefined;
|
|
2627
|
+
} | {
|
|
2628
|
+
path: string;
|
|
2629
|
+
equals: string | number | boolean;
|
|
2630
|
+
} | {
|
|
2631
|
+
path: string;
|
|
2632
|
+
exists: true;
|
|
2633
|
+
} | {
|
|
2634
|
+
path: string;
|
|
2635
|
+
oneOf: (string | number | boolean)[];
|
|
2636
|
+
} | {
|
|
2637
|
+
path: string;
|
|
2638
|
+
startsWith: string;
|
|
2639
|
+
} | {
|
|
2640
|
+
path: string;
|
|
2641
|
+
endsWith: string;
|
|
2642
|
+
} | {
|
|
2643
|
+
path: string;
|
|
2644
|
+
contains: string | number | boolean;
|
|
2645
|
+
})[];
|
|
2646
|
+
model: string | {
|
|
2647
|
+
path: string;
|
|
2648
|
+
bytes: [number, number];
|
|
2649
|
+
mask?: number | undefined;
|
|
2650
|
+
} | (string | {
|
|
2651
|
+
path: string;
|
|
2652
|
+
bytes: [number, number];
|
|
2653
|
+
mask?: number | undefined;
|
|
2654
|
+
})[];
|
|
2655
|
+
}[]>>>;
|
|
2493
2656
|
adopt: z.ZodDefault<z.ZodEnum<{
|
|
2494
2657
|
owner: "owner";
|
|
2495
2658
|
automatic: "automatic";
|
|
@@ -830,7 +830,7 @@ function defineTransport(spec) {
|
|
|
830
830
|
* bundle built with this SDK says `^<major>.<minor>.0`.
|
|
831
831
|
*/
|
|
832
832
|
/** The SDK's own version: `1.0.0`, or a prerelease of it. */
|
|
833
|
-
const SDK_VERSION = "1.
|
|
833
|
+
const SDK_VERSION = "1.8.0";
|
|
834
834
|
/**
|
|
835
835
|
* The runtime range a bundle built with this SDK declares: this version's major and minor, so a
|
|
836
836
|
* platform with the same contract or a later one of the same major loads it.
|
package/dist/index.d.ts
CHANGED
|
@@ -190,7 +190,7 @@ type BluetoothAdvertInput = z.input<typeof bluetoothAdvertSchema>;
|
|
|
190
190
|
/** One advertisement heard. */
|
|
191
191
|
type BluetoothAdvert = z.output<typeof bluetoothAdvertSchema>;
|
|
192
192
|
/**
|
|
193
|
-
* What a device that can be a proxy declares in its profile: the scan modes
|
|
193
|
+
* What a device that can be a proxy declares in its profile: the scan modes its radio can run.
|
|
194
194
|
*/
|
|
195
195
|
declare const bluetoothProxyProfileSchema: z.ZodObject<{
|
|
196
196
|
modes: z.ZodArray<z.ZodEnum<{
|
|
@@ -207,13 +207,17 @@ declare const bluetoothProxyInstallArgsSchema: z.ZodObject<{
|
|
|
207
207
|
active: "active";
|
|
208
208
|
}>;
|
|
209
209
|
}, z.core.$strip>;
|
|
210
|
-
/** Arguments of `bluetooth-proxy.install`: the mode to
|
|
210
|
+
/** Arguments of `bluetooth-proxy.install`: the mode to rest in, which the hub picks. */
|
|
211
211
|
type BluetoothProxyInstallArgs = z.output<typeof bluetoothProxyInstallArgsSchema>;
|
|
212
212
|
/** Arguments of `bluetooth-proxy.filter`. */
|
|
213
213
|
declare const bluetoothProxyFilterArgsSchema: z.ZodObject<{
|
|
214
214
|
addresses: z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>]>;
|
|
215
|
+
active: z.ZodOptional<z.ZodBoolean>;
|
|
215
216
|
}, z.core.$strip>;
|
|
216
|
-
/**
|
|
217
|
+
/**
|
|
218
|
+
* Arguments of `bluetooth-proxy.filter`: the addresses to forward, upper case, or `all`, and
|
|
219
|
+
* whether the hub wants it scanning actively now.
|
|
220
|
+
*/
|
|
217
221
|
type BluetoothProxyFilterArgs = z.output<typeof bluetoothProxyFilterArgsSchema>;
|
|
218
222
|
/** What `bluetooth-proxy.state` answers: a device that can be a proxy, and whether it is one. */
|
|
219
223
|
declare const bluetoothProxyStateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -229,6 +233,7 @@ declare const bluetoothProxyStateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
229
233
|
battery: "battery";
|
|
230
234
|
firmware: "firmware";
|
|
231
235
|
"no-bluetooth": "no-bluetooth";
|
|
236
|
+
unsupported: "unsupported";
|
|
232
237
|
}>;
|
|
233
238
|
update: z.ZodOptional<z.ZodBoolean>;
|
|
234
239
|
}, z.core.$strip>], "eligible">;
|
|
@@ -782,6 +787,8 @@ export declare const BLUETOOTH_GATT_OPS: {
|
|
|
782
787
|
readonly read: "gatt.read";
|
|
783
788
|
readonly write: "gatt.write";
|
|
784
789
|
readonly notify: "gatt.notify";
|
|
790
|
+
/** Writes a request and answers what the device notifies back. */
|
|
791
|
+
readonly exchange: "gatt.exchange";
|
|
785
792
|
};
|
|
786
793
|
declare namespace infrared_codes_d_exports {
|
|
787
794
|
export { BROADLINK_TICK_US, DEFAULT_IR_CARRIER_HZ, FlipperIrCode, FlipperIrFile, InfraredImportProblem, decodeBroadlink, decodeInfraredProtocol, decodePronto, decodeRawTimings, encodeBroadlink, encodeInfraredProtocol, encodePronto, encodeRawTimings, parseFlipperIr, withInfraredProtocol };
|
|
@@ -1149,6 +1156,13 @@ type MappingContext = {
|
|
|
1149
1156
|
*/
|
|
1150
1157
|
lastState: (entityId: EntityId) => CapabilityState | undefined;
|
|
1151
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
|
+
};
|
|
1152
1166
|
/** A command, resolved to the device and entity it is for. */
|
|
1153
1167
|
type CommandTarget = {
|
|
1154
1168
|
readonly entityId: EntityId;
|
|
@@ -1231,6 +1245,21 @@ type Integration<TOptions = JsonObject> = {
|
|
|
1231
1245
|
* @returns The request. Performing it is the transport's job.
|
|
1232
1246
|
*/
|
|
1233
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;
|
|
1234
1263
|
/**
|
|
1235
1264
|
* Reads what a message says about the device itself, beyond its entities: the firmware it runs
|
|
1236
1265
|
* now, which changes when it is updated and is otherwise only known from when it was found.
|
|
@@ -1998,4 +2027,4 @@ export declare function defineAccountModule(factory: AccountFactory): AccountFac
|
|
|
1998
2027
|
*/
|
|
1999
2028
|
export declare function defineStreamModule(factory: StreamFactory): StreamFactory;
|
|
2000
2029
|
//#endregion
|
|
2001
|
-
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 };
|
|
2030
|
+
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>;
|
|
@@ -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.8.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.40",
|
|
66
|
+
"@nebulahome/contracts": "2026.10.0-alpha.40",
|
|
67
|
+
"@nebulahome/tsconfig": "2026.10.0-alpha.40",
|
|
68
|
+
"@nebulahome/eslint-config": "2026.10.0-alpha.40"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build": "tsdown && node scripts/build-schemas.js",
|