@cratis/chronicle 6.60.0 → 6.62.0

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 (379) hide show
  1. package/connection/ChronicleConnection.ts +7 -1
  2. package/connection/ChronicleServices.ts +2 -0
  3. package/dist/connection/ChronicleConnection.d.ts +1 -0
  4. package/dist/connection/ChronicleConnection.d.ts.map +1 -1
  5. package/dist/connection/ChronicleConnection.js +6 -2
  6. package/dist/connection/ChronicleConnection.js.map +1 -1
  7. package/dist/connection/ChronicleServices.d.ts +2 -1
  8. package/dist/connection/ChronicleServices.d.ts.map +1 -1
  9. package/dist/eventSequences/EventForEventSourceId.d.ts +21 -1
  10. package/dist/eventSequences/EventForEventSourceId.d.ts.map +1 -1
  11. package/dist/eventSequences/EventSequence.d.ts +9 -0
  12. package/dist/eventSequences/EventSequence.d.ts.map +1 -1
  13. package/dist/eventSequences/EventSequence.js +18 -0
  14. package/dist/eventSequences/EventSequence.js.map +1 -1
  15. package/dist/eventSequences/IEventSequence.d.ts +30 -0
  16. package/dist/eventSequences/IEventSequence.d.ts.map +1 -1
  17. package/dist/imports/EventImport.d.ts +29 -0
  18. package/dist/imports/EventImport.d.ts.map +1 -0
  19. package/dist/imports/EventImport.js +248 -0
  20. package/dist/imports/EventImport.js.map +1 -0
  21. package/dist/imports/EventImportSettings.d.ts +32 -0
  22. package/dist/imports/EventImportSettings.d.ts.map +1 -0
  23. package/dist/imports/EventImportSettings.js +4 -0
  24. package/dist/imports/EventImportSettings.js.map +1 -0
  25. package/dist/imports/IEventImport.d.ts +50 -0
  26. package/dist/imports/IEventImport.d.ts.map +1 -0
  27. package/dist/imports/IEventImport.js +4 -0
  28. package/dist/imports/IEventImport.js.map +1 -0
  29. package/dist/imports/ImportChunkRefused.d.ts +12 -0
  30. package/dist/imports/ImportChunkRefused.d.ts.map +1 -0
  31. package/dist/imports/ImportChunkRefused.js +19 -0
  32. package/dist/imports/ImportChunkRefused.js.map +1 -0
  33. package/dist/imports/ImportCouldNotBegin.d.ts +10 -0
  34. package/dist/imports/ImportCouldNotBegin.d.ts.map +1 -0
  35. package/dist/imports/ImportCouldNotBegin.js +16 -0
  36. package/dist/imports/ImportCouldNotBegin.js.map +1 -0
  37. package/dist/imports/ImportOptions.d.ts +26 -0
  38. package/dist/imports/ImportOptions.d.ts.map +1 -0
  39. package/dist/imports/ImportOptions.js +4 -0
  40. package/dist/imports/ImportOptions.js.map +1 -0
  41. package/dist/imports/ImportProgress.d.ts +20 -0
  42. package/dist/imports/ImportProgress.d.ts.map +1 -0
  43. package/dist/imports/ImportProgress.js +4 -0
  44. package/dist/imports/ImportProgress.js.map +1 -0
  45. package/dist/imports/ImportRejection.d.ts +10 -0
  46. package/dist/imports/ImportRejection.d.ts.map +1 -0
  47. package/dist/imports/ImportRejection.js +4 -0
  48. package/dist/imports/ImportRejection.js.map +1 -0
  49. package/dist/imports/ImportResult.d.ts +30 -0
  50. package/dist/imports/ImportResult.d.ts.map +1 -0
  51. package/dist/imports/ImportResult.js +4 -0
  52. package/dist/imports/ImportResult.js.map +1 -0
  53. package/dist/imports/ImportState.d.ts +18 -0
  54. package/dist/imports/ImportState.d.ts.map +1 -0
  55. package/dist/imports/ImportState.js +21 -0
  56. package/dist/imports/ImportState.js.map +1 -0
  57. package/dist/imports/ImportTarget.d.ts +16 -0
  58. package/dist/imports/ImportTarget.d.ts.map +1 -0
  59. package/dist/imports/ImportTarget.js +4 -0
  60. package/dist/imports/ImportTarget.js.map +1 -0
  61. package/dist/imports/ImportWasAbandoned.d.ts +11 -0
  62. package/dist/imports/ImportWasAbandoned.d.ts.map +1 -0
  63. package/dist/imports/ImportWasAbandoned.js +16 -0
  64. package/dist/imports/ImportWasAbandoned.js.map +1 -0
  65. package/dist/imports/ImportsNotSupported.d.ts +5 -0
  66. package/dist/imports/ImportsNotSupported.d.ts.map +1 -0
  67. package/dist/imports/ImportsNotSupported.js +10 -0
  68. package/dist/imports/ImportsNotSupported.js.map +1 -0
  69. package/dist/imports/OnInvalidEvent.d.ts +8 -0
  70. package/dist/imports/OnInvalidEvent.d.ts.map +1 -0
  71. package/dist/imports/OnInvalidEvent.js +11 -0
  72. package/dist/imports/OnInvalidEvent.js.map +1 -0
  73. package/dist/imports/abortable.d.ts +23 -0
  74. package/dist/imports/abortable.d.ts.map +1 -0
  75. package/dist/imports/abortable.js +60 -0
  76. package/dist/imports/abortable.js.map +1 -0
  77. package/dist/imports/beginEventImport.d.ts +16 -0
  78. package/dist/imports/beginEventImport.d.ts.map +1 -0
  79. package/dist/imports/beginEventImport.js +74 -0
  80. package/dist/imports/beginEventImport.js.map +1 -0
  81. package/dist/imports/for_EventImport/given/a_kernel_import_session.d.ts +144 -0
  82. package/dist/imports/for_EventImport/given/a_kernel_import_session.d.ts.map +1 -0
  83. package/dist/imports/for_EventImport/given/a_kernel_import_session.js +132 -0
  84. package/dist/imports/for_EventImport/given/a_kernel_import_session.js.map +1 -0
  85. package/dist/imports/importEvents.d.ts +13 -0
  86. package/dist/imports/importEvents.d.ts.map +1 -0
  87. package/dist/imports/importEvents.js +35 -0
  88. package/dist/imports/importEvents.js.map +1 -0
  89. package/dist/imports/index.d.ts +12 -0
  90. package/dist/imports/index.d.ts.map +1 -0
  91. package/dist/imports/index.js +9 -0
  92. package/dist/imports/index.js.map +1 -0
  93. package/dist/imports/isTransientImportFailure.d.ts +7 -0
  94. package/dist/imports/isTransientImportFailure.d.ts.map +1 -0
  95. package/dist/imports/isTransientImportFailure.js +13 -0
  96. package/dist/imports/isTransientImportFailure.js.map +1 -0
  97. package/dist/imports/sizeOfImportEvent.d.ts +9 -0
  98. package/dist/imports/sizeOfImportEvent.d.ts.map +1 -0
  99. package/dist/imports/sizeOfImportEvent.js +25 -0
  100. package/dist/imports/sizeOfImportEvent.js.map +1 -0
  101. package/dist/imports/toImportEvent.d.ts +14 -0
  102. package/dist/imports/toImportEvent.d.ts.map +1 -0
  103. package/dist/imports/toImportEvent.js +54 -0
  104. package/dist/imports/toImportEvent.js.map +1 -0
  105. package/dist/imports/toImportProgress.d.ts +9 -0
  106. package/dist/imports/toImportProgress.d.ts.map +1 -0
  107. package/dist/imports/toImportProgress.js +20 -0
  108. package/dist/imports/toImportProgress.js.map +1 -0
  109. package/dist/imports/toImportResult.d.ts +9 -0
  110. package/dist/imports/toImportResult.d.ts.map +1 -0
  111. package/dist/imports/toImportResult.js +33 -0
  112. package/dist/imports/toImportResult.js.map +1 -0
  113. package/dist/index.d.ts +3 -1
  114. package/dist/index.d.ts.map +1 -1
  115. package/dist/index.js +3 -1
  116. package/dist/index.js.map +1 -1
  117. package/dist/observation/index.d.ts +2 -0
  118. package/dist/observation/index.d.ts.map +1 -1
  119. package/dist/observation/index.js +1 -0
  120. package/dist/observation/index.js.map +1 -1
  121. package/dist/projections/ChildrenOrderingNotSupportedByContracts.d.ts +15 -0
  122. package/dist/projections/ChildrenOrderingNotSupportedByContracts.d.ts.map +1 -0
  123. package/dist/projections/ChildrenOrderingNotSupportedByContracts.js +22 -0
  124. package/dist/projections/ChildrenOrderingNotSupportedByContracts.js.map +1 -0
  125. package/dist/projections/InvalidCausedByProperty.d.ts +10 -0
  126. package/dist/projections/InvalidCausedByProperty.d.ts.map +1 -0
  127. package/dist/projections/InvalidCausedByProperty.js +16 -0
  128. package/dist/projections/InvalidCausedByProperty.js.map +1 -0
  129. package/dist/projections/Projections.d.ts.map +1 -1
  130. package/dist/projections/Projections.js +4 -0
  131. package/dist/projections/Projections.js.map +1 -1
  132. package/dist/projections/causedBy.d.ts +15 -0
  133. package/dist/projections/causedBy.d.ts.map +1 -0
  134. package/dist/projections/causedBy.js +24 -0
  135. package/dist/projections/causedBy.js.map +1 -0
  136. package/dist/projections/childrenOrdering.d.ts +38 -0
  137. package/dist/projections/childrenOrdering.d.ts.map +1 -0
  138. package/dist/projections/childrenOrdering.js +37 -0
  139. package/dist/projections/childrenOrdering.js.map +1 -0
  140. package/dist/projections/childrenOrderingSupport.d.ts +14 -0
  141. package/dist/projections/childrenOrderingSupport.d.ts.map +1 -0
  142. package/dist/projections/childrenOrderingSupport.js +37 -0
  143. package/dist/projections/childrenOrderingSupport.js.map +1 -0
  144. package/dist/projections/declarative/AllSetBuilder.d.ts +3 -0
  145. package/dist/projections/declarative/AllSetBuilder.d.ts.map +1 -1
  146. package/dist/projections/declarative/AllSetBuilder.js +6 -0
  147. package/dist/projections/declarative/AllSetBuilder.js.map +1 -1
  148. package/dist/projections/declarative/ChildrenBuilder.d.ts +9 -0
  149. package/dist/projections/declarative/ChildrenBuilder.d.ts.map +1 -1
  150. package/dist/projections/declarative/ChildrenBuilder.js +29 -1
  151. package/dist/projections/declarative/ChildrenBuilder.js.map +1 -1
  152. package/dist/projections/declarative/ChildrenOrderingAlreadyDefined.d.ts +6 -0
  153. package/dist/projections/declarative/ChildrenOrderingAlreadyDefined.d.ts.map +1 -0
  154. package/dist/projections/declarative/ChildrenOrderingAlreadyDefined.js +11 -0
  155. package/dist/projections/declarative/ChildrenOrderingAlreadyDefined.js.map +1 -0
  156. package/dist/projections/declarative/DictionaryKey.d.ts +48 -0
  157. package/dist/projections/declarative/DictionaryKey.d.ts.map +1 -0
  158. package/dist/projections/declarative/DictionaryKey.js +82 -0
  159. package/dist/projections/declarative/DictionaryKey.js.map +1 -0
  160. package/dist/projections/declarative/FromAllBuilder.d.ts +2 -0
  161. package/dist/projections/declarative/FromAllBuilder.d.ts.map +1 -1
  162. package/dist/projections/declarative/FromAllBuilder.js +5 -0
  163. package/dist/projections/declarative/FromAllBuilder.js.map +1 -1
  164. package/dist/projections/declarative/FromBuilder.d.ts +18 -6
  165. package/dist/projections/declarative/FromBuilder.d.ts.map +1 -1
  166. package/dist/projections/declarative/FromBuilder.js +34 -31
  167. package/dist/projections/declarative/FromBuilder.js.map +1 -1
  168. package/dist/projections/declarative/FromEveryBuilder.d.ts +2 -0
  169. package/dist/projections/declarative/FromEveryBuilder.d.ts.map +1 -1
  170. package/dist/projections/declarative/FromEveryBuilder.js +7 -0
  171. package/dist/projections/declarative/FromEveryBuilder.js.map +1 -1
  172. package/dist/projections/declarative/IAllSetBuilder.d.ts +7 -0
  173. package/dist/projections/declarative/IAllSetBuilder.d.ts.map +1 -1
  174. package/dist/projections/declarative/IChildrenBuilder.d.ts +19 -0
  175. package/dist/projections/declarative/IChildrenBuilder.d.ts.map +1 -1
  176. package/dist/projections/declarative/IFromAllBuilder.d.ts +6 -0
  177. package/dist/projections/declarative/IFromAllBuilder.d.ts.map +1 -1
  178. package/dist/projections/declarative/IFromEveryBuilder.d.ts +6 -0
  179. package/dist/projections/declarative/IFromEveryBuilder.d.ts.map +1 -1
  180. package/dist/projections/declarative/IReadModelPropertiesBuilder.d.ts +37 -6
  181. package/dist/projections/declarative/IReadModelPropertiesBuilder.d.ts.map +1 -1
  182. package/dist/projections/declarative/ISetBuilder.d.ts +7 -0
  183. package/dist/projections/declarative/ISetBuilder.d.ts.map +1 -1
  184. package/dist/projections/declarative/InvalidDictionaryKey.d.ts +10 -0
  185. package/dist/projections/declarative/InvalidDictionaryKey.d.ts.map +1 -0
  186. package/dist/projections/declarative/InvalidDictionaryKey.js +16 -0
  187. package/dist/projections/declarative/InvalidDictionaryKey.js.map +1 -0
  188. package/dist/projections/declarative/JoinBuilder.d.ts +18 -6
  189. package/dist/projections/declarative/JoinBuilder.d.ts.map +1 -1
  190. package/dist/projections/declarative/JoinBuilder.js +34 -31
  191. package/dist/projections/declarative/JoinBuilder.js.map +1 -1
  192. package/dist/projections/declarative/ProjectionBuilderCore.d.ts +2 -0
  193. package/dist/projections/declarative/ProjectionBuilderCore.d.ts.map +1 -1
  194. package/dist/projections/declarative/ProjectionBuilderCore.js.map +1 -1
  195. package/dist/projections/declarative/SetBuilder.d.ts +3 -0
  196. package/dist/projections/declarative/SetBuilder.d.ts.map +1 -1
  197. package/dist/projections/declarative/SetBuilder.js +6 -0
  198. package/dist/projections/declarative/SetBuilder.js.map +1 -1
  199. package/dist/projections/declarative/index.d.ts +4 -0
  200. package/dist/projections/declarative/index.d.ts.map +1 -1
  201. package/dist/projections/declarative/index.js +3 -0
  202. package/dist/projections/declarative/index.js.map +1 -1
  203. package/dist/projections/graphs/GraphDefinitionBuilder.d.ts.map +1 -1
  204. package/dist/projections/graphs/GraphDefinitionBuilder.js +7 -4
  205. package/dist/projections/graphs/GraphDefinitionBuilder.js.map +1 -1
  206. package/dist/projections/graphs/GraphMemberMappings.d.ts +1 -0
  207. package/dist/projections/graphs/GraphMemberMappings.d.ts.map +1 -1
  208. package/dist/projections/graphs/GraphMemberMappings.js +10 -5
  209. package/dist/projections/graphs/GraphMemberMappings.js.map +1 -1
  210. package/dist/projections/graphs/SetOnceNotSupportedInGraph.d.ts +13 -0
  211. package/dist/projections/graphs/SetOnceNotSupportedInGraph.d.ts.map +1 -0
  212. package/dist/projections/graphs/SetOnceNotSupportedInGraph.js +18 -0
  213. package/dist/projections/graphs/SetOnceNotSupportedInGraph.js.map +1 -0
  214. package/dist/projections/graphs/index.d.ts +1 -0
  215. package/dist/projections/graphs/index.d.ts.map +1 -1
  216. package/dist/projections/graphs/index.js +1 -0
  217. package/dist/projections/graphs/index.js.map +1 -1
  218. package/dist/projections/index.d.ts +5 -0
  219. package/dist/projections/index.d.ts.map +1 -1
  220. package/dist/projections/index.js +3 -0
  221. package/dist/projections/index.js.map +1 -1
  222. package/dist/projections/modelBound/ConflictingChildrenOrdering.d.ts +10 -0
  223. package/dist/projections/modelBound/ConflictingChildrenOrdering.d.ts.map +1 -0
  224. package/dist/projections/modelBound/ConflictingChildrenOrdering.js +16 -0
  225. package/dist/projections/modelBound/ConflictingChildrenOrdering.js.map +1 -0
  226. package/dist/projections/modelBound/childrenAndNestedBuilder.d.ts +2 -0
  227. package/dist/projections/modelBound/childrenAndNestedBuilder.d.ts.map +1 -1
  228. package/dist/projections/modelBound/childrenAndNestedBuilder.js +9 -5
  229. package/dist/projections/modelBound/childrenAndNestedBuilder.js.map +1 -1
  230. package/dist/projections/modelBound/childrenFrom.d.ts +39 -1
  231. package/dist/projections/modelBound/childrenFrom.d.ts.map +1 -1
  232. package/dist/projections/modelBound/childrenFrom.js +30 -1
  233. package/dist/projections/modelBound/childrenFrom.js.map +1 -1
  234. package/dist/projections/modelBound/index.d.ts +3 -2
  235. package/dist/projections/modelBound/index.d.ts.map +1 -1
  236. package/dist/projections/modelBound/index.js +1 -0
  237. package/dist/projections/modelBound/index.js.map +1 -1
  238. package/dist/projections/modelBound/setFrom.d.ts +26 -0
  239. package/dist/projections/modelBound/setFrom.d.ts.map +1 -1
  240. package/dist/projections/modelBound/setFrom.js +15 -8
  241. package/dist/projections/modelBound/setFrom.js.map +1 -1
  242. package/dist/projections/modelBound/setFromContext.d.ts +23 -1
  243. package/dist/projections/modelBound/setFromContext.d.ts.map +1 -1
  244. package/dist/projections/modelBound/setFromContext.js +20 -2
  245. package/dist/projections/modelBound/setFromContext.js.map +1 -1
  246. package/dist/projections/propertyExpressions.d.ts +9 -0
  247. package/dist/projections/propertyExpressions.d.ts.map +1 -0
  248. package/dist/projections/propertyExpressions.js +13 -0
  249. package/dist/projections/propertyExpressions.js.map +1 -0
  250. package/dist/reducers/Reducers.d.ts.map +1 -1
  251. package/dist/reducers/Reducers.js +2 -1
  252. package/dist/reducers/Reducers.js.map +1 -1
  253. package/dist/testing/BatchPartitionOutcome.d.ts +7 -0
  254. package/dist/testing/BatchPartitionOutcome.d.ts.map +1 -0
  255. package/dist/testing/BatchPartitionOutcome.js +4 -0
  256. package/dist/testing/BatchPartitionOutcome.js.map +1 -0
  257. package/dist/testing/InProcessEventSequence.d.ts +4 -0
  258. package/dist/testing/InProcessEventSequence.d.ts.map +1 -1
  259. package/dist/testing/InProcessEventSequence.js +2 -0
  260. package/dist/testing/InProcessEventSequence.js.map +1 -1
  261. package/dist/testing/ReactorDeliveryResult.d.ts +2 -0
  262. package/dist/testing/ReactorDeliveryResult.d.ts.map +1 -1
  263. package/dist/testing/ReactorScenario.d.ts +46 -10
  264. package/dist/testing/ReactorScenario.d.ts.map +1 -1
  265. package/dist/testing/ReactorScenario.js +120 -29
  266. package/dist/testing/ReactorScenario.js.map +1 -1
  267. package/dist/testing/deliverToBatchMethods.d.ts +35 -0
  268. package/dist/testing/deliverToBatchMethods.d.ts.map +1 -0
  269. package/dist/testing/deliverToBatchMethods.js +55 -0
  270. package/dist/testing/deliverToBatchMethods.js.map +1 -0
  271. package/dist/testing/projections/ProjectionCapabilities.d.ts.map +1 -1
  272. package/dist/testing/projections/ProjectionCapabilities.js +2 -0
  273. package/dist/testing/projections/ProjectionCapabilities.js.map +1 -1
  274. package/dist/testing/projections/ProjectionChildrenCapabilities.d.ts.map +1 -1
  275. package/dist/testing/projections/ProjectionChildrenCapabilities.js +2 -0
  276. package/dist/testing/projections/ProjectionChildrenCapabilities.js.map +1 -1
  277. package/dist/tsconfig.tsbuildinfo +1 -1
  278. package/eventSequences/EventForEventSourceId.ts +25 -1
  279. package/eventSequences/EventSequence.ts +28 -0
  280. package/eventSequences/IEventSequence.ts +33 -0
  281. package/imports/EventImport.ts +263 -0
  282. package/imports/EventImportSettings.ts +46 -0
  283. package/imports/IEventImport.ts +58 -0
  284. package/imports/ImportChunkRefused.ts +15 -0
  285. package/imports/ImportCouldNotBegin.ts +14 -0
  286. package/imports/ImportOptions.ts +36 -0
  287. package/imports/ImportProgress.ts +29 -0
  288. package/imports/ImportRejection.ts +14 -0
  289. package/imports/ImportResult.ts +43 -0
  290. package/imports/ImportState.ts +26 -0
  291. package/imports/ImportTarget.ts +23 -0
  292. package/imports/ImportWasAbandoned.ts +16 -0
  293. package/imports/ImportsNotSupported.ts +10 -0
  294. package/imports/OnInvalidEvent.ts +11 -0
  295. package/imports/abortable.ts +57 -0
  296. package/imports/beginEventImport.ts +85 -0
  297. package/imports/for_EventImport/given/a_kernel_import_session.ts +160 -0
  298. package/imports/for_EventImport/when_a_chunk_fails.spec.ts +65 -0
  299. package/imports/for_EventImport/when_abandoning.spec.ts +52 -0
  300. package/imports/for_EventImport/when_cancelling_with_an_abort_signal.spec.ts +59 -0
  301. package/imports/for_EventImport/when_completing.spec.ts +71 -0
  302. package/imports/for_EventImport/when_cutting_events_into_chunks.spec.ts +70 -0
  303. package/imports/for_EventImport/when_keeping_chunks_in_flight.spec.ts +49 -0
  304. package/imports/for_beginEventImport/when_reattaching.spec.ts +82 -0
  305. package/imports/for_beginEventImport/when_the_kernel_does_not_serve_imports.spec.ts +55 -0
  306. package/imports/for_importEvents/when_importing_in_one_call.spec.ts +99 -0
  307. package/imports/for_toImportEvent/when_converting_an_event.spec.ts +74 -0
  308. package/imports/importEvents.ts +44 -0
  309. package/imports/index.ts +14 -0
  310. package/imports/isTransientImportFailure.ts +15 -0
  311. package/imports/sizeOfImportEvent.ts +25 -0
  312. package/imports/toImportEvent.ts +60 -0
  313. package/imports/toImportProgress.ts +24 -0
  314. package/imports/toImportResult.ts +36 -0
  315. package/index.ts +3 -0
  316. package/observation/index.ts +2 -0
  317. package/package.json +7 -2
  318. package/projections/ChildrenOrderingNotSupportedByContracts.ts +18 -0
  319. package/projections/InvalidCausedByProperty.ts +14 -0
  320. package/projections/Projections.ts +4 -0
  321. package/projections/causedBy.ts +30 -0
  322. package/projections/childrenOrdering.ts +53 -0
  323. package/projections/childrenOrderingSupport.ts +40 -0
  324. package/projections/declarative/AllSetBuilder.ts +7 -0
  325. package/projections/declarative/ChildrenBuilder.ts +34 -1
  326. package/projections/declarative/ChildrenOrderingAlreadyDefined.ts +11 -0
  327. package/projections/declarative/DictionaryKey.ts +88 -0
  328. package/projections/declarative/FromAllBuilder.ts +10 -0
  329. package/projections/declarative/FromBuilder.ts +42 -32
  330. package/projections/declarative/FromEveryBuilder.ts +12 -0
  331. package/projections/declarative/IAllSetBuilder.ts +8 -0
  332. package/projections/declarative/IChildrenBuilder.ts +22 -0
  333. package/projections/declarative/IFromAllBuilder.ts +7 -0
  334. package/projections/declarative/IFromEveryBuilder.ts +7 -0
  335. package/projections/declarative/IReadModelPropertiesBuilder.ts +39 -6
  336. package/projections/declarative/ISetBuilder.ts +8 -0
  337. package/projections/declarative/InvalidDictionaryKey.ts +14 -0
  338. package/projections/declarative/JoinBuilder.ts +41 -32
  339. package/projections/declarative/ProjectionBuilderCore.ts +2 -0
  340. package/projections/declarative/SetBuilder.ts +7 -0
  341. package/projections/declarative/for_ChildrenBuilder/when_ordering_children.spec.ts +52 -0
  342. package/projections/declarative/for_FromAllBuilder/when_setting_once.spec.ts +29 -0
  343. package/projections/declarative/for_FromBuilder/when_setting_once.spec.ts +39 -0
  344. package/projections/declarative/for_FromBuilder/when_targeting_dictionary_entries.spec.ts +99 -0
  345. package/projections/declarative/for_JoinBuilder/when_setting_once_and_targeting_dictionary_entries.spec.ts +36 -0
  346. package/projections/declarative/for_SetBuilder/when_setting_to_the_causing_identity.spec.ts +37 -0
  347. package/projections/declarative/index.ts +4 -0
  348. package/projections/for_Graphs/when_building_a_fluent_graph.spec.ts +1 -1
  349. package/projections/for_Graphs/when_building_a_model_bound_graph.spec.ts +5 -4
  350. package/projections/for_Graphs/when_declaring_an_invalid_graph.spec.ts +28 -0
  351. package/projections/for_Graphs/when_declaring_with_standard_decorators.standard.spec.ts +4 -4
  352. package/projections/for_Graphs/when_mapping_properties.spec.ts +1 -1
  353. package/projections/for_Projections/when_registering_ordered_children.spec.ts +66 -0
  354. package/projections/for_childrenOrderingSupport/when_detecting_support_in_the_pinned_contracts.spec.ts +22 -0
  355. package/projections/for_childrenOrderingSupport/when_ensuring_children_ordering_is_supported.spec.ts +35 -0
  356. package/projections/graphs/GraphDefinitionBuilder.ts +7 -4
  357. package/projections/graphs/GraphMemberMappings.ts +8 -5
  358. package/projections/graphs/SetOnceNotSupportedInGraph.ts +18 -0
  359. package/projections/graphs/index.ts +1 -0
  360. package/projections/index.ts +5 -0
  361. package/projections/modelBound/ConflictingChildrenOrdering.ts +14 -0
  362. package/projections/modelBound/childrenAndNestedBuilder.ts +11 -5
  363. package/projections/modelBound/childrenFrom.ts +62 -2
  364. package/projections/modelBound/for_childrenFrom/when_ordering_children.spec.ts +91 -0
  365. package/projections/modelBound/for_setFrom/when_setting_once.spec.ts +52 -0
  366. package/projections/modelBound/index.ts +3 -2
  367. package/projections/modelBound/setFrom.ts +37 -2
  368. package/projections/modelBound/setFromContext.ts +38 -3
  369. package/projections/propertyExpressions.ts +14 -0
  370. package/reducers/Reducers.ts +2 -1
  371. package/testing/BatchPartitionOutcome.ts +10 -0
  372. package/testing/InProcessEventSequence.ts +4 -0
  373. package/testing/ReactorDeliveryResult.ts +2 -0
  374. package/testing/ReactorScenario.ts +147 -39
  375. package/testing/deliverToBatchMethods.ts +90 -0
  376. package/testing/for_ReactorScenario/when_the_reactor_has_a_batch_method.spec.ts +143 -9
  377. package/testing/projections/ProjectionCapabilities.ts +1 -0
  378. package/testing/projections/ProjectionChildrenCapabilities.ts +1 -0
  379. package/testing/projections/for_ProjectionCapabilities/when_rejecting_set_once_dictionary_entries_and_ordered_children.spec.ts +52 -0
