@nebulahome/integration-sdk 1.7.0 → 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/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.ZodArray<z.ZodString>]>>;
790
- }, z.core.$strict>>;
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 = [...devices.values()].find((candidate) => candidate.entityIds.includes(entityId));
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.7.0",
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/contracts": "2026.10.0-alpha.36",
66
- "@nebulahome/tsconfig": "2026.10.0-alpha.36",
67
- "@nebulahome/eslint-config": "2026.10.0-alpha.36",
68
- "@nebulahome/package-runtime": "2026.10.0-alpha.36"
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",