@toa.io/core 1.0.0-alpha.73 → 1.0.0-alpha.79

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.73",
3
+ "version": "1.0.0-alpha.79",
4
4
  "description": "Toa Core",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -24,7 +24,7 @@
24
24
  "@toa.io/generic": "1.0.0-alpha.63",
25
25
  "@toa.io/yaml": "1.0.0-alpha.63",
26
26
  "error-value": "0.3.0",
27
- "openspan": "1.0.0-alpha.73"
27
+ "openspan": "1.0.0-alpha.79"
28
28
  },
29
- "gitHead": "3c7d415c68324aae8f1524b2ae06b02eb5832c54"
29
+ "gitHead": "69f3f10212861886d4123786b695de1d456d9a3c"
30
30
  }
package/src/component.js CHANGED
@@ -1,7 +1,8 @@
1
1
  'use strict'
2
2
 
3
- const { Connector } = require('./connector')
4
3
  const assert = require('node:assert')
4
+ const { console } = require('openspan')
5
+ const { Connector } = require('./connector')
5
6
 
6
7
  class Component extends Connector {
7
8
  locator
@@ -22,7 +23,15 @@ class Component extends Connector {
22
23
  assert.ok(endpoint in this.operations,
23
24
  `Endpoint '${endpoint}' is not provided by '${this.locator.id}'`)
24
25
 
25
- return this.operations[endpoint].invoke(request)
26
+ const reply = await this.operations[endpoint].invoke(request)
27
+
28
+ if (reply?.exception !== undefined)
29
+ console.error('Failed to execute operation', {
30
+ endpoint: `${this.locator.id}.${endpoint}`,
31
+ exception: reply.exception
32
+ })
33
+
34
+ return reply
26
35
  }
27
36
  }
28
37
 
@@ -4,6 +4,7 @@ const { difference, newid } = require('@toa.io/generic')
4
4
  const { EntityContractException } = require('../exceptions')
5
5
 
6
6
  class Entity {
7
+ deleted = false
7
8
  #schema
8
9
  #origin = null
9
10
  #state
@@ -61,6 +62,9 @@ class Entity {
61
62
  if (!('_created' in value))
62
63
  value._created = Date.now()
63
64
 
65
+ if (value._deleted !== null)
66
+ this.deleted = true
67
+
64
68
  if (this.#state !== undefined) {
65
69
  value._updated = Date.now()
66
70
  value._version++
@@ -4,7 +4,7 @@ const { Operation } = require('./operation')
4
4
 
5
5
  class Observation extends Operation {
6
6
  async run (store) {
7
- if (store.scope === null) store.reply = null
7
+ if (store.scope === null || store.scope?.deleted === true) store.reply = null
8
8
  else await super.run(store)
9
9
  }
10
10
  }
package/src/operation.js CHANGED
@@ -42,8 +42,6 @@ class Operation extends Connector {
42
42
 
43
43
  return await this.process(store)
44
44
  } catch (e) {
45
- console.error('Failed to execute operation', e)
46
-
47
45
  const exception = e instanceof Error ? new SystemException(e) : e
48
46
 
49
47
  return { exception }
package/src/receiver.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict'
2
2
 
3
+ const { console } = require('openspan')
3
4
  const { add } = require('@toa.io/generic')
4
5
  const { Connector } = require('./connector')
5
6
 
@@ -50,7 +51,13 @@ class Receiver extends Connector {
50
51
 
51
52
  add(request, extensions)
52
53
 
53
- await this.#local.invoke(this.#endpoint, request)
54
+ try {
55
+ await this.#local.invoke(this.#endpoint, request)
56
+ } catch (error) {
57
+ console.error('Receiver error', error)
58
+
59
+ throw error
60
+ }
54
61
  }
55
62
 
56
63
  async #request (payload) {
package/src/transition.js CHANGED
@@ -1,12 +1,8 @@
1
1
  'use strict'
2
2
 
3
3
  const { retry } = require('@toa.io/generic')
4
-
5
4
  const { Operation } = require('./operation')
6
- const {
7
- StateConcurrencyException,
8
- StateNotFoundException
9
- } = require('./exceptions')
5
+ const { StateConcurrencyException, StateNotFoundException } = require('./exceptions')
10
6
 
11
7
  class Transition extends Operation {
12
8
  #concurrency
@@ -26,9 +22,8 @@ class Transition extends Operation {
26
22
 
27
23
  store.scope = request.query ? await this.query(request.query) : this.scope.init()
28
24
 
29
- if (store.scope === null) {
25
+ if (store.scope === null || store.scope.deleted === true)
30
26
  throw new StateNotFoundException()
31
- }
32
27
 
33
28
  store.state = store.scope.get()
34
29
  }
@@ -61,7 +56,7 @@ const RETRY = {
61
56
  base: 10,
62
57
  max: 5000,
63
58
  dispersion: 1,
64
- retries: Infinity
59
+ retries: 32
65
60
  }
66
61
 
67
62
  exports.Transition = Transition