@adobe/helix-html-pipeline 6.7.10 → 6.8.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,17 @@
1
+ ## [6.8.1](https://github.com/adobe/helix-html-pipeline/compare/v6.8.0...v6.8.1) (2024-04-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * move config ([#590](https://github.com/adobe/helix-html-pipeline/issues/590)) ([4c6b6e4](https://github.com/adobe/helix-html-pipeline/commit/4c6b6e474639698eef07673c074e3f5e0848df3f))
7
+
8
+ # [6.8.0](https://github.com/adobe/helix-html-pipeline/compare/v6.7.10...v6.8.0) (2024-04-18)
9
+
10
+
11
+ ### Features
12
+
13
+ * serve /config.json ([#589](https://github.com/adobe/helix-html-pipeline/issues/589)) ([f01f9ce](https://github.com/adobe/helix-html-pipeline/commit/f01f9ced59e21aa406c24babe4200e8267dd72e8))
14
+
1
15
  ## [6.7.10](https://github.com/adobe/helix-html-pipeline/compare/v6.7.9...v6.7.10) (2024-04-17)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-html-pipeline",
3
- "version": "6.7.10",
3
+ "version": "6.8.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
@@ -46,10 +46,12 @@ async function fetchJsonContent(state, req, res) {
46
46
  owner, repo, ref, contentBusId, partition, s3Loader, log, info,
47
47
  } = state;
48
48
  const { path } = state.info;
49
+ state.content.sourceBus = 'content';
49
50
  let ret = await s3Loader.getObject('helix-content-bus', `${contentBusId}/${partition}${path}`);
50
51
 
51
52
  // if not found, fall back to code bus
52
53
  if (ret.status === 404) {
54
+ state.content.sourceBus = 'code';
53
55
  ret = await s3Loader.getObject('helix-code-bus', `${owner}/${repo}/${ref}${path}`);
54
56
  }
55
57
 
@@ -76,15 +78,23 @@ async function fetchJsonContent(state, req, res) {
76
78
 
77
79
  updateLastModified(state, res, extractLastModified(ret.headers));
78
80
  } else {
81
+ state.content.sourceBus = 'content';
79
82
  res.status = ret.status === 404 ? 404 : 502;
80
83
  res.error = `failed to load ${state.info.resourcePath}: ${ret.status}`;
81
84
  }
82
85
  }
83
86
 
84
- async function computeSurrogateKeys(path, contentBusId) {
87
+ async function computeSurrogateKeys(state) {
85
88
  const keys = [];
86
- keys.push(`${contentBusId}${path}`.replace(/\//g, '_')); // TODO: remove
87
- keys.push(await computeSurrogateKey(`${contentBusId}${path}`));
89
+ const pathKey = state.content?.sourceBus === 'code'
90
+ ? `${state.ref}--${state.repo}--${state.owner}${state.info.path}`
91
+ : `${state.contentBusId}${state.info.path}`;
92
+
93
+ if (state.info.path === '/config.json') {
94
+ keys.push(await computeSurrogateKey(`${state.site}--${state.org}_config.json`));
95
+ }
96
+ keys.push(pathKey.replace(/\//g, '_')); // TODO: remove
97
+ keys.push(await computeSurrogateKey(pathKey));
88
98
  return keys;
89
99
  }
90
100
 
@@ -142,23 +152,30 @@ export async function jsonPipe(state, req) {
142
152
 
143
153
  await authenticate(state, req, res);
144
154
 
145
- if (res.error) {
155
+ if (res.status === 404 && state.info.path === '/config.json' && state.config.public) {
156
+ // special handling for public config
157
+ const publicConfig = {
158
+ public: state.config.public,
159
+ };
160
+ res.status = 200;
161
+ res.body = JSON.stringify(publicConfig, null, 2);
162
+ } else if (res.error) {
146
163
  if (res.status < 400) {
147
164
  return res;
148
165
  }
149
166
  throw new PipelineStatusError(res.status, res.error);
167
+ } else {
168
+ // filter data
169
+ jsonFilter(state, res, {
170
+ limit: limit ? Number.parseInt(limit, 10) : undefined,
171
+ offset: offset ? Number.parseInt(offset, 10) : undefined,
172
+ sheet,
173
+ raw: limit === undefined && offset === undefined && sheet === undefined,
174
+ });
150
175
  }
151
176
 
152
- // filter data
153
- jsonFilter(state, res, {
154
- limit: limit ? Number.parseInt(limit, 10) : undefined,
155
- offset: offset ? Number.parseInt(offset, 10) : undefined,
156
- sheet,
157
- raw: limit === undefined && offset === undefined && sheet === undefined,
158
- });
159
-
160
177
  // set surrogate keys
161
- const keys = await computeSurrogateKeys(state.info.path, state.contentBusId);
178
+ const keys = await computeSurrogateKeys(state);
162
179
  res.headers.set('x-surrogate-key', keys.join(' '));
163
180
 
164
181
  await setCustomResponseHeaders(state, req, res);
@@ -175,7 +192,7 @@ export async function jsonPipe(state, req) {
175
192
  await setCustomResponseHeaders(state, req, res);
176
193
  }
177
194
  if (res.status === 404) {
178
- const keys = await computeSurrogateKeys(state.info.path, state.contentBusId);
195
+ const keys = await computeSurrogateKeys(state);
179
196
  res.headers.set('x-surrogate-key', keys.join(' '));
180
197
  }
181
198
  return res;