@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 +6 -5
- package/src/call.js +8 -3
- package/src/observation.js +5 -0
- package/src/state.js +2 -2
- package/src/transition.js +4 -1
- package/test/call.test.js +2 -2
- package/types/connector.d.ts +10 -16
- package/types/extensions.d.ts +8 -8
- package/types/index.d.ts +1 -0
- package/types/locator.d.ts +8 -12
- /package/types/{component.ts → component.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/core",
|
|
3
|
-
"version": "0.20.0-dev.
|
|
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.
|
|
24
|
-
"@toa.io/generic": "0.20.0-dev.
|
|
25
|
-
"@toa.io/yaml": "0.20.0-dev.
|
|
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": "
|
|
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
|
|
26
|
+
const reply = await this.#transmitter.request(request)
|
|
27
27
|
|
|
28
|
-
if (
|
|
28
|
+
if (reply === null) return null
|
|
29
|
+
else {
|
|
30
|
+
const { exception, ...rest } = reply
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
if (exception !== undefined) throw exception
|
|
33
|
+
|
|
34
|
+
return rest
|
|
35
|
+
}
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
|
package/src/observation.js
CHANGED
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
|
-
|
|
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
package/types/connector.d.ts
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
export class Connector {
|
|
2
|
+
public id: string
|
|
3
|
+
public connected: boolean
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
id: string
|
|
5
|
-
connected: boolean
|
|
5
|
+
public connect (): Promise<void>
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
public disconnect (interrupt?: boolean): Promise<void>
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
protected depends (connector: Connector | Connector[]): Connector
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
link (connector: Connector): void
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
protected open (): Promise<void>
|
|
14
14
|
|
|
15
|
-
|
|
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
|
package/types/extensions.d.ts
CHANGED
|
@@ -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'
|
package/types/locator.d.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
export class Locator {
|
|
2
|
+
public readonly name: string
|
|
3
|
+
public readonly namespace: string
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
public readonly id: string
|
|
6
|
+
public readonly label: string
|
|
7
|
+
public readonly uppercase: string
|
|
6
8
|
|
|
7
|
-
|
|
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
|