@adobe/helix-admin-support 1.1.24 → 1.1.27

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.27](https://github.com/adobe/helix-admin-support/compare/v1.1.26...v1.1.27) (2022-06-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update adobe fixes ([745c9a8](https://github.com/adobe/helix-admin-support/commit/745c9a83f669a902177a5c8becfa9a514d299ba1))
7
+
8
+ ## [1.1.26](https://github.com/adobe/helix-admin-support/compare/v1.1.25...v1.1.26) (2022-06-02)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add optional to fetchSitemap ([#40](https://github.com/adobe/helix-admin-support/issues/40)) ([32fd509](https://github.com/adobe/helix-admin-support/commit/32fd509ab2dbb9600018b484ccd7a90dddc8996c))
14
+
15
+ ## [1.1.25](https://github.com/adobe/helix-admin-support/compare/v1.1.24...v1.1.25) (2022-05-31)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * more types ([#39](https://github.com/adobe/helix-admin-support/issues/39)) ([a87027b](https://github.com/adobe/helix-admin-support/commit/a87027ba4b9671a65564e771c870519506ff3e58))
21
+
1
22
  ## [1.1.24](https://github.com/adobe/helix-admin-support/compare/v1.1.23...v1.1.24) (2022-05-31)
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.24",
3
+ "version": "1.1.27",
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,8 +33,8 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@adobe/helix-fetch": "3.0.10",
36
- "@adobe/helix-shared-config": "2.1.1",
37
- "@adobe/helix-shared-utils": "2.0.10",
36
+ "@adobe/helix-shared-config": "2.1.3",
37
+ "@adobe/helix-shared-utils": "2.0.11",
38
38
  "@aws-sdk/client-s3": "3.100.0"
39
39
  },
40
40
  "devDependencies": {
@@ -44,28 +44,21 @@
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
- "eslint": "8.16.0",
47
+ "eslint": "8.17.0",
50
48
  "eslint-plugin-header": "3.1.1",
51
49
  "eslint-plugin-import": "2.26.0",
52
50
  "husky": "8.0.1",
53
51
  "jsdoc-to-markdown": "7.1.1",
54
52
  "junit-report-builder": "3.0.0",
55
- "lint-staged": "12.4.2",
53
+ "lint-staged": "12.5.0",
56
54
  "mocha": "10.0.0",
57
55
  "mocha-multi-reporters": "1.5.1",
58
- "nock": "13.2.4",
56
+ "nock": "13.2.6",
59
57
  "semantic-release": "19.0.2",
60
- "yaml": "2.1.0"
58
+ "yaml": "2.1.1"
61
59
  },
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,8 +9,7 @@
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
-
13
- import {AdminContext, PathInfo} from './index';
12
+ import { AdminContext, PathInfo } from './index';
14
13
 
15
14
  /**
16
15
  * Project CDN Config
@@ -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,9 +9,9 @@
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 {OneDrive} from '@adobe/helix-onedrive-support';
13
- import {UniversalContext} from '@adobe/helix-universal';
14
- import {ProjectConfig} from './fetch-config';
12
+ import { OneDrive } from '@adobe/helix-onedrive-support';
13
+ import { UniversalContext } from '@adobe/helix-universal';
14
+ import { ProjectConfig } from './fetch-config';
15
15
 
16
16
  declare interface AuthInfo {}
17
17
  declare interface MountConfig {}
@@ -19,16 +19,17 @@ declare interface IgnoreConfig {}
19
19
  declare interface IndexConfig {}
20
20
  declare interface SitemapConfig {}
21
21
 
22
- export * from './fetch-config'
23
- export * from './fetch-crontab'
24
- export * from './fetch-fstab'
25
- export * from './fetch-ignore'
26
- export * from './fetch-index'
27
- export * from './fetch-s3'
28
- export * from './fetch-sitemap'
29
- export * from './flatJson2Object'
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';
30
31
 
31
- declare interface ErrorResponse {
32
+ export declare interface ErrorResponse {
32
33
  /**
33
34
  * http like status code
34
35
  */
@@ -43,7 +44,7 @@ declare interface ErrorResponse {
43
44
  /**
44
45
  * Path Info
45
46
  */
46
- declare interface PathInfo {
47
+ export declare interface PathInfo {
47
48
  /**
48
49
  * Original path
49
50
  */
@@ -140,7 +141,7 @@ declare interface PathInfo {
140
141
  cookies?:object;
141
142
  }
142
143
 
143
- declare interface ContextAttributes {
144
+ export declare interface ContextAttributes {
144
145
 
145
146
  /**
146
147
  * optional mount config, once fetched
@@ -185,7 +186,7 @@ declare interface ContextAttributes {
185
186
  /**
186
187
  * optional redirects information
187
188
  */
188
- redirects?:any;
189
+ redirects?:object;
189
190
 
190
191
  /**
191
192
  * onedrive client
@@ -195,10 +196,10 @@ declare interface ContextAttributes {
195
196
  /**
196
197
  * Notifier
197
198
  */
198
- notifier?:any;
199
+ notifier?:object;
199
200
  }
200
201
 
201
- declare interface AdminContext extends UniversalContext {
202
+ export declare interface AdminContext extends UniversalContext {
202
203
 
203
204
  /**
204
205
  * optional github token extracted from the `x-github-token` header
@@ -213,5 +214,5 @@ declare interface AdminContext extends UniversalContext {
213
214
  /**
214
215
  * context data provided via helix-shared-body
215
216
  */
216
- data?:any;
217
+ data?:object;
217
218
  }