@adobe/helix-config 3.7.1 → 3.9.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 +14 -0
- package/package.json +1 -1
- package/src/storage/config-store.js +14 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [3.9.0](https://github.com/adobe/helix-config/compare/v3.8.0...v3.9.0) (2024-07-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* also include ctx ([#140](https://github.com/adobe/helix-config/issues/140)) ([6c29c54](https://github.com/adobe/helix-config/commit/6c29c541ccacc6740d60f577889f5064ec6c29c4))
|
|
7
|
+
|
|
8
|
+
# [3.8.0](https://github.com/adobe/helix-config/compare/v3.7.1...v3.8.0) (2024-07-18)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* make ConfigStore.validate() overridable ([#139](https://github.com/adobe/helix-config/issues/139)) ([6a85c7f](https://github.com/adobe/helix-config/commit/6a85c7fbefb3687c8c4f8ae2117886507192aaac))
|
|
14
|
+
|
|
1
15
|
## [3.7.1](https://github.com/adobe/helix-config/compare/v3.7.0...v3.7.1) (2024-07-17)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
updateCodeSource,
|
|
20
20
|
updateContentSource,
|
|
21
21
|
} from './utils.js';
|
|
22
|
-
import { validate } from './config-validator.js';
|
|
22
|
+
import { validate as validateSchema } from './config-validator.js';
|
|
23
23
|
import { deepGetOrCreate, deepPut } from '../utils.js';
|
|
24
24
|
|
|
25
25
|
const FRAGMENTS_COMMON = {
|
|
@@ -177,6 +177,16 @@ export class ConfigStore {
|
|
|
177
177
|
: `/orgs/${this.org}/${this.type}/${this.name}.json`;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
+
/**
|
|
181
|
+
* Validates the config and throws an error if not valid.
|
|
182
|
+
* @param {AdminContext} ctx
|
|
183
|
+
* @param {HelixSiteConfig|HelixProfileConfig} data the data of the config to be updated
|
|
184
|
+
* @returns {Promise<boolean|undefined>}
|
|
185
|
+
*/
|
|
186
|
+
async validate(ctx, data) {
|
|
187
|
+
return validateSchema(data, this.type);
|
|
188
|
+
}
|
|
189
|
+
|
|
180
190
|
async create(ctx, data, relPath = '') {
|
|
181
191
|
if (relPath) {
|
|
182
192
|
throw new StatusCodeError(409, 'create not supported on substructures.');
|
|
@@ -195,7 +205,7 @@ export class ConfigStore {
|
|
|
195
205
|
updateContentSource(ctx, data.content);
|
|
196
206
|
updateCodeSource(ctx, data.code);
|
|
197
207
|
}
|
|
198
|
-
await validate(
|
|
208
|
+
await this.validate(ctx, data);
|
|
199
209
|
await storage.put(this.key, JSON.stringify(data), 'application/json');
|
|
200
210
|
await this.purge(ctx, null, data);
|
|
201
211
|
}
|
|
@@ -315,7 +325,7 @@ export class ConfigStore {
|
|
|
315
325
|
updateContentSource(ctx, config.content);
|
|
316
326
|
updateCodeSource(ctx, config.code);
|
|
317
327
|
}
|
|
318
|
-
await validate(
|
|
328
|
+
await this.validate(ctx, config);
|
|
319
329
|
await storage.put(this.key, JSON.stringify(config), 'application/json');
|
|
320
330
|
await this.purge(ctx, buf ? JSON.parse(buf) : null, config);
|
|
321
331
|
return ret ?? redact(data, frag);
|
|
@@ -330,7 +340,7 @@ export class ConfigStore {
|
|
|
330
340
|
const frag = getFragmentInfo(this.type, relPath);
|
|
331
341
|
if (frag) {
|
|
332
342
|
const data = deepPut(JSON.parse(buf), relPath, null);
|
|
333
|
-
await validate(
|
|
343
|
+
await this.validate(ctx, data);
|
|
334
344
|
await storage.put(this.key, JSON.stringify(data), 'application/json');
|
|
335
345
|
await this.purge(ctx, JSON.parse(buf), data);
|
|
336
346
|
return;
|