@zwave-js/nvmedit 14.0.0-beta.4 → 14.0.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 (49) hide show
  1. package/build/cjs/lib/nvm3/files/ApplicationCCsFile.js +105 -58
  2. package/build/cjs/lib/nvm3/files/ApplicationCCsFile.js.map +2 -2
  3. package/build/cjs/lib/nvm3/files/ApplicationDataFile.js +69 -22
  4. package/build/cjs/lib/nvm3/files/ApplicationDataFile.js.map +2 -2
  5. package/build/cjs/lib/nvm3/files/ApplicationNameFile.js +71 -24
  6. package/build/cjs/lib/nvm3/files/ApplicationNameFile.js.map +2 -2
  7. package/build/cjs/lib/nvm3/files/ApplicationRFConfigFile.js +140 -93
  8. package/build/cjs/lib/nvm3/files/ApplicationRFConfigFile.js.map +2 -2
  9. package/build/cjs/lib/nvm3/files/ApplicationTypeFile.js +92 -45
  10. package/build/cjs/lib/nvm3/files/ApplicationTypeFile.js.map +2 -2
  11. package/build/cjs/lib/nvm3/files/ControllerInfoFile.js +176 -129
  12. package/build/cjs/lib/nvm3/files/ControllerInfoFile.js.map +2 -2
  13. package/build/cjs/lib/nvm3/files/NVMFile.d.ts +3 -3
  14. package/build/cjs/lib/nvm3/files/NVMFile.js.map +1 -1
  15. package/build/cjs/lib/nvm3/files/NodeInfoFiles.js +186 -111
  16. package/build/cjs/lib/nvm3/files/NodeInfoFiles.js.map +2 -2
  17. package/build/cjs/lib/nvm3/files/ProtocolNodeMaskFiles.js +243 -84
  18. package/build/cjs/lib/nvm3/files/ProtocolNodeMaskFiles.js.map +2 -2
  19. package/build/cjs/lib/nvm3/files/RouteCacheFiles.js +143 -82
  20. package/build/cjs/lib/nvm3/files/RouteCacheFiles.js.map +2 -2
  21. package/build/cjs/lib/nvm3/files/SUCUpdateEntriesFile.js +134 -73
  22. package/build/cjs/lib/nvm3/files/SUCUpdateEntriesFile.js.map +2 -2
  23. package/build/cjs/lib/nvm3/files/VersionFiles.js +98 -23
  24. package/build/cjs/lib/nvm3/files/VersionFiles.js.map +2 -2
  25. package/build/esm/lib/nvm3/files/ApplicationCCsFile.js +106 -66
  26. package/build/esm/lib/nvm3/files/ApplicationCCsFile.js.map +1 -1
  27. package/build/esm/lib/nvm3/files/ApplicationDataFile.js +63 -23
  28. package/build/esm/lib/nvm3/files/ApplicationDataFile.js.map +1 -1
  29. package/build/esm/lib/nvm3/files/ApplicationNameFile.js +66 -26
  30. package/build/esm/lib/nvm3/files/ApplicationNameFile.js.map +1 -1
  31. package/build/esm/lib/nvm3/files/ApplicationRFConfigFile.js +137 -97
  32. package/build/esm/lib/nvm3/files/ApplicationRFConfigFile.js.map +1 -1
  33. package/build/esm/lib/nvm3/files/ApplicationTypeFile.js +87 -47
  34. package/build/esm/lib/nvm3/files/ApplicationTypeFile.js.map +1 -1
  35. package/build/esm/lib/nvm3/files/ControllerInfoFile.js +172 -132
  36. package/build/esm/lib/nvm3/files/ControllerInfoFile.js.map +1 -1
  37. package/build/esm/lib/nvm3/files/NVMFile.d.ts +3 -3
  38. package/build/esm/lib/nvm3/files/NVMFile.d.ts.map +1 -1
  39. package/build/esm/lib/nvm3/files/NodeInfoFiles.js +191 -127
  40. package/build/esm/lib/nvm3/files/NodeInfoFiles.js.map +1 -1
  41. package/build/esm/lib/nvm3/files/ProtocolNodeMaskFiles.js +221 -85
  42. package/build/esm/lib/nvm3/files/ProtocolNodeMaskFiles.js.map +1 -1
  43. package/build/esm/lib/nvm3/files/RouteCacheFiles.js +143 -91
  44. package/build/esm/lib/nvm3/files/RouteCacheFiles.js.map +1 -1
  45. package/build/esm/lib/nvm3/files/SUCUpdateEntriesFile.js +126 -74
  46. package/build/esm/lib/nvm3/files/SUCUpdateEntriesFile.js.map +1 -1
  47. package/build/esm/lib/nvm3/files/VersionFiles.js +87 -23
  48. package/build/esm/lib/nvm3/files/VersionFiles.js.map +1 -1
  49. package/package.json +3 -3
@@ -25,143 +25,190 @@ module.exports = __toCommonJS(ControllerInfoFile_exports);
25
25
  var import_safe = require("@zwave-js/core/safe");
26
26
  var import_shared = require("@zwave-js/shared");
27
27
  var import_NVMFile = require("./NVMFile.js");
28
- var __decorate = function(decorators, target, key, desc) {
29
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
30
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
31
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
32
- return c > 3 && r && Object.defineProperty(target, key, r), r;
28
+ var __esDecorate = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
29
+ function accept(f) {
30
+ if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
31
+ return f;
32
+ }
33
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
34
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
35
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
36
+ var _, done = false;
37
+ for (var i = decorators.length - 1; i >= 0; i--) {
38
+ var context = {};
39
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
40
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
41
+ context.addInitializer = function(f) {
42
+ if (done) throw new TypeError("Cannot add initializers after decoration has completed");
43
+ extraInitializers.push(accept(f || null));
44
+ };
45
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
46
+ if (kind === "accessor") {
47
+ if (result === void 0) continue;
48
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
49
+ if (_ = accept(result.get)) descriptor.get = _;
50
+ if (_ = accept(result.set)) descriptor.set = _;
51
+ if (_ = accept(result.init)) initializers.unshift(_);
52
+ } else if (_ = accept(result)) {
53
+ if (kind === "field") initializers.unshift(_);
54
+ else descriptor[key] = _;
55
+ }
56
+ }
57
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
58
+ done = true;
59
+ };
60
+ var __runInitializers = function(thisArg, initializers, value) {
61
+ var useValue = arguments.length > 2;
62
+ for (var i = 0; i < initializers.length; i++) {
63
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
64
+ }
65
+ return useValue ? value : void 0;
33
66
  };
