@adobe/helix-config-storage 1.2.0 → 1.2.2
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/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/config-merge.js +31 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.2.2](https://github.com/adobe/helix-config-storage/compare/v1.2.1...v1.2.2) (2024-08-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* export required property check ([#7](https://github.com/adobe/helix-config-storage/issues/7)) ([de7b093](https://github.com/adobe/helix-config-storage/commit/de7b0933651f39c8e9068b7e190253243bc3272f))
|
|
7
|
+
|
|
8
|
+
## [1.2.1](https://github.com/adobe/helix-config-storage/compare/v1.2.0...v1.2.1) (2024-08-22)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* keep some required properties ([#6](https://github.com/adobe/helix-config-storage/issues/6)) ([4ef6d96](https://github.com/adobe/helix-config-storage/commit/4ef6d9678901bfa1be53380efe0582e4b30e03eb))
|
|
14
|
+
|
|
1
15
|
# [1.2.0](https://github.com/adobe/helix-config-storage/compare/v1.1.1...v1.2.0) (2024-08-22)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/config-merge.js
CHANGED
|
@@ -40,6 +40,35 @@ const FORCED_TYPES = {
|
|
|
40
40
|
'.cdn.prod.route': 'array',
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* properties that are required by the schema and must not be removed for empty values
|
|
45
|
+
*/
|
|
46
|
+
const REQUIRED_PROPERTIES = [
|
|
47
|
+
'.cdn.prod.host',
|
|
48
|
+
'.cdn.prod.type',
|
|
49
|
+
'.cdn.prod.endpoint',
|
|
50
|
+
'.cdn.prod.clientSecret',
|
|
51
|
+
'.cdn.prod.clientToken',
|
|
52
|
+
'.cdn.prod.accessToken',
|
|
53
|
+
'.cdn.prod.plan',
|
|
54
|
+
'.cdn.prod.zoneId',
|
|
55
|
+
'.cdn.prod.apiToken',
|
|
56
|
+
'.cdn.prod.distributionId',
|
|
57
|
+
'.cdn.prod.accessKeyId',
|
|
58
|
+
'.cdn.prod.secretAccessKey',
|
|
59
|
+
'.cdn.prod.serviceId',
|
|
60
|
+
'.cdn.prod.authToken',
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* properties that are required by the schema and must not be removed for empty values
|
|
65
|
+
* @param propertyPath
|
|
66
|
+
* @returns {boolean}
|
|
67
|
+
*/
|
|
68
|
+
export function isRequiredProperty(propertyPath) {
|
|
69
|
+
return REQUIRED_PROPERTIES.includes(propertyPath);
|
|
70
|
+
}
|
|
71
|
+
|
|
43
72
|
/**
|
|
44
73
|
* Merges the `src` object into the `dst` object.
|
|
45
74
|
* - if the dst property is a scalar, it will be overwritten by the dst property
|
|
@@ -48,13 +77,14 @@ const FORCED_TYPES = {
|
|
|
48
77
|
* - some well known paths are forced to be arrays
|
|
49
78
|
* @param {object} dst
|
|
50
79
|
* @param {object} src
|
|
80
|
+
* @param {string} path the item path
|
|
51
81
|
* @param {boolean} isModifier specifies that the objects are modifiers sheets and need special
|
|
52
82
|
* merging
|
|
53
83
|
*/
|
|
54
84
|
function merge(dst, src, path, isModifier) {
|
|
55
85
|
for (const [key, value] of Object.entries(src)) {
|
|
56
86
|
const itemPath = `${path}.${key}`;
|
|
57
|
-
if (value === '') {
|
|
87
|
+
if (value === '' && !isRequiredProperty(itemPath)) {
|
|
58
88
|
// remove key if value is empty string (keep false, 0)
|
|
59
89
|
delete dst[key];
|
|
60
90
|
} else if (typeof value !== 'object') {
|