@toa.io/boot 1.0.0-alpha.42 → 1.0.0-alpha.44
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 -6
- package/src/contract.js +6 -6
- package/src/operation.js +1 -0
- package/src/remote.js +8 -4
- package/types/index.d.ts +3 -3
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.44",
|
|
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/
|
|
23
|
+
"@toa.io/core": "1.0.0-alpha.44",
|
|
24
|
+
"@toa.io/filesystem": "1.0.0-alpha.44",
|
|
25
|
+
"@toa.io/generic": "1.0.0-alpha.44",
|
|
26
|
+
"@toa.io/norm": "1.0.0-alpha.44",
|
|
27
|
+
"@toa.io/schemas": "1.0.0-alpha.44",
|
|
28
28
|
"clone-deep": "4.0.1",
|
|
29
29
|
"dotenv": "16.1.1"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "9a0401a82a7e63102a1dc5be8686ecc232fdabee"
|
|
32
32
|
}
|
package/src/component.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { Component, Locator, State, entities } = require('@toa.io/core')
|
|
4
|
-
const
|
|
4
|
+
const schemas = require('@toa.io/schemas')
|
|
5
5
|
|
|
6
6
|
const boot = require('./index')
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* @param {toa.norm.Component} manifest
|
|
10
|
-
* @returns {Promise<toa.core.Component>}
|
|
11
|
-
*/
|
|
12
8
|
const component = async (manifest) => {
|
|
13
9
|
boot.extensions.load(manifest)
|
|
14
10
|
|
|
@@ -20,7 +16,7 @@ const component = async (manifest) => {
|
|
|
20
16
|
let state
|
|
21
17
|
|
|
22
18
|
if (manifest.entity !== undefined) {
|
|
23
|
-
const schema =
|
|
19
|
+
const schema = schemas.schema(manifest.entity.schema)
|
|
24
20
|
const entity = new entities.Factory(schema)
|
|
25
21
|
|
|
26
22
|
state = new State(storage, entity, emission, manifest.entity.associated)
|
package/src/contract.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { contract: { Request, Reply } } = require('@toa.io/core')
|
|
4
|
-
const
|
|
4
|
+
const schemas = require('@toa.io/schemas')
|
|
5
5
|
|
|
6
6
|
const request = (definition, entity) => {
|
|
7
7
|
const request = Request.schema(definition, entity)
|
|
8
|
-
const schema =
|
|
8
|
+
const schema = schemas.schema(request, { removeAdditional: true })
|
|
9
9
|
|
|
10
|
-
return new Request(schema)
|
|
10
|
+
return new Request(schema, definition)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const reply = (output,
|
|
14
|
-
const reply = Reply.schema(output,
|
|
15
|
-
const schema =
|
|
13
|
+
const reply = (output, errors) => {
|
|
14
|
+
const reply = Reply.schema(output, errors)
|
|
15
|
+
const schema = schemas.schema(reply)
|
|
16
16
|
|
|
17
17
|
return new Reply(schema)
|
|
18
18
|
}
|
package/src/operation.js
CHANGED
|
@@ -10,6 +10,7 @@ async function operation (manifest, endpoint, definition, context, scope) {
|
|
|
10
10
|
const input = definition.input
|
|
11
11
|
const request = boot.contract.request({ input }, manifest.entity)
|
|
12
12
|
const contracts = { reply, request }
|
|
13
|
+
|
|
13
14
|
const query = manifest.entity === undefined
|
|
14
15
|
? undefined
|
|
15
16
|
: new Query(manifest.entity.schema.properties)
|
package/src/remote.js
CHANGED
|
@@ -5,10 +5,13 @@ const { remap } = require('@toa.io/generic')
|
|
|
5
5
|
|
|
6
6
|
const boot = require('./index')
|
|
7
7
|
|
|
8
|
-
const remote = async (locator, manifest
|
|
9
|
-
|
|
8
|
+
const remote = async (locator, manifest) => {
|
|
9
|
+
let discovery
|
|
10
10
|
|
|
11
|
-
if (manifest === undefined)
|
|
11
|
+
if (manifest === undefined) {
|
|
12
|
+
discovery = await boot.discovery.discovery(locator)
|
|
13
|
+
manifest = await discovery.lookup(locator)
|
|
14
|
+
}
|
|
12
15
|
|
|
13
16
|
const calls = manifest.operations === undefined
|
|
14
17
|
? {}
|
|
@@ -17,7 +20,8 @@ const remote = async (locator, manifest = undefined) => {
|
|
|
17
20
|
const remote = new Remote(locator, calls)
|
|
18
21
|
|
|
19
22
|
// ensure discovery shutdown
|
|
20
|
-
|
|
23
|
+
if (discovery !== undefined)
|
|
24
|
+
remote.depends(discovery)
|
|
21
25
|
|
|
22
26
|
return remote
|
|
23
27
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -5,17 +5,17 @@ export * as bindings from './bindings'
|
|
|
5
5
|
|
|
6
6
|
export async function composition (paths: string[], options?: composition.Options): Promise<core.Connector>
|
|
7
7
|
|
|
8
|
-
export async function remote (locator: core.Locator): Promise<core.
|
|
8
|
+
export async function remote (locator: core.Locator): Promise<core.Remote>
|
|
9
9
|
|
|
10
10
|
export async function receive<T = any> (
|
|
11
11
|
label: string,
|
|
12
|
-
receiver: Receiver
|
|
12
|
+
receiver: Receiver
|
|
13
13
|
): Promise<core.Connector>
|
|
14
14
|
|
|
15
15
|
export async function receive<T = any> (
|
|
16
16
|
label: string,
|
|
17
17
|
group: string | undefined,
|
|
18
|
-
receiver: Receiver
|
|
18
|
+
receiver: Receiver
|
|
19
19
|
): Promise<core.Connector>
|
|
20
20
|
|
|
21
21
|
type Receiver = { receive: (message: core.Message<T>) => void | Promise<void> }
|