34
67
  const ControllerInfoFileID = 327684;
35
- let ControllerInfoFile = class ControllerInfoFile2 extends import_NVMFile.NVMFile {
36
- constructor(options) {
37
- super(options);
38
- if ((0, import_NVMFile.gotDeserializationOptions)(options)) {
39
- this.homeId = this.payload.subarray(0, 4);
40
- if (this.payload.length === 13) {
41
- this.nodeId = this.payload[4];
42
- this.lastNodeId = this.payload[5];
43
- this.staticControllerNodeId = this.payload[6];
44
- this.sucLastIndex = this.payload[7];
45
- this.controllerConfiguration = this.payload[8];
46
- this.sucAwarenessPushNeeded = this.payload[9];
47
- this.maxNodeId = this.payload[10];
48
- this.reservedId = this.payload[11];
49
- this.systemState = this.payload[12];
50
- } else if (this.payload.length === 22) {
51
- this.nodeId = this.payload.readUInt16LE(4);
52
- this.staticControllerNodeId = this.payload.readUInt16LE(6);
53
- this.lastNodeIdLR = this.payload.readUInt16LE(8);
54
- this.lastNodeId = this.payload[10];
55
- this.sucLastIndex = this.payload[11];
56
- this.maxNodeIdLR = this.payload.readUInt16LE(12);
57
- this.maxNodeId = this.payload[14];
58
- this.controllerConfiguration = this.payload[15];
59
- this.reservedIdLR = this.payload.readUInt16LE(16);
60
- this.reservedId = this.payload[18];
61
- this.systemState = this.payload[19];
62
- this.primaryLongRangeChannelId = this.payload[20];
63
- this.dcdcConfig = this.payload[21];
68
+ let ControllerInfoFile = (() => {
69
+ let _classDecorators = [(0, import_NVMFile.nvmFileID)(ControllerInfoFileID), (0, import_NVMFile.nvmSection)("protocol")];
70
+ let _classDescriptor;
71
+ let _classExtraInitializers = [];
72
+ let _classThis;
73
+ let _classSuper = import_NVMFile.NVMFile;
74
+ var ControllerInfoFile2 = class extends _classSuper {
75
+ static {
76
+ _classThis = this;
77
+ }
78
+ static {
79
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
80
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
81
+ ControllerInfoFile2 = _classThis = _classDescriptor.value;
82
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
83
+ __runInitializers(_classThis, _classExtraInitializers);
84
+ }
85
+ constructor(options) {
86
+ super(options);
87
+ if ((0, import_NVMFile.gotDeserializationOptions)(options)) {
88
+ this.homeId = this.payload.subarray(0, 4);
89
+ if (this.payload.length === 13) {
90
+ this.nodeId = this.payload[4];
91
+ this.lastNodeId = this.payload[5];
92
+ this.staticControllerNodeId = this.payload[6];
93
+ this.sucLastIndex = this.payload[7];
94
+ this.controllerConfiguration = this.payload[8];
95
+ this.sucAwarenessPushNeeded = this.payload[9];
96
+ this.maxNodeId = this.payload[10];
97
+ this.reservedId = this.payload[11];
98
+ this.systemState = this.payload[12];
99
+ } else if (this.payload.length === 22) {
100
+ this.nodeId = this.payload.readUInt16LE(4);
101
+ this.staticControllerNodeId = this.payload.readUInt16LE(6);
102
+ this.lastNodeIdLR = this.payload.readUInt16LE(8);
103
+ this.lastNodeId = this.payload[10];
104
+ this.sucLastIndex = this.payload[11];
105
+ this.maxNodeIdLR = this.payload.readUInt16LE(12);
106
+ this.maxNodeId = this.payload[14];
107
+ this.controllerConfiguration = this.payload[15];
108
+ this.reservedIdLR = this.payload.readUInt16LE(16);
109
+ this.reservedId = this.payload[18];
110
+ this.systemState = this.payload[19];
111
+ this.primaryLongRangeChannelId = this.payload[20];
112
+ this.dcdcConfig = this.payload[21];
113
+ } else {
114
+ throw new import_safe.ZWaveError(`Unsupported payload length`, import_safe.ZWaveErrorCodes.NVM_InvalidFormat);
115
+ }
64
116
  } else {
65
- throw new import_safe.ZWaveError(`Unsupported payload length`, import_safe.ZWaveErrorCodes.NVM_InvalidFormat);
117
+ this.homeId = import_shared.Bytes.view(options.homeId);
118
+ this.nodeId = options.nodeId;
119
+ this.lastNodeId = options.lastNodeId;
120
+ this.staticControllerNodeId = options.staticControllerNodeId;
121
+ this.sucLastIndex = options.sucLastIndex;
122
+ this.controllerConfiguration = options.controllerConfiguration;
123
+ this.maxNodeId = options.maxNodeId;
124
+ this.reservedId = options.reservedId;
125
+ this.systemState = options.systemState;
126
+ if ("lastNodeIdLR" in options) {
127
+ this.lastNodeIdLR = options.lastNodeIdLR;
128
+ this.maxNodeIdLR = options.maxNodeIdLR;
129
+ this.reservedIdLR = options.reservedIdLR;
130
+ this.primaryLongRangeChannelId = options.primaryLongRangeChannelId;
131
+ this.dcdcConfig = options.dcdcConfig;
132
+ } else {
133
+ this.sucAwarenessPushNeeded = options.sucAwarenessPushNeeded;
134
+ }
66
135
  }
67
- } else {
68
- this.homeId = import_shared.Bytes.view(options.homeId);
69
- this.nodeId = options.nodeId;
70
- this.lastNodeId = options.lastNodeId;
71
- this.staticControllerNodeId = options.staticControllerNodeId;
72
- this.sucLastIndex = options.sucLastIndex;
73
- this.controllerConfiguration = options.controllerConfiguration;
74
- this.maxNodeId = options.maxNodeId;
75
- this.reservedId = options.reservedId;
76
- this.systemState = options.systemState;
77
- if ("lastNodeIdLR" in options) {
78
- this.lastNodeIdLR = options.lastNodeIdLR;
79
- this.maxNodeIdLR = options.maxNodeIdLR;
80
- this.reservedIdLR = options.reservedIdLR;
81
- this.primaryLongRangeChannelId = options.primaryLongRangeChannelId;
82
- this.dcdcConfig = options.dcdcConfig;
136
+ }
137
+ homeId;
138
+ nodeId;
139
+ lastNodeId;
140
+ staticControllerNodeId;
141
+ sucLastIndex;
142
+ controllerConfiguration;
143
+ // TODO: Figure out what this is
144
+ sucAwarenessPushNeeded;
145
+ maxNodeId;
146
+ reservedId;
147
+ systemState;
148
+ lastNodeIdLR;
149
+ maxNodeIdLR;
150
+ reservedIdLR;
151
+ primaryLongRangeChannelId;
152
+ dcdcConfig;
153
+ serialize() {
154
+ if (this.lastNodeIdLR != void 0) {
155
+ this.payload = new import_shared.Bytes(22);
156
+ this.payload.set(this.homeId, 0);
157
+ this.payload.writeUInt16LE(this.nodeId, 4);
158
+ this.payload.writeUInt16LE(this.staticControllerNodeId, 6);
159
+ this.payload.writeUInt16LE(this.lastNodeIdLR, 8);
160
+ this.payload[10] = this.lastNodeId;
161
+ this.payload[11] = this.sucLastIndex;
162
+ this.payload.writeUInt16LE(this.maxNodeIdLR, 12);
163
+ this.payload[14] = this.maxNodeId;
164
+ this.payload[15] = this.controllerConfiguration;
165
+ this.payload.writeUInt16LE(this.reservedIdLR, 16);
166
+ this.payload[18] = this.reservedId;
167
+ this.payload[19] = this.systemState;
168
+ this.payload[20] = this.primaryLongRangeChannelId;
169
+ this.payload[21] = this.dcdcConfig;
83
170
  } else {
84
- this.sucAwarenessPushNeeded = options.sucAwarenessPushNeeded;
171
+ this.payload = import_shared.Bytes.concat([
172
+ this.homeId,
173
+ import_shared.Bytes.from([
174
+ this.nodeId,
175
+ this.lastNodeId,
176
+ this.staticControllerNodeId,
177
+ this.sucLastIndex,
178
+ this.controllerConfiguration,
179
+ this.sucAwarenessPushNeeded ?? 0,
180
+ this.maxNodeId,
181
+ this.reservedId,
182
+ this.systemState
183
+ ])
184
+ ]);
85
185
  }
186
+ return super.serialize();
86
187
  }
87
- }
88
- homeId;
89
- nodeId;
90
- lastNodeId;
91
- staticControllerNodeId;
92
- sucLastIndex;
93
- controllerConfiguration;
94
- // TODO: Figure out what this is
95
- sucAwarenessPushNeeded;
96
- maxNodeId;
97
- reservedId;
98
- systemState;
99
- lastNodeIdLR;
100
- maxNodeIdLR;
101
- reservedIdLR;
102
- primaryLongRangeChannelId;
103
- dcdcConfig;
104
- serialize() {
105
- if (this.lastNodeIdLR != void 0) {
106
- this.payload = new import_shared.Bytes(22);
107
- this.payload.set(this.homeId, 0);
108
- this.payload.writeUInt16LE(this.nodeId, 4);
109
- this.payload.writeUInt16LE(this.staticControllerNodeId, 6);
110
- this.payload.writeUInt16LE(this.lastNodeIdLR, 8);
111
- this.payload[10] = this.lastNodeId;
112
- this.payload[11] = this.sucLastIndex;
113
- this.payload.writeUInt16LE(this.maxNodeIdLR, 12);
114
- this.payload[14] = this.maxNodeId;
115
- this.payload[15] = this.controllerConfiguration;
116
- this.payload.writeUInt16LE(this.reservedIdLR, 16);
117
- this.payload[18] = this.reservedId;
118
- this.payload[19] = this.systemState;
119
- this.payload[20] = this.primaryLongRangeChannelId;
120
- this.payload[21] = this.dcdcConfig;
121
- } else {
122
- this.payload = import_shared.Bytes.concat([
123
- this.homeId,
124
- import_shared.Bytes.from([
125
- this.nodeId,
126
- this.lastNodeId,
127
- this.staticControllerNodeId,
128
- this.sucLastIndex,
129
- this.controllerConfiguration,
130
- this.sucAwarenessPushNeeded ?? 0,
131
- this.maxNodeId,
132
- this.reservedId,
133
- this.systemState
134
- ])
135
- ]);
188
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
189
+ toJSON() {
190
+ return (0, import_safe.stripUndefined)({
191
+ ...super.toJSON(),
192
+ homeId: (0, import_shared.buffer2hex)(this.homeId),
193
+ nodeId: this.nodeId,
194
+ lastNodeId: this.lastNodeId,
195
+ staticControllerNodeId: this.staticControllerNodeId,
196
+ sucLastIndex: this.sucLastIndex,
197
+ controllerConfiguration: this.controllerConfiguration,
198
+ sucAwarenessPushNeeded: this.sucAwarenessPushNeeded,
199
+ maxNodeId: this.maxNodeId,
200
+ reservedId: this.reservedId,
201
+ systemState: this.systemState,
202
+ lastNodeIdLR: this.lastNodeIdLR,
203
+ maxNodeIdLR: this.maxNodeIdLR,
204
+ reservedIdLR: this.reservedIdLR,
205
+ primaryLongRangeChannelId: this.primaryLongRangeChannelId,
206
+ dcdcConfig: this.dcdcConfig
207
+ });
136
208
  }
137
- return super.serialize();
138
- }
139
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
140
- toJSON() {
141
- return (0, import_safe.stripUndefined)({
142
- ...super.toJSON(),
143
- homeId: (0, import_shared.buffer2hex)(this.homeId),
144
- nodeId: this.nodeId,
145
- lastNodeId: this.lastNodeId,
146
- staticControllerNodeId: this.staticControllerNodeId,
147
- sucLastIndex: this.sucLastIndex,
148
- controllerConfiguration: this.controllerConfiguration,
149
- sucAwarenessPushNeeded: this.sucAwarenessPushNeeded,
150
- maxNodeId: this.maxNodeId,
151
- reservedId: this.reservedId,
152
- systemState: this.systemState,
153
- lastNodeIdLR: this.lastNodeIdLR,
154
- maxNodeIdLR: this.maxNodeIdLR,
155
- reservedIdLR: this.reservedIdLR,
156
- primaryLongRangeChannelId: this.primaryLongRangeChannelId,
157
- dcdcConfig: this.dcdcConfig
158
- });
159
- }
160
- };
161
- ControllerInfoFile = __decorate([
162
- (0, import_NVMFile.nvmFileID)(ControllerInfoFileID),
163
- (0, import_NVMFile.nvmSection)("protocol")
164
- ], ControllerInfoFile);
209
+ };
210
+ return ControllerInfoFile2 = _classThis;
211
+ })();
165
212
  // Annotate the CommonJS export names for ESM import in node:
166
213
  0 && (module.exports = {
167
214
  ControllerInfoFile,
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/nvm3/files/ControllerInfoFile.ts"],
4
4
  "sourcesContent": ["import {\n\tZWaveError,\n\tZWaveErrorCodes,\n\tstripUndefined,\n} from \"@zwave-js/core/safe\";\nimport { Bytes, buffer2hex } from \"@zwave-js/shared\";\nimport type { NVM3Object } from \"../object.js\";\nimport {\n\tNVMFile,\n\ttype NVMFileCreationOptions,\n\ttype NVMFileDeserializationOptions,\n\tgotDeserializationOptions,\n\tnvmFileID,\n\tnvmSection,\n} from \"./NVMFile.js\";\n\nexport type ControllerInfoFileOptions =\n\t& NVMFileCreationOptions\n\t& {\n\t\thomeId: Uint8Array;\n\t\tnodeId: number;\n\t\tlastNodeId: number;\n\t\tstaticControllerNodeId: number;\n\t\tsucLastIndex: number;\n\t\tcontrollerConfiguration: number;\n\t\tmaxNodeId: number;\n\t\treservedId: number;\n\t\tsystemState: number;\n\t}\n\t& (\n\t\t| {\n\t\t\tsucAwarenessPushNeeded: number;\n\t\t}\n\t\t| {\n\t\t\tlastNodeIdLR: number;\n\t\t\tmaxNodeIdLR: number;\n\t\t\treservedIdLR: number;\n\t\t\tprimaryLongRangeChannelId: number;\n\t\t\tdcdcConfig: number;\n\t\t}\n\t);\n\nexport const ControllerInfoFileID = 0x50004;\n\n@nvmFileID(ControllerInfoFileID)\n@nvmSection(\"protocol\")\nexport class ControllerInfoFile extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | ControllerInfoFileOptions,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.homeId = this.payload.subarray(0, 4);\n\t\t\tif (this.payload.length === 13) {\n\t\t\t\tthis.nodeId = this.payload[4];\n\t\t\t\tthis.lastNodeId = this.payload[5];\n\t\t\t\tthis.staticControllerNodeId = this.payload[6];\n\t\t\t\tthis.sucLastIndex = this.payload[7];\n\t\t\t\tthis.controllerConfiguration = this.payload[8];\n\t\t\t\tthis.sucAwarenessPushNeeded = this.payload[9];\n\t\t\t\tthis.maxNodeId = this.payload[10];\n\t\t\t\tthis.reservedId = this.payload[11];\n\t\t\t\tthis.systemState = this.payload[12];\n\t\t\t} else if (this.payload.length === 22) {\n\t\t\t\tthis.nodeId = this.payload.readUInt16LE(4);\n\t\t\t\tthis.staticControllerNodeId = this.payload.readUInt16LE(6);\n\t\t\t\tthis.lastNodeIdLR = this.payload.readUInt16LE(8);\n\t\t\t\tthis.lastNodeId = this.payload[10];\n\t\t\t\tthis.sucLastIndex = this.payload[11];\n\t\t\t\tthis.maxNodeIdLR = this.payload.readUInt16LE(12);\n\t\t\t\tthis.maxNodeId = this.payload[14];\n\t\t\t\tthis.controllerConfiguration = this.payload[15];\n\t\t\t\tthis.reservedIdLR = this.payload.readUInt16LE(16);\n\t\t\t\tthis.reservedId = this.payload[18];\n\t\t\t\tthis.systemState = this.payload[19];\n\t\t\t\tthis.primaryLongRangeChannelId = this.payload[20];\n\t\t\t\tthis.dcdcConfig = this.payload[21];\n\t\t\t} else {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`Unsupported payload length`,\n\t\t\t\t\tZWaveErrorCodes.NVM_InvalidFormat,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.homeId = Bytes.view(options.homeId);\n\t\t\tthis.nodeId = options.nodeId;\n\t\t\tthis.lastNodeId = options.lastNodeId;\n\t\t\tthis.staticControllerNodeId = options.staticControllerNodeId;\n\t\t\tthis.sucLastIndex = options.sucLastIndex;\n\t\t\tthis.controllerConfiguration = options.controllerConfiguration;\n\t\t\tthis.maxNodeId = options.maxNodeId;\n\t\t\tthis.reservedId = options.reservedId;\n\t\t\tthis.systemState = options.systemState;\n\t\t\tif (\"lastNodeIdLR\" in options) {\n\t\t\t\tthis.lastNodeIdLR = options.lastNodeIdLR;\n\t\t\t\tthis.maxNodeIdLR = options.maxNodeIdLR;\n\t\t\t\tthis.reservedIdLR = options.reservedIdLR;\n\t\t\t\tthis.primaryLongRangeChannelId =\n\t\t\t\t\toptions.primaryLongRangeChannelId;\n\t\t\t\tthis.dcdcConfig = options.dcdcConfig;\n\t\t\t} else {\n\t\t\t\tthis.sucAwarenessPushNeeded = options.sucAwarenessPushNeeded;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic homeId: Uint8Array;\n\tpublic nodeId: number;\n\tpublic lastNodeId: number;\n\tpublic staticControllerNodeId: number;\n\tpublic sucLastIndex: number;\n\tpublic controllerConfiguration: number; // TODO: Figure out what this is\n\tpublic sucAwarenessPushNeeded?: number;\n\tpublic maxNodeId: number;\n\tpublic reservedId: number;\n\tpublic systemState: number;\n\tpublic lastNodeIdLR?: number;\n\tpublic maxNodeIdLR?: number;\n\tpublic reservedIdLR?: number;\n\tpublic primaryLongRangeChannelId?: number;\n\tpublic dcdcConfig?: number;\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tif (this.lastNodeIdLR != undefined) {\n\t\t\tthis.payload = new Bytes(22);\n\t\t\tthis.payload.set(this.homeId, 0);\n\t\t\tthis.payload.writeUInt16LE(this.nodeId, 4);\n\t\t\tthis.payload.writeUInt16LE(this.staticControllerNodeId, 6);\n\t\t\tthis.payload.writeUInt16LE(this.lastNodeIdLR, 8);\n\t\t\tthis.payload[10] = this.lastNodeId;\n\t\t\tthis.payload[11] = this.sucLastIndex;\n\t\t\tthis.payload.writeUInt16LE(this.maxNodeIdLR!, 12);\n\t\t\tthis.payload[14] = this.maxNodeId;\n\t\t\tthis.payload[15] = this.controllerConfiguration;\n\t\t\tthis.payload.writeUInt16LE(this.reservedIdLR!, 16);\n\t\t\tthis.payload[18] = this.reservedId;\n\t\t\tthis.payload[19] = this.systemState;\n\t\t\tthis.payload[20] = this.primaryLongRangeChannelId!;\n\t\t\tthis.payload[21] = this.dcdcConfig!;\n\t\t} else {\n\t\t\t// V0\n\t\t\tthis.payload = Bytes.concat([\n\t\t\t\tthis.homeId,\n\t\t\t\tBytes.from([\n\t\t\t\t\tthis.nodeId,\n\t\t\t\t\tthis.lastNodeId,\n\t\t\t\t\tthis.staticControllerNodeId,\n\t\t\t\t\tthis.sucLastIndex,\n\t\t\t\t\tthis.controllerConfiguration,\n\t\t\t\t\tthis.sucAwarenessPushNeeded ?? 0,\n\t\t\t\t\tthis.maxNodeId,\n\t\t\t\t\tthis.reservedId,\n\t\t\t\t\tthis.systemState,\n\t\t\t\t]),\n\t\t\t]);\n\t\t}\n\t\treturn super.serialize();\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic toJSON() {\n\t\treturn stripUndefined({\n\t\t\t...super.toJSON(),\n\t\t\thomeId: buffer2hex(this.homeId),\n\t\t\tnodeId: this.nodeId,\n\t\t\tlastNodeId: this.lastNodeId,\n\t\t\tstaticControllerNodeId: this.staticControllerNodeId,\n\t\t\tsucLastIndex: this.sucLastIndex,\n\t\t\tcontrollerConfiguration: this.controllerConfiguration,\n\t\t\tsucAwarenessPushNeeded: this.sucAwarenessPushNeeded,\n\t\t\tmaxNodeId: this.maxNodeId,\n\t\t\treservedId: this.reservedId,\n\t\t\tsystemState: this.systemState,\n\t\t\tlastNodeIdLR: this.lastNodeIdLR,\n\t\t\tmaxNodeIdLR: this.maxNodeIdLR,\n\t\t\treservedIdLR: this.reservedIdLR,\n\t\t\tprimaryLongRangeChannelId: this.primaryLongRangeChannelId,\n\t\t\tdcdcConfig: this.dcdcConfig,\n\t\t});\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAIO;AACP,oBAAkC;AAElC,qBAOO;;;;;;;AA4BA,MAAM,uBAAuB;AAI7B,IAAM,qBAAN,MAAMA,4BAA2B,uBAAO;EAC9C,YACC,SAAkE;AAElE,UAAM,OAAO;AACb,YAAI,0CAA0B,OAAO,GAAG;AACvC,WAAK,SAAS,KAAK,QAAQ,SAAS,GAAG,CAAC;AACxC,UAAI,KAAK,QAAQ,WAAW,IAAI;AAC/B,aAAK,SAAS,KAAK,QAAQ,CAAC;AAC5B,aAAK,aAAa,KAAK,QAAQ,CAAC;AAChC,aAAK,yBAAyB,KAAK,QAAQ,CAAC;AAC5C,aAAK,eAAe,KAAK,QAAQ,CAAC;AAClC,aAAK,0BAA0B,KAAK,QAAQ,CAAC;AAC7C,aAAK,yBAAyB,KAAK,QAAQ,CAAC;AAC5C,aAAK,YAAY,KAAK,QAAQ,EAAE;AAChC,aAAK,aAAa,KAAK,QAAQ,EAAE;AACjC,aAAK,cAAc,KAAK,QAAQ,EAAE;MACnC,WAAW,KAAK,QAAQ,WAAW,IAAI;AACtC,aAAK,SAAS,KAAK,QAAQ,aAAa,CAAC;AACzC,aAAK,yB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,IAAI,KAAK;AACxB,aAAK,QAAQ,EAAE,IAAI,KAAK;AACxB,aAAK,QAAQ,cAAc,KAAK,cAAe,EAAE;AACjD,aAAK,QAAQ,EAAE,IAAI,KAAK;AACxB,aAAK,QAAQ,EAAE,IAAI,KAAK;AACxB,aAAK,QAAQ,EAAE,IAAI,KAAK;AACxB,aAAK,QAAQ,EAAE,IAAI,KAAK;MACzB,OAAO;AAEN,aAAK,UAAU,oBAAM,OAAO;UAC3B,KAAK;UACL,oBAAM,KAAK;YACV,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK,0BAA0B;YAC/B,KAAK;YACL,KAAK;YACL,KAAK;WACL;SACD;MACF;AACA,aAAO,MAAM,UAAS;IACvB;;IAGO,SAAM;AACZ,iBAAO,4BAAe;QACrB,GAAG,MAAM,OAAM;QACf,YAAQ,0BAAW,KAAK,MAAM;QAC9B,QAAQ,KAAK;QACb,YAAY,KAAK;QACjB,wBAAwB,KAAK;QAC7B,cAAc,KAAK;QACnB,yBAAyB,KAAK;QAC9B,wBAAwB,KAAK;QAC7B,WAAW,KAAK;QAChB,YAAY,KAAK;QACjB,aAAa,KAAK;QAClB,cAAc,KAAK;QACnB,aAAa,KAAK;QAClB,cAAc,KAAK;QACnB,2BAA2B,KAAK;QAChC,YAAY,KAAK;OACjB;IACF;;;;",
6
+ "names": []
7
7
  }
@@ -35,7 +35,7 @@ export type NVMFileConstructor<T extends NVMFile> = typeof NVMFile & {
35
35
  /**
36
36
  * Defines the ID associated with a NVM file class
37
37
  */
38
- export declare function nvmFileID(id: number | ((id: number) => boolean)): TypedClassDecorator<NVMFile>;
38
+ export declare function nvmFileID<Class extends typeof NVMFile>(id: number | ((id: number) => boolean)): TypedClassDecorator<Class>;
39
39
  /**
40
40
  * Retrieves the file ID defined for a NVM file class
41
41
  */
@@ -50,11 +50,11 @@ export declare function getNVMFileConstructor(id: number): NVMFileConstructor<NV
50
50
  export declare function getNVMFileIDStatic<T extends NVMFileConstructor<NVMFile>>(classConstructor: T): number | ((id: number) => boolean);
51
51
  export type NVMSection = "application" | "protocol";
52
52
  /** Defines in which section an NVM file is stored */
53
- export declare const nvmSection: <TTarget extends NVMFile>(section: NVMSection) => TypedClassDecorator<TTarget>;
53
+ export declare const nvmSection: <TTarget extends typeof NVMFile>(section: NVMSection) => TypedClassDecorator<TTarget>;
54
54
  /** Returns in which section an NVM file is stored (using an instance of the file) */
55
55
  export declare const getNVMSection: (target: NVMFile) => NVMSection | undefined;
56
56
  /** Returns in which section an NVM file is stored (using the constructor of the file) */
57
- export declare const getNVMSectionStatic: (constr: Function) => NVMSection | undefined;
57
+ export declare const getNVMSectionStatic: (constr: typeof NVMFile) => NVMSection | undefined;
58
58
  /** Returns in which NVM section the file with the given ID resides in */
59
59
  export declare function getNVMSectionByFileID(fileId: number): NVMSection;
60
60
  //# sourceMappingURL=NVMFile.d.ts.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/nvm3/files/NVMFile.ts"],
4
- "sourcesContent": ["import { createSimpleReflectionDecorator } from \"@zwave-js/core\";\nimport { ZWaveError, ZWaveErrorCodes } from \"@zwave-js/core/safe\";\nimport {\n\tBytes,\n\ttype TypedClassDecorator,\n\tisUint8Array,\n\tnum2hex,\n} from \"@zwave-js/shared\";\nimport {\n\tFragmentType,\n\tNVM3_MAX_OBJ_SIZE_SMALL,\n\tObjectType,\n} from \"../consts.js\";\nimport type { NVM3Object } from \"../object.js\";\n\nexport interface NVMFileBaseOptions {\n\tfileId?: number;\n\tfileVersion: string;\n}\nexport interface NVMFileDeserializationOptions extends NVMFileBaseOptions {\n\tfileId: number;\n\tdata: Bytes;\n}\n\nexport function gotDeserializationOptions(\n\toptions: NVMFileOptions,\n): options is NVMFileDeserializationOptions {\n\treturn \"data\" in options && isUint8Array(options.data);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface NVMFileCreationOptions extends NVMFileBaseOptions {}\n\nexport type NVMFileOptions =\n\t| NVMFileCreationOptions\n\t| NVMFileDeserializationOptions;\n\nexport class NVMFile {\n\tpublic constructor(options: NVMFileOptions) {\n\t\tthis.fileVersion = options.fileVersion;\n\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.fileId = options.fileId;\n\t\t\tthis.payload = options.data;\n\t\t} else {\n\t\t\tconst fileId = options.fileId ?? getNVMFileID(this);\n\t\t\tif (typeof fileId === \"number\") {\n\t\t\t\tthis.fileId = fileId;\n\t\t\t}\n\t\t\tthis.payload = new Bytes();\n\t\t}\n\t}\n\n\tprotected payload: Bytes;\n\tpublic fileId: number = 0;\n\tpublic fileVersion: string;\n\n\t/**\n\t * Creates an instance of the NVM file that is contained in the given NVM object\n\t */\n\tpublic static from(\n\t\tfileId: number,\n\t\tdata: Uint8Array,\n\t\tfileVersion: string,\n\t): NVMFile {\n\t\tconst Constructor = getNVMFileConstructor(fileId)!;\n\t\treturn new Constructor({\n\t\t\tfileId,\n\t\t\tfileVersion,\n\t\t\tdata,\n\t\t});\n\t}\n\n\t/**\n\t * Serializes this NVMFile into an NVM Object\n\t */\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tif (!this.fileId) {\n\t\t\tthrow new Error(\"The NVM file ID must be set before serializing\");\n\t\t}\n\t\treturn {\n\t\t\tkey: this.fileId,\n\t\t\tdata: this.payload,\n\t\t\t// We only support large and small data objects for now\n\t\t\ttype: this.payload.length <= NVM3_MAX_OBJ_SIZE_SMALL\n\t\t\t\t? ObjectType.DataSmall\n\t\t\t\t: ObjectType.DataLarge,\n\t\t\t// By default output unfragmented objects, they will be split later\n\t\t\tfragmentType: FragmentType.None,\n\t\t};\n\t}\n\n\tpublic toJSON(): Record<string, any> {\n\t\treturn {\n\t\t\t\"file ID\": `0x${\n\t\t\t\tthis.fileId.toString(16)\n\t\t\t} (${this.constructor.name})`,\n\t\t};\n\t}\n}\n\nconst METADATA_nvmFileID = Symbol(\"nvmFileID\");\nconst METADATA_nvmFileIDMap = Symbol(\"nvmFileIDMap\");\n\ntype NVMFileIDMap = Map<\n\tnumber | ((id: number) => boolean),\n\tNVMFileConstructor<NVMFile>\n>;\n\nexport type NVMFileConstructor<T extends NVMFile> = typeof NVMFile & {\n\tnew (options: any): T;\n};\n\n/**\n * Defines the ID associated with a NVM file class\n */\nexport function nvmFileID(\n\tid: number | ((id: number) => boolean),\n): TypedClassDecorator<NVMFile> {\n\treturn (messageClass) => {\n\t\tReflect.defineMetadata(METADATA_nvmFileID, id, messageClass);\n\n\t\t// also store a map in the NVMFile metadata for lookup.\n\t\tconst map: NVMFileIDMap =\n\t\t\tReflect.getMetadata(METADATA_nvmFileIDMap, NVMFile) || new Map();\n\t\tmap.set(id, messageClass as unknown as NVMFileConstructor<NVMFile>);\n\t\tReflect.defineMetadata(METADATA_nvmFileIDMap, map, NVMFile);\n\t};\n}\n\n/**\n * Retrieves the file ID defined for a NVM file class\n */\nexport function getNVMFileID<T extends NVMFile>(\n\tid: T,\n): number | ((id: number) => boolean) {\n\t// get the class constructor\n\tconst constr = id.constructor;\n\t// retrieve the current metadata\n\tconst ret: number | undefined = id instanceof NVMFile\n\t\t? Reflect.getMetadata(METADATA_nvmFileID, constr)\n\t\t: undefined;\n\tif (ret == undefined) {\n\t\tthrow new ZWaveError(\n\t\t\t`No NVM file ID defined for ${constr.name}!`,\n\t\t\tZWaveErrorCodes.CC_Invalid,\n\t\t);\n\t}\n\treturn ret;\n}\n\n/**\n * Looks up the NVM file constructor for a given file ID\n */\nexport function getNVMFileConstructor(\n\tid: number,\n): NVMFileConstructor<NVMFile> | undefined {\n\t// Retrieve the constructor map from the NVMFile class\n\tconst map = Reflect.getMetadata(METADATA_nvmFileIDMap, NVMFile) as\n\t\t| NVMFileIDMap\n\t\t| undefined;\n\tif (map != undefined) {\n\t\tif (map.has(id)) return map.get(id);\n\t\t// Otherwise loop through predicates\n\t\tfor (const [key, value] of map.entries()) {\n\t\t\tif (typeof key === \"function\" && key(id)) return value;\n\t\t}\n\t}\n}\n\n/**\n * Retrieves the file ID defined for a NVM file class\n */\nexport function getNVMFileIDStatic<T extends NVMFileConstructor<NVMFile>>(\n\tclassConstructor: T,\n): number | ((id: number) => boolean) {\n\t// retrieve the current metadata\n\tconst ret = Reflect.getMetadata(METADATA_nvmFileID, classConstructor);\n\tif (ret == undefined) {\n\t\tthrow new ZWaveError(\n\t\t\t`No NVM file ID defined for ${classConstructor.name}!`,\n\t\t\tZWaveErrorCodes.CC_Invalid,\n\t\t);\n\t}\n\treturn ret;\n}\n\nexport type NVMSection = \"application\" | \"protocol\";\n\nconst nvmSectionDecorator = createSimpleReflectionDecorator<\n\tNVMFile,\n\t[section: NVMSection]\n>({\n\tname: \"nvmSection\",\n});\n\n/** Defines in which section an NVM file is stored */\nexport const nvmSection = nvmSectionDecorator.decorator;\n\n/** Returns in which section an NVM file is stored (using an instance of the file) */\nexport const getNVMSection = nvmSectionDecorator.lookupValue;\n\n/** Returns in which section an NVM file is stored (using the constructor of the file) */\nexport const getNVMSectionStatic = nvmSectionDecorator.lookupValueStatic;\n\n/** Returns in which NVM section the file with the given ID resides in */\nexport function getNVMSectionByFileID(fileId: number): NVMSection {\n\tconst File = getNVMFileConstructor(fileId);\n\tlet ret: NVMSection | undefined;\n\tif (File) {\n\t\tret = getNVMSectionStatic(File);\n\t}\n\tif (ret) return ret;\n\n\tthrow new ZWaveError(\n\t\t`NVM section for file with ID ${\n\t\t\tnum2hex(fileId)\n\t\t} could not be determined`,\n\t\tZWaveErrorCodes.Argument_Invalid,\n\t);\n}\n"],
4
+ "sourcesContent": ["import { createSimpleReflectionDecorator } from \"@zwave-js/core\";\nimport { ZWaveError, ZWaveErrorCodes } from \"@zwave-js/core/safe\";\nimport {\n\tBytes,\n\ttype TypedClassDecorator,\n\tisUint8Array,\n\tnum2hex,\n} from \"@zwave-js/shared\";\nimport {\n\tFragmentType,\n\tNVM3_MAX_OBJ_SIZE_SMALL,\n\tObjectType,\n} from \"../consts.js\";\nimport type { NVM3Object } from \"../object.js\";\n\nexport interface NVMFileBaseOptions {\n\tfileId?: number;\n\tfileVersion: string;\n}\nexport interface NVMFileDeserializationOptions extends NVMFileBaseOptions {\n\tfileId: number;\n\tdata: Bytes;\n}\n\nexport function gotDeserializationOptions(\n\toptions: NVMFileOptions,\n): options is NVMFileDeserializationOptions {\n\treturn \"data\" in options && isUint8Array(options.data);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface NVMFileCreationOptions extends NVMFileBaseOptions {}\n\nexport type NVMFileOptions =\n\t| NVMFileCreationOptions\n\t| NVMFileDeserializationOptions;\n\nexport class NVMFile {\n\tpublic constructor(options: NVMFileOptions) {\n\t\tthis.fileVersion = options.fileVersion;\n\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.fileId = options.fileId;\n\t\t\tthis.payload = options.data;\n\t\t} else {\n\t\t\tconst fileId = options.fileId ?? getNVMFileID(this);\n\t\t\tif (typeof fileId === \"number\") {\n\t\t\t\tthis.fileId = fileId;\n\t\t\t}\n\t\t\tthis.payload = new Bytes();\n\t\t}\n\t}\n\n\tprotected payload: Bytes;\n\tpublic fileId: number = 0;\n\tpublic fileVersion: string;\n\n\t/**\n\t * Creates an instance of the NVM file that is contained in the given NVM object\n\t */\n\tpublic static from(\n\t\tfileId: number,\n\t\tdata: Uint8Array,\n\t\tfileVersion: string,\n\t): NVMFile {\n\t\tconst Constructor = getNVMFileConstructor(fileId)!;\n\t\treturn new Constructor({\n\t\t\tfileId,\n\t\t\tfileVersion,\n\t\t\tdata,\n\t\t});\n\t}\n\n\t/**\n\t * Serializes this NVMFile into an NVM Object\n\t */\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tif (!this.fileId) {\n\t\t\tthrow new Error(\"The NVM file ID must be set before serializing\");\n\t\t}\n\t\treturn {\n\t\t\tkey: this.fileId,\n\t\t\tdata: this.payload,\n\t\t\t// We only support large and small data objects for now\n\t\t\ttype: this.payload.length <= NVM3_MAX_OBJ_SIZE_SMALL\n\t\t\t\t? ObjectType.DataSmall\n\t\t\t\t: ObjectType.DataLarge,\n\t\t\t// By default output unfragmented objects, they will be split later\n\t\t\tfragmentType: FragmentType.None,\n\t\t};\n\t}\n\n\tpublic toJSON(): Record<string, any> {\n\t\treturn {\n\t\t\t\"file ID\": `0x${\n\t\t\t\tthis.fileId.toString(16)\n\t\t\t} (${this.constructor.name})`,\n\t\t};\n\t}\n}\n\nconst METADATA_nvmFileID = Symbol(\"nvmFileID\");\nconst METADATA_nvmFileIDMap = Symbol(\"nvmFileIDMap\");\n\ntype NVMFileIDMap = Map<\n\tnumber | ((id: number) => boolean),\n\tNVMFileConstructor<NVMFile>\n>;\n\nexport type NVMFileConstructor<T extends NVMFile> = typeof NVMFile & {\n\tnew (options: any): T;\n};\n\n/**\n * Defines the ID associated with a NVM file class\n */\nexport function nvmFileID<Class extends typeof NVMFile>(\n\tid: number | ((id: number) => boolean),\n): TypedClassDecorator<Class> {\n\treturn (messageClass) => {\n\t\tReflect.defineMetadata(METADATA_nvmFileID, id, messageClass);\n\n\t\t// also store a map in the NVMFile metadata for lookup.\n\t\tconst map: NVMFileIDMap =\n\t\t\tReflect.getMetadata(METADATA_nvmFileIDMap, NVMFile) || new Map();\n\t\tmap.set(id, messageClass as unknown as NVMFileConstructor<NVMFile>);\n\t\tReflect.defineMetadata(METADATA_nvmFileIDMap, map, NVMFile);\n\t};\n}\n\n/**\n * Retrieves the file ID defined for a NVM file class\n */\nexport function getNVMFileID<T extends NVMFile>(\n\tid: T,\n): number | ((id: number) => boolean) {\n\t// get the class constructor\n\tconst constr = id.constructor;\n\t// retrieve the current metadata\n\tconst ret: number | undefined = id instanceof NVMFile\n\t\t? Reflect.getMetadata(METADATA_nvmFileID, constr)\n\t\t: undefined;\n\tif (ret == undefined) {\n\t\tthrow new ZWaveError(\n\t\t\t`No NVM file ID defined for ${constr.name}!`,\n\t\t\tZWaveErrorCodes.CC_Invalid,\n\t\t);\n\t}\n\treturn ret;\n}\n\n/**\n * Looks up the NVM file constructor for a given file ID\n */\nexport function getNVMFileConstructor(\n\tid: number,\n): NVMFileConstructor<NVMFile> | undefined {\n\t// Retrieve the constructor map from the NVMFile class\n\tconst map = Reflect.getMetadata(METADATA_nvmFileIDMap, NVMFile) as\n\t\t| NVMFileIDMap\n\t\t| undefined;\n\tif (map != undefined) {\n\t\tif (map.has(id)) return map.get(id);\n\t\t// Otherwise loop through predicates\n\t\tfor (const [key, value] of map.entries()) {\n\t\t\tif (typeof key === \"function\" && key(id)) return value;\n\t\t}\n\t}\n}\n\n/**\n * Retrieves the file ID defined for a NVM file class\n */\nexport function getNVMFileIDStatic<T extends NVMFileConstructor<NVMFile>>(\n\tclassConstructor: T,\n): number | ((id: number) => boolean) {\n\t// retrieve the current metadata\n\tconst ret = Reflect.getMetadata(METADATA_nvmFileID, classConstructor);\n\tif (ret == undefined) {\n\t\tthrow new ZWaveError(\n\t\t\t`No NVM file ID defined for ${classConstructor.name}!`,\n\t\t\tZWaveErrorCodes.CC_Invalid,\n\t\t);\n\t}\n\treturn ret;\n}\n\nexport type NVMSection = \"application\" | \"protocol\";\n\nconst nvmSectionDecorator = createSimpleReflectionDecorator<\n\ttypeof NVMFile,\n\t[section: NVMSection]\n>({\n\tname: \"nvmSection\",\n});\n\n/** Defines in which section an NVM file is stored */\nexport const nvmSection = nvmSectionDecorator.decorator;\n\n/** Returns in which section an NVM file is stored (using an instance of the file) */\nexport const getNVMSection = nvmSectionDecorator.lookupValue;\n\n/** Returns in which section an NVM file is stored (using the constructor of the file) */\nexport const getNVMSectionStatic = nvmSectionDecorator.lookupValueStatic;\n\n/** Returns in which NVM section the file with the given ID resides in */\nexport function getNVMSectionByFileID(fileId: number): NVMSection {\n\tconst File = getNVMFileConstructor(fileId);\n\tlet ret: NVMSection | undefined;\n\tif (File) {\n\t\tret = getNVMSectionStatic(File);\n\t}\n\tif (ret) return ret;\n\n\tthrow new ZWaveError(\n\t\t`NVM section for file with ID ${\n\t\t\tnum2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