@toa.io/userland 1.0.0-alpha.0 → 1.0.0-alpha.3

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.
@@ -1,8 +1,6 @@
1
1
  name: calculations
2
2
  namespace: math
3
3
 
4
- entity: null
5
-
6
4
  operations:
7
5
  add:
8
6
  input:
@@ -1,8 +1,6 @@
1
1
  name: proxy
2
2
  namespace: math
3
3
 
4
- entity: null
5
-
6
4
  operations:
7
5
  add:
8
6
  input:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/userland",
3
- "version": "1.0.0-alpha.0",
3
+ "version": "1.0.0-alpha.3",
4
4
  "description": "Toa development kit",
5
5
  "homepage": "https://toa.io",
6
6
  "author": {
@@ -24,15 +24,15 @@
24
24
  "main": "src/index.js",
25
25
  "types": "types/index.d.ts",
26
26
  "dependencies": {
27
- "@toa.io/boot": "1.0.0-alpha.0",
28
- "@toa.io/core": "1.0.0-alpha.0",
29
- "@toa.io/filesystem": "1.0.0-alpha.0",
30
- "@toa.io/generic": "1.0.0-alpha.0",
31
- "@toa.io/norm": "1.0.0-alpha.0",
32
- "@toa.io/schemas": "1.0.0-alpha.0",
27
+ "@toa.io/boot": "1.0.0-alpha.3",
28
+ "@toa.io/core": "1.0.0-alpha.3",
29
+ "@toa.io/filesystem": "1.0.0-alpha.3",
30
+ "@toa.io/generic": "1.0.0-alpha.3",
31
+ "@toa.io/norm": "1.0.0-alpha.3",
32
+ "@toa.io/schemas": "1.0.0-alpha.3",
33
33
  "@toa.io/storages.null": "0.22.0",
34
- "@toa.io/yaml": "1.0.0-alpha.0",
34
+ "@toa.io/yaml": "1.0.0-alpha.3",
35
35
  "tap": "16.3.4"
36
36
  },
37
- "gitHead": "06c64546f6292cc07c52f74b31415101037f7616"
37
+ "gitHead": "e36ac7871fc14d15863aaf8f9bbdeace8bdfa9f0"
38
38
  }
@@ -1,9 +1,9 @@
1
- import type * as _core from '@toa.io/core/types'
1
+ import type * as _core from '@toa.io/core'
2
2
  import type * as _operation from './operation'
3
3
 
