@toa.io/userland 0.10.1-dev.0 → 1.0.0-dev.0
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.
|
@@ -4,7 +4,7 @@ namespace: tea
|
|
|
4
4
|
entity:
|
|
5
5
|
storage: mongodb
|
|
6
6
|
schema:
|
|
7
|
-
material*: [glass, ceramic, steel]
|
|
7
|
+
material*: [ glass, ceramic, steel ]
|
|
8
8
|
volume: number
|
|
9
9
|
booked: false
|
|
10
10
|
|
|
@@ -21,7 +21,7 @@ operations:
|
|
|
21
21
|
|
|
22
22
|
receivers:
|
|
23
23
|
store.orders.created:
|
|
24
|
-
|
|
24
|
+
operation: transit
|
|
25
25
|
binding: amqp # avoid discovery
|
|
26
26
|
|
|
27
27
|
configuration:
|
|
@@ -13,6 +13,8 @@ let echo
|
|
|
13
13
|
let math
|
|
14
14
|
|
|
15
15
|
beforeAll(async () => {
|
|
16
|
+
process.env.TOA_DEV = '1'
|
|
17
|
+
|
|
16
18
|
const paths = ['echo', 'math.calculations'].map((rel) => resolve(root, rel))
|
|
17
19
|
|
|
18
20
|
await stage.composition(paths)
|
|
@@ -23,6 +25,8 @@ beforeAll(async () => {
|
|
|
23
25
|
|
|
24
26
|
afterAll(async () => {
|
|
25
27
|
await stage.shutdown()
|
|
28
|
+
|
|
29
|
+
delete process.env.TOA_DEV
|
|
26
30
|
})
|
|
27
31
|
|
|
28
32
|
it('should call endpoint', async () => {
|
|
@@ -10,6 +10,8 @@ const root = resolve(__dirname, '../components')
|
|
|
10
10
|
let remote
|
|
11
11
|
|
|
12
12
|
beforeAll(async () => {
|
|
13
|
+
process.env.TOA_DEV = '1'
|
|
14
|
+
|
|
13
15
|
const path = resolve(root, 'tea.pots')
|
|
14
16
|
|
|
15
17
|
await stage.composition([path])
|
|
@@ -19,6 +21,8 @@ beforeAll(async () => {
|
|
|
19
21
|
|
|
20
22
|
afterAll(async () => {
|
|
21
23
|
await stage.shutdown()
|
|
24
|
+
|
|
25
|
+
delete process.env.TOA_DEV
|
|
22
26
|
})
|
|
23
27
|
|
|
24
28
|
it('should receive event', async () => {
|
|
@@ -9,6 +9,8 @@ const root = resolve(__dirname, '../components')
|
|
|
9
9
|
let component
|
|
10
10
|
|
|
11
11
|
beforeAll(async () => {
|
|
12
|
+
process.env.TOA_DEV = '1'
|
|
13
|
+
|
|
12
14
|
const path = resolve(root, 'math.calculations')
|
|
13
15
|
|
|
14
16
|
component = await stage.component(path)
|
|
@@ -16,6 +18,8 @@ beforeAll(async () => {
|
|
|
16
18
|
|
|
17
19
|
afterAll(async () => {
|
|
18
20
|
await stage.shutdown()
|
|
21
|
+
|
|
22
|
+
delete process.env.TOA_DEV
|
|
19
23
|
})
|
|
20
24
|
|
|
21
25
|
it('should invoke', async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/userland",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-dev.0",
|
|
4
4
|
"description": "Toa development kit",
|
|
5
5
|
"homepage": "https://toa.io",
|
|
6
6
|
"author": {
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"main": "src/index.js",
|
|
25
25
|
"types": "types/index.d.ts",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@toa.io/boot": "0.
|
|
28
|
-
"@toa.io/core": "0.
|
|
29
|
-
"@toa.io/filesystem": "0.
|
|
27
|
+
"@toa.io/boot": "1.0.0-dev.0",
|
|
28
|
+
"@toa.io/core": "1.0.0-dev.0",
|
|
29
|
+
"@toa.io/filesystem": "1.0.0-dev.0",
|
|
30
30
|
"@toa.io/generic": "0.9.0",
|
|
31
|
-
"@toa.io/norm": "0.
|
|
32
|
-
"@toa.io/schemas": "0.8.
|
|
33
|
-
"@toa.io/yaml": "0.7.
|
|
31
|
+
"@toa.io/norm": "1.0.0-dev.0",
|
|
32
|
+
"@toa.io/schemas": "0.8.2-dev.0",
|
|
33
|
+
"@toa.io/yaml": "0.7.4-dev.0",
|
|
34
34
|
"tap": "16.3.4"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "2417f76be3783bd7f790cb4580e4139f2c3ff580"
|
|
37
37
|
}
|
|
@@ -5,42 +5,43 @@
|
|
|
5
5
|
*/
|
|
6
6
|
class Binding {
|
|
7
7
|
/** @type {Record<string, function[]>} */
|
|
8
|
-
#
|
|
8
|
+
#callbacks = {}
|
|
9
9
|
|
|
10
10
|
/** @type {Record<string, function>} */
|
|
11
|
-
#
|
|
11
|
+
#producers = {}
|
|
12
12
|
|
|
13
13
|
async subscribe (label, callback) {
|
|
14
|
-
if (this.#
|
|
14
|
+
if (this.#callbacks[label] === undefined) this.#callbacks[label] = []
|
|
15
15
|
|
|
16
|
-
this.#
|
|
16
|
+
this.#callbacks[label].push(callback)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
async emit (label, message) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (callbacks === undefined) return undefined
|
|
20
|
+
if (!(label in this.#callbacks)) return
|
|
23
21
|
|
|
22
|
+
const callbacks = this.#callbacks[label]
|
|
24
23
|
const promises = callbacks.map((callback) => callback(message))
|
|
25
24
|
|
|
26
25
|
await Promise.all(promises)
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
async reply (label, produce) {
|
|
30
|
-
if (
|
|
29
|
+
if (label in this.#producers) throw new Error(`Label '${label}' is already bound`)
|
|
31
30
|
|
|
32
|
-
this.#
|
|
31
|
+
this.#producers[label] = produce
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
async request (label, request) {
|
|
36
|
-
if (
|
|
35
|
+
if (!(label in this.#producers)) throw new Error(`Label '${label}' is not bound`)
|
|
36
|
+
|
|
37
|
+
const produce = this.#producers[label]
|
|
37
38
|
|
|
38
|
-
return
|
|
39
|
+
return produce(request)
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
reset () {
|
|
42
|
-
this.#
|
|
43
|
-
this.#
|
|
43
|
+
this.#callbacks = {}
|
|
44
|
+
this.#producers = {}
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
|
package/stage/src/index.js
CHANGED
|
@@ -7,9 +7,6 @@ const { remote } = require('./remote')
|
|
|
7
7
|
const { shutdown } = require('./shutdown')
|
|
8
8
|
const binding = require('./binding')
|
|
9
9
|
|
|
10
|
-
// staging always runs on local deployment environment
|
|
11
|
-
process.env.TOA_DEV = '1'
|
|
12
|
-
|
|
13
10
|
exports.manifest = manifest
|
|
14
11
|
exports.component = component
|
|
15
12
|
exports.composition = composition
|