@toa.io/core 1.0.0-alpha.284 → 1.0.0-alpha.287

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.
Files changed (290) hide show
  1. package/CHANGELOG.md +1 -185
  2. package/package.json +19 -7
  3. package/source/assignment.ts +27 -0
  4. package/{src/call.js → source/call.ts} +16 -21
  5. package/{src/cascade.js → source/cascade.ts} +6 -8
  6. package/{src/component.js → source/component.ts} +27 -25
  7. package/{src/composition.js → source/composition.ts} +9 -3
  8. package/{src/connector.js → source/connector.ts} +36 -55
  9. package/source/context.ts +67 -0
  10. package/source/contract/contract.ts +23 -0
  11. package/{src/contract/reply.js → source/contract/reply.ts} +26 -19
  12. package/source/contract/request.ts +85 -0
  13. package/source/contract/schemas.ts +39 -0
  14. package/{src/discovery.js → source/discovery.ts} +15 -8
  15. package/source/effect.ts +14 -0
  16. package/{src/emission.js → source/emission.ts} +5 -3
  17. package/source/entities/changeset.ts +37 -0
  18. package/source/entities/entity.ts +137 -0
  19. package/source/entities/factory.ts +52 -0
  20. package/source/entities/index.ts +4 -0
  21. package/{src/entities/newid.js → source/entities/newid.ts} +1 -1
  22. package/{src/entities/set.js → source/entities/set.ts} +8 -5
  23. package/source/event.ts +57 -0
  24. package/{src/exceptions.js → source/exceptions.ts} +52 -33
  25. package/source/exposition.ts +33 -0
  26. package/source/guard.ts +16 -0
  27. package/{src/index.js → source/index.ts} +8 -0
  28. package/{src/locator.js → source/locator.ts} +17 -30
  29. package/source/observation.ts +16 -0
  30. package/source/operation.ts +138 -0
  31. package/{src/outbox/outbox.js → source/outbox/outbox.ts} +87 -53
  32. package/source/query/criteria.ts +90 -0
  33. package/source/query/options.ts +35 -0
  34. package/{src/query.js → source/query.ts} +14 -17
  35. package/source/receiver.ts +120 -0
  36. package/source/reflection.ts +20 -0
  37. package/source/remote.ts +20 -0
  38. package/source/state.ts +179 -0
  39. package/source/transition.ts +79 -0
  40. package/{src/transmission.js → source/transmission.ts} +8 -8
  41. package/source/types/atomicity.ts +63 -0
  42. package/source/types/bindings.ts +59 -0
  43. package/source/types/bridges.ts +54 -0
  44. package/source/types/extensions.ts +89 -0
  45. package/{types → source/types}/index.ts +9 -16
  46. package/{types/message.d.ts → source/types/message.ts} +2 -1
  47. package/source/types/operations.ts +31 -0
  48. package/source/types/outbox.ts +35 -0
  49. package/source/types/receiver.ts +10 -0
  50. package/{types/request.d.ts → source/types/request.ts} +8 -9
  51. package/source/types/state.ts +9 -0
  52. package/source/types/storages.ts +129 -0
  53. package/source/unmanaged.ts +8 -0
  54. package/test/call.fixtures.js +3 -1
  55. package/test/call.test.js +28 -7
  56. package/test/component.test.js +10 -5
  57. package/test/connector.fixtures.js +7 -7
  58. package/test/connector.test.js +15 -2
  59. package/test/context.fixtures.js +1 -1
  60. package/test/context.test.js +4 -4
  61. package/test/contract/conditions.test.js +6 -2
  62. package/test/contract/contract.fixtures.js +3 -4
  63. package/test/contract/request.test.js +68 -34
  64. package/test/discovery.test.js +10 -3
  65. package/test/emission.test.js +16 -8
  66. package/test/entities/entity.fixtures.js +5 -6
  67. package/test/entities/entity.test.js +54 -20
  68. package/test/entities/factory.fixtures.js +11 -10
  69. package/test/entities/factory.test.js +47 -10
  70. package/test/entities/set.test.js +1 -1
  71. package/test/event.test.js +29 -11
  72. package/test/locator.test.js +10 -4
  73. package/test/outbox.test.js +49 -15
  74. package/test/query.test.js +69 -7
  75. package/test/receiver.fixtures.js +2 -2
  76. package/test/receiver.test.js +53 -27
  77. package/test/reflection.test.js +3 -3
  78. package/test/state.fixtures.js +10 -3
  79. package/test/state.test.js +77 -14
  80. package/test/transmission.test.js +25 -12
  81. package/transpiled/assignment.d.ts +6 -0
  82. package/transpiled/assignment.js +20 -0
  83. package/transpiled/assignment.js.map +1 -0
  84. package/transpiled/call.d.ts +10 -0
  85. package/transpiled/call.js +52 -0
  86. package/transpiled/call.js.map +1 -0
  87. package/transpiled/cascade.d.ts +7 -0
  88. package/transpiled/cascade.js +28 -0
  89. package/transpiled/cascade.js.map +1 -0
  90. package/transpiled/component.d.ts +15 -0
  91. package/transpiled/component.js +61 -0
  92. package/transpiled/component.js.map +1 -0
  93. package/transpiled/composition.d.ts +6 -0
  94. package/transpiled/composition.js +23 -0
  95. package/transpiled/composition.js.map +1 -0
  96. package/transpiled/connector.d.ts +47 -0
  97. package/transpiled/connector.js +143 -0
  98. package/transpiled/connector.js.map +1 -0
  99. package/transpiled/context.d.ts +18 -0
  100. package/transpiled/context.js +41 -0
  101. package/transpiled/context.js.map +1 -0
  102. package/transpiled/contract/contract.d.ts +10 -0
  103. package/transpiled/contract/contract.js +14 -0
  104. package/transpiled/contract/contract.js.map +1 -0
  105. package/transpiled/contract/index.d.ts +2 -0
  106. package/transpiled/contract/index.js +3 -0
  107. package/transpiled/contract/index.js.map +1 -0
  108. package/transpiled/contract/reply.d.ts +7 -0
  109. package/transpiled/contract/reply.js +48 -0
  110. package/transpiled/contract/reply.js.map +1 -0
  111. package/transpiled/contract/request.d.ts +24 -0
  112. package/transpiled/contract/request.js +59 -0
  113. package/transpiled/contract/request.js.map +1 -0
  114. package/transpiled/contract/schemas.d.ts +4 -0
  115. package/transpiled/contract/schemas.js +36 -0
  116. package/transpiled/contract/schemas.js.map +1 -0
  117. package/transpiled/discovery.d.ts +12 -0
  118. package/transpiled/discovery.js +34 -0
  119. package/transpiled/discovery.js.map +1 -0
  120. package/transpiled/effect.d.ts +5 -0
  121. package/transpiled/effect.js +11 -0
  122. package/transpiled/effect.js.map +1 -0
  123. package/transpiled/emission.d.ts +8 -0
  124. package/transpiled/emission.js +14 -0
  125. package/transpiled/emission.js.map +1 -0
  126. package/transpiled/entities/changeset.d.ts +10 -0
  127. package/transpiled/entities/changeset.js +27 -0
  128. package/transpiled/entities/changeset.js.map +1 -0
  129. package/transpiled/entities/entity.d.ts +19 -0
  130. package/transpiled/entities/entity.js +109 -0
  131. package/transpiled/entities/entity.js.map +1 -0
  132. package/transpiled/entities/factory.d.ts +22 -0
  133. package/transpiled/entities/factory.js +34 -0
  134. package/transpiled/entities/factory.js.map +1 -0
  135. package/transpiled/entities/index.d.ts +4 -0
  136. package/transpiled/entities/index.js +5 -0
  137. package/transpiled/entities/index.js.map +1 -0
  138. package/transpiled/entities/newid.d.ts +1 -0
  139. package/transpiled/entities/newid.js +7 -0
  140. package/transpiled/entities/newid.js.map +1 -0
  141. package/transpiled/entities/set.d.ts +10 -0
  142. package/transpiled/entities/set.js +19 -0
  143. package/transpiled/entities/set.js.map +1 -0
  144. package/transpiled/event.d.ts +14 -0
  145. package/transpiled/event.js +38 -0
  146. package/transpiled/event.js.map +1 -0
  147. package/transpiled/exceptions.d.ts +61 -0
  148. package/transpiled/exceptions.js +93 -0
  149. package/transpiled/exceptions.js.map +1 -0
  150. package/transpiled/exposition.d.ts +18 -0
  151. package/transpiled/exposition.js +18 -0
  152. package/transpiled/exposition.js.map +1 -0
  153. package/transpiled/guard.d.ts +7 -0
  154. package/transpiled/guard.js +12 -0
  155. package/transpiled/guard.js.map +1 -0
  156. package/transpiled/index.d.ts +35 -0
  157. package/transpiled/index.js +29 -0
  158. package/transpiled/index.js.map +1 -0
  159. package/transpiled/locator.d.ts +12 -0
  160. package/transpiled/locator.js +32 -0
  161. package/transpiled/locator.js.map +1 -0
  162. package/transpiled/observation.d.ts +5 -0
  163. package/transpiled/observation.js +12 -0
  164. package/transpiled/observation.js.map +1 -0
  165. package/transpiled/operation.d.ts +49 -0
  166. package/transpiled/operation.js +77 -0
  167. package/transpiled/operation.js.map +1 -0
  168. package/transpiled/outbox/index.d.ts +1 -0
  169. package/transpiled/outbox/index.js +2 -0
  170. package/transpiled/outbox/index.js.map +1 -0
  171. package/transpiled/outbox/outbox.d.ts +46 -0
  172. package/transpiled/outbox/outbox.js +267 -0
  173. package/transpiled/outbox/outbox.js.map +1 -0
  174. package/transpiled/query/criteria.d.ts +6 -0
  175. package/transpiled/query/criteria.js +74 -0
  176. package/transpiled/query/criteria.js.map +1 -0
  177. package/transpiled/query/options.d.ts +3 -0
  178. package/transpiled/query/options.js +27 -0
  179. package/transpiled/query/options.js.map +1 -0
  180. package/transpiled/query.d.ts +9 -0
  181. package/transpiled/query.js +57 -0
  182. package/transpiled/query.js.map +1 -0
  183. package/transpiled/receiver.d.ts +20 -0
  184. package/transpiled/receiver.js +92 -0
  185. package/transpiled/receiver.js.map +1 -0
  186. package/transpiled/reflection.d.ts +9 -0
  187. package/transpiled/reflection.js +13 -0
  188. package/transpiled/reflection.js.map +1 -0
  189. package/transpiled/remote.d.ts +10 -0
  190. package/transpiled/remote.js +12 -0
  191. package/transpiled/remote.js.map +1 -0
  192. package/transpiled/state.d.ts +33 -0
  193. package/transpiled/state.js +126 -0
  194. package/transpiled/state.js.map +1 -0
  195. package/transpiled/transition.d.ts +14 -0
  196. package/transpiled/transition.js +51 -0
  197. package/transpiled/transition.js.map +1 -0
  198. package/transpiled/transmission.d.ts +8 -0
  199. package/transpiled/transmission.js +30 -0
  200. package/transpiled/transmission.js.map +1 -0
  201. package/transpiled/types/atomicity.d.ts +56 -0
  202. package/transpiled/types/atomicity.js +2 -0
  203. package/transpiled/types/atomicity.js.map +1 -0
  204. package/transpiled/types/bindings.d.ts +42 -0
  205. package/transpiled/types/bindings.js +2 -0
  206. package/transpiled/types/bindings.js.map +1 -0
  207. package/transpiled/types/bridges.d.ts +38 -0
  208. package/transpiled/types/bridges.js +2 -0
  209. package/transpiled/types/bridges.js.map +1 -0
  210. package/transpiled/types/extensions.d.ts +62 -0
  211. package/transpiled/types/extensions.js +2 -0
  212. package/transpiled/types/extensions.js.map +1 -0
  213. package/transpiled/types/index.d.ts +13 -0
  214. package/transpiled/types/index.js +8 -0
  215. package/transpiled/types/index.js.map +1 -0
  216. package/transpiled/types/message.d.ts +5 -0
  217. package/transpiled/types/message.js +2 -0
  218. package/transpiled/types/message.js.map +1 -0
  219. package/transpiled/types/operations.d.ts +15 -0
  220. package/transpiled/types/operations.js +2 -0
  221. package/transpiled/types/operations.js.map +1 -0
  222. package/transpiled/types/outbox.d.ts +28 -0
  223. package/transpiled/types/outbox.js +2 -0
  224. package/transpiled/types/outbox.js.map +1 -0
  225. package/transpiled/types/receiver.d.ts +9 -0
  226. package/transpiled/types/receiver.js +2 -0
  227. package/transpiled/types/receiver.js.map +1 -0
  228. package/transpiled/types/request.d.ts +55 -0
  229. package/transpiled/types/request.js +2 -0
  230. package/transpiled/types/request.js.map +1 -0
  231. package/transpiled/types/state.d.ts +9 -0
  232. package/transpiled/types/state.js +2 -0
  233. package/transpiled/types/state.js.map +1 -0
  234. package/transpiled/types/storages.d.ts +106 -0
  235. package/transpiled/types/storages.js +2 -0
  236. package/transpiled/types/storages.js.map +1 -0
  237. package/transpiled/unmanaged.d.ts +5 -0
  238. package/transpiled/unmanaged.js +7 -0
  239. package/transpiled/unmanaged.js.map +1 -0
  240. package/tsconfig.json +10 -0
  241. package/tsconfig.tsbuildinfo +1 -0
  242. package/src/assignment.js +0 -28
  243. package/src/context.js +0 -57
  244. package/src/contract/contract.js +0 -18
  245. package/src/contract/request.js +0 -77
  246. package/src/contract/schemas/error.yaml +0 -9
  247. package/src/contract/schemas/index.js +0 -11
  248. package/src/contract/schemas/query.yaml +0 -43
  249. package/src/contract/schemas/source.yaml +0 -23
  250. package/src/effect.js +0 -15
  251. package/src/entities/changeset.js +0 -36
  252. package/src/entities/entity.js +0 -119
  253. package/src/entities/factory.js +0 -40
  254. package/src/entities/index.js +0 -1
  255. package/src/event.js +0 -54
  256. package/src/exposition.js +0 -24
  257. package/src/guard.js +0 -13
  258. package/src/observation.js +0 -8
  259. package/src/operation.js +0 -95
  260. package/src/query/criteria.js +0 -44
  261. package/src/query/options.js +0 -37
  262. package/src/receiver.js +0 -123
  263. package/src/reflection.js +0 -24
  264. package/src/remote.js +0 -14
  265. package/src/state.js +0 -138
  266. package/src/transition.js +0 -61
  267. package/src/unmanaged.js +0 -7
  268. package/types/atomicity.d.ts +0 -79
  269. package/types/bindings.d.ts +0 -42
  270. package/types/bridges.ts +0 -33
  271. package/types/call.d.ts +0 -13
  272. package/types/component.d.ts +0 -12
  273. package/types/connector.d.ts +0 -18
  274. package/types/context.d.ts +0 -24
  275. package/types/entity.d.ts +0 -46
  276. package/types/event.d.ts +0 -11
  277. package/types/exception.d.ts +0 -4
  278. package/types/extensions.d.ts +0 -73
  279. package/types/guard.d.ts +0 -5
  280. package/types/locator.d.ts +0 -13
  281. package/types/operations.d.ts +0 -8
  282. package/types/outbox.d.ts +0 -53
  283. package/types/query.d.ts +0 -17
  284. package/types/receiver.d.ts +0 -12
  285. package/types/reflection.d.ts +0 -14
  286. package/types/remote.d.ts +0 -19
  287. package/types/state.d.ts +0 -38
  288. package/types/storages.d.ts +0 -96
  289. /package/{src/contract/index.js → source/contract/index.ts} +0 -0
  290. /package/{src/outbox/index.js → source/outbox/index.ts} +0 -0
