@adobe/helix-admin-support 1.1.23 → 1.1.26

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,24 @@
1
+ ## [1.1.26](https://github.com/adobe/helix-admin-support/compare/v1.1.25...v1.1.26) (2022-06-02)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add optional to fetchSitemap ([#40](https://github.com/adobe/helix-admin-support/issues/40)) ([32fd509](https://github.com/adobe/helix-admin-support/commit/32fd509ab2dbb9600018b484ccd7a90dddc8996c))
7
+
8
+ ## [1.1.25](https://github.com/adobe/helix-admin-support/compare/v1.1.24...v1.1.25) (2022-05-31)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * more types ([#39](https://github.com/adobe/helix-admin-support/issues/39)) ([a87027b](https://github.com/adobe/helix-admin-support/commit/a87027ba4b9671a65564e771c870519506ff3e58))
14
+
15
+ ## [1.1.24](https://github.com/adobe/helix-admin-support/compare/v1.1.23...v1.1.24) (2022-05-31)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * update types ([#38](https://github.com/adobe/helix-admin-support/issues/38)) ([a33bd8b](https://github.com/adobe/helix-admin-support/commit/a33bd8bfa152d6fae3451f09f605eda748c7da9f))
21
+
1
22
  ## [1.1.23](https://github.com/adobe/helix-admin-support/compare/v1.1.22...v1.1.23) (2022-05-28)
2
23
 
3
24
 
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@adobe/helix-admin-support",
3
- "version": "1.1.23",
3
+ "version": "1.1.26",
4
4
  "description": "Helix Admin Support Library",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
7
+ "types": "src/index.d.ts",
7
8
  "scripts": {
8
9
  "test": "c8 mocha",
9
10
  "test-ci": "c8 mocha && codecov",
10
11
  "lint": "eslint .",
11
12
  "docs": "npx jsdoc2md -c .jsdoc.json --files 'src/*.js' > docs/API.md",
12
13
  "semantic-release": "semantic-release",
13
- "commit": "git-cz",
14
14
  "prepare": "husky install"
15
15
  },
16
16
  "repository": {
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@adobe/helix-fetch": "3.0.10",
36
- "@adobe/helix-shared-config": "2.1.1",
36
+ "@adobe/helix-shared-config": "2.1.2",
37
37
  "@adobe/helix-shared-utils": "2.0.10",
38
38
  "@aws-sdk/client-s3": "3.100.0"
39
39
  },
@@ -44,8 +44,6 @@
44
44
  "@semantic-release/npm": "9.0.1",
45
45
  "c8": "7.11.3",
46
46
  "codecov": "3.8.3",
47
- "commitizen": "4.2.4",
48
- "cz-conventional-changelog": "3.3.0",
49
47
  "eslint": "8.16.0",
50
48
  "eslint-plugin-header": "3.1.1",
51
49
  "eslint-plugin-import": "2.26.0",
@@ -62,10 +60,5 @@
62
60
  "lint-staged": {
63
61
  "*.js": "eslint",
64
62
  "*.cjs": "eslint"
65
- },
66
- "config": {
67
- "commitizen": {
68
- "path": "node_modules/cz-conventional-changelog"
69
- }
70
63
  }
71
64
  }
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Copyright 3033 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 { AdminContext, PathInfo } from './index';
13
+
14
+ /**
15
+ * Retrieves the content bus id either from the context or by reading the fstab.
16
+ * @param {AdminContext} ctx the context
17
+ * @param {PathInfo} opts lookup options
18
+ * @param {boolean} optional returns {@code null} if the contentBusId can't be computed due to
19
+ * missing fstab.
20
+ * @returns {Promise<string>} the content bus id
21
+ */
22
+ export function getContentBusId(ctx:AdminContext, opts:PathInfo, optional:boolean): Promise<string>;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2021 Adobe. All rights reserved.
2
+ * Copyright 2022 Adobe. All rights reserved.
3
3
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
4
  * you may not use this file except in compliance with the License. You may obtain a copy
5
5
  * of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -9,11 +9,12 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
+ import { AdminContext, PathInfo } from './index';
12
13
 
13
14
  /**
14
15
  * Project CDN Config
15
16
  */
