@adobe/helix-config 5.15.3 → 5.16.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 +14 -0
- package/package.json +1 -1
- package/src/config-view.js +41 -20
- package/src/index.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [5.16.0](https://github.com/adobe/helix-config/compare/v5.15.4...v5.16.0) (2026-10-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **config-view:** add partition option to restrict metadata ([#417](https://github.com/adobe/helix-config/issues/417)) ([c237a64](https://github.com/adobe/helix-config/commit/c237a64228658301ee444698f1db6adbd0a9dd0c))
|
|
7
|
+
|
|
8
|
+
## [5.15.4](https://github.com/adobe/helix-config/compare/v5.15.3...v5.15.4) (2026-09-28)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* use concat for array concatenation ([#420](https://github.com/adobe/helix-config/issues/420)) ([756f598](https://github.com/adobe/helix-config/commit/756f598692036dfaf95cd4fa5984162fde59d103))
|
|
14
|
+
|
|
1
15
|
## [5.15.3](https://github.com/adobe/helix-config/compare/v5.15.2...v5.15.3) (2026-09-24)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/config-view.js
CHANGED
|
@@ -63,6 +63,12 @@ const VALID_ORG_SCOPES = [
|
|
|
63
63
|
SCOPE_ADMIN,
|
|
64
64
|
];
|
|
65
65
|
|
|
66
|
+
const VALID_PARTITIONS = [
|
|
67
|
+
undefined, // no partition returns all partitions
|
|
68
|
+
'preview',
|
|
69
|
+
'live',
|
|
70
|
+
];
|
|
71
|
+
|
|
66
72
|
/**
|
|
67
73
|
* Returns the hash of the global delivery token if defined.
|
|
68
74
|
* @param ctx
|
|
@@ -236,24 +242,16 @@ async function fetchSitemapIndex(ctx, rso, config) {
|
|
|
236
242
|
}
|
|
237
243
|
|
|
238
244
|
/**
|
|
239
|
-
* Load metadata from the given
|
|
245
|
+
* Load metadata from the given sources
|
|
240
246
|
* @param ctx the context
|
|
241
247
|
* @param config the config
|
|
242
248
|
* @param partition the partition
|
|
249
|
+
* @param {string[]} sources the metadata sheets to load
|
|
243
250
|
* @returns {Promise<ConfigObject|{}>} the metadata
|
|
244
251
|
*/
|
|
245
|
-
async function loadMetadata(ctx, config, partition) {
|
|
246
|
-
const paths = config.metadata?.source ?? [];
|
|
247
|
-
if (!paths.length) {
|
|
248
|
-
paths.push(METADATA_JSON);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// generate the metadata-all.json first
|
|
252
|
-
const metadataConfig = new ConfigObject();
|
|
253
|
-
const metadata = [];
|
|
254
|
-
|
|
252
|
+
async function loadMetadata(ctx, config, partition, sources) {
|
|
255
253
|
// remember the order of entries
|
|
256
|
-
const input =
|
|
254
|
+
const input = sources.map((path, index) => ({ index, path }));
|
|
257
255
|
const output = await processQueue(input, async ({ index, path }) => {
|
|
258
256
|
const key = `${config.content.contentBusId}/${partition}${path}`;
|
|
259
257
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -271,10 +269,14 @@ async function loadMetadata(ctx, config, partition) {
|
|
|
271
269
|
return undefined;
|
|
272
270
|
}, 32);
|
|
273
271
|
|
|
272
|
+
// generate the metadata-all.json first
|
|
273
|
+
const metadataConfig = new ConfigObject();
|
|
274
|
+
let metadata = [];
|
|
275
|
+
|
|
274
276
|
output.sort(({ index: i }, { index: j }) => i - j);
|
|
275
277
|
for (const { data, headers } of output) {
|
|
276
278
|
if (data) {
|
|
277
|
-
metadata.
|
|
279
|
+
metadata = metadata.concat(data);
|
|
278
280
|
}
|
|
279
281
|
metadataConfig.updateLastModified(headers);
|
|
280
282
|
}
|
|
@@ -351,9 +353,11 @@ async function loadProfile(ctx, rso, name) {
|
|
|
351
353
|
* @param ctx
|
|
352
354
|
* @param {RSO} rso
|
|
353
355
|
* @param {string} scope
|
|
356
|
+
* @param {string} [partition] the partition to restrict to. if omitted, all
|
|
357
|
+
* partitions are returned.
|
|
354
358
|
* @return {Promise<ConfigObject|null>}
|
|
355
359
|
*/
|
|
356
|
-
async function resolveConfig(ctx, rso, scope) {
|
|
360
|
+
async function resolveConfig(ctx, rso, scope, partition) {
|
|
357
361
|
// try to load site config from config-bus
|
|
358
362
|
const key = `orgs/${rso.org}/sites/${rso.site}.json`;
|
|
359
363
|
ctx.timer?.update('load-config');
|
|
@@ -393,10 +397,18 @@ async function resolveConfig(ctx, rso, scope) {
|
|
|
393
397
|
const config = site.data;
|
|
394
398
|
if (scope === SCOPE_PIPELINE) {
|
|
395
399
|
ctx.timer?.update('metadata');
|
|
396
|
-
config.metadata
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
+
// read the configured sources before `config.metadata` is replaced below
|
|
401
|
+
const sources = config.metadata?.source?.length
|
|
402
|
+
? config.metadata.source
|
|
403
|
+
: [METADATA_JSON];
|
|
404
|
+
const metadata = {};
|
|
405
|
+
if (partition !== 'live') {
|
|
406
|
+
metadata.preview = await loadMetadata(ctx, config, 'preview', sources);
|
|
407
|
+
}
|
|
408
|
+
if (partition !== 'preview') {
|
|
409
|
+
metadata.live = await loadMetadata(ctx, config, 'live', sources);
|
|
410
|
+
}
|
|
411
|
+
config.metadata = metadata;
|
|
400
412
|
}
|
|
401
413
|
if (scope === SCOPE_PIPELINE || scope === SCOPE_RAW) {
|
|
402
414
|
if (!config.robots) {
|
|
@@ -658,7 +670,7 @@ function computeTrustedHosts(org, site, siteConfig) {
|
|
|
658
670
|
|
|
659
671
|
export async function getConfigResponse(ctx, opts) {
|
|
660
672
|
const {
|
|
661
|
-
ref, site, org, scope,
|
|
673
|
+
ref, site, org, scope, partition,
|
|
662
674
|
} = opts;
|
|
663
675
|
if (!VALID_SCOPES.includes(scope)) {
|
|
664
676
|
return new PipelineResponse('', {
|
|
@@ -669,10 +681,19 @@ export async function getConfigResponse(ctx, opts) {
|
|
|
669
681
|
});
|
|
670
682
|
}
|
|
671
683
|
|
|
684
|
+
if (!VALID_PARTITIONS.includes(partition)) {
|
|
685
|
+
return new PipelineResponse('', {
|
|
686
|
+
status: 400,
|
|
687
|
+
headers: {
|
|
688
|
+
'x-error': 'invalid partition',
|
|
689
|
+
},
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
|
|
672
693
|
const rso = { ref, site, org };
|
|
673
694
|
let siteConfig;
|
|
674
695
|
try {
|
|
675
|
-
siteConfig = await resolveConfig(ctx, rso, scope);
|
|
696
|
+
siteConfig = await resolveConfig(ctx, rso, scope, partition);
|
|
676
697
|
} catch (e) {
|
|
677
698
|
return new PipelineResponse('', {
|
|
678
699
|
status: 502,
|
package/src/index.d.ts
CHANGED