@toa.io/userland 1.0.0-alpha.0 → 1.0.0-alpha.2
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/example/components/math.calculations/manifest.toa.yaml +0 -2
- package/example/components/math.proxy/manifest.toa.yaml +0 -2
- package/package.json +9 -9
- package/samples/types/message.d.ts +3 -3
- package/samples/types/operation.d.ts +3 -3
- package/samples/types/suite.d.ts +3 -3
- package/stage/src/index.js +2 -0
- package/stage/src/service.js +20 -0
- package/stage/src/shutdown.js +2 -1
- package/stage/src/state.js +2 -1
- package/stage/types/binding.d.ts +6 -6
- package/stage/types/index.d.ts +3 -1
- package/stage/types/state.d.ts +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/userland",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.2",
|
|
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.
|
|
28
|
-
"@toa.io/core": "1.0.0-alpha.
|
|
29
|
-
"@toa.io/filesystem": "1.0.0-alpha.
|
|
30
|
-
"@toa.io/generic": "1.0.0-alpha.
|
|
31
|
-
"@toa.io/norm": "1.0.0-alpha.
|
|
32
|
-
"@toa.io/schemas": "1.0.0-alpha.
|
|
27
|
+
"@toa.io/boot": "1.0.0-alpha.2",
|
|
28
|
+
"@toa.io/core": "1.0.0-alpha.2",
|
|
29
|
+
"@toa.io/filesystem": "1.0.0-alpha.2",
|
|
30
|
+
"@toa.io/generic": "1.0.0-alpha.2",
|
|
31
|
+
"@toa.io/norm": "1.0.0-alpha.2",
|
|
32
|
+
"@toa.io/schemas": "1.0.0-alpha.2",
|
|
33
33
|
"@toa.io/storages.null": "0.22.0",
|
|
34
|
-
"@toa.io/yaml": "1.0.0-alpha.
|
|
34
|
+
"@toa.io/yaml": "1.0.0-alpha.2",
|
|
35
35
|
"tap": "16.3.4"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "7688e6e980a65c82ac2e459be4e355eebf406cd0"
|
|
38
38
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type * as _core from '@toa.io/core
|
|
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
|
|
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
|
package/samples/types/suite.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as _core from '@toa.io/core
|
|
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 = {
|
package/stage/src/index.js
CHANGED
|
@@ -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
|
package/stage/src/shutdown.js
CHANGED
|
@@ -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
|
|
package/stage/src/state.js
CHANGED
package/stage/types/binding.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import * as _core from '@toa.io/core
|
|
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
|
}
|
package/stage/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as _core from '@toa.io/core
|
|
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>
|
package/stage/types/state.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import * as _core from '@toa.io/core
|
|
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
|
|