@adobe/helix-config 2.5.0 → 2.5.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,10 @@
1
+ ## [2.5.1](https://github.com/adobe/helix-config/compare/v2.5.0...v2.5.1) (2024-04-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * use head from ref and return 404 if missing ([#47](https://github.com/adobe/helix-config/issues/47)) ([61ab5b5](https://github.com/adobe/helix-config/commit/61ab5b5b6758752c6c87cb64b02d10155a674ab6))
7
+
1
8
  # [2.5.0](https://github.com/adobe/helix-config/compare/v2.4.0...v2.5.0) (2024-04-16)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-config",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "description": "Helix Config",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -17,14 +17,13 @@ const HELIX_CONTENT_BUS = 'helix-content-bus';
17
17
 
18
18
  /**
19
19
  * Retrieves the helix-config.json which is an aggregate from fstab.yaml and head.html.
20
- * Note: it always uses the branch `main`.
21
20
  *
22
21
  * @param {ConfigContext} ctx the context
23
22
  * @param {RSO} rso
24
23
  * @returns {Promise<HelixConfig|null>} the helix-config or {@code null} if optional and not found.
25
24
  */
26
25
  async function fetchHelixConfig(ctx, rso) {
27
- const key = `${rso.org}/${rso.site}/main/helix-config.json`;
26
+ const key = `${rso.org}/${rso.site}/${rso.ref}/helix-config.json`;
28
27
  const res = await ctx.loader.getObject(HELIX_CODE_BUS, key);
29
28
  if (!res.body) {
30
29
  return null;
@@ -105,6 +104,8 @@ export async function resolveLegacyConfig(ctx, rso, scope) {
105
104
  source,
106
105
  },
107
106
  folders: helixConfig.fstab?.data.folders ?? {},
107
+ /* c8 ignore next */
108
+ head: helixConfig?.head?.data ?? {},
108
109
  };
109
110
  const configAllPreview = await fetchConfigAll(ctx, config.content.contentBusId, 'preview');
110
111
  const configAllLive = await fetchConfigAll(ctx, config.content.contentBusId, 'live');
@@ -130,12 +131,6 @@ export async function resolveLegacyConfig(ctx, rso, scope) {
130
131
  if (configAllLive?.metadata) {
131
132
  config.metadata.live = configAllLive.metadata;
132
133
  }
133
-
134
- if (helixConfig?.head?.data?.html) {
135
- config.head = {
136
- html: helixConfig.head.data.html,
137
- };
138
- }
139
134
  }
140
135
  return config;
141
136
  }
@@ -167,6 +167,8 @@ async function resolveConfig(ctx, rso, scope) {
167
167
  preview: await loadMetadata(ctx, config, 'preview'),
168
168
  live: await loadMetadata(ctx, config, 'live'),
169
169
  };
170
+ }
171
+ if (scope === SCOPE_PIPELINE || scope === SCOPE_DELIVERY) {
170
172
  config.head = await loadHeadHtml(ctx, config, rso.ref);
171
173
  }
172
174
 
@@ -212,6 +214,17 @@ export async function getConfigResponse(ctx, opts) {
212
214
  }
213
215
  }
214
216
 
217
+ if (!config.head?.html && (opts.scope === SCOPE_PIPELINE || opts.scope === SCOPE_DELIVERY)) {
218
+ // validate that ref exists in code-bus
219
+ return new PipelineResponse('', {
220
+ status: 404,
221
+ headers: {
222
+ 'x-error': 'ref does not exist (no head.html)',
223
+ ...surrogateHeaders,
224
+ },
225
+ });
226
+ }
227
+
215
228
  if (opts.scope === SCOPE_DELIVERY) {
216
229
  return new PipelineResponse('', {
217
230
  headers: {
@@ -250,6 +263,7 @@ export async function getConfigResponse(ctx, opts) {
250
263
  }
251
264
 
252
265
  if (opts.scope === SCOPE_RAW) {
266
+ delete config.head;
253
267
  return new PipelineResponse(JSON.stringify(config, null, 2), {
254
268
  headers: {
255
269
  'content-type': 'application/json',
@@ -259,17 +273,6 @@ export async function getConfigResponse(ctx, opts) {
259
273
  }
260
274
 
261
275
  if (opts.scope === SCOPE_PIPELINE) {
262
- // validate that ref exists in code-bus
263
- if (!config.head?.html) {
264
- return new PipelineResponse('', {
265
- status: 404,
266
- headers: {
267
- 'x-error': 'ref does not exist (no head.html)',
268
- ...surrogateHeaders,
269
- },
270
- });
271
- }
272
-
273
276
  // remove all properties except `host`. pipeline doesn't need the others.
274
277
  retainProperty(config.cdn, 'host');
275
278
  const pipelineConfig = {