@adobe/helix-config 3.2.1 → 3.2.3
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 +14 -0
- package/package.json +2 -2
- package/src/config-view.js +1 -1
- package/src/storage/config-store.js +1 -2
- package/src/storage/utils.js +0 -61
- package/src/utils.js +72 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [3.2.3](https://github.com/adobe/helix-config/compare/v3.2.2...v3.2.3) (2024-06-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency ajv to v8.14.0 ([c39e9d5](https://github.com/adobe/helix-config/commit/c39e9d5b66b242e5d570194d5fa97a71c0bd7f66))
|
|
7
|
+
|
|
8
|
+
## [3.2.2](https://github.com/adobe/helix-config/compare/v3.2.1...v3.2.2) (2024-05-31)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* refactor to separate imports ([#94](https://github.com/adobe/helix-config/issues/94)) ([2678381](https://github.com/adobe/helix-config/commit/26783813cf54740d10bb485ba98e442213effdf4))
|
|
14
|
+
|
|
1
15
|
## [3.2.1](https://github.com/adobe/helix-config/compare/v3.2.0...v3.2.1) (2024-05-30)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-config",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.3",
|
|
4
4
|
"description": "Helix Config",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@adobe/helix-shared-git": "3.0.9",
|
|
64
64
|
"@adobe/helix-shared-storage": "1.0.2",
|
|
65
65
|
"@adobe/helix-shared-utils": "3.0.2",
|
|
66
|
-
"ajv": "8.
|
|
66
|
+
"ajv": "8.14.0",
|
|
67
67
|
"ajv-formats": "3.0.1",
|
|
68
68
|
"jose": "5.3.0"
|
|
69
69
|
}
|
package/src/config-view.js
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from './ConfigContext.js';
|
|
22
22
|
import { resolveLegacyConfig, fetchRobotsTxt, toArray } from './config-legacy.js';
|
|
23
23
|
import { getMergedConfig } from './config-merge.js';
|
|
24
|
-
import { deepGetOrCreate } from './
|
|
24
|
+
import { deepGetOrCreate } from './utils.js';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* @typedef Config
|
|
@@ -15,13 +15,12 @@ import { HelixStorage } from '@adobe/helix-shared-storage';
|
|
|
15
15
|
import { StatusCodeError } from './status-code-error.js';
|
|
16
16
|
import {
|
|
17
17
|
createToken, createUser,
|
|
18
|
-
deepGetOrCreate,
|
|
19
|
-
deepPut,
|
|
20
18
|
migrateToken,
|
|
21
19
|
updateCodeSource,
|
|
22
20
|
updateContentSource,
|
|
23
21
|
} from './utils.js';
|
|
24
22
|
import { validate } from './config-validator.js';
|
|
23
|
+
import { deepGetOrCreate, deepPut } from '../utils.js';
|
|
25
24
|
|
|
26
25
|
const FRAGMENTS_COMMON = {
|
|
27
26
|
content: 'object',
|
package/src/storage/utils.js
CHANGED
|
@@ -15,67 +15,6 @@ import { GitUrl } from '@adobe/helix-shared-git';
|
|
|
15
15
|
import { decodeJwt } from 'jose';
|
|
16
16
|
import { StatusCodeError } from './status-code-error.js';
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* Returns the property addressed by the given path in the object.
|
|
20
|
-
* If {@code create} is {@code true}, intermediate objects will be created if they do not exist.
|
|
21
|
-
*
|
|
22
|
-
* @param {object} obj the object to search
|
|
23
|
-
* @param {string|string[]} path the path or path segments
|
|
24
|
-
* @param {boolean} create if {@code true} intermediate objects will be created if they do not exist
|
|
25
|
-
* @returns {*}
|
|
26
|
-
*/
|
|
27
|
-
export function deepGetOrCreate(obj, path, create = false) {
|
|
28
|
-
const parts = Array.isArray(path) ? path : path.split('/');
|
|
29
|
-
return parts.reduce((o, prop) => {
|
|
30
|
-
if (Array.isArray(o)) {
|
|
31
|
-
// todo: better support for arrays
|
|
32
|
-
return o.find((e) => e.id === prop);
|
|
33
|
-
} else {
|
|
34
|
-
if (create && !(prop in o)) {
|
|
35
|
-
// eslint-disable-next-line no-param-reassign
|
|
36
|
-
o[prop] = {};
|
|
37
|
-
}
|
|
38
|
-
return o[prop];
|
|
39
|
-
}
|
|
40
|
-
}, obj);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Sets the property addressed by the given path in the object.
|
|
45
|
-
* @param {object} obj the object to search
|
|
46
|
-
* @param {string|string[]} path the path or path segments
|
|
47
|
-
* @param {*} value the value to set on the object
|
|
48
|
-
* @returns {object} the passed in `obj`
|
|
49
|
-
*/
|
|
50
|
-
export function deepPut(obj, path, value) {
|
|
51
|
-
const parts = Array.isArray(path) ? path : path.split('/');
|
|
52
|
-
const last = parts.pop();
|
|
53
|
-
const parent = parts.reduce((o, prop) => {
|
|
54
|
-
if (!(prop in o)) {
|
|
55
|
-
// eslint-disable-next-line no-param-reassign
|
|
56
|
-
o[prop] = {};
|
|
57
|
-
}
|
|
58
|
-
return o[prop];
|
|
59
|
-
}, obj);
|
|
60
|
-
|
|
61
|
-
if (Array.isArray(parent)) {
|
|
62
|
-
// todo: better support for non id keys
|
|
63
|
-
const idx = parent.findIndex((e) => e.id === last);
|
|
64
|
-
if (idx >= 0 && value === null) {
|
|
65
|
-
parent.splice(idx, 1);
|
|
66
|
-
} else if (idx >= 0) {
|
|
67
|
-
parent[idx] = value;
|
|
68
|
-
} else if (value !== null) {
|
|
69
|
-
parent.push(value);
|
|
70
|
-
}
|
|
71
|
-
} else if (value === null) {
|
|
72
|
-
delete parent[last];
|
|
73
|
-
} else {
|
|
74
|
-
parent[last] = value;
|
|
75
|
-
}
|
|
76
|
-
return obj;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
18
|
/**
|
|
80
19
|
* Update the contentBusId field of the content object based on the source URL.
|
|
81
20
|
* @param ctx
|
package/src/utils.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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
|
+
* Returns the property addressed by the given path in the object.
|
|
15
|
+
* If {@code create} is {@code true}, intermediate objects will be created if they do not exist.
|
|
16
|
+
*
|
|
17
|
+
* @param {object} obj the object to search
|
|
18
|
+
* @param {string|string[]} path the path or path segments
|
|
19
|
+
* @param {boolean} create if {@code true} intermediate objects will be created if they do not exist
|
|
20
|
+
* @returns {*}
|
|
21
|
+
*/
|
|
22
|
+
export function deepGetOrCreate(obj, path, create = false) {
|
|
23
|
+
const parts = Array.isArray(path) ? path : path.split('/');
|
|
24
|
+
return parts.reduce((o, prop) => {
|
|
25
|
+
if (Array.isArray(o)) {
|
|
26
|
+
// todo: better support for arrays
|
|
27
|
+
return o.find((e) => e.id === prop);
|
|
28
|
+
} else {
|
|
29
|
+
if (create && !(prop in o)) {
|
|
30
|
+
// eslint-disable-next-line no-param-reassign
|
|
31
|
+
o[prop] = {};
|
|
32
|
+
}
|
|
33
|
+
return o[prop];
|
|
34
|
+
}
|
|
35
|
+
}, obj);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Sets the property addressed by the given path in the object.
|
|
40
|
+
* @param {object} obj the object to search
|
|
41
|
+
* @param {string|string[]} path the path or path segments
|
|
42
|
+
* @param {*} value the value to set on the object
|
|
43
|
+
* @returns {object} the passed in `obj`
|
|
44
|
+
*/
|
|
45
|
+
export function deepPut(obj, path, value) {
|
|
46
|
+
const parts = Array.isArray(path) ? path : path.split('/');
|
|
47
|
+
const last = parts.pop();
|
|
48
|
+
const parent = parts.reduce((o, prop) => {
|
|
49
|
+
if (!(prop in o)) {
|
|
50
|
+
// eslint-disable-next-line no-param-reassign
|
|
51
|
+
o[prop] = {};
|
|
52
|
+
}
|
|
53
|
+
return o[prop];
|
|
54
|
+
}, obj);
|
|
55
|
+
|
|
56
|
+
if (Array.isArray(parent)) {
|
|
57
|
+
// todo: better support for non id keys
|
|
58
|
+
const idx = parent.findIndex((e) => e.id === last);
|
|
59
|
+
if (idx >= 0 && value === null) {
|
|
60
|
+
parent.splice(idx, 1);
|
|
61
|
+
} else if (idx >= 0) {
|
|
62
|
+
parent[idx] = value;
|
|
63
|
+
} else if (value !== null) {
|
|
64
|
+
parent.push(value);
|
|
65
|
+
}
|
|
66
|
+
} else if (value === null) {
|
|
67
|
+
delete parent[last];
|
|
68
|
+
} else {
|
|
69
|
+
parent[last] = value;
|
|
70
|
+
}
|
|
71
|
+
return obj;
|
|
72
|
+
}
|