@toa.io/core 1.0.0-alpha.43 → 1.0.0-alpha.44
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 +5 -5
- package/src/contract/request.js +1 -1
- package/src/transmission.js +12 -3
- package/test/contract/request.test.js +1 -1
- package/types/bindings.d.ts +7 -5
- package/types/request.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/core",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.44",
|
|
4
4
|
"description": "Toa Core",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@rsql/parser": "1.2.4",
|
|
24
|
-
"@toa.io/console": "1.0.0-alpha.
|
|
25
|
-
"@toa.io/generic": "1.0.0-alpha.
|
|
26
|
-
"@toa.io/yaml": "1.0.0-alpha.
|
|
24
|
+
"@toa.io/console": "1.0.0-alpha.44",
|
|
25
|
+
"@toa.io/generic": "1.0.0-alpha.44",
|
|
26
|
+
"@toa.io/yaml": "1.0.0-alpha.44",
|
|
27
27
|
"error-value": "0.3.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"clone-deep": "4.0.1"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "9a0401a82a7e63102a1dc5be8686ecc232fdabee"
|
|
33
33
|
}
|
package/src/contract/request.js
CHANGED
|
@@ -24,7 +24,7 @@ class Request extends Contract {
|
|
|
24
24
|
static schema (definition, entity) {
|
|
25
25
|
const schema = {
|
|
26
26
|
type: 'object',
|
|
27
|
-
properties: { authentic: { type: 'boolean' } },
|
|
27
|
+
properties: { authentic: { type: 'boolean' }, task: { type: 'boolean' } },
|
|
28
28
|
additionalProperties: true
|
|
29
29
|
}
|
|
30
30
|
|
package/src/transmission.js
CHANGED
|
@@ -18,13 +18,22 @@ class Transmission extends Connector {
|
|
|
18
18
|
let i = 0
|
|
19
19
|
|
|
20
20
|
while (reply === false && i < this.#bindings.length) {
|
|
21
|
-
|
|
21
|
+
const binding = this.#bindings[i]
|
|
22
|
+
|
|
22
23
|
i++
|
|
24
|
+
|
|
25
|
+
if (request?.task === true) {
|
|
26
|
+
if (binding.task === undefined)
|
|
27
|
+
continue
|
|
28
|
+
|
|
29
|
+
await binding.task(request)
|
|
30
|
+
reply = null
|
|
31
|
+
} else
|
|
32
|
+
reply = await binding.request(request)
|
|
23
33
|
}
|
|
24
34
|
|
|
25
|
-
if (reply === false)
|
|
35
|
+
if (reply === false)
|
|
26
36
|
throw new TransmissionException(`All (${this.#bindings.length}) bindings rejected.`)
|
|
27
|
-
}
|
|
28
37
|
|
|
29
38
|
return reply
|
|
30
39
|
}
|
|
@@ -59,7 +59,7 @@ describe('schema', () => {
|
|
|
59
59
|
|
|
60
60
|
it('should not contain query if declaration.query is false', () => {
|
|
61
61
|
schema.properties.query = { type: 'null' }
|
|
62
|
-
expect(Request.schema({ query: false }, dummy)).
|
|
62
|
+
expect(Request.schema({ query: false }, dummy)).toMatchObject(schema)
|
|
63
63
|
})
|
|
64
64
|
|
|
65
65
|
it('should require query if declaration.query is true', () => {
|
package/types/bindings.d.ts
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import * as _core from './index'
|
|
2
2
|
|
|
3
|
-
declare namespace toa.core.bindings{
|
|
3
|
+
declare namespace toa.core.bindings {
|
|
4
4
|
|
|
5
5
|
type Properties = {
|
|
6
6
|
async?: boolean
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
interface Consumer extends _core.Connector{
|
|
9
|
+
interface Consumer extends _core.Connector {
|
|
10
10
|
request (request: Request): Promise<_core.Reply>
|
|
11
|
+
|
|
12
|
+
task (request: Request): Promise<void>
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
interface Emitter extends _core.Connector{
|
|
15
|
+
interface Emitter extends _core.Connector {
|
|
14
16
|
emit (message: _core.Message): Promise<void>
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
interface Broadcast<L> extends _core.Connector{
|
|
19
|
+
interface Broadcast<L> extends _core.Connector {
|
|
18
20
|
transmit<T> (label: L, payload: T): Promise<void>
|
|
19
21
|
|
|
20
22
|
receive<T> (label: L, callback: (payload: T) => void | Promise<void>): Promise<void>
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
interface Factory{
|
|
25
|
+
interface Factory {
|
|
24
26
|
producer? (locator: _core.Locator, endpoints: Array<string>, producer: _core.Component): _core.Connector
|
|
25
27
|
|
|
26
28
|
consumer? (locator: _core.Locator, endpoint: string): Consumer
|