@adobe/helix-admin-support 2.0.3 → 2.1.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
+ ## [2.1.1](https://github.com/adobe/helix-admin-support/compare/v2.1.0...v2.1.1) (2023-04-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update external fixes ([53328bb](https://github.com/adobe/helix-admin-support/commit/53328bb7a50524631e64fe8fc2caf900724631e1))
7
+
8
+ # [2.1.0](https://github.com/adobe/helix-admin-support/compare/v2.0.3...v2.1.0) (2023-04-06)
9
+
10
+
11
+ ### Features
12
+
13
+ * create distinct object in helix-config for contentbus ids ([#134](https://github.com/adobe/helix-admin-support/issues/134)) ([fb48877](https://github.com/adobe/helix-admin-support/commit/fb48877af76c431df217c52eaed19aaaf348f811))
14
+
1
15
  ## [2.0.3](https://github.com/adobe/helix-admin-support/compare/v2.0.2...v2.0.3) (2023-04-05)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-admin-support",
3
- "version": "2.0.3",
3
+ "version": "2.1.1",
4
4
  "description": "Helix Admin Support Library",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -37,23 +37,23 @@
37
37
  "@adobe/fetch": "4.0.6",
38
38
  "@adobe/helix-shared-config": "10.0.2",
39
39
  "@adobe/helix-shared-utils": "3.0.0",
40
- "@aws-sdk/client-s3": "3.304.0",
41
- "@aws-sdk/client-sqs": "3.303.0",
42
- "@aws-sdk/node-http-handler": "3.303.0"
40
+ "@aws-sdk/client-s3": "3.309.0",
41
+ "@aws-sdk/client-sqs": "3.309.0",
42
+ "@aws-sdk/node-http-handler": "3.306.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@adobe/eslint-config-helix": "2.0.2",
46
46
  "@adobe/jsonschema2md": "7.1.5",
47
47
  "@semantic-release/changelog": "6.0.3",
48
48
  "@semantic-release/git": "10.0.1",
49
- "@semantic-release/npm": "10.0.2",
49
+ "@semantic-release/npm": "10.0.3",
50
50
  "c8": "7.13.0",
51
- "eslint": "8.37.0",
51
+ "eslint": "8.38.0",
52
52
  "husky": "8.0.3",
53
53
  "jsdoc-to-markdown": "8.0.0",
54
54
  "json-schema-to-typescript": "12.0.0",
55
55
  "junit-report-builder": "3.0.1",
56
- "lint-staged": "13.2.0",
56
+ "lint-staged": "13.2.1",
57
57
  "mocha": "10.2.0",
58
58
  "mocha-multi-reporters": "1.5.1",
59
59
  "nock": "13.3.0",
package/src/contentbus.js CHANGED
@@ -53,16 +53,15 @@ export async function calculateContentBusId(ctx, info) {
53
53
  */
54
54
  export async function getContentBusId(ctx, info, optional) {
55
55
  const fetchId = async () => {
56
- const { path } = info;
57
56
  const helixConfig = await fetchHelixConfig(ctx, info, true);
58
- if (helixConfig?.fstab?.data) {
59
- const mp = helixConfig.fstab?.data.match(path);
60
- if (mp && mp.contentBusId) {
61
- ctx.log.info(`loaded contentBusId: ${mp.contentBusId} for ${mp.url} of ${info.repo}--${info.owner}`);
62
- return mp.contentBusId;
57
+ if (helixConfig?.content?.data) {
58
+ const id = helixConfig.content.data['/']?.contentBusId;
59
+ if (id) {
60
+ ctx.log.info(`loaded contentBusId: ${id} for ${info.repo}--${info.owner}`);
61
+ return id;
63
62
  }
64
63
  }
65
- return calculateContentBusId(ctx, info);
64
+ return calculateContentBusId(ctx, { ...info, path: '/' });
66
65
  };
67
66
 
68
67
  if (ctx.attributes.contentBusId === undefined) {
@@ -28,30 +28,26 @@ async function handleResponse(log, response, key, type) {
28
28
  const config = JSON.parse(text);
29
29
  // create mountconfig of the fstab entry
30
30
  if (config.fstab?.data) {
31
- let cfg = await new MountConfig().withSource(JSON.stringify(config.fstab.data)).init();
32
-
33
- // set contentbus id, if present in header
34
- const cbid = response.headers.get('x-contentbus-id');
35
- if (cbid) {
36
- // we need to create a new expanded config
37
- const newConfig = cfg.toJSON();
31
+ config.fstab.data = await new MountConfig()
32
+ .withSource(JSON.stringify(config.fstab.data)).init();
33
+ }
38
34
 
39
- const nvps = cbid.split(/;\s+/);
40
- for (const nv of nvps) {
41
- const [path, id] = nv.split('=');
42
- let mp = cfg.mountpoints.find((m) => m.path === path);
43
- if (mp) {
44
- mp = { ...mp };
45
- delete mp.isDocument;
46
- mp.contentBusId = id.trim();
47
- newConfig.mountpoints[path] = mp;
48
- } else {
49
- log.warn(`mountpoint in x-contentbus-id header not found in fstab: ${nv}`);
50
- }
35
+ // set contentbus id, if present in header
36
+ const cbid = response.headers.get('x-contentbus-id');
37
+ if (cbid && !config.content) {
38
+ // create the content section if not already present
39
+ config.content = {
40
+ data: Object.create(null),
41
+ };
42
+ const content = config.content.data;
43
+ const nvps = cbid.split(/;\s+/);
44
+ for (const nv of nvps) {
45
+ const [path, id] = nv.split('=');
46
+ if (!content[path]) {
47
+ content[path] = {};
51
48
  }
52
- cfg = await new MountConfig().withSource(JSON.stringify(newConfig)).init();
49
+ content[path].contentBusId = id;
53
50
  }
54
- config.fstab.data = cfg;
55
51
  }
56
52
  return config;
57
53
  }
@@ -34,6 +34,35 @@
34
34
  ],
35
35
  "additionalProperties": false
36
36
  },
37
+ "content": {
38
+ "type": "object",
39
+ "description": "Content information",
40
+ "properties": {
41
+ "lastModified": {
42
+ "description": "The last modified date",
43
+ "type": "string"
44
+ },
45
+ "data": {
46
+ "type": "object",
47
+ "patternProperties": {
48
+ "^/.*[^/]$": {
49
+ "type": "object",
50
+ "properties": {
51
+ "contentBusId": {
52
+ "type": "string"
53
+ }
54
+ },
55
+ "additionalProperties": false
56
+ }
57
+ },
58
+ "additionalProperties": false
59
+ }
60
+ },
61
+ "required": [
62
+ "data",
63
+ "lastModified"
64
+ ]
65
+ },
37
66
  "head": {
38
67
  "type": "object",
39
68
  "description": "The embedded head.html",
@@ -27,6 +27,25 @@ export interface HelixConfig {
27
27
  lastModified: string;
28
28
  data: MountConfig;
29
29
  };
30
+ /**
31
+ * Content information
32
+ */
33
+ content?: {
34
+ /**
35
+ * The last modified date
36
+ */
37
+ lastModified: string;
38
+ data: {
39
+ /**
40
+ * This interface was referenced by `undefined`'s JSON-Schema definition
41
+ * via the `patternProperty` "^/.*[^/]$".
42
+ */
43
+ [k: string]: {
44
+ contentBusId?: string;
45
+ };
46
+ };
47
+ [k: string]: unknown;
48
+ };
30
49
  /**
31
50
  * The embedded head.html
32
51
  */