@adobe/helix-config 2.0.0 → 2.2.0

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
+ # [2.2.0](https://github.com/adobe/helix-config/compare/v2.1.0...v2.2.0) (2024-03-28)
2
+
3
+
4
+ ### Features
5
+
6
+ * add cnd.prod.route ([04ef870](https://github.com/adobe/helix-config/commit/04ef870efc8f9473d755c08573ccb2006010149a))
7
+
8
+ # [2.1.0](https://github.com/adobe/helix-config/compare/v2.0.0...v2.1.0) (2024-03-27)
9
+
10
+
11
+ ### Features
12
+
13
+ * return 404 for missing branch ([#33](https://github.com/adobe/helix-config/issues/33)) ([b3ea0f4](https://github.com/adobe/helix-config/commit/b3ea0f419f34ee0a94b02b9a67c06c64eec06d2d))
14
+
1
15
  # [2.0.0](https://github.com/adobe/helix-config/compare/v1.3.3...v2.0.0) (2024-03-14)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-config",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Helix Config",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -36,7 +36,7 @@
36
36
  "@adobe/eslint-config-helix": "2.0.6",
37
37
  "@semantic-release/changelog": "6.0.3",
38
38
  "@semantic-release/git": "10.0.1",
39
- "@semantic-release/npm": "11.0.3",
39
+ "@semantic-release/npm": "12.0.0",
40
40
  "c8": "9.1.0",
41
41
  "eslint": "8.57.0",
42
42
  "husky": "9.0.11",
@@ -125,7 +125,7 @@ async function loadHeadHtml(ctx, config, ref) {
125
125
  }
126
126
 
127
127
  function retainProperty(obj, prop) {
128
- if (!obj) {
128
+ if (!obj || Array.isArray(obj)) {
129
129
  return;
130
130
  }
131
131
  for (const key of Object.keys(obj)) {
@@ -181,10 +181,14 @@ export async function getConfigResponse(ctx, opts) {
181
181
  } = opts;
182
182
  const rso = { ref, site, org };
183
183
  const config = await resolveConfig(ctx, rso, scope);
184
+ const surrogateHeaders = {
185
+ 'x-surrogate-key': await getSurrogateKey(opts),
186
+ };
184
187
  if (!config) {
185
188
  return new PipelineResponse('', {
186
189
  status: 404,
187
190
  headers: {
191
+ ...surrogateHeaders,
188
192
  'x-error': 'config not found.',
189
193
  },
190
194
  });
@@ -203,15 +207,10 @@ export async function getConfigResponse(ctx, opts) {
203
207
  }
204
208
  }
205
209
 
206
- const headers = {
207
- 'content-type': 'application/json',
208
- 'x-surrogate-key': await getSurrogateKey(opts),
209
- };
210
-
211
210
  if (opts.scope === SCOPE_DELIVERY) {
212
211
  return new PipelineResponse('', {
213
212
  headers: {
214
- 'x-surrogate-key': await getSurrogateKey(opts),
213
+ ...surrogateHeaders,
215
214
  'x-hlx-contentbus-id': config.content.contentBusId,
216
215
  'x-hlx-owner': config.code.owner,
217
216
  'x-hlx-repo': config.code.repo,
@@ -237,11 +236,25 @@ export async function getConfigResponse(ctx, opts) {
237
236
  },
238
237
  };
239
238
  return new PipelineResponse(JSON.stringify(adminConfig, null, 2), {
240
- headers,
239
+ headers: {
240
+ 'content-type': 'application/json',
241
+ ...surrogateHeaders,
242
+ },
241
243
  });
242
244
  }
243
245
 
244
246
  if (opts.scope === SCOPE_PIPELINE) {
247
+ // validate that ref exists in code-bus
248
+ if (!config.head?.html) {
249
+ return new PipelineResponse('', {
250
+ status: 404,
251
+ headers: {
252
+ 'x-error': 'ref does not exit (no head.html)',
253
+ ...surrogateHeaders,
254
+ },
255
+ });
256
+ }
257
+
245
258
  // remove all properties except `host`. pipeline doesn't need the others.
246
259
  retainProperty(config.cdn, 'host');
247
260
  const pipelineConfig = {
@@ -258,7 +271,10 @@ export async function getConfigResponse(ctx, opts) {
258
271
  folders: config.folders,
259
272
  };
260
273
  return new PipelineResponse(JSON.stringify(pipelineConfig, null, 2), {
261
- headers,
274
+ headers: {
275
+ 'content-type': 'application/json',
276
+ ...surrogateHeaders,
277
+ },
262
278
  });
263
279
  }
264
280
 
@@ -269,6 +285,9 @@ export async function getConfigResponse(ctx, opts) {
269
285
  public: {},
270
286
  };
271
287
  return new PipelineResponse(JSON.stringify(publicConfig, null, 2), {
272
- headers,
288
+ headers: {
289
+ 'content-type': 'application/json',
290
+ ...surrogateHeaders,
291
+ },
273
292
  });
274
293
  }
@@ -44,6 +44,13 @@
44
44
  "description": "production host",
45
45
  "type": "string"
46
46
  },
47
+ "route": {
48
+ "description": "Routes on the CDN that are rendered with Franklin",
49
+ "type": "array",
50
+ "items": {
51
+ "type": "string"
52
+ }
53
+ },
47
54
  "serviceId": {
48
55
  "description": "The Fastly Service ID",
49
56
  "type": "string"
@@ -53,7 +60,7 @@
53
60
  "type": "string"
54
61
  }
55
62
  },
56
- "required": ["type", "host", "route", "serviceId", "authToken"],
63
+ "required": ["type", "host", "serviceId", "authToken"],
57
64
  "additionalProperties": false
58
65
  }, {
59
66
  "type": "object",
@@ -67,6 +74,13 @@
67
74
  "description": "production host",
68
75
  "type": "string"
69
76
  },
77
+ "route": {
78
+ "description": "Routes on the CDN that are rendered with Franklin",
79
+ "type": "array",
80
+ "items": {
81
+ "type": "string"
82
+ }
83
+ },
70
84
  "endpoint": {
71
85
  "type": "string"
72
86
  },
@@ -80,7 +94,7 @@
80
94
  "type": "string"
81
95
  }
82
96
  },
83
- "required": ["type", "host", "route", "endpoint", "clientSecret", "clientToken", "accessToken"],
97
+ "required": ["type", "host", "endpoint", "clientSecret", "clientToken", "accessToken"],
84
98
  "additionalProperties": false
85
99
  }, {
86
100
  "type": "object",
@@ -94,6 +108,13 @@
94
108
  "description": "production host",
95
109
  "type": "string"
96
110
  },
111
+ "route": {
112
+ "description": "Routes on the CDN that are rendered with Franklin",
113
+ "type": "array",
114
+ "items": {
115
+ "type": "string"
116
+ }
117
+ },
97
118
  "origin": {
98
119
  "type": "string"
99
120
  },
@@ -107,7 +128,7 @@
107
128
  "type": "string"
108
129
  }
109
130
  },
110
- "required": ["type", "host", "route", "origin", "plan", "zoneId", "apiToken"],
131
+ "required": ["type", "host", "origin", "plan", "zoneId", "apiToken"],
111
132
  "additionalProperties": false
112
133
  }, {
113
134
  "type": "object",
@@ -120,9 +141,16 @@
120
141
  "host": {
121
142
  "description": "production host",
122
143
  "type": "string"
144
+ },
145
+ "route": {
146
+ "description": "Routes on the CDN that are rendered with Franklin",
147
+ "type": "array",
148
+ "items": {
149
+ "type": "string"
150
+ }
123
151
  }
124
152
  },
