@adobe/helix-html-pipeline 6.14.10 → 6.14.11

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,10 @@
1
+ ## [6.14.11](https://github.com/adobe/helix-html-pipeline/compare/v6.14.10...v6.14.11) (2024-09-30)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * scoped keys for prefix content ([82966df](https://github.com/adobe/helix-html-pipeline/commit/82966df9c749a1f03c7423cd9da51f685d788133))
7
+
1
8
  ## [6.14.10](https://github.com/adobe/helix-html-pipeline/compare/v6.14.9...v6.14.10) (2024-09-28)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-html-pipeline",
3
- "version": "6.14.10",
3
+ "version": "6.14.11",
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
@@ -65,6 +65,13 @@ async function fetchJsonContent(state, req, res) {
65
65
  if (state.content.sourceBus === 'content') {
66
66
  keys.push(await computeSurrogateKey(`${contentBusId}${info.path}`));
67
67
  keys.push(contentBusId);
68
+ const contentKeyPrefix = partition === 'preview' ? 'p_' : '';
69
+ if (partition === 'preview') {
70
+ // temporarily provide additional preview content keys
71
+ // TODO: eventually provide either (prefixed) preview or (unprefixed) live content keys
72
+ keys.push(`${contentKeyPrefix}${await computeSurrogateKey(`${contentBusId}${info.path}`)}`);
73
+ keys.push(`${contentKeyPrefix}${contentBusId}`);
74
+ }
68
75
  } else {
69
76
  keys.push(`${ref}--${repo}--${owner}_code`);
70
77
  keys.push(await computeSurrogateKey(`${ref}--${repo}--${owner}${info.path}`));
@@ -104,6 +111,13 @@ async function computeSurrogateKeys(state) {
104
111
  if (state.content.sourceBus.includes('content')) {
105
112
  keys.push(await computeSurrogateKey(`${state.contentBusId}${state.info.path}`));
106
113
  keys.push(state.contentBusId);
114
+ const contentKeyPrefix = state.partition === 'preview' ? 'p_' : '';
115
+ if (state.partition === 'preview') {
116
+ // temporarily provide additional preview content keys
117
+ // TODO: eventually provide either (prefixed) preview or (unprefixed) live content keys
118
+ keys.push(`${contentKeyPrefix}${await computeSurrogateKey(`${state.contentBusId}${state.info.path}`)}`);
119
+ keys.push(`${contentKeyPrefix}${state.contentBusId}`);
120
+ }
107
121
  }
108
122
 
109
123
  return keys;
@@ -22,7 +22,7 @@ import { getPathKey } from './set-x-surrogate-key-header.js';
22
22
  */
23
23
  export default async function fetch404(state, req, res) {
24
24
  const {
25
- owner, repo, ref, contentBusId,
25
+ owner, repo, ref, contentBusId, partition,
26
26
  } = state;
27
27
  const ret = await state.s3Loader.getObject('helix-code-bus', `${owner}/${repo}/${ref}/404.html`);
28
28
  if (ret.status === 200) {
@@ -46,12 +46,25 @@ export default async function fetch404(state, req, res) {
46
46
  `${ref}--${repo}--${owner}_404`,
47
47
  `${ref}--${repo}--${owner}_code`,
48
48
  ];
49
+ const contentKeyPrefix = partition === 'preview' ? 'p_' : '';
50
+ if (partition === 'preview') {
51
+ // temporarily provide additional preview content keys
52
+ // TODO: eventually provide either (prefixed) preview or (unprefixed) live content keys
53
+ keys.push(`${contentKeyPrefix}${pathKey}`);
54
+ keys.push(`${contentKeyPrefix}${contentBusId}`);
55
+ }
49
56
 
50
57
  if (state.info.unmappedPath) {
51
- keys.push(await getPathKey({
58
+ const unmappedPathKey = await getPathKey({
52
59
  contentBusId,
53
60
  info: { path: state.info.unmappedPath },
54
- }));
61
+ });
62
+ keys.push(unmappedPathKey);
63
+ if (partition === 'preview') {
64
+ // temporarily provide additional preview content key
65
+ // TODO: eventually provide either (prefixed) preview or (unprefixed) live content key
66
+ keys.push(`${contentKeyPrefix}${unmappedPathKey}`);
67
+ }
55
68
  }
56
69
 
57
70
  res.headers.set('x-surrogate-key', keys.join(' '));
@@ -48,6 +48,13 @@ export default async function fetchContent(state, req, res) {
48
48
  } else {
49
49
  keys.push(await computeSurrogateKey(`${contentBusId}${info.path}`));
50
50
  keys.push(contentBusId);
51
+ const contentKeyPrefix = partition === 'preview' ? 'p_' : '';
52
+ if (partition === 'preview') {
53
+ // temporarily provide additional preview content keys
54
+ // TODO: eventually provide either (prefixed) preview or (unprefixed) live content keys
55
+ keys.push(`${contentKeyPrefix}${await computeSurrogateKey(`${contentBusId}${info.path}`)}`);
56
+ keys.push(`${contentKeyPrefix}${contentBusId}`);
57
+ }
51
58
  }
52
59
  res.headers.set('x-surrogate-key', keys.join(' '));
53
60
  res.error = 'moved';
@@ -42,11 +42,12 @@ export async function getPathKey(state) {
42
42
  */
43
43
  export default async function setXSurrogateKeyHeader(state, req, res) {
44
44
  const {
45
- contentBusId, owner, repo, ref,
45
+ contentBusId, owner, repo, ref, partition,
46
46
  } = state;
47
47
 
48
48
  const isCode = state.content.sourceBus === 'code';
49
49
 
50
+ const contentKeyPrefix = partition === 'preview' ? 'p_' : '';
50
51
  const keys = [];
51
52
  const hash = await getPathKey(state);
52
53
  if (isCode) {
@@ -57,6 +58,13 @@ export default async function setXSurrogateKeyHeader(state, req, res) {
57
58
  keys.push(`${contentBusId}_metadata`);
58
59
  keys.push(`${ref}--${repo}--${owner}_head`);
59
60
  keys.push(contentBusId);
61
+ if (partition === 'preview') {
62
+ // temporarily provide additional preview content keys
63
+ // TODO: eventually provide either (prefixed) preview or (unprefixed) live content keys
64
+ keys.push(`${contentKeyPrefix}${hash}`);
65
+ keys.push(`${contentKeyPrefix}${contentBusId}_metadata`);
66
+ keys.push(`${contentKeyPrefix}${contentBusId}`);
67
+ }
60
68
  }
61
69
  // for folder-mapped resources, we also need to include the surrogate key of the mapped metadata
62
70
  if (state.mapped) {
@@ -67,6 +75,17 @@ export default async function setXSurrogateKeyHeader(state, req, res) {
67
75
  info: { path: state.info.unmappedPath },
68
76
  }));
69
77
  }
78
+ if (partition === 'preview') {
79
+ // temporarily provide additional preview content keys
80
+ // TODO: eventually provide either (prefixed) preview or (unprefixed) live content keys
81
+ keys.push(`${contentKeyPrefix}${hash}_metadata`);
82
+ if (state.info.unmappedPath) {
83
+ keys.push(`${contentKeyPrefix}${await getPathKey({
84
+ contentBusId,
85
+ info: { path: state.info.unmappedPath },
86
+ })}`);
87
+ }
88
+ }
70
89
  }
71
90
  res.headers.set('x-surrogate-key', keys.join(' '));
72
91
  }