4
- declare namespace toa.samples {
4
+ declare namespace toa.samples{
5
5
 
6
- namespace messages {
6
+ namespace messages{
7
7
 
8
8
  type Set = Record<string, Message[]>
9
9
 
@@ -1,9 +1,9 @@
1
- import * as _core from '@toa.io/core/types'
1
+ import * as _core from '@toa.io/core'
2
2
  import * as _sampling from '@toa.io/extensions.sampling/types/request'
3
3
 
4
- declare namespace toa.samples {
4
+ declare namespace toa.samples{
5
5
 
6
- namespace operations {
6
+ namespace operations{
7
7
 
8
8
  type Call = {
9
9
  input?: any
@@ -1,10 +1,10 @@
1
- import * as _core from '@toa.io/core/types'
1
+ import * as _core from '@toa.io/core'
2
2
  import * as _operations from './operation'
3
3
  import * as _messages from './message'
4
4
 
5
- declare namespace toa.samples {
5
+ declare namespace toa.samples{
6
6
 
7
- namespace suite {
7
+ namespace suite{
8
8
  type Operations = Record<string, _operations.Set>
9
9
 
10
10
  type Options = {
@@ -3,6 +3,7 @@
3
3
  const { manifest } = require('./manifest')
4
4
  const { component } = require('./component')
5
5
  const { composition } = require('./composition')
6
+ const { service } = require('./service')
6
7
  const { remote } = require('./remote')
7
8
  const { shutdown } = require('./shutdown')
8
9
  const binding = require('./binding')
@@ -11,6 +12,7 @@ exports.manifest = manifest
11
12
  exports.component = component
12
13
  exports.composition = composition
13
14
  exports.compose = composition
15
+ exports.serve = service
14
16
  exports.remote = remote
15
17
  exports.shutdown = shutdown
16
18
  exports.binding = binding
@@ -0,0 +1,20 @@
1
+ 'use strict'
2
+
3
+ const boot = require('@toa.io/boot')
4
+ const { state } = require('./state')
5
+ const { shortcuts } = require('@toa.io/norm')
6
+
7
+ const service = async (ref) => {
8
+ const path = shortcuts.resolve(ref)
9
+ const { Factory } = require(path)
10
+ const factory = new Factory(boot)
11
+ const service = factory.service()
12
+
13
+ await service.connect()
14
+
15
+ state.services.push(service)
16
+
17
+ return service
18
+ }
19
+
20
+ exports.service = service
@@ -7,8 +7,9 @@ const { binding } = require('./binding')
7
7
  const shutdown = async () => {
8
8
  const components = state.components.map((component) => component.disconnect())
9
9
  const compositions = state.compositions.map((composition) => composition.disconnect())
10
+ const services = state.services.map((service) => service.disconnect())
10
11
  const remotes = state.remotes.map((remote) => remote.disconnect())
11
- const disconnections = [...components, ...compositions, ...remotes]
12
+ const disconnections = [...components, ...compositions, ...services, ...remotes]
12
13
 
13
14
  await Promise.all(disconnections)
14
15
 
@@ -7,7 +7,8 @@ const reset = () => {
7
7
  reset,
8
8
  components: [],
9
9
  compositions: [],
10
- remotes: []
10
+ remotes: [],
11
+ services: []
11
12
  })
12
13
  }
13
14
 
@@ -1,16 +1,16 @@
1
- import * as _core from '@toa.io/core/types'
1
+ import * as _core from '@toa.io/core'
2
2
 
3
- declare namespace toa.stage.binding {
3
+ declare namespace toa.stage.binding{
4
4
 
5
5
  type Callback = (message: Object) => Promise<void>
6
6
  type Call = (request: Object) => Promise<Object>
7
7
 
8
- interface Binding {
9
- subscribe(label: string, callback: Callback): Promise<void>
8
+ interface Binding{
9
+ subscribe (label: string, callback: Callback): Promise<void>
10
10
 
11
- emit(label: string, message: Object): Promise<undefined>
11
+ emit (label: string, message: Object): Promise<undefined>
12
12
 
13
- reply(label, call: Call): Promise<Object>
13
+ reply (label, call: Call): Promise<Object>
14
14
  }
15
15
 
16
16
  }
@@ -1,4 +1,4 @@
1
- import * as _core from '@toa.io/core/types'
1
+ import * as _core from '@toa.io/core'
2
2
  import * as _norm from '@toa.io/norm/types'
3
3
  import * as _composition from '@toa.io/boot/types/composition'
4
4
 
@@ -10,6 +10,8 @@ export function composition (paths: string[], options?: _composition.Options): P
10
10
 
11
11
  export function compose (paths: string[]): Promise<void>
12
12
 
13
+ export function serve (ref: string): Promise<_core.Component>
14
+
13
15
  export function remote (id: string): Promise<_core.Component>
14
16
 
15
17
  export function shutdown (): Promise<void>
@@ -1,11 +1,12 @@
1
- import * as _core from '@toa.io/core/types'
1
+ import * as _core from '@toa.io/core'
2
2
 
3
- declare namespace toa.stage {
3
+ declare namespace toa.stage{
4
4
 
5
5
  type State = {
6
6
  reset: () => void
7
7
  components: _core.Component[]
8
8
  compositions: _core.Connector[]
9
+ services: _core.Connector[]
9
10
  remotes: _core.Component[]
10
11
  }
11
12