@toa.io/core 1.0.0-alpha.75 → 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.75",
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": "5050fff4a676bbcd7b6f89c1788411701b7ecba6"
29
+ "gitHead": "69f3f10212861886d4123786b695de1d456d9a3c"
30
30
  }
@@ -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/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