@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.
Files changed (59) hide show
  1. package/CHANGELOG.md +189 -0
  2. package/example/components/echo/manifest.toa.yaml +15 -5
  3. package/example/components/echo/operations/get.js +1 -5
  4. package/example/components/echo/operations/resolve.js +1 -5
  5. package/example/components/echo/operations/signal.js +3 -7
  6. package/example/components/math.calculations/manifest.toa.yaml +19 -6
  7. package/example/components/math.calculations/operations/add.js +1 -5
  8. package/example/components/math.calculations/operations/increment.js +1 -5
  9. package/example/components/math.proxy/manifest.toa.yaml +8 -3
  10. package/example/components/math.proxy/operations/add.js +1 -5
  11. package/example/components/tea.pots/manifest.toa.yaml +29 -9
  12. package/example/components/tea.pots/operations/same.js +1 -5
  13. package/example/components/tea.pots/receivers/store.orders.created.js +1 -5
  14. package/example/components/web/manifest.toa.yaml +2 -4
  15. package/example/components/web/operations/get.js +3 -8
  16. package/example/context.toa.yaml +2 -7
  17. package/example/stage/call.test.js +17 -10
  18. package/example/stage/events.test.js +63 -16
  19. package/example/stage/invoke.test.js +12 -9
  20. package/package.json +18 -13
  21. package/stage/package.json +1 -0
  22. package/stage/src/component.js +3 -12
  23. package/stage/src/composition.js +3 -11
  24. package/stage/src/index.js +9 -18
  25. package/stage/src/manifest.js +2 -6
  26. package/stage/src/map.js +15 -0
  27. package/stage/src/quiescence.js +16 -0
  28. package/stage/src/remote.js +11 -8
  29. package/stage/src/service.js +11 -10
  30. package/stage/src/shutdown.js +16 -8
  31. package/stage/src/state.js +2 -4
  32. package/stage/src/workload.js +55 -0
  33. package/stage/test/boot.mock.js +10 -11
  34. package/stage/test/component.test.js +20 -10
  35. package/stage/test/composition.test.js +11 -20
  36. package/stage/test/manifest.test.js +15 -8
  37. package/stage/test/remote.test.js +14 -12
  38. package/stage/test/shutdown.test.js +26 -22
  39. package/stage/test/state.mock.js +5 -6
  40. package/stage/test/state.test.js +13 -12
  41. package/stage/types/index.d.ts +20 -9
  42. package/stage/types/state.d.ts +3 -4
  43. package/stage/src/binding/binding.js +0 -50
  44. package/stage/src/binding/consumer.js +0 -32
  45. package/stage/src/binding/emitter.js +0 -27
  46. package/stage/src/binding/factory.js +0 -49
  47. package/stage/src/binding/index.js +0 -10
  48. package/stage/src/binding/label.js +0 -12
  49. package/stage/src/binding/producer.js +0 -43
  50. package/stage/src/binding/receiver.js +0 -34
  51. package/stage/test/binding/binding.test.js +0 -15
  52. package/stage/test/binding/consumer.test.js +0 -52
  53. package/stage/test/binding/emitter.test.js +0 -78
  54. package/stage/test/binding/producer.fixtures.js +0 -10
  55. package/stage/test/binding/producer.test.js +0 -49
  56. package/stage/test/binding/receiver.fixtures.js +0 -7
  57. package/stage/test/binding/receiver.test.js +0 -54
  58. package/stage/test/binding.mock.js +0 -8
  59. package/stage/types/binding.d.ts +0 -20
@@ -1,7 +0,0 @@
1
- 'use strict'
2
-
3
- const receiver = /** @type {jest.MockedObject<toa.core.Receiver>} */ {
4
- receive: jest.fn(async () => undefined)
5
- }
6
-
7
- exports.receiver = receiver
@@ -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
- })
@@ -1,8 +0,0 @@
1
- 'use strict'
2
-
3
- const original = jest.requireActual('../src/binding')
4
-
5
- const reset = jest.fn(() => original.binding.reset())
6
- const binding = { ...original.binding, reset }
7
-
8
- module.exports = { binding }
@@ -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