@toa.io/userland 1.0.0-alpha.3 → 1.0.0-alpha.300
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 +107 -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 +37 -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/readme.md +0 -2
- 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 +17 -17
- package/stage/src/manifest.js +2 -6
- package/stage/src/remote.js +11 -8
- package/stage/src/service.js +11 -10
- package/stage/src/shutdown.js +10 -9
- package/stage/src/state.js +2 -4
- package/stage/src/workload.js +19 -0
- package/stage/test/boot.mock.js +9 -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 +17 -9
- package/stage/types/state.d.ts +3 -4
- package/example/components/echo/samples/get.yaml +0 -12
- package/example/components/echo/samples/signal.yaml +0 -4
- package/example/components/math.calculations/samples/add.yaml +0 -10
- package/example/components/math.calculations/samples/assets/ab.yaml +0 -2
- package/example/components/math.calculations/samples/increment.yaml +0 -27
- package/example/components/math.proxy/samples/add.yaml +0 -11
- package/example/components/tea.pots/samples/same.yaml +0 -8
- package/example/components/tea.pots/samples/transit.yaml +0 -43
- package/example/components/web/samples/get.yaml +0 -8
- package/example/samples/math.proxy.add.yaml +0 -5
- package/example/samples/messages/store.orders.created.yaml +0 -8
- package/samples/docs/sampling-dark.jpg +0 -0
- package/samples/docs/sampling-light.jpg +0 -0
- package/samples/notes.md +0 -12
- package/samples/package.json +0 -5
- package/samples/readme.md +0 -131
- package/samples/src/.replay/.suite/component.js +0 -20
- package/samples/src/.replay/.suite/index.js +0 -7
- package/samples/src/.replay/.suite/messages.js +0 -39
- package/samples/src/.replay/.suite/operation.js +0 -28
- package/samples/src/.replay/.suite/operations.js +0 -20
- package/samples/src/.replay/.suite/translate/.message/index.js +0 -5
- package/samples/src/.replay/.suite/translate/.message/request.js +0 -31
- package/samples/src/.replay/.suite/translate/.operation/.prepare/cast.js +0 -20
- package/samples/src/.replay/.suite/translate/.operation/.prepare/cast.test.js +0 -94
- package/samples/src/.replay/.suite/translate/.operation/.prepare/expand.js +0 -14
- package/samples/src/.replay/.suite/translate/.operation/.prepare/index.js +0 -7
- package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/.aspect.js +0 -26
- package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/configuration.js +0 -5
- package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/http.js +0 -5
- package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/index.js +0 -9
- package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/state.js +0 -5
- package/samples/src/.replay/.suite/translate/.operation/.prepare/types/async.js +0 -3
- package/samples/src/.replay/.suite/translate/.operation/.prepare/types/cast.js +0 -26
- package/samples/src/.replay/.suite/translate/.operation/.prepare/types/index.js +0 -5
- package/samples/src/.replay/.suite/translate/.operation/.prepare/types/map.js +0 -3
- package/samples/src/.replay/.suite/translate/.operation/.prepare/types/set.js +0 -3
- package/samples/src/.replay/.suite/translate/.operation/.prepare/types/sync.js +0 -3
- package/samples/src/.replay/.suite/translate/.operation/calls.js +0 -49
- package/samples/src/.replay/.suite/translate/.operation/cleanup.js +0 -16
- package/samples/src/.replay/.suite/translate/.operation/events.js +0 -16
- package/samples/src/.replay/.suite/translate/.operation/index.js +0 -11
- package/samples/src/.replay/.suite/translate/.operation/prepare.js +0 -14
- package/samples/src/.replay/.suite/translate/index.js +0 -7
- package/samples/src/.replay/.suite/translate/message.js +0 -26
- package/samples/src/.replay/.suite/translate/operation.js +0 -47
- package/samples/src/.replay/.suite/translate/schemas/index.js +0 -7
- package/samples/src/.replay/.suite/translate/schemas/message.cos.yaml +0 -10
- package/samples/src/.replay/.suite/translate/schemas/operation.cos.yaml +0 -23
- package/samples/src/.replay/index.js +0 -7
- package/samples/src/.replay/stage.js +0 -60
- package/samples/src/.replay/suite.js +0 -23
- package/samples/src/.replay/test.js +0 -19
- package/samples/src/components.js +0 -13
- package/samples/src/context.js +0 -23
- package/samples/src/index.js +0 -9
- package/samples/src/replay.js +0 -16
- package/samples/src/suite/.read/filter.js +0 -15
- package/samples/src/suite/.read/index.js +0 -7
- package/samples/src/suite/.read/messages.js +0 -40
- package/samples/src/suite/.read/operations.js +0 -51
- package/samples/src/suite/.read/parse.js +0 -20
- package/samples/src/suite/components.js +0 -31
- package/samples/src/suite/context.js +0 -20
- package/samples/src/suite/index.js +0 -7
- package/samples/test/components.test.js +0 -42
- package/samples/test/context/components/dummy/manifest.toa.yaml +0 -2
- package/samples/test/context/components/dummy/samples/do.yaml +0 -11
- package/samples/test/context/components/dummy/samples/dummies.dummy.do.yaml +0 -11
- package/samples/test/context/components/dummy/samples/dummies.dummy.undo.yaml +0 -7
- package/samples/test/context/components/dummy/samples/messages/somewhere.something.happened.yaml +0 -6
- package/samples/test/context/components/pot/manifest.toa.yaml +0 -2
- package/samples/test/context/components/pot/samples/do.yaml +0 -11
- package/samples/test/context/components/pot/samples/messages/somewhere.something.happened.yaml +0 -6
- package/samples/test/context/context.toa.yaml +0 -3
- package/samples/test/context/samples/dummies.dummy.observe.yaml +0 -6
- package/samples/test/context/samples/dummies.dummy.transit.yaml +0 -10
- package/samples/test/context/samples/messages/somewhere.something.happened.yaml +0 -6
- package/samples/test/context.fixtures.js +0 -8
- package/samples/test/context.test.js +0 -82
- package/samples/test/replay.mock.js +0 -7
- package/samples/test/replay.test.js +0 -152
- package/samples/test/replay.translate.message.fixtures.js +0 -24
- package/samples/test/replay.translate.message.test.js +0 -119
- package/samples/test/replay.translate.mock.js +0 -17
- package/samples/test/replay.translate.operation.fixtures.js +0 -107
- package/samples/test/replay.translate.operation.test.js +0 -68
- package/samples/test/stage.mock.js +0 -30
- package/samples/test/suite.components.test.js +0 -122
- package/samples/test/suite.context.test.js +0 -79
- package/samples/test/suite.mock.js +0 -10
- package/samples/types/index.d.ts +0 -8
- package/samples/types/message.d.ts +0 -24
- package/samples/types/operation.d.ts +0 -36
- package/samples/types/replay.d.ts +0 -13
- package/samples/types/suite.d.ts +0 -31
- package/stage/src/binding/binding.js +0 -50
- package/stage/src/binding/consumer.js +0 -30
- package/stage/src/binding/emitter.js +0 -26
- 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 -54
- 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,15 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { properties, binding, Factory } = require('../../src').binding
|
|
4
|
-
|
|
5
|
-
it('should be async', async () => {
|
|
6
|
-
expect(properties.async).toStrictEqual(true)
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
it('should export Factory', async () => {
|
|
10
|
-
expect(Factory).toBeDefined()
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it('should export binding instance', async () => {
|
|
14
|
-
expect(binding).toBeDefined()
|
|
15
|
-
})
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { generate } = require('randomstring')
|
|
4
|
-
const { Connector, Locator } = require('@toa.io/core')
|
|
5
|
-
|
|
6
|
-
const { binding, Factory } = require('../../src/binding')
|
|
7
|
-
|
|
8
|
-
const factory = new Factory()
|
|
9
|
-
|
|
10
|
-
it('should expose consumers factory', async () => {
|
|
11
|
-
expect(factory.consumer).toBeDefined()
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
/** @type {toa.core.bindings.Consumer} */
|
|
15
|
-
let consumer
|
|
16
|
-
|
|
17
|
-
/** @type {toa.core.Locator} */
|
|
18
|
-
let locator
|
|
19
|
-
|
|
20
|
-
/** @type {string} */
|
|
21
|
-
let label
|
|
22
|
-
|
|
23
|
-
const endpoint = generate()
|
|
24
|
-
|
|
25
|
-
beforeEach(() => {
|
|
26
|
-
jest.clearAllMocks()
|
|
27
|
-
binding.reset()
|
|
28
|
-
|
|
29
|
-
const namespace = generate()
|
|
30
|
-
const name = generate()
|
|
31
|
-
|
|
32
|
-
locator = new Locator(name, namespace)
|
|
33
|
-
label = locator.id + '.' + endpoint
|
|
34
|
-
consumer = factory.consumer(locator, endpoint)
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('should return Connector', async () => {
|
|
38
|
-
expect(consumer).toBeInstanceOf(Connector)
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('should return reply', async () => {
|
|
42
|
-
const request = generate()
|
|
43
|
-
const reply = generate()
|
|
44
|
-
const call = jest.fn(async () => reply)
|
|
45
|
-
|
|
46
|
-
await binding.reply(label, call)
|
|
47
|
-
|
|
48
|
-
const received = await consumer.request(request)
|
|
49
|
-
|
|
50
|
-
expect(call).toHaveBeenCalledWith(request)
|
|
51
|
-
expect(received).toStrictEqual(reply)
|
|
52
|
-
})
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { generate } = require('randomstring')
|
|
4
|
-
const { Locator, Connector } = require('@toa.io/core')
|
|
5
|
-
|
|
6
|
-
const { binding, Factory } = require('../../src/binding')
|
|
7
|
-
|
|
8
|
-
const factory = new Factory()
|
|
9
|
-
|
|
10
|
-
it('should expose emitters factory', async () => {
|
|
11
|
-
expect(factory.emitter).toBeDefined()
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
/** @type {toa.core.bindings.Emitter} */
|
|
15
|
-
let emitter
|
|
16
|
-
|
|
17
|
-
/** @type {string} */
|
|
18
|
-
let label
|
|
19
|
-
|
|
20
|
-
/** @type {toa.core.Locator} */
|
|
21
|
-
let locator
|
|
22
|
-
|
|
23
|
-
const endpoint = generate()
|
|
24
|
-
|
|
25
|
-
beforeEach(() => {
|
|
26
|
-
jest.clearAllMocks()
|
|
27
|
-
binding.reset()
|
|
28
|
-
|
|
29
|
-
const namespace = generate()
|
|
30
|
-
const name = generate()
|
|
31
|
-
|
|
32
|
-
locator = new Locator(name, namespace)
|
|
33
|
-
label = locator.id + '.' + endpoint
|
|
34
|
-
emitter = factory.emitter(locator, endpoint)
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('should return Connector', async () => {
|
|
38
|
-
expect(emitter).toBeInstanceOf(Connector)
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('should call receiver', async () => {
|
|
42
|
-
const callback = jest.fn(async () => undefined)
|
|
43
|
-
|
|
44
|
-
await binding.subscribe(label, callback)
|
|
45
|
-
|
|
46
|
-
const payload = { [generate()]: generate() }
|
|
47
|
-
|
|
48
|
-
/** @type {toa.core.Message} */
|
|
49
|
-
const message = { payload }
|
|
50
|
-
|
|
51
|
-
await emitter.emit(message)
|
|
52
|
-
|
|
53
|
-
expect(callback).toHaveBeenCalledWith(message)
|
|
54
|
-
})
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { generate } = require('randomstring')
|
|
4
|
-
|
|
5
|
-
const endpoints = [generate(), generate()]
|
|
6
|
-
const invoke = jest.fn(async () => generate())
|
|
7
|
-
const producer = /** @type {jest.MockedObject<toa.core.Component>} */ { invoke }
|
|
8
|
-
|
|
9
|
-
exports.endpoints = endpoints
|
|
10
|
-
exports.producer = producer
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { generate } = require('randomstring')
|
|
4
|
-
const { Locator, Connector } = require('@toa.io/core')
|
|
5
|
-
const { sample } = require('@toa.io/generic')
|
|
6
|
-
|
|
7
|
-
const fixtures = require('./producer.fixtures')
|
|
8
|
-
const { binding, Factory } = require('../../src/binding')
|
|
9
|
-
|
|
10
|
-
const factory = new Factory()
|
|
11
|
-
|
|
12
|
-
it('should expose producers factory', async () => {
|
|
13
|
-
expect(factory.producer).toBeDefined()
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
/** @type {toa.core.Connector} */
|
|
17
|
-
let producer
|
|
18
|
-
|
|
19
|
-
/** @type {toa.core.Locator} */
|
|
20
|
-
let locator
|
|
21
|
-
|
|
22
|
-
beforeEach(async () => {
|
|
23
|
-
jest.clearAllMocks()
|
|
24
|
-
binding.reset()
|
|
25
|
-
|
|
26
|
-
const namespace = generate()
|
|
27
|
-
const name = generate()
|
|
28
|
-
|
|
29
|
-
locator = new Locator(name, namespace)
|
|
30
|
-
producer = factory.producer(locator, fixtures.endpoints, fixtures.producer)
|
|
31
|
-
|
|
32
|
-
await producer.connect()
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('should return Connector', async () => {
|
|
36
|
-
expect(producer).toBeInstanceOf(Connector)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('should return result', async () => {
|
|
40
|
-
const endpoint = sample(fixtures.endpoints)
|
|
41
|
-
const label = locator.id + '.' + endpoint
|
|
42
|
-
const request = { [generate()]: generate() }
|
|
43
|
-
|
|
44
|
-
const reply = await binding.request(label, request)
|
|
45
|
-
|
|
46
|
-
expect(fixtures.producer.invoke).toHaveBeenCalledWith(endpoint, request)
|
|
47
|
-
|
|
48
|
-
expect(reply).toStrictEqual(await fixtures.producer.invoke.mock.results[0].value)
|
|
49
|
-
})
|
|
@@ -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
|