@adobe/helix-admin-support 2.7.3 → 2.8.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,10 @@
1
+ # [2.8.0](https://github.com/adobe/helix-admin-support/compare/v2.7.3...v2.8.0) (2024-04-16)
2
+
3
+
4
+ ### Features
5
+
6
+ * load index/sitemap from content-bus first ([#253](https://github.com/adobe/helix-admin-support/issues/253)) ([e3e9b94](https://github.com/adobe/helix-admin-support/commit/e3e9b94981356878c1f81559a3700eeb1afc75ab))
7
+
1
8
  ## [2.7.3](https://github.com/adobe/helix-admin-support/compare/v2.7.2...v2.7.3) (2024-04-13)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-admin-support",
3
- "version": "2.7.3",
3
+ "version": "2.8.0",
4
4
  "description": "Helix Admin Support Library",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -39,7 +39,7 @@
39
39
  "@adobe/helix-shared-utils": "3.0.1",
40
40
  "@aws-sdk/client-s3": "3.554.0",
41
41
  "@aws-sdk/client-sqs": "3.554.0",
42
- "@aws-sdk/node-http-handler": "3.374.0"
42
+ "@smithy/node-http-handler": "2.5.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@adobe/eslint-config-helix": "2.0.6",
@@ -58,6 +58,7 @@
58
58
  "mocha-multi-reporters": "1.5.1",
59
59
  "nock": "13.5.4",
60
60
  "semantic-release": "22.0.12",
61
+ "xml2js": "0.6.2",
61
62
  "yaml": "2.4.1"
62
63
  },
63
64
  "lint-staged": {
@@ -12,13 +12,18 @@
12
12
  import { logLevelForStatusCode, propagateStatusCode } from '@adobe/helix-shared-utils';
13
13
  import { IndexConfig } from '@adobe/helix-shared-config';
14
14
  import { fetchS3 } from './fetch-s3.js';
15
- import { fetch } from './utils.js';
15
+ import { getContentBusId } from './contentbus.js';
16
16
 
17
17
  /**
18
18
  * Name of the indexing configuration, subject to be renamed.
19
19
  */
20
20
  export const INDEX_CONFIGURATION_NAME = 'helix-query.yaml';
21
21
 
22
+ /**
23
+ * Location of the indexing configuration in the content-bus.
24
+ */
25
+ const INDEX_LOCATION = 'preview/.helix/query.yaml';
26
+
22
27
  /**
23
28
  * Checks if the response is valid and returns an index config.
24
29
  *
@@ -55,33 +60,28 @@ async function handleResponse(log, response, key, type) {
55
60
  * @returns {Promise<IndexConfig>} the index config
56
61
  */
57
62
  export async function fetchIndex(ctx, opts, optional) {
58
- const { attributes, log, env = {} } = ctx;
63
+ const { attributes, log } = ctx;
59
64
  const { owner, repo } = opts;
60
65
 
61
66
  if (attributes.indexConfig !== undefined) {
62
67
  return attributes.indexConfig;
63
68
  }
64
69
 
65
- const key = `${owner}/${repo}/main/${INDEX_CONFIGURATION_NAME}`;
66
- let response = await fetchS3(ctx, 'helix-code-bus', key);
67
- attributes.indexConfig = await handleResponse(log, response, key, 'code-bus');
68
- if (attributes.indexConfig) {
69
- return attributes.indexConfig;
70
+ const contentBusId = await getContentBusId(ctx, opts, optional);
71
+ if (!contentBusId) {
72
+ return null;
70
73
  }
71
74
 
72
- // try loading from github for non helix-3 repos
73
- const headers = {};
74
- if (ctx.githubToken) {
75
- headers.authorization = `token ${ctx.githubToken}`;
75
+ let key = `${contentBusId}/${INDEX_LOCATION}`;
76
+ let response = await fetchS3(ctx, 'helix-content-bus', key);
77
+ attributes.indexConfig = await handleResponse(log, response, key, 'content-bus');
78
+ if (attributes.indexConfig) {
79
+ return attributes.indexConfig;
76
80
  }
77
- const { GH_RAW_URL = 'https://raw.githubusercontent.com' } = env;
78
-
79
- response = await fetch(`${GH_RAW_URL}/${key}`, {
80
- cache: 'no-store',
81
- headers,
82
- });
83
- attributes.indexConfig = await handleResponse(log, response, key, 'github');
84
81
 
82
+ key = `${owner}/${repo}/main/${INDEX_CONFIGURATION_NAME}`;
83
+ response = await fetchS3(ctx, 'helix-code-bus', key);
84
+ attributes.indexConfig = await handleResponse(log, response, key, 'code-bus');
85
85
  if (attributes.indexConfig || optional) {
86
86
  return attributes.indexConfig;
87
87
  }
package/src/fetch-s3.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  HeadObjectCommand,
19
19
  NoSuchKey,
20
20
  } from '@aws-sdk/client-s3';
21
- import { NodeHttpHandler } from '@aws-sdk/node-http-handler';
21
+ import { NodeHttpHandler } from '@smithy/node-http-handler';
22
22
 
23
23
  const gunzip = promisify(zlib.gunzip);
24
24
 
@@ -12,6 +12,12 @@
12
12
  import { logLevelForStatusCode, propagateStatusCode } from '@adobe/helix-shared-utils';
13
13
  import { SitemapConfig } from '@adobe/helix-shared-config';
14
14
  import { fetchS3 } from './fetch-s3.js';
15
+ import { getContentBusId } from './contentbus.js';
16
+
17
+ /**
18
+ * Location of the sitemap configuration in the content-bus.
19
+ */
20
+ const SITEMAP_LOCATION = 'preview/.helix/sitemap.yaml';
15
21
 
16
22
  /**
17
23
  * Checks if the response is valid and returns a sitemap config.
@@ -58,8 +64,20 @@ export async function fetchSitemap(ctx, opts, optional) {
58
64
  return attributes.sitemapConfig;
59
65
  }
60
66
 
61
- const key = `${owner}/${repo}/main/helix-sitemap.yaml`;
62
- const response = await fetchS3(ctx, 'helix-code-bus', key);
67
+ const contentBusId = await getContentBusId(ctx, opts, optional);
68
+ if (!contentBusId) {
69
+ return null;
70
+ }
71
+
72
+ let key = `${contentBusId}/${SITEMAP_LOCATION}`;
73
+ let response = await fetchS3(ctx, 'helix-content-bus', key);
74
+ attributes.sitemapConfig = await handleResponse(log, response, key, 'content-bus');
75
+ if (attributes.sitemapConfig) {
76
+ return attributes.sitemapConfig;
77
+ }
78
+
79
+ key = `${owner}/${repo}/main/helix-sitemap.yaml`;
80
+ response = await fetchS3(ctx, 'helix-code-bus', key);
63
81
  attributes.sitemapConfig = await handleResponse(log, response, key, 'code-bus');
64
82
  if (attributes.sitemapConfig || optional) {
65
83
  return attributes.sitemapConfig;