@zwave-js/config 15.15.3 → 15.16.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.
Files changed (41) hide show
  1. package/build/cjs/Logic.d.ts +1 -1
  2. package/build/cjs/Logic.js +6 -7
  3. package/build/cjs/Logic.js.map +2 -2
  4. package/build/cjs/LogicParser.d.ts +66 -84
  5. package/build/cjs/LogicParser.js +410 -1337
  6. package/build/cjs/LogicParser.js.map +3 -3
  7. package/build/cjs/_version.d.ts +1 -1
  8. package/build/cjs/_version.js +1 -1
  9. package/build/cjs/_version.js.map +1 -1
  10. package/build/cjs/devices/DeviceConfig.d.ts +3 -3
  11. package/build/cjs/devices/DeviceConfig.js.map +2 -2
  12. package/build/cjs/devices/ParamInformation.d.ts +2 -0
  13. package/build/cjs/devices/ParamInformation.js +15 -1
  14. package/build/cjs/devices/ParamInformation.js.map +2 -2
  15. package/build/esm/Logic.d.ts +1 -1
  16. package/build/esm/Logic.d.ts.map +1 -1
  17. package/build/esm/Logic.js +6 -8
  18. package/build/esm/Logic.js.map +1 -1
  19. package/build/esm/LogicParser.d.ts +66 -84
  20. package/build/esm/LogicParser.d.ts.map +1 -1
  21. package/build/esm/LogicParser.js +432 -2335
  22. package/build/esm/LogicParser.js.map +1 -1
  23. package/build/esm/_version.d.ts +1 -1
  24. package/build/esm/_version.js +1 -1
  25. package/build/esm/devices/DeviceConfig.d.ts +3 -3
  26. package/build/esm/devices/DeviceConfig.d.ts.map +1 -1
  27. package/build/esm/devices/DeviceConfig.js.map +1 -1
  28. package/build/esm/devices/ParamInformation.d.ts +2 -0
  29. package/build/esm/devices/ParamInformation.d.ts.map +1 -1
  30. package/build/esm/devices/ParamInformation.js +16 -0
  31. package/build/esm/devices/ParamInformation.js.map +1 -1
  32. package/config/devices/0x003b/be468zp.json +1 -1
  33. package/config/devices/0x003b/be469.json +2 -3
  34. package/config/devices/0x003b/be469zp.json +2 -3
  35. package/config/devices/0x0063/55258_zw4002.json +34 -1
  36. package/config/devices/0x0090/918.json +97 -0
  37. package/config/devices/0x0090/hc620.json +4 -0
  38. package/config/devices/0x027a/zse11.json +134 -0
  39. package/config/devices/templates/master_template.json +1 -1
  40. package/config/eslint.config.mjs +24 -19
  41. package/package.json +8 -10
@@ -1,4 +1,4 @@
1
1
  import { type RulesLogic } from "json-logic-js";
2
- export declare function parseLogic(logic: string): RulesLogic;
2
+ export declare function parseLogic(input: string): RulesLogic;
3
3
  export declare function evaluate(logic: string, context: unknown): string | number | boolean;
4
4
  //# sourceMappingURL=Logic.d.ts.map
@@ -39,8 +39,8 @@ var import_gt = __toESM(require("semver/functions/gt.js"), 1);
39
39
  var import_gte = __toESM(require("semver/functions/gte.js"), 1);
40
40
  var import_lt = __toESM(require("semver/functions/lt.js"), 1);
41
41
  var import_lte = __toESM(require("semver/functions/lte.js"), 1);
42
- var import_LogicParser = require("./LogicParser.js");
43
42
  var import_json_logic_js = __toESM(require("json-logic-js"), 1);
43
+ var import_LogicParser = require("./LogicParser.js");
44
44
  const { add_operation, apply } = import_json_logic_js.default;
