@toa.io/norm 1.0.0-alpha.274 → 1.0.0-alpha.278
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 +17 -0
- package/package.json +8 -7
- package/src/.component/.expand/bridge.js +2 -6
- package/src/.component/.expand/entity.js +2 -6
- package/src/.component/.expand/events.js +2 -6
- package/src/.component/.expand/extensions.js +2 -6
- package/src/.component/.expand/index.js +8 -19
- package/src/.component/.expand/operations.js +2 -6
- package/src/.component/.expand/properties.js +2 -6
- package/src/.component/.expand/receivers.js +2 -6
- package/src/.component/.expand/version.js +4 -8
- package/src/.component/.normalize/events.js +12 -5
- package/src/.component/.normalize/index.js +3 -9
- package/src/.component/.normalize/operations.js +1 -5
- package/src/.component/.normalize/receivers.js +1 -5
- package/src/.component/collapse.js +2 -6
- package/src/.component/defaults.js +2 -6
- package/src/.component/dependencies.js +7 -6
- package/src/.component/dereference.js +2 -6
- package/src/.component/expand.js +2 -15
- package/src/.component/extensions.js +6 -9
- package/src/.component/index.js +9 -21
- package/src/.component/merge.js +7 -8
- package/src/.component/normalize.js +3 -7
- package/src/.component/validate.js +11 -13
- package/src/.context/.dependencies/connectors.js +2 -6
- package/src/.context/.dependencies/describe.js +1 -5
- package/src/.context/.dependencies/extensions.js +4 -7
- package/src/.context/.dependencies/index.js +3 -9
- package/src/.context/.dependencies/load.js +14 -13
- package/src/.context/.dependencies/resolve.js +6 -10
- package/src/.context/complete.js +1 -5
- package/src/.context/dependencies.js +2 -6
- package/src/.context/dereference.js +1 -5
- package/src/.context/expand.js +2 -6
- package/src/.context/index.js +6 -15
- package/src/.context/normalize.js +2 -6
- package/src/.context/validate.js +7 -11
- package/src/component.js +14 -25
- package/src/context.js +12 -21
- package/src/index.js +3 -9
- package/src/shortcuts.js +4 -10
- package/test/component/collapse.fixtures.js +2 -5
- package/test/component/collapse.test.js +17 -10
- package/test/component/dependencies.test.js +12 -10
- package/test/component/dereference.fixtures.js +2 -7
- package/test/component/dereference.test.js +9 -8
- package/test/component/dummies/extension/index.js +1 -5
- package/test/component/expand.fixtures.js +3 -8
- package/test/component/expand.test.js +10 -9
- package/test/component/normalize.fixtures.js +3 -7
- package/test/component/normalize.test.js +20 -18
- package/test/component/validate.fixtures.js +1 -5
- package/test/component/validate.test.js +88 -86
- package/test/context/complete.fixtures.js +2 -7
- package/test/context/complete.test.js +10 -8
- package/test/context/dependencies.load.test.js +13 -12
- package/test/context/dereference.fixtures.js +3 -8
- package/test/context/dereference.test.js +8 -7
- package/test/context/expand.fixtures.js +1 -5
- package/test/context/expand.test.js +9 -8
- package/test/context/normalize.fixtures.js +2 -6
- package/test/context/normalize.test.js +10 -8
- package/test/context/validate.fixtures.js +1 -5
- package/test/context/validate.test.js +20 -19
- package/test/shortcuts.fixtures.js +4 -9
- package/test/shortcuts.test.js +16 -15
- package/types/context/declaration.d.ts +1 -1
- package/types/context.d.ts +2 -2
- package/types/index.d.ts +3 -3
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
import { it, before } from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
import clone from 'clone-deep'
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
import { dereference } from '../../src/.context/index.js'
|
|
7
|
+
import * as fixtures from './dereference.fixtures.js'
|
|
7
8
|
|
|
8
9
|
/** @type {toa.norm.Context} */
|
|
9
10
|
let context
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
before(() => {
|
|
12
13
|
context = clone(fixtures.context)
|
|
13
14
|
dereference(context)
|
|
14
15
|
})
|
|
15
16
|
|
|
16
17
|
it('should dereference', () => {
|
|
17
|
-
|
|
18
|
+
assert.partialDeepStrictEqual(context, fixtures.expected)
|
|
18
19
|
})
|
|
19
20
|
|
|
20
21
|
it('should not throw on empty compositions', () => {
|
|
21
22
|
context.compositions = undefined
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
assert.doesNotThrow(() => dereference(context))
|
|
24
25
|
})
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { describe, it, beforeEach } from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import clone from 'clone-deep'
|
|
5
|
+
import { generate } from 'randomstring'
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
import { expand } from '../../src/.context/index.js'
|
|
8
|
+
import * as fixtures from './expand.fixtures.js'
|
|
8
9
|
|
|
9
10
|
/** @type {toa.norm.context.Declaration | object} */
|
|
10
11
|
let context
|
|
@@ -17,7 +18,7 @@ describe('annotations', () => {
|
|
|
17
18
|
it('should not throw without annotations', () => {
|
|
18
19
|
delete context.annotations
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
assert.doesNotThrow(() => expand(context))
|
|
21
22
|
})
|
|
22
23
|
|
|
23
24
|
it('should expand known annotations', () => {
|
|
@@ -28,7 +29,7 @@ describe('annotations', () => {
|
|
|
28
29
|
|
|
29
30
|
expand(context)
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
assert.deepStrictEqual(context.annotations, fixtures.context.annotations)
|
|
32
33
|
})
|
|
33
34
|
|
|
34
35
|
it('should recognize annotations', () => {
|
|
@@ -36,6 +37,6 @@ describe('annotations', () => {
|
|
|
36
37
|
|
|
37
38
|
expand(context)
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
assert.notStrictEqual(context.annotations['@toa.io/storages.mongodb'], undefined)
|
|
40
41
|
})
|
|
41
42
|
})
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { generate } from 'randomstring'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
const context = {
|
|
3
|
+
export const context = {
|
|
6
4
|
runtime: {
|
|
7
5
|
version: '0.0.0'
|
|
8
6
|
},
|
|
@@ -27,5 +25,3 @@ const context = {
|
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
|
-
|
|
31
|
-
exports.context = context
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import * as runtime from '@toa.io/runtime'
|
|
2
|
+
import { it, beforeEach } from 'node:test'
|
|
3
|
+
import assert from 'node:assert/strict'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
import clone from 'clone-deep'
|
|
6
|
+
import { generate } from 'randomstring'
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
import * as fixtures from './normalize.fixtures.js'
|
|
9
|
+
import { normalize } from '../../src/.context/index.js'
|
|
8
10
|
|
|
9
11
|
let context
|
|
10
12
|
|
|
@@ -17,8 +19,8 @@ it('should resolve local version', () => {
|
|
|
17
19
|
|
|
18
20
|
normalize(context)
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
assert.notDeepStrictEqual(context.runtime, '.')
|
|
23
|
+
assert.deepStrictEqual(context.runtime.version, runtime.version)
|
|
22
24
|
})
|
|
23
25
|
|
|
24
26
|
it('should expand registry', () => {
|
|
@@ -28,7 +30,7 @@ it('should expand registry', () => {
|
|
|
28
30
|
|
|
29
31
|
normalize(context)
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
assert.deepStrictEqual(context.registry, {
|
|
32
34
|
base
|
|
33
35
|
})
|
|
34
36
|
})
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { describe, it, before, beforeEach } from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
import clone from 'clone-deep'
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
import { validate } from '../../src/.context/index.js'
|
|
7
|
+
import * as fixtures from './validate.fixtures.js'
|
|
7
8
|
|
|
8
9
|
let context
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
before(() => {
|
|
12
|
+
assert.doesNotThrow(() => validate(fixtures.context))
|
|
12
13
|
})
|
|
13
14
|
|
|
14
15
|
beforeEach(() => {
|
|
@@ -18,23 +19,23 @@ beforeEach(() => {
|
|
|
18
19
|
describe('runtime', () => {
|
|
19
20
|
it('should require', () => {
|
|
20
21
|
delete context.runtime
|
|
21
|
-
|
|
22
|
+
assert.throws(() => validate(context), (error) => /required/.test(error.message))
|
|
22
23
|
})
|
|
23
24
|
|
|
24
25
|
it('should require registry to match uri format', () => {
|
|
25
26
|
context.runtime.registry = 'not-a-uri'
|
|
26
|
-
|
|
27
|
+
assert.throws(() => validate(context), (error) => /must match format/.test(error.message))
|
|
27
28
|
|
|
28
29
|
context.runtime.registry = 'http://localhost'
|
|
29
|
-
|
|
30
|
+
assert.doesNotThrow(() => validate(context))
|
|
30
31
|
})
|
|
31
32
|
|
|
32
33
|
it('should require proxy to match uri format', () => {
|
|
33
34
|
context.runtime.proxy = 'not-a-uri'
|
|
34
|
-
|
|
35
|
+
assert.throws(() => validate(context), (error) => /must match format/.test(error.message))
|
|
35
36
|
|
|
36
37
|
context.runtime.proxy = 'http://localhost'
|
|
37
|
-
|
|
38
|
+
assert.doesNotThrow(() => validate(context))
|
|
38
39
|
})
|
|
39
40
|
})
|
|
40
41
|
|
|
@@ -42,7 +43,7 @@ describe('registry', () => {
|
|
|
42
43
|
it('should require', () => {
|
|
43
44
|
delete context.registry
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
assert.throws(() => validate(context), (error) => /required property 'registry'/.test(error.message))
|
|
46
47
|
})
|
|
47
48
|
|
|
48
49
|
it('should set default platforms', () => {
|
|
@@ -50,25 +51,25 @@ describe('registry', () => {
|
|
|
50
51
|
|
|
51
52
|
validate(context)
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
assert.ok(context.registry.platforms instanceof Array)
|
|
55
|
+
assert.deepStrictEqual(context.registry.platforms, ['linux/amd64', 'linux/arm/v7', 'linux/arm64'])
|
|
55
56
|
})
|
|
56
57
|
})
|
|
57
58
|
|
|
58
59
|
it('should require name as label', () => {
|
|
59
60
|
delete context.name
|
|
60
|
-
|
|
61
|
+
assert.throws(() => validate(context), (error) => /required/.test(error.message))
|
|
61
62
|
|
|
62
63
|
context.name = 'foo bar'
|
|
63
|
-
|
|
64
|
+
assert.throws(() => validate(context), (error) => /pattern/.test(error.message))
|
|
64
65
|
|
|
65
66
|
context.name = 'foo-bar'
|
|
66
|
-
|
|
67
|
+
assert.doesNotThrow(() => validate(context))
|
|
67
68
|
})
|
|
68
69
|
|
|
69
70
|
it('should require registry url', () => {
|
|
70
71
|
delete context.registry
|
|
71
|
-
|
|
72
|
+
assert.throws(() => validate(context), (error) => /required/.test(error.message))
|
|
72
73
|
})
|
|
73
74
|
|
|
74
75
|
it('should allow mono replicas and resources', () => {
|
|
@@ -80,5 +81,5 @@ it('should allow mono replicas and resources', () => {
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
|
|
84
|
+
assert.doesNotThrow(() => validate(context))
|
|
84
85
|
})
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { generate } from 'randomstring'
|
|
2
|
+
import { random } from '@toa.io/generic'
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
const { random } = require('@toa.io/generic')
|
|
5
|
-
|
|
6
|
-
const SHORTCUTS = {
|
|
4
|
+
export const SHORTCUTS = {
|
|
7
5
|
amqp: '@toa.io/bindings.amqp',
|
|
8
6
|
mongodb: '@toa.io/storages.mongodb'
|
|
9
7
|
}
|
|
10
8
|
|
|
11
|
-
const object = { foo: random(), bar: { baz: generate() } }
|
|
12
|
-
|
|
13
|
-
exports.object = object
|
|
14
|
-
exports.SHORTCUTS = SHORTCUTS
|
|
9
|
+
export const object = { foo: random(), bar: { baz: generate() } }
|
package/test/shortcuts.test.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { describe, it, beforeEach } from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import clone from 'clone-deep'
|
|
5
|
+
import { generate } from 'randomstring'
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
import { recognize, resolve } from '../src/shortcuts.js'
|
|
8
|
+
import * as fixtures from './shortcuts.fixtures.js'
|
|
8
9
|
|
|
9
10
|
let object
|
|
10
11
|
|
|
@@ -14,16 +15,16 @@ beforeEach(() => {
|
|
|
14
15
|
|
|
15
16
|
describe('resolve', () => {
|
|
16
17
|
it('should be defined', () => {
|
|
17
|
-
|
|
18
|
+
assert.notStrictEqual(resolve, undefined)
|
|
18
19
|
})
|
|
19
20
|
|
|
20
21
|
it('should resolve', () => {
|
|
21
|
-
|
|
22
|
+
assert.ok(Object.keys(fixtures.SHORTCUTS).length > 0)
|
|
22
23
|
|
|
23
24
|
for (const [key, value] of Object.entries(fixtures.SHORTCUTS)) {
|
|
24
25
|
const resolved = resolve(key)
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
assert.deepStrictEqual(resolved, value)
|
|
27
28
|
}
|
|
28
29
|
})
|
|
29
30
|
})
|
|
@@ -32,7 +33,7 @@ describe('recognize', () => {
|
|
|
32
33
|
it('should not change unknown', () => {
|
|
33
34
|
recognize(fixtures.SHORTCUTS, object)
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
assert.deepStrictEqual(object, fixtures.object)
|
|
36
37
|
})
|
|
37
38
|
|
|
38
39
|
it('should resolve known', () => {
|
|
@@ -41,8 +42,8 @@ describe('recognize', () => {
|
|
|
41
42
|
recognize(fixtures.SHORTCUTS, object)
|
|
42
43
|
|
|
43
44
|
for (const [alias, name] of Object.entries(fixtures.SHORTCUTS)) {
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
assert.strictEqual(object[alias], undefined)
|
|
46
|
+
assert.deepStrictEqual(object[name], known[name])
|
|
46
47
|
}
|
|
47
48
|
})
|
|
48
49
|
|
|
@@ -52,9 +53,9 @@ describe('recognize', () => {
|
|
|
52
53
|
|
|
53
54
|
recognize(fixtures.SHORTCUTS, object, group)
|
|
54
55
|
|
|
55
|
-
|
|
56
|
+
assert.deepStrictEqual(object[group], known)
|
|
56
57
|
|
|
57
|
-
for (const alias of Object.keys(fixtures.SHORTCUTS))
|
|
58
|
+
for (const alias of Object.keys(fixtures.SHORTCUTS)) assert.strictEqual(object[alias], undefined)
|
|
58
59
|
})
|
|
59
60
|
|
|
60
61
|
it('should not overwrite group', () => {
|
|
@@ -67,7 +68,7 @@ describe('recognize', () => {
|
|
|
67
68
|
|
|
68
69
|
recognize(fixtures.SHORTCUTS, object, group)
|
|
69
70
|
|
|
70
|
-
|
|
71
|
+
assert.partialDeepStrictEqual(object[group], existing)
|
|
71
72
|
})
|
|
72
73
|
|
|
73
74
|
it('should not create empty group', () => {
|
|
@@ -75,7 +76,7 @@ describe('recognize', () => {
|
|
|
75
76
|
|
|
76
77
|
recognize(object, group)
|
|
77
78
|
|
|
78
|
-
|
|
79
|
+
assert.strictEqual(object[group], undefined)
|
|
79
80
|
})
|
|
80
81
|
|
|
81
82
|
const append = () => {
|
package/types/context.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Manifest } from './component'
|
|
1
|
+
import { Manifest } from './component.js'
|
|
2
2
|
import { Locator } from '@toa.io/core'
|
|
3
|
-
import type { Declaration } from './context/declaration'
|
|
3
|
+
import type { Declaration } from './context/declaration.js'
|
|
4
4
|
|
|
5
5
|
interface Runtime{
|
|
6
6
|
version: string
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * as context from './context'
|
|
2
|
-
export * as component from './component'
|
|
1
|
+
export * as context from './context.js'
|
|
2
|
+
export * as component from './component.js'
|
|
3
3
|
|
|
4
|
-
export { Manifest } from './component'
|
|
4
|
+
export { Manifest } from './component.js'
|