@toa.io/boot 1.0.0-alpha.182 → 1.0.0-alpha.190
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 +4 -4
- package/src/bridge.js +2 -0
- package/src/component.js +2 -1
- package/src/guards.js +23 -0
- package/src/index.js +2 -0
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.190",
|
|
4
4
|
"description": "Toa Boot",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@toa.io/core": "1.0.0-alpha.
|
|
23
|
+
"@toa.io/core": "1.0.0-alpha.190",
|
|
24
24
|
"@toa.io/filesystem": "1.0.0-alpha.173",
|
|
25
25
|
"@toa.io/generic": "1.0.0-alpha.173",
|
|
26
|
-
"@toa.io/norm": "1.0.0-alpha.
|
|
26
|
+
"@toa.io/norm": "1.0.0-alpha.190",
|
|
27
27
|
"@toa.io/schemas": "1.0.0-alpha.182",
|
|
28
28
|
"clone-deep": "4.0.1",
|
|
29
29
|
"dotenv": "16.1.1",
|
|
30
30
|
"openspan": "1.0.0-alpha.173"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "494b1c8f05c21f377f1152a9d89df5cbbd1001de"
|
|
33
33
|
}
|
package/src/bridge.js
CHANGED
|
@@ -11,6 +11,7 @@ async function algorithm (bridge, path, endpoint, context) {
|
|
|
11
11
|
|
|
12
12
|
const event = (bridge, path, label, context) => resolve(bridge).event(path, label, context)
|
|
13
13
|
const receiver = (bridge, path, label) => resolve(bridge).receiver(path, label)
|
|
14
|
+
const guard = (bridge, path, label, context) => resolve(bridge).guard(path, label, context)
|
|
14
15
|
|
|
15
16
|
const factories = {}
|
|
16
17
|
|
|
@@ -27,3 +28,4 @@ const resolve = (bridge) => {
|
|
|
27
28
|
exports.algorithm = algorithm
|
|
28
29
|
exports.event = event
|
|
29
30
|
exports.receiver = receiver
|
|
31
|
+
exports.guard = guard
|
package/src/component.js
CHANGED
|
@@ -17,7 +17,8 @@ const component = async (manifest) => {
|
|
|
17
17
|
|
|
18
18
|
if (manifest.entity !== undefined) {
|
|
19
19
|
const schema = schemas.schema(manifest.entity.schema)
|
|
20
|
-
const
|
|
20
|
+
const guards = await boot.guards(manifest, context)
|
|
21
|
+
const entity = new entities.Factory(schema, guards)
|
|
21
22
|
|
|
22
23
|
state = new State(storage, entity, emission, manifest.entity.associated)
|
|
23
24
|
}
|
package/src/guards.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { Guard } = require('@toa.io/core')
|
|
4
|
+
const boot = require('./index')
|
|
5
|
+
|
|
6
|
+
async function guards(manifest, context) {
|
|
7
|
+
if (manifest.guards === undefined)
|
|
8
|
+
return
|
|
9
|
+
|
|
10
|
+
const entries = Object.entries(manifest.guards)
|
|
11
|
+
|
|
12
|
+
return await Promise.all(entries.map(async ([name, guard]) => {
|
|
13
|
+
const bridge = await load(guard, name, context)
|
|
14
|
+
|
|
15
|
+
return new Guard(name, bridge)
|
|
16
|
+
}))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function load(guard, name, context) {
|
|
20
|
+
return await boot.bridge.guard(guard.bridge, guard.path, name, context)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.guards = guards
|
package/src/index.js
CHANGED
|
@@ -14,6 +14,7 @@ const { operation } = require('./operation')
|
|
|
14
14
|
const { receivers, receive } = require('./receivers')
|
|
15
15
|
const { remote } = require('./remote')
|
|
16
16
|
const { storage } = require('./storage')
|
|
17
|
+
const { guards } = require('./guards')
|
|
17
18
|
|
|
18
19
|
exports.bindings = require('./bindings')
|
|
19
20
|
exports.bridge = require('./bridge')
|
|
@@ -34,3 +35,4 @@ exports.receivers = receivers
|
|
|
34
35
|
exports.receive = receive
|
|
35
36
|
exports.remote = remote
|
|
36
37
|
exports.storage = storage
|
|
38
|
+
exports.guards = guards
|