@adobe/helix-html-pipeline 6.11.0 → 6.12.1

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,19 @@
1
+ ## [6.12.1](https://github.com/adobe/helix-html-pipeline/compare/v6.12.0...v6.12.1) (2024-06-01)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency @adobe/mdast-util-gridtables to v4.0.5 ([156fde7](https://github.com/adobe/helix-html-pipeline/commit/156fde71d727e11e1dc7bd31e5f88071bedf9d4c))
7
+
8
+ # [6.12.0](https://github.com/adobe/helix-html-pipeline/compare/v6.11.0...v6.12.0) (2024-05-22)
9
+
10
+
11
+ ### Features
12
+
13
+ * add contentbusid surrogate key for pipeline responses depending on content resources ([e821162](https://github.com/adobe/helix-html-pipeline/commit/e821162b9afc649fbb53ef550d51fd61b4ccc346))
14
+ * add ref--repo--owner_code surrogate key for pipeline responses depending on codebus resources ([797aad2](https://github.com/adobe/helix-html-pipeline/commit/797aad2a1b34aa7eb95fc9ef57a65b60afed2c76))
15
+ * add ref--repo-owner_code for all code resources ([edaa518](https://github.com/adobe/helix-html-pipeline/commit/edaa518db81259d4c247c6cc8445277f41a3ccfb))
16
+
1
17
  # [6.11.0](https://github.com/adobe/helix-html-pipeline/compare/v6.10.3...v6.11.0) (2024-05-13)
2
18
 
3
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-html-pipeline",
3
- "version": "6.11.0",
3
+ "version": "6.12.1",
4
4
  "description": "Helix HTML Pipeline",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -45,7 +45,7 @@
45
45
  "dependencies": {
46
46
  "@adobe/helix-markdown-support": "7.1.2",
47
47
  "@adobe/helix-shared-utils": "3.0.2",
48
- "@adobe/mdast-util-gridtables": "4.0.4",
48
+ "@adobe/mdast-util-gridtables": "4.0.5",
49
49
  "@adobe/remark-gridtables": "3.0.4",
50
50
  "github-slugger": "2.0.0",
51
51
  "hast-util-raw": "9.0.3",
@@ -83,9 +83,9 @@
83
83
  "esmock": "2.6.5",
84
84
  "husky": "9.0.11",
85
85
  "js-yaml": "4.1.0",
86
- "jsdom": "24.0.0",
86
+ "jsdom": "24.1.0",
87
87
  "junit-report-builder": "3.2.1",
88
- "lint-staged": "15.2.2",
88
+ "lint-staged": "15.2.5",
89
89
  "mocha": "10.4.0",
90
90
  "mocha-multi-reporters": "1.5.1",
91
91
  "mocha-suppress-logs": "0.5.1",
package/src/json-pipe.js CHANGED
@@ -61,7 +61,15 @@ async function fetchJsonContent(state, req, res) {
61
61
  res.body = '';
62
62
  res.headers.delete('content-type');
63
63
  res.headers.set('location', redirectLocation);
64
- res.headers.set('x-surrogate-key', await computeSurrogateKey(`${contentBusId}${info.path}`));
64
+ const keys = [];
65
+ if (state.content.sourceBus === 'content') {
66
+ keys.push(await computeSurrogateKey(`${contentBusId}${info.path}`));
67
+ keys.push(contentBusId);
68
+ } else {
69
+ keys.push(`${ref}--${repo}--${owner}_code`);
70
+ keys.push(await computeSurrogateKey(`${ref}--${repo}--${owner}${info.path}`));
71
+ }
72
+ res.headers.set('x-surrogate-key', keys.join(' '));
65
73
  res.error = 'moved';
66
74
  return;
67
75
  }
@@ -92,8 +100,12 @@ async function computeSurrogateKeys(state) {
92
100
  if (state.info.path === '/config.json') {
93
101
  keys.push(await computeSurrogateKey(`${state.site}--${state.org}_config.json`));
94
102
  }
95
- keys.push(pathKey.replace(/\//g, '_')); // TODO: remove
96
103
  keys.push(await computeSurrogateKey(pathKey));
104
+ if (state.content?.sourceBus === 'content') {
105
+ keys.push(state.contentBusId);
106
+ } else {
107
+ keys.push(`${state.ref}--${state.repo}--${state.owner}_code`);
108
+ }
97
109
  return keys;
98
110
  }
99
111
 
@@ -120,7 +120,6 @@ async function computeSurrogateKeys(state) {
120
120
 
121
121
  const pathKey = `${state.ref}--${state.repo}--${state.owner}${state.info.path}`;
122
122
  keys.push(await computeSurrogateKey(`${state.site}--${state.org}_config.json`));
123
- keys.push(pathKey.replace(/\//g, '_')); // TODO: remove
124
123
  keys.push(await computeSurrogateKey(pathKey));
125
124
  return keys;
126
125
  }
@@ -38,5 +38,5 @@ export default async function fetch404(state, req, res) {
38
38
 
39
39
  // set 404 keys in any case
40
40
  const pathKey = await getPathKey(state);
41
- res.headers.set('x-surrogate-key', `${pathKey} ${ref}--${repo}--${owner}_404`);
41
+ res.headers.set('x-surrogate-key', `${pathKey} ${ref}--${repo}--${owner}_404 ${ref}--${repo}--${owner}_code`);
42
42
  }
@@ -41,7 +41,15 @@ export default async function fetchContent(state, req, res) {
41
41
  redirectLocation += '.plain.html';
42
42
  }
43
43
  res.headers.set('location', redirectLocation);
44
- res.headers.set('x-surrogate-key', await computeSurrogateKey(`${contentBusId}${info.path}`));
44
+ const keys = [];
45
+ if (isCode) {
46
+ keys.push(await computeSurrogateKey(`${ref}--${repo}--${owner}${info.path}`));
47
+ keys.push(`${ref}--${repo}--${owner}_code`);
48
+ } else {
49
+ keys.push(await computeSurrogateKey(`${contentBusId}${info.path}`));
50
+ keys.push(contentBusId);
51
+ }
52
+ res.headers.set('x-surrogate-key', keys.join(' '));
45
53
  res.error = 'moved';
46
54
  return;
47
55
  }
@@ -49,6 +49,7 @@ export default async function setXSurrogateKeyHeader(state, req, res) {
49
49
  hash,
50
50
  `${contentBusId}_metadata`,
51
51
  `${ref}--${repo}--${owner}_head`,
52
+ contentBusId,
52
53
  ];
53
54
 
54
55
  // for folder-mapped resources, we also need to include the surrogate key of the mapped metadata