@toa.io/core 1.0.0-alpha.33 → 1.0.0-alpha.332

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 (289) 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 +203 -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 +21 -0
  15. package/transpiled/component.js +159 -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 +34 -0
  24. package/transpiled/context.js +71 -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 +47 -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 +156 -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 +43 -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 +31 -0
  48. package/transpiled/deliveries.js +49 -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 +146 -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 +27 -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 +119 -0
  81. package/transpiled/exceptions.js +230 -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 +86 -0
  108. package/transpiled/operation.js +240 -0
  109. package/transpiled/operation.js.map +1 -0
  110. package/transpiled/outbox.d.ts +45 -0
  111. package/transpiled/outbox.js +450 -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 +3 -0
  120. package/transpiled/query/criteria.js +67 -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 +35 -0
  124. package/transpiled/query/options.js.map +1 -0
  125. package/transpiled/query/property.d.ts +16 -0
  126. package/transpiled/query/property.js +30 -0
  127. package/transpiled/query/property.js.map +1 -0
  128. package/transpiled/query.d.ts +9 -0
  129. package/transpiled/query.js +57 -0
  130. package/transpiled/query.js.map +1 -0
  131. package/transpiled/receiver.d.ts +20 -0
  132. package/transpiled/receiver.js +113 -0
  133. package/transpiled/receiver.js.map +1 -0
  134. package/transpiled/reflection.d.ts +9 -0
  135. package/transpiled/reflection.js +13 -0
  136. package/transpiled/reflection.js.map +1 -0
  137. package/transpiled/regional.d.ts +22 -0
  138. package/transpiled/regional.js +55 -0
  139. package/transpiled/regional.js.map +1 -0
  140. package/transpiled/remote.d.ts +10 -0
  141. package/transpiled/remote.js +11 -0
  142. package/transpiled/remote.js.map +1 -0
  143. package/transpiled/rendering.d.ts +13 -0
  144. package/transpiled/rendering.js +21 -0
  145. package/transpiled/rendering.js.map +1 -0
  146. package/transpiled/safety.d.ts +5 -0
  147. package/transpiled/safety.js +26 -0
  148. package/transpiled/safety.js.map +1 -0
  149. package/transpiled/state.d.ts +36 -0
  150. package/transpiled/state.js +134 -0
  151. package/transpiled/state.js.map +1 -0
  152. package/transpiled/trail.d.ts +84 -0
  153. package/transpiled/trail.js +112 -0
  154. package/transpiled/trail.js.map +1 -0
  155. package/transpiled/transition.d.ts +14 -0
  156. package/transpiled/transition.js +53 -0
  157. package/transpiled/transition.js.map +1 -0
  158. package/transpiled/transmission.d.ts +8 -0
  159. package/transpiled/transmission.js +30 -0
  160. package/transpiled/transmission.js.map +1 -0
  161. package/transpiled/types/atomicity.d.ts +58 -0
  162. package/transpiled/types/atomicity.js +2 -0
  163. package/transpiled/types/atomicity.js.map +1 -0
  164. package/transpiled/types/bindings.d.ts +82 -0
  165. package/transpiled/types/bindings.js +2 -0
  166. package/transpiled/types/bindings.js.map +1 -0
  167. package/transpiled/types/bridges.d.ts +41 -0
  168. package/transpiled/types/bridges.js +2 -0
  169. package/transpiled/types/bridges.js.map +1 -0
  170. package/transpiled/types/extensions.d.ts +121 -0
  171. package/transpiled/types/extensions.js +2 -0
  172. package/transpiled/types/extensions.js.map +1 -0
  173. package/transpiled/types/inbox.d.ts +27 -0
  174. package/transpiled/types/inbox.js +2 -0
  175. package/transpiled/types/inbox.js.map +1 -0
  176. package/transpiled/types/index.d.ts +14 -0
  177. package/transpiled/types/index.js +9 -0
  178. package/transpiled/types/index.js.map +1 -0
  179. package/transpiled/types/message.d.ts +16 -0
  180. package/transpiled/types/message.js +2 -0
  181. package/transpiled/types/message.js.map +1 -0
  182. package/transpiled/types/operations.d.ts +15 -0
  183. package/transpiled/types/operations.js +2 -0
  184. package/transpiled/types/operations.js.map +1 -0
  185. package/transpiled/types/outbox.d.ts +93 -0
  186. package/transpiled/types/outbox.js +2 -0
  187. package/transpiled/types/outbox.js.map +1 -0
  188. package/transpiled/types/receiver.d.ts +9 -0
  189. package/transpiled/types/receiver.js +2 -0
  190. package/transpiled/types/receiver.js.map +1 -0
  191. package/transpiled/types/request.d.ts +123 -0
  192. package/transpiled/types/request.js +2 -0
  193. package/transpiled/types/request.js.map +1 -0
  194. package/transpiled/types/state.d.ts +9 -0
  195. package/transpiled/types/state.js +2 -0
  196. package/transpiled/types/state.js.map +1 -0
  197. package/transpiled/types/storages.d.ts +160 -0
  198. package/transpiled/types/storages.js +2 -0
  199. package/transpiled/types/storages.js.map +1 -0
  200. package/transpiled/unmanaged.d.ts +5 -0
  201. package/transpiled/unmanaged.js +7 -0
  202. package/transpiled/unmanaged.js.map +1 -0
  203. package/src/assignment.js +0 -31
  204. package/src/call.js +0 -42
  205. package/src/cascade.js +0 -35
  206. package/src/component.js +0 -41
  207. package/src/composition.js +0 -25
  208. package/src/connector.js +0 -183
  209. package/src/context.js +0 -55
  210. package/src/contract/conditions.js +0 -21
  211. package/src/contract/index.js +0 -7
  212. package/src/contract/reply.js +0 -25
  213. package/src/contract/request.js +0 -67
  214. package/src/contract/schemas/error.yaml +0 -9
  215. package/src/contract/schemas/index.js +0 -7
  216. package/src/contract/schemas/query.yaml +0 -30
  217. package/src/discovery.js +0 -44
  218. package/src/emission.js +0 -23
  219. package/src/entities/changeset.js +0 -38
  220. package/src/entities/entity.js +0 -74
  221. package/src/entities/factory.js +0 -33
  222. package/src/entities/index.js +0 -5
  223. package/src/entities/set.js +0 -15
  224. package/src/event.js +0 -40
  225. package/src/exceptions.js +0 -100
  226. package/src/exposition.js +0 -27
  227. package/src/index.js +0 -47
  228. package/src/locator.js +0 -54
  229. package/src/observation.js +0 -12
  230. package/src/operation.js +0 -80
  231. package/src/query/criteria.js +0 -41
  232. package/src/query/options.js +0 -40
  233. package/src/query.js +0 -41
  234. package/src/receiver.js +0 -61
  235. package/src/reflection.js +0 -28
  236. package/src/remote.js +0 -17
  237. package/src/state.js +0 -103
  238. package/src/transition.js +0 -67
  239. package/src/transmission.js +0 -33
  240. package/test/call.fixtures.js +0 -27
  241. package/test/call.test.js +0 -46
  242. package/test/component.fixtures.js +0 -21
  243. package/test/component.test.js +0 -40
  244. package/test/connector.fixtures.js +0 -40
  245. package/test/connector.test.js +0 -176
  246. package/test/context.fixtures.js +0 -18
  247. package/test/context.test.js +0 -29
  248. package/test/contract/conditions.test.js +0 -26
  249. package/test/contract/contract.fixtures.js +0 -33
  250. package/test/contract/request.test.js +0 -112
  251. package/test/emission.fixtures.js +0 -17
  252. package/test/emission.test.js +0 -35
  253. package/test/entities/entity.fixtures.js +0 -29
  254. package/test/entities/entity.test.js +0 -65
  255. package/test/entities/factory.fixtures.js +0 -18
  256. package/test/entities/factory.test.js +0 -48
  257. package/test/entities/set.fixtures.js +0 -11
  258. package/test/entities/set.test.js +0 -12
  259. package/test/event.fixtures.js +0 -29
  260. package/test/event.test.js +0 -118
  261. package/test/locator.test.js +0 -113
  262. package/test/query.fixtures.js +0 -100
  263. package/test/query.test.js +0 -86
  264. package/test/receiver.fixtures.js +0 -23
  265. package/test/receiver.test.js +0 -95
  266. package/test/reflection.test.js +0 -30
  267. package/test/state.fixtures.js +0 -47
  268. package/test/state.test.js +0 -46
  269. package/test/transmission.fixtures.js +0 -15
  270. package/test/transmission.test.js +0 -46
  271. package/types/bindings.d.ts +0 -40
  272. package/types/bridges.ts +0 -30
  273. package/types/component.d.ts +0 -9
  274. package/types/connector.d.ts +0 -18
  275. package/types/context.d.ts +0 -21
  276. package/types/entity.d.ts +0 -46
  277. package/types/event.d.ts +0 -11
  278. package/types/exception.d.ts +0 -4
  279. package/types/extensions.d.ts +0 -29
  280. package/types/index.ts +0 -14
  281. package/types/locator.d.ts +0 -13
  282. package/types/message.d.ts +0 -3
  283. package/types/operations.d.ts +0 -2
  284. package/types/query.d.ts +0 -15
  285. package/types/receiver.d.ts +0 -12
  286. package/types/reflection.d.ts +0 -14
  287. package/types/request.d.ts +0 -23
  288. package/types/state.d.ts +0 -35
  289. package/types/storages.d.ts +0 -71
