@toa.io/norm 1.0.0-alpha.30 → 1.0.0-alpha.32
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/package.json +7 -7
- package/src/.component/defaults.js +14 -2
- package/src/.component/schema.yaml +2 -0
- package/src/component.js +4 -4
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.32",
|
|
4
4
|
"description": "Toa declarations normalization and validation",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@toa.io/core": "1.0.0-alpha.
|
|
24
|
-
"@toa.io/generic": "1.0.0-alpha.
|
|
25
|
-
"@toa.io/schema": "1.0.0-alpha.
|
|
26
|
-
"@toa.io/schemas": "1.0.0-alpha.
|
|
27
|
-
"@toa.io/yaml": "1.0.0-alpha.
|
|
23
|
+
"@toa.io/core": "1.0.0-alpha.32",
|
|
24
|
+
"@toa.io/generic": "1.0.0-alpha.32",
|
|
25
|
+
"@toa.io/schema": "1.0.0-alpha.32",
|
|
26
|
+
"@toa.io/schemas": "1.0.0-alpha.32",
|
|
27
|
+
"@toa.io/yaml": "1.0.0-alpha.32"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "93ceb53797363abb77eb9c550db77e906691d42a"
|
|
30
30
|
}
|
|
@@ -4,8 +4,11 @@ const { hash } = require('@toa.io/generic')
|
|
|
4
4
|
const assert = require('node:assert')
|
|
5
5
|
|
|
6
6
|
// these defaults are required before validation
|
|
7
|
-
const defaults = (manifest) => {
|
|
8
|
-
if (manifest.name === undefined)
|
|
7
|
+
const defaults = (manifest, proto) => {
|
|
8
|
+
if (manifest.name === undefined)
|
|
9
|
+
if (proto) manifest.name = protoName(manifest)
|
|
10
|
+
else nameAfterDir(manifest)
|
|
11
|
+
|
|
9
12
|
if (manifest.bindings === undefined) manifest.bindings = ['@toa.io/bindings.amqp']
|
|
10
13
|
if (manifest.bridge === undefined) manifest.bridge = '@toa.io/bridges.node'
|
|
11
14
|
|
|
@@ -24,4 +27,13 @@ function protoName (manifest) {
|
|
|
24
27
|
return 'proto' + hash(manifest.path)
|
|
25
28
|
}
|
|
26
29
|
|
|
30
|
+
function nameAfterDir (manifest) {
|
|
31
|
+
const parts = manifest.path.split('/')
|
|
32
|
+
const dirname = parts[parts.length - 1]
|
|
33
|
+
const [name, namespace] = dirname.split('.').reverse()
|
|
34
|
+
|
|
35
|
+
manifest.name = name
|
|
36
|
+
manifest.namespace = namespace
|
|
37
|
+
}
|
|
38
|
+
|
|
27
39
|
exports.defaults = defaults
|
package/src/component.js
CHANGED
|
@@ -20,7 +20,7 @@ const {
|
|
|
20
20
|
const component = async (path) => {
|
|
21
21
|
const manifest = await load(path)
|
|
22
22
|
|
|
23
|
-
normalize(manifest)
|
|
23
|
+
normalize(manifest, path)
|
|
24
24
|
validate(manifest)
|
|
25
25
|
extensions(manifest)
|
|
26
26
|
|
|
@@ -29,7 +29,7 @@ const component = async (path) => {
|
|
|
29
29
|
return manifest
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const load = async (path, base) => {
|
|
32
|
+
const load = async (path, base, proto = false) => {
|
|
33
33
|
if (base !== undefined) path = find(path, base, MANIFEST)
|
|
34
34
|
|
|
35
35
|
const file = join(path, MANIFEST)
|
|
@@ -37,13 +37,13 @@ const load = async (path, base) => {
|
|
|
37
37
|
|
|
38
38
|
manifest.path = path
|
|
39
39
|
|
|
40
|
-
defaults(manifest)
|
|
40
|
+
defaults(manifest, proto)
|
|
41
41
|
await expand(manifest)
|
|
42
42
|
|
|
43
43
|
await merge(path, manifest)
|
|
44
44
|
|
|
45
45
|
if (manifest.prototype !== null) {
|
|
46
|
-
const prototype = await load(manifest.prototype, path)
|
|
46
|
+
const prototype = await load(manifest.prototype, path, true)
|
|
47
47
|
|
|
48
48
|
collapse(manifest, prototype)
|
|
49
49
|
}
|