45
45
  function tryOr(operation, onError) {
46
46
  return ((...args) => {
@@ -57,13 +57,12 @@ add_operation("ver >", tryOr((a, b) => (0, import_gt.default)((0, import_shared.
57
57
  add_operation("ver <=", tryOr((a, b) => (0, import_lte.default)((0, import_shared.padVersion)(a), (0, import_shared.padVersion)(b)), false));
58
58
  add_operation("ver <", tryOr((a, b) => (0, import_lt.default)((0, import_shared.padVersion)(a), (0, import_shared.padVersion)(b)), false));
59
59
  add_operation("ver ===", tryOr((a, b) => (0, import_eq.default)((0, import_shared.padVersion)(a), (0, import_shared.padVersion)(b)), false));
60
- function parseLogic(logic) {
61
- try {
62
- return (0, import_LogicParser.parse)(logic);
63
- } catch (e) {
64
- throw new Error(`Invalid logic: ${logic}
65
- ${e.message}`);
60
+ function parseLogic(input) {
61
+ const expr = (0, import_LogicParser.parse)(input);
62
+ if (!expr) {
63
+ throw new Error(`Failed to parse expression: ${input}`);
66
64
  }
65
+ return (0, import_LogicParser.toRulesLogic)(expr);
67
66
  }
68
67
  __name(parseLogic, "parseLogic");
69
68
  function evaluate(logic, context) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Logic.ts"],
4
- "sourcesContent": ["import { padVersion } from \"@zwave-js/shared\";\nimport semverEq from \"semver/functions/eq.js\";\nimport semverGt from \"semver/functions/gt.js\";\nimport semverGte from \"semver/functions/gte.js\";\nimport semverLt from \"semver/functions/lt.js\";\nimport semverLte from \"semver/functions/lte.js\";\nimport { parse } from \"./LogicParser.js\";\n\n// The types are not correct:\nimport { type RulesLogic, default as JsonLogic } from \"json-logic-js\";\nconst { add_operation, apply } = JsonLogic;\n\nfunction tryOr<T extends (...args: any[]) => any>(\n\toperation: T,\n\tonError: ReturnType<T>,\n): T {\n\treturn ((...args: any[]) => {\n\t\ttry {\n\t\t\treturn operation(...args);\n\t\t} catch {\n\t\t\treturn onError;\n\t\t}\n\t}) as any as T;\n}\n\nadd_operation(\n\t\"ver >=\",\n\ttryOr((a, b) => semverGte(padVersion(a), padVersion(b)), false),\n);\nadd_operation(\n\t\"ver >\",\n\ttryOr((a, b) => semverGt(padVersion(a), padVersion(b)), false),\n);\nadd_operation(\n\t\"ver <=\",\n\ttryOr((a, b) => semverLte(padVersion(a), padVersion(b)), false),\n);\nadd_operation(\n\t\"ver <\",\n\ttryOr((a, b) => semverLt(padVersion(a), padVersion(b)), false),\n);\nadd_operation(\n\t\"ver ===\",\n\ttryOr((a, b) => semverEq(padVersion(a), padVersion(b)), false),\n);\n\nexport function parseLogic(logic: string): RulesLogic {\n\ttry {\n\t\t// The generated types for the version comparisons are not compatible with the RulesLogic type\n\t\treturn parse(logic) as unknown as RulesLogic;\n\t} catch (e: any) {\n\t\tthrow new Error(`Invalid logic: ${logic}\\n${e.message}`);\n\t}\n}\n\nexport function evaluate(\n\tlogic: string,\n\tcontext: unknown,\n): string | number | boolean {\n\tconst rules = parseLogic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["import { padVersion } from \"@zwave-js/shared\";\nimport semverEq from \"semver/functions/eq.js\";\nimport semverGt from \"semver/functions/gt.js\";\nimport semverGte from \"semver/functions/gte.js\";\nimport semverLt from \"semver/functions/lt.js\";\nimport semverLte from \"semver/functions/lte.js\";\n\n// The types are not correct:\nimport { type RulesLogic, default as JsonLogic } from \"json-logic-js\";\nimport { parse, toRulesLogic } from \"./LogicParser.js\";\nconst { add_operation, apply } = JsonLogic;\n\nfunction tryOr<T extends (...args: any[]) => any>(\n\toperation: T,\n\tonError: ReturnType<T>,\n): T {\n\treturn ((...args: any[]) => {\n\t\ttry {\n\t\t\treturn operation(...args);\n\t\t} catch {\n\t\t\treturn onError;\n\t\t}\n\t}) as any as T;\n}\n\nadd_operation(\n\t\"ver >=\",\n\ttryOr((a, b) => semverGte(padVersion(a), padVersion(b)), false),\n);\nadd_operation(\n\t\"ver >\",\n\ttryOr((a, b) => semverGt(padVersion(a), padVersion(b)), false),\n);\nadd_operation(\n\t\"ver <=\",\n\ttryOr((a, b) => semverLte(padVersion(a), padVersion(b)), false),\n);\nadd_operation(\n\t\"ver <\",\n\ttryOr((a, b) => semverLt(padVersion(a), padVersion(b)), false),\n);\nadd_operation(\n\t\"ver ===\",\n\ttryOr((a, b) => semverEq(padVersion(a), padVersion(b)), false),\n);\n\nexport function parseLogic(input: string): RulesLogic {\n\tconst expr = parse(input);\n\tif (!expr) {\n\t\tthrow new Error(`Failed to parse expression: ${input}`);\n\t}\n\treturn toRulesLogic(expr);\n}\n\nexport function evaluate(\n\tlogic: string,\n\tcontext: unknown,\n): string | number | boolean {\n\tconst rules = parseLogic(logic);\n\treturn apply(rules, context);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;AAAA,oBAA2B;AAC3B,gBAAqB;AACrB,gBAAqB;AACrB,iBAAsB;AACtB,gBAAqB;AACrB,iBAAsB;AAGtB,2BAAsD;AACtD,yBAAoC;AACpC,MAAM,EAAE,eAAe,MAAK,IAAK,qBAAAA;AAEjC,SAAS,MACR,WACA,SAAsB;AAEtB,UAAQ,IAAI,SAAe;AAC1B,QAAI;AACH,aAAO,UAAU,GAAG,IAAI;IACzB,QAAQ;AACP,aAAO;IACR;EACD;AACD;AAXS;AAaT,cACC,UACA,MAAM,CAAC,GAAG,UAAM,WAAAC,aAAU,0BAAW,CAAC,OAAG,0BAAW,CAAC,CAAC,GAAG,KAAK,CAAC;AAEhE,cACC,SACA,MAAM,CAAC,GAAG,UAAM,UAAAC,aAAS,0BAAW,CAAC,OAAG,0BAAW,CAAC,CAAC,GAAG,KAAK,CAAC;AAE/D,cACC,UACA,MAAM,CAAC,GAAG,UAAM,WAAAC,aAAU,0BAAW,CAAC,OAAG,0BAAW,CAAC,CAAC,GAAG,KAAK,CAAC;AAEhE,cACC,SACA,MAAM,CAAC,GAAG,UAAM,UAAAC,aAAS,0BAAW,CAAC,OAAG,0BAAW,CAAC,CAAC,GAAG,KAAK,CAAC;AAE/D,cACC,WACA,MAAM,CAAC,GAAG,UAAM,UAAAC,aAAS,0BAAW,CAAC,OAAG,0BAAW,CAAC,CAAC,GAAG,KAAK,CAAC;AAGzD,SAAU,WAAW,OAAa;AACvC,QAAM,WAAO,0BAAM,KAAK;AACxB,MAAI,CAAC,MAAM;AACV,UAAM,IAAI,MAAM,+BAA+B,KAAK,EAAE;EACvD;AACA,aAAO,iCAAa,IAAI;AACzB;AANgB;AAQV,SAAU,SACf,OACA,SAAgB;AAEhB,QAAM,QAAQ,WAAW,KAAK;AAC9B,SAAO,MAAM,OAAO,OAAO;AAC5B;AANgB;",
6
6
  "names": ["JsonLogic", "semverGte", "semverGt", "semverLte", "semverLt", "semverEq"]
7
7
  }
@@ -1,93 +1,75 @@
1
- export interface FilePosition {
2
- offset: number;
3
- line: number;
4
- column: number;
1
+ import type { RulesLogic } from "json-logic-js";
2
+ export declare enum SyntaxKind {
3
+ Group = 0,
4
+ Or = 1,
5
+ And = 2,
6
+ Comparison = 3,
7
+ Identifier = 4,
8
+ NumberLiteral = 5,
9
+ Version = 6
5
10
  }
6
- export interface FileRange {
7
- start: FilePosition;
8
- end: FilePosition;
9
- source: string;
11
+ export declare enum Operator {
12
+ Equal = 0,
13
+ NotEqual = 1,
14
+ LessThan = 2,
15
+ LessThanOrEqual = 3,
16
+ GreaterThan = 4,
17
+ GreaterThanOrEqual = 5
10
18
  }
11
- export interface LiteralExpectation {
12
- type: "literal";
13
- text: string;
14
- ignoreCase: boolean;
15
- }
16
- export interface ClassParts extends Array<string | ClassParts> {
17
- }
18
- export interface ClassExpectation {
19
- type: "class";
20
- parts: ClassParts;
21
- inverted: boolean;
22
- ignoreCase: boolean;
23
- }
24
- export interface AnyExpectation {
25
- type: "any";
26
- }
27
- export interface EndExpectation {
28
- type: "end";
29
- }
30
- export interface OtherExpectation {
31
- type: "other";
32
- description: string;
33
- }
34
- export type Expectation = LiteralExpectation | ClassExpectation | AnyExpectation | EndExpectation | OtherExpectation;
35
- declare class _PeggySyntaxError extends Error {
36
- static buildMessage(expected: Expectation[], found: string | null): string;
37
- message: string;
38
- expected: Expectation[];
39
- found: string | null;
40
- location: FileRange;
41
- name: string;
42
- constructor(message: string, expected: Expectation[], found: string | null, location: FileRange);
43
- format(sources: {
44
- source?: any;
45
- text: string;
46
- }[]): string;
47
- }
48
- export interface TraceEvent {
49
- type: string;
50
- rule: string;
51
- result?: any;
52
- location: FileRange;
53
- }
54
- export interface ParseOptions {
55
- filename?: string;
56
- startRule?: "start";
57
- tracer?: any;
58
- [key: string]: any;
59
- }
60
- export type ParseFunction = <Options extends ParseOptions>(input: string, options?: Options) => Options extends {
61
- startRule: infer StartRule;
62
- } ? StartRule extends "start" ? Start : Start : Start;
63
- export declare const parse: ParseFunction;
64
- export declare const PeggySyntaxError: typeof _PeggySyntaxError;
65
- export type PeggySyntaxError = _PeggySyntaxError;
66
- export type Start = Group | Or | And | Comparison;
67
- export type Group = Or;
68
- export type Or = {
69
- or: [And | Comparison, ...OrTails[]];
19
+ export type Expression = Or | And | Comparison;
20
+ type Or = {
21
+ kind: SyntaxKind.Or;
22
+ operands: Expression[];
70
23
  };
71
- export type OrTails = And | Comparison;
72
- export type And = {
73
- and: [Group | Comparison, ...AndTails[]];
24
+ type And = {
25
+ kind: SyntaxKind.And;
26
+ operands: Expression[];
74
27
  };
75
- export type AndTails = Group | Comparison;
76
- export type Comparison = VerComparison | IntComparison;
77
- export type IntComparison = {
78
- [x: string]: [Term, Term];
28
+ type Comparison = {
29
+ kind: SyntaxKind.Comparison;
30
+ left: Identifier;
31
+ operator: Operator;
32
+ right: NumberLiteral | Version;
79
33
  };
80
- export type VerComparison = {
81
- [x: string]: [Term, Version];
34
+ type Identifier = {
35
+ kind: SyntaxKind.Identifier;
36
+ name: string;
82
37
  };
83
- export type Term = Const | String_1 | Hex | Integer;
84
- export type Const = {
85
- var: string;
38
+ type NumberLiteral = {
39
+ kind: SyntaxKind.NumberLiteral;
40
+ value: number;
41
+ };
42
+ type Version = {
43
+ kind: SyntaxKind.Version;
44
+ value: string;
45
+ };
46
+ export declare enum TokenKind {
47
+ Identifier = 0,
48
+ NumberLiteral = 1,
49
+ Dot = 2,// "."
50
+ LeftParen = 3,// "("
51
+ RightParen = 4,// ")"
52
+ BarBar = 5,// "||"
53
+ AmpAmp = 6,// "&&"
54
+ EqualsEquals = 7,// "=="
55
+ EqualsEqualsEquals = 8,// "==="
56
+ ExclamationEquals = 9,// "!="
57
+ ExclamationEqualsEquals = 10,// "!=="
58
+ LessThan = 11,// "<"
59
+ LessThanEquals = 12,// "<="
60
+ GreaterThan = 13,// ">"
61
+ GreaterThanEquals = 14
62
+ }
63
+ export type Token = {
64
+ start: number;
65
+ kind: TokenKind;
66
+ value?: string;
86
67
  };
87
- export type Integer = number;
88
- export type Hex = number;
89
- export type Version = string;
90
- export type String_1 = string;
91
- export type _ = string[];
68
+ /**
69
+ * Splits a string into tokens to be consumed by the Parser.
70
+ */
71
+ export declare function tokenize(input: string): Generator<Token>;
72
+ export declare function parse(input: string): Expression | undefined;
73
+ export declare function toRulesLogic(expr: Expression): RulesLogic;
92
74
  export {};
93
75
  //# sourceMappingURL=LogicParser.d.ts.map