@toa.io/core 1.0.0-alpha.107 → 1.0.0-alpha.110

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.107",
3
+ "version": "1.0.0-alpha.110",
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.93"
28
28
  },
29
- "gitHead": "0c69afa09e2515ed76f88eaa9c9f5e5c97d8c5db"
29
+ "gitHead": "579e0243a9e783d9492c3616d6279f64862305c7"
30
30
  }
package/src/index.js CHANGED
@@ -20,6 +20,7 @@ const { Component } = require('./component')
20
20
  const { State } = require('./state')
21
21
  const { Transition } = require('./transition')
22
22
  const { Transmission } = require('./transmission')
23
+ const { Unmanaged } = require('./unmanaged')
23
24
 
24
25
  exports.entities = require('./entities')
25
26
  exports.exceptions = require('./exceptions')
@@ -47,3 +48,4 @@ exports.Remote = Remote
47
48
  exports.State = State
48
49
  exports.Transition = Transition
49
50
  exports.Transmission = Transmission
51
+ exports.Unmanaged = Unmanaged
package/src/operation.js CHANGED
@@ -1,6 +1,5 @@
1
1
  'use strict'
2
2
 
3
- const { console } = require('openspan')
4
3
  const { Connector } = require('./connector')
5
4
  const { SystemException, RequestContractException } = require('./exceptions')
6
5
  const { Readable } = require('node:stream')
package/src/state.js CHANGED
@@ -1,16 +1,17 @@
1
1
  'use strict'
2
2
 
3
- const { empty, newid } = require('@toa.io/generic')
3
+ const { empty } = require('@toa.io/generic')
4
4
  const { StatePreconditionException, StateNotFoundException } = require('./exceptions')
5
5
 
6
6
  class State {
7
+ storage
8
+
7
9
  #associated
8
- #storage
9
10
  #entities
10
11
  #emission
11
12
 
12
13
  constructor (storage, entity, emission, associated) {
13
- this.#storage = storage
14
+ this.storage = storage
14
15
  this.#entities = entity
15
16
  this.#emission = emission
16
17
  this.#associated = associated === true
@@ -25,7 +26,7 @@ class State {
25
26
  }
26
27
 
27
28
  async object (query) {
28
- const record = await this.#storage.get(query)
29
+ const record = await this.storage.get(query)
29
30
 
30
31
  if (record === null) {
31
32
  if (this.#associated && query.id !== undefined && query.criteria === undefined && query.version === undefined)
@@ -39,13 +40,13 @@ class State {
39
40
  }
40
41
 
41
42
  async objects (query) {
42
- const recordset = await this.#storage.find(query)
43
+ const recordset = await this.storage.find(query)
43
44
 
44
45
  return this.#entities.objects(recordset)
45
46
  }
46
47
 
47
48
  async stream (query) {
48
- return this.#storage.stream(query)
49
+ return this.storage.stream(query)
49
50
  }
50
51
 
51
52
  changeset (query) {
@@ -64,7 +65,7 @@ class State {
64
65
 
65
66
  object.set(blank)
66
67
 
67
- const record = await this.#storage.ensure(query, properties, object.get())
68
+ const record = await this.storage.ensure(query, properties, object.get())
68
69
 
69
70
  if (record.id !== blank.id) // exists
70
71
  return this.#entities.object(record)
@@ -84,7 +85,7 @@ class State {
84
85
  if (!empty(event.changeset)) {
85
86
  const object = state.get()
86
87
 
87
- ok = await this.#storage.store(object)
88
+ ok = await this.storage.store(object)
88
89
 
89
90
  // #20
90
91
  if (ok === true)
@@ -97,7 +98,7 @@ class State {
97
98
  async apply (state) {
98
99
  const changeset = state.export()
99
100
 
100
- const result = await this.#storage.upsert(state.query, changeset)
101
+ const result = await this.storage.upsert(state.query, changeset)
101
102
 
102
103
  if (result === null) {
103
104
  if (state.query.version !== undefined) {
@@ -0,0 +1,11 @@
1
+ 'use strict'
2
+
3
+ const { Operation } = require('./operation')
4
+
5
+ class Unmanaged extends Operation {
6
+ acquire (context) {
7
+ context.state = this.scope.storage.raw
8
+ }
9
+ }
10
+
11
+ exports.Unmanaged = Unmanaged