@toa.io/norm 1.0.0-alpha.286 → 1.0.0-alpha.287
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
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# [1.0.0-alpha.287](https://github.com/toa-io/toa/compare/v1.0.0-alpha.286...v1.0.0-alpha.287) (2026-09-06)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @toa.io/norm
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/norm",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.287",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Toa declarations normalization and validation",
|
|
6
6
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@toa.io/core": "1.0.0-alpha.
|
|
24
|
+
"@toa.io/core": "1.0.0-alpha.287",
|
|
25
25
|
"@toa.io/generic": "1.0.0-alpha.286",
|
|
26
|
-
"@toa.io/schemas": "1.0.0-alpha.
|
|
26
|
+
"@toa.io/schemas": "1.0.0-alpha.287",
|
|
27
27
|
"fast-glob": "3.3.3",
|
|
28
28
|
"js-yaml": "5.4.1"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "5c7944a70c16065ab6372072385cc1f02f5db77c"
|
|
31
31
|
}
|
|
@@ -45,6 +45,19 @@ export const collapse = (manifest, prototype) => {
|
|
|
45
45
|
delete prototype.entity.properties.id
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/*
|
|
49
|
+
* `id` is the only one a component may state for itself. The rest are written by the runtime
|
|
50
|
+
* and read by it, so one redeclared here would be merged over what the prototype says and
|
|
51
|
+
* change what the record holds, or what a criterion against it compares — without the
|
|
52
|
+
* component that wrote it having anything to do with either.
|
|
53
|
+
*/
|
|
54
|
+
for (const name of SYSTEM)
|
|
55
|
+
if (
|
|
56
|
+
manifest.entity?.properties?.[name] !== undefined &&
|
|
57
|
+
entity?.properties?.[name] !== undefined
|
|
58
|
+
)
|
|
59
|
+
throw new Error(`System property '${name}' cannot be overridden`)
|
|
60
|
+
|
|
48
61
|
if (prototype.events !== undefined && manifest.events !== undefined)
|
|
49
62
|
for (const event of Object.keys(prototype.events))
|
|
50
63
|
if (event in manifest.events) delete prototype.events[event]
|
|
@@ -55,3 +68,6 @@ export const collapse = (manifest, prototype) => {
|
|
|
55
68
|
|
|
56
69
|
merge(manifest, { entity, events, extensions })
|
|
57
70
|
}
|
|
71
|
+
|
|
72
|
+
/** What the runtime writes into every record. `id` is not among them: a component may own it. */
|
|
73
|
+
const SYSTEM = ['VERSION', 'CREATED', 'UPDATED', 'DELETED']
|
|
@@ -38,6 +38,26 @@ describe('entity', () => {
|
|
|
38
38
|
assert.deepStrictEqual(manifest, samples.entity.result)
|
|
39
39
|
})
|
|
40
40
|
|
|
41
|
+
it('should let a component state its own id', () => {
|
|
42
|
+
const prototype = { entity: { properties: { id: { type: 'string' }, VERSION: {} } } }
|
|
43
|
+
const manifest = { name: 'pot', entity: { properties: { id: { type: 'number' } } } }
|
|
44
|
+
|
|
45
|
+
collapse(manifest, prototype)
|
|
46
|
+
|
|
47
|
+
assert.strictEqual(manifest.entity.custom, true)
|
|
48
|
+
assert.deepStrictEqual(manifest.entity.properties.id, { type: 'number' })
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('should refuse a component that states a property the runtime writes', () => {
|
|
52
|
+
const prototype = { entity: { properties: { DELETED: { type: 'integer' } } } }
|
|
53
|
+
const manifest = { name: 'pot', entity: { properties: { DELETED: { type: 'integer' } } } }
|
|
54
|
+
|
|
55
|
+
assert.throws(
|
|
56
|
+
() => collapse(manifest, prototype),
|
|
57
|
+
/System property 'DELETED' cannot be overridden/
|
|
58
|
+
)
|
|
59
|
+
})
|
|
60
|
+
|
|
41
61
|
it('should not inherit migrations', () => {
|
|
42
62
|
const manifest = { entity: { migrations: [{ id: '0002', steps: [] }] } }
|
|
43
63
|
const prototype = { entity: { migrations: [{ id: '0001', steps: [] }] } }
|
|
@@ -65,6 +65,16 @@ describe('entity', () => {
|
|
|
65
65
|
assert.deepStrictEqual(manifest.entity.associated, false)
|
|
66
66
|
assert.deepStrictEqual(manifest.entity.custom, false)
|
|
67
67
|
})
|
|
68
|
+
|
|
69
|
+
it('should allow a date-time on the record', async () => {
|
|
70
|
+
manifest.entity = { properties: { settled: { type: 'string', format: 'date-time' } } }
|
|
71
|
+
|
|
72
|
+
await normalize(manifest)
|
|
73
|
+
|
|
74
|
+
assert.deepStrictEqual(manifest.entity.properties.settled.format, 'date-time')
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
|
|
68
78
|
})
|
|
69
79
|
|
|
70
80
|
describe('extensions', () => {
|