@adobe/helix-admin-support 1.1.39 → 1.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 +21 -0
- package/package.json +2 -2
- package/src/fetch-config-all.d.ts +53 -0
- package/src/fetch-config-all.js +73 -0
- package/src/fetch-config.js +2 -2
- package/src/index.d.ts +17 -9
- package/src/index.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
# [1.3.0](https://github.com/adobe/helix-admin-support/compare/v1.2.1...v1.3.0) (2022-08-13)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* improve exports ([#58](https://github.com/adobe/helix-admin-support/issues/58)) ([283d642](https://github.com/adobe/helix-admin-support/commit/283d642f07397dc3d7149887713d2b8350e7f938))
|
|
7
|
+
|
|
8
|
+
## [1.2.1](https://github.com/adobe/helix-admin-support/compare/v1.2.0...v1.2.1) (2022-08-12)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** update dependency @adobe/helix-shared-config to v8.3.0 ([21fcd47](https://github.com/adobe/helix-admin-support/commit/21fcd472b9bd66fdcb3f0a6ddb41efca25ec3ba0))
|
|
14
|
+
|
|
15
|
+
# [1.2.0](https://github.com/adobe/helix-admin-support/compare/v1.1.39...v1.2.0) (2022-08-11)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* add fetch-config-all ([#57](https://github.com/adobe/helix-admin-support/issues/57)) ([cb5adef](https://github.com/adobe/helix-admin-support/commit/cb5adef3eb52448091ba27fed3f98950b31a2bca))
|
|
21
|
+
|
|
1
22
|
## [1.1.39](https://github.com/adobe/helix-admin-support/compare/v1.1.38...v1.1.39) (2022-08-07)
|
|
2
23
|
|
|
3
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-admin-support",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Helix Admin Support Library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@adobe/helix-fetch": "3.1.2",
|
|
35
|
-
"@adobe/helix-shared-config": "8.
|
|
35
|
+
"@adobe/helix-shared-config": "8.3.0",
|
|
36
36
|
"@adobe/helix-shared-utils": "2.0.11",
|
|
37
37
|
"@aws-sdk/client-s3": "3.142.0"
|
|
38
38
|
},
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { ModifierMap } from '@adobe/helix-shared-config';
|
|
13
|
+
import {AdminContext, PathInfo} from './index';
|
|
14
|
+
import { ProjectConfig } from './fetch-config';
|
|
15
|
+
|
|
16
|
+
export declare interface ProjectConfigEntry {
|
|
17
|
+
data: ProjectConfig;
|
|
18
|
+
lastModified: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export declare interface ModifierConfigEntry {
|
|
22
|
+
data: ModifierMap;
|
|
23
|
+
lastModified: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Combine config stored in /.helix/config-all.json
|
|
28
|
+
*/
|
|
29
|
+
export declare interface ConfigAll {
|
|
30
|
+
/**
|
|
31
|
+
* Project config (from /.helix/config.json)
|
|
32
|
+
*/
|
|
33
|
+
config?:ProjectConfigEntry;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Metadata (from /metadata.json)
|
|
37
|
+
*/
|
|
38
|
+
metadata?:ModifierConfigEntry;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Headers modifier (from /.helix/config.json)
|
|
42
|
+
*/
|
|
43
|
+
headers?:ModifierConfigEntry;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Retrieves the project config from the underlying storage
|
|
48
|
+
* and stores it in the context as projectConfig.
|
|
49
|
+
* @param {AdminContext} ctx the context
|
|
50
|
+
* @param {PathInfo} info path info
|
|
51
|
+
* @returns {Promise<ConfigAll>} the project configuration
|
|
52
|
+
*/
|
|
53
|
+
export function fetchConfigAll(ctx: AdminContext, info:PathInfo): Promise<ConfigAll>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2021 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { logLevelForStatusCode, propagateStatusCode } from '@adobe/helix-shared-utils';
|
|
13
|
+
import { fetchS3 } from './fetch-s3.js';
|
|
14
|
+
import { getContentBusId } from './contentbus.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Checks if the response is valid and returns the project config.
|
|
18
|
+
*
|
|
19
|
+
* @param {Console} log logger
|
|
20
|
+
* @param {Response} response content response from the storage
|
|
21
|
+
* @param {string} key storage key (logging information)
|
|
22
|
+
* @param {string} type type of storage (logging information)
|
|
23
|
+
* @returns {Promise<ConfigAll>} the helix project config or null
|
|
24
|
+
*/
|
|
25
|
+
async function handleResponse(log, response, key, type) {
|
|
26
|
+
const text = await response.text();
|
|
27
|
+
if (response.ok) {
|
|
28
|
+
try {
|
|
29
|
+
return JSON.parse(text);
|
|
30
|
+
// eslint-disable-next-line no-empty
|
|
31
|
+
} catch { }
|
|
32
|
+
log.info(`Empty or invalid /.helix/config-all.json found in ${type} ${key}`);
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (response.status === 404) {
|
|
37
|
+
log.info(`No /.helix/config-all.json found in ${type} ${key}, ${text}`);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
log[logLevelForStatusCode(response.status)](
|
|
42
|
+
`Invalid response (${response.status}) when fetching config-all from ${type} ${key}`,
|
|
43
|
+
);
|
|
44
|
+
const err = new Error(`Unable to fetch config-all: ${response.status} ${text}`);
|
|
45
|
+
err.status = propagateStatusCode(response.status);
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves the project config from the underlying storage
|
|
51
|
+
* and stores it in the context as projectConfig.
|
|
52
|
+
* @param {AdminContext} ctx the context
|
|
53
|
+
* @param {PathInfo} opts lookup options
|
|
54
|
+
* @returns {Promise<ConfigAll>} the project configuration
|
|
55
|
+
*/
|
|
56
|
+
export async function fetchConfigAll(ctx, opts) {
|
|
57
|
+
const { log, attributes } = ctx;
|
|
58
|
+
const partition = opts.route === 'preview' || opts.route === 'live' ? opts.route : 'preview';
|
|
59
|
+
const getConfig = async () => {
|
|
60
|
+
const contentBusId = await getContentBusId(ctx, opts, true);
|
|
61
|
+
if (!contentBusId) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
const key = `${contentBusId}/${partition}/.helix/config-all.json`;
|
|
65
|
+
const response = await fetchS3(ctx, 'helix-content-bus', key);
|
|
66
|
+
return handleResponse(log, response, key, 'content-bus');
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
if (attributes.configAll === undefined) {
|
|
70
|
+
attributes.configAll = await getConfig();
|
|
71
|
+
}
|
|
72
|
+
return attributes.configAll;
|
|
73
|
+
}
|
package/src/fetch-config.js
CHANGED
|
@@ -56,8 +56,8 @@ async function handleResponse(log, response, key, type) {
|
|
|
56
56
|
* Retrieves the project config from the underlying storage
|
|
57
57
|
* and stores it in the context as projectConfig.
|
|
58
58
|
* @param {AdminContext} ctx the context
|
|
59
|
-
* @param {
|
|
60
|
-
* @returns {Promise<
|
|
59
|
+
* @param {PathInfo} opts lookup options
|
|
60
|
+
* @returns {Promise<ProjectConfig>} the project configuration
|
|
61
61
|
*/
|
|
62
62
|
export async function fetchProjectConfig(ctx, opts) {
|
|
63
63
|
const { log, attributes } = ctx;
|
package/src/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { OneDrive } from '@adobe/helix-onedrive-support';
|
|
13
13
|
import { UniversalContext } from '@adobe/helix-universal';
|
|
14
14
|
import { ProjectConfig } from './fetch-config';
|
|
15
|
+
import { ConfigAll } from "./fetch-config-all";
|
|
15
16
|
|
|
16
17
|
declare interface AuthInfo {}
|
|
17
18
|
declare interface MountConfig {}
|
|
@@ -19,15 +20,16 @@ declare interface IgnoreConfig {}
|
|
|
19
20
|
declare interface IndexConfig {}
|
|
20
21
|
declare interface SitemapConfig {}
|
|
21
22
|
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
23
|
+
export * from './fetch-config-all';
|
|
24
|
+
export * from './fetch-config';
|
|
25
|
+
export * from './contentbus';
|
|
26
|
+
export * from './fetch-crontab';
|
|
27
|
+
export * from './fetch-fstab';
|
|
28
|
+
export * from './fetch-ignore';
|
|
29
|
+
export * from './fetch-index';
|
|
30
|
+
export * from './fetch-s3';
|
|
31
|
+
export * from './fetch-sitemap';
|
|
32
|
+
export * from './flatJson2Object';
|
|
31
33
|
|
|
32
34
|
export declare interface ErrorResponse {
|
|
33
35
|
/**
|
|
@@ -197,6 +199,11 @@ export declare interface ContextAttributes {
|
|
|
197
199
|
* Notifier
|
|
198
200
|
*/
|
|
199
201
|
notifier?:object;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* combined config
|
|
205
|
+
*/
|
|
206
|
+
configAll?:ConfigAll;
|
|
200
207
|
}
|
|
201
208
|
|
|
202
209
|
export declare interface AdminContext extends UniversalContext {
|
|
@@ -216,3 +223,4 @@ export declare interface AdminContext extends UniversalContext {
|
|
|
216
223
|
*/
|
|
217
224
|
data?:object;
|
|
218
225
|
}
|
|
226
|
+
|