homey-lib 2.46.0 → 2.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/app/schema.d.ts +1 -0
- package/assets/app/schema.json +8 -0
- package/lib/App/index.js +17 -16
- package/lib/Util/file.js +1 -1
- package/lib/Util/index.js +1 -1
- package/package.json +1 -1
- package/types/assets/app/schema.d.ts +1 -0
- package/types/lib/App/index.d.ts.map +1 -1
- package/types/lib/Util/index.d.ts +2 -2
- package/types/lib/Util/index.d.ts.map +1 -1
- package/webpack/index.js +1 -1
package/assets/app/schema.d.ts
CHANGED
package/assets/app/schema.json
CHANGED
package/lib/App/index.js
CHANGED
|
@@ -386,32 +386,29 @@ class App {
|
|
|
386
386
|
// validate `appJson.drivers[].capabilitiesOptions`
|
|
387
387
|
if (driver.capabilitiesOptions) {
|
|
388
388
|
for (const [capabilityId, capabilityOptions] of Object.entries(driver.capabilitiesOptions)) {
|
|
389
|
-
//
|
|
390
|
-
if (Capability.isInstanceOfId(capabilityId, 'target_power_mode')) {
|
|
389
|
+
// Validate target_power_mode values - check canonical IDs present, no reserved prefixes
|
|
390
|
+
if (Capability.isInstanceOfId(capabilityId, 'target_power_mode') && Array.isArray(capabilityOptions.values)) {
|
|
391
391
|
const canonicalValues = Capability.getCapability('target_power_mode').values;
|
|
392
|
-
const providedValues = Array.isArray(capabilityOptions.values) ? capabilityOptions.values : [];
|
|
393
392
|
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
if (seenIds.has(value.id)) continue;
|
|
400
|
-
seenIds.add(value.id);
|
|
401
|
-
extraValues.push(value);
|
|
393
|
+
for (const canonical of canonicalValues) {
|
|
394
|
+
const provided = capabilityOptions.values.find(v => v && typeof v === 'object' && v.id === canonical.id);
|
|
395
|
+
if (!provided) {
|
|
396
|
+
throw new Error(`drivers.${driver.id}.capabilitiesOptions.${capabilityId}.values must include canonical value "${canonical.id}"`);
|
|
397
|
+
}
|
|
402
398
|
}
|
|
403
399
|
|
|
404
|
-
const
|
|
400
|
+
const canonicalIds = new Set(canonicalValues.map(v => v.id));
|
|
401
|
+
const extraValues = capabilityOptions.values.filter(v => v && typeof v === 'object' && typeof v.id === 'string' && !canonicalIds.has(v.id));
|
|
402
|
+
|
|
403
|
+
const RESERVED_PREFIXES = ['homey_'];
|
|
405
404
|
const reservedValues = extraValues.filter(value =>
|
|
406
405
|
RESERVED_PREFIXES.some(prefix => value.id.startsWith(prefix))
|
|
407
406
|
);
|
|
408
407
|
|
|
409
408
|
if (reservedValues.length) {
|
|
410
409
|
const ids = reservedValues.map(value => value.id).join(', ');
|
|
411
|
-
throw new Error(`drivers.${driver.id}.capabilitiesOptions.${capabilityId} custom values cannot use reserved
|
|
410
|
+
throw new Error(`drivers.${driver.id}.capabilitiesOptions.${capabilityId}.values custom values cannot use reserved prefix "homey_": ${ids}`);
|
|
412
411
|
}
|
|
413
|
-
|
|
414
|
-
capabilityOptions.values = [...canonicalValues, ...extraValues];
|
|
415
412
|
}
|
|
416
413
|
|
|
417
414
|
// validate target_power exclude range must include 0
|
|
@@ -698,7 +695,11 @@ class App {
|
|
|
698
695
|
const seenFiles = new Set();
|
|
699
696
|
|
|
700
697
|
for (const [fileIndex, file] of Object.entries(update.files)) {
|
|
701
|
-
|
|
698
|
+
if (basename(file.name) !== file.name) {
|
|
699
|
+
throw new Error(`drivers.${driver.id}.firmwareUpdates.updates[${updateIndex}].files[${fileIndex}] cannot include (sub)directories in the file name`);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
const relativeFilePath = Util.getOTAFilePath({ driverId: driver.id, fileName: file.name });
|
|
702
703
|
await this._ensureFileExistsCaseSensitive(relativeFilePath);
|
|
703
704
|
const filePath = join(this._path, relativeFilePath);
|
|
704
705
|
const isIntegrityValid = await Util.validateIntegrity(filePath, file.integrity);
|
package/lib/Util/file.js
CHANGED
|
@@ -73,7 +73,7 @@ async function getIntegrity(filePath, hashName = 'sha256') {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
function getOTAFilePath({ appPath, driverId, fileName }) {
|
|
76
|
-
return path.join(appPath, 'drivers', driverId, 'assets', 'firmware', fileName);
|
|
76
|
+
return path.join(appPath || '', 'drivers', driverId, 'assets', 'firmware', fileName);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
module.exports = {
|
package/lib/Util/index.js
CHANGED
|
@@ -73,7 +73,7 @@ class Util {
|
|
|
73
73
|
* Returns the expected file path for an OTA file based on app path, driver ID and file name.
|
|
74
74
|
* NOTE: This method is only available in Node.js environments.
|
|
75
75
|
* @param {object} options - File path options.
|
|
76
|
-
* @param {string} options.appPath - Absolute path to the app.
|
|
76
|
+
* @param {string} [options.appPath] - Absolute path to the app. If not provided, the path is relative to the app root.
|
|
77
77
|
* @param {string} options.driverId - Driver ID.
|
|
78
78
|
* @param {string} options.fileName - OTA file name.
|
|
79
79
|
* @returns {string} Resolves with the expected file path.
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/App/index.js"],"names":[],"mappings":";AA8EA;IACE,2CAAqD;IACrD,2CAAmD;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/App/index.js"],"names":[],"mappings":";AA8EA;IACE,2CAAqD;IACrD,2CAAmD;IAuyBnD;;;OAGG;IACH,sCAHW,WAAW,GACT,IAAI,CAOhB;IA4PD;;;;;OAKG;IACH,4CALW,MAAM,QACN;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,aAClB,MAAM,GACJ,IAAI,CAkChB;IAiBD;;;OAGG;IACH,wBAHW,MAAM,GACJ,OAAO,CAQnB;IAED;;;OAGG;IACH,gCAHW,MAAM,GACJ,OAAO,CAInB;IAED;;OAEG;IACH,wBAFa,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMnC;IAED;;OAEG;IACH,yBA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AAE,MAAM,CAAA;KAAE,QAChC,KAAK,GAAG,QAAQ,cAChB,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CA6BzB;IAED;;OAEG;IACH,oBAFa,OAAO,CAAC,IAAI,CAAC,CAuBzB;IAED;;;;;;OAMG;IACH,wBANW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,aACvB,MAAM,WACN,WAAW,mCACX;QAAE,YAAY,EAAE,OAAO,CAAC;QAAC,aAAa,EAAE,OAAO,CAAA;KAAE,GAC/C,IAAI,CA+EhB;IA0CD;;;;OAIG;IACH,qBAJW,MAAM,YACN,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAU3B;CAwJF;;;;mBAvyCa,OAAO,yBAAyB,EAAE,GAAG"}
|
|
@@ -54,13 +54,13 @@ declare class Util {
|
|
|
54
54
|
* Returns the expected file path for an OTA file based on app path, driver ID and file name.
|
|
55
55
|
* NOTE: This method is only available in Node.js environments.
|
|
56
56
|
* @param {object} options - File path options.
|
|
57
|
-
* @param {string} options.appPath - Absolute path to the app.
|
|
57
|
+
* @param {string} [options.appPath] - Absolute path to the app. If not provided, the path is relative to the app root.
|
|
58
58
|
* @param {string} options.driverId - Driver ID.
|
|
59
59
|
* @param {string} options.fileName - OTA file name.
|
|
60
60
|
* @returns {string} Resolves with the expected file path.
|
|
61
61
|
*/
|
|
62
62
|
static getOTAFilePath({ appPath, driverId, fileName }: {
|
|
63
|
-
appPath
|
|
63
|
+
appPath?: string;
|
|
64
64
|
driverId: string;
|
|
65
65
|
fileName: string;
|
|
66
66
|
}): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/Util/index.js"],"names":[],"mappings":";AAKA;IAEE;;;OAGG;IACH,yCAHW,MAAM,GACJ,MAAM,EAAE,CAIpB;IAED;;;;OAIG;IACH,gDAJW,MAAM,kBACN,MAAM,EAAE,GACN,MAAM,EAAE,CAKpB;IAED;;;;;;OAMG;IACH,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