@toa.io/core 0.20.0-dev.8 → 0.20.0
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 +9 -5
- package/src/call.js +14 -6
- package/src/cascade.js +15 -11
- package/src/context.js +1 -1
- package/src/contract/schemas/error.yaml +4 -3
- package/src/discovery.js +1 -1
- package/src/observation.js +5 -0
- package/src/operation.js +1 -5
- package/src/state.js +6 -6
- package/src/transition.js +4 -2
- package/test/call.fixtures.js +2 -1
- package/test/call.test.js +3 -9
- package/types/bindings.d.ts +11 -10
- package/types/component.d.ts +9 -0
- package/types/connector.d.ts +10 -16
- package/types/exception.d.ts +3 -9
- package/types/extensions.d.ts +8 -8
- package/types/index.d.ts +2 -2
- package/types/locator.d.ts +8 -12
- package/types/message.d.ts +2 -8
- package/types/operations.d.ts +2 -0
- package/types/request.d.ts +19 -22
- package/test/cascade.fixtures.js +0 -11
- package/test/cascade.test.js +0 -42
- package/types/component.ts +0 -16
- package/types/reply.d.ts +0 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/core",
|
|
3
|
-
"version": "0.20.0
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Toa Core",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -12,18 +12,22 @@
|
|
|
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
|
},
|
|
18
19
|
"scripts": {
|
|
19
20
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
20
21
|
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"nopeable": "*"
|
|
24
|
+
},
|
|
21
25
|
"dependencies": {
|
|
22
26
|
"@rsql/parser": "1.2.4",
|
|
23
|
-
"@toa.io/console": "0.20.0
|
|
24
|
-
"@toa.io/generic": "0.20.0
|
|
25
|
-
"@toa.io/yaml": "0.20.0
|
|
27
|
+
"@toa.io/console": "0.20.0",
|
|
28
|
+
"@toa.io/generic": "0.20.0",
|
|
29
|
+
"@toa.io/yaml": "0.20.0",
|
|
26
30
|
"clone-deep": "4.0.1"
|
|
27
31
|
},
|
|
28
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "28fc4b45c224c3683acaaf0e4abd1eb04e07b408"
|
|
29
33
|
}
|
package/src/call.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { Connector } = require('./connector')
|
|
4
|
+
const { Nope } = require('nopeable')
|
|
5
|
+
const { Readable } = require('stream')
|
|
4
6
|
|
|
5
7
|
class Call extends Connector {
|
|
6
8
|
#transmitter
|
|
@@ -15,19 +17,25 @@ class Call extends Connector {
|
|
|
15
17
|
this.depends(transmitter)
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
/**
|
|
19
|
-
* @param {toa.core.Request} request
|
|
20
|
-
*/
|
|
21
20
|
async invoke (request = {}) {
|
|
22
21
|
this.#contract.fit(request)
|
|
23
22
|
|
|
23
|
+
// avoid validation on the recipient's side
|
|
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 if (reply instanceof Readable) return reply
|
|
30
|
+
else {
|
|
31
|
+
if (reply.exception !== undefined)
|
|
32
|
+
throw reply.exception
|
|
29
33
|
|
|
30
|
-
|
|
34
|
+
if (reply.error !== undefined)
|
|
35
|
+
return new Nope(reply.error)
|
|
36
|
+
|
|
37
|
+
return reply.output
|
|
38
|
+
}
|
|
31
39
|
}
|
|
32
40
|
}
|
|
33
41
|
|
package/src/cascade.js
CHANGED
|
@@ -5,27 +5,31 @@ const { Connector } = require('./connector')
|
|
|
5
5
|
|
|
6
6
|
class Cascade extends Connector {
|
|
7
7
|
#bridges
|
|
8
|
+
#last
|
|
8
9
|
|
|
9
10
|
constructor (bridges) {
|
|
10
11
|
super()
|
|
11
12
|
|
|
12
13
|
this.#bridges = bridges
|
|
14
|
+
this.#last = bridges[bridges.length - 1]
|
|
13
15
|
|
|
14
16
|
this.depends(bridges)
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
async run (...args) {
|
|
18
|
-
const reply = {}
|
|
19
|
-
|
|
20
|
-
for (const bridge of this.#bridges) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return reply
|
|
20
|
+
// const reply = {}
|
|
21
|
+
//
|
|
22
|
+
// for (const bridge of this.#bridges) {
|
|
23
|
+
// const partial = await bridge.execute(...args)
|
|
24
|
+
//
|
|
25
|
+
// if (partial.error) return { error: partial.error }
|
|
26
|
+
//
|
|
27
|
+
// merge(reply, partial)
|
|
28
|
+
// }
|
|
29
|
+
//
|
|
30
|
+
// return reply
|
|
31
|
+
|
|
32
|
+
return this.#last.execute(...args)
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
35
|
|
package/src/context.js
CHANGED
|
@@ -38,7 +38,7 @@ class Context extends Connector {
|
|
|
38
38
|
async #remote (namespace, name) {
|
|
39
39
|
const key = namespace + '.' + name
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
this.#remotes[key] ??= this.#connect(namespace, name)
|
|
42
42
|
|
|
43
43
|
return this.#remotes[key]
|
|
44
44
|
}
|
package/src/discovery.js
CHANGED
|
@@ -30,7 +30,7 @@ class Discovery extends Connector {
|
|
|
30
30
|
const warning = () => console.warn(`Waiting for lookup response from '${id}'...`)
|
|
31
31
|
const timeout = setTimeout(warning, TIMEOUT)
|
|
32
32
|
|
|
33
|
-
const
|
|
33
|
+
const output = await this.#lookups[id].invoke()
|
|
34
34
|
|
|
35
35
|
console.debug(`Lookup response from '${id}' received`)
|
|
36
36
|
clearTimeout(timeout)
|
package/src/observation.js
CHANGED
package/src/operation.js
CHANGED
|
@@ -24,10 +24,6 @@ class Operation extends Connector {
|
|
|
24
24
|
this.depends(cascade)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
/**
|
|
28
|
-
* @param {toa.core.Request} request
|
|
29
|
-
* @return {Promise<toa.core.Reply>}
|
|
30
|
-
*/
|
|
31
27
|
async invoke (request) {
|
|
32
28
|
try {
|
|
33
29
|
if (request.authentic !== true) this.#contracts.request.fit(request)
|
|
@@ -57,7 +53,7 @@ class Operation extends Connector {
|
|
|
57
53
|
const { request, state } = store
|
|
58
54
|
const reply = await this.#cascade.run(request.input, state) || {}
|
|
59
55
|
|
|
60
|
-
this.#contracts.reply.fit(reply)
|
|
56
|
+
// this.#contracts.reply.fit(reply)
|
|
61
57
|
|
|
62
58
|
store.reply = reply
|
|
63
59
|
}
|
package/src/state.js
CHANGED
|
@@ -28,9 +28,9 @@ class State {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
init (id) {
|
|
31
|
-
if (this.#initialized === true && id === undefined) {
|
|
32
|
-
|
|
33
|
-
}
|
|
31
|
+
// if (this.#initialized === true && id === undefined) {
|
|
32
|
+
// throw new StateInitializationException('Cannot initialize entity which is initialized. Use request.query.id to access.')
|
|
33
|
+
// }
|
|
34
34
|
|
|
35
35
|
return this.#entity.init(id)
|
|
36
36
|
}
|
|
@@ -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) {
|
|
@@ -94,7 +94,7 @@ class State {
|
|
|
94
94
|
else throw new StateNotFoundException()
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
//
|
|
97
|
+
// same as above
|
|
98
98
|
await this.#emission.emit({ changeset, state: result })
|
|
99
99
|
}
|
|
100
100
|
}
|
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
|
|
|
@@ -47,7 +50,6 @@ class Transition extends Operation {
|
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
52
|
|
|
50
|
-
/** @type {toa.generic.retry.Options} */
|
|
51
53
|
const RETRY = {
|
|
52
54
|
base: 10,
|
|
53
55
|
max: 5000,
|
package/test/call.fixtures.js
CHANGED
|
@@ -4,7 +4,8 @@ const { generate } = require('randomstring')
|
|
|
4
4
|
|
|
5
5
|
// noinspection JSCheckFunctionSignatures
|
|
6
6
|
const transmission = {
|
|
7
|
-
request: jest.fn((request) => ({ [request.invalid ? 'exception' :
|
|
7
|
+
request: jest.fn((request) => ({ [request.invalid ? 'exception' : 'output']: generate() })),
|
|
8
|
+
link: jest.fn()
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
const contract = {
|
package/test/call.test.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { Call } = require('../src/call')
|
|
4
3
|
const fixtures = require('./call.fixtures')
|
|
5
|
-
|
|
6
|
-
jest.mock('../src/connector')
|
|
7
|
-
|
|
8
|
-
const { Connector } = require('../src/connector')
|
|
4
|
+
const { Call } = require('../src/call')
|
|
9
5
|
|
|
10
6
|
let call
|
|
11
7
|
|
|
@@ -16,9 +12,7 @@ beforeEach(() => {
|
|
|
16
12
|
})
|
|
17
13
|
|
|
18
14
|
it('should depend on transmission', () => {
|
|
19
|
-
expect(
|
|
20
|
-
expect(call).toBe(Connector.mock.instances[0])
|
|
21
|
-
expect(Connector.mock.instances[0].depends).toHaveBeenCalledWith(fixtures.transmission)
|
|
15
|
+
expect(fixtures.transmission.link).toHaveBeenLastCalledWith(call)
|
|
22
16
|
})
|
|
23
17
|
|
|
24
18
|
it('should call transmission', async () => {
|
|
@@ -42,7 +36,7 @@ it('should return reply', async () => {
|
|
|
42
36
|
|
|
43
37
|
const reply = await call.invoke(request)
|
|
44
38
|
|
|
45
|
-
expect(reply).toStrictEqual(fixtures.transmission.request.mock.results[0].value)
|
|
39
|
+
expect(reply).toStrictEqual(fixtures.transmission.request.mock.results[0].value.output)
|
|
46
40
|
})
|
|
47
41
|
|
|
48
42
|
it('should throw received exceptions', async () => {
|
package/types/bindings.d.ts
CHANGED
|
@@ -7,29 +7,29 @@ declare namespace toa.core.bindings {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
interface Consumer extends _core.Connector {
|
|
10
|
-
request(request: Request): Promise<_core.Reply>
|
|
10
|
+
request (request: Request): Promise<_core.Reply>
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
interface Emitter extends _core.Connector {
|
|
14
|
-
emit(message: _core.Message): Promise<void>
|
|
14
|
+
emit (message: _core.Message): Promise<void>
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
interface Broadcast extends _core.Connector {
|
|
18
|
-
transmit(label:
|
|
17
|
+
interface Broadcast<L> extends _core.Connector {
|
|
18
|
+
transmit<T> (label: L, payload: T): Promise<void>
|
|
19
19
|
|
|
20
|
-
receive(label:
|
|
20
|
+
receive<T> (label: L, callback: (payload: T) => void | Promise<void>): Promise<void>
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
interface Factory {
|
|
24
|
-
producer?(locator: _core.Locator, endpoints: Array<string>, producer: _core.Component): _core.Connector
|
|
24
|
+
producer? (locator: _core.Locator, endpoints: Array<string>, producer: _core.Component): _core.Connector
|
|
25
25
|
|
|
26
|
-
consumer?(locator: _core.Locator, endpoint: string): Consumer
|
|
26
|
+
consumer? (locator: _core.Locator, endpoint: string): Consumer
|
|
27
27
|
|
|
28
|
-
emitter?(locator: _core.Locator, label: string): Emitter
|
|
28
|
+
emitter? (locator: _core.Locator, label: string): Emitter
|
|
29
29
|
|
|
30
|
-
receiver?(locator: _core.Locator, label: string, group: string, receiver: _core.Receiver): _core.Connector
|
|
30
|
+
receiver? (locator: _core.Locator, label: string, group: string, receiver: _core.Receiver): _core.Connector
|
|
31
31
|
|
|
32
|
-
broadcast?(name: string, group?: string): Broadcast
|
|
32
|
+
broadcast? (name: string, group?: string): Broadcast
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
}
|
|
@@ -37,3 +37,4 @@ declare namespace toa.core.bindings {
|
|
|
37
37
|
export type Emitter = toa.core.bindings.Emitter
|
|
38
38
|
export type Factory = toa.core.bindings.Factory
|
|
39
39
|
export type Properties = toa.core.bindings.Properties
|
|
40
|
+
export type Broadcast<L> = toa.core.bindings.Broadcast<L>
|
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
|
+
public depends (connector: Connector | Connector[]): Connector
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
link (connector: Connector): void
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
protected open (): Promise<void> | void
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
close(): Promise<void>
|
|
18
|
-
|
|
19
|
-
dispose(): Promise<void>
|
|
20
|
-
}
|
|
15
|
+
protected close (): Promise<void> | void
|
|
21
16
|
|
|
17
|
+
protected dispose (): Promise<void> | void
|
|
22
18
|
}
|
|
23
|
-
|
|
24
|
-
export type Connector = toa.core.Connector
|
package/types/exception.d.ts
CHANGED
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,
|
|
10
|
+
tenant? (locator: _core.Locator, manifest: object): _core.Connector
|
|
11
11
|
|
|
12
|
-
aspect?(locator: _core.Locator,
|
|
12
|
+
aspect? (locator: _core.Locator, manifest: object | null): 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'
|
|
@@ -10,5 +11,4 @@ export { Exception } from './exception'
|
|
|
10
11
|
export { Locator } from './locator'
|
|
11
12
|
export { Receiver } from './receiver'
|
|
12
13
|
export { Message } from './message'
|
|
13
|
-
export { Reply } from './
|
|
14
|
-
export { Request, Query } from './request'
|
|
14
|
+
export { Request, Query, Reply } from './request'
|
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
|
package/types/message.d.ts
CHANGED
package/types/request.d.ts
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import { Exception } from './exception'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
version?: number
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type Request = {
|
|
18
|
-
input?: any
|
|
19
|
-
query?: request.Query
|
|
20
|
-
authentic?: boolean
|
|
21
|
-
}
|
|
3
|
+
export interface Query {
|
|
4
|
+
id?: string
|
|
5
|
+
criteria?: string
|
|
6
|
+
omit?: number
|
|
7
|
+
limit?: number
|
|
8
|
+
sort?: Array<string>
|
|
9
|
+
projection?: Array<string>
|
|
10
|
+
version?: number
|
|
11
|
+
}
|
|
22
12
|
|
|
13
|
+
export interface Request {
|
|
14
|
+
input?: any
|
|
15
|
+
query?: Query
|
|
16
|
+
authentic?: boolean
|
|
23
17
|
}
|
|
24
18
|
|
|
25
|
-
export
|
|
26
|
-
|
|
19
|
+
export interface Reply {
|
|
20
|
+
output?: any
|
|
21
|
+
error?: object
|
|
22
|
+
exception?: Exception
|
|
23
|
+
}
|
package/test/cascade.fixtures.js
DELETED
package/test/cascade.test.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
jest.mock('../src/connector')
|
|
4
|
-
|
|
5
|
-
const clone = require('clone-deep')
|
|
6
|
-
|
|
7
|
-
const { Connector } = require('../src/connector')
|
|
8
|
-
const { Cascade } = require('../src/cascade')
|
|
9
|
-
const fixtures = require('./cascade.fixtures')
|
|
10
|
-
|
|
11
|
-
let cascade
|
|
12
|
-
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
jest.clearAllMocks()
|
|
15
|
-
|
|
16
|
-
cascade = new Cascade(clone(fixtures.bridges))
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('should depend on bridges', () => {
|
|
20
|
-
expect(cascade).toBeInstanceOf(Connector)
|
|
21
|
-
expect(Connector.mock.instances[0].depends).toHaveBeenCalledWith(fixtures.bridges)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it('should call bridges.execute', async () => {
|
|
25
|
-
const args = [1, 2]
|
|
26
|
-
await cascade.run(...args)
|
|
27
|
-
|
|
28
|
-
for (const bridge of fixtures.bridges) expect(bridge.execute).toHaveBeenCalledWith(...args)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it('should merge output', async () => {
|
|
32
|
-
const reply = await cascade.run()
|
|
33
|
-
|
|
34
|
-
expect(reply).toStrictEqual({ output: { a: true, b: true, c: true } })
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('should interrupt on error', async () => {
|
|
38
|
-
const reply = await cascade.run({ error: 'b' })
|
|
39
|
-
|
|
40
|
-
expect(reply).toStrictEqual({ error: 'b' })
|
|
41
|
-
expect(fixtures.bridges[2].execute).not.toHaveBeenCalled()
|
|
42
|
-
})
|
package/types/component.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as _connector from './connector'
|
|
2
|
-
import * as _locator from './locator'
|
|
3
|
-
import * as _request from './request'
|
|
4
|
-
import * as _reply from './reply'
|
|
5
|
-
|
|
6
|
-
declare namespace toa.core {
|
|
7
|
-
|
|
8
|
-
interface Component extends _connector.Connector {
|
|
9
|
-
locator: _locator.Locator
|
|
10
|
-
|
|
11
|
-
invoke(endpoint: string, request: _request.Request): Promise<_reply.Reply>
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type Component = toa.core.Component
|
package/types/reply.d.ts
DELETED