@toa.io/userland 1.0.0-alpha.31 → 1.0.0-alpha.310
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/CHANGELOG.md +189 -0
- package/example/components/echo/manifest.toa.yaml +15 -5
- package/example/components/echo/operations/get.js +1 -5
- package/example/components/echo/operations/resolve.js +1 -5
- package/example/components/echo/operations/signal.js +3 -7
- package/example/components/math.calculations/manifest.toa.yaml +19 -6
- package/example/components/math.calculations/operations/add.js +1 -5
- package/example/components/math.calculations/operations/increment.js +1 -5
- package/example/components/math.proxy/manifest.toa.yaml +8 -3
- package/example/components/math.proxy/operations/add.js +1 -5
- package/example/components/tea.pots/manifest.toa.yaml +29 -9
- package/example/components/tea.pots/operations/same.js +1 -5
- package/example/components/tea.pots/receivers/store.orders.created.js +1 -5
- package/example/components/web/manifest.toa.yaml +2 -4
- package/example/components/web/operations/get.js +3 -8
- package/example/context.toa.yaml +2 -7
- package/example/stage/call.test.js +17 -10
- package/example/stage/events.test.js +63 -16
- package/example/stage/invoke.test.js +12 -9
- package/package.json +18 -13
- package/stage/package.json +1 -0
- package/stage/src/component.js +3 -12
- package/stage/src/composition.js +3 -11
- package/stage/src/index.js +9 -18
- package/stage/src/manifest.js +2 -6
- package/stage/src/map.js +15 -0
- package/stage/src/quiescence.js +16 -0
- package/stage/src/remote.js +11 -8
- package/stage/src/service.js +11 -10
- package/stage/src/shutdown.js +16 -8
- package/stage/src/state.js +2 -4
- package/stage/src/workload.js +55 -0
- package/stage/test/boot.mock.js +10 -11
- package/stage/test/component.test.js +20 -10
- package/stage/test/composition.test.js +11 -20
- package/stage/test/manifest.test.js +15 -8
- package/stage/test/remote.test.js +14 -12
- package/stage/test/shutdown.test.js +26 -22
- package/stage/test/state.mock.js +5 -6
- package/stage/test/state.test.js +13 -12
- package/stage/types/index.d.ts +20 -9
- package/stage/types/state.d.ts +3 -4
- package/stage/src/binding/binding.js +0 -50
- package/stage/src/binding/consumer.js +0 -32
- package/stage/src/binding/emitter.js +0 -27
- package/stage/src/binding/factory.js +0 -49
- package/stage/src/binding/index.js +0 -10
- package/stage/src/binding/label.js +0 -12
- package/stage/src/binding/producer.js +0 -43
- package/stage/src/binding/receiver.js +0 -34
- package/stage/test/binding/binding.test.js +0 -15
- package/stage/test/binding/consumer.test.js +0 -52
- package/stage/test/binding/emitter.test.js +0 -78
- package/stage/test/binding/producer.fixtures.js +0 -10
- package/stage/test/binding/producer.test.js +0 -49
- package/stage/test/binding/receiver.fixtures.js +0 -7
- package/stage/test/binding/receiver.test.js +0 -54
- package/stage/test/binding.mock.js +0 -8
- package/stage/types/binding.d.ts +0 -20
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { generate } = require('randomstring')
|
|
4
|
-
const { Locator, Connector } = require('@toa.io/core')
|
|
5
|
-
|
|
6
|
-
const fixtures = require('./receiver.fixtures')
|
|
7
|
-
const { binding, Factory } = require('../../src/binding')
|
|
8
|
-
|
|
9
|
-
const factory = new Factory()
|
|
10
|
-
|
|
11
|
-
it('should expose receivers factory', async () => {
|
|
12
|
-
expect(factory.receiver).toBeDefined()
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
/** @type {toa.core.Connector} */
|
|
16
|
-
let receiver
|
|
17
|
-
|
|
18
|
-
/** @type {toa.core.Locator} */
|
|
19
|
-
let locator
|
|
20
|
-
|
|
21
|
-
/** @type {string} */
|
|
22
|
-
let label
|
|
23
|
-
|
|
24
|
-
const group = generate()
|
|
25
|
-
const endpoint = generate()
|
|
26
|
-
|
|
27
|
-
beforeEach(async () => {
|
|
28
|
-
jest.clearAllMocks()
|
|
29
|
-
binding.reset()
|
|
30
|
-
|
|
31
|
-
const namespace = generate()
|
|
32
|
-
const name = generate()
|
|
33
|
-
|
|
34
|
-
locator = new Locator(name, namespace)
|
|
35
|
-
label = locator.id + '.' + endpoint
|
|
36
|
-
receiver = factory.receiver(locator, label, group, fixtures.receiver)
|
|
37
|
-
|
|
38
|
-
await receiver.connect()
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('should return connector', async () => {
|
|
42
|
-
expect(receiver).toBeInstanceOf(Connector)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('should call receiver', async () => {
|
|
46
|
-
const payload = { [generate()]: generate() }
|
|
47
|
-
|
|
48
|
-
/** @type {toa.core.Message} */
|
|
49
|
-
const message = { payload }
|
|
50
|
-
|
|
51
|
-
await binding.emit(label, message)
|
|
52
|
-
|
|
53
|
-
expect(fixtures.receiver.receive).toHaveBeenCalledWith(message)
|
|
54
|
-
})
|
package/stage/types/binding.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as _core from '@toa.io/core'
|
|
2
|
-
|
|
3
|
-
declare namespace toa.stage.binding{
|
|
4
|
-
|
|
5
|
-
type Callback = (message: Object) => Promise<void>
|
|
6
|
-
type Call = (request: Object) => Promise<Object>
|
|
7
|
-
|
|
8
|
-
interface Binding{
|
|
9
|
-
subscribe (label: string, callback: Callback): Promise<void>
|
|
10
|
-
|
|
11
|
-
emit (label: string, message: Object): Promise<undefined>
|
|
12
|
-
|
|
13
|
-
reply (label, call: Call): Promise<Object>
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type Factory = _core.bindings.Factory
|
|
19
|
-
export const binding: toa.stage.binding.Binding
|
|
20
|
-
export const properties: _core.bindings.Properties
|