@@ -1,7 +1,7 @@
1
- import { describe, it, beforeEach, mock } from 'node:test'
1
+ import { describe, it, beforeEach } from 'node:test'
2
2
  import assert from 'node:assert/strict'
3
3
 
4
- import { Query } from '../src/query.js'
4
+ import { Query } from '../source/query.js'
5
5
  import * as fixtures from './query.fixtures.js'
6
6
 
7
7
  beforeEach(() => {
@@ -54,10 +54,62 @@ describe('criteria', () => {
54
54
  assert.deepStrictEqual(query.criteria, fixtures.samples.extended.parsed.criteria)
55
55
  })
56
56
 
57
+ it('should refuse a value the property cannot hold', () => {
58
+ const strict = new Query({
59
+ volume: { type: 'number' },
60
+ count: { type: 'integer' },
61
+ booked: { type: 'boolean' }
62
+ })
63
+
64
+ const refused = [
65
+ ['volume>abc', /takes a number/],
66
+ ['volume==1.5kg', /takes a number/],
67
+ ['count==1.5', /takes an integer/],
68
+ ['count==12kg', /takes an integer/],
69
+ ['booked==yes', /takes a boolean/],
70
+ ['booked==TRUE', /takes a boolean/],
71
+ ['volume=in=(1,two)', /'two' is not one/]
72
+ ]
73
+
74
+ for (const [criteria, message] of refused)
75
+ assert.throws(
76
+ () => strict.parse({ criteria }),
77
+ (error) => message.test(error.message),
78
+ criteria
79
+ )
80
+ })
81
+
82
+ it('should read a value the property can hold', () => {
83
+ const strict = new Query({
84
+ volume: { type: 'number' },
85
+ count: { type: 'integer' },
86
+ booked: { type: 'boolean' },
87
+ title: { type: 'string' }
88
+ })
89
+
90
+ const read = [
91
+ ['volume>1.5', 1.5],
92
+ ['volume>-1.5', -1.5],
93
+ ['count==12', 12],
94
+ ['booked==false', false],
95
+ ['title==12kg', '12kg']
96
+ ]
97
+
98
+ for (const [criteria, value] of read)
99
+ assert.deepStrictEqual(
100
+ strict.parse({ criteria }).criteria.right.value,
101
+ value,
102
+ criteria
103
+ )
104
+ })
105
+
57
106
  it('should throw on unknown properties', () => {
58
107
  const instance = new Query(fixtures.samples.simple.properties)
59
108
 
60
- assert.throws(() => instance.parse({ criteria: 'lastname==Johnson' }), (error) => /not defined/.test(error.message))
109
+ assert.throws(
110
+ () => instance.parse({ criteria: 'lastname==Johnson' }),
111
+ (error) => /not defined/.test(error.message)
112
+ )
61
113
  })
62
114
 
63
115
  it('should parse id', () => {
@@ -91,13 +143,20 @@ describe('options', () => {
91
143
  const sort = ['a', 'b:desc', 'c']
92
144
  const query = instance.parse({ sort })
93
145
 
94
- assert.deepStrictEqual(query.options.sort, [['a', 'asc'], ['b', 'desc'], ['c', 'asc']])
146
+ assert.deepStrictEqual(query.options.sort, [
147
+ ['a', 'asc'],
148
+ ['b', 'desc'],
149
+ ['c', 'asc']
150
+ ])
95
151
  })
96
152
 
97
153
  it('should throw on unknown properties', () => {
98
154
  const sort = ['d:asc']
99
155
 
100
- assert.throws(() => instance.parse({ sort }), (error) => /not defined/.test(error.message))
156
+ assert.throws(
157
+ () => instance.parse({ sort }),
158
+ (error) => /not defined/.test(error.message)
159
+ )
101
160
  })
102
161
  })
103
162
 
@@ -105,12 +164,15 @@ describe('options', () => {
105
164
  it('should throw on unknown properties', () => {
106
165
  const projection = ['a', 'b', 'c', 'd']
107
166
 
108
- assert.throws(() => instance.parse({ projection }), (error) => /not defined/.test(error.message))
167
+ assert.throws(
168
+ () => instance.parse({ projection }),
169
+ (error) => /not defined/.test(error.message)
170
+ )
109
171
  })
110
172
  })
111
173
  })