@@ -2,25 +2,159 @@
2
2
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
 
4
4
  import { field } from '@cratis/fundamentals';
5
- import { chai, describe, it } from 'vitest';
6
- import { eventType, observes, reactor } from '../../index.js';
7
- import { ReactorScenario, UnsupportedReactorOperation } from '../index.js';
5
+ import { beforeEach, chai, describe, it } from 'vitest';
6
+ import { BatchContext, BatchMethodReturnedAValue, BatchOutcomeKind, EventBatch, eventType, ObservationOrigin, observes, reactor } from '../../index.js';
7
+ import { ReactorScenario } from '../index.js';
8
8
 
9
9
  chai.should();
10
10
 
11
11
  @eventType('scenario-batch-shipment-sent')
12
12
  class ShipmentSent {
13
- @field(String) trackingNumber = '';
13
+ @field(String) trackingNumber: string;
14
+ constructor(trackingNumber = '') { this.trackingNumber = trackingNumber; }
14
15
  }
15
16
 
17
+ @eventType('scenario-batch-shipment-lost')
18
+ class ShipmentLost {
19
+ @field(String) reason: string;
20
+ constructor(reason = '') { this.reason = reason; }
21
+ }
22
+
23
+ @eventType('scenario-batch-shipment-delivered')
24
+ class ShipmentDelivered {
25
+ @field(String) signedBy: string;
26
+ constructor(signedBy = '') { this.signedBy = signedBy; }
27
+ }
28
+
29
+ let batches: { batch: EventBatch; context: BatchContext }[] = [];
30
+ let delivered: string[] = [];
31
+ let failing = '';
32
+ let deferring = '';
33
+ let throwing = false;
34
+
16
35
  @reactor('scenario-batch-shipments')
