@toa.io/core 1.0.0-alpha.32 → 1.0.0-alpha.321

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 (286) hide show
  1. package/package.json +28 -12
  2. package/transpiled/abandon.d.ts +9 -0
  3. package/transpiled/abandon.js +37 -0
  4. package/transpiled/abandon.js.map +1 -0
  5. package/transpiled/assignment.d.ts +6 -0
  6. package/transpiled/assignment.js +25 -0
  7. package/transpiled/assignment.js.map +1 -0
  8. package/transpiled/call.d.ts +10 -0
  9. package/transpiled/call.js +187 -0
  10. package/transpiled/call.js.map +1 -0
  11. package/transpiled/cascade.d.ts +7 -0
  12. package/transpiled/cascade.js +28 -0
  13. package/transpiled/cascade.js.map +1 -0
  14. package/transpiled/component.d.ts +17 -0
  15. package/transpiled/component.js +151 -0
  16. package/transpiled/component.js.map +1 -0
  17. package/transpiled/composition.d.ts +6 -0
  18. package/transpiled/composition.js +20 -0
  19. package/transpiled/composition.js.map +1 -0
  20. package/transpiled/connector.d.ts +71 -0
  21. package/transpiled/connector.js +248 -0
  22. package/transpiled/connector.js.map +1 -0
  23. package/transpiled/context.d.ts +25 -0
  24. package/transpiled/context.js +55 -0
  25. package/transpiled/context.js.map +1 -0
  26. package/transpiled/contract/component.d.ts +37 -0
  27. package/transpiled/contract/component.js +94 -0
  28. package/transpiled/contract/component.js.map +1 -0
  29. package/transpiled/contract/contract.d.ts +10 -0
  30. package/transpiled/contract/contract.js +14 -0
  31. package/transpiled/contract/contract.js.map +1 -0
  32. package/transpiled/contract/index.d.ts +4 -0
  33. package/transpiled/contract/index.js +5 -0
  34. package/transpiled/contract/index.js.map +1 -0
  35. package/transpiled/contract/reply.d.ts +7 -0
  36. package/transpiled/contract/reply.js +48 -0
  37. package/transpiled/contract/reply.js.map +1 -0
  38. package/transpiled/contract/request.d.ts +49 -0
  39. package/transpiled/contract/request.js +152 -0
  40. package/transpiled/contract/request.js.map +1 -0
  41. package/transpiled/contract/schemas.d.ts +4 -0
  42. package/transpiled/contract/schemas.js +38 -0
  43. package/transpiled/contract/schemas.js.map +1 -0
  44. package/transpiled/contract/system.d.ts +33 -0
  45. package/transpiled/contract/system.js +76 -0
  46. package/transpiled/contract/system.js.map +1 -0
  47. package/transpiled/deliveries.d.ts +22 -0
  48. package/transpiled/deliveries.js +31 -0
  49. package/transpiled/deliveries.js.map +1 -0
  50. package/transpiled/effect.d.ts +7 -0
  51. package/transpiled/effect.js +13 -0
  52. package/transpiled/effect.js.map +1 -0
  53. package/transpiled/emission.d.ts +10 -0
  54. package/transpiled/emission.js +16 -0
  55. package/transpiled/emission.js.map +1 -0
  56. package/transpiled/encoded.d.ts +16 -0
  57. package/transpiled/encoded.js +25 -0
  58. package/transpiled/encoded.js.map +1 -0
  59. package/transpiled/entities/changeset.d.ts +10 -0
  60. package/transpiled/entities/changeset.js +27 -0
  61. package/transpiled/entities/changeset.js.map +1 -0
  62. package/transpiled/entities/entity.d.ts +19 -0
  63. package/transpiled/entities/entity.js +137 -0
  64. package/transpiled/entities/entity.js.map +1 -0
  65. package/transpiled/entities/factory.d.ts +27 -0
  66. package/transpiled/entities/factory.js +38 -0
  67. package/transpiled/entities/factory.js.map +1 -0
  68. package/transpiled/entities/index.d.ts +5 -0
  69. package/transpiled/entities/index.js +6 -0
  70. package/transpiled/entities/index.js.map +1 -0
  71. package/transpiled/entities/newid.d.ts +11 -0
  72. package/transpiled/entities/newid.js +41 -0
  73. package/transpiled/entities/newid.js.map +1 -0
  74. package/transpiled/entities/set.d.ts +10 -0
  75. package/transpiled/entities/set.js +19 -0
  76. package/transpiled/entities/set.js.map +1 -0
  77. package/transpiled/event.d.ts +20 -0
  78. package/transpiled/event.js +65 -0
  79. package/transpiled/event.js.map +1 -0
  80. package/transpiled/exceptions.d.ts +110 -0
  81. package/transpiled/exceptions.js +215 -0
  82. package/transpiled/exceptions.js.map +1 -0
  83. package/transpiled/gate.d.ts +40 -0
  84. package/transpiled/gate.js +84 -0
  85. package/transpiled/gate.js.map +1 -0
  86. package/transpiled/guard.d.ts +7 -0
  87. package/transpiled/guard.js +12 -0
  88. package/transpiled/guard.js.map +1 -0
  89. package/transpiled/halting.d.ts +16 -0
  90. package/transpiled/halting.js +25 -0
  91. package/transpiled/halting.js.map +1 -0
  92. package/transpiled/index.d.ts +45 -0
  93. package/transpiled/index.js +37 -0
  94. package/transpiled/index.js.map +1 -0
  95. package/transpiled/instance.d.ts +10 -0
  96. package/transpiled/instance.js +30 -0
  97. package/transpiled/instance.js.map +1 -0
  98. package/transpiled/locator.d.ts +12 -0
  99. package/transpiled/locator.js +32 -0
  100. package/transpiled/locator.js.map +1 -0
  101. package/transpiled/measurements.d.ts +20 -0
  102. package/transpiled/measurements.js +40 -0
  103. package/transpiled/measurements.js.map +1 -0
  104. package/transpiled/observation.d.ts +7 -0
  105. package/transpiled/observation.js +14 -0
  106. package/transpiled/observation.js.map +1 -0
  107. package/transpiled/operation.d.ts +77 -0
  108. package/transpiled/operation.js +216 -0
  109. package/transpiled/operation.js.map +1 -0
  110. package/transpiled/outbox.d.ts +45 -0
  111. package/transpiled/outbox.js +448 -0
  112. package/transpiled/outbox.js.map +1 -0
  113. package/transpiled/outbox.measurements.d.ts +4 -0
  114. package/transpiled/outbox.measurements.js +38 -0
  115. package/transpiled/outbox.measurements.js.map +1 -0
  116. package/transpiled/parts.d.ts +20 -0
  117. package/transpiled/parts.js +23 -0
  118. package/transpiled/parts.js.map +1 -0
  119. package/transpiled/query/criteria.d.ts +6 -0
  120. package/transpiled/query/criteria.js +177 -0
  121. package/transpiled/query/criteria.js.map +1 -0
  122. package/transpiled/query/options.d.ts +3 -0
  123. package/transpiled/query/options.js +34 -0
  124. package/transpiled/query/options.js.map +1 -0
  125. package/transpiled/query.d.ts +9 -0
  126. package/transpiled/query.js +57 -0
  127. package/transpiled/query.js.map +1 -0
  128. package/transpiled/receiver.d.ts +20 -0
  129. package/transpiled/receiver.js +113 -0
  130. package/transpiled/receiver.js.map +1 -0
  131. package/transpiled/reflection.d.ts +9 -0
  132. package/transpiled/reflection.js +13 -0
  133. package/transpiled/reflection.js.map +1 -0
  134. package/transpiled/regional.d.ts +22 -0
  135. package/transpiled/regional.js +55 -0
  136. package/transpiled/regional.js.map +1 -0
  137. package/transpiled/remote.d.ts +10 -0
  138. package/transpiled/remote.js +11 -0
  139. package/transpiled/remote.js.map +1 -0
  140. package/transpiled/rendering.d.ts +13 -0
  141. package/transpiled/rendering.js +21 -0
  142. package/transpiled/rendering.js.map +1 -0
  143. package/transpiled/safety.d.ts +5 -0
  144. package/transpiled/safety.js +26 -0
  145. package/transpiled/safety.js.map +1 -0
  146. package/transpiled/state.d.ts +36 -0
  147. package/transpiled/state.js +131 -0
  148. package/transpiled/state.js.map +1 -0
  149. package/transpiled/trail.d.ts +78 -0
  150. package/transpiled/trail.js +112 -0
  151. package/transpiled/trail.js.map +1 -0
  152. package/transpiled/transition.d.ts +14 -0
  153. package/transpiled/transition.js +51 -0
  154. package/transpiled/transition.js.map +1 -0
  155. package/transpiled/transmission.d.ts +8 -0
  156. package/transpiled/transmission.js +30 -0
  157. package/transpiled/transmission.js.map +1 -0
  158. package/transpiled/types/atomicity.d.ts +58 -0
  159. package/transpiled/types/atomicity.js +2 -0
  160. package/transpiled/types/atomicity.js.map +1 -0
  161. package/transpiled/types/bindings.d.ts +82 -0
  162. package/transpiled/types/bindings.js +2 -0
  163. package/transpiled/types/bindings.js.map +1 -0
  164. package/transpiled/types/bridges.d.ts +41 -0
  165. package/transpiled/types/bridges.js +2 -0
  166. package/transpiled/types/bridges.js.map +1 -0
  167. package/transpiled/types/extensions.d.ts +121 -0
  168. package/transpiled/types/extensions.js +2 -0
  169. package/transpiled/types/extensions.js.map +1 -0
  170. package/transpiled/types/inbox.d.ts +27 -0
  171. package/transpiled/types/inbox.js +2 -0
  172. package/transpiled/types/inbox.js.map +1 -0
  173. package/transpiled/types/index.d.ts +14 -0
  174. package/transpiled/types/index.js +9 -0
  175. package/transpiled/types/index.js.map +1 -0
  176. package/transpiled/types/message.d.ts +16 -0
  177. package/transpiled/types/message.js +2 -0
  178. package/transpiled/types/message.js.map +1 -0
  179. package/transpiled/types/operations.d.ts +15 -0
  180. package/transpiled/types/operations.js +2 -0
  181. package/transpiled/types/operations.js.map +1 -0
  182. package/transpiled/types/outbox.d.ts +93 -0
  183. package/transpiled/types/outbox.js +2 -0
  184. package/transpiled/types/outbox.js.map +1 -0
  185. package/transpiled/types/receiver.d.ts +9 -0
  186. package/transpiled/types/receiver.js +2 -0
  187. package/transpiled/types/receiver.js.map +1 -0
  188. package/transpiled/types/request.d.ts +119 -0
  189. package/transpiled/types/request.js +2 -0
  190. package/transpiled/types/request.js.map +1 -0
  191. package/transpiled/types/state.d.ts +9 -0
  192. package/transpiled/types/state.js +2 -0
  193. package/transpiled/types/state.js.map +1 -0
  194. package/transpiled/types/storages.d.ts +158 -0
  195. package/transpiled/types/storages.js +2 -0
  196. package/transpiled/types/storages.js.map +1 -0
  197. package/transpiled/unmanaged.d.ts +5 -0
  198. package/transpiled/unmanaged.js +7 -0
  199. package/transpiled/unmanaged.js.map +1 -0
  200. package/src/assignment.js +0 -31
  201. package/src/call.js +0 -42
  202. package/src/cascade.js +0 -35
  203. package/src/component.js +0 -41
  204. package/src/composition.js +0 -25
  205. package/src/connector.js +0 -183
  206. package/src/context.js +0 -55
  207. package/src/contract/conditions.js +0 -21
  208. package/src/contract/index.js +0 -7
  209. package/src/contract/reply.js +0 -25
  210. package/src/contract/request.js +0 -67
  211. package/src/contract/schemas/error.yaml +0 -9
  212. package/src/contract/schemas/index.js +0 -7
  213. package/src/contract/schemas/query.yaml +0 -30
  214. package/src/discovery.js +0 -44
  215. package/src/emission.js +0 -23
  216. package/src/entities/changeset.js +0 -38
  217. package/src/entities/entity.js +0 -74
  218. package/src/entities/factory.js +0 -33
  219. package/src/entities/index.js +0 -5
  220. package/src/entities/set.js +0 -15
  221. package/src/event.js +0 -40
  222. package/src/exceptions.js +0 -100
  223. package/src/exposition.js +0 -27
  224. package/src/index.js +0 -47
  225. package/src/locator.js +0 -54
  226. package/src/observation.js +0 -20
  227. package/src/operation.js +0 -69
  228. package/src/query/criteria.js +0 -41
  229. package/src/query/options.js +0 -40
  230. package/src/query.js +0 -41
  231. package/src/receiver.js +0 -61
  232. package/src/reflection.js +0 -28
  233. package/src/remote.js +0 -17
  234. package/src/state.js +0 -99
  235. package/src/transition.js +0 -67
  236. package/src/transmission.js +0 -33
  237. package/test/call.fixtures.js +0 -27
  238. package/test/call.test.js +0 -46
  239. package/test/component.fixtures.js +0 -21
  240. package/test/component.test.js +0 -40
  241. package/test/connector.fixtures.js +0 -40
  242. package/test/connector.test.js +0 -176
  243. package/test/context.fixtures.js +0 -18
  244. package/test/context.test.js +0 -29
  245. package/test/contract/conditions.test.js +0 -26
  246. package/test/contract/contract.fixtures.js +0 -33
  247. package/test/contract/request.test.js +0 -112
  248. package/test/emission.fixtures.js +0 -17
  249. package/test/emission.test.js +0 -35
  250. package/test/entities/entity.fixtures.js +0 -29
  251. package/test/entities/entity.test.js +0 -65
  252. package/test/entities/factory.fixtures.js +0 -18
  253. package/test/entities/factory.test.js +0 -48
  254. package/test/entities/set.fixtures.js +0 -11
  255. package/test/entities/set.test.js +0 -12
  256. package/test/event.fixtures.js +0 -29
  257. package/test/event.test.js +0 -118
  258. package/test/locator.test.js +0 -113
  259. package/test/query.fixtures.js +0 -100
  260. package/test/query.test.js +0 -86
  261. package/test/receiver.fixtures.js +0 -23
  262. package/test/receiver.test.js +0 -95
  263. package/test/reflection.test.js +0 -30
  264. package/test/state.fixtures.js +0 -47
  265. package/test/state.test.js +0 -46
  266. package/test/transmission.fixtures.js +0 -15
  267. package/test/transmission.test.js +0 -46
  268. package/types/bindings.d.ts +0 -40
  269. package/types/bridges.ts +0 -30
  270. package/types/component.d.ts +0 -9
  271. package/types/connector.d.ts +0 -18
  272. package/types/context.d.ts +0 -21
  273. package/types/entity.d.ts +0 -46
  274. package/types/event.d.ts +0 -11
  275. package/types/exception.d.ts +0 -4
  276. package/types/extensions.d.ts +0 -29
  277. package/types/index.ts +0 -14
  278. package/types/locator.d.ts +0 -13
  279. package/types/message.d.ts +0 -3
  280. package/types/operations.d.ts +0 -2
  281. package/types/query.d.ts +0 -15
  282. package/types/receiver.d.ts +0 -12
  283. package/types/reflection.d.ts +0 -14
  284. package/types/request.d.ts +0 -23
  285. package/types/state.d.ts +0 -35
  286. package/types/storages.d.ts +0 -71
