@zwave-js/config 14.0.0-beta.1 → 14.0.0-beta.4

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 (214) hide show
  1. package/build/{ConfigManager.d.ts → cjs/ConfigManager.d.ts} +2 -2
  2. package/build/cjs/ConfigManager.js +208 -0
  3. package/build/cjs/ConfigManager.js.map +7 -0
  4. package/build/cjs/JsonTemplate.js +198 -0
  5. package/build/cjs/JsonTemplate.js.map +7 -0
  6. package/build/{Logger.d.ts → cjs/Logger.d.ts} +1 -1
  7. package/build/cjs/Logger.js +50 -0
  8. package/build/cjs/Logger.js.map +7 -0
  9. package/build/cjs/Logger_safe.js +32 -0
  10. package/build/cjs/Logger_safe.js.map +7 -0
  11. package/build/cjs/Logic.js +71 -0
  12. package/build/cjs/Logic.js.map +7 -0
  13. package/build/cjs/LogicParser.js +1343 -0
  14. package/build/cjs/LogicParser.js.map +7 -0
  15. package/build/cjs/Manufacturers.js +88 -0
  16. package/build/cjs/Manufacturers.js.map +7 -0
  17. package/build/cjs/_version.d.ts +2 -0
  18. package/build/cjs/_version.js +29 -0
  19. package/build/cjs/_version.js.map +7 -0
  20. package/build/{devices → cjs/devices}/AssociationConfig.d.ts +2 -2
  21. package/build/cjs/devices/AssociationConfig.js +93 -0
  22. package/build/cjs/devices/AssociationConfig.js.map +7 -0
  23. package/build/{devices → cjs/devices}/CompatConfig.d.ts +2 -2
  24. package/build/cjs/devices/CompatConfig.js +584 -0
  25. package/build/cjs/devices/CompatConfig.js.map +7 -0
  26. package/build/{devices → cjs/devices}/ConditionalItem.d.ts +1 -1
  27. package/build/cjs/devices/ConditionalItem.js +107 -0
  28. package/build/cjs/devices/ConditionalItem.js.map +7 -0
  29. package/build/{devices → cjs/devices}/ConditionalPrimitive.d.ts +2 -2
  30. package/build/cjs/devices/ConditionalPrimitive.js +59 -0
  31. package/build/cjs/devices/ConditionalPrimitive.js.map +7 -0
  32. package/build/{devices → cjs/devices}/DeviceConfig.d.ts +7 -7
  33. package/build/cjs/devices/DeviceConfig.js +502 -0
  34. package/build/cjs/devices/DeviceConfig.js.map +7 -0
  35. package/build/cjs/devices/DeviceConfig.unit._test.js +17 -0
  36. package/build/cjs/devices/DeviceConfig.unit._test.js.map +7 -0
  37. package/build/{devices → cjs/devices}/DeviceMetadata.d.ts +3 -3
  38. package/build/cjs/devices/DeviceMetadata.js +112 -0
  39. package/build/cjs/devices/DeviceMetadata.js.map +7 -0
  40. package/build/{devices → cjs/devices}/EndpointConfig.d.ts +5 -5
  41. package/build/cjs/devices/EndpointConfig.js +87 -0
  42. package/build/cjs/devices/EndpointConfig.js.map +7 -0
  43. package/build/{devices → cjs/devices}/ParamInformation.d.ts +3 -3
  44. package/build/cjs/devices/ParamInformation.js +209 -0
  45. package/build/cjs/devices/ParamInformation.js.map +7 -0
  46. package/build/cjs/devices/shared.js +17 -0
  47. package/build/cjs/devices/shared.js.map +7 -0
  48. package/build/cjs/index.d.ts +13 -0
  49. package/build/cjs/index.js +53 -0
  50. package/build/cjs/index.js.map +7 -0
  51. package/build/cjs/index_safe.d.ts +3 -0
  52. package/build/cjs/index_safe.js +32 -0
  53. package/build/cjs/index_safe.js.map +7 -0
  54. package/build/cjs/package.json +3 -0
  55. package/build/{utils.d.ts → cjs/utils.d.ts} +2 -2
  56. package/build/cjs/utils.js +117 -0
  57. package/build/cjs/utils.js.map +7 -0
  58. package/build/cjs/utils_safe.js +57 -0
  59. package/build/cjs/utils_safe.js.map +7 -0
  60. package/build/esm/ConfigManager.d.ts +57 -0
  61. package/build/esm/ConfigManager.d.ts.map +1 -0
  62. package/build/{ConfigManager.js → esm/ConfigManager.js} +36 -43
  63. package/build/esm/ConfigManager.js.map +1 -0
  64. package/build/esm/JsonTemplate.d.ts +4 -0
  65. package/build/esm/JsonTemplate.d.ts.map +1 -0
  66. package/build/{JsonTemplate.js → esm/JsonTemplate.js} +30 -60
  67. package/build/esm/JsonTemplate.js.map +1 -0
  68. package/build/esm/Logger.d.ts +11 -0
  69. package/build/esm/Logger.d.ts.map +1 -0
  70. package/build/esm/Logger.js +23 -0
  71. package/build/esm/Logger.js.map +1 -0
  72. package/build/esm/Logger_safe.d.ts +5 -0
  73. package/build/esm/Logger_safe.d.ts.map +1 -0
  74. package/build/esm/Logger_safe.js +3 -0
  75. package/build/esm/Logger_safe.js.map +1 -0
  76. package/build/esm/Logic.d.ts +4 -0
  77. package/build/esm/Logic.d.ts.map +1 -0
  78. package/build/esm/Logic.js +35 -0
  79. package/build/esm/Logic.js.map +1 -0
  80. package/build/esm/LogicParser.d.ts +93 -0
  81. package/build/esm/LogicParser.d.ts.map +1 -0
  82. package/build/{LogicParser.js → esm/LogicParser.js} +2 -5
  83. package/build/{LogicParser.js.map → esm/LogicParser.js.map} +1 -1
  84. package/build/esm/Manufacturers.d.ts +6 -0
  85. package/build/esm/Manufacturers.d.ts.map +1 -0
  86. package/build/esm/Manufacturers.js +55 -0
  87. package/build/esm/Manufacturers.js.map +1 -0
  88. package/build/esm/_version.d.ts +2 -0
  89. package/build/esm/_version.d.ts.map +1 -0
  90. package/build/esm/_version.js +3 -0
  91. package/build/esm/_version.js.map +1 -0
  92. package/build/esm/devices/AssociationConfig.d.ts +27 -0
  93. package/build/esm/devices/AssociationConfig.d.ts.map +1 -0
  94. package/build/{devices → esm/devices}/AssociationConfig.js +12 -16
  95. package/build/esm/devices/AssociationConfig.js.map +1 -0
  96. package/build/esm/devices/CompatConfig.d.ts +112 -0
  97. package/build/esm/devices/CompatConfig.d.ts.map +1 -0
  98. package/build/{devices → esm/devices}/CompatConfig.js +112 -119
  99. package/build/esm/devices/CompatConfig.js.map +1 -0
  100. package/build/esm/devices/ConditionalItem.d.ts +14 -0
  101. package/build/esm/devices/ConditionalItem.d.ts.map +1 -0
  102. package/build/{devices → esm/devices}/ConditionalItem.js +15 -21
  103. package/build/esm/devices/ConditionalItem.js.map +1 -0
  104. package/build/esm/devices/ConditionalPrimitive.d.ts +13 -0
  105. package/build/esm/devices/ConditionalPrimitive.d.ts.map +1 -0
  106. package/build/esm/devices/ConditionalPrimitive.js +35 -0
  107. package/build/esm/devices/ConditionalPrimitive.js.map +1 -0
  108. package/build/esm/devices/DeviceConfig.d.ts +117 -0
  109. package/build/esm/devices/DeviceConfig.d.ts.map +1 -0
  110. package/build/{devices → esm/devices}/DeviceConfig.js +96 -108
  111. package/build/esm/devices/DeviceConfig.js.map +1 -0
  112. package/build/esm/devices/DeviceConfig.unit._test.d.ts +2 -0
  113. package/build/esm/devices/DeviceConfig.unit._test.d.ts.map +1 -0
  114. package/build/{devices → esm/devices}/DeviceConfig.unit._test.js +1 -2
  115. package/build/esm/devices/DeviceConfig.unit._test.js.map +1 -0
  116. package/build/esm/devices/DeviceMetadata.d.ts +41 -0
  117. package/build/esm/devices/DeviceMetadata.d.ts.map +1 -0
  118. package/build/{devices → esm/devices}/DeviceMetadata.js +16 -21
  119. package/build/esm/devices/DeviceMetadata.js.map +1 -0
  120. package/build/esm/devices/EndpointConfig.d.ts +20 -0
  121. package/build/esm/devices/EndpointConfig.d.ts.map +1 -0
  122. package/build/esm/devices/EndpointConfig.js +60 -0
  123. package/build/esm/devices/EndpointConfig.js.map +1 -0
  124. package/build/esm/devices/ParamInformation.d.ts +50 -0
  125. package/build/esm/devices/ParamInformation.d.ts.map +1 -0
  126. package/build/{devices → esm/devices}/ParamInformation.js +38 -44
  127. package/build/esm/devices/ParamInformation.js.map +1 -0
  128. package/build/esm/devices/shared.d.ts +11 -0
  129. package/build/esm/devices/shared.d.ts.map +1 -0
  130. package/build/esm/devices/shared.js +2 -0
  131. package/build/{devices → esm/devices}/shared.js.map +1 -1
  132. package/build/esm/index.d.ts +13 -0
  133. package/build/esm/index.d.ts.map +1 -0
  134. package/build/esm/index.js +14 -0
  135. package/build/esm/index.js.map +1 -0
  136. package/build/esm/index_safe.d.ts +3 -0
  137. package/build/esm/index_safe.d.ts.map +1 -0
  138. package/build/esm/index_safe.js +4 -0
  139. package/build/esm/index_safe.js.map +1 -0
  140. package/build/esm/package.json +3 -0
  141. package/build/esm/utils.d.ts +19 -0
  142. package/build/esm/utils.d.ts.map +1 -0
  143. package/build/esm/utils.js +93 -0
  144. package/build/esm/utils.js.map +1 -0
  145. package/build/esm/utils_safe.d.ts +7 -0
  146. package/build/esm/utils_safe.d.ts.map +1 -0
  147. package/build/esm/utils_safe.js +28 -0
  148. package/build/esm/utils_safe.js.map +1 -0
  149. package/package.json +22 -19
  150. package/build/ConfigManager.d.ts.map +0 -1
  151. package/build/ConfigManager.js.map +0 -1
  152. package/build/JsonTemplate.d.ts.map +0 -1
  153. package/build/JsonTemplate.js.map +0 -1
  154. package/build/Logger.d.ts.map +0 -1
  155. package/build/Logger.js +0 -27
  156. package/build/Logger.js.map +0 -1
  157. package/build/Logger_safe.d.ts.map +0 -1
  158. package/build/Logger_safe.js +0 -6
  159. package/build/Logger_safe.js.map +0 -1
  160. package/build/Logic.d.ts.map +0 -1
  161. package/build/Logic.js +0 -60
  162. package/build/Logic.js.map +0 -1
  163. package/build/LogicParser.d.ts.map +0 -1
  164. package/build/Manufacturers.d.ts.map +0 -1
  165. package/build/Manufacturers.js +0 -62
  166. package/build/Manufacturers.js.map +0 -1
  167. package/build/_version.d.ts +0 -2
  168. package/build/_version.d.ts.map +0 -1
  169. package/build/_version.js +0 -6
  170. package/build/_version.js.map +0 -1
  171. package/build/devices/AssociationConfig.d.ts.map +0 -1
  172. package/build/devices/AssociationConfig.js.map +0 -1
  173. package/build/devices/CompatConfig.d.ts.map +0 -1
  174. package/build/devices/CompatConfig.js.map +0 -1
  175. package/build/devices/ConditionalItem.d.ts.map +0 -1
  176. package/build/devices/ConditionalItem.js.map +0 -1
  177. package/build/devices/ConditionalPrimitive.d.ts.map +0 -1
  178. package/build/devices/ConditionalPrimitive.js +0 -40
  179. package/build/devices/ConditionalPrimitive.js.map +0 -1
  180. package/build/devices/DeviceConfig.d.ts.map +0 -1
  181. package/build/devices/DeviceConfig.js.map +0 -1
  182. package/build/devices/DeviceConfig.unit._test.d.ts.map +0 -1
  183. package/build/devices/DeviceConfig.unit._test.js.map +0 -1
  184. package/build/devices/DeviceMetadata.d.ts.map +0 -1
  185. package/build/devices/DeviceMetadata.js.map +0 -1
  186. package/build/devices/EndpointConfig.d.ts.map +0 -1
  187. package/build/devices/EndpointConfig.js +0 -64
  188. package/build/devices/EndpointConfig.js.map +0 -1
  189. package/build/devices/ParamInformation.d.ts.map +0 -1
  190. package/build/devices/ParamInformation.js.map +0 -1
  191. package/build/devices/shared.d.ts.map +0 -1
  192. package/build/devices/shared.js +0 -3
  193. package/build/index.d.ts +0 -13
  194. package/build/index.d.ts.map +0 -1
  195. package/build/index.js +0 -33
  196. package/build/index.js.map +0 -1
  197. package/build/index_safe.d.ts +0 -3
  198. package/build/index_safe.d.ts.map +0 -1
  199. package/build/index_safe.js +0 -22
  200. package/build/index_safe.js.map +0 -1
  201. package/build/utils.d.ts.map +0 -1
  202. package/build/utils.js +0 -124
  203. package/build/utils.js.map +0 -1
  204. package/build/utils_safe.d.ts.map +0 -1
  205. package/build/utils_safe.js +0 -33
  206. package/build/utils_safe.js.map +0 -1
  207. /package/build/{JsonTemplate.d.ts → cjs/JsonTemplate.d.ts} +0 -0
  208. /package/build/{Logger_safe.d.ts → cjs/Logger_safe.d.ts} +0 -0
  209. /package/build/{Logic.d.ts → cjs/Logic.d.ts} +0 -0
  210. /package/build/{LogicParser.d.ts → cjs/LogicParser.d.ts} +0 -0
  211. /package/build/{Manufacturers.d.ts → cjs/Manufacturers.d.ts} +0 -0
  212. /package/build/{devices → cjs/devices}/DeviceConfig.unit._test.d.ts +0 -0
  213. /package/build/{devices → cjs/devices}/shared.d.ts +0 -0
  214. /package/build/{utils_safe.d.ts → cjs/utils_safe.d.ts} +0 -0
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var index_safe_exports = {};
21
+ __export(index_safe_exports, {
22
+ PACKAGE_VERSION: () => import_version.PACKAGE_VERSION
23
+ });
24
+ module.exports = __toCommonJS(index_safe_exports);
25
+ __reExport(index_safe_exports, require("./Logger_safe.js"), module.exports);
26
+ var import_version = require("./_version.js");
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ PACKAGE_VERSION,
30
+ ...require("./Logger_safe.js")
31
+ });
32
+ //# sourceMappingURL=index_safe.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index_safe.ts"],
4
+ "sourcesContent": ["/* @forbiddenImports external */\n\nexport * from \"./Logger_safe.js\";\nexport { PACKAGE_VERSION } from \"./_version.js\";\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;AAEA,+BAAc,6BAFd;AAGA,qBAAgC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -1,5 +1,5 @@
1
- import type { ConfigLogger } from "./Logger";
2
- import type { DeviceConfigIndexEntry } from "./devices/DeviceConfig";
1
+ import type { ConfigLogger } from "./Logger.js";
2
+ import type { DeviceConfigIndexEntry } from "./devices/DeviceConfig.js";
3
3
  /** The absolute path of the embedded configuration directory */
4
4
  export declare const configDir: string;
5
5
  /** The (optional) absolute path of an external configuration directory */
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var utils_exports = {};
30
+ __export(utils_exports, {
31
+ configDir: () => configDir,
32
+ externalConfigDir: () => externalConfigDir,
33
+ getDeviceEntryPredicate: () => getDeviceEntryPredicate,
34
+ syncExternalConfigDir: () => syncExternalConfigDir,
35
+ versionInRange: () => versionInRange
36
+ });
37
+ module.exports = __toCommonJS(utils_exports);
38
+ var __import_meta_url = typeof document === "undefined" ? new (require("url".replace("", ""))).URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
39
+ var import_shared = require("@zwave-js/shared");
40
+ var import_promises = __toESM(require("node:fs/promises"), 1);
41
+ var import_node_module = require("node:module");
42
+ var import_node_path = __toESM(require("node:path"), 1);
43
+ var semver = __toESM(require("semver"), 1);
44
+ var import_version = require("./_version.js");
45
+ const require2 = (0, import_node_module.createRequire)(__import_meta_url);
46
+ const configDir = import_node_path.default.resolve(import_node_path.default.dirname(require2.resolve("@zwave-js/config/package.json")), "config");
47
+ function externalConfigDir() {
48
+ return process.env.ZWAVEJS_EXTERNAL_CONFIG;
49
+ }
50
+ function getDeviceEntryPredicate(manufacturerId, productType, productId, firmwareVersion) {
51
+ return (entry) => {
52
+ if (entry.manufacturerId !== (0, import_shared.formatId)(manufacturerId))
53
+ return false;
54
+ if (entry.productType !== (0, import_shared.formatId)(productType))
55
+ return false;
56
+ if (entry.productId !== (0, import_shared.formatId)(productId))
57
+ return false;
58
+ if (firmwareVersion != void 0) {
59
+ return semver.lte((0, import_shared.padVersion)(entry.firmwareVersion.min), (0, import_shared.padVersion)(firmwareVersion)) && semver.gte((0, import_shared.padVersion)(entry.firmwareVersion.max), (0, import_shared.padVersion)(firmwareVersion));
60
+ }
61
+ return true;
62
+ };
63
+ }
64
+ async function syncExternalConfigDir(logger) {
65
+ const extConfigDir = externalConfigDir();
66
+ if (!extConfigDir)
67
+ return { success: false };
68
+ try {
69
+ await import_promises.default.mkdir(extConfigDir, { recursive: true });
70
+ } catch {
71
+ logger.print(`Synchronizing external config dir failed - directory could not be created`, "error");
72
+ return { success: false };
73
+ }
74
+ const externalVersionFilename = import_node_path.default.join(extConfigDir, "version");
75
+ const currentVersion = import_version.PACKAGE_VERSION;
76
+ const supportedRange = `>=${currentVersion} <${semver.inc(currentVersion, "patch")}`;
77
+ let wipe = false;
78
+ let externalVersion;
79
+ try {
80
+ externalVersion = await import_promises.default.readFile(externalVersionFilename, "utf8");
81
+ if (!semver.valid(externalVersion)) {
82
+ wipe = true;
83
+ } else if (!semver.satisfies(externalVersion, supportedRange, {
84
+ includePrerelease: true
85
+ })) {
86
+ wipe = true;
87
+ }
88
+ } catch {
89
+ wipe = true;
90
+ }
91
+ if (!wipe)
92
+ return { success: true, version: externalVersion };
93
+ try {
94
+ logger.print(`Synchronizing external config dir ${extConfigDir}...`);
95
+ await import_promises.default.rm(extConfigDir, { recursive: true, force: true });
96
+ await import_promises.default.mkdir(extConfigDir, { recursive: true });
97
+ await (0, import_shared.copyFilesRecursive)(configDir, extConfigDir, (src) => src.endsWith(".json"));
98
+ await import_promises.default.writeFile(externalVersionFilename, currentVersion, "utf8");
99
+ externalVersion = currentVersion;
100
+ } catch {
101
+ logger.print(`Synchronizing external config dir failed - using embedded config`, "error");
102
+ return { success: false };
103
+ }
104
+ return { success: true, version: externalVersion };
105
+ }
106
+ function versionInRange(version, min, max) {
107
+ return semver.gte((0, import_shared.padVersion)(version), (0, import_shared.padVersion)(min)) && semver.lte((0, import_shared.padVersion)(version), (0, import_shared.padVersion)(max));
108
+ }
109
+ // Annotate the CommonJS export names for ESM import in node:
110
+ 0 && (module.exports = {
111
+ configDir,
112
+ externalConfigDir,
113
+ getDeviceEntryPredicate,
114
+ syncExternalConfigDir,
115
+ versionInRange
116
+ });
117
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils.ts", "../../../../node_modules/.store/@alcalzone-esm2cjs-npm-1.2.3-e86ac3cbf2/package/shims/import.meta.url/shim.js"],
4
+ "sourcesContent": ["import { copyFilesRecursive, formatId, padVersion } from \"@zwave-js/shared\";\nimport fs from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport * as semver from \"semver\";\nimport type { ConfigLogger } from \"./Logger.js\";\nimport { PACKAGE_VERSION } from \"./_version.js\";\nimport type { DeviceConfigIndexEntry } from \"./devices/DeviceConfig.js\";\n\nconst require = createRequire(import.meta.url);\n\n/** The absolute path of the embedded configuration directory */\nexport const configDir = path.resolve(\n\tpath.dirname(require.resolve(\"@zwave-js/config/package.json\")),\n\t\"config\",\n);\n/** The (optional) absolute path of an external configuration directory */\nexport function externalConfigDir(): string | undefined {\n\treturn process.env.ZWAVEJS_EXTERNAL_CONFIG;\n}\n\nexport function getDeviceEntryPredicate(\n\tmanufacturerId: number,\n\tproductType: number,\n\tproductId: number,\n\tfirmwareVersion?: string,\n): (entry: DeviceConfigIndexEntry) => boolean {\n\treturn (entry) => {\n\t\tif (entry.manufacturerId !== formatId(manufacturerId)) return false;\n\t\tif (entry.productType !== formatId(productType)) return false;\n\t\tif (entry.productId !== formatId(productId)) return false;\n\t\tif (firmwareVersion != undefined) {\n\t\t\t// A firmware version was given, only look at files with a matching firmware version\n\t\t\treturn (\n\t\t\t\tsemver.lte(\n\t\t\t\t\tpadVersion(entry.firmwareVersion.min),\n\t\t\t\t\tpadVersion(firmwareVersion),\n\t\t\t\t)\n\t\t\t\t&& semver.gte(\n\t\t\t\t\tpadVersion(entry.firmwareVersion.max),\n\t\t\t\t\tpadVersion(firmwareVersion),\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t};\n}\n\nexport type SyncExternalConfigDirResult =\n\t| {\n\t\tsuccess: false;\n\t}\n\t| {\n\t\tsuccess: true;\n\t\tversion: string;\n\t};\n\n/**\n * Synchronizes or updates the external config directory and returns whether the directory is in a state that can be used\n */\nexport async function syncExternalConfigDir(\n\tlogger: ConfigLogger,\n): Promise<SyncExternalConfigDirResult> {\n\tconst extConfigDir = externalConfigDir();\n\tif (!extConfigDir) return { success: false };\n\n\t// Make sure the config dir exists\n\ttry {\n\t\tawait fs.mkdir(extConfigDir, { recursive: true });\n\t} catch {\n\t\tlogger.print(\n\t\t\t`Synchronizing external config dir failed - directory could not be created`,\n\t\t\t\"error\",\n\t\t);\n\t\treturn { success: false };\n\t}\n\n\tconst externalVersionFilename = path.join(extConfigDir, \"version\");\n\tconst currentVersion = PACKAGE_VERSION;\n\tconst supportedRange = `>=${currentVersion} <${\n\t\tsemver.inc(\n\t\t\tcurrentVersion,\n\t\t\t\"patch\",\n\t\t)\n\t}`;\n\n\t// We remember the config version that was copied there in a file called \"version\"\n\t// If that either...\n\t// ...isn't there,\n\t// ...can't be read,\n\t// ...doesn't contain a matching version (>= current && nightly)\n\t// wipe the external config dir and recreate it\n\tlet wipe = false;\n\tlet externalVersion: string | undefined;\n\ttry {\n\t\texternalVersion = await fs.readFile(externalVersionFilename, \"utf8\");\n\t\tif (!semver.valid(externalVersion)) {\n\t\t\twipe = true;\n\t\t} else if (\n\t\t\t!semver.satisfies(externalVersion, supportedRange, {\n\t\t\t\tincludePrerelease: true,\n\t\t\t})\n\t\t) {\n\t\t\twipe = true;\n\t\t}\n\t} catch {\n\t\twipe = true;\n\t}\n\n\t// Nothing to wipe, the external dir is good to go\n\tif (!wipe) return { success: true, version: externalVersion! };\n\n\t// Wipe and override the external dir\n\ttry {\n\t\tlogger.print(`Synchronizing external config dir ${extConfigDir}...`);\n\t\tawait fs.rm(extConfigDir, { recursive: true, force: true });\n\t\tawait fs.mkdir(extConfigDir, { recursive: true });\n\t\tawait copyFilesRecursive(\n\t\t\tconfigDir,\n\t\t\textConfigDir,\n\t\t\t(src) => src.endsWith(\".json\"),\n\t\t);\n\t\tawait fs.writeFile(externalVersionFilename, currentVersion, \"utf8\");\n\t\texternalVersion = currentVersion;\n\t} catch {\n\t\t// Something went wrong\n\t\tlogger.print(\n\t\t\t`Synchronizing external config dir failed - using embedded config`,\n\t\t\t\"error\",\n\t\t);\n\t\treturn { success: false };\n\t}\n\n\treturn { success: true, version: externalVersion };\n}\n\nexport function versionInRange(\n\tversion: string,\n\tmin: string,\n\tmax: string,\n): boolean {\n\treturn (\n\t\tsemver.gte(padVersion(version), padVersion(min))\n\t\t&& semver.lte(padVersion(version), padVersion(max))\n\t);\n}\n", "export const __import_meta_url =\n typeof document === 'undefined' ? new (require('url'.replace('', '')).URL)('file:' + __filename).href :\n (document.curr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MAAK;EACxB;AAEA,QAAM,0BAA0B,iBAAAD,QAAK,KAAK,cAAc,SAAS;AACjE,QAAM,iBAAiB;AACvB,QAAM,iBAAiB,KAAK,cAAc,KACzC,OAAO,IACN,gBACA,OAAO,CAET;AAQA,MAAI,OAAO;AACX,MAAI;AACJ,MAAI;AACH,sBAAkB,MAAM,gBAAAC,QAAG,SAAS,yBAAyB,MAAM;AACnE,QAAI,CAAC,OAAO,MAAM,eAAe,GAAG;AACnC,aAAO;IACR,WACC,CAAC,OAAO,UAAU,iBAAiB,gBAAgB;MAClD,mBAAmB;KACnB,GACA;AACD,aAAO;IACR;EACD,QAAQ;AACP,WAAO;EACR;AAGA,MAAI,CAAC;AAAM,WAAO,EAAE,SAAS,MAAM,SAAS,gBAAgB;AAG5D,MAAI;AACH,WAAO,MAAM,qCAAqC,YAAY,KAAK;AACnE,UAAM,gBAAAA,QAAG,GAAG,cAAc,EAAE,WAAW,MAAM,OAAO,KAAI,CAAE;AAC1D,UAAM,gBAAAA,QAAG,MAAM,cAAc,EAAE,WAAW,KAAI,CAAE;AAChD,cAAM,kCACL,WACA,cACA,CAAC,QAAQ,IAAI,SAAS,OAAO,CAAC;AAE/B,UAAM,gBAAAA,QAAG,UAAU,yBAAyB,gBAAgB,MAAM;AAClE,sBAAkB;EACnB,QAAQ;AAEP,WAAO,MACN,oEACA,OAAO;AAER,WAAO,EAAE,SAAS,MAAK;EACxB;AAEA,SAAO,EAAE,SAAS,MAAM,SAAS,gBAAe;AACjD;AAEM,SAAU,eACf,SACA,KACA,KAAW;AAEX,SACC,OAAO,QAAI,0BAAW,OAAO,OAAG,0BAAW,GAAG,CAAC,KAC5C,OAAO,QAAI,0BAAW,OAAO,OAAG,0BAAW,GAAG,CAAC;AAEpD;",
6
+ "names": ["require", "path", "fs"]
7
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var utils_safe_exports = {};
20
+ __export(utils_safe_exports, {
21
+ hexKeyRegex2Digits: () => hexKeyRegex2Digits,
22
+ hexKeyRegex4Digits: () => hexKeyRegex4Digits,
23
+ hexKeyRegexNDigits: () => hexKeyRegexNDigits,
24
+ throwInvalidConfig: () => throwInvalidConfig,
25
+ tryParseCCId: () => tryParseCCId
26
+ });
27
+ module.exports = __toCommonJS(utils_safe_exports);
28
+ var import_safe = require("@zwave-js/core/safe");
29
+ const hexKeyRegexNDigits = /^0x[a-f0-9]+$/;
30
+ const hexKeyRegex4Digits = /^0x[a-f0-9]{4}$/;
31
+ const hexKeyRegex2Digits = /^0x[a-f0-9]{2}$/;
32
+ function throwInvalidConfig(which, reason) {
33
+ throw new import_safe.ZWaveError(`The ${which ? which + " " : ""}config file is malformed!` + (reason ? `
34
+ ${reason}` : ""), import_safe.ZWaveErrorCodes.Config_Invalid);
35
+ }
36
+ function tryParseCCId(from) {
37
+ let ccId;
38
+ if (/^\d+$/.test(from)) {
39
+ ccId = parseInt(from, 10);
40
+ } else if (hexKeyRegexNDigits.test(from)) {
41
+ ccId = parseInt(from.slice(2), 16);
42
+ } else if (from in import_safe.CommandClasses) {
43
+ return import_safe.CommandClasses[from];
44
+ }
45
+ if (ccId != void 0 && ccId in import_safe.CommandClasses) {
46
+ return ccId;
47
+ }
48
+ }
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ hexKeyRegex2Digits,
52
+ hexKeyRegex4Digits,
53
+ hexKeyRegexNDigits,
54
+ throwInvalidConfig,
55
+ tryParseCCId
56
+ });
57
+ //# sourceMappingURL=utils_safe.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils_safe.ts"],
4
+ "sourcesContent": ["import {\n\tCommandClasses,\n\tZWaveError,\n\tZWaveErrorCodes,\n} from \"@zwave-js/core/safe\";\n\nexport const hexKeyRegexNDigits = /^0x[a-f0-9]+$/;\nexport const hexKeyRegex4Digits = /^0x[a-f0-9]{4}$/;\nexport const hexKeyRegex2Digits = /^0x[a-f0-9]{2}$/;\n\nexport function throwInvalidConfig(which: string, reason?: string): never {\n\tthrow new ZWaveError(\n\t\t`The ${which ? which + \" \" : \"\"}config file is malformed!`\n\t\t\t+ (reason ? `\\n${reason}` : \"\"),\n\t\tZWaveErrorCodes.Config_Invalid,\n\t);\n}\n\nexport function tryParseCCId(from: string): CommandClasses | undefined {\n\tlet ccId: number | undefined;\n\tif (/^\\d+$/.test(from)) {\n\t\t// Decimal CC ID\n\t\tccId = parseInt(from, 10);\n\t} else if (hexKeyRegexNDigits.test(from)) {\n\t\t// Hexadecimal CC ID\n\t\tccId = parseInt(from.slice(2), 16);\n\t} else if (from in CommandClasses) {\n\t\t// CC name\n\t\treturn (CommandClasses as any)[from];\n\t}\n\n\tif (ccId != undefined && ccId in CommandClasses) {\n\t\t// This is a valid CC ID\n\t\treturn ccId;\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;AAAA,kBAIO;AAEA,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAE5B,SAAU,mBAAmB,OAAe,QAAe;AAChE,QAAM,IAAI,uBACT,OAAO,QAAQ,QAAQ,MAAM,EAAE,+BAC3B,SAAS;EAAK,MAAM,KAAK,KAC7B,4BAAgB,cAAc;AAEhC;AAEM,SAAU,aAAa,MAAY;AACxC,MAAI;AACJ,MAAI,QAAQ,KAAK,IAAI,GAAG;AAEvB,WAAO,SAAS,MAAM,EAAE;EACzB,WAAW,mBAAmB,KAAK,IAAI,GAAG;AAEzC,WAAO,SAAS,KAAK,MAAM,CAAC,GAAG,EAAE;EAClC,WAAW,QAAQ,4BAAgB;AAElC,WAAQ,2BAAuB,IAAI;EACpC;AAEA,MAAI,QAAQ,UAAa,QAAQ,4BAAgB;AAEhD,WAAO;EACR;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,57 @@
1
+ import { ZWaveLogContainer } from "@zwave-js/core";
2
+ import { type ManufacturersMap } from "./Manufacturers.js";
3
+ import { ConditionalDeviceConfig, type DeviceConfig, type DeviceConfigIndex, type FulltextDeviceConfigIndex } from "./devices/DeviceConfig.js";
4
+ export interface ConfigManagerOptions {
5
+ logContainer?: ZWaveLogContainer;
6
+ deviceConfigPriorityDir?: string;
7
+ }
8
+ export declare class ConfigManager {
9
+ constructor(options?: ConfigManagerOptions);
10
+ private _configVersion;
11
+ get configVersion(): string;
12
+ private logger;
13
+ private _manufacturers;
14
+ get manufacturers(): ManufacturersMap;
15
+ private deviceConfigPriorityDir;
16
+ private index;
17
+ private fulltextIndex;
18
+ private _useExternalConfig;
19
+ get useExternalConfig(): boolean;
20
+ loadAll(): Promise<void>;
21
+ loadManufacturers(): Promise<void>;
22
+ saveManufacturers(): Promise<void>;
23
+ /**
24
+ * Looks up the name of the manufacturer with the given ID in the configuration DB
25
+ * @param manufacturerId The manufacturer id to look up
26
+ */
27
+ lookupManufacturer(manufacturerId: number): string | undefined;
28
+ /**
29
+ * Add new manufacturers to configuration DB
30
+ * @param manufacturerId The manufacturer id to look up
31
+ * @param manufacturerName The manufacturer name
32
+ */
33
+ setManufacturer(manufacturerId: number, manufacturerName: string): void;
34
+ loadDeviceIndex(): Promise<void>;
35
+ getIndex(): DeviceConfigIndex | undefined;
36
+ loadFulltextDeviceIndex(): Promise<void>;
37
+ getFulltextIndex(): FulltextDeviceConfigIndex | undefined;
38
+ /**
39
+ * Looks up the definition of a given device in the configuration DB, but does not evaluate conditional settings.
40
+ * @param manufacturerId The manufacturer id of the device
41
+ * @param productType The product type of the device
42
+ * @param productId The product id of the device
43
+ * @param firmwareVersion If known, configuration for a specific firmware version can be loaded.
44
+ * If this is `undefined` or not given, the first matching file with a defined firmware range will be returned.
45
+ */
46
+ lookupDevicePreserveConditions(manufacturerId: number, productType: number, productId: number, firmwareVersion?: string): Promise<ConditionalDeviceConfig | undefined>;
47
+ /**
48
+ * Looks up the definition of a given device in the configuration DB
49
+ * @param manufacturerId The manufacturer id of the device
50
+ * @param productType The product type of the device
51
+ * @param productId The product id of the device
52
+ * @param firmwareVersion If known, configuration for a specific firmware version can be loaded.
53
+ * If this is `undefined` or not given, the first matching file with a defined firmware range will be returned.
54
+ */
55
+ lookupDevice(manufacturerId: number, productType: number, productId: number, firmwareVersion?: string): Promise<DeviceConfig | undefined>;
56
+ }
57
+ //# sourceMappingURL=ConfigManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigManager.d.ts","sourceRoot":"","sources":["../../src/ConfigManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,iBAAiB,EAEjB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EACN,KAAK,gBAAgB,EAGrB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACN,uBAAuB,EACvB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAK9B,MAAM,2BAA2B,CAAC;AAQnC,MAAM,WAAW,oBAAoB;IACpC,YAAY,CAAC,EAAE,iBAAiB,CAAC;IACjC,uBAAuB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,qBAAa,aAAa;gBACN,OAAO,GAAE,oBAAyB;IAQrD,OAAO,CAAC,cAAc,CAAS;IAC/B,IAAW,aAAa,IAAI,MAAM,CAEjC;IAED,OAAO,CAAC,MAAM,CAAe;IAE7B,OAAO,CAAC,cAAc,CAA+B;IACrD,IAAW,aAAa,IAAI,gBAAgB,CAQ3C;IAED,OAAO,CAAC,uBAAuB,CAAqB;IACpD,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,aAAa,CAAwC;IAE7D,OAAO,CAAC,kBAAkB,CAAkB;IAC5C,IAAW,iBAAiB,IAAI,OAAO,CAEtC;IAEY,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAoBxB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBlC,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAW/C;;;OAGG;IACI,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAWrE;;;;OAIG;IACI,eAAe,CACrB,cAAc,EAAE,MAAM,EACtB,gBAAgB,EAAE,MAAM,GACtB,IAAI;IAWM,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAiDtC,QAAQ,IAAI,iBAAiB,GAAG,SAAS;IAInC,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9C,gBAAgB,IAAI,yBAAyB,GAAG,SAAS;IAIhE;;;;;;;OAOG;IACU,8BAA8B,CAC1C,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,eAAe,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC;IA6D/C;;;;;;;OAOG;IACU,YAAY,CACxB,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,eAAe,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;CAcpC"}
@@ -1,22 +1,16 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ConfigManager = void 0;
7
- const core_1 = require("@zwave-js/core");
8
- const shared_1 = require("@zwave-js/shared");
9
- const node_path_1 = __importDefault(require("node:path"));
10
- const Logger_1 = require("./Logger");
11
- const Manufacturers_1 = require("./Manufacturers");
12
- const _version_1 = require("./_version");
13
- const DeviceConfig_1 = require("./devices/DeviceConfig");
14
- const utils_1 = require("./utils");
15
- class ConfigManager {
1
+ import { ZWaveError, ZWaveErrorCodes, ZWaveLogContainer, isZWaveError, } from "@zwave-js/core";
2
+ import { getErrorMessage, pathExists } from "@zwave-js/shared";
3
+ import path from "node:path";
4
+ import { ConfigLogger } from "./Logger.js";
5
+ import { loadManufacturersInternal, saveManufacturersInternal, } from "./Manufacturers.js";
6
+ import { PACKAGE_VERSION } from "./_version.js";
7
+ import { ConditionalDeviceConfig, generatePriorityDeviceIndex, getDevicesPaths, loadDeviceIndexInternal, loadFulltextDeviceIndexInternal, } from "./devices/DeviceConfig.js";
8
+ import { configDir, externalConfigDir, getDeviceEntryPredicate, syncExternalConfigDir, } from "./utils.js";
9
+ export class ConfigManager {
16
10
  constructor(options = {}) {
17
- this.logger = new Logger_1.ConfigLogger(options.logContainer ?? new core_1.ZWaveLogContainer({ enabled: false }));
11
+ this.logger = new ConfigLogger(options.logContainer ?? new ZWaveLogContainer({ enabled: false }));
18
12
  this.deviceConfigPriorityDir = options.deviceConfigPriorityDir;
19
- this._configVersion = _version_1.PACKAGE_VERSION;
13
+ this._configVersion = PACKAGE_VERSION;
20
14
  }
21
15
  _configVersion;
22
16
  get configVersion() {
@@ -26,7 +20,7 @@ class ConfigManager {
26
20
  _manufacturers;
27
21
  get manufacturers() {
28
22
  if (!this._manufacturers) {
29
- throw new core_1.ZWaveError("The config has not been loaded yet!", core_1.ZWaveErrorCodes.Driver_NotReady);
23
+ throw new ZWaveError("The config has not been loaded yet!", ZWaveErrorCodes.Driver_NotReady);
30
24
  }
31
25
  return this._manufacturers;
32
26
  }
@@ -40,15 +34,15 @@ class ConfigManager {
40
34
  async loadAll() {
41
35
  // If the environment option for an external config dir is set
42
36
  // try to sync it and then use it
43
- const syncResult = await (0, utils_1.syncExternalConfigDir)(this.logger);
37
+ const syncResult = await syncExternalConfigDir(this.logger);
44
38
  if (syncResult.success) {
45
39
  this._useExternalConfig = true;
46
- this.logger.print(`Using external configuration dir ${(0, utils_1.externalConfigDir)()}`);
40
+ this.logger.print(`Using external configuration dir ${externalConfigDir()}`);
47
41
  this._configVersion = syncResult.version;
48
42
  }
49
43
  else {
50
44
  this._useExternalConfig = false;
51
- this._configVersion = _version_1.PACKAGE_VERSION;
45
+ this._configVersion = PACKAGE_VERSION;
52
46
  }
53
47
  this.logger.print(`version ${this._configVersion}`, "info");
54
48
  await this.loadManufacturers();
@@ -56,11 +50,11 @@ class ConfigManager {
56
50
  }
57
51
  async loadManufacturers() {
58
52
  try {
59
- this._manufacturers = await (0, Manufacturers_1.loadManufacturersInternal)(this._useExternalConfig);
53
+ this._manufacturers = await loadManufacturersInternal(this._useExternalConfig);
60
54
  }
61
55
  catch (e) {
62
56
  // If the config file is missing or invalid, don't try to find it again
63
- if ((0, core_1.isZWaveError)(e) && e.code === core_1.ZWaveErrorCodes.Config_Invalid) {
57
+ if (isZWaveError(e) && e.code === ZWaveErrorCodes.Config_Invalid) {
64
58
  if (process.env.NODE_ENV !== "test") {
65
59
  this.logger.print(`Could not load manufacturers config: ${e.message}`, "error");
66
60
  }
@@ -75,9 +69,9 @@ class ConfigManager {
75
69
  }
76
70
  async saveManufacturers() {
77
71
  if (!this._manufacturers) {
78
- throw new core_1.ZWaveError("The config has not been loaded yet!", core_1.ZWaveErrorCodes.Driver_NotReady);
72
+ throw new ZWaveError("The config has not been loaded yet!", ZWaveErrorCodes.Driver_NotReady);
79
73
  }
80
- await (0, Manufacturers_1.saveManufacturersInternal)(this._manufacturers);
74
+ await saveManufacturersInternal(this._manufacturers);
81
75
  }
82
76
  /**
83
77
  * Looks up the name of the manufacturer with the given ID in the configuration DB
@@ -85,7 +79,7 @@ class ConfigManager {
85
79
  */
86
80
  lookupManufacturer(manufacturerId) {
87
81
  if (!this._manufacturers) {
88
- throw new core_1.ZWaveError("The config has not been loaded yet!", core_1.ZWaveErrorCodes.Driver_NotReady);
82
+ throw new ZWaveError("The config has not been loaded yet!", ZWaveErrorCodes.Driver_NotReady);
89
83
  }
90
84
  return this._manufacturers.get(manufacturerId);
91
85
  }
@@ -96,19 +90,19 @@ class ConfigManager {
96
90
  */
97
91
  setManufacturer(manufacturerId, manufacturerName) {
98
92
  if (!this._manufacturers) {
99
- throw new core_1.ZWaveError("The config has not been loaded yet!", core_1.ZWaveErrorCodes.Driver_NotReady);
93
+ throw new ZWaveError("The config has not been loaded yet!", ZWaveErrorCodes.Driver_NotReady);
100
94
  }
101
95
  this._manufacturers.set(manufacturerId, manufacturerName);
102
96
  }
103
97
  async loadDeviceIndex() {
104
98
  try {
105
99
  // The index of config files included in this package
106
- const embeddedIndex = await (0, DeviceConfig_1.loadDeviceIndexInternal)(this.logger, this._useExternalConfig);
100
+ const embeddedIndex = await loadDeviceIndexInternal(this.logger, this._useExternalConfig);
107
101
  // A dynamic index of the user-defined priority device config files
108
102
  const priorityIndex = [];
109
103
  if (this.deviceConfigPriorityDir) {
110
- if (await (0, shared_1.pathExists)(this.deviceConfigPriorityDir)) {
111
- priorityIndex.push(...(await (0, DeviceConfig_1.generatePriorityDeviceIndex)(this.deviceConfigPriorityDir, this.logger)));
104
+ if (await pathExists(this.deviceConfigPriorityDir)) {
105
+ priorityIndex.push(...(await generatePriorityDeviceIndex(this.deviceConfigPriorityDir, this.logger)));
112
106
  }
113
107
  else {
114
108
  this.logger.print(`Priority device configuration directory ${this.deviceConfigPriorityDir} not found`, "warn");
@@ -119,9 +113,9 @@ class ConfigManager {
119
113
  }
120
114
  catch (e) {
121
115
  // If the index file is missing or invalid, don't try to find it again
122
- if ((!(0, core_1.isZWaveError)(e) && e instanceof Error)
123
- || ((0, core_1.isZWaveError)(e)
124
- && e.code === core_1.ZWaveErrorCodes.Config_Invalid)) {
116
+ if ((!isZWaveError(e) && e instanceof Error)
117
+ || (isZWaveError(e)
118
+ && e.code === ZWaveErrorCodes.Config_Invalid)) {
125
119
  // Fall back to no index on production systems
126
120
  if (!this.index)
127
121
  this.index = [];
@@ -139,7 +133,7 @@ class ConfigManager {
139
133
  return this.index;
140
134
  }
141
135
  async loadFulltextDeviceIndex() {
142
- this.fulltextIndex = await (0, DeviceConfig_1.loadFulltextDeviceIndexInternal)(this.logger);
136
+ this.fulltextIndex = await loadFulltextDeviceIndexInternal(this.logger);
143
137
  }
144
138
  getFulltextIndex() {
145
139
  return this.fulltextIndex;
@@ -157,20 +151,20 @@ class ConfigManager {
157
151
  if (!this.index)
158
152
  await this.loadDeviceIndex();
159
153
  // Look up the device in the index
160
- const indexEntries = this.index.filter((0, utils_1.getDeviceEntryPredicate)(manufacturerId, productType, productId, firmwareVersion));
154
+ const indexEntries = this.index.filter(getDeviceEntryPredicate(manufacturerId, productType, productId, firmwareVersion));
161
155
  // If there are multiple with overlapping firmware ranges, return the preferred one first
162
156
  const indexEntry = indexEntries.find((e) => !!e.preferred)
163
157
  ?? indexEntries[0];
164
158
  if (indexEntry) {
165
- const devicesDir = (0, DeviceConfig_1.getDevicesPaths)(this._useExternalConfig ? (0, utils_1.externalConfigDir)() : utils_1.configDir).devicesDir;
166
- const filePath = node_path_1.default.isAbsolute(indexEntry.filename)
159
+ const devicesDir = getDevicesPaths(this._useExternalConfig ? externalConfigDir() : configDir).devicesDir;
160
+ const filePath = path.isAbsolute(indexEntry.filename)
167
161
  ? indexEntry.filename
168
- : node_path_1.default.join(devicesDir, indexEntry.filename);
169
- if (!(await (0, shared_1.pathExists)(filePath)))
162
+ : path.join(devicesDir, indexEntry.filename);
163
+ if (!(await pathExists(filePath)))
170
164
  return;
171
165
  // A config file is treated as am embedded one when it is located under the devices root dir
172
166
  // or the external config dir
173
- const isEmbedded = !node_path_1.default
167
+ const isEmbedded = !path
174
168
  .relative(devicesDir, filePath)
175
169
  .startsWith("..");
176
170
  // When a device file is located in a different root directory than the embedded config files,
@@ -180,11 +174,11 @@ class ConfigManager {
180
174
  ? undefined
181
175
  : [devicesDir];
182
176
  try {
183
- return await DeviceConfig_1.ConditionalDeviceConfig.from(filePath, isEmbedded, { rootDir, fallbackDirs });
177
+ return await ConditionalDeviceConfig.from(filePath, isEmbedded, { rootDir, fallbackDirs });
184
178
  }
185
179
  catch (e) {
186
180
  if (process.env.NODE_ENV !== "test") {
187
- this.logger.print(`Error loading device config ${filePath}: ${(0, shared_1.getErrorMessage)(e, true)}`, "error");
181
+ this.logger.print(`Error loading device config ${filePath}: ${getErrorMessage(e, true)}`, "error");
188
182
  }
189
183
  }
190
184
  }
@@ -207,5 +201,4 @@ class ConfigManager {
207
201
  });
208
202
  }
209
203
  }
210
- exports.ConfigManager = ConfigManager;
211
204
  //# sourceMappingURL=ConfigManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigManager.js","sourceRoot":"","sources":["../../src/ConfigManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,YAAY,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAEN,yBAAyB,EACzB,yBAAyB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACN,uBAAuB,EAIvB,2BAA2B,EAC3B,eAAe,EACf,uBAAuB,EACvB,+BAA+B,GAC/B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,SAAS,EACT,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,GACrB,MAAM,YAAY,CAAC;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;IACI,KAAK,CAAC,YAAY,CACxB,cAAsB,EACtB,WAAmB,EACnB,SAAiB,EACjB,eAAwB;QAExB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,8BAA8B,CACpD,cAAc,EACd,WAAW,EACX,SAAS,EACT,eAAe,CACf,CAAC;QACF,OAAO,GAAG,EAAE,QAAQ,CAAC;YACpB,cAAc;YACd,WAAW;YACX,SAAS;YACT,eAAe;SACf,CAAC,CAAC;IACJ,CAAC;CACD"}
@@ -0,0 +1,4 @@
1
+ export declare function clearTemplateCache(): void;
2
+ /** Parses a JSON file with $import keys and replaces them with the selected objects */
3
+ export declare function readJsonWithTemplate(filename: string, rootDirs?: string | string[]): Promise<Record<string, unknown>>;
4
+ //# sourceMappingURL=JsonTemplate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonTemplate.d.ts","sourceRoot":"","sources":["../../src/JsonTemplate.ts"],"names":[],"mappings":"AAkBA,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED,uFAAuF;AACvF,wBAAsB,oBAAoB,CACzC,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAC1B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA4BlC"}