@deconz-community/ddf-validator 2.18.0 → 2.19.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/README.md +51 -2
- package/dist/ddf-schema.json +1 -1
- package/dist/ddf-validator.cjs +1 -1
- package/dist/ddf-validator.d.ts +191 -237
- package/dist/ddf-validator.mjs +257 -310
- package/package.json +11 -11
package/dist/ddf-validator.mjs
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
1
|
import { z as e } from "zod";
|
|
2
|
-
const
|
|
2
|
+
const M = "2.19.0", O = {
|
|
3
3
|
"devcap1.schema.json": [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
z,
|
|
5
|
+
P,
|
|
6
|
+
W,
|
|
7
|
+
L,
|
|
8
|
+
N,
|
|
9
|
+
Y
|
|
10
10
|
],
|
|
11
11
|
"constants2.schema.json": [
|
|
12
|
-
|
|
12
|
+
R
|
|
13
13
|
]
|
|
14
14
|
};
|
|
15
|
-
function
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
15
|
+
function z(t, r, u) {
|
|
16
|
+
const i = typeof t.manufacturername == "string" && typeof t.modelid == "string";
|
|
17
|
+
if (i)
|
|
18
18
|
return;
|
|
19
|
-
const
|
|
20
|
-
if (
|
|
21
|
-
|
|
19
|
+
const c = Array.isArray(t.manufacturername) && Array.isArray(t.modelid);
|
|
20
|
+
if (c && t.manufacturername.length !== t.modelid.length) {
|
|
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",
|
|
24
24
|
path: ["manufacturername", "modelid"]
|
|
25
25
|
});
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
(
|
|
28
|
+
(i || c) === !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
|
|
34
|
+
function P(t, r, u) {
|
|
35
35
|
if (!t.bindings)
|
|
36
36
|
return;
|
|
37
|
-
const
|
|
38
|
-
t.bindings.forEach((
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
const i = (n) => `0x${(typeof n == "number" ? n : Number.parseInt(n, 16)).toString(16)}`, c = {};
|
|
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);
|
|
41
41
|
});
|
|
42
|
-
}), t.subdevices.forEach((
|
|
43
|
-
|
|
44
|
-
var
|
|
45
|
-
if (
|
|
46
|
-
const
|
|
47
|
-
for (let
|
|
48
|
-
const
|
|
49
|
-
|
|
42
|
+
}), t.subdevices.forEach((n, d) => {
|
|
43
|
+
n.items.forEach((a, m) => {
|
|
44
|
+
var s;
|
|
45
|
+
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({
|
|
50
50
|
code: e.ZodIssueCode.custom,
|
|
51
|
-
message: `The refresh interval (${
|
|
52
|
-
path: ["subdevices",
|
|
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"]
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
const
|
|
59
|
+
function W(t, r, u) {
|
|
60
|
+
const i = [
|
|
61
61
|
/*
|
|
62
62
|
{
|
|
63
63
|
description: 'a device should always have basic attributes.',
|
|
@@ -147,100 +147,100 @@ function $(t, a, u) {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
],
|
|
151
|
-
t.subdevices.forEach((
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
(Object.keys(
|
|
155
|
-
switch (
|
|
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) {
|
|
156
156
|
case "type":
|
|
157
|
-
return
|
|
157
|
+
return c(o, (p) => p === n.type);
|
|
158
158
|
case "item":
|
|
159
|
-
return
|
|
159
|
+
return c(o, (p) => a.includes(p));
|
|
160
160
|
default:
|
|
161
161
|
return !1;
|
|
162
162
|
}
|
|
163
|
-
})) && (
|
|
163
|
+
})) && (c(m.need.item, (s) => a.includes(s)) || r.addIssue({
|
|
164
164
|
code: e.ZodIssueCode.custom,
|
|
165
|
-
message: `The device is missing some items because ${
|
|
166
|
-
path: ["subdevices",
|
|
165
|
+
message: `The device is missing some items because ${m.description}`,
|
|
166
|
+
path: ["subdevices", d, "items"]
|
|
167
167
|
}));
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
|
-
function
|
|
172
|
-
const
|
|
173
|
-
t.subdevices.forEach((
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
|
|
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({
|
|
178
178
|
code: e.ZodIssueCode.custom,
|
|
179
|
-
message: `The '${
|
|
180
|
-
path: ["subdevices",
|
|
181
|
-
}),
|
|
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({
|
|
182
182
|
code: e.ZodIssueCode.custom,
|
|
183
|
-
message: `The '${
|
|
184
|
-
path: ["subdevices",
|
|
183
|
+
message: `The '${m}' function is having both 'eval' and 'script' option.`,
|
|
184
|
+
path: ["subdevices", n, "items", a, m]
|
|
185
185
|
}));
|
|
186
186
|
});
|
|
187
187
|
});
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
|
-
function
|
|
191
|
-
const
|
|
192
|
-
Object.keys(t).forEach((
|
|
193
|
-
if (!Object.keys(
|
|
194
|
-
if (!["$MF_", "$TYPE_"].some((
|
|
195
|
-
|
|
190
|
+
function R(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))) {
|
|
195
|
+
r.addIssue({
|
|
196
196
|
code: e.ZodIssueCode.custom,
|
|
197
197
|
message: "The constant key should start with '$MF_' or '$TYPE_'",
|
|
198
|
-
path: [
|
|
198
|
+
path: [c]
|
|
199
199
|
});
|
|
200
200
|
return;
|
|
201
201
|
}
|
|
202
|
-
typeof t[
|
|
202
|
+
typeof t[c] != "string" && r.addIssue({
|
|
203
203
|
code: e.ZodIssueCode.custom,
|
|
204
204
|
message: "The constant value should be a string",
|
|
205
|
-
path: [
|
|
205
|
+
path: [c]
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
|
-
function
|
|
211
|
-
t.subdevices.forEach((
|
|
212
|
-
const
|
|
213
|
-
if (!
|
|
214
|
-
|
|
210
|
+
function N(t, r, u) {
|
|
211
|
+
t.subdevices.forEach((i, c) => {
|
|
212
|
+
const n = u.subDevices[i.type];
|
|
213
|
+
if (!n) {
|
|
214
|
+
r.addIssue({
|
|
215
215
|
code: e.ZodIssueCode.custom,
|
|
216
|
-
message: `The device is missing the device definition for the type "${
|
|
217
|
-
path: ["subdevices",
|
|
216
|
+
message: `The device is missing the device definition for the type "${i.type}"`,
|
|
217
|
+
path: ["subdevices", c, "items"]
|
|
218
218
|
});
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
|
-
let
|
|
222
|
-
|
|
223
|
-
|
|
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({
|
|
224
224
|
code: e.ZodIssueCode.custom,
|
|
225
|
-
message: `The device should have the item "${
|
|
226
|
-
path: ["subdevices",
|
|
225
|
+
message: `The device should have the item "${a}" because it is mandatory for devices of type "${i.type}"`,
|
|
226
|
+
path: ["subdevices", c, "items"]
|
|
227
227
|
});
|
|
228
228
|
});
|
|
229
229
|
});
|
|
230
230
|
}
|
|
231
|
-
function
|
|
232
|
-
t.subdevices.forEach((
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
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({
|
|
236
236
|
code: e.ZodIssueCode.custom,
|
|
237
|
-
message: `The device should have the item "${
|
|
238
|
-
path: ["subdevices",
|
|
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"]
|
|
239
239
|
}));
|
|
240
240
|
});
|
|
241
241
|
});
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function B(t) {
|
|
244
244
|
return e.strictObject({
|
|
245
245
|
$schema: e.optional(e.string()),
|
|
246
246
|
schema: e.literal("constants1.schema.json"),
|
|
@@ -248,100 +248,92 @@ function M(t) {
|
|
|
248
248
|
"device-types": e.record(e.string().startsWith("$TYPE_"), e.string())
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
|
-
function
|
|
251
|
+
function C(t) {
|
|
252
252
|
return e.object({
|
|
253
253
|
$schema: e.optional(e.string()),
|
|
254
254
|
schema: e.literal("constants2.schema.json")
|
|
255
255
|
}).passthrough();
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function U() {
|
|
258
258
|
return e.string().regex(
|
|
259
259
|
// Regex for AAAA-MM-JJ
|
|
260
260
|
/^(\d{4})-(?:(?:0[1-9])|(?:1[0-2]))-(?:(?:0[1-9])|(?:[12][0-9])|(?:3[01]))$/,
|
|
261
261
|
"Invalid date value"
|
|
262
262
|
);
|
|
263
263
|
}
|
|
264
|
-
function
|
|
265
|
-
const
|
|
266
|
-
return t === void 0 ? e.string().regex(/^0x[0-9a-fA-F]+$/,
|
|
264
|
+
function l(t = void 0) {
|
|
265
|
+
const r = "Invalid hexadecimal value";
|
|
266
|
+
return t === void 0 ? e.string().regex(/^0x[0-9a-fA-F]+$/, r) : e.string().regex(new RegExp(`^0x[0-9a-fA-F]{${t}}$`), r);
|
|
267
267
|
}
|
|
268
|
-
function
|
|
268
|
+
function g() {
|
|
269
269
|
return e.union([
|
|
270
|
-
|
|
270
|
+
l(2),
|
|
271
271
|
e.number().min(0).max(255)
|
|
272
272
|
]);
|
|
273
273
|
}
|
|
274
|
-
function
|
|
274
|
+
function k() {
|
|
275
275
|
return e.custom((t) => {
|
|
276
276
|
if (!Array.isArray(t) || t.length % 2 !== 0)
|
|
277
277
|
return !1;
|
|
278
|
-
for (let
|
|
279
|
-
const u = t[
|
|
280
|
-
if (typeof u != "number" || typeof
|
|
278
|
+
for (let r = 0; r < t.length; r += 2) {
|
|
279
|
+
const u = t[r], i = t[r + 1];
|
|
280
|
+
if (typeof u != "number" || typeof i != "string")
|
|
281
281
|
return !1;
|
|
282
282
|
}
|
|
283
283
|
return !0;
|
|
284
284
|
}, "The value must be an array with an even number of values and alternating between number and string.");
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function S() {
|
|
287
287
|
return e.union([
|
|
288
288
|
e.tuple([
|
|
289
289
|
e.literal("$address.ext"),
|
|
290
|
-
|
|
290
|
+
l(2)
|
|
291
291
|
]),
|
|
292
292
|
e.tuple([
|
|
293
293
|
e.literal("$address.ext"),
|
|
294
|
-
|
|
295
|
-
|
|
294
|
+
l(2),
|
|
295
|
+
l(4)
|
|
296
296
|
])
|
|
297
297
|
]);
|
|
298
298
|
}
|
|
299
|
-
function
|
|
299
|
+
function A() {
|
|
300
300
|
return e.string();
|
|
301
301
|
}
|
|
302
|
-
function
|
|
302
|
+
function F() {
|
|
303
303
|
return e.string();
|
|
304
304
|
}
|
|
305
|
-
|
|
305
|
+
const x = e.strictObject({
|
|
306
|
+
ep: e.optional(g()).describe("Endpoint, 255 means any endpoint, 0 means auto selected from subdevice."),
|
|
307
|
+
cl: l(4).describe("Cluster ID."),
|
|
308
|
+
at: e.optional(l(4).or(e.array(l(4)))).describe("Attribute ID."),
|
|
309
|
+
mf: e.optional(l(4)).describe("Manufacturer code, must be set to 0x0000 for non manufacturer specific commands."),
|
|
310
|
+
cmd: e.optional(l(2)).describe("Zigbee command."),
|
|
311
|
+
eval: e.optional(F()).describe("Javascript expression to transform the attribute value to the Item value."),
|
|
312
|
+
script: e.optional(A()).describe("Relative path of a Javascript .js file.")
|
|
313
|
+
}), f = {
|
|
314
|
+
read: x.extend({
|
|
315
|
+
fc: e.optional(l(2).or(e.number())).describe("Zigbee command frame control.")
|
|
316
|
+
}),
|
|
317
|
+
parse: x.extend({}),
|
|
318
|
+
write: x.extend({
|
|
319
|
+
"state.timeout": e.optional(e.number()),
|
|
320
|
+
"change.timeout": e.optional(e.number()),
|
|
321
|
+
dt: e.optional(l(2)).describe("Data type.")
|
|
322
|
+
})
|
|
323
|
+
};
|
|
324
|
+
function V() {
|
|
306
325
|
return e.discriminatedUnion("fn", [
|
|
307
326
|
e.strictObject({
|
|
308
327
|
fn: e.literal("none")
|
|
309
328
|
}),
|
|
310
|
-
|
|
311
|
-
fn: e.undefined().describe("Generic function to read ZCL attributes.")
|
|
312
|
-
at: r(4).or(e.array(r(4))).describe("Attribute ID."),
|
|
313
|
-
cl: r(4).describe("Cluster ID."),
|
|
314
|
-
ep: e.optional(m()).describe("Endpoint, 255 means any endpoint, 0 means auto selected from subdevice."),
|
|
315
|
-
mf: e.optional(r(4)).describe("Manufacturer code, must be set to 0x0000 for non manufacturer specific commands."),
|
|
316
|
-
eval: e.optional(p()).describe("Javascript expression to transform the raw value.")
|
|
329
|
+
f.read.extend({
|
|
330
|
+
fn: e.undefined().describe("Generic function to read ZCL attributes.")
|
|
317
331
|
}),
|
|
318
|
-
|
|
319
|
-
fn: e.literal("zcl").describe("Generic function to
|
|
320
|
-
at: r(4).or(e.array(r(4))).describe("Attribute ID."),
|
|
321
|
-
cl: r(4).describe("Cluster ID."),
|
|
322
|
-
ep: e.optional(m()).describe("Endpoint, 255 means any endpoint, 0 means auto selected from subdevice."),
|
|
323
|
-
mf: e.optional(r(4)).describe("Manufacturer code, must be set to 0x0000 for non manufacturer specific commands."),
|
|
324
|
-
eval: e.optional(p()).describe("Javascript expression to transform the raw value."),
|
|
325
|
-
script: e.optional(f()).describe("Relative path of a Javascript .js file.")
|
|
326
|
-
}).describe("Deprecated"),
|
|
327
|
-
e.strictObject({
|
|
328
|
-
fn: e.literal("zcl:attr").describe("Generic function to parse ZCL values from read/report commands."),
|
|
329
|
-
at: r(4).or(e.array(r(4))).describe("String hex value or array of string hex values."),
|
|
330
|
-
cl: r(4).describe("Cluster ID."),
|
|
331
|
-
ep: e.optional(m()).describe("Endpoint, 255 means any endpoint, 0 means auto selected from subdevice."),
|
|
332
|
-
mf: e.optional(r(4)).describe("Manufacturer code, must be set to 0x0000 for non manufacturer specific commands."),
|
|
333
|
-
eval: e.optional(p()).describe("Javascript expression to transform the attribute value to the Item value."),
|
|
334
|
-
script: e.optional(f()).describe("Relative path of a Javascript .js file.")
|
|
332
|
+
f.read.extend({
|
|
333
|
+
fn: e.literal("zcl:attr").describe("Generic function to parse ZCL values from read/report commands.")
|
|
335
334
|
}),
|
|
336
|
-
|
|
337
|
-
fn: e.literal("zcl:cmd").describe("Generic function to parse ZCL values from read/report commands.")
|
|
338
|
-
cl: r(4).describe("Cluster ID."),
|
|
339
|
-
ep: e.optional(m()).describe("Endpoint, 255 means any endpoint, 0 means auto selected from subdevice."),
|
|
340
|
-
mf: e.optional(r(4)).describe("Manufacturer code, must be set to 0x0000 for non manufacturer specific commands."),
|
|
341
|
-
cmd: e.optional(r(2)).describe("Zigbee command."),
|
|
342
|
-
eval: e.optional(p()).describe("Javascript expression to transform the attribute value to the Item value."),
|
|
343
|
-
fc: e.optional(r(2).or(e.number())).describe("Zigbee command frame control."),
|
|
344
|
-
script: e.optional(f()).describe("Relative path of a Javascript .js file.")
|
|
335
|
+
f.read.extend({
|
|
336
|
+
fn: e.literal("zcl:cmd").describe("Generic function to parse ZCL values from read/report commands.")
|
|
345
337
|
}),
|
|
346
338
|
e.strictObject({
|
|
347
339
|
fn: e.literal("tuya").describe("Generic function to read all Tuya datapoints. It has no parameters.")
|
|
@@ -350,47 +342,17 @@ function Z() {
|
|
|
350
342
|
message: "eval and script should not both be present"
|
|
351
343
|
});
|
|
352
344
|
}
|
|
353
|
-
function
|
|
345
|
+
function q(t) {
|
|
354
346
|
return e.discriminatedUnion("fn", [
|
|
355
|
-
|
|
356
|
-
fn: e.undefined().describe("Generic function to
|
|
357
|
-
|
|
358
|
-
cl: r(4).describe("Cluster ID."),
|
|
359
|
-
cppsrc: e.optional(e.string()),
|
|
360
|
-
ep: e.optional(m()).describe("Endpoint, 255 means any endpoint, 0 means auto selected from subdevice."),
|
|
361
|
-
cmd: e.optional(r(2)).describe("Zigbee command."),
|
|
362
|
-
mf: e.optional(r(4)).describe("Manufacturer code, must be set to 0x0000 for non manufacturer specific commands."),
|
|
363
|
-
eval: e.optional(p()).describe("Javascript expression to transform the raw value."),
|
|
364
|
-
script: e.optional(f()).describe("Relative path of a Javascript .js file.")
|
|
347
|
+
f.parse.extend({
|
|
348
|
+
fn: e.undefined().describe("Generic function to read ZCL attributes."),
|
|
349
|
+
cppsrc: e.optional(e.string())
|
|
365
350
|
}),
|
|
366
|
-
|
|
367
|
-
fn: e.literal("zcl").describe("Generic function to parse ZCL
|
|
368
|
-
at: e.optional(r(4).or(e.array(r(4)))).describe("Attribute ID."),
|
|
369
|
-
cl: r(4).describe("Cluster ID."),
|
|
370
|
-
cppsrc: e.optional(e.string()),
|
|
371
|
-
ep: e.optional(m()).describe("Endpoint, 255 means any endpoint, 0 means auto selected from subdevice."),
|
|
372
|
-
cmd: e.optional(r(2)).describe("Zigbee command."),
|
|
373
|
-
mf: e.optional(r(4)).describe("Manufacturer code, must be set to 0x0000 for non manufacturer specific commands."),
|
|
374
|
-
eval: e.optional(p()).describe("Javascript expression to transform the raw value."),
|
|
375
|
-
script: e.optional(f()).describe("Relative path of a Javascript .js file.")
|
|
376
|
-
}).describe("Deprecated"),
|
|
377
|
-
e.strictObject({
|
|
378
|
-
fn: e.literal("zcl:attr").describe("Generic function to parse ZCL values from read/report commands."),
|
|
379
|
-
at: r(4).or(e.array(r(4))).describe("String hex value or array of string hex values."),
|
|
380
|
-
cl: r(4).describe("Cluster ID."),
|
|
381
|
-
ep: e.optional(m()).describe("Endpoint, 255 means any endpoint, 0 means auto selected from subdevice."),
|
|
382
|
-
mf: e.optional(r(4)).describe("Manufacturer code, must be set to 0x0000 for non manufacturer specific commands."),
|
|
383
|
-
eval: e.optional(p()).describe("Javascript expression to transform the attribute value to the Item value."),
|
|
384
|
-
script: e.optional(f()).describe("Relative path of a Javascript .js file.")
|
|
351
|
+
f.parse.extend({
|
|
352
|
+
fn: e.literal("zcl:attr").describe("Generic function to parse ZCL values from read/report commands.")
|
|
385
353
|
}),
|
|
386
|
-
|
|
387
|
-
fn: e.literal("zcl:cmd").describe("Generic function to parse ZCL values from read/report commands.")
|
|
388
|
-
cl: r(4).describe("Cluster ID."),
|
|
389
|
-
ep: e.optional(m()).describe("Endpoint, 255 means any endpoint, 0 means auto selected from subdevice."),
|
|
390
|
-
mf: e.optional(r(4)).describe("Manufacturer code, must be set to 0x0000 for non manufacturer specific commands."),
|
|
391
|
-
cmd: e.optional(r(2)).describe("Zigbee command."),
|
|
392
|
-
eval: e.optional(p()).describe("Javascript expression to transform the attribute value to the Item value."),
|
|
393
|
-
script: e.optional(f()).describe("Relative path of a Javascript .js file.")
|
|
354
|
+
f.parse.extend({
|
|
355
|
+
fn: e.literal("zcl:cmd").describe("Generic function to parse ZCL values from read/report commands.")
|
|
394
356
|
}),
|
|
395
357
|
e.strictObject({
|
|
396
358
|
fn: e.literal("ias:zonestatus").describe("Generic function to parse IAS ZONE status change notifications or zone status from read/report command."),
|
|
@@ -399,102 +361,64 @@ function G(t) {
|
|
|
399
361
|
e.strictObject({
|
|
400
362
|
fn: e.literal("numtostr").describe("Generic function to to convert number to string."),
|
|
401
363
|
srcitem: e.enum(t.attributes, {
|
|
402
|
-
errorMap: (
|
|
364
|
+
errorMap: (r, u) => r.code === "invalid_enum_value" ? { message: `Invalid enum value. Expected item from generic attributes definition, received '${r.received}'` } : { message: u.defaultError }
|
|
403
365
|
}).describe("The source item holding the number."),
|
|
404
366
|
op: e.enum(["lt", "le", "eq", "gt", "ge"]).describe("Comparison operator (lt | le | eq | gt | ge)"),
|
|
405
|
-
to:
|
|
367
|
+
to: k().describe("Array of (num, string) mappings")
|
|
406
368
|
}),
|
|
407
369
|
e.strictObject({
|
|
408
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.")
|
|
409
371
|
}),
|
|
410
|
-
|
|
372
|
+
f.parse.pick({
|
|
373
|
+
ep: !0,
|
|
374
|
+
at: !0,
|
|
375
|
+
mf: !0,
|
|
376
|
+
eval: !0,
|
|
377
|
+
script: !0
|
|
378
|
+
}).extend({
|
|
411
379
|
fn: e.literal("xiaomi:special").describe("Generic function to parse custom Xiaomi attributes and commands."),
|
|
412
|
-
|
|
413
|
-
mf: e.optional(r(4)).describe("Manufacturer code, must be set to 0x0000 for non manufacturer specific commands."),
|
|
414
|
-
at: e.optional(r(4)).describe("Attribute ID. The attribute to parse, shall be 0xff01, 0xff02 or 0x00f7"),
|
|
415
|
-
idx: r(2).describe("A 8-bit string hex value."),
|
|
416
|
-
eval: e.optional(p()).describe("Javascript expression to transform the raw value."),
|
|
417
|
-
script: e.optional(f()).describe("Relative path of a Javascript .js file.")
|
|
380
|
+
idx: l(2).describe("A 8-bit string hex value.")
|
|
418
381
|
}),
|
|
419
|
-
|
|
382
|
+
f.parse.pick({ eval: !0, script: !0 }).extend({
|
|
420
383
|
fn: e.literal("tuya").describe("Generic function to parse Tuya data."),
|
|
421
|
-
dpid: e.number().describe("Data point ID. 1-255 the datapoint ID.")
|
|
422
|
-
eval: e.optional(p()).describe("Javascript expression to transform the raw value."),
|
|
423
|
-
script: e.optional(f()).describe("Relative path of a Javascript .js file.")
|
|
384
|
+
dpid: e.number().describe("Data point ID. 1-255 the datapoint ID.")
|
|
424
385
|
})
|
|
425
|
-
]).refine((
|
|
386
|
+
]).refine((r) => !("eval" in r && "script" in r), {
|
|
426
387
|
message: "eval and script should not both be present"
|
|
427
388
|
});
|
|
428
389
|
}
|
|
429
|
-
function
|
|
390
|
+
function H() {
|
|
430
391
|
return e.discriminatedUnion("fn", [
|
|
431
392
|
e.strictObject({
|
|
432
393
|
fn: e.literal("none")
|
|
433
394
|
}),
|
|
434
|
-
|
|
435
|
-
fn: e.undefined(),
|
|
436
|
-
|
|
437
|
-
"state.timeout": e.optional(e.number()),
|
|
438
|
-
"change.timeout": e.optional(e.number()),
|
|
439
|
-
cl: r(4).describe("Cluster ID."),
|
|
440
|
-
dt: r(2).describe("Data type."),
|
|
441
|
-
ep: e.optional(m()).describe("Endpoint, 255 means any endpoint, 0 means auto selected from subdevice."),
|
|
442
|
-
mf: e.optional(r(4)).describe("Manufacturer code, must be set to 0x0000 for non manufacturer specific commands."),
|
|
443
|
-
eval: e.optional(p()).describe("Javascript expression to transform the raw value."),
|
|
444
|
-
script: e.optional(f()).describe("Relative path of a Javascript .js file.")
|
|
395
|
+
f.write.extend({
|
|
396
|
+
fn: e.undefined().describe("Generic function to read ZCL attributes."),
|
|
397
|
+
cppsrc: e.optional(e.string())
|
|
445
398
|
}),
|
|
446
|
-
|
|
447
|
-
fn: e.literal("zcl")
|
|
448
|
-
at: e.optional(r(4).or(e.array(r(4)))).describe("Attribute ID."),
|
|
449
|
-
"state.timeout": e.optional(e.number()),
|
|
450
|
-
"change.timeout": e.optional(e.number()),
|
|
451
|
-
cl: r(4).describe("Cluster ID."),
|
|
452
|
-
dt: r(2).describe("Data type."),
|
|
453
|
-
ep: e.optional(m()).describe("Endpoint, 255 means any endpoint, 0 means auto selected from subdevice."),
|
|
454
|
-
mf: e.optional(r(4)).describe("Manufacturer code, must be set to 0x0000 for non manufacturer specific commands."),
|
|
455
|
-
eval: e.optional(p()).describe("Javascript expression to transform the raw value."),
|
|
456
|
-
script: e.optional(f()).describe("Relative path of a Javascript .js file.")
|
|
457
|
-
}).describe("Deprecated"),
|
|
458
|
-
e.strictObject({
|
|
459
|
-
fn: e.literal("zcl:attr").describe("Generic function to parse ZCL values from read/report commands."),
|
|
460
|
-
at: r(4).or(e.array(r(4))).describe("String hex value or array of string hex values."),
|
|
461
|
-
"state.timeout": e.optional(e.number()),
|
|
462
|
-
"change.timeout": e.optional(e.number()),
|
|
463
|
-
cl: r(4).describe("Cluster ID."),
|
|
464
|
-
dt: r(2).describe("Data type."),
|
|
465
|
-
ep: e.optional(m()).describe("Endpoint, 255 means any endpoint, 0 means auto selected from subdevice."),
|
|
466
|
-
mf: e.optional(r(4)).describe("Manufacturer code, must be set to 0x0000 for non manufacturer specific commands."),
|
|
467
|
-
eval: e.optional(p()).describe("Javascript expression to transform the attribute value to the Item value."),
|
|
468
|
-
script: e.optional(f()).describe("Relative path of a Javascript .js file.")
|
|
399
|
+
f.write.extend({
|
|
400
|
+
fn: e.literal("zcl:attr").describe("Generic function to parse ZCL values from read/report commands.")
|
|
469
401
|
}),
|
|
470
|
-
|
|
471
|
-
fn: e.literal("zcl:cmd").describe("Generic function to parse ZCL values from read/report commands.")
|
|
472
|
-
cl: r(4).describe("Cluster ID."),
|
|
473
|
-
ep: e.optional(m()).describe("Endpoint, 255 means any endpoint, 0 means auto selected from subdevice."),
|
|
474
|
-
mf: e.optional(r(4)).describe("Manufacturer code, must be set to 0x0000 for non manufacturer specific commands."),
|
|
475
|
-
cmd: e.optional(r(2)).describe("Zigbee command."),
|
|
476
|
-
eval: e.optional(p()).describe("Javascript expression to transform the attribute value to the Item value."),
|
|
477
|
-
script: e.optional(f()).describe("Relative path of a Javascript .js file.")
|
|
402
|
+
f.write.extend({
|
|
403
|
+
fn: e.literal("zcl:cmd").describe("Generic function to parse ZCL values from read/report commands.")
|
|
478
404
|
}),
|
|
479
|
-
|
|
405
|
+
f.write.pick({ eval: !0, script: !0 }).extend({
|
|
480
406
|
fn: e.literal("tuya").describe("Generic function to write Tuya data."),
|
|
481
407
|
dpid: e.number().describe("Data point ID. 1-255 the datapoint ID."),
|
|
482
|
-
dt:
|
|
483
|
-
eval: e.optional(p()).describe("Javascript expression to transform the raw value."),
|
|
484
|
-
script: e.optional(f()).describe("Relative path of a Javascript .js file.")
|
|
408
|
+
dt: l(2).describe("Data type.")
|
|
485
409
|
})
|
|
486
410
|
]).refine((t) => !("eval" in t && "script" in t), {
|
|
487
411
|
message: "eval and script should not both be present"
|
|
488
412
|
});
|
|
489
413
|
}
|
|
490
|
-
function
|
|
414
|
+
function Z(t) {
|
|
491
415
|
return e.strictObject({
|
|
492
416
|
$schema: e.optional(e.string()),
|
|
493
417
|
schema: e.literal("resourceitem1.schema.json"),
|
|
494
418
|
id: e.string(),
|
|
495
419
|
description: e.optional(e.string()).describe("Item description, better to do not use it."),
|
|
496
420
|
comment: e.optional(e.string()).describe("TODO: What is this ? What the difference with description ?"),
|
|
497
|
-
deprecated: e.optional(
|
|
421
|
+
deprecated: e.optional(U()).describe("Date of deprecation, if the item is deprecated, it's better to use the new one."),
|
|
498
422
|
datatype: e.optional(e.enum([
|
|
499
423
|
"String",
|
|
500
424
|
"Bool",
|
|
@@ -519,9 +443,9 @@ function D(t) {
|
|
|
519
443
|
static: e.optional(e.union([e.string(), e.number(), e.boolean()])).describe("A static default value is fixed and can be not changed."),
|
|
520
444
|
range: e.optional(e.tuple([e.number(), e.number()])).describe("Values range limit."),
|
|
521
445
|
virtual: e.optional(e.boolean()).describe("TODO: What is this ?"),
|
|
522
|
-
read: e.optional(
|
|
523
|
-
parse: e.optional(
|
|
524
|
-
write: e.optional(
|
|
446
|
+
read: e.optional(V()).describe("Fonction used to read value."),
|
|
447
|
+
parse: e.optional(q(t)).describe("Fonction used to parse incoming values."),
|
|
448
|
+
write: e.optional(H()).describe("Fonction used to write value."),
|
|
525
449
|
"refresh.interval": e.optional(e.number()).describe("Refresh interval used for read fonction, NEED to be superior at value used in binding part."),
|
|
526
450
|
// TODO Validate this
|
|
527
451
|
values: e.optional(e.unknown()).describe("TODO: What is this ?"),
|
|
@@ -529,7 +453,7 @@ function D(t) {
|
|
|
529
453
|
default: e.optional(e.unknown()).describe("Defaut value.")
|
|
530
454
|
});
|
|
531
455
|
}
|
|
532
|
-
function
|
|
456
|
+
function J(t) {
|
|
533
457
|
return e.strictObject({
|
|
534
458
|
$schema: e.optional(e.string()),
|
|
535
459
|
schema: e.literal("devcap1.schema.json"),
|
|
@@ -552,32 +476,32 @@ function F(t) {
|
|
|
552
476
|
modelid: e.string().or(e.array(e.string())).describe("Model ID from Basic Cluster."),
|
|
553
477
|
vendor: e.optional(e.string()).describe("Friendly name of the manufacturer."),
|
|
554
478
|
comment: e.optional(e.string()),
|
|
555
|
-
matchexpr: e.optional(
|
|
556
|
-
path: e.optional(
|
|
479
|
+
matchexpr: e.optional(F()).describe("Need to return true for the DDF be used."),
|
|
480
|
+
path: e.optional(A()).describe("DDF path, useless, can be removed."),
|
|
557
481
|
product: e.optional(e.string()).describe("Complements the model id to be shown in the UI."),
|
|
558
482
|
sleeper: e.optional(e.boolean()).describe("Sleeping devices can only receive when awake."),
|
|
559
483
|
supportsMgmtBind: e.optional(e.boolean()),
|
|
560
484
|
status: e.enum(["Draft", "Bronze", "Silver", "Gold"]).describe("The code quality of the DDF file."),
|
|
561
|
-
subdevices: e.array(
|
|
562
|
-
bindings: e.optional(e.array(
|
|
485
|
+
subdevices: e.array(X(t)).describe("Devices section."),
|
|
486
|
+
bindings: e.optional(e.array(Q())).describe("Bindings section.")
|
|
563
487
|
});
|
|
564
488
|
}
|
|
565
|
-
function
|
|
489
|
+
function X(t) {
|
|
566
490
|
return e.strictObject({
|
|
567
491
|
type: e.union([
|
|
568
492
|
e.enum(Object.keys(t.deviceTypes), {
|
|
569
|
-
errorMap: (
|
|
493
|
+
errorMap: (r, u) => r.code === "invalid_enum_value" ? { message: `Invalid enum value. Expected type from generic attributes definition, received '${r.received}'` } : { message: u.defaultError }
|
|
570
494
|
}),
|
|
571
495
|
e.string().regex(/^(?!\$TYPE_).*/g, "The type start with $TYPE_ but is not present in constants.json")
|
|
572
496
|
]),
|
|
573
497
|
restapi: e.enum(["/lights", "/sensors"]),
|
|
574
|
-
uuid:
|
|
498
|
+
uuid: S(),
|
|
575
499
|
fingerprint: e.optional(e.strictObject({
|
|
576
|
-
profile:
|
|
577
|
-
device:
|
|
578
|
-
endpoint:
|
|
579
|
-
in: e.optional(e.array(
|
|
580
|
-
out: e.optional(e.array(
|
|
500
|
+
profile: l(4),
|
|
501
|
+
device: l(4),
|
|
502
|
+
endpoint: g(),
|
|
503
|
+
in: e.optional(e.array(l(4))),
|
|
504
|
+
out: e.optional(e.array(l(4)))
|
|
581
505
|
})),
|
|
582
506
|
meta: e.optional(e.strictObject({
|
|
583
507
|
// TODO validate this
|
|
@@ -588,51 +512,51 @@ function z(t) {
|
|
|
588
512
|
buttons: e.optional(e.any()),
|
|
589
513
|
// TODO validate this
|
|
590
514
|
buttonevents: e.optional(e.any()),
|
|
591
|
-
items: e.array(
|
|
515
|
+
items: e.array(K(t)),
|
|
592
516
|
example: e.optional(e.unknown())
|
|
593
517
|
});
|
|
594
518
|
}
|
|
595
|
-
function
|
|
596
|
-
return
|
|
519
|
+
function K(t) {
|
|
520
|
+
return Z(t).omit({
|
|
597
521
|
$schema: !0,
|
|
598
522
|
schema: !0,
|
|
599
523
|
id: !0
|
|
600
524
|
}).extend({
|
|
601
525
|
name: e.enum(t.attributes, {
|
|
602
|
-
errorMap: (
|
|
526
|
+
errorMap: (r, u) => r.code === "invalid_enum_value" ? { message: `Invalid enum value. Expected item from generic attributes definition, received '${r.received}'` } : { message: u.defaultError }
|
|
603
527
|
}).describe("Item name.")
|
|
604
528
|
});
|
|
605
529
|
}
|
|
606
|
-
function
|
|
530
|
+
function Q(t) {
|
|
607
531
|
return e.discriminatedUnion("bind", [
|
|
608
532
|
e.strictObject({
|
|
609
533
|
bind: e.literal("unicast"),
|
|
610
|
-
"src.ep":
|
|
611
|
-
"dst.ep": e.optional(
|
|
612
|
-
cl:
|
|
534
|
+
"src.ep": g().describe("Source endpoint."),
|
|
535
|
+
"dst.ep": e.optional(g()).describe("Destination endpoint, generaly 0x01."),
|
|
536
|
+
cl: l(4).describe("Cluster."),
|
|
613
537
|
report: e.optional(e.array(
|
|
614
538
|
e.strictObject({
|
|
615
|
-
at:
|
|
616
|
-
dt:
|
|
617
|
-
mf: e.optional(
|
|
539
|
+
at: l(4),
|
|
540
|
+
dt: l(2),
|
|
541
|
+
mf: e.optional(l(4)),
|
|
618
542
|
min: e.number(),
|
|
619
543
|
max: e.number(),
|
|
620
|
-
change: e.optional(
|
|
621
|
-
}).refine((
|
|
544
|
+
change: e.optional(l().or(e.number()))
|
|
545
|
+
}).refine((r) => r.min <= r.max, { message: "invalid report time, min should be smaller than max" })
|
|
622
546
|
))
|
|
623
547
|
}),
|
|
624
548
|
e.strictObject({
|
|
625
549
|
bind: e.literal("groupcast"),
|
|
626
|
-
"src.ep":
|
|
627
|
-
cl:
|
|
550
|
+
"src.ep": g().describe("Source endpoint."),
|
|
551
|
+
cl: l(4).describe("Cluster."),
|
|
628
552
|
"config.group": e.number().min(0).max(255)
|
|
629
553
|
})
|
|
630
554
|
]);
|
|
631
555
|
}
|
|
632
|
-
function
|
|
633
|
-
const
|
|
556
|
+
function ee(t) {
|
|
557
|
+
const r = e.array(
|
|
634
558
|
e.enum(t.attributes, {
|
|
635
|
-
errorMap: (u,
|
|
559
|
+
errorMap: (u, i) => u.code === "invalid_enum_value" ? { message: `Invalid enum value. Expected item from generic attributes definition, received '${u.received}'` } : { message: i.defaultError }
|
|
636
560
|
})
|
|
637
561
|
);
|
|
638
562
|
return e.strictObject({
|
|
@@ -640,88 +564,111 @@ function W(t) {
|
|
|
640
564
|
schema: e.literal("subdevice1.schema.json"),
|
|
641
565
|
type: e.union([
|
|
642
566
|
e.enum(Object.keys(t.deviceTypes), {
|
|
643
|
-
errorMap: (u,
|
|
567
|
+
errorMap: (u, i) => u.code === "invalid_enum_value" ? { message: `Invalid enum value. Expected type from generic attributes definition, received '${u.received}'` } : { message: i.defaultError }
|
|
644
568
|
}),
|
|
645
569
|
e.string().regex(/^(?!\$TYPE_).*/g, "The type start with $TYPE_ but is not present in constants.json")
|
|
646
570
|
]),
|
|
647
571
|
name: e.string(),
|
|
648
572
|
restapi: e.enum(["/lights", "/sensors"]),
|
|
649
573
|
order: e.number(),
|
|
650
|
-
uuid:
|
|
651
|
-
items:
|
|
652
|
-
items_optional: e.optional(
|
|
574
|
+
uuid: S(),
|
|
575
|
+
items: r,
|
|
576
|
+
items_optional: e.optional(r)
|
|
653
577
|
});
|
|
654
578
|
}
|
|
655
|
-
function
|
|
579
|
+
function D(t) {
|
|
656
580
|
return e.discriminatedUnion("schema", [
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
]).superRefine((
|
|
663
|
-
switch (
|
|
581
|
+
J(t),
|
|
582
|
+
B(),
|
|
583
|
+
C(),
|
|
584
|
+
Z(t),
|
|
585
|
+
ee(t)
|
|
586
|
+
]).superRefine((r, u) => {
|
|
587
|
+
switch (r.schema) {
|
|
664
588
|
case "devcap1.schema.json":
|
|
665
|
-
|
|
589
|
+
O[r.schema].map((i) => i(r, u, t));
|
|
666
590
|
break;
|
|
667
591
|
case "constants2.schema.json":
|
|
668
|
-
|
|
592
|
+
O[r.schema].map((i) => i(r, u, t));
|
|
669
593
|
break;
|
|
670
594
|
}
|
|
671
595
|
});
|
|
672
596
|
}
|
|
673
|
-
function
|
|
597
|
+
function re(t = {
|
|
674
598
|
attributes: [],
|
|
675
599
|
manufacturers: {},
|
|
676
600
|
deviceTypes: {},
|
|
677
601
|
resources: {},
|
|
678
602
|
subDevices: {}
|
|
679
603
|
}) {
|
|
680
|
-
let
|
|
604
|
+
let r = D(t);
|
|
681
605
|
const u = () => {
|
|
682
|
-
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
606
|
+
r = D(t);
|
|
607
|
+
}, i = (m) => [
|
|
608
|
+
"constants1.schema.json",
|
|
609
|
+
"constants2.schema.json",
|
|
610
|
+
"resourceitem1.schema.json",
|
|
611
|
+
"subdevice1.schema.json"
|
|
612
|
+
].includes(m), c = (m) => m === "devcap1.schema.json", n = (m) => {
|
|
613
|
+
const s = r.parse(m);
|
|
614
|
+
switch (s.schema) {
|
|
687
615
|
case "constants1.schema.json":
|
|
688
616
|
t.manufacturers = {
|
|
689
617
|
...t.manufacturers,
|
|
690
|
-
...
|
|
618
|
+
...s.manufacturers
|
|
691
619
|
}, t.deviceTypes = {
|
|
692
620
|
...t.deviceTypes,
|
|
693
|
-
...
|
|
621
|
+
...s["device-types"]
|
|
694
622
|
};
|
|
695
623
|
break;
|
|
696
624
|
case "constants2.schema.json": {
|
|
697
|
-
Object.keys(
|
|
698
|
-
t.manufacturers[
|
|
699
|
-
}), Object.keys(
|
|
700
|
-
t.deviceTypes[
|
|
625
|
+
Object.keys(s).filter((o) => o.startsWith("$MF_")).forEach((o) => {
|
|
626
|
+
t.manufacturers[o] = s[o];
|
|
627
|
+
}), Object.keys(s).filter((o) => o.startsWith("$TYPE_")).forEach((o) => {
|
|
628
|
+
t.deviceTypes[o] = s[o];
|
|
701
629
|
});
|
|
702
630
|
break;
|
|
703
631
|
}
|
|
704
632
|
case "resourceitem1.schema.json": {
|
|
705
|
-
if (t.attributes.includes(
|
|
706
|
-
throw new Error(`Got duplicate resource item with attribute id '${
|
|
707
|
-
const
|
|
708
|
-
delete
|
|
633
|
+
if (t.attributes.includes(s.id))
|
|
634
|
+
throw new Error(`Got duplicate resource item with attribute id '${s.id}'.`);
|
|
635
|
+
const o = s, p = s.id;
|
|
636
|
+
delete o.$schema, delete o.schema, delete o.id, t.resources[p] = o, t.attributes.push(p);
|
|
709
637
|
break;
|
|
710
638
|
}
|
|
711
639
|
case "subdevice1.schema.json":
|
|
712
|
-
t.subDevices[
|
|
640
|
+
t.subDevices[s.type] = s, t.subDevices[s.name] = s;
|
|
713
641
|
break;
|
|
714
642
|
default:
|
|
715
|
-
throw new Error(`Got invalid generic file, got data with schema '${
|
|
643
|
+
throw new Error(`Got invalid generic file, got data with schema '${s.schema}'.`);
|
|
716
644
|
}
|
|
717
645
|
return u(), !0;
|
|
718
|
-
},
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
646
|
+
}, d = (m) => r.parse(m);
|
|
647
|
+
return { generics: t, loadGeneric: n, validate: d, bulkValidate: (m, s, o = {}) => {
|
|
648
|
+
const p = (b, h) => {
|
|
649
|
+
var E, j, T;
|
|
650
|
+
let I = 0, _ = Number.POSITIVE_INFINITY, $ = b, v = [];
|
|
651
|
+
for ((E = o.onSectionStart) == null || E.call(o, h, b.length); v = [], (j = o.onSectionProgress) == null || j.call(o, h, 1, b.length), $.forEach((y) => {
|
|
652
|
+
var w;
|
|
653
|
+
(w = o.onSectionProgress) == null || w.call(o, h, I++, b.length);
|
|
654
|
+
try {
|
|
655
|
+
h === "generic" ? n(y.data) : h === "ddf" && d(y.data);
|
|
656
|
+
} catch (G) {
|
|
657
|
+
v.push({
|
|
658
|
+
...y,
|
|
659
|
+
error: G
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
}), !(v.length === 0 || v.length >= _); )
|
|
663
|
+
I -= v.length, $ = v, _ = v.length;
|
|
664
|
+
return (T = o.onSectionEnd) == null || T.call(o, h, b.length, v), v;
|
|
665
|
+
};
|
|
666
|
+
return [
|
|
667
|
+
...p(m, "generic"),
|
|
668
|
+
...p(s, "ddf")
|
|
669
|
+
];
|
|
670
|
+
}, getSchema: () => r, version: M, isGeneric: i, isDDF: c };
|
|
724
671
|
}
|
|
725
672
|
export {
|
|
726
|
-
|
|
673
|
+
re as createValidator
|
|
727
674
|
};
|