@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 +5 -5
- package/src/exceptions.js +1 -1
- package/src/state.js +3 -1
- package/src/transition.js +5 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/core",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
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.
|
|
25
|
-
"@toa.io/generic": "1.0.0-alpha.
|
|
26
|
-
"@toa.io/yaml": "1.0.0-alpha.
|
|
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": "
|
|
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
|
|
92
|
+
super(code, message ?? classname)
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
}
|
package/src/state.js
CHANGED
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)
|
|
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) {
|