@adobe/helix-config-storage 1.7.14 → 1.8.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
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.8.0](https://github.com/adobe/helix-config-storage/compare/v1.7.14...v1.8.0) (2024-10-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* store created and lastModified in configs ([#45](https://github.com/adobe/helix-config-storage/issues/45)) ([f3d7b83](https://github.com/adobe/helix-config-storage/commit/f3d7b83f17cf80defe28b640c60a9cb50abfb392))
|
|
7
|
+
|
|
1
8
|
## [1.7.14](https://github.com/adobe/helix-config-storage/compare/v1.7.13...v1.7.14) (2024-10-09)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/config-merge.js
CHANGED
package/src/config-store.js
CHANGED
|
@@ -232,6 +232,19 @@ export class ConfigStore {
|
|
|
232
232
|
this.key = type === 'org'
|
|
233
233
|
? `/orgs/${org}/${name || 'config'}.json`
|
|
234
234
|
: `/orgs/${org}/${type}/${name}.json`;
|
|
235
|
+
this.now = new Date();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* updates the created and lastModified time stamp on the data object to the current time.
|
|
240
|
+
* the created property is only set if it doesn't exist yet.
|
|
241
|
+
* @param {object} data
|
|
242
|
+
*/
|
|
243
|
+
#updateTimeStamps(data) {
|
|
244
|
+
data.lastModified = this.now.toISOString();
|
|
245
|
+
if (!data.created) {
|
|
246
|
+
data.created = data.lastModified;
|
|
247
|
+
}
|
|
235
248
|
}
|
|
236
249
|
|
|
237
250
|
async #list(ctx) {
|
|
@@ -308,6 +321,9 @@ export class ConfigStore {
|
|
|
308
321
|
updateContentSource(ctx, data.content);
|
|
309
322
|
updateCodeSource(ctx, data.code);
|
|
310
323
|
}
|
|
324
|
+
// we don't allow to define created
|
|
325
|
+
delete data.created;
|
|
326
|
+
this.#updateTimeStamps(data);
|
|
311
327
|
const config = await this.getAggregatedConfig(ctx, data);
|
|
312
328
|
await this.validate(ctx, config);
|
|
313
329
|
await storage.put(this.key, JSON.stringify(data), 'application/json');
|
|
@@ -424,6 +440,8 @@ export class ConfigStore {
|
|
|
424
440
|
updateCodeSource(ctx, config.code);
|
|
425
441
|
}
|
|
426
442
|
let oldConfig = buf ? JSON.parse(buf) : null;
|
|
443
|
+
config.created = oldConfig?.created;
|
|
444
|
+
this.#updateTimeStamps(config);
|
|
427
445
|
let newConfig = config;
|
|
428
446
|
if (this.type === 'sites') {
|
|
429
447
|
// apply profile
|
|
@@ -452,6 +470,7 @@ export class ConfigStore {
|
|
|
452
470
|
|
|
453
471
|
if (frag) {
|
|
454
472
|
const data = deepPut(JSON.parse(buf), relPath, null);
|
|
473
|
+
this.#updateTimeStamps(data);
|
|
455
474
|
const newConfig = await this.getAggregatedConfig(ctx, data);
|
|
456
475
|
await this.validate(ctx, newConfig);
|
|
457
476
|
await storage.put(this.key, JSON.stringify(data), 'application/json');
|
|
@@ -11,6 +11,16 @@
|
|
|
11
11
|
"type": "string",
|
|
12
12
|
"description": "description for clarity. has no influence on the configuration."
|
|
13
13
|
},
|
|
14
|
+
"created": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"format": "date-time",
|
|
17
|
+
"description": "the date and time this configuration was created."
|
|
18
|
+
},
|
|
19
|
+
"lastModified": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"format": "date-time",
|
|
22
|
+
"description": "the date and time this configuration was modified last."
|
|
23
|
+
},
|
|
14
24
|
"keyValuePair": {
|
|
15
25
|
"type": "object",
|
|
16
26
|
"properties": {
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
"enum": [1],
|
|
11
11
|
"default": 1
|
|
12
12
|
},
|
|
13
|
+
"created": { "$ref": "https://ns.adobe.com/helix/config/common#/definitions/created" },
|
|
14
|
+
"lastModified": { "$ref": "https://ns.adobe.com/helix/config/common#/definitions/lastModified" },
|
|
13
15
|
"title": { "$ref": "https://ns.adobe.com/helix/config/common#/definitions/title" },
|
|
14
16
|
"description": { "$ref": "https://ns.adobe.com/helix/config/common#/definitions/description" },
|
|
15
17
|
"users": {
|
|
@@ -26,7 +28,9 @@
|
|
|
26
28
|
}
|
|
27
29
|
},
|
|
28
30
|
"required": [
|
|
29
|
-
"version"
|
|
31
|
+
"version",
|
|
32
|
+
"created",
|
|
33
|
+
"lastModified"
|
|
30
34
|
],
|
|
31
35
|
"additionalProperties": false
|
|
32
36
|
}
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
},
|
|
13
13
|
"title": { "$ref": "https://ns.adobe.com/helix/config/common#/definitions/title" },
|
|
14
14
|
"description": { "$ref": "https://ns.adobe.com/helix/config/common#/definitions/description" },
|
|
15
|
-
|
|
15
|
+
"created": { "$ref": "https://ns.adobe.com/helix/config/common#/definitions/created" },
|
|
16
|
+
"lastModified": { "$ref": "https://ns.adobe.com/helix/config/common#/definitions/lastModified" },
|
|
16
17
|
"content": {
|
|
17
18
|
"$ref": "https://ns.adobe.com/helix/config/content"
|
|
18
19
|
},
|
|
@@ -51,7 +52,9 @@
|
|
|
51
52
|
}
|
|
52
53
|
},
|
|
53
54
|
"required": [
|
|
54
|
-
"version"
|
|
55
|
+
"version",
|
|
56
|
+
"created",
|
|
57
|
+
"lastModified"
|
|
55
58
|
],
|
|
56
59
|
"additionalProperties": false
|
|
57
60
|
}
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"title": { "$ref": "https://ns.adobe.com/helix/config/common#/definitions/title" },
|
|
19
19
|
"description": { "$ref": "https://ns.adobe.com/helix/config/common#/definitions/description" },
|
|
20
|
+
"created": { "$ref": "https://ns.adobe.com/helix/config/common#/definitions/created" },
|
|
21
|
+
"lastModified": { "$ref": "https://ns.adobe.com/helix/config/common#/definitions/lastModified" },
|
|
20
22
|
|
|
21
23
|
"content": {
|
|
22
24
|
"$ref": "https://ns.adobe.com/helix/config/content"
|
|
@@ -68,7 +70,9 @@
|
|
|
68
70
|
"required": [
|
|
69
71
|
"version",
|
|
70
72
|
"content",
|
|
71
|
-
"code"
|
|
73
|
+
"code",
|
|
74
|
+
"created",
|
|
75
|
+
"lastModified"
|
|
72
76
|
],
|
|
73
77
|
"additionalProperties": false
|
|
74
78
|
}
|