@adobe/helix-config 4.5.1 → 4.5.3

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,17 @@
1
+ ## [4.5.3](https://github.com/adobe/helix-config/compare/v4.5.2...v4.5.3) (2024-09-19)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * dedupe sidekick plugins when merging site with profile ([#189](https://github.com/adobe/helix-config/issues/189)) ([69d32da](https://github.com/adobe/helix-config/commit/69d32da8c771f37b77cbc9047b45160d547e3b6d)), closes [#188](https://github.com/adobe/helix-config/issues/188)
7
+
8
+ ## [4.5.2](https://github.com/adobe/helix-config/compare/v4.5.1...v4.5.2) (2024-09-13)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * remove tst support again ([#185](https://github.com/adobe/helix-config/issues/185)) ([6043644](https://github.com/adobe/helix-config/commit/6043644c43490e71b7b5ba2d97e2bf55f0ef519d))
14
+
1
15
  ## [4.5.1](https://github.com/adobe/helix-config/compare/v4.5.0...v4.5.1) (2024-09-10)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-config",
3
- "version": "4.5.1",
3
+ "version": "4.5.3",
4
4
  "description": "Helix Config",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -41,14 +41,14 @@
41
41
  "@semantic-release/npm": "12.0.1",
42
42
  "c8": "10.1.2",
43
43
  "eslint": "8.57.0",
44
- "husky": "9.1.5",
44
+ "husky": "9.1.6",
45
45
  "junit-report-builder": "5.0.0",
46
46
  "lint-staged": "15.2.10",
47
47
  "mocha": "10.7.3",
48
48
  "mocha-multi-reporters": "1.5.1",
49
49
  "mocha-suppress-logs": "0.5.1",
50
50
  "nock": "13.5.5",
51
- "semantic-release": "24.1.0"
51
+ "semantic-release": "24.1.1"
52
52
  },
53
53
  "lint-staged": {
54
54
  "*.js": "eslint",
@@ -38,6 +38,9 @@ const ROOT_PROPERTIES = {
38
38
 
39
39
  const FORCED_TYPES = {
40
40
  '.cdn.prod.route': 'array',
41
+ '.sidekick.plugins': 'id-array',
42
+ '.headers': 'modifier',
43
+ '.metadata': 'modifier',
41
44
  };
42
45
 
43
46
  /**
@@ -48,10 +51,9 @@ const FORCED_TYPES = {
48
51
  * - some well known paths are forced to be arrays
49
52
  * @param {object} dst
50
53
  * @param {object} src
51
- * @param {boolean} isModifier specifies that the objects are modifiers sheets and need special
52
- * merging
54
+ * @param {string} [path]
53
55
  */
54
- function merge(dst, src, path, isModifier) {
56
+ function merge(dst, src, path) {
55
57
  for (const [key, value] of Object.entries(src)) {
56
58
  const itemPath = `${path}.${key}`;
57
59
  if (value === '') {
@@ -88,7 +90,7 @@ function merge(dst, src, path, isModifier) {
88
90
  if (typeof item === 'object') {
89
91
  // todo: handle arrays in arrays eventually
90
92
  // special case for modifier sheets
91
- if (isModifier && item.key) {
93
+ if (FORCED_TYPES[path] === 'modifier' && item.key) {
92
94
  const idx = dstArray.findIndex((i) => i.key === item.key);
93
95
  if (idx >= 0) {
94
96
  dstArray.splice(idx, 1);
@@ -98,9 +100,16 @@ function merge(dst, src, path, isModifier) {
98
100
  continue;
99
101
  }
100
102
  }
103
+ if (FORCED_TYPES[itemPath] === 'id-array' && item.id !== undefined) {
104
+ // special case for id arrays
105
+ const idx = dstArray.findIndex((i) => i.id === item.id);
106
+ if (idx >= 0) {
107
+ dstArray.splice(idx, 1);
108
+ }
109
+ }
101
110
  const dstObj = Object.create(null);
102
111
  dstArray.push(dstObj);
103
- merge(dstObj, item, itemPath, isModifier);
112
+ merge(dstObj, item, itemPath);
104
113
  } else if (!dstArray.includes(item)) {
105
114
  dstArray.push(item);
106
115
  }
@@ -108,26 +117,26 @@ function merge(dst, src, path, isModifier) {
108
117
  } else {
109
118
  // handle plain object
110
119
  // eslint-disable-next-line no-use-before-define
111
- mergeObject(dst, key, value, `${path}.${key}`, isModifier);
120
+ mergeObject(dst, key, value, `${path}.${key}`);
112
121
  }
113
122
  }
114
123
  }
115
124
 
116
- function mergeObject(dst, key, value, path, isModifier) {
125
+ function mergeObject(dst, key, value, path) {
117
126
  const dstObj = dst[key] ?? Object.create(null);
118
127
  if (!dst[key]) {
119
128
  dst[key] = dstObj;
120
129
  }
121
- merge(dstObj, value, path, isModifier);
130
+ merge(dstObj, value, path);
122
131
  }
123
132
 
124
133
  function mergeConfig(dst, src) {
125
- Object.entries(ROOT_PROPERTIES).forEach(([key, { atomic, isModifier }]) => {
134
+ Object.entries(ROOT_PROPERTIES).forEach(([key, { atomic }]) => {
126
135
  if (src[key]) {
127
136
  if (atomic) {
128
137
  dst[key] = src[key];
129
138
  } else {
130
- mergeObject(dst, key, src[key], `.${key}`, isModifier);
139
+ mergeObject(dst, key, src[key], `.${key}`);
131
140
  }
132
141
  }
133
142
  });
@@ -303,12 +303,6 @@ export async function loadOrgConfig(ctx, org) {
303
303
  return res.body ? res.json() : null;
304
304
  }
305
305
 
306
- export async function loadTransientSiteToken(ctx, org, site) {
307
- const key = `orgs/${org}/sites/${site}/transient-site-tokens.json`;
308
- const res = await ctx.loader.getObject(HELIX_CONFIG_BUS, key);
309
- return res.body ? res.json() : null;
310
- }
311
-
312
306
  /**
313
307
  * Computes the access.admin.role arrays for the org users.
314
308
  * @param adminConfig
@@ -446,13 +440,6 @@ export async function getConfigResponse(ctx, opts) {
446
440
  if (opts.scope === SCOPE_ADMIN || opts.scope === SCOPE_RAW) {
447
441
  // eslint-disable-next-line max-len
448
442
  config.access.admin = computeSiteAdminRoles(admin, orgConfig, config.groups);
449
- } else {
450
- // for pipeline and delivery, also load the site tokens
451
- const tst = await loadTransientSiteToken(ctx, rso.org, rso.site);
452
- if (tst) {
453
- config.access.preview.transientSiteToken = tst.tokens.preview;
454
- config.access.live.transientSiteToken = tst.tokens.live;
455
- }
456
443
  }
457
444
  }
458
445
 
@@ -479,8 +466,6 @@ export async function getConfigResponse(ctx, opts) {
479
466
  'x-hlx-auth-clientdn-live': canonicalArrayString(config.access, 'live', 'clientCertDN'),
480
467
  'x-hlx-auth-hash-preview': canonicalArrayString(config.access, 'preview', 'tokenHash'),
481
468
  'x-hlx-auth-hash-live': canonicalArrayString(config.access, 'live', 'tokenHash'),
482
- 'x-hlx-auth-tst-preview': config.access?.preview?.transientSiteToken?.value || '',
483
- 'x-hlx-auth-tst-live': config.access?.live?.transientSiteToken?.value || '',
484
469
  },
485
470
  });
486
471
  }