@toa.io/userland 0.24.0-alpha.0 → 0.24.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.
- package/package.json +9 -9
- 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/index.d.ts +2 -0
- package/stage/types/state.d.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/userland",
|
|
3
|
-
"version": "0.24.0-alpha.
|
|
3
|
+
"version": "0.24.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": "0.24.0-alpha.
|
|
28
|
-
"@toa.io/core": "0.24.0-alpha.
|
|
29
|
-
"@toa.io/filesystem": "0.24.0-alpha.
|
|
30
|
-
"@toa.io/generic": "0.24.0-alpha.
|
|
31
|
-
"@toa.io/norm": "0.24.0-alpha.
|
|
32
|
-
"@toa.io/schemas": "0.24.0-alpha.
|
|
27
|
+
"@toa.io/boot": "0.24.0-alpha.3",
|
|
28
|
+
"@toa.io/core": "0.24.0-alpha.3",
|
|
29
|
+
"@toa.io/filesystem": "0.24.0-alpha.3",
|
|
30
|
+
"@toa.io/generic": "0.24.0-alpha.3",
|
|
31
|
+
"@toa.io/norm": "0.24.0-alpha.3",
|
|
32
|
+
"@toa.io/schemas": "0.24.0-alpha.3",
|
|
33
33
|
"@toa.io/storages.null": "0.22.0",
|
|
34
|
-
"@toa.io/yaml": "0.24.0-alpha.
|
|
34
|
+
"@toa.io/yaml": "0.24.0-alpha.3",
|
|
35
35
|
"tap": "16.3.4"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "3cc48302f33c5594dff99034b809ea2ac49d4b02"
|
|
38
38
|
}
|
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/index.d.ts
CHANGED
|
@@ -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
1
|
import * as _core from '@toa.io/core/types'
|
|
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
|
|