@@ -0,0 +1,177 @@
1
+ import { parse } from '@rsql/parser';
2
+ import { QuerySyntaxException } from '../exceptions.js';
3
+ export function criteria(expression, properties) {
4
+ let ast;
5
+ try {
6
+ ast = parse(expression);
7
+ }
8
+ catch (e) {
9
+ throw new QuerySyntaxException(e.message);
10
+ }
11
+ // what spells neither word holds neither, and pays nothing for this
12
+ if (expression.includes('null') || expression.includes('undefined'))
13
+ nothing(ast, expression);
14
+ if (properties !== undefined)
15
+ read(ast, properties);
16
+ return ast;
17
+ }
18
+ /**
19
+ * An unquoted `null` or `undefined` is no value, and a quoted one is text. The parser answers
20
+ * both as the text, so which of them was quoted is read from the expression: a value is what
21
+ * follows a comparison operator, or the list in parentheses that does, and the tree holds the
22
+ * values in the order the expression writes them.
23
+ */
24
+ function nothing(ast, expression) {
25
+ const quoted = values(expression);
26
+ let index = 0;
27
+ function resolve(value) {
28
+ return !quoted[index++] && (value === 'null' || value === 'undefined') ? null : value;
29
+ }
30
+ comparisons(ast, (node) => {
31
+ const right = node.right;
32
+ right.value = Array.isArray(right.value) ? right.value.map(resolve) : resolve(right.value);
33
+ const none = Array.isArray(right.value) ? right.value.includes(null) : right.value === null;
34
+ // no value is neither greater nor less than anything, and a storage asked to order by it
35
+ // finds nothing and says nothing
36
+ if (none && !EQUALITY.includes(node.operator))
37
+ throw new QuerySyntaxException(`Criteria selector '${node.left.selector}' compares no value with '${node.operator}'`);
38
+ });
39
+ }
40
+ const EQUALITY = ['==', '!=', '=in=', '=out='];
41
+ function comparisons(node, visit) {
42
+ if (node.type === 'COMPARISON')
43
+ visit(node);
44
+ else if (node.type === 'LOGIC') {
45
+ comparisons(node.left, visit);
46
+ comparisons(node.right, visit);
47
+ }
48
+ }
49
+ /**
50
+ * Whether each value of an expression the parser has accepted is quoted, in the order they are
51
+ * written. Tokens are told apart as the parser's lexer tells them.
52
+ */
53
+ function values(expression) {
54
+ const quoted = [];
55
+ let position = 0;
56
+ let value = false;
57
+ let list = false;
58
+ while (position < expression.length) {
59
+ const char = expression[position];
60
+ if (WHITESPACE.includes(char)) {
61
+ position++;
62
+ }
63
+ else if (char === '"' || char === "'") {
64
+ position = closing(expression, position) + 1;
65
+ if (value)
66
+ quoted.push(true);
67
+ value = list;
68
+ }
69
+ else if (char === '(') {
70
+ position++;
71
+ list = value;
72
+ }
73
+ else if (char === ')') {
74
+ position++;
75
+ list = value = false;
76
+ }
77
+ else if (char === ',' || char === ';') {
78
+ position++;
79
+ }
80
+ else if (OPERATOR_START.includes(char)) {
81
+ OPERATOR.lastIndex = position;
82
+ position = OPERATOR.test(expression) ? OPERATOR.lastIndex : position + 1;
83
+ value = true;
84
+ }
85
+ else {
86
+ position++;
87
+ while (position < expression.length && !RESERVED.includes(expression[position]))
88
+ position++;
89
+ if (value)
90
+ quoted.push(false);
91
+ value = list;
92
+ }
93
+ }
94
+ return quoted;
95
+ }
96
+ /** The quote that closes the one at `position`: the first one not escaped by a backslash. */
97
+ function closing(expression, position) {
98
+ const quote = expression[position];
99
+ let end = position;
100
+ for (;;) {
101
+ end = expression.indexOf(quote, end + 1);
102
+ if (end === -1)
103
+ return expression.length;
104
+ let escaped = false;
105
+ for (let back = end - 1; expression[back] === '\\' && back > position; back--)
106
+ escaped = !escaped;
107
+ if (!escaped)
108
+ return end;
109
+ }
110
+ }
111
+ const WHITESPACE = ' \n\t\r';
112
+ const RESERVED = `"'();,=!~<> \n\t\r`;
113
+ const OPERATOR_START = '=!<>';
114
+ const OPERATOR = /=[a-z]*=|[!<>]=?/y;
115
+ function read(node, properties) {
116
+ if (node.type === 'COMPARISON' &&
117
+ node.left?.type === 'SELECTOR' &&
118
+ node.right?.type === 'VALUE') {
119
+ const selector = node.left.selector;
120
+ const property = properties[selector];
121
+ if (property === undefined) {
122
+ throw new QuerySyntaxException(`Criteria selector '${selector}' is not defined`);
123
+ }
124
+ const cast = CAST[property.type];
125
+ // `=in=` and `=out=` carry a list, and casting that as one value gives whatever
126
+ // a comma-separated string reads as
127
+ // no value is no property's to read
128
+ if (cast !== undefined)
129
+ node.right.value = Array.isArray(node.right.value)
130
+ ? node.right.value.map((value) => value === null ? null : cast(value, selector))
131
+ : node.right.value === null
132
+ ? null
133
+ : cast(node.right.value, selector);
134
+ }
135
+ else {
136
+ if (node.left !== undefined)
137
+ read(node.left, properties);
138
+ if (node.right !== undefined)
139
+ read(node.right, properties);
140
+ }
141
+ }
142
+ /**
143
+ * A criteria arrives as text, so a value is read as what the property it selects on holds. What
144
+ * cannot be read as that is refused rather than passed on: `parseInt` answers `NaN` for a word
145
+ * and `12` for `12kg`, and a storage asked to match either finds nothing and says nothing —
146
+ * a mistyped filter reads as an empty result.
147
+ *
148
+ * A string is left as it came, because every text is one: what a criteria may compare a string
149
+ * to is not the type's to say.
150
+ */
151
+ const CAST = {
152
+ number: (value, selector) => finite(value, selector, 'a number'),
153
+ integer: (value, selector) => {
154
+ const number = finite(value, selector, 'an integer');
155
+ if (!Number.isInteger(number))
156
+ refuse(selector, 'an integer', value);
157
+ return number;
158
+ },
159
+ boolean: (value, selector) => {
160
+ if (value === 'true')
161
+ return true;
162
+ if (value === 'false')
163
+ return false;
164
+ return refuse(selector, 'a boolean', value);
165
+ }
166
+ };
167
+ function finite(value, selector, expected) {
168
+ // `Number` reads a blank string as zero, and a criteria that says nothing says nothing
169
+ const number = value.trim() === '' ? Number.NaN : Number(value);
170
+ if (!Number.isFinite(number))
171
+ refuse(selector, expected, value);
172
+ return number;
173
+ }
174
+ function refuse(selector, expected, value) {
175
+ throw new QuerySyntaxException(`Criteria selector '${selector}' takes ${expected}, and '${value}' is not one`);
176
+ }
177
+ //# sourceMappingURL=criteria.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"criteria.js","sourceRoot":"","sources":["../../source/query/criteria.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAMvD,MAAM,UAAU,QAAQ,CAAC,UAAkB,EAAE,UAAuB;IAClE,IAAI,GAAS,CAAA;IAEb,IAAI,CAAC;QACH,GAAG,GAAG,KAAK,CAAC,UAAU,CAAoB,CAAA;IAC5C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,oBAAoB,CAAE,CAAW,CAAC,OAAO,CAAC,CAAA;IACtD,CAAC;IAED,oEAAoE;IACpE,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC;QAAE,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;IAE7F,IAAI,UAAU,KAAK,SAAS;QAAE,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;IAEnD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED;;;;;GAKG;AACH,SAAS,OAAO,CAAC,GAAS,EAAE,UAAkB;IAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;IACjC,IAAI,KAAK,GAAG,CAAC,CAAA;IAEb,SAAS,OAAO,CAAC,KAAc;QAC7B,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAA;IACvF,CAAC;IAED,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAM,CAAA;QAEz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EAAE,QAAQ,EAAE,EAAE;QAC3B,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAA;QAEpD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;YAAE,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,CAAC,CAAA;QAEpE,OAAO,MAAM,CAAA;IACf,CAAC;IAED,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;QAC3B,IAAI,KAAK,KAAK,MAAM;YAAE,OAAO,IAAI,CAAA;QACjC,IAAI,KAAK,KAAK,OAAO;YAAE,OAAO,KAAK,CAAA;QAEnC,OAAO,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,CAAC,CAAA;IAC7C,CAAC;CACF,CAAA;AAED,SAAS,MAAM,CAAC,KAAa,EAAE,QAAgB,EAAE,QAAgB;IAC/D,uFAAuF;IACvF,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAE/D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA;IAE/D,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,MAAM,CAAC,QAAgB,EAAE,QAAgB,EAAE,KAAa;IAC/D,MAAM,IAAI,oBAAoB,CAC5B,sBAAsB,QAAQ,WAAW,QAAQ,UAAU,KAAK,cAAc,CAC/E,CAAA;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Options } from '../types/storages.ts';
2
+ import type { Properties } from './criteria.ts';
3
+ export declare function options(given: Record<string, any>, properties: Properties): Options;
@@ -0,0 +1,34 @@
1
+ import { QuerySyntaxException } from '../exceptions.js';
2
+ export function options(given, properties) {
3
+ if (given.sort !== undefined)
4
+ given.sort = sort(given.sort, properties);
5
+ if (given.projection !== undefined)
6
+ given.projection = projection(given.projection, properties);
7
+ return given;
8
+ }
9
+ function sort(sort, properties) {
10
+ const result = [];
11
+ for (const sorting of sort) {
12
+ const [property, direction] = sorting.split(':');
13
+ if (properties[property] === undefined)
14
+ throw new QuerySyntaxException(`Sort property '${property}' is not defined`);
15
+ result.push([property, direction ?? 'asc']);
16
+ }
17
+ return result;
18
+ }
19
+ /**
20
+ * A copy, because a route declares one projection and sends it with every request it serves,
21
+ * and the system properties are what every read answers besides.
22
+ */
23
+ function projection(declared, properties) {
24
+ for (const property of declared)
25
+ if (properties[property] === undefined)
26
+ throw new QuerySyntaxException(`Projection property '${property}' is not defined`);
27
+ const projection = declared.slice();
28
+ for (const property of SYSTEM)
29
+ if (!projection.includes(property))
30
+ projection.push(property);
31
+ return projection;
32
+ }
33
+ const SYSTEM = ['VERSION', 'CREATED', 'UPDATED', 'DELETED', 'REGION'];
34
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../source/query/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAIvD,MAAM,UAAU,OAAO,CAAC,KAA0B,EAAE,UAAsB;IACxE,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;IAEvE,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS;QAChC,KAAK,CAAC,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;IAE7D,OAAO,KAAgB,CAAA;AACzB,CAAC;AAED,SAAS,IAAI,CAAC,IAAc,EAAE,UAAsB;IAClD,MAAM,MAAM,GAA4B,EAAE,CAAA;IAE1C,KAAK,MAAM,OAAO,IAAI,IAAI,EAAE,CAAC;QAC3B,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAEhD,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,SAAS;YACpC,MAAM,IAAI,oBAAoB,CAAC,kBAAkB,QAAQ,kBAAkB,CAAC,CAAA;QAE9E,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,SAAS,IAAI,KAAK,CAAC,CAAC,CAAA;IAC7C,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;GAGG;AACH,SAAS,UAAU,CAAC,QAAkB,EAAE,UAAsB;IAC5D,KAAK,MAAM,QAAQ,IAAI,QAAQ;QAC7B,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,SAAS;YACpC,MAAM,IAAI,oBAAoB,CAAC,wBAAwB,QAAQ,kBAAkB,CAAC,CAAA;IAEtF,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAA;IAEnC,KAAK,MAAM,QAAQ,IAAI,MAAM;QAC3B,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAAE,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAE/D,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,MAAM,MAAM,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA"}
@@ -0,0 +1,9 @@
1
+ import type { Properties } from './query/criteria.ts';
2
+ import type { Query as Parsed } from './types/storages.ts';
3
+ import type { Query as Requested } from './types/request.ts';
4
+ /** Translates the query a request carries into the one a storage is given. */
5
+ export declare class Query {
6
+ #private;
7
+ constructor(properties: Properties);
8
+ parse(query: Requested): Parsed;
9
+ }
@@ -0,0 +1,57 @@
1
+ import { empty } from '@toa.io/generic';
2
+ import * as criteria from './query/criteria.js';
3
+ import * as options from './query/options.js';
4
+ const parse = { ...criteria, ...options };
5
+ /** Translates the query a request carries into the one a storage is given. */
6
+ export class Query {
7
+ #properties;
8
+ /** parsed criteria by their expression */
9
+ #asts = new Map();
10
+ constructor(properties) {
11
+ this.#properties = properties;
12
+ }
13
+ parse(query) {
14
+ const result = {};
15
+ const { id, ids, version, criteria, search, ...rest } = query;
16
+ const options = this.#options(rest);
17
+ if (id !== undefined)
18
+ result.id = id;
19
+ if (ids !== undefined)
20
+ result.ids = ids;
21
+ if (version !== undefined)
22
+ result.version = version;
23
+ if (criteria !== undefined)
24
+ result.criteria = this.#criteria(criteria);
25
+ if (search !== undefined)
26
+ result.search = search;
27
+ if (options !== undefined)
28
+ result.options = options;
29
+ return result;
30
+ }
31
+ #options(given) {
32
+ if (empty(given))
33
+ return undefined;
34
+ return parse.options(given, this.#properties);
35
+ }
36
+ /**
37
+ * Lexing an RSQL expression is the most expensive thing this class does, and the same
38
+ * expression arrives over and over: a route builds it from its own declaration and the
39
+ * request parameters. The tree is only read downstream — a storage builds a fresh query
40
+ * from it — so it is kept rather than parsed again.
41
+ *
42
+ * Expressions come from the client, hence the bound. An invalid one throws before it
43
+ * reaches the cache.
44
+ */
45
+ #criteria(criteria) {
46
+ const known = this.#asts.get(criteria);
47
+ if (known !== undefined)
48
+ return known;
49
+ const ast = parse.criteria(criteria, this.#properties);
50
+ if (this.#asts.size >= LIMIT)
51
+ this.#asts.clear();
52
+ this.#asts.set(criteria, ast);
53
+ return ast;
54
+ }
55
+ }
56
+ const LIMIT = 1024;
57
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../source/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAK7C,MAAM,KAAK,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,OAAO,E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C,QAAQ,CAAC,CAAA;QAEtC,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAA;QAErC,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;QAEtD,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK;YAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QAEhD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;QAE7B,OAAO,GAAG,CAAA;IACZ,CAAC;CACF;AAED,MAAM,KAAK,GAAG,IAAI,CAAA"}
@@ -0,0 +1,20 @@
1
+ import { Connector } from './connector.ts';
2
+ import type { Component } from './component.ts';
3
+ import type { Receiver as Bridge } from './types/bridges.ts';
4
+ import type { Message } from './types/message.ts';
5
+ import type { Source } from './types/request.ts';
6
+ export interface Definition {
7
+ conditioned?: boolean;
8
+ adaptive?: boolean;
9
+ operation: string;
10
+ label?: string;
11
+ destination?: string;
12
+ arguments?: unknown[];
13
+ origin?: Source;
14
+ }
15
+ export declare class Receiver extends Connector {
16
+ #private;
17
+ constructor(definition: Definition, local: Component, bridge?: Bridge);
18
+ /** @hot */
19
+ receive(message: Message): Promise<void>;
20
+ }
@@ -0,0 +1,113 @@
1
+ import { console, decode, run } from 'openspan';
2
+ import { add } from '@toa.io/generic';
3
+ import { Connector } from './connector.js';
4
+ import * as trail from './trail.js';
5
+ export class Receiver extends Connector {
6
+ #conditioned;
7
+ #adaptive;
8
+ #endpoint;
9
+ #label;
10
+ #destination;
11
+ #arguments;
12
+ #origin;
13
+ #local;
14
+ #bridge;
15
+ #delivery;
16
+ #processing;
17
+ constructor(definition, local, bridge) {
18
+ super();
19
+ const { conditioned, adaptive, operation } = definition;
20
+ this.#conditioned = conditioned;
21
+ this.#adaptive = adaptive;
22
+ this.#endpoint = operation;
23
+ this.#label = definition.label ?? operation;
24
+ this.#destination = definition.destination ?? this.#label;
25
+ this.#arguments = definition.arguments;
26
+ this.#origin = definition.origin;
27
+ this.#local = local;
28
+ this.#bridge = bridge;
29
+ this.depends(local);
30
+ if (bridge !== undefined)
31
+ this.depends(bridge);
32
+ /*
33
+ * The delivery span is created on behalf of the messaging destination, so that
34
+ * each consumer forms its own complete producer/consumer pair, and service graphs
35
+ * display fan-out correctly: producer -> destination -> each consumer
36
+ * (Tempo pairs spans one-to-one, thus multiple consumers can not pair
37
+ * with a single producer span, see grafana/tempo#5408)
38
+ */
39
+ this.#delivery = {
40
+ name: `${this.#label} deliver`,
41
+ kind: 'producer',
42
+ service: this.#destination,
43
+ attributes: { 'messaging.destination.name': this.#destination }
44
+ };
45
+ this.#processing = {
46
+ name: `${this.#label} process`,
47
+ kind: 'consumer',
48
+ service: local.locator.id,
49
+ attributes: { 'messaging.destination.name': this.#destination }
50
+ };
51
+ }
52
+ /** @hot */
53
+ async receive(message) {
54
+ /*
55
+ * `trail` is taken out by name rather than left to `add`, which leaves an array the
56
+ * request already has alone and shares the deserialized one by reference where it does
57
+ * not — and validates neither.
58
+ */
59
+ const { payload, telemetry, id, trail: inbound, ...extensions } = message;
60
+ if (this.#conditioned === true && (await this.#bridge?.condition(payload)) === false)
61
+ return;
62
+ const request = await this.#request(payload);
63
+ add(request, extensions);
64
+ // set after `add`, so that a message field can not spoof the origin
65
+ if (this.#origin !== undefined)
66
+ request.source = this.#origin;
67
+ /*
68
+ * The message's identity is the request's. Not derived any further: a component declares at
69
+ * most one receiver per event, so two of its own cannot collide, and two components have
70
+ * collections of their own. A message from before this existed carries none, and the call
71
+ * this makes mints one — which is to say it is not deduplicated, as it is not today.
72
+ */
73
+ if (id !== undefined)
74
+ request.id = id;
75
+ /*
76
+ * The event is a hop of its own. What an operator rewires to break a cycle is the
77
+ * subscription rather than the operation, so a chain that named only operations would not
78
+ * say how a component was re-entered. Refusing is left to `Component.invoke`, one hop
79
+ * later, which acquires and commits nothing before it.
80
+ */
81
+ request.trail = [...trail.received(inbound), trail.event(this.#destination)];
82
+ // continue the trace from the producer span
83
+ const remote = telemetry === undefined ? null : decode(telemetry);
84
+ const task = async () => {
85
+ await this.#process(request);
86
+ };
87
+ if (remote === null)
88
+ await task();
89
+ else
90
+ await run(remote, task);
91
+ }
92
+ async #process(request) {
93
+ return console.span(this.#delivery, async () => console.span(this.#processing, async () => {
94
+ try {
95
+ await this.#local.invoke(this.#endpoint, request);
96
+ }
97
+ catch (error) {
98
+ console.error('Receiver error', {
99
+ component: this.#local.locator.id,
100
+ endpoint: this.#endpoint,
101
+ error
102
+ });
103
+ throw error;
104
+ }
105
+ }));
106
+ }
107
+ async #request(payload) {
108
+ return this.#adaptive === true
109
+ ? await this.#bridge.request(payload, ...(this.#arguments ?? []))
110
+ : { input: payload };
111
+ }
112
+ }
113
+ //# sourceMappingURL=receiver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receiver.js","sourceRoot":"","sources":["../source/receiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAoB,MAAM,UAAU,CAAA;AACjE,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAgBnC,MAAM,OAAO,QAAS,SAAQ,SAAS;IAC5B,YAAY,CAAqB;IACjC,SAAS,CAAqB;IAC9B,SAAS,CAAQ;IACjB,MAAM,CAAQ;IACd,YAAY,CAAQ;IACpB,UAAU,CAAuB;IACjC,OAAO,CAAoB;IAC3B,MAAM,CAAW;IACjB,OAAO,CAAoB;IAC3B,SAAS,CAAa;IACtB,WAAW,CAAa;IAEjC,YAAmB,UAAsB,EAAE,KAAgB,EAAE,MAAe;QAC1E,KAAK,EAAE,CAAA;QAEP,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,UAAU,CAAA;QA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,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;YACnD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE;oBAC9B,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;oBACjC,QAAQ,EAAE,IAAI,CAAC,SAAS;oBACxB,KAAK;iBACN,CAAC,CAAA;gBAEF,MAAM,KAAK,CAAA;YACb,CAAC;QACH,CAAC,CAAC,CACH,CAAA;IACH,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAe;QAC5B,OAAO,IAAI,CAAC,SAAS,KAAK,IAAI;YAC5B,CAAC,CAAC,MAAM,IAAI,CAAC,OAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;YAClE,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;IACxB,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ import { Connector } from './connector.ts';
2
+ /** What a reflection reads, once, as it connects. */
3
+ export type Source<T = any> = () => Promise<T>;
4
+ export declare class Reflection<T = any> extends Connector {
5
+ #private;
6
+ value: T | undefined;
7
+ constructor(source: Source<T>);
8
+ protected open(): Promise<void>;
9
+ }
@@ -0,0 +1,13 @@
1
+ import { Connector } from './connector.js';
2
+ export class Reflection extends Connector {
3
+ value;
4
+ #source;
5
+ constructor(source) {
6
+ super();
7
+ this.#source = source;
8
+ }
9
+ async open() {
10
+ this.value = await this.#source();
11
+ }
12
+ }
13
+ //# sourceMappingURL=reflection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reflection.js","sourceRoot":"","sources":["../source/reflection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAK1C,MAAM,OAAO,UAAoB,SAAQ,SAAS;IACzC,KAAK,CAAe;IAElB,OAAO,CAAW;IAE3B,YAAmB,MAAiB;QAClC,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;IACvB,CAAC;IAEkB,KAAK,CAAC,IAAI;QAC3B,IAAI,CAAC,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;IACnC,CAAC;CACF"}
@@ -0,0 +1,22 @@
1
+ import type { Destination, Regional as Declaration, Row } from './types/outbox.ts';
2
+ /**
3
+ * The component's regional destinations, as a carrier is given them. The carrier puts what they
4
+ * export beside what it carries and hands it back where it arrives; which destination a part is
5
+ * for, and what it holds, is theirs.
6
+ */
7
+ export declare class Regional implements Declaration {
8
+ #private;
9
+ constructor(destinations: Destination[]);
10
+ /** Whether a destination writes to something each region keeps for itself. */
11
+ static is(destination: Destination): boolean;
12
+ /**
13
+ * One destination failing to say what it would write takes out its own part and nothing else:
14
+ * the carrier carries state, and state is not held back by what the others write beside it.
15
+ */
16
+ export(row: Row): Promise<Record<string, unknown> | undefined>;
17
+ /**
18
+ * What fails, fails the import: the change is delivered again, and imported again. Not before
19
+ * every part has landed or failed, so that nothing is still being written when it is.
20
+ */
21
+ import(carried: Record<string, unknown>): Promise<void>;
22
+ }
@@ -0,0 +1,55 @@
1
+ import { console } from 'openspan';
2
+ /**
3
+ * The component's regional destinations, as a carrier is given them. The carrier puts what they
4
+ * export beside what it carries and hands it back where it arrives; which destination a part is
5
+ * for, and what it holds, is theirs.
6
+ */
7
+ export class Regional {
8
+ #destinations;
9
+ constructor(destinations) {
10
+ this.#destinations = new Map(destinations.map((destination) => [destination.name, destination]));
11
+ }
12
+ /** Whether a destination writes to something each region keeps for itself. */
13
+ static is(destination) {
14
+ return destination.export !== undefined && destination.import !== undefined;
15
+ }
16
+ /**
17
+ * One destination failing to say what it would write takes out its own part and nothing else:
18
+ * the carrier carries state, and state is not held back by what the others write beside it.
19
+ */
20
+ async export(row) {
21
+ const exports = [...this.#destinations].map(async ([name, destination]) => {
22
+ try {
23
+ return [name, await destination.export(row)];
24
+ }
25
+ catch (error) {
26
+ console.error('Regional export failed', {
27
+ row: row.id,
28
+ destination: name,
29
+ message: error?.message
30
+ });
31
+ return [name, undefined];
32
+ }
33
+ });
34
+ const parts = (await Promise.all(exports)).filter(([, part]) => part !== undefined);
35
+ return parts.length === 0 ? undefined : Object.fromEntries(parts);
36
+ }
37
+ /**
38
+ * What fails, fails the import: the change is delivered again, and imported again. Not before
39
+ * every part has landed or failed, so that nothing is still being written when it is.
40
+ */
41
+ async import(carried) {
42
+ const imports = Object.entries(carried).map(async ([name, part]) => {
43
+ const destination = this.#destinations.get(name);
44
+ if (destination === undefined) {
45
+ console.debug('Regional import has no destination', { destination: name });
46
+ return;
47
+ }
48
+ await destination.import(part);
49
+ });
50
+ const failed = (await Promise.allSettled(imports)).find((outcome) => outcome.status === 'rejected');
51
+ if (failed !== undefined)
52
+ throw failed.reason;
53
+ }
54
+ }
55
+ //# sourceMappingURL=regional.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regional.js","sourceRoot":"","sources":["../source/regional.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAGlC;;;;GAIG;AACH,MAAM,OAAO,QAAQ;IACV,aAAa,CAA0B;IAEhD,YAAmB,YAA2B;QAC5C,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,CAC1B,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CACnE,CAAA;IACH,CAAC;IAED,8EAA8E;IACvE,MAAM,CAAC,EAAE,CAAC,WAAwB;QACvC,OAAO,WAAW,CAAC,MAAM,KAAK,SAAS,IAAI,WAAW,CAAC,MAAM,KAAK,SAAS,CAAA;IAC7E,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,MAAM,CAAC,GAAQ;QAC1B,MAAM,OAAO,GAAG,CAAC,GAAG,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AW,CAAC,MAAO,CAAC,IAAI,CAAC,CAAA;QACjC,CAAC,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,CAAC,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CACrD,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,UAAU,CAC3C,CAAA;QAED,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,MAAM,CAAC,MAAM,CAAA;IAC/C,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ import { Component } from './component.ts';
2
+ import type { Invocable } from './component.ts';
3
+ /** A call knows what its endpoint declares, which is what an explanation is read from. */
4
+ export interface Explicable extends Invocable {
5
+ explain(): any;
6
+ }
7
+ export declare class Remote extends Component<Explicable> {
8
+ protected kind: 'client';
9
+ explain(endpoint: string): any;
10
+ }
@@ -0,0 +1,11 @@
1
+ import { Component } from './component.js';
2
+ import { EndpointException } from './exceptions.js';
3
+ export class Remote extends Component {
4
+ kind = 'client';
5
+ explain(endpoint) {
6
+ if (!(endpoint in this.operations))
7
+ throw new EndpointException(`'${endpoint}' is not provided by '${this.locator.id}'`);
8
+ return this.operations[endpoint].explain();
9
+ }
10
+ }
11
+ //# sourceMappingURL=remote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote.js","sourceRoot":"","sources":["../source/remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAQnD,MAAM,OAAO,MAAO,SAAQ,SAAqB;IAC5B,IAAI,GAAG,QAAiB,CAAA;IAEpC,OAAO,CAAC,QAAgB;QAC7B,IAAI,CAAC,CAAC,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC;YAChC,MAAM,IAAI,iBAAiB,CAAC,IAAI,QAAQ,yBAAyB,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAA;QAEtF,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAA;IAC5C,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ import { Connector } from './connector.ts';
2
+ import type { Event, Raised } from './event.ts';
3
+ import type { Rendering as Declaration, Row } from './types/outbox.ts';
4
+ /**
5
+ * The component's events, rendered for a destination that writes them somewhere of its own. The
6
+ * condition and the payload are the component's, as they are for the events it publishes, so
7
+ * what the destination writes is what a receiver of the event would have received.
8
+ */
9
+ export declare class Rendering extends Connector implements Declaration {
10
+ #private;
11
+ constructor(events: Map<string, Event>);
12
+ render(label: string, row: Row): Promise<Raised | null>;
13
+ }
@@ -0,0 +1,21 @@
1
+ import { Connector } from './connector.js';
2
+ /**
3
+ * The component's events, rendered for a destination that writes them somewhere of its own. The
4
+ * condition and the payload are the component's, as they are for the events it publishes, so
5
+ * what the destination writes is what a receiver of the event would have received.
6
+ */
7
+ export class Rendering extends Connector {
8
+ #events;
9
+ constructor(events) {
10
+ super();
11
+ this.#events = events;
12
+ this.depends([...events.values()]);
13
+ }
14
+ async render(label, row) {
15
+ const event = this.#events.get(label);
16
+ if (event === undefined)
17
+ throw new Error(`Event '${label}' is not rendered`);
18
+ return await event.render(row);
19
+ }
20
+ }
21
+ //# sourceMappingURL=rendering.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rendering.js","sourceRoot":"","sources":["../source/rendering.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAI1C;;;;GAIG;AACH,MAAM,OAAO,SAAU,SAAQ,SAAS;IAC7B,OAAO,CAAoB;IAEpC,YAAmB,MAA0B;QAC3C,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;QAErB,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IACpC,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,KAAa,EAAE,GAAQ;QACzC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAErC,IAAI,KAAK,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,UAAU,KAAK,mBAAmB,CAAC,CAAA;QAE5E,OAAO,MAAM,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAChC,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Takes a `string` because it comes off a manifest: an operation of a type this does not know is
3
+ * unsafe, which is what an endpoint nothing can classify has to be.
4
+ */
5
+ export declare function safe(type: string): boolean;