@toa.io/core 1.0.0-alpha.29 → 1.0.0-alpha.30

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/core",
3
- "version": "1.0.0-alpha.29",
3
+ "version": "1.0.0-alpha.30",
4
4
  "description": "Toa Core",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -21,13 +21,13 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@rsql/parser": "1.2.4",
24
- "@toa.io/console": "1.0.0-alpha.29",
25
- "@toa.io/generic": "1.0.0-alpha.29",
26
- "@toa.io/yaml": "1.0.0-alpha.29",
24
+ "@toa.io/console": "1.0.0-alpha.30",
25
+ "@toa.io/generic": "1.0.0-alpha.30",
26
+ "@toa.io/yaml": "1.0.0-alpha.30",
27
27
  "error-value": "0.3.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "clone-deep": "4.0.1"
31
31
  },
32
- "gitHead": "186d0e17c12a9016b8076edf925963cbb32b9219"
32
+ "gitHead": "29cc19358f35fbe9229dced979724f7a26538013"
33
33
  }
package/src/cascade.js CHANGED
@@ -1,16 +1,15 @@
1
1
  'use strict'
2
2
 
3
- const { merge } = require('@toa.io/generic')
4
3
  const { Connector } = require('./connector')
5
4
 
6
5
  class Cascade extends Connector {
7
- #bridges
6
+ // #bridges
8
7
  #last
9
8
 
10
9
  constructor (bridges) {
11
10
  super()
12
11
 
13
- this.#bridges = bridges
12
+ // this.#bridges = bridges
14
13
  this.#last = bridges[bridges.length - 1]
15
14
 
16
15
  this.depends(bridges)
@@ -1,10 +1,5 @@
1
1
  'use strict'
2
2
 
3
- const {
4
- merge,
5
- overwrite,
6
- newid
7
- } = require('@toa.io/generic')
8
3
  const { EntityContractException } = require('../exceptions')
9
4
 
10
5
  class Changeset {
@@ -1,10 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const {
4
- difference,
5
- newid
6
- } = require('@toa.io/generic')
7
-
3
+ const { difference, newid } = require('@toa.io/generic')
8
4
  const { EntityContractException } = require('../exceptions')
9
5
 
10
6
  class Entity {
@@ -32,7 +28,8 @@ class Entity {
32
28
  set (value) {
33
29
  const error = this.#schema.fit(value)
34
30
 
35
- if (error !== null) throw new EntityContractException(error)
31
+ if (error !== null)
32
+ throw new EntityContractException(error)
36
33
 
37
34
  this.#set(value)
38
35
  }
@@ -41,7 +38,8 @@ class Entity {
41
38
  return {
42
39
  origin: this.#origin,
43
40
  state: this.#state,
44
- changeset: this.#origin === null ? this.#state : difference(this.#origin, this.#state)
41
+ changeset: this.#origin === null ? this.#state : difference(this.#origin, this.#state),
42
+ trailers: this.#state._trailers
45
43
  }
46
44
  }
47
45
 
@@ -56,10 +54,13 @@ class Entity {
56
54
  }
57
55
 
58
56
  #set (value) {
59
- Object.defineProperty(value, 'id', {
60
- writable: false,
61
- configurable: false
62
- })
57
+ if (!('_trailers' in value))
58
+ Object.defineProperty(value, '_trailers', {
59
+ writable: false,
60
+ configurable: false,
61
+ enumerable: false,
62
+ value: {}
63
+ })
63
64
 
64
65
  if (this.#state !== undefined) {
65
66
  value._updated = Date.now()
package/src/transition.js CHANGED
@@ -34,12 +34,7 @@ class Transition extends Operation {
34
34
  }
35
35
 
36
36
  async commit (store) {
37
- const {
38
- scope,
39
- state,
40
- reply,
41
- retry
42
- } = store
37
+ const { scope, state, reply, retry } = store
43
38
 
44
39
  if (reply.error !== undefined) return
45
40
 
@@ -48,11 +43,10 @@ class Transition extends Operation {
48
43
  const result = await this.scope.commit(scope)
49
44
 
50
45
  if (result === false) {
51
- if (this.#concurrency === 'retry') {
46
+ if (this.#concurrency === 'retry')
52
47
  return retry()
53
- } else {
48
+ else
54
49
  throw new StateConcurrencyException()
55
- }
56
50
  }
57
51
  }
58
52
 
@@ -63,20 +63,3 @@ it('should provide event', () => {
63
63
  })
64
64
  }))
65
65
  })
66
-
67
- it('should define `id` as readonly', async () => {
68
- const origin = fixtures.state()
69
- const entity = new Entity(fixtures.schema, origin)
70
- const state = entity.get()
71
-
72
- expect(() => (state.id = 1)).toThrow('assign to read only property')
73
- })
74
-
75
- it('should seal id', async () => {
76
- const origin = fixtures.state()
77
- const entity = new Entity(fixtures.schema, origin)
78
- const state = entity.get()
79
- const redefine = () => Object.defineProperty(state, 'id', { writable: true })
80
-
81
- expect(redefine).toThrow('redefine property')
82
- })