@toa.io/boot 1.0.2-dev.8 → 1.1.0-canary.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/package.json +7 -7
- package/src/component.js +2 -0
- package/src/composition.js +0 -2
- package/src/contract.js +2 -2
- package/src/deployment.js +18 -2
- package/src/extensions/load.js +4 -17
- package/src/index.js +2 -1
- package/src/manifest.js +3 -0
- package/types/composition.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/boot",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0-canary.0",
|
|
4
4
|
"description": "Toa Boot",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@toa.io/core": "1.1.0-
|
|
23
|
-
"@toa.io/filesystem": "1.0
|
|
24
|
-
"@toa.io/generic": "0.11.0-
|
|
25
|
-
"@toa.io/norm": "1.0
|
|
26
|
-
"@toa.io/schema": "0.7.6-
|
|
22
|
+
"@toa.io/core": "1.1.0-canary.0",
|
|
23
|
+
"@toa.io/filesystem": "1.1.0-canary.0",
|
|
24
|
+
"@toa.io/generic": "0.11.0-canary.0",
|
|
25
|
+
"@toa.io/norm": "1.1.0-canary.0",
|
|
26
|
+
"@toa.io/schema": "0.7.6-canary.0",
|
|
27
27
|
"clone-deep": "4.0.1",
|
|
28
28
|
"dotenv": "16.0.3"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "0adb45e6d6d309b21b976d257ac0a4fc48d866b3"
|
|
31
31
|
}
|
package/src/component.js
CHANGED
|
@@ -11,6 +11,8 @@ const boot = require('./index')
|
|
|
11
11
|
* @returns {Promise<toa.core.Component>}
|
|
12
12
|
*/
|
|
13
13
|
const component = async (manifest) => {
|
|
14
|
+
boot.extensions.load(manifest)
|
|
15
|
+
|
|
14
16
|
const locator = new Locator(manifest.name, manifest.namespace)
|
|
15
17
|
const storage = boot.storage(manifest)
|
|
16
18
|
const context = await boot.context(manifest)
|
package/src/composition.js
CHANGED
|
@@ -10,8 +10,6 @@ async function composition (paths, options) {
|
|
|
10
10
|
/** @type {toa.norm.Component[]} */
|
|
11
11
|
const manifests = await Promise.all(paths.map((path) => boot.manifest(path, options)))
|
|
12
12
|
|
|
13
|
-
boot.extensions.load(manifests, options.extensions)
|
|
14
|
-
|
|
15
13
|
/** @type {toa.core.Connector[]} */
|
|
16
14
|
const tenants = await Promise.all(manifests.map(boot.extensions.tenants))
|
|
17
15
|
|
package/src/contract.js
CHANGED
|
@@ -5,14 +5,14 @@ const { Schema } = require('@toa.io/schema')
|
|
|
5
5
|
|
|
6
6
|
const request = (definition) => {
|
|
7
7
|
const request = Request.schema(definition)
|
|
8
|
-
const schema = new Schema(request)
|
|
8
|
+
const schema = new Schema(request, { removeAdditional: true }) // inputs soft
|
|
9
9
|
|
|
10
10
|
return new Request(schema)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const reply = (output, error) => {
|
|
14
14
|
const reply = Reply.schema(output, error)
|
|
15
|
-
const schema = new Schema(reply)
|
|
15
|
+
const schema = new Schema(reply) // outputs strict
|
|
16
16
|
|
|
17
17
|
return new Reply(schema)
|
|
18
18
|
}
|
package/src/deployment.js
CHANGED
|
@@ -9,10 +9,26 @@ const { context: load } = require('@toa.io/norm')
|
|
|
9
9
|
* @returns {Promise<toa.deployment.Operator>}
|
|
10
10
|
*/
|
|
11
11
|
const deployment = async (path, environment) => {
|
|
12
|
-
const
|
|
13
|
-
const factory = new Factory(context)
|
|
12
|
+
const factory = await getFactory(path, environment)
|
|
14
13
|
|
|
15
14
|
return factory.operator()
|
|
16
15
|
}
|
|
17
16
|
|
|
17
|
+
/**
|
|
18
|
+
* @param {string} path
|
|
19
|
+
* @returns {Promise<toa.deployment.Registry>}
|
|
20
|
+
*/
|
|
21
|
+
const registry = async (path) => {
|
|
22
|
+
const factory = await getFactory(path)
|
|
23
|
+
|
|
24
|
+
return factory.registry()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function getFactory (path, environment) {
|
|
28
|
+
const context = await load(path, environment)
|
|
29
|
+
|
|
30
|
+
return new Factory(context)
|
|
31
|
+
}
|
|
32
|
+
|
|
18
33
|
exports.deployment = deployment
|
|
34
|
+
exports.registry = registry
|
package/src/extensions/load.js
CHANGED
|
@@ -3,25 +3,12 @@
|
|
|
3
3
|
const { resolve } = require('./resolve')
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* @param {toa.norm.Component
|
|
7
|
-
* @param {string[]} defaults
|
|
6
|
+
* @param {toa.norm.Component} manifest
|
|
8
7
|
*/
|
|
9
|
-
const load = (
|
|
10
|
-
|
|
11
|
-
defaults.map((name) => resolve(name))
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @param {toa.norm.Component[]} manifests
|
|
16
|
-
*/
|
|
17
|
-
const scan = (manifests) => {
|
|
18
|
-
for (const manifest of manifests) {
|
|
19
|
-
if (manifest.extensions === undefined) continue
|
|
8
|
+
const load = (manifest) => {
|
|
9
|
+
if (manifest.extensions === undefined) return
|
|
20
10
|
|
|
21
|
-
|
|
22
|
-
resolve(name, manifest.path)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
11
|
+
for (const name of Object.keys(manifest.extensions)) resolve(name, manifest.path)
|
|
25
12
|
}
|
|
26
13
|
|
|
27
14
|
exports.load = load
|
package/src/index.js
CHANGED
|
@@ -7,7 +7,7 @@ const { cascade } = require('./cascade')
|
|
|
7
7
|
const { component } = require('./component')
|
|
8
8
|
const { composition } = require('./composition')
|
|
9
9
|
const { context } = require('./context')
|
|
10
|
-
const { deployment } = require('./deployment')
|
|
10
|
+
const { deployment, registry } = require('./deployment')
|
|
11
11
|
const { emission } = require('./emission')
|
|
12
12
|
const { exposition } = require('./exposition')
|
|
13
13
|
const { images } = require('./images')
|
|
@@ -35,5 +35,6 @@ exports.images = images
|
|
|
35
35
|
exports.manifest = manifest
|
|
36
36
|
exports.operation = operation
|
|
37
37
|
exports.receivers = receivers
|
|
38
|
+
exports.registry = registry
|
|
38
39
|
exports.remote = remote
|
|
39
40
|
exports.storage = storage
|
package/src/manifest.js
CHANGED
|
@@ -37,11 +37,14 @@ const manifest = async (path, options = {}) => {
|
|
|
37
37
|
if (!(extension in manifest.extensions)) manifest.extensions[extension] = null
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
if ('storage' in options && 'entity' in manifest) manifest.entity.storage = options.storage
|
|
41
|
+
|
|
40
42
|
manifest.locator = new Locator(manifest.name, manifest.namespace)
|
|
41
43
|
|
|
42
44
|
return manifest
|
|
43
45
|
}
|
|
44
46
|
|
|
47
|
+
/** @type {toa.boot.composition.Options} */
|
|
45
48
|
const DEFAULTS = {
|
|
46
49
|
extensions: ['@toa.io/extensions.sampling', '@toa.io/extensions.state']
|
|
47
50
|
}
|