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

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.79",
3
+ "version": "1.0.0-alpha.81",
4
4
  "description": "Toa Core",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -26,5 +26,5 @@
26
26
  "error-value": "0.3.0",
27
27
  "openspan": "1.0.0-alpha.79"
28
28
  },
29
- "gitHead": "69f3f10212861886d4123786b695de1d456d9a3c"
29
+ "gitHead": "99c366c07ee6a34206ecb15d46c0f53e46eb9b06"
30
30
  }
package/src/effect.js CHANGED
@@ -5,12 +5,12 @@ const { Observation } = require('./observation')
5
5
  class Effect extends Observation {
6
6
 
7
7
  async acquire (store) {
8
- const { query, entity } = store.request
8
+ const { query, entity, input } = store.request
9
9
 
10
10
  if (entity === undefined)
11
11
  return super.acquire(store)
12
12
 
13
- store.scope = await this.scope.ensure(query, entity)
13
+ store.scope = await this.scope.ensure(query, entity, input)
14
14
  store.state = store.scope.get()
15
15
  }
16
16
 
@@ -35,12 +35,13 @@ class Entity {
35
35
  this.#set(value)
36
36
  }
37
37
 
38
- event () {
38
+ event (input = undefined) {
39
39
  return {
40
40
  origin: this.#origin,
41
41
  state: this.#state,
42
42
  changeset: this.#origin === null ? this.#state : difference(this.#origin, this.#state),
43
- trailers: this.#state._trailers
43
+ trailers: this.#state._trailers,
44
+ input
44
45
  }
45
46
  }
46
47
 
package/src/state.js CHANGED
@@ -56,7 +56,7 @@ class State {
56
56
  return null
57
57
  }
58
58
 
59
- async ensure (query, properties) {
59
+ async ensure (query, properties, input) {
60
60
  const object = this.#entities.init()
61
61
  const blank = object.get()
62
62
 
@@ -69,13 +69,15 @@ class State {
69
69
  if (record.id !== blank.id) // exists
70
70
  return this.#entities.object(record)
71
71
 
72
- await this.#emission.emit(object.event())
72
+ const event = object.event(input)
73
+
74
+ await this.#emission.emit(event)
73
75
 
74
76
  return object
75
77
  }
76
78
 
77
- async commit (state) {
78
- const event = state.event()
79
+ async commit (state, input) {
80
+ const event = state.event(input)
79
81
 
80
82
  let ok = true
81
83
 
@@ -85,9 +87,8 @@ class State {
85
87
  ok = await this.#storage.store(object)
86
88
 
87
89
  // #20
88
- if (ok === true) {
90
+ if (ok === true)
89
91
  await this.#emission.emit(event)
90
- }
91
92
  }
92
93
 
93
94
  return ok
package/src/transition.js CHANGED
@@ -35,7 +35,7 @@ class Transition extends Operation {
35
35
 
36
36
  scope.set(state)
37
37
 
38
- const result = await this.scope.commit(scope)
38
+ const result = await this.scope.commit(scope, store.request.input)
39
39
 
40
40
  if (result === false) {
41
41
  if (this.#concurrency === 'retry')