125
- "required": [ "type", "host", "route"],
153
+ "required": [ "type", "host"],
126
154
  "additionalProperties": false
127
155
  }]
128
156
  },
@@ -139,6 +139,10 @@ export interface FastlyConfig {
139
139
  * production host
140
140
  */
141
141
  host: string;
142
+ /**
143
+ * Routes on the CDN that are rendered with Franklin
144
+ */
145
+ route?: string[];
142
146
  /**
143
147
  * The Fastly Service ID
144
148
  */
@@ -154,6 +158,10 @@ export interface AkamaiConfig {
154
158
  * production host
155
159
  */
156
160
  host: string;
161
+ /**
162
+ * Routes on the CDN that are rendered with Franklin
163
+ */
164
+ route?: string[];
157
165
  endpoint: string;
158
166
  clientSecret: string;
159
167
  clientToken: string;
@@ -165,6 +173,10 @@ export interface CloudflareConfig {
165
173
  * production host
166
174
  */
167
175
  host: string;
176
+ /**
177
+ * Routes on the CDN that are rendered with Franklin
178
+ */
179
+ route?: string[];
168
180
  origin: string;
169
181
  plan: string;
170
182
  zoneId: string;
@@ -176,6 +188,10 @@ export interface ManagedConfig {
176
188
  * production host
177
189
  */
178
190
  host: string;
191
+ /**
192
+ * Routes on the CDN that are rendered with Franklin
193
+ */
194
+ route?: string[];
179
195
  }
180
196
  export interface AdminAccessConfig {
181
197
  role?: Role;