112
174
 
113
- function resetCalls (target = [assert, fixtures], seen = new Set()) {
175
+ function resetCalls(target = [assert, fixtures], seen = new Set()) {
114
176
  if (target === null || typeof target !== 'object' || seen.has(target)) return
115
177
 
116
178
  seen.add(target)
@@ -8,13 +8,13 @@ export const definition = /** @type {toa.norm.component.Receiver} */ {
8
8
  adaptive: false
9
9
  }
10
10
 
11
- export const local = /** @type {toa.core.Component} */ {
11
+ export const local = /** @type {import('@toa.io/core').Component} */ {
12
12
  locator: { id: 'default.dummy' },
13
13
  invoke: mock.fn()
14
14
  }
15
15
 
16
16
  // noinspection JSCheckFunctionSignatures
17
- export const bridge = /** @type {toa.core.bridges.Event} */ {
17
+ export const bridge = /** @type {import('@toa.io/core/types').bridges.Event} */ {
18
18
  condition: mock.fn(async (payload) => !(payload.reject === true)),
19
19
  request: mock.fn(async () => ({ input: generate() }))
20
20
  }
@@ -6,19 +6,20 @@ import clone from 'clone-deep'
6
6
  import { generate } from 'randomstring'
7
7
  import { merge } from '@toa.io/generic'
8
8
 
9
- import { Connector } from '../src/connector.js'
9
+ import { Connector } from '../source/connector.js'
10
10
 
11
11
  // the fixtures are not connectors, so a dependency is recorded rather than linked
12
12
  const depends = mock.method(Connector.prototype, 'depends', () => undefined)
13
13
 
14
- const dependencies = (instance) => depends.mock.calls
15
- .filter((call) => call.this === instance)
16
- .map((call) => call.arguments[0])
14
+ const dependencies = (instance) =>
15
+ depends.mock.calls
16
+ .filter((call) => call.this === instance)
17
+ .map((call) => call.arguments[0])
17
18
 
18
- import { Receiver } from '../src/receiver.js'
19
+ import { Receiver } from '../source/receiver.js'
19
20
  import * as fixtures from './receiver.fixtures.js'
20
21
 
21
- /** @type {toa.core.Receiver} */
22
+ /** @type {import('@toa.io/core/types').Receiver} */
22
23
  let receiver
23
24
 
24
25
  /** @type {toa.norm.component.Receiver} */
@@ -42,29 +43,38 @@ it('should apply', async () => {
42
43
 
43
44
  await receiver.receive({ payload })
44
45
 
45
- assert.ok(fixtures.local.invoke.mock.calls.some((call) => call.arguments.length === 2 && isDeepStrictEqual(call.arguments[0], definition.operation) && isDeepStrictEqual(call.arguments[1], { input: payload })))
46
+ assert.ok(
47
+ fixtures.local.invoke.mock.calls.some(
48
+ (call) =>
49
+ call.arguments.length === 2 &&
50
+ isDeepStrictEqual(call.arguments[0], definition.operation) &&
51
+ isDeepStrictEqual(call.arguments[1], { input: payload })
52
+ )
53
+ )
46
54
  })
47
55
 
48
56
  for (const [adaptive] of [[false], [true]])
49
- it(`should pass UI extensions (adaptive: ${adaptive})`, async () => {
50
- resetCalls()
57
+ it(`should pass UI extensions (adaptive: ${adaptive})`, async () => {
58
+ resetCalls()
51
59
 
52
- definition.adaptive = adaptive
53
- receiver = new Receiver(definition, fixtures.local, fixtures.bridge)
60
+ definition.adaptive = adaptive
61
+ receiver = new Receiver(definition, fixtures.local, fixtures.bridge)
54
62
 
55
- const payload = { foo: generate() }
56
- const extension = { [generate()]: generate() }
57
- const message = { payload, ...extension }
63
+ const payload = { foo: generate() }
64
+ const extension = { [generate()]: generate() }
65
+ const message = { payload, ...extension }
58
66
 
59
- await receiver.receive(message)
67
+ await receiver.receive(message)
60
68
 
61
- const request = adaptive ? await fixtures.bridge.request.mock.calls[0].result : { input: payload }
62
- const expected = merge(clone(request), extension)
69
+ const request = adaptive
70
+ ? await fixtures.bridge.request.mock.calls[0].result
71
+ : { input: payload }
72
+ const expected = merge(clone(request), extension)
63
73
 
64
- const argument = fixtures.local.invoke.mock.calls[0].arguments[1]
74
+ const argument = fixtures.local.invoke.mock.calls[0].arguments[1]
65
75
 
66
- assert.deepStrictEqual(argument, expected)
67
- })
76
+ assert.deepStrictEqual(argument, expected)
77
+ })
68
78
 
69
79
  describe('conditioned', () => {
70
80
  beforeEach(() => {
@@ -76,8 +86,20 @@ describe('conditioned', () => {
76
86
  const payload = { foo: 'bar' }
77
87
  await receiver.receive({ payload })
78
88
 
79
- assert.ok(fixtures.bridge.condition.mock.calls.some((call) => call.arguments.length === 1 && isDeepStrictEqual(call.arguments[0], payload)))
80
- assert.ok(fixtures.local.invoke.mock.calls.some((call) => call.arguments.length === 2 && isDeepStrictEqual(call.arguments[0], definition.operation) && isDeepStrictEqual(call.arguments[1], { input: payload })))
89
+ assert.ok(
90
+ fixtures.bridge.condition.mock.calls.some(
91
+ (call) =>
92
+ call.arguments.length === 1 && isDeepStrictEqual(call.arguments[0], payload)
93
+ )
94
+ )
95
+ assert.ok(
96
+ fixtures.local.invoke.mock.calls.some(
97
+ (call) =>
98
+ call.arguments.length === 2 &&
99
+ isDeepStrictEqual(call.arguments[0], definition.operation) &&
100
+ isDeepStrictEqual(call.arguments[1], { input: payload })
101
+ )
102
+ )
81
103
  })
82
104
 
83
105
  it('should not apply if condition is false', async () => {
@@ -100,14 +122,18 @@ describe('adaptive', () => {
100
122
 
101
123
  const request = await fixtures.bridge.request.mock.calls[0].result
102
124
 
103
- assert.ok(fixtures.local.invoke.mock.calls.some((call) =>
104
- call.arguments.length === 2 &&
105
- isDeepStrictEqual(call.arguments[0], definition.operation) &&
106
- isDeepStrictEqual(call.arguments[1], request)))
125
+ assert.ok(
126
+ fixtures.local.invoke.mock.calls.some(
127
+ (call) =>
128
+ call.arguments.length === 2 &&
129
+ isDeepStrictEqual(call.arguments[0], definition.operation) &&
130
+ isDeepStrictEqual(call.arguments[1], request)
131
+ )
132
+ )
107
133
  })
108
134
  })
109
135
 
110
- function resetCalls (target = [assert, clone, fixtures], seen = new Set()) {
136
+ function resetCalls(target = [assert, clone, fixtures], seen = new Set()) {
111
137
  if (target === null || typeof target !== 'object' || seen.has(target)) return
112
138
 
113
139
  seen.add(target)
@@ -2,18 +2,18 @@ import { it, beforeEach } from 'node:test'
2
2
  import assert from 'node:assert/strict'
3
3
 
4
4
  import { generate } from 'randomstring'
5
- import { Reflection, Connector } from '../src/index.js'
5
+ import { Reflection, Connector } from '../source/index.js'
6
6
 
7
7
  it('should export', () => {
8
8
  assert.notStrictEqual(Reflection, undefined)
9
9
  })
10
10
 
11
- /** @type {toa.core.Reflection<string>} */
11
+ /** @type {import('@toa.io/core').Reflection<string>} */
12
12
  let reflection
13
13
 
14
14
  const value = generate()
15
15
 
16
- /** @type {toa.core.reflection.Source<string>} */
16
+ /** @type {import('@toa.io/core').ReflectionSource<string>} */
17
17
  const source = async () => value
18
18
 
19
19
  beforeEach(() => {
@@ -5,7 +5,7 @@ import { generate } from 'randomstring'
5
5
  export const storage = {
6
6
  name: 'dummy',
7
7
  get: mock.fn(() => ({ id: generate() })),
8
- find: mock.fn(() => ([{ id: generate() }])),
8
+ find: mock.fn(() => [{ id: generate() }]),
9
9
  add: mock.fn(() => true),
10
10
  set: mock.fn(() => true),
11
11
  store: mock.fn(() => true),
@@ -27,7 +27,8 @@ export const entity = {
27
27
  }
28
28
 
29
29
  export const initial = {
30
- initial: true, ...entity
30
+ initial: true,
31
+ ...entity
31
32
  }
32
33
 
33
34
  export const unchanged = {
@@ -37,6 +38,12 @@ export const unchanged = {
37
38
 
38
39
  // a legacy outbox: no storage capability, so `publish` emits inline
39
40
  export const outbox = {
40
- row: mock.fn((event) => ({ id: generate(), lane: 0, published: false, pending: 0, event })),
41
+ row: mock.fn((event) => ({
42
+ id: generate(),
43
+ lane: 0,
44
+ published: false,
45
+ pending: 0,
46
+ event
47
+ })),
41
48
  publish: mock.fn()
42
49
  }
@@ -1,8 +1,8 @@
1
- import { describe, it, beforeEach, mock } from 'node:test'
1
+ import { describe, it, beforeEach } from 'node:test'
2
2
  import assert from 'node:assert/strict'
3
3
  import { isDeepStrictEqual } from 'node:util'
4
4
 
5
- import { State } from '../src/state.js'
5
+ import { State } from '../source/state.js'
6
6
  import * as fixtures from './state.fixtures.js'
7
7
 
8
8
  let state
@@ -16,34 +16,84 @@ beforeEach(() => {
16
16
  it('should provide object', async () => {
17
17
  const entity = await state.object(fixtures.query)
18
18
 
19
- assert.ok(fixtures.storage.get.mock.calls.some((call) => call.arguments.length === 1 && isDeepStrictEqual(call.arguments[0], fixtures.query)))
19
+ assert.ok(
20
+ fixtures.storage.get.mock.calls.some(
21
+ (call) =>
22
+ call.arguments.length === 1 &&
23
+ isDeepStrictEqual(call.arguments[0], fixtures.query)
24
+ )
25
+ )
20
26
  assert.deepStrictEqual(entity, fixtures.factory.object.mock.calls[0].result)
21
- assert.ok(fixtures.factory.object.mock.calls.some((call) => call.arguments.length === 2 && isDeepStrictEqual(call.arguments[0], fixtures.storage.get.mock.calls[0].result) && isDeepStrictEqual(call.arguments[1], true)))
27
+ assert.ok(
28
+ fixtures.factory.object.mock.calls.some(
29
+ (call) =>
30
+ call.arguments.length === 2 &&
31
+ isDeepStrictEqual(call.arguments[0], fixtures.storage.get.mock.calls[0].result) &&
32
+ isDeepStrictEqual(call.arguments[1], true)
33
+ )
34
+ )
22
35
  })
23
36
 
24
37
  it('should provide read-only object', async () => {
25
38
  await state.object(fixtures.query, false)
26
39
 
27
- assert.ok(fixtures.factory.object.mock.calls.some((call) => call.arguments.length === 2 && isDeepStrictEqual(call.arguments[0], fixtures.storage.get.mock.calls[0].result) && isDeepStrictEqual(call.arguments[1], false)))
40
+ assert.ok(
41
+ fixtures.factory.object.mock.calls.some(
42
+ (call) =>
43
+ call.arguments.length === 2 &&
44
+ isDeepStrictEqual(call.arguments[0], fixtures.storage.get.mock.calls[0].result) &&
45
+ isDeepStrictEqual(call.arguments[1], false)
46
+ )
47
+ )
28
48
  })
29
49
 
30
50
  it('should provide read-only objects', async () => {
31
51
  await state.objects(fixtures.query, false)
32
52
 
33
- assert.ok(fixtures.factory.objects.mock.calls.some((call) => call.arguments.length === 3 && isDeepStrictEqual(call.arguments[0], fixtures.storage.find.mock.calls[0].result) && isDeepStrictEqual(call.arguments[1], undefined) && isDeepStrictEqual(call.arguments[2], false)))
53
+ assert.ok(
54
+ fixtures.factory.objects.mock.calls.some(
55
+ (call) =>
56
+ call.arguments.length === 3 &&
57
+ isDeepStrictEqual(
58
+ call.arguments[0],
59
+ fixtures.storage.find.mock.calls[0].result
60
+ ) &&
61
+ isDeepStrictEqual(call.arguments[1], undefined) &&
62
+ isDeepStrictEqual(call.arguments[2], false)
63
+ )
64
+ )
34
65
  })
35
66
 
36
67
  it('should store entity', async () => {
37
68
  await state.commit(fixtures.initial)
38
69
 
39
- assert.ok(fixtures.storage.store.mock.calls.some((call) => call.arguments.length === 2 && isDeepStrictEqual(call.arguments[0], fixtures.initial.get.mock.calls[0].result) && isDeepStrictEqual(call.arguments[1], fixtures.outbox.row.mock.calls[0].result)))
70
+ assert.ok(
71
+ fixtures.storage.store.mock.calls.some(
72
+ (call) =>
73
+ call.arguments.length === 2 &&
74
+ isDeepStrictEqual(call.arguments[0], fixtures.initial.get.mock.calls[0].result) &&
75
+ isDeepStrictEqual(call.arguments[1], fixtures.outbox.row.mock.calls[0].result)
76
+ )
77
+ )
40
78
  })
41
79
 
42
80
  it('should publish the row', async () => {
43
81
  await state.commit(fixtures.entity)
44
82
 
45
- assert.ok(fixtures.outbox.row.mock.calls.some((call) => call.arguments.length === 1 && isDeepStrictEqual(call.arguments[0], fixtures.entity.event.mock.calls[0].result)))
46
- assert.ok(fixtures.outbox.publish.mock.calls.some((call) => call.arguments.length === 1 && isDeepStrictEqual(call.arguments[0], fixtures.outbox.row.mock.calls[0].result)))
83
+ assert.ok(
84
+ fixtures.outbox.row.mock.calls.some(
85
+ (call) =>
86
+ call.arguments.length === 1 &&
87
+ isDeepStrictEqual(call.arguments[0], fixtures.entity.event.mock.calls[0].result)
88
+ )
89
+ )
90
+ assert.ok(
91
+ fixtures.outbox.publish.mock.calls.some(
92
+ (call) =>
93
+ call.arguments.length === 1 &&
94
+ isDeepStrictEqual(call.arguments[0], fixtures.outbox.row.mock.calls[0].result)
95
+ )
96
+ )
47
97
  })
48
98
 
49
99
  it('should not publish if the write did not happen', async () => {
@@ -62,7 +112,6 @@ it('should build the row before the write', async () => {
62
112
  return true
63
113
  })
64
114
 
65
-
66
115
  await state.commit(fixtures.entity)
67
116
  })
68
117
 
@@ -72,9 +121,23 @@ describe('assignment', () => {
72
121
  it('should pass the row to upsert and publish it', async () => {
73
122
  const result = await state.apply(changeset, { foo: 1 })
74
123
 
75
- assert.ok(fixtures.storage.upsert.mock.calls.some((call) => call.arguments.length === 3 && isDeepStrictEqual(call.arguments[0], changeset.query) && isDeepStrictEqual(call.arguments[1], { foo: 1 }) && isDeepStrictEqual(call.arguments[2], fixtures.outbox.row.mock.calls[0].result)))
76
-
77
- assert.ok(fixtures.outbox.publish.mock.calls.some((call) => call.arguments.length === 1 && isDeepStrictEqual(call.arguments[0], fixtures.outbox.row.mock.calls[0].result)))
124
+ assert.ok(
125
+ fixtures.storage.upsert.mock.calls.some(
126
+ (call) =>
127
+ call.arguments.length === 3 &&
128
+ isDeepStrictEqual(call.arguments[0], changeset.query) &&
129
+ isDeepStrictEqual(call.arguments[1], { foo: 1 }) &&
130
+ isDeepStrictEqual(call.arguments[2], fixtures.outbox.row.mock.calls[0].result)
131
+ )
132
+ )
133
+
134
+ assert.ok(
135
+ fixtures.outbox.publish.mock.calls.some(
136
+ (call) =>
137
+ call.arguments.length === 1 &&
138
+ isDeepStrictEqual(call.arguments[0], fixtures.outbox.row.mock.calls[0].result)
139
+ )
140
+ )
78
141
  assert.deepStrictEqual(result, fixtures.storage.upsert.mock.calls[0].result)
79
142
  })
80
143
 
@@ -88,7 +151,7 @@ describe('assignment', () => {
88
151
  })
89
152
  })
90
153
 
91
- function resetCalls (target = [assert, fixtures], seen = new Set()) {
154
+ function resetCalls(target = [assert, fixtures], seen = new Set()) {
92
155
  if (target === null || typeof target !== 'object' || seen.has(target)) return
93
156
 
94
157
  seen.add(target)
@@ -2,16 +2,17 @@ import { it, beforeEach, mock } from 'node:test'
2
2
  import assert from 'node:assert/strict'
3
3
  import { isDeepStrictEqual } from 'node:util'
4
4
 
5
- import { Connector } from '../src/connector.js'
5
+ import { Connector } from '../source/connector.js'
6
6
 
7
7
  // the fixtures are not connectors, so a dependency is recorded rather than linked
8
8
  const depends = mock.method(Connector.prototype, 'depends', () => undefined)
9
9
 
10
- const dependencies = (instance) => depends.mock.calls
11
- .filter((call) => call.this === instance)
12
- .map((call) => call.arguments[0])
13
- import { Transmission } from '../src/transmission.js'
14
- import { codes } from '../src/exceptions.js'
10
+ const dependencies = (instance) =>
11
+ depends.mock.calls
12
+ .filter((call) => call.this === instance)
13
+ .map((call) => call.arguments[0])
14
+ import { Transmission } from '../source/transmission.js'
15
+ import { codes } from '../source/exceptions.js'
15
16
  import * as fixtures from './transmission.fixtures.js'
16
17
 
17
18
  let transmission
@@ -27,14 +28,21 @@ beforeEach(() => {
27
28
 
28
29
  it('should be instance of Connector depending on bindings', () => {
29
30
  assert.ok(transmission instanceof Connector)
30
- assert.ok(dependencies(transmission).some((one) => isDeepStrictEqual(one, fixtures.bindings)))
31
+ assert.ok(
32
+ dependencies(transmission).some((one) => isDeepStrictEqual(one, fixtures.bindings))
33
+ )
31
34
  })
32
35
 
33
36
  it('should pass arguments and return value', async () => {
34
37
  const request = { foo: 'bar' }
35
38
  const result = await transmission.request(request)
36
39
 
37
- assert.ok(fixtures.bindings[0].request.mock.calls.some((call) => call.arguments.length === 1 && isDeepStrictEqual(call.arguments[0], request)))
40
+ assert.ok(
41
+ fixtures.bindings[0].request.mock.calls.some(
42
+ (call) =>
43
+ call.arguments.length === 1 && isDeepStrictEqual(call.arguments[0], request)
44
+ )
45
+ )
38
46
  assert.strictEqual(result, await fixtures.bindings[0].request.mock.calls[0].result)
39
47
  })
40
48
 
@@ -47,13 +55,18 @@ it('should pick bindings sequentially', async () => {
47
55
  })
48
56
 
49
57
  it('should throw exception if none succeeded', async () => {
50
- await assert.rejects(transmission.request({ pick: 5 }), (error) => { assert.partialDeepStrictEqual(error, { code: codes.Transmission }); return true })
58
+ await assert.rejects(transmission.request({ pick: 5 }), (error) => {
59
+ assert.partialDeepStrictEqual(error, { code: codes.Transmission })
60
+ return true
61
+ })
51
62
 
52
- fixtures.bindings.forEach((binding) =>
53
- assert.ok(binding.request.mock.callCount() > 0))
63
+ fixtures.bindings.forEach((binding) => assert.ok(binding.request.mock.callCount() > 0))
54
64
  })
55
65
 
56
- function resetCalls (target = [assert, depends, dependencies, fixtures], seen = new Set()) {
66
+ function resetCalls(
67
+ target = [assert, depends, dependencies, fixtures],
68
+ seen = new Set()
69
+ ) {
57
70
  if (target === null || typeof target !== 'object' || seen.has(target)) return
58
71
 
59
72
  seen.add(target)
@@ -0,0 +1,6 @@
1
+ import { Operation } from './operation.js';
2
+ import type { Store } from './operation.js';
3
+ export declare class Assignment extends Operation {
4
+ protected acquire(store: Store): Promise<void>;
5
+ protected commit(store: Store): Promise<void>;
6
+ }
@@ -0,0 +1,20 @@
1
+ import { Operation } from './operation.js';
2
+ export class Assignment extends Operation {
3
+ async acquire(store) {
4
+ const changeset = this.scope.changeset(store.request.query);
5
+ store.scope = changeset;
6
+ store.state = changeset.get();
7
+ }
8
+ async commit(store) {
9
+ const { scope, state, reply, request } = store;
10
+ if (reply.error !== undefined)
11
+ return;
12
+ const changeset = scope;
13
+ changeset.set(state);
14
+ const output = await this.scope.apply(changeset, request.input);
15
+ // assignment returns new state by default
16
+ if (store.reply.output === undefined)
17
+ store.reply.output = output;
18
+ }
19
+ }
20
+ //# sourceMappingURL=assignment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assignment.js","sourceRoot":"","sources":["../source/assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAI1C,MAAM,OAAO,UAAW,SAAQ,SAAS;IACpB,KAAK,CAAC,OAAO,CAAC,KAAY;QAC3C,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,KAAY,CAAC,CAAA;QAElE,KAAK,CAAC,KAAK,GAAG,SAAS,CAAA;QACvB,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,EAAE,CAAA;IAC/B,CAAC;IAEkB,KAAK,CAAC,MAAM,CAAC,KAAY;QAC1C,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,CAAA;QAE9C,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;YAAE,OAAM;QAErC,MAAM,SAAS,GAAG,KAAkB,CAAA;QAEpC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAEpB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;QAE/D,0CAA0C;QAC1C,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS;YAAE,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAA;IACnE,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ import { Connector } from './connector.js';
2
+ import type { Transmission } from './transmission.js';
3
+ import type { Request as Contract } from './contract/request.js';
4
+ import type { Request, Source } from './types/request.js';
5
+ export declare class Call extends Connector {
6
+ #private;
7
+ constructor(transmitter: Transmission, contract: Contract, source?: Source);
8
+ invoke(request?: Request): Promise<any>;
9
+ explain(): any;
10
+ }
@@ -0,0 +1,52 @@
1
+ import { Readable } from 'node:stream';
2
+ import { current, encode } from 'openspan';
3
+ import { Connector } from './connector.js';
4
+ export class Call extends Connector {
5
+ #transmitter;
6
+ #contract;
7
+ #source;
8
+ constructor(transmitter, contract, source) {
9
+ super();
10
+ this.#transmitter = transmitter;
11
+ this.#contract = contract;
12
+ this.#source = source;
13
+ this.depends(transmitter);
14
+ }
15
+ async invoke(request = {}) {
16
+ // the caller may have attributed the call itself, as the node bridge does
17
+ if (this.#source !== undefined)
18
+ request.source ??= this.#source;
19
+ this.#contract.fit(request);
20
+ // an operation that takes no input still has to send an explicit null
21
+ request.input ??= null;
22
+ // avoid validation on the recipient's side
23
+ request.authentic = true;
24
+ const context = current();
25
+ if (context !== undefined)
26
+ request.telemetry = encode(context);
27
+ const reply = await this.#transmitter.request(request);
28
+ if (reply === null)
29
+ return null;
30
+ else if (reply instanceof Readable)
31
+ return reply;
32
+ else {
33
+ if (reply.exception !== undefined)
34
+ throw reply.exception;
35
+ if (reply.error !== undefined)
36
+ return new RemoteError(reply.error);
37
+ else
38
+ return reply.output;
39
+ }
40
+ }
41
+ explain() {
42
+ return this.#contract.discovery;
43
+ }
44
+ }
45
+ // the remote error as a value: every property it carries, and nothing else enumerable
46
+ class RemoteError extends Error {
47
+ constructor(error) {
48
+ super();
49
+ Object.assign(this, error);
50
+ }
51
+ }
52
+ //# sourceMappingURL=call.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call.js","sourceRoot":"","sources":["../source/call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAK1C,MAAM,OAAO,IAAK,SAAQ,SAAS;IACxB,YAAY,CAAc;IAC1B,SAAS,CAAU;IACnB,OAAO,CAAoB;IAEpC,YAAmB,WAAyB,EAAE,QAAkB,EAAE,MAAe;QAC/E,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,YAAY,GAAG,WAAW,CAAA;QAC/B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;QACzB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;QAErB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IAC3B,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,OAAO,GAAY,EAAE;QACvC,0EAA0E;QAC1E,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;YAAE,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAA;QAE/D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QAE3B,sEAAsE;QACtE,OAAO,CAAC,KAAK,KAAK,IAAI,CAAA;QAEtB,2CAA2C;QAC3C,OAAO,CAAC,SAAS,GAAG,IAAI,CAAA;QAExB,MAAM,OAAO,GAAG,OAAO,EAAE,CAAA;QAEzB,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;QAE9D,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAEtD,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,IAAI,CAAA;aAC1B,IAAI,KAAK,YAAY,QAAQ;YAAE,OAAO,KAAK,CAAA;aAC3C,CAAC;YACJ,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS;gBAAE,MAAM,KAAK,CAAC,SAAS,CAAA;YAExD,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;gBAAE,OAAO,IAAI,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;;gBAC7D,OAAO,KAAK,CAAC,MAAM,CAAA;QAC1B,CAAC;IACH,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAA;IACjC,CAAC;CACF;AAED,sFAAsF;AACtF,MAAM,WAAY,SAAQ,KAAK;IAC7B,YAAmB,KAAa;QAC9B,KAAK,EAAE,CAAA;QAEP,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IAC5B,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ import { Connector } from './connector.js';
2
+ import type { Algorithm } from './types/bridges.js';
3
+ export declare class Cascade extends Connector {
4
+ #private;
5
+ constructor(bridges: Algorithm[], preflight?: Connector);
6
+ run(...args: [any, any?]): Promise<any>;
7
+ }
@@ -0,0 +1,28 @@
1
+ import { Connector } from './connector.js';
2
+ export class Cascade extends Connector {
3
+ #last;
4
+ constructor(bridges, preflight) {
5
+ super();
6
+ // this.#bridges = bridges
7
+ this.#last = bridges[bridges.length - 1];
8
+ if (preflight === undefined)
9
+ this.depends(bridges);
10
+ else
11
+ this.depends(bridges).depends(preflight);
12
+ }
13
+ async run(...args) {
14
+ // const reply = {}
15
+ //
16
+ // for (const bridge of this.#bridges) {
17
+ // const partial = await bridge.execute(...args)
18
+ //
19
+ // if (partial.error) return { error: partial.error }
20
+ //
21
+ // merge(reply, partial)
22
+ // }
23
+ //
24
+ // return reply
25
+ return this.#last.execute(...args);
26
+ }
27
+ }
28
+ //# sourceMappingURL=cascade.js.map