@toa.io/boot 1.0.0-alpha.42 → 1.0.0-alpha.43

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/boot",
3
- "version": "1.0.0-alpha.42",
3
+ "version": "1.0.0-alpha.43",
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.42",
24
- "@toa.io/filesystem": "1.0.0-alpha.42",
25
- "@toa.io/generic": "1.0.0-alpha.42",
26
- "@toa.io/norm": "1.0.0-alpha.42",
27
- "@toa.io/schema": "1.0.0-alpha.42",
23
+ "@toa.io/core": "1.0.0-alpha.43",
24
+ "@toa.io/filesystem": "1.0.0-alpha.43",
25
+ "@toa.io/generic": "1.0.0-alpha.43",
26
+ "@toa.io/norm": "1.0.0-alpha.43",
27
+ "@toa.io/schemas": "1.0.0-alpha.43",
28
28
  "clone-deep": "4.0.1",
29
29
  "dotenv": "16.1.1"
30
30
  },
31
- "gitHead": "6df7ba51d3f8f419b95253538e08dc7e9bc14072"
31
+ "gitHead": "c559729a642603a9d5b04ebe95fa01b4915b5c9e"
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 { Schema } = require('@toa.io/schema')
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 = new Schema(manifest.entity.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 { Schema } = require('@toa.io/schema')
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 = new Schema(request, { removeAdditional: true }) // soft inputs
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, error) => {
14
- const reply = Reply.schema(output, error)
15
- const schema = new Schema(reply) // outputs strict
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 = undefined) => {
9
- const discovery = await boot.discovery.discovery()
8
+ const remote = async (locator, manifest) => {
9
+ let discovery
10
10
 
11
- if (manifest === undefined) manifest = await discovery.lookup(locator)
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
- remote.depends(discovery)
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.Component>
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> }