@zwave-js/config 14.0.0-beta.1 → 14.0.0-beta.5
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/build/{ConfigManager.d.ts → cjs/ConfigManager.d.ts} +5 -2
- package/build/cjs/ConfigManager.js +217 -0
- package/build/cjs/ConfigManager.js.map +7 -0
- package/build/cjs/JsonTemplate.js +198 -0
- package/build/cjs/JsonTemplate.js.map +7 -0
- package/build/{Logger.d.ts → cjs/Logger.d.ts} +1 -1
- package/build/cjs/Logger.js +50 -0
- package/build/cjs/Logger.js.map +7 -0
- package/build/cjs/Logger_safe.js +32 -0
- package/build/cjs/Logger_safe.js.map +7 -0
- package/build/cjs/Logic.js +71 -0
- package/build/cjs/Logic.js.map +7 -0
- package/build/cjs/LogicParser.js +1343 -0
- package/build/cjs/LogicParser.js.map +7 -0
- package/build/cjs/Manufacturers.js +88 -0
- package/build/cjs/Manufacturers.js.map +7 -0
- package/build/cjs/_version.d.ts +2 -0
- package/build/cjs/_version.js +29 -0
- package/build/cjs/_version.js.map +7 -0
- package/build/{devices → cjs/devices}/AssociationConfig.d.ts +2 -2
- package/build/cjs/devices/AssociationConfig.js +93 -0
- package/build/cjs/devices/AssociationConfig.js.map +7 -0
- package/build/{devices → cjs/devices}/CompatConfig.d.ts +2 -2
- package/build/cjs/devices/CompatConfig.js +584 -0
- package/build/cjs/devices/CompatConfig.js.map +7 -0
- package/build/{devices → cjs/devices}/ConditionalItem.d.ts +1 -1
- package/build/cjs/devices/ConditionalItem.js +107 -0
- package/build/cjs/devices/ConditionalItem.js.map +7 -0
- package/build/{devices → cjs/devices}/ConditionalPrimitive.d.ts +2 -2
- package/build/cjs/devices/ConditionalPrimitive.js +59 -0
- package/build/cjs/devices/ConditionalPrimitive.js.map +7 -0
- package/build/{devices → cjs/devices}/DeviceConfig.d.ts +7 -7
- package/build/cjs/devices/DeviceConfig.js +502 -0
- package/build/cjs/devices/DeviceConfig.js.map +7 -0
- package/build/cjs/devices/DeviceConfig.unit._test.js +17 -0
- package/build/cjs/devices/DeviceConfig.unit._test.js.map +7 -0
- package/build/{devices → cjs/devices}/DeviceMetadata.d.ts +3 -3
- package/build/cjs/devices/DeviceMetadata.js +112 -0
- package/build/cjs/devices/DeviceMetadata.js.map +7 -0
- package/build/{devices → cjs/devices}/EndpointConfig.d.ts +5 -5
- package/build/cjs/devices/EndpointConfig.js +87 -0
- package/build/cjs/devices/EndpointConfig.js.map +7 -0
- package/build/{devices → cjs/devices}/ParamInformation.d.ts +3 -3
- package/build/cjs/devices/ParamInformation.js +209 -0
- package/build/cjs/devices/ParamInformation.js.map +7 -0
- package/build/cjs/devices/shared.js +17 -0
- package/build/cjs/devices/shared.js.map +7 -0
- package/build/cjs/index.d.ts +12 -0
- package/build/cjs/index.js +50 -0
- package/build/cjs/index.js.map +7 -0
- package/build/cjs/index_safe.d.ts +3 -0
- package/build/cjs/index_safe.js +32 -0
- package/build/cjs/index_safe.js.map +7 -0
- package/build/cjs/package.json +3 -0
- package/build/{utils.d.ts → cjs/utils.d.ts} +4 -4
- package/build/cjs/utils.js +116 -0
- package/build/cjs/utils.js.map +7 -0
- package/build/cjs/utils_safe.js +57 -0
- package/build/cjs/utils_safe.js.map +7 -0
- package/build/esm/ConfigManager.d.ts +60 -0
- package/build/esm/ConfigManager.d.ts.map +1 -0
- package/build/{ConfigManager.js → esm/ConfigManager.js} +47 -44
- package/build/esm/ConfigManager.js.map +1 -0
- package/build/esm/JsonTemplate.d.ts +4 -0
- package/build/esm/JsonTemplate.d.ts.map +1 -0
- package/build/{JsonTemplate.js → esm/JsonTemplate.js} +30 -60
- package/build/esm/JsonTemplate.js.map +1 -0
- package/build/esm/Logger.d.ts +11 -0
- package/build/esm/Logger.d.ts.map +1 -0
- package/build/esm/Logger.js +23 -0
- package/build/esm/Logger.js.map +1 -0
- package/build/esm/Logger_safe.d.ts +5 -0
- package/build/esm/Logger_safe.d.ts.map +1 -0
- package/build/esm/Logger_safe.js +3 -0
- package/build/esm/Logger_safe.js.map +1 -0
- package/build/esm/Logic.d.ts +4 -0
- package/build/esm/Logic.d.ts.map +1 -0
- package/build/esm/Logic.js +35 -0
- package/build/esm/Logic.js.map +1 -0
- package/build/esm/LogicParser.d.ts +93 -0
- package/build/esm/LogicParser.d.ts.map +1 -0
- package/build/{LogicParser.js → esm/LogicParser.js} +2 -5
- package/build/{LogicParser.js.map → esm/LogicParser.js.map} +1 -1
- package/build/esm/Manufacturers.d.ts +6 -0
- package/build/esm/Manufacturers.d.ts.map +1 -0
- package/build/esm/Manufacturers.js +55 -0
- package/build/esm/Manufacturers.js.map +1 -0
- package/build/esm/_version.d.ts +2 -0
- package/build/esm/_version.d.ts.map +1 -0
- package/build/esm/_version.js +3 -0
- package/build/esm/_version.js.map +1 -0
- package/build/esm/devices/AssociationConfig.d.ts +27 -0
- package/build/esm/devices/AssociationConfig.d.ts.map +1 -0
- package/build/{devices → esm/devices}/AssociationConfig.js +12 -16
- package/build/esm/devices/AssociationConfig.js.map +1 -0
- package/build/esm/devices/CompatConfig.d.ts +112 -0
- package/build/esm/devices/CompatConfig.d.ts.map +1 -0
- package/build/{devices → esm/devices}/CompatConfig.js +112 -119
- package/build/esm/devices/CompatConfig.js.map +1 -0
- package/build/esm/devices/ConditionalItem.d.ts +14 -0
- package/build/esm/devices/ConditionalItem.d.ts.map +1 -0
- package/build/{devices → esm/devices}/ConditionalItem.js +15 -21
- package/build/esm/devices/ConditionalItem.js.map +1 -0
- package/build/esm/devices/ConditionalPrimitive.d.ts +13 -0
- package/build/esm/devices/ConditionalPrimitive.d.ts.map +1 -0
- package/build/esm/devices/ConditionalPrimitive.js +35 -0
- package/build/esm/devices/ConditionalPrimitive.js.map +1 -0
- package/build/esm/devices/DeviceConfig.d.ts +117 -0
- package/build/esm/devices/DeviceConfig.d.ts.map +1 -0
- package/build/{devices → esm/devices}/DeviceConfig.js +96 -108
- package/build/esm/devices/DeviceConfig.js.map +1 -0
- package/build/esm/devices/DeviceConfig.unit._test.d.ts +2 -0
- package/build/esm/devices/DeviceConfig.unit._test.d.ts.map +1 -0
- package/build/{devices → esm/devices}/DeviceConfig.unit._test.js +1 -2
- package/build/esm/devices/DeviceConfig.unit._test.js.map +1 -0
- package/build/esm/devices/DeviceMetadata.d.ts +41 -0
- package/build/esm/devices/DeviceMetadata.d.ts.map +1 -0
- package/build/{devices → esm/devices}/DeviceMetadata.js +16 -21
- package/build/esm/devices/DeviceMetadata.js.map +1 -0
- package/build/esm/devices/EndpointConfig.d.ts +20 -0
- package/build/esm/devices/EndpointConfig.d.ts.map +1 -0
- package/build/esm/devices/EndpointConfig.js +60 -0
- package/build/esm/devices/EndpointConfig.js.map +1 -0
- package/build/esm/devices/ParamInformation.d.ts +50 -0
- package/build/esm/devices/ParamInformation.d.ts.map +1 -0
- package/build/{devices → esm/devices}/ParamInformation.js +38 -44
- package/build/esm/devices/ParamInformation.js.map +1 -0
- package/build/esm/devices/shared.d.ts +11 -0
- package/build/esm/devices/shared.d.ts.map +1 -0
- package/build/esm/devices/shared.js +2 -0
- package/build/{devices → esm/devices}/shared.js.map +1 -1
- package/build/esm/index.d.ts +12 -0
- package/build/esm/index.d.ts.map +1 -0
- package/build/esm/index.js +13 -0
- package/build/esm/index.js.map +1 -0
- package/build/esm/index_safe.d.ts +3 -0
- package/build/esm/index_safe.d.ts.map +1 -0
- package/build/esm/index_safe.js +4 -0
- package/build/esm/index_safe.js.map +1 -0
- package/build/esm/package.json +3 -0
- package/build/esm/utils.d.ts +19 -0
- package/build/esm/utils.d.ts.map +1 -0
- package/build/esm/utils.js +92 -0
- package/build/esm/utils.js.map +1 -0
- package/build/esm/utils_safe.d.ts +7 -0
- package/build/esm/utils_safe.d.ts.map +1 -0
- package/build/esm/utils_safe.js +28 -0
- package/build/esm/utils_safe.js.map +1 -0
- package/package.json +22 -19
- package/build/ConfigManager.d.ts.map +0 -1
- package/build/ConfigManager.js.map +0 -1
- package/build/JsonTemplate.d.ts.map +0 -1
- package/build/JsonTemplate.js.map +0 -1
- package/build/Logger.d.ts.map +0 -1
- package/build/Logger.js +0 -27
- package/build/Logger.js.map +0 -1
- package/build/Logger_safe.d.ts.map +0 -1
- package/build/Logger_safe.js +0 -6
- package/build/Logger_safe.js.map +0 -1
- package/build/Logic.d.ts.map +0 -1
- package/build/Logic.js +0 -60
- package/build/Logic.js.map +0 -1
- package/build/LogicParser.d.ts.map +0 -1
- package/build/Manufacturers.d.ts.map +0 -1
- package/build/Manufacturers.js +0 -62
- package/build/Manufacturers.js.map +0 -1
- package/build/_version.d.ts +0 -2
- package/build/_version.d.ts.map +0 -1
- package/build/_version.js +0 -6
- package/build/_version.js.map +0 -1
- package/build/devices/AssociationConfig.d.ts.map +0 -1
- package/build/devices/AssociationConfig.js.map +0 -1
- package/build/devices/CompatConfig.d.ts.map +0 -1
- package/build/devices/CompatConfig.js.map +0 -1
- package/build/devices/ConditionalItem.d.ts.map +0 -1
- package/build/devices/ConditionalItem.js.map +0 -1
- package/build/devices/ConditionalPrimitive.d.ts.map +0 -1
- package/build/devices/ConditionalPrimitive.js +0 -40
- package/build/devices/ConditionalPrimitive.js.map +0 -1
- package/build/devices/DeviceConfig.d.ts.map +0 -1
- package/build/devices/DeviceConfig.js.map +0 -1
- package/build/devices/DeviceConfig.unit._test.d.ts.map +0 -1
- package/build/devices/DeviceConfig.unit._test.js.map +0 -1
- package/build/devices/DeviceMetadata.d.ts.map +0 -1
- package/build/devices/DeviceMetadata.js.map +0 -1
- package/build/devices/EndpointConfig.d.ts.map +0 -1
- package/build/devices/EndpointConfig.js +0 -64
- package/build/devices/EndpointConfig.js.map +0 -1
- package/build/devices/ParamInformation.d.ts.map +0 -1
- package/build/devices/ParamInformation.js.map +0 -1
- package/build/devices/shared.d.ts.map +0 -1
- package/build/devices/shared.js +0 -3
- package/build/index.d.ts +0 -13
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -33
- package/build/index.js.map +0 -1
- package/build/index_safe.d.ts +0 -3
- package/build/index_safe.d.ts.map +0 -1
- package/build/index_safe.js +0 -22
- package/build/index_safe.js.map +0 -1
- package/build/utils.d.ts.map +0 -1
- package/build/utils.js +0 -124
- package/build/utils.js.map +0 -1
- package/build/utils_safe.d.ts.map +0 -1
- package/build/utils_safe.js +0 -33
- package/build/utils_safe.js.map +0 -1
- /package/build/{JsonTemplate.d.ts → cjs/JsonTemplate.d.ts} +0 -0
- /package/build/{Logger_safe.d.ts → cjs/Logger_safe.d.ts} +0 -0
- /package/build/{Logic.d.ts → cjs/Logic.d.ts} +0 -0
- /package/build/{LogicParser.d.ts → cjs/LogicParser.d.ts} +0 -0
- /package/build/{Manufacturers.d.ts → cjs/Manufacturers.d.ts} +0 -0
- /package/build/{devices → cjs/devices}/DeviceConfig.unit._test.d.ts +0 -0
- /package/build/{devices → cjs/devices}/shared.d.ts +0 -0
- /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
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
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 */
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function getExternalConfigDirEnvVariable(): string | undefined;
|
|
7
7
|
export declare function getDeviceEntryPredicate(manufacturerId: number, productType: number, productId: number, firmwareVersion?: string): (entry: DeviceConfigIndexEntry) => boolean;
|
|
8
8
|
export type SyncExternalConfigDirResult = {
|
|
9
9
|
success: false;
|
|
@@ -14,6 +14,6 @@ export type SyncExternalConfigDirResult = {
|
|
|
14
14
|
/**
|
|
15
15
|
* Synchronizes or updates the external config directory and returns whether the directory is in a state that can be used
|
|
16
16
|
*/
|
|
17
|
-
export declare function syncExternalConfigDir(logger: ConfigLogger): Promise<SyncExternalConfigDirResult>;
|
|
17
|
+
export declare function syncExternalConfigDir(extConfigDir: string, logger: ConfigLogger): Promise<SyncExternalConfigDirResult>;
|
|
18
18
|
export declare function versionInRange(version: string, min: string, max: string): boolean;
|
|
19
19
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1,116 @@
|
|
|
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
|
+
getDeviceEntryPredicate: () => getDeviceEntryPredicate,
|
|
33
|
+
getExternalConfigDirEnvVariable: () => getExternalConfigDirEnvVariable,
|
|
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 getExternalConfigDirEnvVariable() {
|
|
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(extConfigDir, logger) {
|
|
65
|
+
if (!extConfigDir)
|
|
66
|
+
return { success: false };
|
|
67
|
+
try {
|
|
68
|
+
await import_promises.default.mkdir(extConfigDir, { recursive: true });
|
|
69
|
+
} catch {
|
|
70
|
+
logger.print(`Synchronizing external config dir failed - directory could not be created`, "error");
|
|
71
|
+
return { success: false };
|
|
72
|
+
}
|
|
73
|
+
const externalVersionFilename = import_node_path.default.join(extConfigDir, "version");
|
|
74
|
+
const currentVersion = import_version.PACKAGE_VERSION;
|
|
75
|
+
const supportedRange = `>=${currentVersion} <${semver.inc(currentVersion, "patch")}`;
|
|
76
|
+
let wipe = false;
|
|
77
|
+
let externalVersion;
|
|
78
|
+
try {
|
|
79
|
+
externalVersion = await import_promises.default.readFile(externalVersionFilename, "utf8");
|
|
80
|
+
if (!semver.valid(externalVersion)) {
|
|
81
|
+
wipe = true;
|
|
82
|
+
} else if (!semver.satisfies(externalVersion, supportedRange, {
|
|
83
|
+
includePrerelease: true
|
|
84
|
+
})) {
|
|
85
|
+
wipe = true;
|
|
86
|
+
}
|
|
87
|
+
} catch {
|
|
88
|
+
wipe = true;
|
|
89
|
+
}
|
|
90
|
+
if (!wipe)
|
|
91
|
+
return { success: true, version: externalVersion };
|
|
92
|
+
try {
|
|
93
|
+
logger.print(`Synchronizing external config dir ${extConfigDir}...`);
|
|
94
|
+
await import_promises.default.rm(extConfigDir, { recursive: true, force: true });
|
|
95
|
+
await import_promises.default.mkdir(extConfigDir, { recursive: true });
|
|
96
|
+
await (0, import_shared.copyFilesRecursive)(configDir, extConfigDir, (src) => src.endsWith(".json"));
|
|
97
|
+
await import_promises.default.writeFile(externalVersionFilename, currentVersion, "utf8");
|
|
98
|
+
externalVersion = currentVersion;
|
|
99
|
+
} catch {
|
|
100
|
+
logger.print(`Synchronizing external config dir failed - using embedded config`, "error");
|
|
101
|
+
return { success: false };
|
|
102
|
+
}
|
|
103
|
+
return { success: true, version: externalVersion };
|
|
104
|
+
}
|
|
105
|
+
function versionInRange(version, min, max) {
|
|
106
|
+
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));
|
|
107
|
+
}
|
|
108
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
109
|
+
0 && (module.exports = {
|
|
110
|
+
configDir,
|
|
111
|
+
getDeviceEntryPredicate,
|
|
112
|
+
getExternalConfigDirEnvVariable,
|
|
113
|
+
syncExternalConfigDir,
|
|
114
|
+
versionInRange
|
|
115
|
+
});
|
|
116
|
+
//# 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\n/** The (optional) absolute path of an external configuration directory */\nexport function getExternalConfigDirEnvVariable(): 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\textConfigDir: string,\n\tlogger: ConfigLogger,\n): Promise<SyncExternalConfigDirResult> {\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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= 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,60 @@
|
|
|
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
|
+
deviceConfigExternalDir?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class ConfigManager {
|
|
10
|
+
constructor(options?: ConfigManagerOptions);
|
|
11
|
+
private _configVersion;
|
|
12
|
+
get configVersion(): string;
|
|
13
|
+
private logger;
|
|
14
|
+
private _manufacturers;
|
|
15
|
+
get manufacturers(): ManufacturersMap;
|
|
16
|
+
private deviceConfigPriorityDir;
|
|
17
|
+
private deviceConfigExternalDir;
|
|
18
|
+
get externalConfigDir(): string | undefined;
|
|
19
|
+
private index;
|
|
20
|
+
private fulltextIndex;
|
|
21
|
+
private _useExternalConfig;
|
|
22
|
+
get useExternalConfig(): boolean;
|
|
23
|
+
loadAll(): Promise<void>;
|
|
24
|
+
loadManufacturers(): Promise<void>;
|
|
25
|
+
saveManufacturers(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Looks up the name of the manufacturer with the given ID in the configuration DB
|
|
28
|
+
* @param manufacturerId The manufacturer id to look up
|
|
29
|
+
*/
|
|
30
|
+
lookupManufacturer(manufacturerId: number): string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Add new manufacturers to configuration DB
|
|
33
|
+
* @param manufacturerId The manufacturer id to look up
|
|
34
|
+
* @param manufacturerName The manufacturer name
|
|
35
|
+
*/
|
|
36
|
+
setManufacturer(manufacturerId: number, manufacturerName: string): void;
|
|
37
|
+
loadDeviceIndex(): Promise<void>;
|
|
38
|
+
getIndex(): DeviceConfigIndex | undefined;
|
|
39
|
+
loadFulltextDeviceIndex(): Promise<void>;
|
|
40
|
+
getFulltextIndex(): FulltextDeviceConfigIndex | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Looks up the definition of a given device in the configuration DB, but does not evaluate conditional settings.
|
|
43
|
+
* @param manufacturerId The manufacturer id of the device
|
|
44
|
+
* @param productType The product type of the device
|
|
45
|
+
* @param productId The product id of the device
|
|
46
|
+
* @param firmwareVersion If known, configuration for a specific firmware version can be loaded.
|
|
47
|
+
* If this is `undefined` or not given, the first matching file with a defined firmware range will be returned.
|
|
48
|
+
*/
|
|
49
|
+
lookupDevicePreserveConditions(manufacturerId: number, productType: number, productId: number, firmwareVersion?: string): Promise<ConditionalDeviceConfig | undefined>;
|
|
50
|
+
/**
|
|
51
|
+
* Looks up the definition of a given device in the configuration DB
|
|
52
|
+
* @param manufacturerId The manufacturer id of the device
|
|
53
|
+
* @param productType The product type of the device
|
|
54
|
+
* @param productId The product id of the device
|
|
55
|
+
* @param firmwareVersion If known, configuration for a specific firmware version can be loaded.
|
|
56
|
+
* If this is `undefined` or not given, the first matching file with a defined firmware range will be returned.
|
|
57
|
+
*/
|
|
58
|
+
lookupDevice(manufacturerId: number, productType: number, productId: number, firmwareVersion?: string): Promise<DeviceConfig | undefined>;
|
|
59
|
+
}
|
|
60
|
+
//# 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;AASnC,MAAM,WAAW,oBAAoB;IACpC,YAAY,CAAC,EAAE,iBAAiB,CAAC;IACjC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,uBAAuB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,qBAAa,aAAa;gBACN,OAAO,GAAE,oBAAyB;IAUrD,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,uBAAuB,CAAqB;IACp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ers");
|
|
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, getDeviceEntryPredicate, getExternalConfigDirEnvVariable, syncExternalConfigDir, } from "./utils.js";
|
|
9
|
+
export class ConfigManager {
|
|
16
10
|
constructor(options = {}) {
|
|
17
|
-
this.logger = new
|
|
11
|
+
this.logger = new ConfigLogger(options.logContainer ?? new ZWaveLogContainer({ enabled: false }));
|
|
18
12
|
this.deviceConfigPriorityDir = options.deviceConfigPriorityDir;
|
|
19
|
-
this.
|
|
13
|
+
this.deviceConfigExternalDir = options.deviceConfigExternalDir;
|
|
14
|
+
this._configVersion = PACKAGE_VERSION;
|
|
20
15
|
}
|
|
21
16
|
_configVersion;
|
|
22
17
|
get configVersion() {
|
|
@@ -26,11 +21,16 @@ class ConfigManager {
|
|
|
26
21
|
_manufacturers;
|
|
27
22
|
get manufacturers() {
|
|
28
23
|
if (!this._manufacturers) {
|
|
29
|
-
throw new
|
|
24
|
+
throw new ZWaveError("The config has not been loaded yet!", ZWaveErrorCodes.Driver_NotReady);
|
|
30
25
|
}
|
|
31
26
|
return this._manufacturers;
|
|
32
27
|
}
|
|
33
28
|
deviceConfigPriorityDir;
|
|
29
|
+
deviceConfigExternalDir;
|
|
30
|
+
get externalConfigDir() {
|
|
31
|
+
return this.deviceConfigExternalDir
|
|
32
|
+
?? getExternalConfigDirEnvVariable();
|
|
33
|
+
}
|
|
34
34
|
index;
|
|
35
35
|
fulltextIndex;
|
|
36
36
|
_useExternalConfig = false;
|
|
@@ -40,15 +40,19 @@ class ConfigManager {
|
|
|
40
40
|
async loadAll() {
|
|
41
41
|
// If the environment option for an external config dir is set
|
|
42
42
|
// try to sync it and then use it
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
let syncResult;
|
|
44
|
+
const externalConfigDir = this.externalConfigDir;
|
|
45
|
+
if (externalConfigDir) {
|
|
46
|
+
syncResult = await syncExternalConfigDir(externalConfigDir, this.logger);
|
|
47
|
+
}
|
|
48
|
+
if (syncResult?.success) {
|
|
45
49
|
this._useExternalConfig = true;
|
|
46
|
-
this.logger.print(`Using external configuration dir ${
|
|
50
|
+
this.logger.print(`Using external configuration dir ${externalConfigDir}`);
|
|
47
51
|
this._configVersion = syncResult.version;
|
|
48
52
|
}
|
|
49
53
|
else {
|
|
50
54
|
this._useExternalConfig = false;
|
|
51
|
-
this._configVersion =
|
|
55
|
+
this._configVersion = PACKAGE_VERSION;
|
|
52
56
|
}
|
|
53
57
|
this.logger.print(`version ${this._configVersion}`, "info");
|
|
54
58
|
await this.loadManufacturers();
|
|
@@ -56,11 +60,11 @@ class ConfigManager {
|
|
|
56
60
|
}
|
|
57
61
|
async loadManufacturers() {
|
|
58
62
|
try {
|
|
59
|
-
this._manufacturers = await
|
|
63
|
+
this._manufacturers = await loadManufacturersInternal(this._useExternalConfig && this.externalConfigDir || undefined);
|
|
60
64
|
}
|
|
61
65
|
catch (e) {
|
|
62
66
|
// If the config file is missing or invalid, don't try to find it again
|
|
63
|
-
if (
|
|
67
|
+
if (isZWaveError(e) && e.code === ZWaveErrorCodes.Config_Invalid) {
|
|
64
68
|
if (process.env.NODE_ENV !== "test") {
|
|
65
69
|
this.logger.print(`Could not load manufacturers config: ${e.message}`, "error");
|
|
66
70
|
}
|
|
@@ -75,9 +79,9 @@ class ConfigManager {
|
|
|
75
79
|
}
|
|
76
80
|
async saveManufacturers() {
|
|
77
81
|
if (!this._manufacturers) {
|
|
78
|
-
throw new
|
|
82
|
+
throw new ZWaveError("The config has not been loaded yet!", ZWaveErrorCodes.Driver_NotReady);
|
|
79
83
|
}
|
|
80
|
-
await
|
|
84
|
+
await saveManufacturersInternal(this._manufacturers);
|
|
81
85
|
}
|
|
82
86
|
/**
|
|
83
87
|
* Looks up the name of the manufacturer with the given ID in the configuration DB
|
|
@@ -85,7 +89,7 @@ class ConfigManager {
|
|
|
85
89
|
*/
|
|
86
90
|
lookupManufacturer(manufacturerId) {
|
|
87
91
|
if (!this._manufacturers) {
|
|
88
|
-
throw new
|
|
92
|
+
throw new ZWaveError("The config has not been loaded yet!", ZWaveErrorCodes.Driver_NotReady);
|
|
89
93
|
}
|
|
90
94
|
return this._manufacturers.get(manufacturerId);
|
|
91
95
|
}
|
|
@@ -96,19 +100,19 @@ class ConfigManager {
|
|
|
96
100
|
*/
|
|
97
101
|
setManufacturer(manufacturerId, manufacturerName) {
|
|
98
102
|
if (!this._manufacturers) {
|
|
99
|
-
throw new
|
|
103
|
+
throw new ZWaveError("The config has not been loaded yet!", ZWaveErrorCodes.Driver_NotReady);
|
|
100
104
|
}
|
|
101
105
|
this._manufacturers.set(manufacturerId, manufacturerName);
|
|
102
106
|
}
|
|
103
107
|
async loadDeviceIndex() {
|
|
104
108
|
try {
|
|
105
109
|
// The index of config files included in this package
|
|
106
|
-
const embeddedIndex = await
|
|
110
|
+
const embeddedIndex = await loadDeviceIndexInternal(this.logger, this._useExternalConfig && this.externalConfigDir || undefined);
|
|
107
111
|
// A dynamic index of the user-defined priority device config files
|
|
108
112
|
const priorityIndex = [];
|
|
109
113
|
if (this.deviceConfigPriorityDir) {
|
|
110
|
-
if (await
|
|
111
|
-
priorityIndex.push(...(await
|
|
114
|
+
if (await pathExists(this.deviceConfigPriorityDir)) {
|
|
115
|
+
priorityIndex.push(...(await generatePriorityDeviceIndex(this.deviceConfigPriorityDir, this.logger)));
|
|
112
116
|
}
|
|
113
117
|
else {
|
|
114
118
|
this.logger.print(`Priority device configuration directory ${this.deviceConfigPriorityDir} not found`, "warn");
|
|
@@ -119,9 +123,9 @@ class ConfigManager {
|
|
|
119
123
|
}
|
|
120
124
|
catch (e) {
|
|
121
125
|
// If the index file is missing or invalid, don't try to find it again
|
|
122
|
-
if ((!
|
|
123
|
-
|| (
|
|
124
|
-
&& e.code ===
|
|
126
|
+
if ((!isZWaveError(e) && e instanceof Error)
|
|
127
|
+
|| (isZWaveError(e)
|
|
128
|
+
&& e.code === ZWaveErrorCodes.Config_Invalid)) {
|
|
125
129
|
// Fall back to no index on production systems
|
|
126
130
|
if (!this.index)
|
|
127
131
|
this.index = [];
|
|
@@ -139,7 +143,7 @@ class ConfigManager {
|
|
|
139
143
|
return this.index;
|
|
140
144
|
}
|
|
141
145
|
async loadFulltextDeviceIndex() {
|
|
142
|
-
this.fulltextIndex = await
|
|
146
|
+
this.fulltextIndex = await loadFulltextDeviceIndexInternal(this.logger);
|
|
143
147
|
}
|
|
144
148
|
getFulltextIndex() {
|
|
145
149
|
return this.fulltextIndex;
|
|
@@ -157,20 +161,20 @@ class ConfigManager {
|
|
|
157
161
|
if (!this.index)
|
|
158
162
|
await this.loadDeviceIndex();
|
|
159
163
|
// Look up the device in the index
|
|
160
|
-
const indexEntries = this.index.filter(
|
|
164
|
+
const indexEntries = this.index.filter(getDeviceEntryPredicate(manufacturerId, productType, productId, firmwareVersion));
|
|
161
165
|
// If there are multiple with overlapping firmware ranges, return the preferred one first
|
|
162
166
|
const indexEntry = indexEntries.find((e) => !!e.preferred)
|
|
163
167
|
?? indexEntries[0];
|
|
164
168
|
if (indexEntry) {
|
|
165
|
-
const devicesDir =
|
|
166
|
-
const filePath =
|
|
169
|
+
const devicesDir = getDevicesPaths(this._useExternalConfig && this.externalConfigDir || configDir).devicesDir;
|
|
170
|
+
const filePath = path.isAbsolute(indexEntry.filename)
|
|
167
171
|
? indexEntry.filename
|
|
168
|
-
:
|
|
169
|
-
if (!(await
|
|
172
|
+
: path.join(devicesDir, indexEntry.filename);
|
|
173
|
+
if (!(await pathExists(filePath)))
|
|
170
174
|
return;
|
|
171
175
|
// A config file is treated as am embedded one when it is located under the devices root dir
|
|
172
176
|
// or the external config dir
|
|
173
|
-
const isEmbedded = !
|
|
177
|
+
const isEmbedded = !path
|
|
174
178
|
.relative(devicesDir, filePath)
|
|
175
179
|
.startsWith("..");
|
|
176
180
|
// When a device file is located in a different root directory than the embedded config files,
|
|
@@ -180,11 +184,11 @@ class ConfigManager {
|
|
|
180
184
|
? undefined
|
|
181
185
|
: [devicesDir];
|
|
182
186
|
try {
|
|
183
|
-
return await
|
|
187
|
+
return await ConditionalDeviceConfig.from(filePath, isEmbedded, { rootDir, fallbackDirs });
|
|
184
188
|
}
|
|
185
189
|
catch (e) {
|
|
186
190
|
if (process.env.NODE_ENV !== "test") {
|
|
187
|
-
this.logger.print(`Error loading device config ${filePath}: ${
|
|
191
|
+
this.logger.print(`Error loading device config ${filePath}: ${getErrorMessage(e, true)}`, "error");
|
|
188
192
|
}
|
|
189
193
|
}
|
|
190
194
|
}
|
|
@@ -207,5 +211,4 @@ class ConfigManager {
|
|
|
207
211
|
});
|
|
208
212
|
}
|
|
209
213
|
}
|
|
210
|
-
exports.ConfigManager = ConfigManager;
|
|
211
214
|
//# 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,E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ACtB,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC;iBAC9B,UAAU,CAAC,IAAI,CAAC,CAAC;YAEnB,8FAA8F;YAC9F,qCAAqC;YACrC,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,IAAI,UAAU,CAAC;YACjD,MAAM,YAAY,GAAG,OAAO,KAAK,UAAU;gBAC1C,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;YAEhB,IAAI,CAAC;gBACJ,OAAO,MAAM,uBAAuB,CAAC,IAAI,CACxC,QAAQ,EACR,UAAU,EACV,EAAE,OAAO,EAAE,YAAY,EAAE,CACzB,CAAC;YACH,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACZ,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;oBACrC,IAAI,CAAC,MAAM,CAAC,KAAK,CAChB,+BAA+B,QAAQ,KACtC,eAAe,CACd,CAAC,EACD,IAAI,CAEN,EAAE,EACF,OAAO,CACP,CAAC;gBACH,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAED;;;;;;;OAOG;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"}
|