@toa.io/bindings.loop 1.0.0-alpha.283 → 1.0.0-alpha.286
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 +4 -4
- package/src/consumer.js +2 -2
- package/src/factory.js +2 -2
- package/src/producer.js +6 -5
- package/test/loop.test.js +11 -4
- package/CHANGELOG.md +0 -62
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/bindings.loop",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.286",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Toa Loop Binding",
|
|
6
6
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@toa.io/core": "1.0.0-alpha.
|
|
24
|
-
"@toa.io/generic": "1.0.0-alpha.
|
|
23
|
+
"@toa.io/core": "1.0.0-alpha.286",
|
|
24
|
+
"@toa.io/generic": "1.0.0-alpha.286"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "81f3d0688f17668b902be336d1749cc715edcdb6"
|
|
27
27
|
}
|
package/src/consumer.js
CHANGED
|
@@ -5,7 +5,7 @@ export class Consumer extends Connector {
|
|
|
5
5
|
#locator
|
|
6
6
|
#endpoint
|
|
7
7
|
|
|
8
|
-
constructor
|
|
8
|
+
constructor(bindings, locator, endpoint) {
|
|
9
9
|
super()
|
|
10
10
|
|
|
11
11
|
this.#bindings = bindings
|
|
@@ -13,7 +13,7 @@ export class Consumer extends Connector {
|
|
|
13
13
|
this.#endpoint = endpoint
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
async request
|
|
16
|
+
async request(request) {
|
|
17
17
|
const invoke = this.#bindings[this.#locator.id]?.[this.#endpoint]
|
|
18
18
|
|
|
19
19
|
if (invoke === undefined) return false
|
package/src/factory.js
CHANGED
|
@@ -4,11 +4,11 @@ import { Consumer } from './consumer.js'
|
|
|
4
4
|
export class Factory {
|
|
5
5
|
#bindings = {}
|
|
6
6
|
|
|
7
|
-
producer
|
|
7
|
+
producer(locator, endpoints, producer) {
|
|
8
8
|
return new Producer(this.#bindings, locator, endpoints, producer)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
consumer
|
|
11
|
+
consumer(locator, endpoint) {
|
|
12
12
|
return new Consumer(this.#bindings, locator, endpoint)
|
|
13
13
|
}
|
|
14
14
|
}
|
package/src/producer.js
CHANGED
|
@@ -5,7 +5,7 @@ export class Producer extends Connector {
|
|
|
5
5
|
#endpoints
|
|
6
6
|
#producer
|
|
7
7
|
|
|
8
|
-
constructor
|
|
8
|
+
constructor(bindings, locator, endpoints, producer) {
|
|
9
9
|
super()
|
|
10
10
|
|
|
11
11
|
if (bindings[locator.id] === undefined) bindings[locator.id] = {}
|
|
@@ -17,16 +17,17 @@ export class Producer extends Connector {
|
|
|
17
17
|
this.depends(producer)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
async open
|
|
20
|
+
async open() {
|
|
21
21
|
this.#endpoints.forEach((endpoint) => this.#operation(endpoint))
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
async close
|
|
24
|
+
async close() {
|
|
25
25
|
this.#endpoints.forEach((endpoint) => delete this.#binding[endpoint])
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
#operation
|
|
29
|
-
if (this.#binding[endpoint] !== undefined)
|
|
28
|
+
#operation(endpoint) {
|
|
29
|
+
if (this.#binding[endpoint] !== undefined)
|
|
30
|
+
throw new Error(`Loop binding endpoint '${endpoint}' already exists`)
|
|
30
31
|
|
|
31
32
|
this.#binding[endpoint] = async (request) => this.#producer.invoke(endpoint, request)
|
|
32
33
|
}
|
package/test/loop.test.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { it, before, after, beforeEach, afterEach
|
|
1
|
+
import { it, before, after, beforeEach, afterEach } from 'node:test'
|
|
2
2
|
import assert from 'node:assert/strict'
|
|
3
3
|
|
|
4
4
|
import clone from 'clone-deep'
|
|
@@ -8,7 +8,11 @@ import { Factory } from '../src/factory.js'
|
|
|
8
8
|
import * as fixtures from './fixtures.js'
|
|
9
9
|
|
|
10
10
|
const factory = new Factory()
|
|
11
|
-
const producer = factory.producer(
|
|
11
|
+
const producer = factory.producer(
|
|
12
|
+
fixtures.component.locator,
|
|
13
|
+
fixtures.endpoints,
|
|
14
|
+
fixtures.component
|
|
15
|
+
)
|
|
12
16
|
|
|
13
17
|
let consumer, endpoint
|
|
14
18
|
|
|
@@ -67,10 +71,13 @@ it('should not depend on initialization order', async () => {
|
|
|
67
71
|
const producer = factory.producer(component.locator, fixtures.endpoints, component)
|
|
68
72
|
await producer.connect()
|
|
69
73
|
|
|
70
|
-
assert.strictEqual(
|
|
74
|
+
assert.strictEqual(
|
|
75
|
+
await consumer.request(),
|
|
76
|
+
await component.invoke.mock.calls[0].result
|
|
77
|
+
)
|
|
71
78
|
})
|
|
72
79
|
|
|
73
|
-
function resetCalls
|
|
80
|
+
function resetCalls(target = [fixtures], seen = new Set()) {
|
|
74
81
|
if (target === null || typeof target !== 'object' || seen.has(target)) return
|
|
75
82
|
|
|
76
83
|
seen.add(target)
|
package/CHANGELOG.md
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
# [1.0.0-alpha.283](https://github.com/toa-io/toa/compare/v1.0.0-alpha.282...v1.0.0-alpha.283) (2026-09-04)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @toa.io/bindings.loop
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# [1.0.0-alpha.282](https://github.com/toa-io/toa/compare/v1.0.0-alpha.281...v1.0.0-alpha.282) (2026-09-03)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package @toa.io/bindings.loop
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# [1.0.0-alpha.278](https://github.com/toa-io/toa/compare/v1.0.0-alpha.277...v1.0.0-alpha.278) (2026-09-03)
|
|
23
|
-
|
|
24
|
-
**Note:** Version bump only for package @toa.io/bindings.loop
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# [1.0.0-alpha.277](https://github.com/toa-io/toa/compare/v1.0.0-alpha.276...v1.0.0-alpha.277) (2026-09-03)
|
|
31
|
-
|
|
32
|
-
**Note:** Version bump only for package @toa.io/bindings.loop
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
# [1.0.0-alpha.273](https://github.com/toa-io/toa/compare/v1.0.0-alpha.272...v1.0.0-alpha.273) (2026-09-02)
|
|
39
|
-
|
|
40
|
-
**Note:** Version bump only for package @toa.io/bindings.loop
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
# [1.0.0-alpha.272](https://github.com/toa-io/toa/compare/v1.0.0-alpha.271...v1.0.0-alpha.272) (2026-09-01)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
### Bug Fixes
|
|
50
|
-
|
|
51
|
-
* **connectors:** declare the packages they require ([a940808](https://github.com/toa-io/toa/commit/a940808744aa5e793205a0ea35eccb43b7534afa))
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
# [1.0.0-alpha.259](https://github.com/toa-io/toa/compare/v1.0.0-alpha.258...v1.0.0-alpha.259) (2026-08-24)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
### Features
|
|
61
|
-
|
|
62
|
-
* **runtime:** split component RC into preflight and settle ([0d648b3](https://github.com/toa-io/toa/commit/0d648b314e4aac226c254bf01a86affa04b59b34))
|