@toa.io/userland 1.0.0-alpha.15 → 1.0.0-alpha.17

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/userland",
3
- "version": "1.0.0-alpha.15",
3
+ "version": "1.0.0-alpha.17",
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": "1.0.0-alpha.15",
28
- "@toa.io/core": "1.0.0-alpha.15",
29
- "@toa.io/filesystem": "1.0.0-alpha.15",
30
- "@toa.io/generic": "1.0.0-alpha.15",
31
- "@toa.io/norm": "1.0.0-alpha.15",
32
- "@toa.io/schemas": "1.0.0-alpha.15",
27
+ "@toa.io/boot": "1.0.0-alpha.17",
28
+ "@toa.io/core": "1.0.0-alpha.17",
29
+ "@toa.io/filesystem": "1.0.0-alpha.17",
30
+ "@toa.io/generic": "1.0.0-alpha.17",
31
+ "@toa.io/norm": "1.0.0-alpha.17",
32
+ "@toa.io/schemas": "1.0.0-alpha.17",
33
33
  "@toa.io/storages.null": "0.22.0",
34
- "@toa.io/yaml": "1.0.0-alpha.15",
34
+ "@toa.io/yaml": "1.0.0-alpha.17",
35
35
  "tap": "16.3.4"
36
36
  },
37
- "gitHead": "8c42f0b136162a579859d6baa7f940bd16c66821"
37
+ "gitHead": "40ea6c9695dc6b8dc434cad4eb413d7477238ac5"
38
38
  }
@@ -23,6 +23,8 @@ class Consumer extends Connector {
23
23
  }
24
24
 
25
25
  async request (request) {
26
+ request = JSON.parse(JSON.stringify(request))
27
+
26
28
  return binding.request(this.#label, request)
27
29
  }
28
30
  }
@@ -19,6 +19,7 @@ class Emitter extends Connector {
19
19
  }
20
20
 
21
21
  async emit (message) {
22
+ message = JSON.parse(JSON.stringify(message))
22
23
  await binding.emit(this.#label, message)
23
24
  }
24
25
  }
@@ -1,9 +1,15 @@
1
1
  'use strict'
2
2
 
3
3
  const { generate } = require('randomstring')
4
- const { Locator, Connector } = require('@toa.io/core')
4
+ const {
5
+ Locator,
6
+ Connector
7
+ } = require('@toa.io/core')
5
8
 
6
- const { binding, Factory } = require('../../src/binding')
9
+ const {
10
+ binding,
11
+ Factory
12
+ } = require('../../src/binding')
7
13
 
8
14
  const factory = new Factory()
9
15
 
@@ -52,3 +58,21 @@ it('should call receiver', async () => {
52
58
 
53
59
  expect(callback).toHaveBeenCalledWith(message)
54
60
  })
61
+
62
+ it('should not modify message', async () => {
63
+ const callback = jest.fn((payload) => {
64
+ payload.payload.foo = 'bar'
65
+ })
66
+
67
+ await binding.subscribe(label, callback)
68
+
69
+ const payload = { [generate()]: generate() }
70
+
71
+ /** @type {toa.core.Message} */
72
+ const message = { payload }
73
+ const origin = JSON.parse(JSON.stringify(message))
74
+
75
+ await emitter.emit(message)
76
+
77
+ expect(origin).toEqual(message)
78
+ })