@deconz-community/ddf-validator 2.33.2 → 2.35.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.
@@ -1,23 +1,23 @@
1
1
  import { z as e } from "zod";
2
- const M = "2.33.2", O = {
2
+ const A = "2.35.0", _ = {
3
3
  "devcap1.schema.json": [
4
- z,
4
+ F,
5
+ k,
6
+ Z,
7
+ G,
5
8
  P,
6
- W,
7
- L,
8
- R,
9
- Y
9
+ M
10
10
  ],
11
11
  "constants2.schema.json": [
12
- N
12
+ z
13
13
  ]
14
14
  };
15
- function z(t, r, u) {
16
- const i = typeof t.manufacturername == "string" && typeof t.modelid == "string";
17
- if (i)
15
+ function F(t, r, m) {
16
+ const s = typeof t.manufacturername == "string" && typeof t.modelid == "string";
17
+ if (s)
18
18
  return;
19
- const c = Array.isArray(t.manufacturername) && Array.isArray(t.modelid);
20
- if (c && t.manufacturername.length !== t.modelid.length) {
19
+ const o = Array.isArray(t.manufacturername) && Array.isArray(t.modelid);
20
+ if (o && t.manufacturername.length !== t.modelid.length) {
21
21
  r.addIssue({
22
22
  code: e.ZodIssueCode.invalid_intersection_types,
23
23
  message: "When 'manufacturername' and 'modelid' are both arrays they should be the same length",
@@ -25,39 +25,38 @@ function z(t, r, u) {
25
25
  });
26
26
  return;
27
27
  }
28
- (i || c) === !1 && r.addIssue({
28
+ (s || o) === !1 && r.addIssue({
29
29
  code: e.ZodIssueCode.invalid_intersection_types,
30
30
  message: "Invalid properties 'manufacturername' and 'modelid' should have the same type",
31
31
  path: ["manufacturername", "modelid"]
32
32
  });
33
33
  }
34
- function P(t, r, u) {
34
+ function k(t, r, m) {
35
35
  if (!t.bindings)
36
36
  return;
37
- const i = (n) => `0x${(typeof n == "number" ? n : Number.parseInt(n, 16)).toString(16)}`, c = {};
37
+ const s = (n) => `0x${(typeof n == "number" ? n : Number.parseInt(n, 16)).toString(16)}`, o = {};
38
38
  t.bindings.forEach((n) => {
39
- n.bind === "unicast" && n.report && n.report.forEach((d) => {
40
- d.max !== 65535 && (c[`${i(n["src.ep"])}.${i(n.cl)}.${i(d.at)}`] = d.max);
39
+ n.bind === "unicast" && n.report && n.report.forEach((c) => {
40
+ c.max !== 65535 && (o[`${s(n["src.ep"])}.${s(n.cl)}.${s(c.at)}`] = c.max);
41
41
  });
42
- }), t.subdevices.forEach((n, d) => {
43
- n.items.forEach((a, m) => {
44
- var s;
42
+ }), t.subdevices.forEach((n, c) => {
43
+ n.items.forEach((a, d) => {
45
44
  if (a["refresh.interval"] && a.read && a.read.fn === "zcl:attr" && a.read.at) {
46
- const o = i(a.read.ep ?? ((s = n.fingerprint) == null ? void 0 : s.endpoint) ?? n.uuid[1]), p = Array.isArray(a.read.at) ? a.read.at : [a.read.at];
47
- for (let b = 0; b < p.length; b++) {
48
- const h = `${o}.${i(a.read.cl)}.${i(p[b])}`;
49
- c[h] !== void 0 && a["refresh.interval"] - 60 < c[h] && r.addIssue({
45
+ const i = s(a.read.ep ?? n.fingerprint?.endpoint ?? n.uuid[1]), u = Array.isArray(a.read.at) ? a.read.at : [a.read.at];
46
+ for (let p = 0; p < u.length; p++) {
47
+ const h = `${i}.${s(a.read.cl)}.${s(u[p])}`;
48
+ o[h] !== void 0 && a["refresh.interval"] - 60 < o[h] && r.addIssue({
50
49
  code: e.ZodIssueCode.custom,
51
- message: `The refresh interval (${a["refresh.interval"]} - 60 = ${a["refresh.interval"] - 60}) should be greater than the binding max refresh value (${c[h]}) with a margin of 60 seconds`,
52
- path: ["subdevices", d, "items", m, "refresh.interval"]
50
+ message: `The refresh interval (${a["refresh.interval"]} - 60 = ${a["refresh.interval"] - 60}) should be greater than the binding max refresh value (${o[h]}) with a margin of 60 seconds`,
51
+ path: ["subdevices", c, "items", d, "refresh.interval"]
53
52
  });
54
53
  }
55
54
  }
56
55
  });
57
56
  });
58
57
  }
59
- function W(t, r, u) {
60
- const i = [
58
+ function Z(t, r, m) {
59
+ const s = [
61
60
  /*
62
61
  {
63
62
  description: 'a device should always have basic attributes.',
@@ -147,100 +146,100 @@ function W(t, r, u) {
147
146
  }
148
147
  }
149
148
  }
150
- ], c = (n, d) => typeof n == "string" ? d(n) : Array.isArray(n) ? n.every((a) => c(a, d)) : "and" in n ? n.and.every((a) => c(a, d)) : "or" in n ? n.or.some((a) => c(a, d)) : !1;
151
- t.subdevices.forEach((n, d) => {
152
- const a = n.items.map((m) => m.name);
153
- i.forEach((m) => {
154
- (Object.keys(m.if).length === 0 || Object.entries(m.if).some(([s, o]) => {
155
- switch (s) {
149
+ ], o = (n, c) => typeof n == "string" ? c(n) : Array.isArray(n) ? n.every((a) => o(a, c)) : "and" in n ? n.and.every((a) => o(a, c)) : "or" in n ? n.or.some((a) => o(a, c)) : !1;
150
+ t.subdevices.forEach((n, c) => {
151
+ const a = n.items.map((d) => d.name);
152
+ s.forEach((d) => {
153
+ (Object.keys(d.if).length === 0 || Object.entries(d.if).some(([i, u]) => {
154
+ switch (i) {
156
155
  case "type":
157
- return c(o, (p) => p === n.type);
156
+ return o(u, (p) => p === n.type);
158
157
  case "item":
159
- return c(o, (p) => a.includes(p));
158
+ return o(u, (p) => a.includes(p));
160
159
  default:
161
160
  return !1;
162
161
  }
163
- })) && (c(m.need.item, (s) => a.includes(s)) || r.addIssue({
162
+ })) && (o(d.need.item, (i) => a.includes(i)) || r.addIssue({
164
163
  code: e.ZodIssueCode.custom,
165
- message: `The device is missing some items because ${m.description}`,
166
- path: ["subdevices", d, "items"]
164
+ message: `The device is missing some items because ${d.description}`,
165
+ path: ["subdevices", c, "items"]
167
166
  }));
168
167
  });
169
168
  });
170
169
  }
171
- function L(t, r, u) {
172
- const i = ["parse", "write"];
173
- t.subdevices.forEach((c, n) => {
174
- c.items.forEach((d, a) => {
175
- i.forEach((m) => {
176
- const s = d[m];
177
- s !== void 0 && (s.fn === void 0 || s.fn === "zcl:attr" || s.fn === "zcl:cmd") && (s.eval === void 0 && s.script === void 0 && r.addIssue({
170
+ function G(t, r, m) {
171
+ const s = ["parse", "write"];
172
+ t.subdevices.forEach((o, n) => {
173
+ o.items.forEach((c, a) => {
174
+ s.forEach((d) => {
175
+ const i = c[d];
176
+ i !== void 0 && (i.fn === void 0 || i.fn === "zcl:attr" || i.fn === "zcl:cmd") && (i.eval === void 0 && i.script === void 0 && r.addIssue({
178
177
  code: e.ZodIssueCode.custom,
179
- message: `The '${m}' function is missing 'eval' or 'script' option.`,
180
- path: ["subdevices", n, "items", a, m]
181
- }), s.eval !== void 0 && s.script !== void 0 && r.addIssue({
178
+ message: `The '${d}' function is missing 'eval' or 'script' option.`,
179
+ path: ["subdevices", n, "items", a, d]
180
+ }), i.eval !== void 0 && i.script !== void 0 && r.addIssue({
182
181
  code: e.ZodIssueCode.custom,
183
- message: `The '${m}' function is having both 'eval' and 'script' option.`,
184
- path: ["subdevices", n, "items", a, m]
182
+ message: `The '${d}' function is having both 'eval' and 'script' option.`,
183
+ path: ["subdevices", n, "items", a, d]
185
184
  }));
186
185
  });
187
186
  });
188
187
  });
189
188
  }
190
- function N(t, r, u) {
191
- const i = C();
192
- Object.keys(t).forEach((c) => {
193
- if (!Object.keys(i.shape).includes(c)) {
194
- if (!["$MF_", "$TYPE_"].some((n) => c.startsWith(n))) {
189
+ function z(t, r, m) {
190
+ const s = w();
191
+ Object.keys(t).forEach((o) => {
192
+ if (!Object.keys(s.shape).includes(o)) {
193
+ if (!["$MF_", "$TYPE_"].some((n) => o.startsWith(n))) {
195
194
  r.addIssue({
196
195
  code: e.ZodIssueCode.custom,
197
196
  message: "The constant key should start with '$MF_' or '$TYPE_'",
198
- path: [c]
197
+ path: [o]
199
198
  });
200
199
  return;
201
200
  }
202
- typeof t[c] != "string" && r.addIssue({
201
+ typeof t[o] != "string" && r.addIssue({
203
202
  code: e.ZodIssueCode.custom,
204
203
  message: "The constant value should be a string",
205
- path: [c]
204
+ path: [o]
206
205
  });
207
206
  }
208
207
  });
209
208
  }
210
- function R(t, r, u) {
211
- t.subdevices.forEach((i, c) => {
212
- const n = u.subDevices[i.type];
209
+ function P(t, r, m) {
210
+ t.subdevices.forEach((s, o) => {
211
+ const n = m.subDevices[s.type];
213
212
  if (!n) {
214
213
  r.addIssue({
215
214
  code: e.ZodIssueCode.custom,
216
- message: `The device is missing the device definition (subdevice1.schema.json) for the type "${i.type}"`,
217
- path: ["subdevices", c, "items"]
215
+ message: `The device is missing the device definition (subdevice1.schema.json) for the type "${s.type}"`,
216
+ path: ["subdevices", o, "items"]
218
217
  });
219
218
  return;
220
219
  }
221
- let d = n.items;
222
- n.items_optional && (d = d.filter((a) => !n.items_optional.includes(a))), d.forEach((a) => {
223
- i.items.find((m) => m.name === a) || r.addIssue({
220
+ let c = n.items;
221
+ n.items_optional && (c = c.filter((a) => !n.items_optional.includes(a))), c.forEach((a) => {
222
+ s.items.find((d) => d.name === a) || r.addIssue({
224
223
  code: e.ZodIssueCode.custom,
225
- message: `The device should have the item "${a}" because it is mandatory for devices of type "${i.type}"`,
226
- path: ["subdevices", c, "items"]
224
+ message: `The device should have the item "${a}" because it is mandatory for devices of type "${s.type}"`,
225
+ path: ["subdevices", o, "items"]
227
226
  });
228
227
  });
229
228
  });
230
229
  }
231
- function Y(t, r, u) {
232
- t.subdevices.forEach((i, c) => {
233
- const n = i.items.map((d) => d.name);
234
- i.items.forEach((d, a) => {
235
- d.parse && d.parse.fn === "numtostr" && (n.includes(d.parse.srcitem) || r.addIssue({
230
+ function M(t, r, m) {
231
+ t.subdevices.forEach((s, o) => {
232
+ const n = s.items.map((c) => c.name);
233
+ s.items.forEach((c, a) => {
234
+ c.parse && c.parse.fn === "numtostr" && (n.includes(c.parse.srcitem) || r.addIssue({
236
235
  code: e.ZodIssueCode.custom,
237
- message: `The device should have the item "${d.parse.srcitem}" because it is used in the 'numtostr' function`,
238
- path: ["subdevices", c, "items", a, "parse", "srcitem"]
236
+ message: `The device should have the item "${c.parse.srcitem}" because it is used in the 'numtostr' function`,
237
+ path: ["subdevices", o, "items", a, "parse", "srcitem"]
239
238
  }));
240
239
  });
241
240
  });
242
241
  }
243
- function B(t) {
242
+ function W(t) {
244
243
  return e.strictObject({
245
244
  $schema: e.optional(e.string()),
246
245
  schema: e.literal("constants1.schema.json"),
@@ -249,14 +248,14 @@ function B(t) {
249
248
  "device-types": e.record(e.string().startsWith("$TYPE_"), e.string())
250
249
  });
251
250
  }
252
- function C(t) {
251
+ function w(t) {
253
252
  return e.object({
254
253
  $schema: e.optional(e.string()),
255
254
  schema: e.literal("constants2.schema.json"),
256
255
  ddfvalidate: e.optional(e.boolean())
257
- }).passthrough();
256
+ }).loose();
258
257
  }
259
- function U() {
258
+ function L() {
260
259
  return e.string().regex(
261
260
  // Regex for AAAA-MM-JJ
262
261
  /^(\d{4})-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/,
@@ -273,19 +272,19 @@ function g() {
273
272
  e.number().min(0).max(255)
274
273
  ]);
275
274
  }
276
- function k() {
275
+ function N() {
277
276
  return e.custom((t) => {
278
277
  if (!Array.isArray(t) || t.length % 2 !== 0)
279
278
  return !1;
280
279
  for (let r = 0; r < t.length; r += 2) {
281
- const u = t[r], i = t[r + 1];
282
- if (typeof u != "number" || typeof i != "string")
280
+ const m = t[r], s = t[r + 1];
281
+ if (typeof m != "number" || typeof s != "string")
283
282
  return !1;
284
283
  }
285
284
  return !0;
286
285
  }, "The value must be an array with an even number of values and alternating between number and string.");
287
286
  }
288
- function S() {
287
+ function E() {
289
288
  return e.union([
290
289
  e.tuple([
291
290
  e.literal("$address.ext"),
@@ -298,10 +297,10 @@ function S() {
298
297
  ])
299
298
  ]);
300
299
  }
301
- function A() {
300
+ function O() {
302
301
  return e.string();
303
302
  }
304
- function F() {
303
+ function D() {
305
304
  return e.string();
306
305
  }
307
306
  const x = e.strictObject({
@@ -311,8 +310,8 @@ const x = e.strictObject({
311
310
  mf: e.optional(l(4)).describe("Manufacturer code, must be set to 0x0000 for non manufacturer specific commands."),
312
311
  cmd: e.optional(e.union([e.literal("any"), l(2)])).describe("Zigbee command."),
313
312
  fc: e.optional(l(2).or(e.number())).describe("Zigbee command frame control."),
314
- eval: e.optional(F()).describe("Javascript expression to transform the attribute value to the Item value."),
315
- script: e.optional(A()).describe("Relative path of a Javascript .js file.")
313
+ eval: e.optional(D()).describe("Javascript expression to transform the attribute value to the Item value."),
314
+ script: e.optional(O()).describe("Relative path of a Javascript .js file.")
316
315
  }), f = {
317
316
  read: x.extend({}),
318
317
  parse: x.extend({}),
@@ -322,7 +321,7 @@ const x = e.strictObject({
322
321
  dt: e.optional(l(2)).describe("Data type.")
323
322
  })
324
323
  };
325
- function V() {
324
+ function R() {
326
325
  return e.discriminatedUnion("fn", [
327
326
  e.strictObject({
328
327
  fn: e.literal("none")
@@ -343,7 +342,7 @@ function V() {
343
342
  message: "eval and script should not both be present"
344
343
  });
345
344
  }
346
- function q(t) {
345
+ function Y(t) {
347
346
  return e.discriminatedUnion("fn", [
348
347
  f.parse.extend({
349
348
  fn: e.undefined().describe("Generic function to read ZCL attributes."),
@@ -362,10 +361,10 @@ function q(t) {
362
361
  e.strictObject({
363
362
  fn: e.literal("numtostr").describe("Generic function to to convert number to string."),
364
363
  srcitem: e.enum(t.attributes, {
365
- errorMap: (r, u) => r.code === "invalid_enum_value" ? { message: `Invalid enum value. Expected item from generic attributes definition, received '${r.received}'` } : { message: u.defaultError }
364
+ error: (r) => r.code === "invalid_value" ? `Invalid enum value. Expected item from generic attributes definition, received '${r.input}'` : r.message
366
365
  }).describe("The source item holding the number."),
367
366
  op: e.enum(["lt", "le", "eq", "gt", "ge"]).describe("Comparison operator (lt | le | eq | gt | ge)"),
368
- to: k().describe("Array of (num, string) mappings")
367
+ to: N().describe("Array of (num, string) mappings")
369
368
  }),
370
369
  e.strictObject({
371
370
  fn: e.literal("time").describe("Specialized function to parse time, local and last set time from read/report commands of the time cluster and auto-sync time if needed.")
@@ -388,7 +387,7 @@ function q(t) {
388
387
  message: "eval and script should not both be present"
389
388
  });
390
389
  }
391
- function H() {
390
+ function B() {
392
391
  return e.discriminatedUnion("fn", [
393
392
  e.strictObject({
394
393
  fn: e.literal("none")
@@ -412,7 +411,7 @@ function H() {
412
411
  message: "eval and script should not both be present"
413
412
  });
414
413
  }
415
- function Z(t) {
414
+ function C(t) {
416
415
  return e.strictObject({
417
416
  $schema: e.optional(e.string()),
418
417
  schema: e.literal("resourceitem1.schema.json"),
@@ -420,7 +419,7 @@ function Z(t) {
420
419
  ddfvalidate: e.optional(e.boolean()),
421
420
  description: e.optional(e.string()).describe("Item description, better to do not use it."),
422
421
  comment: e.optional(e.string()).describe("TODO: What is this ? What the difference with description ?"),
423
- deprecated: e.optional(U()).describe("Date of deprecation, if the item is deprecated, it's better to use the new one."),
422
+ deprecated: e.optional(L()).describe("Date of deprecation, if the item is deprecated, it's better to use the new one."),
424
423
  datatype: e.optional(e.enum([
425
424
  "String",
426
425
  "Bool",
@@ -445,9 +444,9 @@ function Z(t) {
445
444
  static: e.optional(e.union([e.string(), e.number(), e.boolean()])).describe("A static default value is fixed and can be not changed."),
446
445
  range: e.optional(e.tuple([e.number(), e.number()])).describe("Values range limit."),
447
446
  virtual: e.optional(e.boolean()).describe("TODO: What is this ?"),
448
- read: e.optional(V()).describe("Fonction used to read value."),
449
- parse: e.optional(q(t)).describe("Fonction used to parse incoming values."),
450
- write: e.optional(H()).describe("Fonction used to write value."),
447
+ read: e.optional(R()).describe("Fonction used to read value."),
448
+ parse: e.optional(Y(t)).describe("Fonction used to parse incoming values."),
449
+ write: e.optional(B()).describe("Fonction used to write value."),
451
450
  "refresh.interval": e.optional(e.number()).describe("Refresh interval used for read fonction, NEED to be superior at value used in binding part."),
452
451
  // TODO Validate this
453
452
  values: e.optional(e.unknown()).describe("TODO: What is this ?"),
@@ -455,7 +454,7 @@ function Z(t) {
455
454
  default: e.optional(e.unknown()).describe("Defaut value.")
456
455
  });
457
456
  }
458
- function J(t) {
457
+ function U(t) {
459
458
  return e.strictObject({
460
459
  $schema: e.optional(e.string()),
461
460
  schema: e.literal("devcap1.schema.json"),
@@ -483,25 +482,25 @@ function J(t) {
483
482
  vendor: e.optional(e.string()).describe("Friendly name of the manufacturer."),
484
483
  product: e.optional(e.string()).describe("Friendly name of the product."),
485
484
  comment: e.optional(e.string()),
486
- matchexpr: e.optional(F()).describe("Need to return true for the DDF be used."),
487
- path: e.optional(A()).describe("DDF path, useless, can be removed."),
485
+ matchexpr: e.optional(D()).describe("Need to return true for the DDF be used."),
486
+ path: e.optional(O()).describe("DDF path, useless, can be removed."),
488
487
  sleeper: e.optional(e.boolean()).describe("Sleeping devices can only receive when awake."),
489
488
  supportsMgmtBind: e.optional(e.boolean()),
490
489
  status: e.enum(["Draft", "Bronze", "Silver", "Gold"]).describe("The code quality of the DDF file."),
491
- subdevices: e.array(X(t)).describe("Devices section."),
492
- bindings: e.optional(e.array(Q())).describe("Bindings section.")
490
+ subdevices: e.array(V(t)).describe("Devices section."),
491
+ bindings: e.optional(e.array(H())).describe("Bindings section.")
493
492
  });
494
493
  }
495
- function X(t) {
494
+ function V(t) {
496
495
  return e.strictObject({
497
496
  type: e.union([
498
497
  e.enum(Object.keys(t.deviceTypes), {
499
- errorMap: (r, u) => r.code === "invalid_enum_value" ? { message: `Invalid enum value. Expected type from generic attributes definition, received '${r.received}'` } : { message: u.defaultError }
498
+ error: (r) => r.code === "invalid_value" ? `Invalid enum value. Expected type from generic attributes definition, received '${r.received}'` : r.message
500
499
  }),
501
500
  e.string().regex(/^(?!\$TYPE_).*/g, "The type start with $TYPE_ but is not present in constants.json")
502
501
  ]),
503
502
  restapi: e.enum(["/lights", "/sensors"]),
504
- uuid: S(),
503
+ uuid: E(),
505
504
  fingerprint: e.optional(e.strictObject({
506
505
  profile: l(4),
507
506
  device: l(4),
@@ -518,22 +517,22 @@ function X(t) {
518
517
  buttons: e.optional(e.any()),
519
518
  // TODO validate this
520
519
  buttonevents: e.optional(e.any()),
521
- items: e.array(K(t)),
520
+ items: e.array(q(t)),
522
521
  example: e.optional(e.unknown())
523
522
  });
524
523
  }
525
- function K(t) {
526
- return Z(t).omit({
524
+ function q(t) {
525
+ return C(t).omit({
527
526
  $schema: !0,
528
527
  schema: !0,
529
528
  id: !0
530
529
  }).extend({
531
530
  name: e.enum(t.attributes, {
532
- errorMap: (r, u) => r.code === "invalid_enum_value" ? { message: `Invalid enum value. Expected item from generic attributes definition, received '${r.received}'` } : { message: u.defaultError }
531
+ error: (r) => r.code === "invalid_value" ? `Invalid enum value. Expected item from generic attributes definition, received '${r.received}'` : r.message
533
532
  }).describe("Item name.")
534
533
  });
535
534
  }
536
- function Q(t) {
535
+ function H(t) {
537
536
  return e.discriminatedUnion("bind", [
538
537
  e.strictObject({
539
538
  bind: e.literal("unicast"),
@@ -559,10 +558,10 @@ function Q(t) {
559
558
  })
560
559
  ]);
561
560
  }
562
- function ee(t) {
561
+ function J(t) {
563
562
  const r = e.array(
564
563
  e.enum(t.attributes, {
565
- errorMap: (u, i) => u.code === "invalid_enum_value" ? { message: `Invalid enum value. Expected item from generic attributes definition, received '${u.received}'` } : { message: i.defaultError }
564
+ error: (m) => m.code === "invalid_value" ? `Invalid enum value. Expected item from generic attributes definition, received '${m.input}'` : m.message
566
565
  })
567
566
  );
568
567
  return e.strictObject({
@@ -571,7 +570,7 @@ function ee(t) {
571
570
  ddfvalidate: e.optional(e.boolean()),
572
571
  type: e.union([
573
572
  e.enum(Object.keys(t.deviceTypes), {
574
- errorMap: (u, i) => u.code === "invalid_enum_value" ? { message: `Invalid enum value. Expected type from generic attributes definition, received '${u.received}'` } : { message: i.defaultError }
573
+ error: (m) => m.code === "invalid_value" ? `Invalid enum value. Expected type from generic attributes definition, received '${m.input}'` : m.message
575
574
  }),
576
575
  e.string().regex(/^(?!\$TYPE_).*/g, "The type start with $TYPE_ but is not present in constants.json")
577
576
  ]),
@@ -579,104 +578,102 @@ function ee(t) {
579
578
  ui_name: e.string().max(64),
580
579
  restapi: e.enum(["/lights", "/sensors"]),
581
580
  order: e.number(),
582
- uuid: S(),
581
+ uuid: E(),
583
582
  items: r,
584
583
  items_optional: e.optional(r)
585
584
  });
586
585
  }
587
- function D(t) {
586
+ function T(t) {
588
587
  return e.discriminatedUnion("schema", [
589
- J(t),
590
- B(),
591
- C(),
592
- Z(t),
593
- ee(t)
594
- ]).superRefine((r, u) => {
588
+ U(t),
589
+ W(),
590
+ w(),
591
+ C(t),
592
+ J(t)
593
+ ]).superRefine((r, m) => {
595
594
  switch (r.schema) {
596
595
  case "devcap1.schema.json":
597
- O[r.schema].map((i) => i(r, u, t));
596
+ _[r.schema].map((s) => s(r, m, t));
598
597
  break;
599
598
  case "constants2.schema.json":
600
- O[r.schema].map((i) => i(r, u, t));
599
+ _[r.schema].map((s) => s(r, m, t));
601
600
  break;
602
601
  }
603
602
  });
604
603
  }
605
- function re(t = {
604
+ function K(t = {
606
605
  attributes: [],
607
606
  manufacturers: {},
608
607
  deviceTypes: {},
609
608
  resources: {},
610
609
  subDevices: {}
611
610
  }) {
612
- let r = D(t);
613
- const u = () => {
614
- r = D(t);
615
- }, i = (m) => [
611
+ let r = T(t);
612
+ const m = () => {
613
+ r = T(t);
614
+ }, s = (d) => [
616
615
  "constants1.schema.json",
617
616
  "constants2.schema.json",
618
617
  "resourceitem1.schema.json",
619
618
  "subdevice1.schema.json"
620
- ].includes(m), c = (m) => m === "devcap1.schema.json", n = (m) => {
621
- const s = r.parse(m);
622
- switch (s.schema) {
619
+ ].includes(d), o = (d) => d === "devcap1.schema.json", n = (d) => {
620
+ const i = r.parse(d);
621
+ switch (i.schema) {
623
622
  case "constants1.schema.json":
624
623
  t.manufacturers = {
625
624
  ...t.manufacturers,
626
- ...s.manufacturers
625
+ ...i.manufacturers
627
626
  }, t.deviceTypes = {
628
627
  ...t.deviceTypes,
629
- ...s["device-types"]
628
+ ...i["device-types"]
630
629
  };
631
630
  break;
632
631
  case "constants2.schema.json": {
633
- Object.keys(s).filter((o) => o.startsWith("$MF_")).forEach((o) => {
634
- t.manufacturers[o] = s[o];
635
- }), Object.keys(s).filter((o) => o.startsWith("$TYPE_")).forEach((o) => {
636
- t.deviceTypes[o] = s[o];
632
+ Object.keys(i).filter((u) => u.startsWith("$MF_")).forEach((u) => {
633
+ t.manufacturers[u] = i[u];
634
+ }), Object.keys(i).filter((u) => u.startsWith("$TYPE_")).forEach((u) => {
635
+ t.deviceTypes[u] = i[u];
637
636
  });
638
637
  break;
639
638
  }
640
639
  case "resourceitem1.schema.json": {
641
- if (t.attributes.includes(s.id))
642
- throw new Error(`Got duplicate resource item with attribute id '${s.id}'.`);
643
- const o = s, p = s.id;
644
- delete o.$schema, delete o.schema, delete o.id, t.resources[p] = o, t.attributes.push(p);
640
+ if (t.attributes.includes(i.id))
641
+ throw new Error(`Got duplicate resource item with attribute id '${i.id}'.`);
642
+ const u = i, p = i.id;
643
+ delete u.$schema, delete u.schema, delete u.id, t.resources[p] = u, t.attributes.push(p);
645
644
  break;
646
645
  }
647
646
  case "subdevice1.schema.json":
648
- t.subDevices[s.type] = s, t.subDevices[s.name] = s;
647
+ t.subDevices[i.type] = i, t.subDevices[i.name] = i;
649
648
  break;
650
649
  default:
651
- throw new Error(`Got invalid generic file, got data with schema '${s.schema}'.`);
650
+ throw new Error(`Got invalid generic file, got data with schema '${i.schema}'.`);
652
651
  }
653
- return u(), !0;
654
- }, d = (m) => r.parse(m);
655
- return { generics: t, loadGeneric: n, validate: d, bulkValidate: (m, s, o = {}) => {
656
- const p = (b, h) => {
657
- var j, E, T;
658
- let I = 0, _ = Number.POSITIVE_INFINITY, $ = b, v = [];
659
- for ((j = o.onSectionStart) == null || j.call(o, h, b.length); v = [], (E = o.onSectionProgress) == null || E.call(o, h, 1, b.length), $.forEach((y) => {
660
- var w;
661
- (w = o.onSectionProgress) == null || w.call(o, h, I++, b.length);
652
+ return m(), !0;
653
+ }, c = (d) => r.parse(d);
654
+ return { generics: t, loadGeneric: n, validate: c, bulkValidate: (d, i, u = {}) => {
655
+ const p = (h, v) => {
656
+ let I = 0, $ = Number.POSITIVE_INFINITY, j = h, b = [];
657
+ for (u.onSectionStart?.(v, h.length); b = [], u.onSectionProgress?.(v, 1, h.length), j.forEach((y) => {
658
+ u.onSectionProgress?.(v, I++, h.length);
662
659
  try {
663
- h === "generic" ? n(y.data) : h === "ddf" && d(y.data);
664
- } catch (G) {
665
- v.push({
660
+ v === "generic" ? n(y.data) : v === "ddf" && c(y.data);
661
+ } catch (S) {
662
+ b.push({
666
663
  ...y,
667
- error: G
664
+ error: S
668
665
  });
669
666
  }
670
- }), !(v.length === 0 || v.length >= _); )
671
- I -= v.length, $ = v, _ = v.length;
672
- return (T = o.onSectionEnd) == null || T.call(o, h, b.length, v), v;
667
+ }), !(b.length === 0 || b.length >= $); )
668
+ I -= b.length, j = b, $ = b.length;
669
+ return u.onSectionEnd?.(v, h.length, b), b;
673
670
  };
674
671
  return [
675
- ...p(m, "generic"),
676
- ...p(s, "ddf")
672
+ ...p(d, "generic"),
673
+ ...p(i, "ddf")
677
674
  ];
678
- }, getSchema: () => r, version: M, isGeneric: i, isDDF: c };
675
+ }, getSchema: () => r, version: A, isGeneric: s, isDDF: o };
679
676
  }
680
677
  export {
681
- re as createValidator
678
+ K as createValidator
682
679
  };