@@ -0,0 +1,35 @@
1
+ import { QuerySyntaxException } from '../exceptions.js';
2
+ import { property as find } from './property.js';
3
+ export function options(given, properties) {
4
+ if (given.sort !== undefined)
5
+ given.sort = sort(given.sort, properties);
6
+ if (given.projection !== undefined)
7
+ given.projection = projection(given.projection, properties);
8
+ return given;
9
+ }
10
+ function sort(sort, properties) {
11
+ const result = [];
12
+ for (const sorting of sort) {
13
+ const [property, direction] = sorting.split(':');
14
+ if (find(properties, property) === undefined)
15
+ throw new QuerySyntaxException(`Sort property '${property}' is not defined`);
16
+ result.push([property, direction ?? 'asc']);
17
+ }
18
+ return result;
19
+ }
20
+ /**
21
+ * A copy, because a route declares one projection and sends it with every request it serves,
22
+ * and the system properties are what every read answers besides.
23
+ */
24
+ function projection(declared, properties) {
25
+ for (const property of declared)
26
+ if (find(properties, property) === undefined)
27
+ throw new QuerySyntaxException(`Projection property '${property}' is not defined`);
28
+ const projection = declared.slice();
29
+ for (const property of SYSTEM)
30
+ if (!projection.includes(property))
31
+ projection.push(property);
32
+ return projection;
33
+ }
34
+ const SYSTEM = ['VERSION', 'CREATED', 'UPDATED', 'DELETED', 'REGION'];
35
+ //# 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;AAC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,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,16 @@
1
+ /** What a component declares about the properties a query may name. */
2
+ export type Properties = Record<string, Property>;
3
+ export interface Property {
4
+ type?: string;
5
+ properties?: Properties;
6
+ items?: Property;
7
+ }
8
+ /**
9
+ * What an entity declares for the property a query names, by its name or by the path to it:
10
+ * `size.volume` is `volume` of the object `size` holds. `undefined` where it declares none.
11
+ *
12
+ * An array is read as what it holds, at the end of a path and on the way: a storage compares
13
+ * a value with each element of one, so `leaves.grams` is `grams` of the objects in `leaves`,
14
+ * and `ranks` takes the value one of its elements may be.
15
+ */
16
+ export declare function property(properties: Properties, path: string): Property | undefined;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * What an entity declares for the property a query names, by its name or by the path to it:
3
+ * `size.volume` is `volume` of the object `size` holds. `undefined` where it declares none.
4
+ *
5
+ * An array is read as what it holds, at the end of a path and on the way: a storage compares
6
+ * a value with each element of one, so `leaves.grams` is `grams` of the objects in `leaves`,
7
+ * and `ranks` takes the value one of its elements may be.
8
+ */
9
+ export function property(properties, path) {
10
+ // a name is a client's to write, and `constructor` is no property of any entity
11
+ if (Object.hasOwn(properties, path))
12
+ return held(properties[path]);
13
+ if (!path.includes('.'))
14
+ return undefined;
15
+ let declared = properties;
16
+ let found;
17
+ for (const name of path.split('.')) {
18
+ if (declared === undefined || !Object.hasOwn(declared, name))
19
+ return undefined;
20
+ found = held(declared[name]);
21
+ declared = found?.type === 'object' ? found.properties : undefined;
22
+ }
23
+ return found;
24
+ }
25
+ function held(property) {
26
+ while (property?.type === 'array' && property.items !== undefined)
27
+ property = property.items;
28
+ return property;
29
+ }
30
+ //# sourceMappingURL=property.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property.js","sourceRoot":"","sources":["../../source/query/property.ts"],"names":[],"mappings":"AASA;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,UAAsB,EAAE,IAAY;IAC3D,gFAAgF;IAChF,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAA;IAElE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAA;IAEzC,IAAI,QAAQ,GAA2B,UAAU,CAAA;IACjD,IAAI,KAA2B,CAAA;IAE/B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC;YAAE,OAAO,SAAS,CAAA;QAE9E,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAA;QAC5B,QAAQ,GAAG,KAAK,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAA;IACpE,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,IAAI,CAAC,QAA8B;IAC1C,OAAO,QAAQ,EAAE,IAAI,KAAK,OAAO,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS;QAC/D,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAA;IAE3B,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Properties } from './query/property.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,O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AE,IAAI,CAAC,WAAW,CAAC,CAAA;IAC/C,CAAC;IAED;;;;;;;;OAQG;IACH,SAAS,CAAC,QAAgB;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,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;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AI,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE,CAC7C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,EAAE;YACxC,IAAI,CAAC;gBACH,MAAM,IAAI,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,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K,SAAS,EAAE,CAAC;gBAC9B,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAA;gBAE1E,OAAM;YACR,CAAC;YAED,MAAM,WAAW,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;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Whether an operation of this type is incapable of changing the State. What a readonly request may
3
+ * reach, and nothing else; see `documentation/readonly.md`.
4
+ *
5
+ * Exhaustive on purpose, as the outcome of an exception code is: a type added later does not
6
+ * compile until it says which it is, because a type nobody classified would otherwise be reachable
7
+ * from a request that promised to read.
8
+ */
9
+ const SAFE = {
10
+ transition: false,
11
+ observation: true,
12
+ assignment: false,
13
+ computation: true,
14
+ // the type for an operation that reaches outside; what it reaches is not the runtime's to read
15
+ effect: false,
16
+ // its scope is the driver's own handle, and the runtime sees nothing it does with one
17
+ unmanaged: false
18
+ };
19
+ /**
20
+ * Takes a `string` because it comes off a manifest: an operation of a type this does not know is
21
+ * unsafe, which is what an endpoint nothing can classify has to be.
22
+ */
23
+ export function safe(type) {
24
+ return SAFE[type] === true;
25
+ }
26
+ //# sourceMappingURL=safety.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safety.js","sourceRoot":"","sources":["../source/safety.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,IAAI,GAA0B;IAClC,UAAU,EAAE,KAAK;IACjB,WAAW,EAAE,IAAI;IACjB,UAAU,EAAE,KAAK;IACjB,WAAW,EAAE,IAAI;IACjB,+FAA+F;IAC/F,MAAM,EAAE,KAAK;IACb,sFAAsF;IACtF,SAAS,EAAE,KAAK;CACjB,CAAA;AAED;;;GAGG;AACH,MAAM,UAAU,IAAI,CAAC,IAAY;IAC/B,OAAO,IAAI,CAAC,IAAY,CAAC,KAAK,IAAI,CAAA;AACpC,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { EntitySet } from './entities/set.ts';
2
+ import type { Readable } from 'node:stream';
3
+ import type { Factory } from './entities/factory.ts';
4
+ import type { Entity } from './entities/entity.ts';
5
+ import type { Changeset } from './entities/changeset.ts';
6
+ import type { Outbox } from './outbox.ts';
7
+ import type { Call } from './types/inbox.ts';
8
+ import type { Query, Record, Storage } from './types/storages.ts';
9
+ /**
10
+ * What an operation acquires and commits. One method per scope a manifest may declare, which
11
+ * is how an operation reaches the one it was declared with.
12
+ */
13
+ export declare class State {
14
+ #private;
15
+ readonly storage: Storage;
16
+ constructor(storage: Storage, entities: Factory, outbox: Outbox | undefined, associated?: boolean);
17
+ init(id?: string): Entity;
18
+ fit(values: object): void;
19
+ /** scope `entry` */
20
+ entry(query: Query, mutable?: boolean): Promise<Entity | null>;
21
+ /** scope `entries` */
22
+ entries(query: Query, mutable?: boolean): Promise<EntitySet>;
23
+ /** scope `stream` */
24
+ stream(query: Query): Promise<Readable>;
25
+ /** scope `changeset` */
26
+ changeset(query: Query): Changeset;
27
+ /** scope `none`: an operation that acquires nothing still asks for its scope */
28
+ none(): null;
29
+ /** get-or-create, in one indivisible step */
30
+ /** what the call under this identity answered, or `null` where it was never made */
31
+ recall(id: string): Promise<object | null>;
32
+ ensure(query: Query | undefined, properties: object, input?: object, call?: Call): Promise<Entity>;
33
+ commit(state: Entity | EntitySet, input?: object, call?: Call): Promise<boolean>;
34
+ massCommit(state: EntitySet, input?: object): Promise<boolean>;
35
+ apply(state: Changeset, input?: object, call?: Call): Promise<Record>;
36
+ }