@adobe/helix-config-storage 1.2.1 → 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 CHANGED
@@ -1,3 +1,10 @@
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
+
1
8
  ## [1.2.1](https://github.com/adobe/helix-config-storage/compare/v1.2.0...v1.2.1) (2024-08-22)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-config-storage",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Helix Config Storage",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -43,22 +43,31 @@ const FORCED_TYPES = {
43
43
  /**
44
44
  * properties that are required by the schema and must not be removed for empty values
45
45
  */
46
- const REQUIRED_PROPERTIES = {
47
- '.cdn.prod.host': true,
48
- '.cdn.prod.type': true,
49
- '.cdn.prod.endpoint': true,
50
- '.cdn.prod.clientSecret': true,
51
- '.cdn.prod.clientToken': true,
52
- '.cdn.prod.accessToken': true,
53
- '.cdn.prod.plan': true,
54
- '.cdn.prod.zoneId': true,
55
- '.cdn.prod.apiToken': true,
56
- '.cdn.prod.distributionId': true,
57
- '.cdn.prod.accessKeyId': true,
58
- '.cdn.prod.secretAccessKey': true,
59
- '.cdn.prod.serviceId': true,
60
- '.cdn.prod.authToken': true,
61
- };
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
+ }
62
71
 
63
72
  /**
64
73
  * Merges the `src` object into the `dst` object.
@@ -75,7 +84,7 @@ const REQUIRED_PROPERTIES = {
75
84
  function merge(dst, src, path, isModifier) {
76
85
  for (const [key, value] of Object.entries(src)) {
77
86
  const itemPath = `${path}.${key}`;
78
- if (value === '' && !REQUIRED_PROPERTIES[itemPath]) {
87
+ if (value === '' && !isRequiredProperty(itemPath)) {
79
88
  // remove key if value is empty string (keep false, 0)
80
89
  delete dst[key];
81
90
  } else if (typeof value !== 'object') {