@adobe/helix-html-pipeline 3.11.1 → 3.11.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
+ ## [3.11.3](https://github.com/adobe/helix-html-pipeline/compare/v3.11.2...v3.11.3) (2023-05-02)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * compute surrogate keys for unfound json ([#303](https://github.com/adobe/helix-html-pipeline/issues/303)) ([f86afde](https://github.com/adobe/helix-html-pipeline/commit/f86afde9f1bdb98ef98cdaac56e3fa297bb59a55))
7
+
8
+ ## [3.11.2](https://github.com/adobe/helix-html-pipeline/compare/v3.11.1...v3.11.2) (2023-04-29)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update external fixes ([e9a798c](https://github.com/adobe/helix-html-pipeline/commit/e9a798ccccf57a5ab73d22470cb8549f9962a1de))
14
+
1
15
  ## [3.11.1](https://github.com/adobe/helix-html-pipeline/compare/v3.11.0...v3.11.1) (2023-04-24)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-html-pipeline",
3
- "version": "3.11.1",
3
+ "version": "3.11.3",
4
4
  "description": "Helix HTML Pipeline",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -50,7 +50,7 @@
50
50
  "hast-util-to-html": "8.0.4",
51
51
  "hast-util-to-string": "2.0.0",
52
52
  "hastscript": "7.2.0",
53
- "jose": "4.14.1",
53
+ "jose": "4.14.3",
54
54
  "mdast-util-gfm-footnote": "1.0.2",
55
55
  "mdast-util-gfm-strikethrough": "1.0.3",
56
56
  "mdast-util-gfm-table": "1.0.7",
@@ -92,11 +92,11 @@
92
92
  "js-yaml": "4.1.0",
93
93
  "jsdom": "21.1.1",
94
94
  "junit-report-builder": "3.0.1",
95
- "lint-staged": "13.2.1",
95
+ "lint-staged": "13.2.2",
96
96
  "mocha": "10.2.0",
97
97
  "mocha-multi-reporters": "1.5.1",
98
98
  "remark-gfm": "3.0.1",
99
- "semantic-release": "21.0.1"
99
+ "semantic-release": "21.0.2"
100
100
  },
101
101
  "lint-staged": {
102
102
  "*.js": "eslint",
package/src/json-pipe.js CHANGED
@@ -67,6 +67,13 @@ async function fetchJsonContent(state, req, res) {
67
67
  }
68
68
  }
69
69
 
70
+ async function computeSurrogateKeys(path, contentBusId) {
71
+ const keys = [];
72
+ keys.push(`${contentBusId}${path}`.replace(/\//g, '_')); // TODO: remove
73
+ keys.push(await computeSurrogateKey(`${contentBusId}${path}`));
74
+ return keys;
75
+ }
76
+
70
77
  /**
71
78
  * Runs the default pipeline and returns the response.
72
79
  * @param {PipelineState} state
@@ -140,10 +147,7 @@ export async function jsonPipe(state, req) {
140
147
  });
141
148
 
142
149
  // set surrogate keys
143
- const keys = [];
144
- const { path } = state.info;
145
- keys.push(`${contentBusId}${path}`.replace(/\//g, '_')); // TODO: remove
146
- keys.push(await computeSurrogateKey(`${contentBusId}${path}`));
150
+ const keys = await computeSurrogateKeys(state.info.path, contentBusId);
147
151
  res.headers.set('x-surrogate-key', keys.join(' '));
148
152
 
149
153
  await setCustomResponseHeaders(state, req, res);
@@ -159,7 +163,10 @@ export async function jsonPipe(state, req) {
159
163
  if (res.status < 500) {
160
164
  await setCustomResponseHeaders(state, req, res);
161
165
  }
162
-
166
+ if (res.status === 404) {
167
+ const keys = await computeSurrogateKeys(state.info.path, contentBusId);
168
+ res.headers.set('x-surrogate-key', keys.join(' '));
169
+ }
163
170
  return res;
164
171
  }
165
172
  }