@adobe/helix-config-storage 2.2.12 → 2.3.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.3.0](https://github.com/adobe/helix-config-storage/compare/v2.2.13...v2.3.0) (2025-06-24)
2
+
3
+
4
+ ### Features
5
+
6
+ * include site details in list ([#146](https://github.com/adobe/helix-config-storage/issues/146)) ([00656ee](https://github.com/adobe/helix-config-storage/commit/00656ee93da9ac41410aeb79b4c2fdad35359fe7))
7
+
8
+ ## [2.2.13](https://github.com/adobe/helix-config-storage/compare/v2.2.12...v2.2.13) (2025-06-18)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * ensure that purge receives empty old config ([#143](https://github.com/adobe/helix-config-storage/issues/143)) ([77bab30](https://github.com/adobe/helix-config-storage/commit/77bab30a36aa8a817f1d45307447ec62e1ee39ae))
14
+
1
15
  ## [2.2.12](https://github.com/adobe/helix-config-storage/compare/v2.2.11...v2.2.12) (2025-06-18)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-config-storage",
3
- "version": "2.2.12",
3
+ "version": "2.3.0",
4
4
  "description": "Helix Config Storage",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -36,7 +36,7 @@
36
36
  "reporter-options": "configFile=.mocha-multi.json"
37
37
  },
38
38
  "devDependencies": {
39
- "@adobe/eslint-config-helix": "3.0.4",
39
+ "@adobe/eslint-config-helix": "3.0.5",
40
40
  "@eslint/config-helpers": "0.2.3",
41
41
  "@semantic-release/changelog": "6.0.3",
42
42
  "@semantic-release/git": "10.0.1",
@@ -48,7 +48,7 @@
48
48
  "json-schema-to-typescript": "15.0.4",
49
49
  "junit-report-builder": "5.1.1",
50
50
  "lint-staged": "16.1.2",
51
- "mocha": "11.6.0",
51
+ "mocha": "11.7.0",
52
52
  "mocha-multi-reporters": "1.5.1",
53
53
  "mocha-suppress-logs": "0.5.1",
54
54
  "nock": "13.5.6",
@@ -63,6 +63,7 @@
63
63
  "@adobe/fetch": "^4.2.0",
64
64
  "@adobe/helix-shared-config": "^11.1.4",
65
65
  "@adobe/helix-shared-git": "^3.0.18",
66
+ "@adobe/helix-shared-process-queue": "3.1.3",
66
67
  "@adobe/helix-shared-storage": "^1.3.0",
67
68
  "@adobe/helix-shared-string": "^2.1.0",
68
69
  "@adobe/helix-shared-utils": "^3.0.2",
@@ -13,6 +13,7 @@
13
13
  import crypto from 'crypto';
14
14
  import { decodeJwt } from 'jose';
15
15
  import { HelixStorage } from '@adobe/helix-shared-storage';
16
+ import processQueue from '@adobe/helix-shared-process-queue';
16
17
  import { StatusCodeError } from './status-code-error.js';
17
18
  import {
18
19
  createToken, createUser,
@@ -350,6 +351,7 @@ export class ConfigStore {
350
351
  this.now = new Date();
351
352
  this.isAdmin = false;
352
353
  this.isOps = false;
354
+ this.listDetails = false;
353
355
  }
354
356
 
355
357
  /**
@@ -372,6 +374,16 @@ export class ConfigStore {
372
374
  return this;
373
375
  }
374
376
 
377
+ /**
378
+ * shows the details of the config list, like the source and code urls.
379
+ * @param v
380
+ * @returns {ConfigStore}
381
+ */
382
+ withListDetails(v) {
383
+ this.listDetails = v;
384
+ return this;
385
+ }
386
+
375
387
  /**
376
388
  * updates the created and lastModified time stamp on the data object to the current time.
377
389
  * the created property is only set if it doesn't exist yet.
@@ -388,18 +400,28 @@ export class ConfigStore {
388
400
  const storage = HelixStorage.fromContext(ctx).configBus();
389
401
  const key = `orgs/${this.org}/${this.type}/`;
390
402
  const list = await storage.list(key);
403
+ let entries = list.map((entry) => {
404
+ const siteKey = entry.key;
405
+ if (siteKey.endsWith('.json')) {
406
+ const name = siteKey.split('/').pop();
407
+ return {
408
+ path: `/config/${this.org}/${this.type}/${name}`,
409
+ name: name.substring(0, name.length - 5),
410
+ };
411
+ }
412
+ return null;
413
+ }).filter((entry) => !!entry);
414
+
415
+ if (this.listDetails) {
416
+ entries = await processQueue(entries, async (entry) => {
417
+ const json = JSON.parse(await storage.get(`/orgs/${this.org}/${this.type}/${entry.name}.json`));
418
+ entry.content = json.content;
419
+ entry.code = json.code;
420
+ return entry;
421
+ });
422
+ }
391
423
  return {
392
- [this.type]: list.map((entry) => {
393
- const siteKey = entry.key;
394
- if (siteKey.endsWith('.json')) {
395
- const name = siteKey.split('/').pop();
396
- return {
397
- path: `/config/${this.org}/${this.type}/${name}`,
398
- name: name.substring(0, name.length - 5),
399
- };
400
- }
401
- return null;
402
- }).filter((entry) => !!entry),
424
+ [this.type]: entries,
403
425
  };
404
426
  }
405
427
 
@@ -732,21 +754,19 @@ export class ConfigStore {
732
754
  config.created = oldConfig?.created;
733
755
  this.#updateTimeStamps(config);
734
756
  let newConfig = config;
757
+ let purgeConfig = oldConfig;
735
758
  if (this.type === 'sites') {
736
- // apply profile
737
- if (!oldConfig) {
738
- // for a new site using a profile, we get the aggregate of the same profile.
739
- // this allows to validate the protected properties like features and limits.
740
- oldConfig = { extends: newConfig.extends };
741
- }
742
- oldConfig = await this.getAggregatedConfig(ctx, oldConfig);
759
+ // apply profile: for a new site using a profile, we get the aggregate of the same profile.
760
+ // this allows to validate the protected properties like features and limits.
761
+ oldConfig = await this.getAggregatedConfig(ctx, oldConfig ?? { extends: newConfig.extends });
762
+ purgeConfig = await this.getAggregatedConfig(ctx, purgeConfig);
743
763
  newConfig = await this.getAggregatedConfig(ctx, newConfig);
744
764
  }
745
765
 
746
766
  await this.validate(ctx, newConfig);
747
767
  await this.validatePermissions(ctx, oldConfig, newConfig);
748
768
  await storage.put(this.key, JSON.stringify(config), 'application/json');
749
- await this.purge(ctx, oldConfig, newConfig);
769
+ await this.purge(ctx, purgeConfig, newConfig);
750
770
  return ret ?? redact(data, frag);
751
771
  }
752
772