@adobe/helix-html-pipeline 6.18.0 → 6.18.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,11 @@
1
+ ## [6.18.1](https://github.com/adobe/helix-html-pipeline/compare/v6.18.0...v6.18.1) (2025-01-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * always return content and code keys for 404 ([572c1b6](https://github.com/adobe/helix-html-pipeline/commit/572c1b6e8a2e81c1c2a5ed57216926b9091dfe41))
7
+ * surrogate key for non-existing .html in code-bus ([c10182c](https://github.com/adobe/helix-html-pipeline/commit/c10182cbb99d5a793418adb224ab3e1a8b3b28b0))
8
+
1
9
  # [6.18.0](https://github.com/adobe/helix-html-pipeline/compare/v6.17.8...v6.18.0) (2025-01-24)
2
10
 
3
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-html-pipeline",
3
- "version": "6.18.0",
3
+ "version": "6.18.1",
4
4
  "description": "Helix HTML Pipeline",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
package/src/json-pipe.js CHANGED
@@ -12,6 +12,7 @@
12
12
  import { cleanupHeaderValue, computeSurrogateKey } from '@adobe/helix-shared-utils';
13
13
  import initConfig from './steps/init-config.js';
14
14
  import setCustomResponseHeaders from './steps/set-custom-response-headers.js';
15
+ import { computeContentPathKey, computeCodePathKey } from './steps/set-x-surrogate-key-header.js';
15
16
  import { PipelineResponse } from './PipelineResponse.js';
16
17
  import jsonFilter from './utils/json-filter.js';
17
18
  import { extractLastModified, recordLastModified, setLastModified } from './utils/last-modified.js';
@@ -42,7 +43,7 @@ export default function folderMapping(state) {
42
43
 
43
44
  async function fetchJsonContent(state, req, res) {
44
45
  const {
45
- owner, repo, ref, contentBusId, partition, s3Loader, log, info,
46
+ owner, repo, ref, contentBusId, partition, s3Loader, log,
46
47
  } = state;
47
48
  const { path } = state.info;
48
49
  state.content.sourceBus = 'content';
@@ -65,11 +66,11 @@ async function fetchJsonContent(state, req, res) {
65
66
  if (state.content.sourceBus === 'content') {
66
67
  // provide either (prefixed) preview or (unprefixed) live content keys
67
68
  const contentKeyPrefix = partition === 'preview' ? 'p_' : '';
68
- keys.push(`${contentKeyPrefix}${await computeSurrogateKey(`${contentBusId}${info.path}`)}`);
69
+ keys.push(`${contentKeyPrefix}${await computeContentPathKey(state)}`);
69
70
  keys.push(`${contentKeyPrefix}${contentBusId}`);
70
71
  } else {
71
72
  keys.push(`${ref}--${repo}--${owner}_code`);
72
- keys.push(await computeSurrogateKey(`${ref}--${repo}--${owner}${info.path}`));
73
+ keys.push(await computeCodePathKey(state));
73
74
  }
74
75
  res.headers.set('x-surrogate-key', keys.join(' '));
75
76
  res.error = 'moved';
@@ -100,13 +101,13 @@ async function computeSurrogateKeys(state) {
100
101
  keys.push(await computeSurrogateKey(`${state.site}--${state.org}_config.json`));
101
102
  }
102
103
  if (state.content.sourceBus.includes('code')) {
103
- keys.push(await computeSurrogateKey(`${state.ref}--${state.repo}--${state.owner}${state.info.path}`));
104
+ keys.push(await computeCodePathKey(state));
104
105
  keys.push(`${state.ref}--${state.repo}--${state.owner}_code`);
105
106
  }
106
107
  if (state.content.sourceBus.includes('content')) {
107
108
  // provide either (prefixed) preview or (unprefixed) live content keys
108
109
  const contentKeyPrefix = state.partition === 'preview' ? 'p_' : '';
109
- keys.push(`${contentKeyPrefix}${await computeSurrogateKey(`${state.contentBusId}${state.info.path}`)}`);
110
+ keys.push(`${contentKeyPrefix}${await computeContentPathKey(state)}`);
110
111
  keys.push(`${contentKeyPrefix}${state.contentBusId}`);
111
112
  }
112
113
 
@@ -11,6 +11,7 @@
11
11
  */
12
12
  import { cleanupHeaderValue, computeSurrogateKey } from '@adobe/helix-shared-utils';
13
13
  import renderCode from './steps/render-code.js';
14
+ import { computeCodePathKey } from './steps/set-x-surrogate-key-header.js';
14
15
  import setCustomResponseHeaders from './steps/set-custom-response-headers.js';
15
16
  import { PipelineResponse } from './PipelineResponse.js';
16
17
  import initConfig from './steps/init-config.js';
@@ -119,9 +120,8 @@ function getForwardedHosts(req) {
119
120
  async function computeSurrogateKeys(state) {
120
121
  const keys = [];
121
122
 
122
- const pathKey = `${state.ref}--${state.repo}--${state.owner}${state.info.path}`;
123
123
  keys.push(await computeSurrogateKey(`${state.site}--${state.org}_config.json`));
124
- keys.push(await computeSurrogateKey(pathKey));
124
+ keys.push(await computeCodePathKey(state));
125
125
  return keys;
126
126
  }
127
127
 
@@ -10,7 +10,7 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
  import { extractLastModified, recordLastModified } from '../utils/last-modified.js';
13
- import { getPathKey } from './set-x-surrogate-key-header.js';
13
+ import { computeContentPathKey, computeCodePathKey } from './set-x-surrogate-key-header.js';
14
14
 
15
15
  /**
16
16
  * Loads the 404.html from code-bus and stores it in `res.body`
@@ -39,23 +39,24 @@ export default async function fetch404(state, req, res) {
39
39
  }
40
40
 
41
41
  // set 404 keys in any case
42
- const pathKey = await getPathKey(state);
42
+ // always provide code and content keys since a resource could be added later to either bus
43
+ const keys = [];
44
+ // content keys
43
45
  // provide either (prefixed) preview or (unprefixed) live content keys
44
46
  const contentKeyPrefix = partition === 'preview' ? 'p_' : '';
45
- const keys = [
46
- `${contentKeyPrefix}${pathKey}`,
47
- `${contentKeyPrefix}${contentBusId}`,
48
- `${ref}--${repo}--${owner}_404`,
49
- `${ref}--${repo}--${owner}_code`,
50
- ];
51
-
47
+ keys.push(`${contentKeyPrefix}${await computeContentPathKey(state)}`);
48
+ keys.push(`${contentKeyPrefix}${contentBusId}`);
52
49
  if (state.info.unmappedPath) {
53
- const unmappedPathKey = await getPathKey({
50
+ const unmappedPathKey = await computeContentPathKey({
54
51
  contentBusId,
55
52
  info: { path: state.info.unmappedPath },
56
53
  });
57
54
  keys.push(`${contentKeyPrefix}${unmappedPathKey}`);
58
55
  }
56
+ // code keys
57
+ keys.push(await computeCodePathKey(state));
58
+ keys.push(`${ref}--${repo}--${owner}_404`);
59
+ keys.push(`${ref}--${repo}--${owner}_code`);
59
60
 
60
61
  res.headers.set('x-surrogate-key', keys.join(' '));
61
62
  }
@@ -9,7 +9,7 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- import { computeSurrogateKey } from '@adobe/helix-shared-utils';
12
+ import { computeContentPathKey, computeCodePathKey } from './set-x-surrogate-key-header.js';
13
13
  import { extractLastModified, recordLastModified } from '../utils/last-modified.js';
14
14
 
15
15
  /**
@@ -43,12 +43,12 @@ export default async function fetchContent(state, req, res) {
43
43
  res.headers.set('location', redirectLocation);
44
44
  const keys = [];
45
45
  if (isCode) {
46
- keys.push(await computeSurrogateKey(`${ref}--${repo}--${owner}${info.path}`));
46
+ keys.push(await computeCodePathKey(state));
47
47
  keys.push(`${ref}--${repo}--${owner}_code`);
48
48
  } else {
49
49
  // provide either (prefixed) preview or (unprefixed) live content keys
50
50
  const contentKeyPrefix = partition === 'preview' ? 'p_' : '';
51
- keys.push(`${contentKeyPrefix}${await computeSurrogateKey(`${contentBusId}${info.path}`)}`);
51
+ keys.push(`${contentKeyPrefix}${await computeContentPathKey(state)}`);
52
52
  keys.push(`${contentKeyPrefix}${contentBusId}`);
53
53
  }
54
54
  res.headers.set('x-surrogate-key', keys.join(' '));
@@ -12,11 +12,12 @@
12
12
  import { computeSurrogateKey } from '@adobe/helix-shared-utils';
13
13
 
14
14
  /**
15
- * Returns the surrogate key based on the contentBusId and the resource path
15
+ * Returns the surrogate key for a content-bus resource
16
+ * based on the contentBusId and the resource path
16
17
  * @param state
17
18
  * @returns {Promise<string>}
18
19
  */
19
- export async function getPathKey(state) {
20
+ export async function computeContentPathKey(state) {
20
21
  const { contentBusId, info } = state;
21
22
  let { path } = info;
22
23
  // surrogate key for path
@@ -33,6 +34,19 @@ export async function getPathKey(state) {
33
34
  return computeSurrogateKey(`${contentBusId}${path}`);
34
35
  }
35
36
 
37
+ /**
38
+ * Returns the surrogate key for a code-bus resource
39
+ * based on the repositry and the resource path
40
+ * @param state
41
+ * @returns {Promise<string>}
42
+ */
43
+ export async function computeCodePathKey(state) {
44
+ const {
45
+ owner, repo, ref, info: { path },
46
+ } = state;
47
+ return computeSurrogateKey(`${ref}--${repo}--${owner}${path}`);
48
+ }
49
+
36
50
  /**
37
51
  * @type PipelineStep
38
52
  * @param {PipelineState} state
@@ -50,9 +64,9 @@ export default async function setXSurrogateKeyHeader(state, req, res) {
50
64
  // provide either (prefixed) preview or (unprefixed) live content keys
51
65
  const contentKeyPrefix = partition === 'preview' ? 'p_' : '';
52
66
  const keys = [];
53
- const hash = await getPathKey(state);
67
+ const hash = await computeContentPathKey(state);
54
68
  if (isCode) {
55
- keys.push(await computeSurrogateKey(`${ref}--${repo}--${owner}${state.info.path}`));
69
+ keys.push(await computeCodePathKey(state));
56
70
  keys.push(`${ref}--${repo}--${owner}_code`);
57
71
  } else {
58
72
  keys.push(`${contentKeyPrefix}${hash}`);
@@ -64,7 +78,7 @@ export default async function setXSurrogateKeyHeader(state, req, res) {
64
78
  if (state.mapped) {
65
79
  keys.push(`${contentKeyPrefix}${hash}_metadata`);
66
80
  if (state.info.unmappedPath) {
67
- keys.push(`${contentKeyPrefix}${await getPathKey({
81
+ keys.push(`${contentKeyPrefix}${await computeContentPathKey({
68
82
  contentBusId,
69
83
  info: { path: state.info.unmappedPath },
70
84
  })}`);