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

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 (283) 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 +15 -0
  15. package/transpiled/component.js +148 -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 +44 -0
  93. package/transpiled/index.js +36 -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 +73 -0
  108. package/transpiled/operation.js +213 -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/remote.d.ts +10 -0
  135. package/transpiled/remote.js +11 -0
  136. package/transpiled/remote.js.map +1 -0
  137. package/transpiled/rendering.d.ts +13 -0
  138. package/transpiled/rendering.js +21 -0
  139. package/transpiled/rendering.js.map +1 -0
  140. package/transpiled/safety.d.ts +5 -0
  141. package/transpiled/safety.js +26 -0
  142. package/transpiled/safety.js.map +1 -0
  143. package/transpiled/state.d.ts +36 -0
  144. package/transpiled/state.js +131 -0
  145. package/transpiled/state.js.map +1 -0
  146. package/transpiled/trail.d.ts +78 -0
  147. package/transpiled/trail.js +112 -0
  148. package/transpiled/trail.js.map +1 -0
  149. package/transpiled/transition.d.ts +14 -0
  150. package/transpiled/transition.js +51 -0
  151. package/transpiled/transition.js.map +1 -0
  152. package/transpiled/transmission.d.ts +8 -0
  153. package/transpiled/transmission.js +30 -0
  154. package/transpiled/transmission.js.map +1 -0
  155. package/transpiled/types/atomicity.d.ts +58 -0
  156. package/transpiled/types/atomicity.js +2 -0
  157. package/transpiled/types/atomicity.js.map +1 -0
  158. package/transpiled/types/bindings.d.ts +82 -0
  159. package/transpiled/types/bindings.js +2 -0
  160. package/transpiled/types/bindings.js.map +1 -0
  161. package/transpiled/types/bridges.d.ts +41 -0
  162. package/transpiled/types/bridges.js +2 -0
  163. package/transpiled/types/bridges.js.map +1 -0
  164. package/transpiled/types/extensions.d.ts +121 -0
  165. package/transpiled/types/extensions.js +2 -0
  166. package/transpiled/types/extensions.js.map +1 -0
  167. package/transpiled/types/inbox.d.ts +27 -0
  168. package/transpiled/types/inbox.js +2 -0
  169. package/transpiled/types/inbox.js.map +1 -0
  170. package/transpiled/types/index.d.ts +14 -0
  171. package/transpiled/types/index.js +9 -0
  172. package/transpiled/types/index.js.map +1 -0
  173. package/transpiled/types/message.d.ts +16 -0
  174. package/transpiled/types/message.js +2 -0
  175. package/transpiled/types/message.js.map +1 -0
  176. package/transpiled/types/operations.d.ts +15 -0
  177. package/transpiled/types/operations.js +2 -0
  178. package/transpiled/types/operations.js.map +1 -0
  179. package/transpiled/types/outbox.d.ts +68 -0
  180. package/transpiled/types/outbox.js +2 -0
  181. package/transpiled/types/outbox.js.map +1 -0
  182. package/transpiled/types/receiver.d.ts +9 -0
  183. package/transpiled/types/receiver.js +2 -0
  184. package/transpiled/types/receiver.js.map +1 -0
  185. package/transpiled/types/request.d.ts +119 -0
  186. package/transpiled/types/request.js +2 -0
  187. package/transpiled/types/request.js.map +1 -0
  188. package/transpiled/types/state.d.ts +9 -0
  189. package/transpiled/types/state.js +2 -0
  190. package/transpiled/types/state.js.map +1 -0
  191. package/transpiled/types/storages.d.ts +154 -0
  192. package/transpiled/types/storages.js +2 -0
  193. package/transpiled/types/storages.js.map +1 -0
  194. package/transpiled/unmanaged.d.ts +5 -0
  195. package/transpiled/unmanaged.js +7 -0
  196. package/transpiled/unmanaged.js.map +1 -0
  197. package/src/assignment.js +0 -31
  198. package/src/call.js +0 -42
  199. package/src/cascade.js +0 -35
  200. package/src/component.js +0 -41
  201. package/src/composition.js +0 -25
  202. package/src/connector.js +0 -183
  203. package/src/context.js +0 -55
  204. package/src/contract/conditions.js +0 -21
  205. package/src/contract/index.js +0 -7
  206. package/src/contract/reply.js +0 -25
  207. package/src/contract/request.js +0 -67
  208. package/src/contract/schemas/error.yaml +0 -9
  209. package/src/contract/schemas/index.js +0 -7
  210. package/src/contract/schemas/query.yaml +0 -30
  211. package/src/discovery.js +0 -44
  212. package/src/emission.js +0 -23
  213. package/src/entities/changeset.js +0 -38
  214. package/src/entities/entity.js +0 -74
  215. package/src/entities/factory.js +0 -33
  216. package/src/entities/index.js +0 -5
  217. package/src/entities/set.js +0 -15
  218. package/src/event.js +0 -40
  219. package/src/exceptions.js +0 -100
  220. package/src/exposition.js +0 -27
  221. package/src/index.js +0 -47
  222. package/src/locator.js +0 -54
  223. package/src/observation.js +0 -20
  224. package/src/operation.js +0 -69
  225. package/src/query/criteria.js +0 -41
  226. package/src/query/options.js +0 -40
  227. package/src/query.js +0 -41
  228. package/src/receiver.js +0 -61
  229. package/src/reflection.js +0 -28
  230. package/src/remote.js +0 -17
  231. package/src/state.js +0 -99
  232. package/src/transition.js +0 -67
  233. package/src/transmission.js +0 -33
  234. package/test/call.fixtures.js +0 -27
  235. package/test/call.test.js +0 -46
  236. package/test/component.fixtures.js +0 -21
  237. package/test/component.test.js +0 -40
  238. package/test/connector.fixtures.js +0 -40
  239. package/test/connector.test.js +0 -176
  240. package/test/context.fixtures.js +0 -18
  241. package/test/context.test.js +0 -29
  242. package/test/contract/conditions.test.js +0 -26
  243. package/test/contract/contract.fixtures.js +0 -33
  244. package/test/contract/request.test.js +0 -112
  245. package/test/emission.fixtures.js +0 -17
  246. package/test/emission.test.js +0 -35
  247. package/test/entities/entity.fixtures.js +0 -29
  248. package/test/entities/entity.test.js +0 -65
  249. package/test/entities/factory.fixtures.js +0 -18
  250. package/test/entities/factory.test.js +0 -48
  251. package/test/entities/set.fixtures.js +0 -11
  252. package/test/entities/set.test.js +0 -12
  253. package/test/event.fixtures.js +0 -29
  254. package/test/event.test.js +0 -118
  255. package/test/locator.test.js +0 -113
  256. package/test/query.fixtures.js +0 -100
  257. package/test/query.test.js +0 -86
  258. package/test/receiver.fixtures.js +0 -23
  259. package/test/receiver.test.js +0 -95
  260. package/test/reflection.test.js +0 -30
  261. package/test/state.fixtures.js +0 -47
  262. package/test/state.test.js +0 -46
  263. package/test/transmission.fixtures.js +0 -15
  264. package/test/transmission.test.js +0 -46
  265. package/types/bindings.d.ts +0 -40
  266. package/types/bridges.ts +0 -30
  267. package/types/component.d.ts +0 -9
  268. package/types/connector.d.ts +0 -18
  269. package/types/context.d.ts +0 -21
  270. package/types/entity.d.ts +0 -46
  271. package/types/event.d.ts +0 -11
  272. package/types/exception.d.ts +0 -4
  273. package/types/extensions.d.ts +0 -29
  274. package/types/index.ts +0 -14
  275. package/types/locator.d.ts +0 -13
  276. package/types/message.d.ts +0 -3
  277. package/types/operations.d.ts +0 -2
  278. package/types/query.d.ts +0 -15
  279. package/types/receiver.d.ts +0 -12
  280. package/types/reflection.d.ts +0 -14
  281. package/types/request.d.ts +0 -23
  282. package/types/state.d.ts +0 -35
  283. package/types/storages.d.ts +0 -71
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bridges.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridges.js","sourceRoot":"","sources":["../../source/types/bridges.ts"],"names":[],"mappings":""}
@@ -0,0 +1,121 @@
1
+ import type { Connector } from '../connector.ts';
2
+ import type { Gate } from '../gate.ts';
3
+ import type { Locator } from '../locator.ts';
4
+ import type { Component } from '../component.ts';
5
+ import type { Contract } from '../contract/component.ts';
6
+ import type { Remote } from '../remote.ts';
7
+ import type { Receiver } from './receiver.ts';
8
+ import type { Context } from '../context.ts';
9
+ import type { Storage } from './storages.ts';
10
+ import type { Broadcast, Emitter, Inbound, Outbound } from './bindings.ts';
11
+ import type { Atom } from './atomicity.ts';
12
+ import type { Source } from './request.ts';
13
+ import type { Destination } from './outbox.ts';
14
+ /**
15
+ * What the process hosting an extension provides to it: the counterpart of a component's
16
+ * context. What is returned is a connector the extension depends on.
17
+ */
18
+ export interface Host {
19
+ /** a component of the context, by locator */
20
+ /**
21
+ * @param contract what the component provides, where the caller has it; absent, what the
22
+ * process's map states.
23
+ */
24
+ remote(locator: Locator, source?: Source, contract?: Contract): Promise<Remote>;
25
+ /** a channel of the messaging binding */
26
+ broadcast<L extends string = string>(channel: string, group?: string): Promise<Broadcast<L>>;
27
+ /** components to run inside the extension's own process */
28
+ composition(paths: string[]): Promise<Connector>;
29
+ /** a consumer of an event of the context, `namespace.component.event` */
30
+ receive(label: string, receiver: Receiver): Promise<Connector>;
31
+ /** what the replicas of one group decide together */
32
+ atom(group: string): Atom;
33
+ /** where this deployment publishes a channel, over the brokers named */
34
+ outbound(binding: string, channel: string, uris: string[]): Promise<Outbound>;
35
+ /** what arrives on a channel under one label */
36
+ inbound(binding: string, channel: string, uris: string[], label: string, sink: Inbound): Promise<Connector>;
37
+ /**
38
+ * A part of this tree a halt takes down and builds again. What is not behind one of these
39
+ * outlives a halt: the readiness probe does, and so does whatever answers on a port the
40
+ * process was already listening on.
41
+ */
42
+ gate(build: () => Promise<Connector>): Gate;
43
+ /**
44
+ * Stops what this process does of its own accord — its gateway, its clocks, its run
45
+ * commands — and holds open everything it has. Nothing closes, so this is reversible.
46
+ */
47
+ quiesce(): Promise<void>;
48
+ /** Undoes a quiesce: the process works again, having been rebuilt by nothing. */
49
+ cancel(): Promise<void>;
50
+ /** Stops this process for `seconds`, then builds it again. */
51
+ stop(seconds: number): void;
52
+ }
53
+ /**
54
+ * `Manifest` is a type parameter rather than an import: `@toa.io/norm` depends on core, so
55
+ * core cannot name its types.
56
+ */
57
+ export interface Factory<Manifest = unknown> {
58
+ /**
59
+ * What the package offers for each declaration it claims beside its main one: a manifest key
60
+ * that resolves to `package#key` is answered by `keys[key]`, and never by this.
61
+ */
62
+ keys?: Record<string, Factory<Manifest>>;
63
+ tenant?(locator: Locator, declaration: any, manifest: Manifest): Connector | Promise<Connector>;
64
+ aspect?(locator: Locator, declaration: any): Aspect | Aspect[];
65
+ /**
66
+ * Where a committed state change of this component goes, beside its own events. Read before
67
+ * the storage is made, because one of these is what gives a component an outbox when it
68
+ * declares no event at all.
69
+ */
70
+ destination?(locator: Locator, declaration: any, manifest: Manifest): Destination | Promise<Destination> | undefined;
71
+ /** what the extension runs as a process of its own; `null` where it is off here */
72
+ service?(): Connector | null | Promise<Connector | null>;
73
+ /**
74
+ * What the extension keeps in every process, whatever that process runs — the counterpart of
75
+ * `tenant` for a process rather than a component. Asked of every extension the process has
76
+ * loaded, and the predefined ones are loaded by every process for this.
77
+ *
78
+ * `null` where the extension keeps nothing here.
79
+ */
80
+ resident?(host: Host): Resident | null | Promise<Resident | null>;
81
+ component?(component: Component): Component;
82
+ context?(context: Context): Context;
83
+ manage?(composition: Connector): Connector;
84
+ storage?(storage: Storage, locator: Locator): Storage;
85
+ emitter?(emitter: Emitter, label: string, locator: Locator): Emitter;
86
+ receiver?(receiver: Receiver, locator: Locator): Receiver;
87
+ }
88
+ /**
89
+ * A connector that lives as long as the process, whatever the process runs.
90
+ *
91
+ * It connects before what the process was built with and goes after it, which is what makes it
92
+ * the place for something that answers for the process rather than for anything in it — the
93
+ * readiness probe is the one this was written for.
94
+ *
95
+ * It outlives a halt. One that must not says so by being a `Host.gate`, which is a connector
96
+ * like any other: the gate stays, what it holds does not.
97
+ */
98
+ export interface Resident extends Connector {
99
+ /** Everything the process was built with has connected. */
100
+ complete?: () => Promise<void>;
101
+ }
102
+ export interface Aspect extends Connector {
103
+ /** the key it takes on the context; a duplicate is a boot error */
104
+ readonly name: string;
105
+ invoke(...args: any[]): any;
106
+ }
107
+ /**
108
+ * What an extension puts on a component's context, as the extension states it. How it is
109
+ * presented there is the bridge's — a bash bridge has no context to put anything on — and
110
+ * what is declared here is the key and what it holds.
111
+ */
112
+ export interface Contribution {
113
+ /** the key on the context */
114
+ name: string;
115
+ /** what the key holds, as TypeScript */
116
+ type?: string;
117
+ /** what `type` names, by the module it comes from */
118
+ imports?: Record<string, string[]>;
119
+ /** a JSON Schema to read the type from instead, where a component states one */
120
+ schema?: object;
121
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=extensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensions.js","sourceRoot":"","sources":["../../source/types/extensions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * What a call was, kept so that the same call arriving again is refused rather than made twice.
3
+ *
4
+ * Everything about it is core's, as the outbox row is: core builds it and hands it to the write,
5
+ * and the storage commits it in the transaction the entity is committed in. Written only for a
6
+ * call that changed something — an operation that refused, or that raised, leaves nothing, and a
7
+ * call that arrives again after one of those is made again and refuses again.
8
+ */
9
+ export interface Call {
10
+ /** the identity of the request, which is the key it is refused on */
11
+ id: string;
12
+ /** what the call answered, so that a duplicate of it is answered rather than refused */
13
+ reply: object;
14
+ /**
15
+ * Seconds the call is remembered, where its operation states them. Absent, the storage keeps
16
+ * it for the deployment's window.
17
+ */
18
+ retention?: number;
19
+ }
20
+ /**
21
+ * The read side of an inbox. What writes a record is the storage's own: it happens inside the
22
+ * transaction the storage opened, which core never reaches into.
23
+ */
24
+ export interface Inbox {
25
+ /** what the call under this identity answered, or `null` where it was never made */
26
+ recall(id: string): Promise<object | null>;
27
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbox.js","sourceRoot":"","sources":["../../source/types/inbox.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ export * as atomicity from './atomicity.ts';
2
+ export * as bindings from './bindings.ts';
3
+ export * as bridges from './bridges.ts';
4
+ export * as extensions from './extensions.ts';
5
+ export * as operations from './operations.ts';
6
+ export * as inbox from './inbox.ts';
7
+ export * as outbox from './outbox.ts';
8
+ export * as storages from './storages.ts';
9
+ export type { Contribution } from './extensions.ts';
10
+ export type { Event } from './state.ts';
11
+ export type { Message } from './message.ts';
12
+ export type { Receiver } from './receiver.ts';
13
+ export type { Call, Guard, Observation, Transition } from './operations.ts';
14
+ export type { Envelope, Maybe, Options, Query, Reply, RemoteError, Request, Source } from './request.ts';
@@ -0,0 +1,9 @@
1
+ export * as atomicity from './atomicity.js';
2
+ export * as bindings from './bindings.js';
3
+ export * as bridges from './bridges.js';
4
+ export * as extensions from './extensions.js';
5
+ export * as operations from './operations.js';
6
+ export * as inbox from './inbox.js';
7
+ export * as outbox from './outbox.js';
8
+ export * as storages from './storages.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA"}
@@ -0,0 +1,16 @@
1
+ export interface Message<T = any> {
2
+ payload: T;
3
+ /**
4
+ * What this message is, so that a receiver's state change happens once however many times it
5
+ * arrives. Derived from the outbox row it was published from, which is committed once, so the
6
+ * immediate path, the pump and a redelivery all carry the one identity.
7
+ */
8
+ id?: string;
9
+ /** W3C traceparent */
10
+ telemetry?: string;
11
+ /**
12
+ * The hops that led to the state change this is about, so a receiver of it continues the
13
+ * chain rather than starting one. See `core/source/trail.ts`.
14
+ */
15
+ trail?: string[];
16
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.js","sourceRoot":"","sources":["../../source/types/message.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import type { Request } from './request.ts';
2
+ export type type = 'transition' | 'observation' | 'assignment' | 'computation' | 'effect' | 'unmanaged';
3
+ export type scope = 'entry' | 'entries' | 'changeset' | 'stream' | 'none';
4
+ /**
5
+ * How an endpoint is called. What it resolves to is what the operation declares — `toa types`
6
+ * writes that per operation, and these are what a hand-written context says instead.
7
+ */
8
+ export type Call<Output = any, Input = any> = (request: Request<Input>) => Promise<Output>;
9
+ export type Observation<Output = any, Input = never, Entity = unknown> = (request: Request<Input, Entity>) => Promise<Output extends unknown[] ? Output : Output | null>;
10
+ export type Transition<Output = any, Input = never, Entity = unknown> = (request: Request<Input, Entity>) => Promise<Output | null>;
11
+ /**
12
+ * Runs on every change to an entity's state, before the contract is applied. `false` refuses
13
+ * the change as `EntityGuard`.
14
+ */
15
+ export type Guard<T, C = unknown> = (state: T, origin: T | null, context: C) => boolean;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.js","sourceRoot":"","sources":["../../source/types/operations.ts"],"names":[],"mappings":""}
@@ -0,0 +1,68 @@
1
+ import type { Connector } from '../connector.ts';
2
+ import type { Event } from './state.ts';
3
+ /**
4
+ * The intent to publish, committed with the state change it belongs to. Everything about it
5
+ * is core's: the storage writes it and, where the images are the write's own, fills
6
+ * `event.origin` and `event.state` in.
7
+ */
8
+ export interface Row {
9
+ id: string;
10
+ /** which replica pumps this row; carries no other meaning, and no ordering */
11
+ lane: number;
12
+ /** settled for every destination */
13
+ published: boolean;
14
+ /** not before this */
15
+ pending: number;
16
+ /** the destinations it has not been sent to yet, by name */
17
+ outstanding: string[];
18
+ /**
19
+ * The hops that led to the change. Written onto the row rather than left in scope, because
20
+ * the pump publishes off the operation's path — possibly in another replica, an hour later.
21
+ * Absent on a row written before this existed, which reads as a chain that starts there.
22
+ */
23
+ trail?: string[];
24
+ /** an assignment's images are absent until the storage fills them in */
25
+ event: Event;
26
+ }
27
+ /**
28
+ * Somewhere a committed state change goes. A component's `Emission` is one, under the name
29
+ * `events`; an extension may contribute others, and each is published and settled on its own,
30
+ * so one that is down delays nothing but itself.
31
+ */
32
+ export interface Destination extends Connector {
33
+ /** what a row is outstanding for, as the row records it */
34
+ readonly name: string;
35
+ /** the row, not its event: what goes on the wire is the chain it carries too */
36
+ emit(row: Row): Promise<void>;
37
+ /**
38
+ * The events of the component this renders a row into, by their labels. A destination that
39
+ * names them is given a `Rendering` of them before it connects: the payload each would be
40
+ * published with, by the component's own condition and payload.
41
+ */
42
+ readonly renders?: string[];
43
+ rendering?: Rendering;
44
+ }
45
+ /** What a row makes of the component's events: the payload of each that it raises. */
46
+ export interface Rendering {
47
+ /** `null` where the event's condition does not hold for the row */
48
+ render(label: string, row: Row): Promise<{
49
+ payload: unknown;
50
+ } | null>;
51
+ }
52
+ /**
53
+ * The read side of an outbox. What writes a row is the storage's own: it happens inside the
54
+ * transaction the storage opened, which core never reaches into.
55
+ */
56
+ export interface Storage {
57
+ /**
58
+ * One page of what is due, not settled for every destination, and in one of the given lanes,
59
+ * in the order the rows were written. `after` continues from the last id of the page before.
60
+ */
61
+ pending(lanes: number[], now: number, limit: number, after?: string): Promise<Row[]>;
62
+ /**
63
+ * Takes `destinations` out of what those rows are outstanding for, and marks published the
64
+ * ones left outstanding for nothing. Several destinations at once, because the ordinary case
65
+ * is all of them landing in one window, and that is then one write.
66
+ */
67
+ settle(ids: string[], destinations: string[]): Promise<void>;
68
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=outbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbox.js","sourceRoot":"","sources":["../../source/types/outbox.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import type { Connector } from '../connector.ts';
2
+ import type { Message } from './message.ts';
3
+ /**
4
+ * What consumes an event of the context. Core ships one, and an extension may put its own
5
+ * in its place, so what a binding is handed is this rather than core's class.
6
+ */
7
+ export interface Receiver extends Connector {
8
+ receive(message: Message): Promise<void>;
9
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=receiver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receiver.js","sourceRoot":"","sources":["../../source/types/receiver.ts"],"names":[],"mappings":""}
@@ -0,0 +1,119 @@
1
+ import type { Exception } from '../exceptions.ts';
2
+ /**
3
+ * What a call asks for. `Entity` is the record it is about, which narrows the projection;
4
+ * left out, any name is accepted.
5
+ */
6
+ export interface Query<Entity = any> {
7
+ id?: string;
8
+ ids?: string[];
9
+ criteria?: string;
10
+ search?: string;
11
+ sample?: number;
12
+ omit?: number;
13
+ limit?: number;
14
+ sort?: string[];
15
+ projection?: Array<string & keyof Entity>;
16
+ version?: number;
17
+ deleted?: boolean;
18
+ token?: string;
19
+ stop?: boolean;
20
+ }
21
+ /** Origin of a call. Stamped by the framework; whoever reads it takes the keys it knows. */
22
+ export type Source = {
23
+ namespace: string;
24
+ component: string;
25
+ operation: string;
26
+ } | {
27
+ namespace: string;
28
+ component: string;
29
+ event: string;
30
+ } | {
31
+ service: string;
32
+ };
33
+ /**
34
+ * What a caller asks for, and what a caller may say about it — the identity of the call, where the
35
+ * caller has one to give, and whatever of the envelope whoever hands it over already knows. A
36
+ * receiver stamps the identity and the chain off the message the call came from.
37
+ */
38
+ export interface Request<Input = any, Entity = any> {
39
+ input?: Input;
40
+ query?: Query<Entity>;
41
+ /** What the operation acquires, where the caller supplies it rather than the storage. */
42
+ entity?: Entity;
43
+ task?: boolean;
44
+ /**
45
+ * The process a call to a stateful operation goes to: that process's `context.instance`. Named
46
+ * for a stateful operation, and for no other.
47
+ */
48
+ instance?: string;
49
+ /**
50
+ * What this call is, so that the same call arriving twice is written once. Left out, the caller
51
+ * stamps one: derived from the call it is itself serving, where there is one, and minted where
52
+ * there is not. See `core/source/entities/newid.ts` and the inbox.
53
+ */
54
+ id?: string;
55
+ source?: Source;
56
+ /**
57
+ * The hops this call passed through, oldest first. Stamped by the framework; a call that has
58
+ * been where it is going already is refused rather than made. See `core/source/trail.ts`.
59
+ */
60
+ trail?: string[];
61
+ /**
62
+ * The properties of the output this caller receives, of each object the operation answers. An
63
+ * empty list receives none of it, and a request that names none receives the output whole.
64
+ */
65
+ output?: string[];
66
+ /**
67
+ * Whether this caller reads an output encoded rather than as values: a gateway writing it as a
68
+ * response body spends nothing on reading it. What answers one encodes it once.
69
+ */
70
+ encoded?: boolean;
71
+ /**
72
+ * Whether this call, and every call made under it, may reach only a safe operation. Stamped by
73
+ * the framework and carried down the chain; set and never cleared, so a call made under one is
74
+ * readonly whatever it says of itself. See `core/source/safety.ts`.
75
+ */
76
+ readonly?: boolean;
77
+ /** the sender validated against the contract, so the recipient does not */
78
+ authentic?: boolean;
79
+ /** W3C traceparent */
80
+ telemetry?: string;
81
+ }
82
+ /**
83
+ * How a caller waits for an addressed call, given beside the request: neither is part of what the
84
+ * call asks, and neither is sent with it. An ordinary call waits for as long as its reply takes, and
85
+ * is refused if it names either.
86
+ */
87
+ export interface Options {
88
+ /** Milliseconds the caller waits for the reply. Without one, the context's default. */
89
+ timeout?: number;
90
+ /** Ends the wait when it aborts, within the timeout. */
91
+ signal?: AbortSignal;
92
+ }
93
+ /**
94
+ * What an operation receives: the request, in the envelope the framework put it in. The one
95
+ * difference from what a caller may hand over is that the identity is settled, which is why an
96
+ * operation may rely on it and a caller need not supply it.
97
+ *
98
+ * The envelope is the framework's own object rather than the caller's written over, because a
99
+ * caller may hand one object to several calls — `id` alone makes that fatal, as two calls cannot
100
+ * share an identity — and because what a caller wrote and what the runtime added are then two
101
+ * things rather than one.
102
+ */
103
+ export interface Envelope<Input = any, Entity = any> extends Request<Input, Entity> {
104
+ id: string;
105
+ }
106
+ /**
107
+ * An error an operation declares and returns. A call resolves to it rather than throwing:
108
+ * only an exception is thrown.
109
+ */
110
+ export interface RemoteError<Code extends string = string> extends Error {
111
+ code: Code;
112
+ }
113
+ /** What an operation returns where it may refuse: the value, or the error it refused with. */
114
+ export type Maybe<T> = T | Error;
115
+ export interface Reply {
116
+ output?: any;
117
+ error?: object;
118
+ exception?: Exception;
119
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../../source/types/request.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ /** What a commit publishes: the images of one state change. */
2
+ export interface Event<State = object, Trailers = object> {
3
+ /** the pre-image; null when the entity did not exist before */
4
+ origin: State | null;
5
+ state: State;
6
+ /** out-of-band values an algorithm wrote into `state.TRAILERS`; must be serializable */
7
+ trailers?: Trailers;
8
+ input?: object;
9
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../source/types/state.ts"],"names":[],"mappings":""}
@@ -0,0 +1,154 @@
1
+ import type { Readable } from 'node:stream';
2
+ import type { Connector } from '../connector.ts';
3
+ import type { Locator } from '../locator.ts';
4
+ import type { Call, Inbox } from './inbox.ts';
5
+ import type { Row, Storage as Outbox } from './outbox.ts';
6
+ /** the RSQL tree `@rsql/parser` produces; a storage translates it into its own dialect */
7
+ export interface Node {
8
+ type: 'LOGIC' | 'COMPARISON' | 'SELECTOR' | 'VALUE';
9
+ left?: Node;
10
+ right?: Node;
11
+ operator?: string;
12
+ selector?: string;
13
+ value?: unknown;
14
+ }
15
+ /** What a storage stores. `id` is the key; the upper-cased names are core's. */
16
+ export interface Record {
17
+ id: string;
18
+ VERSION: number;
19
+ CREATED?: number;
20
+ UPDATED?: number;
21
+ /** a tombstone's timestamp; `null` on a live record */
22
+ DELETED?: number | null;
23
+ /** the rank of the region that last wrote it; `0` where there is one region */
24
+ REGION?: number;
25
+ [key: string]: any;
26
+ }
27
+ /** Everything a request query carried that was not a selector. */
28
+ export interface Options {
29
+ omit?: number;
30
+ limit?: number;
31
+ /** normalised by `query/options.ts` from `'name:asc'` into pairs */
32
+ sort?: Array<[property: string, direction: string]>;
33
+ /** always includes `VERSION`, `CREATED`, `UPDATED`, `DELETED` */
34
+ projection?: string[];
35
+ sample?: number;
36
+ /** include tombstones; without it an observation answers `null` over one */
37
+ deleted?: boolean;
38
+ /** where a stream continues from: the token the one before it ended with */
39
+ token?: string;
40
+ /** a stream read in windows ends its first window with where changes continue from, not deeper */
41
+ stop?: boolean;
42
+ }
43
+ /** What core hands a storage, written by `Query.parse`. */
44
+ export interface Query {
45
+ id?: string;
46
+ /** many identities at once; `State.entries` inits whichever of them are missing */
47
+ ids?: string[];
48
+ version?: number;
49
+ criteria?: Node;
50
+ search?: string;
51
+ options?: Options;
52
+ }
53
+ /**
54
+ * What core requires of a storage. Every member but `outbox` is called unguarded, so a
55
+ * storage that leaves one out throws where an operation needs it — a storage may serve
56
+ * only some scopes, and says so by failing rather than by declaring less.
57
+ */
58
+ export interface Storage extends Connector {
59
+ /** scope `entry` */
60
+ get(query: Query): Promise<Record | null>;
61
+ /** scope `entries` */
62
+ find(query: Query): Promise<Record[]>;
63
+ /**
64
+ * scope `stream`: the parts of the collection the query selects, or of what changed in it since
65
+ * `options.token` — see `parts.ts`. The last part is the token; a stream that ends without it
66
+ * was cut.
67
+ */
68
+ stream(query?: Query): Promise<Readable>;
69
+ /**
70
+ * A transition's commit. `false` is a lost compare-and-swap, not an error. Where `row` is
71
+ * given, it is committed in the same transaction as the record or not at all, and where
72
+ * `call` is, so is that — and an identity already recorded raises `DuplicateCall` instead,
73
+ * having written nothing.
74
+ */
75
+ store(record: Record, row?: Row, call?: Call): Promise<boolean>;
76
+ /** a transition over `objects` */
77
+ massStore(records: Record[], rows?: Row[]): Promise<boolean>;
78
+ /** an assignment; `null` where the query matched nothing */
79
+ upsert(query: Query, changeset: object, row?: Row, call?: Call): Promise<Record | null>;
80
+ /** get-or-create, in one indivisible step */
81
+ ensure(query: Query | undefined, properties: object, record: Record, row?: Row, call?: Call): Promise<Record>;
82
+ /** the driver's own handle, which an unmanaged operation is given as its state */
83
+ readonly raw: unknown;
84
+ /**
85
+ * Present only where a row can be committed atomically with the entity. Its absence is
86
+ * what makes the runtime publish inline, so a storage that cannot do this must not offer
87
+ * it: a row written outside the transaction would be a second write with a crash window
88
+ * in front of it, which is the defect the outbox exists to close.
89
+ */
90
+ readonly outbox?: Outbox;
91
+ /**
92
+ * Present only where a call can be recorded atomically with the entity, and only where a
93
+ * component declares `once`. Unlike the outbox there is no weaker thing to fall back to —
94
+ * a record written outside the transaction guarantees nothing — so a storage that cannot
95
+ * says so through `claims`, and a component that asked for it does not boot.
96
+ */
97
+ readonly inbox?: Inbox;
98
+ /**
99
+ * Whether this storage can record a call at all, which is a property of the storage rather
100
+ * than of the deployment it is pointed at, and so is answerable before it is connected.
101
+ */
102
+ readonly claims?: boolean;
103
+ /**
104
+ * Whether this storage applies `entity.migrations`. Absent is what a storage that does not
105
+ * says, and a component declaring migrations against one is refused at boot rather than
106
+ * starting with a structure nothing has made.
107
+ */
108
+ readonly migrates?: boolean;
109
+ /**
110
+ * Writes `record` as it stands — its `VERSION`, its timestamps, its `REGION` and whatever
111
+ * else it carries — where what it would replace precedes it: a lower `VERSION`, or the same
112
+ * `VERSION` written by a region this one outranks. `false` where it does not: nothing is
113
+ * written, and that is not an error.
114
+ *
115
+ * Both sides of the comparison are on the two records, so this takes nothing else. What it
116
+ * is for is a record that was written somewhere else and has to land here as it was, which
117
+ * is neither a transition nor an assignment: it is not the writer's version to increment,
118
+ * nor its timestamps to set.
119
+ */
120
+ converge?(record: Record): Promise<boolean>;
121
+ /**
122
+ * Whether this storage converges. Absent is what a storage that does not says, and a
123
+ * component of a context that converges stands down rather than running where it would
124
+ * never take a record from another region.
125
+ */
126
+ readonly converges?: boolean;
127
+ }
128
+ /**
129
+ * The subset of a component's entity declaration a storage reads. Structural, so that core
130
+ * names no type of `@toa.io/norm`, which depends on core.
131
+ */
132
+ export interface Entity {
133
+ associated?: boolean;
134
+ custom?: boolean;
135
+ /** in the order they are applied; what a step is belongs to the storage that reads it */
136
+ migrations?: Migration[];
137
+ }
138
+ /**
139
+ * One file of a `migrations` directory, named after it — the component's own, or a prototype's,
140
+ * which every descendant applies to its collection ahead of its own.
141
+ */
142
+ export interface Migration {
143
+ id: string;
144
+ steps: unknown[];
145
+ /** the prototype it is inherited from; absent on the component's own */
146
+ prototype?: string;
147
+ }
148
+ export interface StorageOptions {
149
+ /** whether the component publishes anything, and so needs a place to commit a row */
150
+ outbox?: boolean;
151
+ }
152
+ export interface Factory {
153
+ storage(locator: Locator, entity: Entity, options?: StorageOptions): Storage;
154
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=storages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storages.js","sourceRoot":"","sources":["../../source/types/storages.ts"],"names":[],"mappings":""}