16
- declare interface ProjectCDNProductionConfig {
17
+ export declare interface ProjectCDNProductionConfig {
17
18
  /**
18
19
  * cnd type
19
20
  * @enum 'fastly', 'cloudflare', 'akamai'
@@ -26,38 +27,15 @@ declare interface ProjectCDNProductionConfig {
26
27
  host:string,
27
28
 
28
29
  /**
29
- * cloudflare specific: origin
30
+ * Route or routes on the CDN that are rendered with helix
30
31
  */
31
- origin:string,
32
-
33
- /**
34
- * cloudflare specific: plan
35
- */
36
- plan:string,
37
-
38
- /**
39
- * cloudflare specific: zoneId
40
- */
41
- zoneId:string,
42
-
43
- /**
44
- * cloudflare specific: apiToken
45
- */
46
- apiToken:string,
47
- // fastly
48
- serviceId:string,
49
- authToken:string,
50
- // akamai
51
- endpoint:string,
52
- clientSecret:string,
53
- clientToken:string,
54
- accessToken:string,
32
+ route: (string|string[]),
55
33
  }
56
34
 
57
35
  /**
58
36
  * Cloudflare Config
59
37
  */
60
- declare interface CloudflareConfig extends ProjectCDNProductionConfig {
38
+ export declare interface CloudflareConfig extends ProjectCDNProductionConfig {
61
39
  origin:string,
62
40
  plan:string,
63
41
  zoneId:string,
@@ -67,7 +45,7 @@ declare interface CloudflareConfig extends ProjectCDNProductionConfig {
67
45
  /**
68
46
  * Fastly Config
69
47
  */
70
- declare interface FastlyConfig extends ProjectCDNProductionConfig {
48
+ export declare interface FastlyConfig extends ProjectCDNProductionConfig {
71
49
  serviceId:string,
72
50
  authToken:string,
73
51
  }
@@ -75,7 +53,7 @@ declare interface FastlyConfig extends ProjectCDNProductionConfig {
75
53
  /**
76
54
  * Akamai Config
77
55
  */
78
- declare interface AkamaiConfig extends ProjectCDNProductionConfig {
56
+ export declare interface AkamaiConfig extends ProjectCDNProductionConfig {
79
57
  endpoint:string,
80
58
  clientSecret:string,
81
59
  clientToken:string,
@@ -85,16 +63,35 @@ declare interface AkamaiConfig extends ProjectCDNProductionConfig {
85
63
  /**
86
64
  * Project CDN Config
87
65
  */
88
- declare interface ProjectCDNConfig {
66
+ export declare interface ProjectCDNConfig {
89
67
  prod?: (FastlyConfig|AkamaiConfig|CloudflareConfig),
90
68
  }
91
69
 
92
70
  /**
93
71
  * Project Config
94
72
  */
95
- declare interface ProjectConfig {
73
+ export declare interface ProjectConfig {
96
74
  /**
97
75
  * CDN Configuration
98
76
  */
99
77
  cdn?:ProjectCDNConfig;
78
+
79
+ /**
80
+ * project title
81
+ */
82
+ project?: string;
83
+
84
+ /**
85
+ * slack specific config
86
+ */
87
+ slack?: (string|string[]);
100
88
  }
89
+
90
+ /**
91
+ * Retrieves the project config from the underlying storage
92
+ * and stores it in the context as projectConfig.
93
+ * @param {AdminContext} ctx the context
94
+ * @param {PathInfo} info path info
95
+ * @returns {Promise<object>} the project configuration
96
+ */
97
+ export function fetchProjectConfig(ctx: AdminContext, info:PathInfo): Promise<ProjectConfig>;
@@ -0,0 +1,21 @@
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 { AdminContext, PathInfo } from './index';
13
+
14
+ /**
15
+ * Retrieves the project config from the underlying storage
16
+ * and stores it in the context as projectConfig.
17
+ * @param {AdminContext} ctx the context
18
+ * @param {PathInfo} info path info
19
+ * @returns {Promise<object>} the crontab
20
+ */
21
+ export function fetchCrontab(ctx:AdminContext, info:PathInfo): Promise<object>;
@@ -0,0 +1,22 @@
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 { MountConfig } from '@adobe/helix-shared-config';
13
+ import { AdminContext, PathInfo } from './index';
14
+
15
+ /**
16
+ * Retrieves the fstab from the underlying storage and stores it in the context as mountConfig.
17
+ * @param {AdminContext} ctx the context
18
+ * @param {PathInfo} info path info
19
+ * @param {boolean} optional if {@code true}, no error is thrown if the fstab can't be retrieved
20
+ * @returns {Promise<MountConfig>} the fstab
21
+ */
22
+ export function fetchFstab(ctx:AdminContext, info:PathInfo, optional:boolean):Promise<MountConfig>;
@@ -0,0 +1,25 @@
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 { IgnoreConfig } from '@adobe/helix-shared-config';
13
+ import { AdminContext, PathInfo } from './index';
14
+
15
+ /**
16
+ * Retrieves the hlxignore from github and stores it in the context as IgnoreConfig.
17
+ * If 404 is encountered, returns an empty IgnoreConfig that considers nothing ignored.
18
+ *
19
+ * @param {AdminContext} ctx the context
20
+ * @param {PathInfo} info lookup options
21
+ * @returns {Promise<IgnoreConfig>} the IgnoreConfig
22
+ *
23
+ * @throws
24
+ */
25
+ export function fetchIgnore(ctx:AdminContext, info:PathInfo):Promise<IgnoreConfig>;
@@ -0,0 +1,24 @@
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 { IndexConfig } from '@adobe/helix-shared-config';
13
+ import { AdminContext, PathInfo } from './index';
14
+
15
+ /**
16
+ * Retrieves the indexing configuration from the underlying storage and stores it in the context as
17
+ * indexConfig.
18
+ *
19
+ * @param {AdminContext} ctx the context
20
+ * @param {PathInfo} info path info
21
+ * @param {boolean} optional if {@code true}, no error is thrown if the config can't be retrieved
22
+ * @returns {Promise<IndexConfig>} the index config
23
+ */
24
+ export function fetchIndex(ctx:AdminContext, info:PathInfo, optional:boolean):Promise<IndexConfig>;
@@ -0,0 +1,24 @@
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 { Response } from '@adobe/helix-fetch';
13
+ import { AdminContext } from './index';
14
+
15
+ /**
16
+ * Fetches content from s3
17
+ *
18
+ * @param {AdminContext} ctx the admin context
19
+ * @param {string} bucketId bucket id
20
+ * @param {string} key the resource key
21
+ * @param {boolean} head flag indicating to create a head request
22
+ * @return {Promise<Response>} fetch api response
23
+ */
24
+ export function fetchS3(ctx:AdminContext, bucketId:string, key:string, head:boolean):Promise<Response>;
@@ -0,0 +1,22 @@
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 { SitemapConfig } from '@adobe/helix-shared-config';
13
+ import { AdminContext, PathInfo } from './index';
14
+
15
+ /**
16
+ * Retrieves the sitemap from the underlying storage and stores it in the context as sitemapConfig.
17
+ * @param {AdminContext} ctx the context
18
+ * @param {PathInfo} info path info
19
+ * @param {boolean} optional if {@code true}, no error is thrown if the config can't be retrieved
20
+ * @returns {Promise<SitemapConfig>} the sitemap configuration
21
+ */
22
+ export function fetchSitemap(ctx: AdminContext, info:PathInfo, optional:boolean):Promise<SitemapConfig>;
@@ -47,9 +47,10 @@ async function handleResponse(log, response, key, type) {
47
47
  * Retrieves the sitemap from the underlying storage and stores it in the context as sitemapConfig.
48
48
  * @param {AdminContext} ctx the context
49
49
  * @param {LookupOptions} opts lookup options
50
+ * @param {boolean} optional if {@code true}, no error is thrown if the config can't be retrieved
50
51
  * @returns {Promise<SitemapConfig>} the sitemap configuration
51
52
  */
52
- export async function fetchSitemap(ctx, opts) {
53
+ export async function fetchSitemap(ctx, opts, optional) {
53
54
  const { attributes, log } = ctx;
54
55
  const { owner, repo, ref } = opts;
55
56
 
@@ -60,7 +61,7 @@ export async function fetchSitemap(ctx, opts) {
60
61
  const key = `${owner}/${repo}/${ref}/helix-sitemap.yaml`;
61
62
  const response = await fetchS3(ctx, 'helix-code-bus', key);
62
63
  attributes.sitemapConfig = await handleResponse(log, response, key, 'code-bus');
63
- if (attributes.sitemapConfig) {
64
+ if (attributes.sitemapConfig || optional) {
64
65
  return attributes.sitemapConfig;
65
66
  }
66
67
  throw Error(`no sitemap configuration for ${key}`);
@@ -0,0 +1,56 @@
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
+
13
+ /**
14
+ * Converts a config row-based name/value pair array with dotted key notation to an object.
15
+ *
16
+ * example:
17
+ *
18
+ * ```
19
+ * host: www.adobe.com
20
+ * document.level: 42,
21
+ * document.title: hello
22
+ * document.body.status: 200
23
+ * acl.allow: /foo
24
+ * acl.allow: /bar
25
+ * cnd.0.type: fastly
26
+ * cnd.0.host: www.adobe.com
27
+ * cnd.1.type: cloudflare
28
+ * ```
29
+ *
30
+ * becomes:
31
+ *
32
+ * ```
33
+ * {
34
+ * host: 'www.adobe.com',
35
+ * document: {
36
+ * level: 42,
37
+ * title: 'hello',
38
+ * body: {
39
+ * status: 200,
40
+ * }
41
+ * },
42
+ * acl: {
43
+ * allow: ['/foo', '/bar],
44
+ * }
45
+ * cnd: [
46
+ * { type: 'fastly', host: 'www.adobe.com' },
47
+ * { type: 'cloudflare' },
48
+ * ]
49
+ * }
50
+ * ```
51
+ *
52
+ * @param {object[]} rows array of columns
53
+ * @param {string} [keyName = 'key'] name of the key column.
54
+ * @param {string} [valueName = 'value'] name of the value column.
55
+ */
56
+ export function flatJson2object(rows:object[], keyName:string, valueName:string);
package/src/index.d.ts CHANGED
@@ -9,18 +9,27 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- import {UniversalContext} from "@adobe/helix-universal";
13
- import {Credentials} from "./support/credentials";
14
- import {AuthInfo} from "./support/auth";
15
- import {ProjectConfig} from "./support/fetch-config";
16
- import {OneDrive} from "@adobe/helix-onedrive-support";
12
+ import { OneDrive } from '@adobe/helix-onedrive-support';
13
+ import { UniversalContext } from '@adobe/helix-universal';
14
+ import { ProjectConfig } from './fetch-config';
17
15
 
16
+ declare interface AuthInfo {}
18
17
  declare interface MountConfig {}
19
18
  declare interface IgnoreConfig {}
20
19
  declare interface IndexConfig {}
21
20
  declare interface SitemapConfig {}
22
21
 
23
- declare interface ErrorResponse {
22
+ export { fetchProjectConfig } from './fetch-config';
23
+ export { getContentBusId } from './contentbus';
24
+ export { fetchCrontab } from './fetch-crontab';
25
+ export { fetchFstab } from './fetch-fstab';
26
+ export { fetchIgnore } from './fetch-ignore';
27
+ export { fetchIndex } from './fetch-index';
28
+ export { fetchS3 } from './fetch-s3';
29
+ export { fetchSitemap } from './fetch-sitemap';
30
+ export { flatJson2object } from './flatJson2Object';
31
+
32
+ export declare interface ErrorResponse {
24
33
  /**
25
34
  * http like status code
26
35
  */
@@ -35,7 +44,7 @@ declare interface ErrorResponse {
35
44
  /**
36
45
  * Path Info
37
46
  */
38
- declare interface PathInfo {
47
+ export declare interface PathInfo {
39
48
  /**
40
49
  * Original path
41
50
  */
@@ -132,12 +141,7 @@ declare interface PathInfo {
132
141
  cookies?:object;
133
142
  }
134
143
 
135
- declare interface ContextAttributes {
136
-
137
- /**
138
- * optional credentials, once computed
139
- */
140
- credentials?:Credentials;
144
+ export declare interface ContextAttributes {
141
145
 
142
146
  /**
143
147
  * optional mount config, once fetched
@@ -182,7 +186,7 @@ declare interface ContextAttributes {
182
186
  /**
183
187
  * optional redirects information
184
188
  */
185
- redirects?:any;
189
+ redirects?:object;
186
190
 
187
191
  /**
188
192
  * onedrive client
@@ -192,10 +196,10 @@ declare interface ContextAttributes {
192
196
  /**
193
197
  * Notifier
194
198
  */
195
- notifier?:any;
199
+ notifier?:object;
196
200
  }
197
201
 
198
- declare interface AdminContext extends UniversalContext {
202
+ export declare interface AdminContext extends UniversalContext {
199
203
 
200
204
  /**
201
205
  * optional github token extracted from the `x-github-token` header
@@ -210,5 +214,5 @@ declare interface AdminContext extends UniversalContext {
210
214
  /**
211
215
  * context data provided via helix-shared-body
212
216
  */
213
- data?:any;
217
+ data?:object;
214
218
  }