@toa.io/core 1.0.0-alpha.13 → 1.0.0-alpha.15

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.13",
3
+ "version": "1.0.0-alpha.15",
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.13",
25
- "@toa.io/generic": "1.0.0-alpha.13",
26
- "@toa.io/yaml": "1.0.0-alpha.13",
24
+ "@toa.io/console": "1.0.0-alpha.15",
25
+ "@toa.io/generic": "1.0.0-alpha.15",
26
+ "@toa.io/yaml": "1.0.0-alpha.15",
27
27
  "error-value": "0.3.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "clone-deep": "4.0.1"
31
31
  },
32
- "gitHead": "f779cc4a98abe96e4e928b918f9521826403536b"
32
+ "gitHead": "8c42f0b136162a579859d6baa7f940bd16c66821"
33
33
  }
package/src/exceptions.js CHANGED
@@ -89,7 +89,7 @@ for (const [name, code] of Object.entries(codes)) {
89
89
  if (exports[classname] === undefined) {
90
90
  exports[classname] = class extends Exception {
91
91
  constructor (message) {
92
- super(code, message || classname)
92
+ super(code, message ?? classname)
93
93
  }
94
94
  }
95
95
  }
package/src/state.js CHANGED
@@ -65,7 +65,9 @@ class State {
65
65
  ok = await this.#storage.store(object)
66
66
 
67
67
  // #20
68
- await this.#emission.emit(event)
68
+ if (ok === true) {
69
+ await this.#emission.emit(event)
70
+ }
69
71
  }
70
72
 
71
73
  return ok
package/src/transition.js CHANGED
@@ -5,9 +5,7 @@ const { retry } = require('@toa.io/generic')
5
5
  const { Operation } = require('./operation')
6
6
  const {
7
7
  StateConcurrencyException,
8
- StateNotFoundException,
9
- DuplicateException,
10
- Exception
8
+ StateNotFoundException
11
9
  } = require('./exceptions')
12
10
 
13
11
  class Transition extends Operation {
@@ -28,7 +26,9 @@ class Transition extends Operation {
28
26
 
29
27
  store.scope = request.query ? await this.query(request.query) : this.scope.init()
30
28
 
31
- if (store.scope === null) throw new StateNotFoundException()
29
+ if (store.scope === null) {
30
+ throw new StateNotFoundException()
31
+ }
32
32
 
33
33
  store.state = store.scope.get()
34
34
  }
@@ -47,16 +47,13 @@ class Transition extends Operation {
47
47
 
48
48
  const result = await this.scope.commit(scope)
49
49
 
50
- if (result === false ||
51
- (result instanceof DuplicateException && result.message.includes('_id'))) {
50
+ if (result === false) {
52
51
  if (this.#concurrency === 'retry') {
53
52
  return retry()
54
53
  } else {
55
54
  throw new StateConcurrencyException()
56
55
  }
57
56
  }
58
-
59
- if (result instanceof Exception) throw result
60
57
  }
61
58
 
62
59
  async #retry (store, retry) {