@toa.io/boot 1.0.0-alpha.37 → 1.0.0-alpha.39
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/bridge.js +3 -2
- package/src/cascade.js +3 -3
- package/src/component.js +14 -12
- package/src/operation.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/boot",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.39",
|
|
4
4
|
"description": "Toa Boot",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -20,13 +20,13 @@
|
|
|
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/filesystem": "1.0.0-alpha.
|
|
25
|
-
"@toa.io/generic": "1.0.0-alpha.
|
|
26
|
-
"@toa.io/norm": "1.0.0-alpha.
|
|
27
|
-
"@toa.io/schema": "1.0.0-alpha.
|
|
23
|
+
"@toa.io/core": "1.0.0-alpha.39",
|
|
24
|
+
"@toa.io/filesystem": "1.0.0-alpha.39",
|
|
25
|
+
"@toa.io/generic": "1.0.0-alpha.39",
|
|
26
|
+
"@toa.io/norm": "1.0.0-alpha.39",
|
|
27
|
+
"@toa.io/schema": "1.0.0-alpha.39",
|
|
28
28
|
"clone-deep": "4.0.1",
|
|
29
29
|
"dotenv": "16.1.1"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "d9c966c3f8c95c59768e14c61e97d0aeee5ea61f"
|
|
32
32
|
}
|
package/src/bridge.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
const
|
|
3
|
+
async function algorithm (bridge, path, endpoint, context) {
|
|
4
|
+
const factory = resolve(bridge)
|
|
5
|
+
const algorithm = await factory.algorithm(path, endpoint, context)
|
|
5
6
|
|
|
6
7
|
algorithm.depends(context)
|
|
7
8
|
|
package/src/cascade.js
CHANGED
|
@@ -4,13 +4,13 @@ const { Cascade } = require('@toa.io/core')
|
|
|
4
4
|
|
|
5
5
|
const boot = require('./index')
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
async function cascade (manifest, endpoint, definition, context) {
|
|
8
8
|
const bridges = []
|
|
9
9
|
|
|
10
10
|
if (definition.forward) endpoint = definition.forward
|
|
11
11
|
|
|
12
12
|
if (definition.bridge) {
|
|
13
|
-
const bridge = boot.bridge.algorithm(definition.bridge, manifest.path, endpoint, context)
|
|
13
|
+
const bridge = await boot.bridge.algorithm(definition.bridge, manifest.path, endpoint, context)
|
|
14
14
|
|
|
15
15
|
bridges.unshift(bridge)
|
|
16
16
|
}
|
|
@@ -22,7 +22,7 @@ const cascade = (manifest, endpoint, definition, context) => {
|
|
|
22
22
|
|
|
23
23
|
if (operation === undefined) continue
|
|
24
24
|
|
|
25
|
-
const bridge = boot.bridge.algorithm(operation.bridge, prototype.path, endpoint, context)
|
|
25
|
+
const bridge = await boot.bridge.algorithm(operation.bridge, prototype.path, endpoint, context)
|
|
26
26
|
|
|
27
27
|
bridges.unshift(bridge)
|
|
28
28
|
}
|
package/src/component.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
const {
|
|
5
|
-
Component,
|
|
6
|
-
Locator,
|
|
7
|
-
State,
|
|
8
|
-
entities
|
|
9
|
-
} = require('@toa.io/core')
|
|
3
|
+
const { Component, Locator, State, entities } = require('@toa.io/core')
|
|
10
4
|
const { Schema } = require('@toa.io/schema')
|
|
11
5
|
|
|
12
6
|
const boot = require('./index')
|
|
@@ -32,11 +26,7 @@ const component = async (manifest) => {
|
|
|
32
26
|
state = new State(storage, entity, emission, manifest.entity.associated)
|
|
33
27
|
}
|
|
34
28
|
|
|
35
|
-
const operations = manifest
|
|
36
|
-
? {}
|
|
37
|
-
: remap(manifest.operations, (definition, endpoint) =>
|
|
38
|
-
boot.operation(manifest, endpoint, definition, context, state))
|
|
39
|
-
|
|
29
|
+
const operations = await bootOperations(manifest, context, state)
|
|
40
30
|
const component = new Component(locator, operations)
|
|
41
31
|
|
|
42
32
|
if (storage) component.depends(storage)
|
|
@@ -45,4 +35,16 @@ const component = async (manifest) => {
|
|
|
45
35
|
return boot.extensions.component(component)
|
|
46
36
|
}
|
|
47
37
|
|
|
38
|
+
async function bootOperations (manifest, context, state) {
|
|
39
|
+
if (manifest.operations === undefined)
|
|
40
|
+
return {}
|
|
41
|
+
|
|
42
|
+
const operations = {}
|
|
43
|
+
|
|
44
|
+
for (const [endpoint, definition] of Object.entries(manifest.operations))
|
|
45
|
+
operations[endpoint] = await boot.operation(manifest, endpoint, definition, context, state)
|
|
46
|
+
|
|
47
|
+
return operations
|
|
48
|
+
}
|
|
49
|
+
|
|
48
50
|
exports.component = component
|
package/src/operation.js
CHANGED
|
@@ -4,8 +4,8 @@ const { Transition, Observation, Assignment, Operation, Query, Effect } = requir
|
|
|
4
4
|
|
|
5
5
|
const boot = require('./index')
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
const cascade = boot.cascade(manifest, endpoint, definition, context)
|
|
7
|
+
async function operation (manifest, endpoint, definition, context, scope) {
|
|
8
|
+
const cascade = await boot.cascade(manifest, endpoint, definition, context)
|
|
9
9
|
const reply = boot.contract.reply(definition.output, definition.error)
|
|
10
10
|
const input = definition.input
|
|
11
11
|
const request = boot.contract.request({ input }, manifest.entity)
|