@toa.io/core 0.20.0-dev.17 → 0.20.0-dev.19

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": "0.20.0-dev.17",
3
+ "version": "0.20.0-dev.19",
4
4
  "description": "Toa Core",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -12,6 +12,7 @@
12
12
  "url": "https://github.com/toa-io/toa/issues"
13
13
  },
14
14
  "main": "src/index.js",
15
+ "types": "types/index.d.ts",
15
16
  "publishConfig": {
16
17
  "access": "public"
17
18
  },
@@ -20,10 +21,10 @@
20
21
  },
21
22
  "dependencies": {
22
23
  "@rsql/parser": "1.2.4",
23
- "@toa.io/console": "0.20.0-dev.17",
24
- "@toa.io/generic": "0.20.0-dev.17",
25
- "@toa.io/yaml": "0.20.0-dev.17",
24
+ "@toa.io/console": "0.20.0-dev.19",
25
+ "@toa.io/generic": "0.20.0-dev.19",
26
+ "@toa.io/yaml": "0.20.0-dev.19",
26
27
  "clone-deep": "4.0.1"
27
28
  },
28
- "gitHead": "cafb719d8e80d3e78a00904dc6ab6d6b0d5b568b"
29
+ "gitHead": "e10214f746cf4fc699af42dba90e099487177a43"
29
30
  }
package/src/call.js CHANGED
@@ -23,11 +23,16 @@ class Call extends Connector {
23
23
 
24
24
  request.authentic = true
25
25
 
26
- const { exception, ...reply } = await this.#transmitter.request(request)
26
+ const reply = await this.#transmitter.request(request)
27
27
 
28
- if (exception) throw exception
28
+ if (reply === null) return null
29
+ else {
30
+ const { exception, ...rest } = reply
29
31
 
30
- return reply
32
+ if (exception !== undefined) throw exception
33
+
34
+ return rest
35
+ }
31
36
  }
32
37
  }
33
38
 
@@ -14,6 +14,11 @@ class Observation extends Operation {
14
14
  store.scope = scope
15
15
  store.state = state
16
16
  }
17
+
18
+ async run (store) {
19
+ if (store.scope === null) store.reply = null
20
+ else await super.run(store)
21
+ }
17
22
  }
18
23
 
19
24
  exports.Observation = Observation
package/src/state.js CHANGED
@@ -41,10 +41,10 @@ class State {
41
41
  if (record === null) {
42
42
  if (this.#initialized && query.id !== undefined && query.version === undefined) return this.init(query.id)
43
43
  else if (query.version !== undefined) throw new StatePreconditionException()
44
- else throw new StateNotFoundException()
45
44
  }
46
45
 
47
- return this.#entity.object(record)
46
+ if (record === null) return null
47
+ else return this.#entity.object(record)
48
48
  }
49
49
 
50
50
  async objects (query) {
package/src/transition.js CHANGED
@@ -3,7 +3,7 @@
3
3
  const { retry } = require('@toa.io/generic')
4
4
 
5
5
  const { Operation } = require('./operation')
6
- const { StateConcurrencyException } = require('./exceptions')
6
+ const { StateConcurrencyException, StateNotFoundException } = require('./exceptions')
7
7
 
8
8
  class Transition extends Operation {
9
9
  #concurrency
@@ -22,6 +22,9 @@ class Transition extends Operation {
22
22
  const { request } = store
23
23
 
24
24
  store.scope = request.query ? await this.query(request.query) : this.scope.init()
25
+
26
+ if (store.scope === null) throw new StateNotFoundException()
27
+
25
28
  store.state = store.scope.get()
26
29
  }
27
30
 
package/test/call.test.js CHANGED
@@ -1,10 +1,10 @@
1
1
  'use strict'
2
2
 
3
+ jest.mock('../src/connector')
4
+
3
5
  const { Call } = require('../src/call')
4
6
  const fixtures = require('./call.fixtures')
5
7
 
6
- jest.mock('../src/connector')
7
-
8
8
  const { Connector } = require('../src/connector')
9
9
 
10
10
  let call
@@ -1,24 +1,18 @@
1
- declare namespace toa.core {
1
+ export class Connector {
2
+ public id: string
3
+ public connected: boolean
2
4
 
3
- interface Connector {
4
- id: string
5
- connected: boolean
5
+ public connect (): Promise<void>
6
6
 
7
- depends(connector: Connector): Connector
7
+ public disconnect (interrupt?: boolean): Promise<void>
8
8
 
9
- link(connector: Connector): void
9
+ protected depends (connector: Connector | Connector[]): Connector
10
10
 
11
- connect(): Promise<void>
11
+ link (connector: Connector): void
12
12
 
13
- disconnect(interrupt?: boolean): Promise<void>
13
+ protected open (): Promise<void>
14
14
 
15
- open(): Promise<void>
16
-
17
- close(): Promise<void>
18
-
19
- dispose(): Promise<void>
20
- }
15
+ protected close (): Promise<void>
21
16
 
17
+ protected dispose (): Promise<void>
22
18
  }
23
-
24
- export type Connector = toa.core.Connector
@@ -7,21 +7,21 @@ import * as _bindings from './bindings'
7
7
  declare namespace toa.core.extensions {
8
8
 
9
9
  interface Factory {
10
- tenant?(locator: _core.Locator, declaration: object): _core.Connector
10
+ tenant? (locator: _core.Locator, declaration: object): _core.Connector
11
11
 
12
- aspect?(locator: _core.Locator, declaration: object): Aspect | Aspect[]
12
+ aspect? (locator: _core.Locator, declaration: object): Aspect | Aspect[]
13
13
 
14
- service?(name?: string): _core.Connector
14
+ service? (name?: string): _core.Connector | null
15
15
 
16
- component?(component: _component.Component): _component.Component
16
+ component? (component: _component.Component): _component.Component
17
17
 
18
- context?(context: _context.Context): _context.Context
18
+ context? (context: _context.Context): _context.Context
19
19
 
20
- storage?(storage: _storages.Storage): _storages.Storage
20
+ storage? (storage: _storages.Storage): _storages.Storage
21
21
 
22
- emitter?(emitter: _bindings.Emitter, label: string): _bindings.Emitter
22
+ emitter? (emitter: _bindings.Emitter, label: string): _bindings.Emitter
23
23
 
24
- receiver?(receiver: _core.Receiver, locator: _core.Locator): _core.Receiver
24
+ receiver? (receiver: _core.Receiver, locator: _core.Locator): _core.Receiver
25
25
  }
26
26
 
27
27
  interface Aspect extends _core.Connector {
package/types/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * as bindings from './bindings'
2
2
  export * as extensions from './extensions'
3
3
  export * as storages from './storages'
4
4
  export * as bridges from './bridges'
5
+ export * as operations from './operations'
5
6
 
6
7
  export { Component } from './component'
7
8
  export { Connector } from './connector'
@@ -1,16 +1,12 @@
1
- declare namespace toa.core {
1
+ export class Locator {
2
+ public readonly name: string
3
+ public readonly namespace: string
2
4
 
3
- interface Locator {
4
- name: string
5
- namespace: string
5
+ public readonly id: string
6
+ public readonly label: string
7
+ public readonly uppercase: string
6
8
 
7
- id: string
8
- label: string
9
- uppercase: string
10
-
11
- hostname(type?: string): string
12
- }
9
+ constructor (name: string, namespace: string)
13
10
 
11
+ hostname (type?: string): string
14
12
  }
15
-
16
- export type Locator = toa.core.Locator
File without changes