17
36
  class Shipments {
18
37
  @observes(ShipmentSent)
19
- track() {}
38
+ @observes(ShipmentLost)
39
+ track(batch: EventBatch, context: BatchContext) {
40
+ batches.push({ batch, context });
41
+ if (throwing) throw new Error('tracking service is down');
42
+ if (failing) batch.fail(failing, new Error('unknown carrier'));
43
+ if (deferring) batch.defer(deferring, 1000);
44
+ }
45
+
46
+ shipmentDelivered(event: ShipmentDelivered) {
47
+ delivered.push(event.signedBy);
48
+ }
20
49
  }
21
50
 
22
- describe('when creating a reactor scenario for a reactor with a batch method', () => {
23
- it('should refuse it instead of skipping its events', () =>
24
- (() => new ReactorScenario(Shipments, { artifacts: { eventTypes: [ShipmentSent] }, constraints: 'disabled' }))
25
- .should.throw(UnsupportedReactorOperation, 'reactor.batchMethod'));
51
+ const options = { artifacts: { eventTypes: [ShipmentSent, ShipmentLost, ShipmentDelivered] }, constraints: 'disabled' as const };
52
+
53
+ function reset() {
54
+ batches = [];
55
+ delivered = [];
56
+ failing = '';
57
+ deferring = '';
58
+ throwing = false;
59
+ }
60
+
61
+ describe('when the events of one events call reach a batch method', () => {
62
+ let scenario: ReactorScenario;
63
+ beforeEach(async () => {
64
+ reset();
65
+ scenario = new ReactorScenario(Shipments, options);
66
+ await scenario.when.forEventSource('order-1').events(new ShipmentSent('T-1'), new ShipmentDelivered('Jane'), new ShipmentLost('weather'));
67
+ });
68
+
69
+ it('should call the batch method once', () => batches.length.should.equal(1));
70
+ it('should give it the events it observes, in sequence order', () =>
71
+ batches[0].batch.events.map(event => event.eventType).should.deep.equal([ShipmentSent, ShipmentLost]));
72
+ it('should give it the content of the events', () =>
73
+ (batches[0].batch.ofType(ShipmentSent)[0].event as unknown as ShipmentSent).trackingNumber.should.equal('T-1'));
74
+ it('should describe the page as live', () => batches[0].context.origin.should.equal(ObservationOrigin.Live));
75
+ it('should describe every event of the page', () => batches[0].context.eventCount.should.equal(3));
76
+ it('should allow deferring', () => batches[0].context.canDefer.should.be.true);
77
+ it('should give each event its delivery identity', () => batches[0].batch.events.every(event => event.delivery !== undefined).should.be.true);
78
+ it('should still call the per-event method for the other events', () => delivered.should.deep.equal(['Jane']));
79
+ it('should report every event as handled', () => scenario.results[0].handled.length.should.equal(3));
80
+ it('should report no partition outcomes', () => scenario.partitionOutcomes.should.be.empty);
81
+ });
82
+
83
+ describe('when a page of several event sources reaches a batch method', () => {
84
+ let scenario: ReactorScenario;
85
+ beforeEach(async () => {
86
+ reset();
87
+ scenario = new ReactorScenario(Shipments, options);
88
+ await scenario.given.page(
89
+ { eventSourceId: 'order-1', event: new ShipmentSent('T-1') },
90
+ { eventSourceId: 'order-2', event: new ShipmentSent('T-2') });
91
+ await scenario.when.page(
92
+ { eventSourceId: 'order-3', event: new ShipmentSent('T-3') },
93
+ { eventSourceId: 'order-4', event: new ShipmentLost('customs') },
94
+ { eventSourceId: 'order-3', event: new ShipmentLost('weather') });
95
+ });
96
+
97
+ it('should call the batch method once per page', () => batches.length.should.equal(2));
98
+ it('should give the given page as one batch', () => batches[0].batch.partitions.should.deep.equal(['order-1', 'order-2']));
99
+ it('should give the action page as one batch', () => batches[1].batch.length.should.equal(3));
100
+ it('should list the partitions of the page in order', () => batches[1].context.partitions.should.deep.equal(['order-3', 'order-4']));
101
+ it('should report the partitions of the delivery', () => scenario.results[1].partitions.should.deep.equal(['order-3', 'order-4']));
102
+ });
103
+
104
+ describe('when a batch method fails and defers partitions', () => {
105
+ let scenario: ReactorScenario;
106
+ beforeEach(async () => {
107
+ reset();
108
+ failing = 'order-1';
109
+ deferring = 'order-2';
110
+ scenario = new ReactorScenario(Shipments, options);
111
+ await scenario.when.page(
112
+ { eventSourceId: 'order-1', event: new ShipmentSent('T-1') },
113
+ { eventSourceId: 'order-2', event: new ShipmentSent('T-2') },
114
+ { eventSourceId: 'order-3', event: new ShipmentSent('T-3') });
115
+ });
116
+
117
+ it('should assert the failed partition', () => scenario.shouldHaveFailed('order-1'));
118
+ it('should assert the deferred partition', () => scenario.shouldHaveDeferred('order-2'));
119
+ it('should refuse to assert a partition that succeeded as failed', () =>
120
+ (() => scenario.shouldHaveFailed('order-3')).should.throw(/order-3.*failed 'order-1', deferred 'order-2'/));
121
+ it('should refuse to assert a failed partition as deferred', () => (() => scenario.shouldHaveDeferred('order-1')).should.throw());
122
+ it('should keep the outcomes in the order they were reported', () =>
123
+ scenario.partitionOutcomes.map(outcome => [outcome.partition, outcome.kind, outcome.methodName]).should.deep.equal([
124
+ ['order-1', BatchOutcomeKind.Failed, 'track'], ['order-2', BatchOutcomeKind.Deferred, 'track']]));
125
+ it('should keep the delay of the deferral', () => scenario.partitionOutcomes[1].retryAfterMilliseconds.should.equal(1000));
126
+ it('should keep the error of the failure', () => (scenario.partitionOutcomes[0].error as Error).message.should.equal('unknown carrier'));
127
+ it('should report only the other partition as handled', () =>
128
+ scenario.results[0].handled.map(context => context.eventSourceId).should.deep.equal(['order-3']));
129
+ it('should complete the delivery', () => scenario.results[0].completed.should.be.true);
130
+ it('should offer the outcomes on the assertion view', () => scenario.then.partitionOutcomes.length.should.equal(2));
131
+ });
132
+
133
+ describe('when a batch method throws', () => {
134
+ let scenario: ReactorScenario;
135
+ let error: unknown;
136
+ beforeEach(async () => {
137
+ reset();
138
+ throwing = true;
139
+ scenario = new ReactorScenario(Shipments, options);
140
+ error = await scenario.when.forEventSource('order-1').events(new ShipmentSent('T-1')).catch(caught => caught);
141
+ });
142
+
143
+ it('should reject the call that delivered the events', () => (error as Error).message.should.equal('tracking service is down'));
144
+ it('should report the delivery as not completed', () => scenario.results[0].completed.should.be.false);
145
+ });
146
+
147
+ describe('when a batch method returns a value', () => {
148
+ let error: unknown;
149
+ beforeEach(async () => {
150
+ @reactor('scenario-batch-returning')
151
+ class Returning {
152
+ @observes(ShipmentSent)
153
+ track() { return 'done'; }
154
+ }
155
+ const scenario = new ReactorScenario(Returning, options);
156
+ error = await scenario.when.forEventSource('order-1').events(new ShipmentSent('T-1')).catch(caught => caught);
157
+ });
158
+
159
+ it('should reject the delivery', () => error!.should.be.instanceOf(BatchMethodReturnedAValue));
26
160
  });
@@ -175,6 +175,7 @@ export class ProjectionCapabilities {
175
175
  return;
176
176
  }
177
177
  if (expression === '$null') return;
178
+ if (expression.startsWith('$setOnce(')) fail('set once requires a kernel-backed test');
178
179
  if (expression.startsWith('$eventContext(')) {
179
180
  if (expression === '$eventContext(Occurred)') fail('raw Occurred is converted inconsistently by the kernel; only its Year, Month and Day paths are supported');
180
181
  if (/^\$eventContext\(.+\(\)\)$/.test(expression)) fail('derived event-context functions require a kernel-backed test');
@@ -54,6 +54,7 @@ export class ProjectionChildrenCapabilities {
54
54
  if (Object.keys(child.Nested ?? {}).length) reject(`${base}.Nested`, `nested projections inside children ${kernelBacked}`);
55
55
  if ((child.RemovedWithJoin ?? []).length) reject(`${base}.RemovedWithJoin`, `removedWithJoin inside children ${kernelBacked}`);
56
56
  if (wire.FromEventProperty) reject(`${base}.FromEventProperty`, `value children from an event property ${kernelBacked}`);
57
+ if (wire.Ordering !== undefined) reject(`${base}.Ordering`, `prepended or sorted children ${kernelBacked}`);
57
58
  if (Object.keys(child.All?.Properties ?? {}).length || child.All?.IncludeChildren || (child.All?.AutoMap ?? AutoMap.Inherit) !== AutoMap.Inherit) {
58
59
  reject(`${base}.All`, `fromEvery/all inside children ${kernelBacked}`);
59
60
  }
@@ -0,0 +1,52 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import 'reflect-metadata';
5
+ import { field } from '@cratis/fundamentals';
6
+ import { chai, describe, it } from 'vitest';
7
+ import { eventType } from '../../../events/eventTypeDecorator.js';
8
+ import { DictionaryKey } from '../../../projections/declarative/DictionaryKey.js';
9
+ import { ProjectionCapabilities } from '../ProjectionCapabilities.js';
10
+ import { UnsupportedProjectionOperation } from '../UnsupportedProjectionOperation.js';
11
+ import { Changed } from './given/Changed.js';
12
+ import { compileDeclarative } from './given/compile.js';
13
+
14
+ chai.should();
15
+
16
+ class OrderedChildAdded { itemId!: string; }
17
+ field(String)(OrderedChildAdded.prototype, 'itemId');
18
+ eventType('capability-ordered-child-added')(OrderedChildAdded);
19
+
20
+ describe('when a read-model scenario sets a property once', () => {
21
+ it('should require a kernel-backed test', () => {
22
+ const { compiled, definition } = compileDeclarative(builder => builder.from(Changed, _ => _.setOnce(m => m.name).to(e => e.name)));
23
+ (() => ProjectionCapabilities.validate(compiled, definition)).should.throw(UnsupportedProjectionOperation)
24
+ .with.property('message').that.includes("'$setOnce(name)'").and.includes('set once requires a kernel-backed test');
25
+ });
26
+ });
27
+
28
+ describe('when a read-model scenario targets dictionary entries', () => {
29
+ for (const [name, define] of [
30
+ ['set', (builder: Parameters<Parameters<typeof compileDeclarative>[0]>[0]) => builder.from(Changed, _ => _.set(m => m.details, e => e.name).to(e => e.quantity))],
31
+ ['remove', (builder: Parameters<Parameters<typeof compileDeclarative>[0]>[0]) => builder.from(Changed, _ => _.removeKey(m => m.details, DictionaryKey.causedBy('subject')))]
32
+ ] as const) {
33
+ it(`should require a kernel-backed test to ${name} an entry`, () => {
34
+ const { compiled, definition } = compileDeclarative(define);
35
+ (() => ProjectionCapabilities.validate(compiled, definition)).should.throw(UnsupportedProjectionOperation)
36
+ .with.property('message').that.includes('dynamic or unknown destination paths require a kernel-backed test');
37
+ });
38
+ }
39
+ });
40
+
41
+ describe('when a read-model scenario orders children', () => {
42
+ it('should require a kernel-backed test', () => {
43
+ const { compiled, definition } = compileDeclarative(builder => {
44
+ builder.from(Changed).children<{ lineId: string }>(model => model.labels as never, child => child
45
+ .identifiedBy(line => line.lineId)
46
+ .prepend()
47
+ .from(OrderedChildAdded, from => from.usingKey(event => event.itemId)));
48
+ }, [OrderedChildAdded]);
49
+ (() => ProjectionCapabilities.validate(compiled, definition)).should.throw(UnsupportedProjectionOperation)
50
+ .with.property('message').that.includes('Children.labels.Ordering').and.includes('prepended or sorted children');
51
+ });
52
+ });