@adobe/helix-html-pipeline 5.10.0 → 5.11.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,20 @@
1
+ ## [5.11.1](https://github.com/adobe/helix-html-pipeline/compare/v5.11.0...v5.11.1) (2024-06-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency @adobe/mdast-util-gridtables to v4.0.5 ([#612](https://github.com/adobe/helix-html-pipeline/issues/612)) ([f3cffb1](https://github.com/adobe/helix-html-pipeline/commit/f3cffb1a2e158a0fb7824223fbf17e2c4374dda2))
7
+
8
+ # [5.11.0](https://github.com/adobe/helix-html-pipeline/compare/v5.10.0...v5.11.0) (2024-05-29)
9
+
10
+
11
+ ### Features
12
+
13
+ * add contentbusid surrogate key for pipeline responses depending on content resources ([d26d19e](https://github.com/adobe/helix-html-pipeline/commit/d26d19e5e5ceb5830e7aea007ccfe8df306642be))
14
+ * add ref--repo--owner_code surrogate key for pipeline responses depending on codebus resources ([96624fc](https://github.com/adobe/helix-html-pipeline/commit/96624fc6da8bd1bb748d76e157ef10d752e18e24))
15
+ * add ref--repo-owner_code for all code resources ([40fb5cc](https://github.com/adobe/helix-html-pipeline/commit/40fb5ccb067831dac5a84ed66e636ef9167cc64e))
16
+ * backport surrogate key changes ([a7ed342](https://github.com/adobe/helix-html-pipeline/commit/a7ed3421cf17039337c70b608c5bec72b7450502))
17
+
1
18
  # [5.10.0](https://github.com/adobe/helix-html-pipeline/compare/v5.9.10...v5.10.0) (2024-04-23)
2
19
 
3
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-html-pipeline",
3
- "version": "5.10.0",
3
+ "version": "5.11.1",
4
4
  "description": "Helix HTML Pipeline",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -16,7 +16,7 @@
16
16
  "test": "c8 mocha",
17
17
  "lint": "eslint .",
18
18
  "semantic-release": "semantic-release",
19
- "semantic-release-dry": "semantic-release --dry-run --branches main,$CI_BRANCH",
19
+ "semantic-release-dry": "semantic-release --debug --dry-run --branches main,5.x,$CI_BRANCH",
20
20
  "prepare": "husky install"
21
21
  },
22
22
  "repository": {
@@ -45,20 +45,20 @@
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
  "cookie": "0.6.0",
51
51
  "github-slugger": "2.0.0",
52
- "hast-util-raw": "9.0.2",
52
+ "hast-util-raw": "9.0.3",
53
53
  "hast-util-select": "6.0.2",
54
54
  "hast-util-to-html": "9.0.1",
55
55
  "hast-util-to-string": "3.0.0",
56
56
  "hastscript": "9.0.0",
57
- "jose": "5.2.4",
57
+ "jose": "5.3.0",
58
58
  "lodash.escape": "4.0.1",
59
59
  "mdast-util-to-hast": "13.1.0",
60
60
  "mdast-util-to-string": "4.0.0",
61
- "mime": "4.0.1",
61
+ "mime": "4.0.3",
62
62
  "rehype-format": "5.0.0",
63
63
  "rehype-parse": "9.0.0",
64
64
  "remark-parse": "11.0.0",
@@ -76,22 +76,22 @@
76
76
  "@markedjs/html-differ": "4.0.2",
77
77
  "@semantic-release/changelog": "6.0.3",
78
78
  "@semantic-release/git": "10.0.1",
79
- "@semantic-release/npm": "12.0.0",
79
+ "@semantic-release/npm": "12.0.1",
80
80
  "c8": "9.1.0",
81
81
  "eslint": "8.57.0",
82
82
  "eslint-import-resolver-exports": "1.0.0-beta.5",
83
83
  "eslint-plugin-header": "3.1.1",
84
84
  "eslint-plugin-import": "2.29.1",
85
- "esmock": "2.6.4",
85
+ "esmock": "2.6.5",
86
86
  "husky": "9.0.11",
87
87
  "js-yaml": "4.1.0",
88
- "jsdom": "24.0.0",
88
+ "jsdom": "24.1.0",
89
89
  "junit-report-builder": "3.2.1",
90
- "lint-staged": "15.2.2",
90
+ "lint-staged": "15.2.5",
91
91
  "mocha": "10.4.0",
92
92
  "mocha-multi-reporters": "1.5.1",
93
93
  "mocha-suppress-logs": "0.5.1",
94
- "semantic-release": "23.0.8"
94
+ "semantic-release": "24.0.0"
95
95
  },
96
96
  "lint-staged": {
97
97
  "*.js": "eslint",
package/src/json-pipe.js CHANGED
@@ -47,10 +47,12 @@ async function fetchJsonContent(state, req, res) {
47
47
  owner, repo, ref, contentBusId, partition, s3Loader, log, info,
48
48
  } = state;
49
49
  const { path } = state.info;
50
+ state.content.sourceBus = 'content';
50
51
  let ret = await s3Loader.getObject('helix-content-bus', `${contentBusId}/${partition}${path}`);
51
52
 
52
53
  // if not found, fall back to code bus
53
54
  if (ret.status === 404) {
55
+ state.content.sourceBus = 'code';
54
56
  ret = await s3Loader.getObject('helix-code-bus', `${owner}/${repo}/${ref}${path}`);
55
57
  }
56
58
 
@@ -61,7 +63,15 @@ async function fetchJsonContent(state, req, res) {
61
63
  res.body = '';
62
64
  res.headers.delete('content-type');
63
65
  res.headers.set('location', redirectLocation);
64
- res.headers.set('x-surrogate-key', await computeSurrogateKey(`${contentBusId}${info.path}`));
66
+ const keys = [];
67
+ if (state.content.sourceBus === 'content') {
68
+ keys.push(await computeSurrogateKey(`${contentBusId}${info.path}`));
69
+ keys.push(contentBusId);
70
+ } else {
71
+ keys.push(`${ref}--${repo}--${owner}_code`);
72
+ keys.push(await computeSurrogateKey(`${ref}--${repo}--${owner}${info.path}`));
73
+ }
74
+ res.headers.set('x-surrogate-key', keys.join(' '));
65
75
  res.error = 'moved';
66
76
  return;
67
77
  }
@@ -77,15 +87,24 @@ async function fetchJsonContent(state, req, res) {
77
87
 
78
88
  updateLastModified(state, res, extractLastModified(ret.headers));
79
89
  } else {
90
+ state.content.sourceBus = 'content';
80
91
  res.status = ret.status === 404 ? 404 : 502;
81
92
  res.error = `failed to load ${state.info.resourcePath}: ${ret.status}`;
82
93
  }
83
94
  }
84
95
 
85
- async function computeSurrogateKeys(path, contentBusId) {
96
+ async function computeSurrogateKeys(state) {
86
97
  const keys = [];
87
- keys.push(`${contentBusId}${path}`.replace(/\//g, '_')); // TODO: remove
88
- keys.push(await computeSurrogateKey(`${contentBusId}${path}`));
98
+ const pathKey = state.content?.sourceBus === 'code'
99
+ ? `${state.ref}--${state.repo}--${state.owner}${state.info.path}`
100
+ : `${state.contentBusId}${state.info.path}`;
101
+
102
+ keys.push(await computeSurrogateKey(pathKey));
103
+ if (state.content?.sourceBus === 'content') {
104
+ keys.push(state.contentBusId);
105
+ } else {
106
+ keys.push(`${state.ref}--${state.repo}--${state.owner}_code`);
107
+ }
89
108
  return keys;
90
109
  }
91
110
 
@@ -173,7 +192,7 @@ export async function jsonPipe(state, req) {
173
192
  });
174
193
 
175
194
  // set surrogate keys
176
- const keys = await computeSurrogateKeys(state.info.path, state.contentBusId);
195
+ const keys = await computeSurrogateKeys(state);
177
196
  res.headers.set('x-surrogate-key', keys.join(' '));
178
197
 
179
198
  await setCustomResponseHeaders(state, req, res);
@@ -190,7 +209,7 @@ export async function jsonPipe(state, req) {
190
209
  await setCustomResponseHeaders(state, req, res);
191
210
  }
192
211
  if (res.status === 404) {
193
- const keys = await computeSurrogateKeys(state.info.path, state.contentBusId);
212
+ const keys = await computeSurrogateKeys(state);
194
213
  res.headers.set('x-surrogate-key', keys.join(' '));
195
214
  }
196
215
  return res;
@@ -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
  }
@@ -45,7 +45,15 @@ export default async function fetchContent(state, req, res) {
45
45
  redirectLocation += '.plain.html';
46
46
  }
47
47
  res.headers.set('location', redirectLocation);
48
- res.headers.set('x-surrogate-key', await computeSurrogateKey(`${contentBusId}${info.path}`));
48
+ const keys = [];
49
+ if (isCode) {
50
+ keys.push(await computeSurrogateKey(`${ref}--${repo}--${owner}${info.path}`));
51
+ keys.push(`${ref}--${repo}--${owner}_code`);
52
+ } else {
53
+ keys.push(await computeSurrogateKey(`${contentBusId}${info.path}`));
54
+ keys.push(contentBusId);
55
+ }
56
+ res.headers.set('x-surrogate-key', keys.join(' '));
49
57
  res.error = 'moved';
50
58
  return;
51
59
  }
@@ -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