@cratis/chronicle 6.59.0 → 6.61.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 (525) hide show
  1. package/ChronicleClient.ts +1 -1
  2. package/ChronicleOptions.ts +11 -0
  3. package/EventStore.ts +9 -1
  4. package/IEventStore.ts +7 -0
  5. package/README.md +1 -1
  6. package/artifacts/DefaultClientArtifactsProvider.ts +13 -1
  7. package/artifacts/IClientArtifactsProvider.ts +6 -0
  8. package/dist/ChronicleClient.js +1 -1
  9. package/dist/ChronicleClient.js.map +1 -1
  10. package/dist/ChronicleOptions.d.ts +7 -0
  11. package/dist/ChronicleOptions.d.ts.map +1 -1
  12. package/dist/ChronicleOptions.js +8 -0
  13. package/dist/ChronicleOptions.js.map +1 -1
  14. package/dist/EventStore.d.ts +3 -1
  15. package/dist/EventStore.d.ts.map +1 -1
  16. package/dist/EventStore.js +7 -1
  17. package/dist/EventStore.js.map +1 -1
  18. package/dist/IEventStore.d.ts +6 -0
  19. package/dist/IEventStore.d.ts.map +1 -1
  20. package/dist/artifacts/DefaultClientArtifactsProvider.d.ts +4 -0
  21. package/dist/artifacts/DefaultClientArtifactsProvider.d.ts.map +1 -1
  22. package/dist/artifacts/DefaultClientArtifactsProvider.js +11 -1
  23. package/dist/artifacts/DefaultClientArtifactsProvider.js.map +1 -1
  24. package/dist/artifacts/IClientArtifactsProvider.d.ts +4 -0
  25. package/dist/artifacts/IClientArtifactsProvider.d.ts.map +1 -1
  26. package/dist/projections/ChildrenOrderingNotSupportedByContracts.d.ts +15 -0
  27. package/dist/projections/ChildrenOrderingNotSupportedByContracts.d.ts.map +1 -0
  28. package/dist/projections/ChildrenOrderingNotSupportedByContracts.js +22 -0
  29. package/dist/projections/ChildrenOrderingNotSupportedByContracts.js.map +1 -0
  30. package/dist/projections/InvalidCausedByProperty.d.ts +10 -0
  31. package/dist/projections/InvalidCausedByProperty.d.ts.map +1 -0
  32. package/dist/projections/InvalidCausedByProperty.js +16 -0
  33. package/dist/projections/InvalidCausedByProperty.js.map +1 -0
  34. package/dist/projections/Projections.d.ts.map +1 -1
  35. package/dist/projections/Projections.js +7 -30
  36. package/dist/projections/Projections.js.map +1 -1
  37. package/dist/projections/causedBy.d.ts +15 -0
  38. package/dist/projections/causedBy.d.ts.map +1 -0
  39. package/dist/projections/causedBy.js +24 -0
  40. package/dist/projections/causedBy.js.map +1 -0
  41. package/dist/projections/childrenOrdering.d.ts +38 -0
  42. package/dist/projections/childrenOrdering.d.ts.map +1 -0
  43. package/dist/projections/childrenOrdering.js +37 -0
  44. package/dist/projections/childrenOrdering.js.map +1 -0
  45. package/dist/projections/childrenOrderingSupport.d.ts +14 -0
  46. package/dist/projections/childrenOrderingSupport.d.ts.map +1 -0
  47. package/dist/projections/childrenOrderingSupport.js +37 -0
  48. package/dist/projections/childrenOrderingSupport.js.map +1 -0
  49. package/dist/projections/declarative/AllSetBuilder.d.ts +3 -0
  50. package/dist/projections/declarative/AllSetBuilder.d.ts.map +1 -1
  51. package/dist/projections/declarative/AllSetBuilder.js +6 -0
  52. package/dist/projections/declarative/AllSetBuilder.js.map +1 -1
  53. package/dist/projections/declarative/ChildrenBuilder.d.ts +9 -0
  54. package/dist/projections/declarative/ChildrenBuilder.d.ts.map +1 -1
  55. package/dist/projections/declarative/ChildrenBuilder.js +29 -1
  56. package/dist/projections/declarative/ChildrenBuilder.js.map +1 -1
  57. package/dist/projections/declarative/ChildrenOrderingAlreadyDefined.d.ts +6 -0
  58. package/dist/projections/declarative/ChildrenOrderingAlreadyDefined.d.ts.map +1 -0
  59. package/dist/projections/declarative/ChildrenOrderingAlreadyDefined.js +11 -0
  60. package/dist/projections/declarative/ChildrenOrderingAlreadyDefined.js.map +1 -0
  61. package/dist/projections/declarative/DictionaryKey.d.ts +48 -0
  62. package/dist/projections/declarative/DictionaryKey.d.ts.map +1 -0
  63. package/dist/projections/declarative/DictionaryKey.js +82 -0
  64. package/dist/projections/declarative/DictionaryKey.js.map +1 -0
  65. package/dist/projections/declarative/FromAllBuilder.d.ts +2 -0
  66. package/dist/projections/declarative/FromAllBuilder.d.ts.map +1 -1
  67. package/dist/projections/declarative/FromAllBuilder.js +5 -0
  68. package/dist/projections/declarative/FromAllBuilder.js.map +1 -1
  69. package/dist/projections/declarative/FromBuilder.d.ts +18 -6
  70. package/dist/projections/declarative/FromBuilder.d.ts.map +1 -1
  71. package/dist/projections/declarative/FromBuilder.js +34 -31
  72. package/dist/projections/declarative/FromBuilder.js.map +1 -1
  73. package/dist/projections/declarative/FromEveryBuilder.d.ts +2 -0
  74. package/dist/projections/declarative/FromEveryBuilder.d.ts.map +1 -1
  75. package/dist/projections/declarative/FromEveryBuilder.js +7 -0
  76. package/dist/projections/declarative/FromEveryBuilder.js.map +1 -1
  77. package/dist/projections/declarative/IAllSetBuilder.d.ts +7 -0
  78. package/dist/projections/declarative/IAllSetBuilder.d.ts.map +1 -1
  79. package/dist/projections/declarative/IChildrenBuilder.d.ts +19 -0
  80. package/dist/projections/declarative/IChildrenBuilder.d.ts.map +1 -1
  81. package/dist/projections/declarative/IFromAllBuilder.d.ts +6 -0
  82. package/dist/projections/declarative/IFromAllBuilder.d.ts.map +1 -1
  83. package/dist/projections/declarative/IFromEveryBuilder.d.ts +6 -0
  84. package/dist/projections/declarative/IFromEveryBuilder.d.ts.map +1 -1
  85. package/dist/projections/declarative/IReadModelPropertiesBuilder.d.ts +37 -6
  86. package/dist/projections/declarative/IReadModelPropertiesBuilder.d.ts.map +1 -1
  87. package/dist/projections/declarative/ISetBuilder.d.ts +7 -0
  88. package/dist/projections/declarative/ISetBuilder.d.ts.map +1 -1
  89. package/dist/projections/declarative/InvalidDictionaryKey.d.ts +10 -0
  90. package/dist/projections/declarative/InvalidDictionaryKey.d.ts.map +1 -0
  91. package/dist/projections/declarative/InvalidDictionaryKey.js +16 -0
  92. package/dist/projections/declarative/InvalidDictionaryKey.js.map +1 -0
  93. package/dist/projections/declarative/JoinBuilder.d.ts +18 -6
  94. package/dist/projections/declarative/JoinBuilder.d.ts.map +1 -1
  95. package/dist/projections/declarative/JoinBuilder.js +34 -31
  96. package/dist/projections/declarative/JoinBuilder.js.map +1 -1
  97. package/dist/projections/declarative/ProjectionBuilderCore.d.ts +2 -0
  98. package/dist/projections/declarative/ProjectionBuilderCore.d.ts.map +1 -1
  99. package/dist/projections/declarative/ProjectionBuilderCore.js.map +1 -1
  100. package/dist/projections/declarative/SetBuilder.d.ts +3 -0
  101. package/dist/projections/declarative/SetBuilder.d.ts.map +1 -1
  102. package/dist/projections/declarative/SetBuilder.js +6 -0
  103. package/dist/projections/declarative/SetBuilder.js.map +1 -1
  104. package/dist/projections/declarative/index.d.ts +4 -0
  105. package/dist/projections/declarative/index.d.ts.map +1 -1
  106. package/dist/projections/declarative/index.js +3 -0
  107. package/dist/projections/declarative/index.js.map +1 -1
  108. package/dist/projections/for_Graphs/given/a_discovered_graph.d.ts +29 -0
  109. package/dist/projections/for_Graphs/given/a_discovered_graph.d.ts.map +1 -0
  110. package/dist/projections/for_Graphs/given/a_discovered_graph.js +19 -0
  111. package/dist/projections/for_Graphs/given/a_discovered_graph.js.map +1 -0
  112. package/dist/projections/for_Graphs/given/a_fake_connection.d.ts +24 -0
  113. package/dist/projections/for_Graphs/given/a_fake_connection.d.ts.map +1 -0
  114. package/dist/projections/for_Graphs/given/a_fake_connection.js +17 -0
  115. package/dist/projections/for_Graphs/given/a_fake_connection.js.map +1 -0
  116. package/dist/projections/for_Graphs/given/organization.d.ts +43 -0
  117. package/dist/projections/for_Graphs/given/organization.d.ts.map +1 -0
  118. package/dist/projections/for_Graphs/given/organization.js +84 -0
  119. package/dist/projections/for_Graphs/given/organization.js.map +1 -0
  120. package/dist/projections/graphs/EdgeCanHaveOnlyOneIdentifyingKey.d.ts +11 -0
  121. package/dist/projections/graphs/EdgeCanHaveOnlyOneIdentifyingKey.d.ts.map +1 -0
  122. package/dist/projections/graphs/EdgeCanHaveOnlyOneIdentifyingKey.js +16 -0
  123. package/dist/projections/graphs/EdgeCanHaveOnlyOneIdentifyingKey.js.map +1 -0
  124. package/dist/projections/graphs/EdgeMustHaveOneSourceAndOneTarget.d.ts +11 -0
  125. package/dist/projections/graphs/EdgeMustHaveOneSourceAndOneTarget.d.ts.map +1 -0
  126. package/dist/projections/graphs/EdgeMustHaveOneSourceAndOneTarget.js +16 -0
  127. package/dist/projections/graphs/EdgeMustHaveOneSourceAndOneTarget.js.map +1 -0
  128. package/dist/projections/graphs/GraphDeclaredMoreThanOnce.d.ts +11 -0
  129. package/dist/projections/graphs/GraphDeclaredMoreThanOnce.d.ts.map +1 -0
  130. package/dist/projections/graphs/GraphDeclaredMoreThanOnce.js +16 -0
  131. package/dist/projections/graphs/GraphDeclaredMoreThanOnce.js.map +1 -0
  132. package/dist/projections/graphs/GraphDefinitionBuilder.d.ts +24 -0
  133. package/dist/projections/graphs/GraphDefinitionBuilder.d.ts.map +1 -0
  134. package/dist/projections/graphs/GraphDefinitionBuilder.js +148 -0
  135. package/dist/projections/graphs/GraphDefinitionBuilder.js.map +1 -0
  136. package/dist/projections/graphs/GraphEdgeBuilder.d.ts +41 -0
  137. package/dist/projections/graphs/GraphEdgeBuilder.d.ts.map +1 -0
  138. package/dist/projections/graphs/GraphEdgeBuilder.js +94 -0
  139. package/dist/projections/graphs/GraphEdgeBuilder.js.map +1 -0
  140. package/dist/projections/graphs/GraphEdgeFromBuilder.d.ts +25 -0
  141. package/dist/projections/graphs/GraphEdgeFromBuilder.d.ts.map +1 -0
  142. package/dist/projections/graphs/GraphEdgeFromBuilder.js +37 -0
  143. package/dist/projections/graphs/GraphEdgeFromBuilder.js.map +1 -0
  144. package/dist/projections/graphs/GraphEdgeFromModel.d.ts +16 -0
  145. package/dist/projections/graphs/GraphEdgeFromModel.d.ts.map +1 -0
  146. package/dist/projections/graphs/GraphEdgeFromModel.js +4 -0
  147. package/dist/projections/graphs/GraphEdgeFromModel.js.map +1 -0
  148. package/dist/projections/graphs/GraphEdgeModel.d.ts +24 -0
  149. package/dist/projections/graphs/GraphEdgeModel.d.ts.map +1 -0
  150. package/dist/projections/graphs/GraphEdgeModel.js +4 -0
  151. package/dist/projections/graphs/GraphEdgeModel.js.map +1 -0
  152. package/dist/projections/graphs/GraphEdgeRemovedWithBuilder.d.ts +21 -0
  153. package/dist/projections/graphs/GraphEdgeRemovedWithBuilder.d.ts.map +1 -0
  154. package/dist/projections/graphs/GraphEdgeRemovedWithBuilder.js +31 -0
  155. package/dist/projections/graphs/GraphEdgeRemovedWithBuilder.js.map +1 -0
  156. package/dist/projections/graphs/GraphEdgeRemovedWithModel.d.ts +14 -0
  157. package/dist/projections/graphs/GraphEdgeRemovedWithModel.d.ts.map +1 -0
  158. package/dist/projections/graphs/GraphEdgeRemovedWithModel.js +4 -0
  159. package/dist/projections/graphs/GraphEdgeRemovedWithModel.js.map +1 -0
  160. package/dist/projections/graphs/GraphElementCannotBeReadModel.d.ts +11 -0
  161. package/dist/projections/graphs/GraphElementCannotBeReadModel.d.ts.map +1 -0
  162. package/dist/projections/graphs/GraphElementCannotBeReadModel.js +16 -0
  163. package/dist/projections/graphs/GraphElementCannotBeReadModel.js.map +1 -0
  164. package/dist/projections/graphs/GraphHasDuplicateElement.d.ts +13 -0
  165. package/dist/projections/graphs/GraphHasDuplicateElement.d.ts.map +1 -0
  166. package/dist/projections/graphs/GraphHasDuplicateElement.js +18 -0
  167. package/dist/projections/graphs/GraphHasDuplicateElement.js.map +1 -0
  168. package/dist/projections/graphs/GraphKeyPropertyNotFound.d.ts +12 -0
  169. package/dist/projections/graphs/GraphKeyPropertyNotFound.d.ts.map +1 -0
  170. package/dist/projections/graphs/GraphKeyPropertyNotFound.js +17 -0
  171. package/dist/projections/graphs/GraphKeyPropertyNotFound.js.map +1 -0
  172. package/dist/projections/graphs/GraphMappingBuilder.d.ts +32 -0
  173. package/dist/projections/graphs/GraphMappingBuilder.d.ts.map +1 -0
  174. package/dist/projections/graphs/GraphMappingBuilder.js +48 -0
  175. package/dist/projections/graphs/GraphMappingBuilder.js.map +1 -0
  176. package/dist/projections/graphs/GraphMemberMappings.d.ts +9 -0
  177. package/dist/projections/graphs/GraphMemberMappings.d.ts.map +1 -0
  178. package/dist/projections/graphs/GraphMemberMappings.js +59 -0
  179. package/dist/projections/graphs/GraphMemberMappings.js.map +1 -0
  180. package/dist/projections/graphs/GraphModel.d.ts +15 -0
  181. package/dist/projections/graphs/GraphModel.d.ts.map +1 -0
  182. package/dist/projections/graphs/GraphModel.js +4 -0
  183. package/dist/projections/graphs/GraphModel.js.map +1 -0
  184. package/dist/projections/graphs/GraphNameRequired.d.ts +11 -0
  185. package/dist/projections/graphs/GraphNameRequired.d.ts.map +1 -0
  186. package/dist/projections/graphs/GraphNameRequired.js +16 -0
  187. package/dist/projections/graphs/GraphNameRequired.js.map +1 -0
  188. package/dist/projections/graphs/GraphNodeBuilder.d.ts +34 -0
  189. package/dist/projections/graphs/GraphNodeBuilder.d.ts.map +1 -0
  190. package/dist/projections/graphs/GraphNodeBuilder.js +66 -0
  191. package/dist/projections/graphs/GraphNodeBuilder.js.map +1 -0
  192. package/dist/projections/graphs/GraphNodeFromBuilder.d.ts +21 -0
  193. package/dist/projections/graphs/GraphNodeFromBuilder.d.ts.map +1 -0
  194. package/dist/projections/graphs/GraphNodeFromBuilder.js +30 -0
  195. package/dist/projections/graphs/GraphNodeFromBuilder.js.map +1 -0
  196. package/dist/projections/graphs/GraphNodeFromModel.d.ts +14 -0
  197. package/dist/projections/graphs/GraphNodeFromModel.d.ts.map +1 -0
  198. package/dist/projections/graphs/GraphNodeFromModel.js +4 -0
  199. package/dist/projections/graphs/GraphNodeFromModel.js.map +1 -0
  200. package/dist/projections/graphs/GraphNodeModel.d.ts +18 -0
  201. package/dist/projections/graphs/GraphNodeModel.d.ts.map +1 -0
  202. package/dist/projections/graphs/GraphNodeModel.js +4 -0
  203. package/dist/projections/graphs/GraphNodeModel.js.map +1 -0
  204. package/dist/projections/graphs/GraphNodeRemovedWithBuilder.d.ts +17 -0
  205. package/dist/projections/graphs/GraphNodeRemovedWithBuilder.d.ts.map +1 -0
  206. package/dist/projections/graphs/GraphNodeRemovedWithBuilder.js +24 -0
  207. package/dist/projections/graphs/GraphNodeRemovedWithBuilder.js.map +1 -0
  208. package/dist/projections/graphs/GraphNodeRemovedWithModel.d.ts +12 -0
  209. package/dist/projections/graphs/GraphNodeRemovedWithModel.d.ts.map +1 -0
  210. package/dist/projections/graphs/GraphNodeRemovedWithModel.js +4 -0
  211. package/dist/projections/graphs/GraphNodeRemovedWithModel.js.map +1 -0
  212. package/dist/projections/graphs/GraphProjectionBuilder.d.ts +25 -0
  213. package/dist/projections/graphs/GraphProjectionBuilder.d.ts.map +1 -0
  214. package/dist/projections/graphs/GraphProjectionBuilder.js +36 -0
  215. package/dist/projections/graphs/GraphProjectionBuilder.js.map +1 -0
  216. package/dist/projections/graphs/GraphRegistration.d.ts +14 -0
  217. package/dist/projections/graphs/GraphRegistration.d.ts.map +1 -0
  218. package/dist/projections/graphs/GraphRegistration.js +4 -0
  219. package/dist/projections/graphs/GraphRegistration.js.map +1 -0
  220. package/dist/projections/graphs/GraphSchemaWriter.d.ts +28 -0
  221. package/dist/projections/graphs/GraphSchemaWriter.d.ts.map +1 -0
  222. package/dist/projections/graphs/GraphSchemaWriter.js +76 -0
  223. package/dist/projections/graphs/GraphSchemaWriter.js.map +1 -0
  224. package/dist/projections/graphs/Graphs.d.ts +39 -0
  225. package/dist/projections/graphs/Graphs.d.ts.map +1 -0
  226. package/dist/projections/graphs/Graphs.js +144 -0
  227. package/dist/projections/graphs/Graphs.js.map +1 -0
  228. package/dist/projections/graphs/IGraphEdgeBuilder.d.ts +37 -0
  229. package/dist/projections/graphs/IGraphEdgeBuilder.d.ts.map +1 -0
  230. package/dist/projections/graphs/IGraphEdgeBuilder.js +4 -0
  231. package/dist/projections/graphs/IGraphEdgeBuilder.js.map +1 -0
  232. package/dist/projections/graphs/IGraphEdgeFromBuilder.d.ts +29 -0
  233. package/dist/projections/graphs/IGraphEdgeFromBuilder.d.ts.map +1 -0
  234. package/dist/projections/graphs/IGraphEdgeFromBuilder.js +4 -0
  235. package/dist/projections/graphs/IGraphEdgeFromBuilder.js.map +1 -0
  236. package/dist/projections/graphs/IGraphEdgeRemovedWithBuilder.d.ts +27 -0
  237. package/dist/projections/graphs/IGraphEdgeRemovedWithBuilder.d.ts.map +1 -0
  238. package/dist/projections/graphs/IGraphEdgeRemovedWithBuilder.js +4 -0
  239. package/dist/projections/graphs/IGraphEdgeRemovedWithBuilder.js.map +1 -0
  240. package/dist/projections/graphs/IGraphMappingBuilder.d.ts +49 -0
  241. package/dist/projections/graphs/IGraphMappingBuilder.d.ts.map +1 -0
  242. package/dist/projections/graphs/IGraphMappingBuilder.js +4 -0
  243. package/dist/projections/graphs/IGraphMappingBuilder.js.map +1 -0
  244. package/dist/projections/graphs/IGraphNodeBuilder.d.ts +32 -0
  245. package/dist/projections/graphs/IGraphNodeBuilder.d.ts.map +1 -0
  246. package/dist/projections/graphs/IGraphNodeBuilder.js +4 -0
  247. package/dist/projections/graphs/IGraphNodeBuilder.js.map +1 -0
  248. package/dist/projections/graphs/IGraphNodeFromBuilder.d.ts +21 -0
  249. package/dist/projections/graphs/IGraphNodeFromBuilder.d.ts.map +1 -0
  250. package/dist/projections/graphs/IGraphNodeFromBuilder.js +4 -0
  251. package/dist/projections/graphs/IGraphNodeFromBuilder.js.map +1 -0
  252. package/dist/projections/graphs/IGraphNodeRemovedWithBuilder.d.ts +19 -0
  253. package/dist/projections/graphs/IGraphNodeRemovedWithBuilder.d.ts.map +1 -0
  254. package/dist/projections/graphs/IGraphNodeRemovedWithBuilder.js +4 -0
  255. package/dist/projections/graphs/IGraphNodeRemovedWithBuilder.js.map +1 -0
  256. package/dist/projections/graphs/IGraphProjection.d.ts +13 -0
  257. package/dist/projections/graphs/IGraphProjection.d.ts.map +1 -0
  258. package/dist/projections/graphs/IGraphProjection.js +4 -0
  259. package/dist/projections/graphs/IGraphProjection.js.map +1 -0
  260. package/dist/projections/graphs/IGraphProjectionBuilder.d.ts +26 -0
  261. package/dist/projections/graphs/IGraphProjectionBuilder.d.ts.map +1 -0
  262. package/dist/projections/graphs/IGraphProjectionBuilder.js +4 -0
  263. package/dist/projections/graphs/IGraphProjectionBuilder.js.map +1 -0
  264. package/dist/projections/graphs/IGraphs.d.ts +27 -0
  265. package/dist/projections/graphs/IGraphs.d.ts.map +1 -0
  266. package/dist/projections/graphs/IGraphs.js +4 -0
  267. package/dist/projections/graphs/IGraphs.js.map +1 -0
  268. package/dist/projections/graphs/ModelBoundGraphReader.d.ts +30 -0
  269. package/dist/projections/graphs/ModelBoundGraphReader.d.ts.map +1 -0
  270. package/dist/projections/graphs/ModelBoundGraphReader.js +112 -0
  271. package/dist/projections/graphs/ModelBoundGraphReader.js.map +1 -0
  272. package/dist/projections/graphs/NestedObjectInGraph.d.ts +12 -0
  273. package/dist/projections/graphs/NestedObjectInGraph.d.ts.map +1 -0
  274. package/dist/projections/graphs/NestedObjectInGraph.js +17 -0
  275. package/dist/projections/graphs/NestedObjectInGraph.js.map +1 -0
  276. package/dist/projections/graphs/NodeMustHaveExactlyOneKey.d.ts +12 -0
  277. package/dist/projections/graphs/NodeMustHaveExactlyOneKey.d.ts.map +1 -0
  278. package/dist/projections/graphs/NodeMustHaveExactlyOneKey.js +17 -0
  279. package/dist/projections/graphs/NodeMustHaveExactlyOneKey.js.map +1 -0
  280. package/dist/projections/graphs/SetOnceNotSupportedInGraph.d.ts +13 -0
  281. package/dist/projections/graphs/SetOnceNotSupportedInGraph.d.ts.map +1 -0
  282. package/dist/projections/graphs/SetOnceNotSupportedInGraph.js +18 -0
  283. package/dist/projections/graphs/SetOnceNotSupportedInGraph.js.map +1 -0
  284. package/dist/projections/graphs/UnknownGraphEventProperty.d.ts +13 -0
  285. package/dist/projections/graphs/UnknownGraphEventProperty.d.ts.map +1 -0
  286. package/dist/projections/graphs/UnknownGraphEventProperty.js +18 -0
  287. package/dist/projections/graphs/UnknownGraphEventProperty.js.map +1 -0
  288. package/dist/projections/graphs/UnknownGraphNode.d.ts +12 -0
  289. package/dist/projections/graphs/UnknownGraphNode.d.ts.map +1 -0
  290. package/dist/projections/graphs/UnknownGraphNode.js +17 -0
  291. package/dist/projections/graphs/UnknownGraphNode.js.map +1 -0
  292. package/dist/projections/graphs/edge.d.ts +23 -0
  293. package/dist/projections/graphs/edge.d.ts.map +1 -0
  294. package/dist/projections/graphs/edge.js +29 -0
  295. package/dist/projections/graphs/edge.js.map +1 -0
  296. package/dist/projections/graphs/edgeFrom.d.ts +31 -0
  297. package/dist/projections/graphs/edgeFrom.d.ts.map +1 -0
  298. package/dist/projections/graphs/edgeFrom.js +26 -0
  299. package/dist/projections/graphs/edgeFrom.js.map +1 -0
  300. package/dist/projections/graphs/edgeRemovedWith.d.ts +22 -0
  301. package/dist/projections/graphs/edgeRemovedWith.d.ts.map +1 -0
  302. package/dist/projections/graphs/edgeRemovedWith.js +25 -0
  303. package/dist/projections/graphs/edgeRemovedWith.js.map +1 -0
  304. package/dist/projections/graphs/edgeSource.d.ts +22 -0
  305. package/dist/projections/graphs/edgeSource.d.ts.map +1 -0
  306. package/dist/projections/graphs/edgeSource.js +30 -0
  307. package/dist/projections/graphs/edgeSource.js.map +1 -0
  308. package/dist/projections/graphs/edgeTarget.d.ts +22 -0
  309. package/dist/projections/graphs/edgeTarget.d.ts.map +1 -0
  310. package/dist/projections/graphs/edgeTarget.js +30 -0
  311. package/dist/projections/graphs/edgeTarget.js.map +1 -0
  312. package/dist/projections/graphs/graph.d.ts +16 -0
  313. package/dist/projections/graphs/graph.d.ts.map +1 -0
  314. package/dist/projections/graphs/graph.js +24 -0
  315. package/dist/projections/graphs/graph.js.map +1 -0
  316. package/dist/projections/graphs/graphKey.d.ts +16 -0
  317. package/dist/projections/graphs/graphKey.d.ts.map +1 -0
  318. package/dist/projections/graphs/graphKey.js +28 -0
  319. package/dist/projections/graphs/graphKey.js.map +1 -0
  320. package/dist/projections/graphs/graphProjection.d.ts +21 -0
  321. package/dist/projections/graphs/graphProjection.d.ts.map +1 -0
  322. package/dist/projections/graphs/graphProjection.js +28 -0
  323. package/dist/projections/graphs/graphProjection.js.map +1 -0
  324. package/dist/projections/graphs/index.d.ts +49 -0
  325. package/dist/projections/graphs/index.d.ts.map +1 -0
  326. package/dist/projections/graphs/index.js +28 -0
  327. package/dist/projections/graphs/index.js.map +1 -0
  328. package/dist/projections/graphs/isGraphElement.d.ts +7 -0
  329. package/dist/projections/graphs/isGraphElement.d.ts.map +1 -0
  330. package/dist/projections/graphs/isGraphElement.js +13 -0
  331. package/dist/projections/graphs/isGraphElement.js.map +1 -0
  332. package/dist/projections/graphs/node.d.ts +22 -0
  333. package/dist/projections/graphs/node.d.ts.map +1 -0
  334. package/dist/projections/graphs/node.js +29 -0
  335. package/dist/projections/graphs/node.js.map +1 -0
  336. package/dist/projections/graphs/nodeFrom.d.ts +31 -0
  337. package/dist/projections/graphs/nodeFrom.d.ts.map +1 -0
  338. package/dist/projections/graphs/nodeFrom.js +26 -0
  339. package/dist/projections/graphs/nodeFrom.js.map +1 -0
  340. package/dist/projections/graphs/nodeRemovedWith.d.ts +28 -0
  341. package/dist/projections/graphs/nodeRemovedWith.d.ts.map +1 -0
  342. package/dist/projections/graphs/nodeRemovedWith.js +25 -0
  343. package/dist/projections/graphs/nodeRemovedWith.js.map +1 -0
  344. package/dist/projections/graphs/propertyPathOf.d.ts +8 -0
  345. package/dist/projections/graphs/propertyPathOf.d.ts.map +1 -0
  346. package/dist/projections/graphs/propertyPathOf.js +14 -0
  347. package/dist/projections/graphs/propertyPathOf.js.map +1 -0
  348. package/dist/projections/index.d.ts +6 -0
  349. package/dist/projections/index.d.ts.map +1 -1
  350. package/dist/projections/index.js +4 -0
  351. package/dist/projections/index.js.map +1 -1
  352. package/dist/projections/modelBound/ConflictingChildrenOrdering.d.ts +10 -0
  353. package/dist/projections/modelBound/ConflictingChildrenOrdering.d.ts.map +1 -0
  354. package/dist/projections/modelBound/ConflictingChildrenOrdering.js +16 -0
  355. package/dist/projections/modelBound/ConflictingChildrenOrdering.js.map +1 -0
  356. package/dist/projections/modelBound/childrenAndNestedBuilder.d.ts +2 -0
  357. package/dist/projections/modelBound/childrenAndNestedBuilder.d.ts.map +1 -1
  358. package/dist/projections/modelBound/childrenAndNestedBuilder.js +9 -5
  359. package/dist/projections/modelBound/childrenAndNestedBuilder.js.map +1 -1
  360. package/dist/projections/modelBound/childrenFrom.d.ts +39 -1
  361. package/dist/projections/modelBound/childrenFrom.d.ts.map +1 -1
  362. package/dist/projections/modelBound/childrenFrom.js +30 -1
  363. package/dist/projections/modelBound/childrenFrom.js.map +1 -1
  364. package/dist/projections/modelBound/index.d.ts +3 -2
  365. package/dist/projections/modelBound/index.d.ts.map +1 -1
  366. package/dist/projections/modelBound/index.js +1 -0
  367. package/dist/projections/modelBound/index.js.map +1 -1
  368. package/dist/projections/modelBound/setFrom.d.ts +26 -0
  369. package/dist/projections/modelBound/setFrom.d.ts.map +1 -1
  370. package/dist/projections/modelBound/setFrom.js +15 -8
  371. package/dist/projections/modelBound/setFrom.js.map +1 -1
  372. package/dist/projections/modelBound/setFromContext.d.ts +23 -1
  373. package/dist/projections/modelBound/setFromContext.d.ts.map +1 -1
  374. package/dist/projections/modelBound/setFromContext.js +20 -2
  375. package/dist/projections/modelBound/setFromContext.js.map +1 -1
  376. package/dist/projections/propertyExpressions.d.ts +9 -0
  377. package/dist/projections/propertyExpressions.d.ts.map +1 -0
  378. package/dist/projections/propertyExpressions.js +13 -0
  379. package/dist/projections/propertyExpressions.js.map +1 -0
  380. package/dist/projections/registerProjectionWithRetry.d.ts +15 -0
  381. package/dist/projections/registerProjectionWithRetry.d.ts.map +1 -0
  382. package/dist/projections/registerProjectionWithRetry.js +44 -0
  383. package/dist/projections/registerProjectionWithRetry.js.map +1 -0
  384. package/dist/readModels/rootReadModelTypes.d.ts.map +1 -1
  385. package/dist/readModels/rootReadModelTypes.js +3 -1
  386. package/dist/readModels/rootReadModelTypes.js.map +1 -1
  387. package/dist/reducers/Reducers.d.ts.map +1 -1
  388. package/dist/reducers/Reducers.js +2 -1
  389. package/dist/reducers/Reducers.js.map +1 -1
  390. package/dist/sinks/WellKnownSinks.d.ts +4 -0
  391. package/dist/sinks/WellKnownSinks.d.ts.map +1 -1
  392. package/dist/sinks/WellKnownSinks.js +5 -1
  393. package/dist/sinks/WellKnownSinks.js.map +1 -1
  394. package/dist/testing/projections/ProjectionCapabilities.d.ts.map +1 -1
  395. package/dist/testing/projections/ProjectionCapabilities.js +2 -0
  396. package/dist/testing/projections/ProjectionCapabilities.js.map +1 -1
  397. package/dist/testing/projections/ProjectionChildrenCapabilities.d.ts.map +1 -1
  398. package/dist/testing/projections/ProjectionChildrenCapabilities.js +2 -0
  399. package/dist/testing/projections/ProjectionChildrenCapabilities.js.map +1 -1
  400. package/dist/tsconfig.tsbuildinfo +1 -1
  401. package/dist/types/DecoratorType.d.ts +5 -1
  402. package/dist/types/DecoratorType.d.ts.map +1 -1
  403. package/dist/types/DecoratorType.js +4 -0
  404. package/dist/types/DecoratorType.js.map +1 -1
  405. package/for_ChronicleOptions/when_configuring_the_graph_sink/with_graph_sink_type.spec.ts +22 -0
  406. package/package.json +3 -3
  407. package/projections/ChildrenOrderingNotSupportedByContracts.ts +18 -0
  408. package/projections/InvalidCausedByProperty.ts +14 -0
  409. package/projections/Projections.ts +8 -29
  410. package/projections/causedBy.ts +30 -0
  411. package/projections/childrenOrdering.ts +53 -0
  412. package/projections/childrenOrderingSupport.ts +40 -0
  413. package/projections/declarative/AllSetBuilder.ts +7 -0
  414. package/projections/declarative/ChildrenBuilder.ts +34 -1
  415. package/projections/declarative/ChildrenOrderingAlreadyDefined.ts +11 -0
  416. package/projections/declarative/DictionaryKey.ts +88 -0
  417. package/projections/declarative/FromAllBuilder.ts +10 -0
  418. package/projections/declarative/FromBuilder.ts +42 -32
  419. package/projections/declarative/FromEveryBuilder.ts +12 -0
  420. package/projections/declarative/IAllSetBuilder.ts +8 -0
  421. package/projections/declarative/IChildrenBuilder.ts +22 -0
  422. package/projections/declarative/IFromAllBuilder.ts +7 -0
  423. package/projections/declarative/IFromEveryBuilder.ts +7 -0
  424. package/projections/declarative/IReadModelPropertiesBuilder.ts +39 -6
  425. package/projections/declarative/ISetBuilder.ts +8 -0
  426. package/projections/declarative/InvalidDictionaryKey.ts +14 -0
  427. package/projections/declarative/JoinBuilder.ts +41 -32
  428. package/projections/declarative/ProjectionBuilderCore.ts +2 -0
  429. package/projections/declarative/SetBuilder.ts +7 -0
  430. package/projections/declarative/for_ChildrenBuilder/when_ordering_children.spec.ts +52 -0
  431. package/projections/declarative/for_FromAllBuilder/when_setting_once.spec.ts +29 -0
  432. package/projections/declarative/for_FromBuilder/when_setting_once.spec.ts +39 -0
  433. package/projections/declarative/for_FromBuilder/when_targeting_dictionary_entries.spec.ts +99 -0
  434. package/projections/declarative/for_JoinBuilder/when_setting_once_and_targeting_dictionary_entries.spec.ts +36 -0
  435. package/projections/declarative/for_SetBuilder/when_setting_to_the_causing_identity.spec.ts +37 -0
  436. package/projections/declarative/index.ts +4 -0
  437. package/projections/for_Graphs/given/a_discovered_graph.ts +21 -0
  438. package/projections/for_Graphs/given/a_fake_connection.ts +19 -0
  439. package/projections/for_Graphs/given/organization.ts +96 -0
  440. package/projections/for_Graphs/when_building_a_fluent_graph.spec.ts +112 -0
  441. package/projections/for_Graphs/when_building_a_model_bound_graph.spec.ts +92 -0
  442. package/projections/for_Graphs/when_declaring_an_edge_with_an_identity.spec.ts +137 -0
  443. package/projections/for_Graphs/when_declaring_an_invalid_graph.spec.ts +227 -0
  444. package/projections/for_Graphs/when_declaring_with_standard_decorators.standard.spec.ts +92 -0
  445. package/projections/for_Graphs/when_discovering_graph_elements.spec.ts +32 -0
  446. package/projections/for_Graphs/when_mapping_properties.spec.ts +159 -0
  447. package/projections/for_Graphs/when_registering_graphs.spec.ts +56 -0
  448. package/projections/for_Projections/when_registering_ordered_children.spec.ts +66 -0
  449. package/projections/for_childrenOrderingSupport/when_detecting_support_in_the_pinned_contracts.spec.ts +22 -0
  450. package/projections/for_childrenOrderingSupport/when_ensuring_children_ordering_is_supported.spec.ts +35 -0
  451. package/projections/graphs/EdgeCanHaveOnlyOneIdentifyingKey.ts +16 -0
  452. package/projections/graphs/EdgeMustHaveOneSourceAndOneTarget.ts +16 -0
  453. package/projections/graphs/GraphDeclaredMoreThanOnce.ts +16 -0
  454. package/projections/graphs/GraphDefinitionBuilder.ts +169 -0
  455. package/projections/graphs/GraphEdgeBuilder.ts +107 -0
  456. package/projections/graphs/GraphEdgeFromBuilder.ts +47 -0
  457. package/projections/graphs/GraphEdgeFromModel.ts +22 -0
  458. package/projections/graphs/GraphEdgeModel.ts +34 -0
  459. package/projections/graphs/GraphEdgeRemovedWithBuilder.ts +39 -0
  460. package/projections/graphs/GraphEdgeRemovedWithModel.ts +19 -0
  461. package/projections/graphs/GraphElementCannotBeReadModel.ts +16 -0
  462. package/projections/graphs/GraphHasDuplicateElement.ts +18 -0
  463. package/projections/graphs/GraphKeyPropertyNotFound.ts +17 -0
  464. package/projections/graphs/GraphMappingBuilder.ts +65 -0
  465. package/projections/graphs/GraphMemberMappings.ts +60 -0
  466. package/projections/graphs/GraphModel.ts +20 -0
  467. package/projections/graphs/GraphNameRequired.ts +16 -0
  468. package/projections/graphs/GraphNodeBuilder.ts +76 -0
  469. package/projections/graphs/GraphNodeFromBuilder.ts +38 -0
  470. package/projections/graphs/GraphNodeFromModel.ts +19 -0
  471. package/projections/graphs/GraphNodeModel.ts +25 -0
  472. package/projections/graphs/GraphNodeRemovedWithBuilder.ts +30 -0
  473. package/projections/graphs/GraphNodeRemovedWithModel.ts +16 -0
  474. package/projections/graphs/GraphProjectionBuilder.ts +52 -0
  475. package/projections/graphs/GraphRegistration.ts +19 -0
  476. package/projections/graphs/GraphSchemaWriter.ts +80 -0
  477. package/projections/graphs/Graphs.ts +165 -0
  478. package/projections/graphs/IGraphEdgeBuilder.ts +43 -0
  479. package/projections/graphs/IGraphEdgeFromBuilder.ts +34 -0
  480. package/projections/graphs/IGraphEdgeRemovedWithBuilder.ts +32 -0
  481. package/projections/graphs/IGraphMappingBuilder.ts +57 -0
  482. package/projections/graphs/IGraphNodeBuilder.ts +37 -0
  483. package/projections/graphs/IGraphNodeFromBuilder.ts +25 -0
  484. package/projections/graphs/IGraphNodeRemovedWithBuilder.ts +23 -0
  485. package/projections/graphs/IGraphProjection.ts +16 -0
  486. package/projections/graphs/IGraphProjectionBuilder.ts +34 -0
  487. package/projections/graphs/IGraphs.ts +33 -0
  488. package/projections/graphs/ModelBoundGraphReader.ts +119 -0
  489. package/projections/graphs/NestedObjectInGraph.ts +17 -0
  490. package/projections/graphs/NodeMustHaveExactlyOneKey.ts +17 -0
  491. package/projections/graphs/SetOnceNotSupportedInGraph.ts +18 -0
  492. package/projections/graphs/UnknownGraphEventProperty.ts +18 -0
  493. package/projections/graphs/UnknownGraphNode.ts +17 -0
  494. package/projections/graphs/edge.ts +40 -0
  495. package/projections/graphs/edgeFrom.ts +48 -0
  496. package/projections/graphs/edgeRemovedWith.ts +36 -0
  497. package/projections/graphs/edgeSource.ts +39 -0
  498. package/projections/graphs/edgeTarget.ts +39 -0
  499. package/projections/graphs/graph.ts +28 -0
  500. package/projections/graphs/graphKey.ts +31 -0
  501. package/projections/graphs/graphProjection.ts +39 -0
  502. package/projections/graphs/index.ts +51 -0
  503. package/projections/graphs/isGraphElement.ts +14 -0
  504. package/projections/graphs/node.ts +40 -0
  505. package/projections/graphs/nodeFrom.ts +48 -0
  506. package/projections/graphs/nodeRemovedWith.ts +44 -0
  507. package/projections/graphs/propertyPathOf.ts +15 -0
  508. package/projections/index.ts +6 -0
  509. package/projections/modelBound/ConflictingChildrenOrdering.ts +14 -0
  510. package/projections/modelBound/childrenAndNestedBuilder.ts +11 -5
  511. package/projections/modelBound/childrenFrom.ts +62 -2
  512. package/projections/modelBound/for_childrenFrom/when_ordering_children.spec.ts +91 -0
  513. package/projections/modelBound/for_setFrom/when_setting_once.spec.ts +52 -0
  514. package/projections/modelBound/index.ts +3 -2
  515. package/projections/modelBound/setFrom.ts +37 -2
  516. package/projections/modelBound/setFromContext.ts +38 -3
  517. package/projections/propertyExpressions.ts +14 -0
  518. package/projections/registerProjectionWithRetry.ts +53 -0
  519. package/readModels/rootReadModelTypes.ts +3 -1
  520. package/reducers/Reducers.ts +2 -1
  521. package/sinks/WellKnownSinks.ts +7 -1
  522. package/testing/projections/ProjectionCapabilities.ts +1 -0
  523. package/testing/projections/ProjectionChildrenCapabilities.ts +1 -0
  524. package/testing/projections/for_ProjectionCapabilities/when_rejecting_set_once_dictionary_entries_and_ordered_children.spec.ts +52 -0
  525. package/types/DecoratorType.ts +7 -1
@@ -0,0 +1,30 @@
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 type { PropertyAccessor } from '@cratis/fundamentals';
5
+ import type { IGraphNodeRemovedWithBuilder } from './IGraphNodeRemovedWithBuilder.js';
6
+ import { propertyPathOf } from './propertyPathOf.js';
7
+
8
+ /**
9
+ * Implements {@link IGraphNodeRemovedWithBuilder}.
10
+ * @template TEvent - The type of event.
11
+ */
12
+ export class GraphNodeRemovedWithBuilder<TEvent> implements IGraphNodeRemovedWithBuilder<TEvent> {
13
+ /** The expression for the key of the node, or undefined for the event source id. */
14
+ key?: string;
15
+
16
+ /** Whether the edges attached to the node are deleted with it. */
17
+ detachEdges = false;
18
+
19
+ /** @inheritdoc */
20
+ usingKey(keyAccessor: PropertyAccessor<TEvent>): IGraphNodeRemovedWithBuilder<TEvent> {
21
+ this.key = propertyPathOf(keyAccessor);
22
+ return this;
23
+ }
24
+
25
+ /** @inheritdoc */
26
+ detach(): IGraphNodeRemovedWithBuilder<TEvent> {
27
+ this.detachEdges = true;
28
+ return this;
29
+ }
30
+ }
@@ -0,0 +1,16 @@
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
+ /**
5
+ * Represents how an event deletes a node.
6
+ */
7
+ export interface GraphNodeRemovedWithModel {
8
+ /** The event type. */
9
+ readonly eventType: Function;
10
+
11
+ /** The expression for the key of the node, or undefined for the event source id. */
12
+ readonly key?: string;
13
+
14
+ /** Whether the edges attached to the node are deleted with it. */
15
+ readonly detach: boolean;
16
+ }
@@ -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 type { Constructor } from '@cratis/fundamentals';
5
+ import { GraphEdgeBuilder } from './GraphEdgeBuilder.js';
6
+ import type { GraphEdgeModel } from './GraphEdgeModel.js';
7
+ import { GraphNodeBuilder } from './GraphNodeBuilder.js';
8
+ import type { GraphModel } from './GraphModel.js';
9
+ import type { GraphNodeModel } from './GraphNodeModel.js';
10
+ import type { IGraphEdgeBuilder } from './IGraphEdgeBuilder.js';
11
+ import type { IGraphNodeBuilder } from './IGraphNodeBuilder.js';
12
+ import type { IGraphProjection } from './IGraphProjection.js';
13
+ import type { IGraphProjectionBuilder } from './IGraphProjectionBuilder.js';
14
+
15
+ /**
16
+ * Implements {@link IGraphProjectionBuilder}, collecting the nodes and edges a graph projection defines.
17
+ */
18
+ export class GraphProjectionBuilder implements IGraphProjectionBuilder {
19
+ private readonly _nodes: GraphNodeModel[] = [];
20
+ private readonly _edges: GraphEdgeModel[] = [];
21
+
22
+ /** @inheritdoc */
23
+ node<TNode>(nodeType: Constructor<TNode>, configure: (builder: IGraphNodeBuilder<TNode>) => void): IGraphProjectionBuilder {
24
+ const builder = new GraphNodeBuilder<TNode>(nodeType);
25
+ configure(builder);
26
+ this._nodes.push(builder.build());
27
+ return this;
28
+ }
29
+
30
+ /** @inheritdoc */
31
+ edge<TEdge>(
32
+ edgeType: Constructor<TEdge>,
33
+ sourceType: Function,
34
+ targetType: Function,
35
+ configure: (builder: IGraphEdgeBuilder<TEdge>) => void): IGraphProjectionBuilder {
36
+ const builder = new GraphEdgeBuilder<TEdge>(edgeType, sourceType, targetType);
37
+ configure(builder);
38
+ this._edges.push(builder.build());
39
+ return this;
40
+ }
41
+
42
+ /**
43
+ * Builds the {@link GraphModel} of a graph projection.
44
+ * @param name - The name of the graph.
45
+ * @param projection - The graph projection to define the model with.
46
+ * @returns The model.
47
+ */
48
+ build(name: string, projection: IGraphProjection): GraphModel {
49
+ projection.define(this);
50
+ return { name, nodes: this._nodes, edges: this._edges };
51
+ }
52
+ }
@@ -0,0 +1,19 @@
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 type { ProjectionDefinition } from '@cratis/chronicle.contracts';
5
+ import type { buildReadModelDefinition } from '../../readModels/buildReadModelDefinition.js';
6
+
7
+ /**
8
+ * Represents everything that is registered for a graph: the read model that describes it and the projection that fills it.
9
+ */
10
+ export interface GraphRegistration {
11
+ /** The name of the graph. */
12
+ readonly graphName: string;
13
+
14
+ /** The read model whose schema describes the graph. */
15
+ readonly readModel: ReturnType<typeof buildReadModelDefinition>;
16
+
17
+ /** The projection with the graph mappings. */
18
+ readonly projection: ProjectionDefinition;
19
+ }
@@ -0,0 +1,80 @@
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 { JsonSchema, JsonSchemaGenerator } from '../../schemas/index.js';
5
+ import { GraphKeyPropertyNotFound } from './GraphKeyPropertyNotFound.js';
6
+ import type { GraphModel } from './GraphModel.js';
7
+ import { NestedObjectInGraph } from './NestedObjectInGraph.js';
8
+ import { UnknownGraphNode } from './UnknownGraphNode.js';
9
+
10
+ /**
11
+ * Writes the schema form of a graph: an object schema whose properties are the node labels and edge types.
12
+ * This is the form the kernel reads a graph from. The annotations are the ones of the kernel's graph definition.
13
+ */
14
+ export class GraphSchemaWriter {
15
+ /**
16
+ * Writes the schema of a graph.
17
+ * @param model - The {@link GraphModel}.
18
+ * @returns The schema as JSON.
19
+ * @throws {NestedObjectInGraph} When a node or an edge has an object property.
20
+ * @throws {UnknownGraphNode} When an edge connects a type that is not a node of the graph.
21
+ */
22
+ write(model: GraphModel): string {
23
+ const properties: Record<string, unknown> = {};
24
+ for (const node of model.nodes) {
25
+ this.assertProperty(node.type, node.keyProperty, this.propertiesOf(node.type, []));
26
+ properties[node.label] = {
27
+ ...this.element(node.type, []),
28
+ 'x-graph-kind': 'Node',
29
+ 'x-graph-key': node.keyProperty
30
+ };
31
+ }
32
+
33
+ for (const edge of model.edges) {
34
+ const identity = edge.identifyingProperty;
35
+ if (identity !== undefined) this.assertProperty(edge.type, identity, this.propertiesOf(edge.type, edge.excludedProperties));
36
+ properties[edge.edgeType] = {
37
+ ...this.element(edge.type, edge.excludedProperties),
38
+ 'x-graph-kind': 'Edge',
39
+ 'x-graph-source': this.labelOf(model, edge.edgeType, edge.sourceNode),
40
+ 'x-graph-target': this.labelOf(model, edge.edgeType, edge.targetNode),
41
+ ...(identity === undefined ? {} : { 'x-graph-identity': identity })
42
+ };
43
+ }
44
+
45
+ return JSON.stringify({ type: 'object', title: model.name, 'x-graph': true, properties });
46
+ }
47
+
48
+ /**
49
+ * Gets the properties of a node or edge type, as they are named in the graph.
50
+ * @param type - The node or edge type.
51
+ * @param excluded - Names of members that are not properties.
52
+ * @returns The property names with their schemas.
53
+ * @throws {NestedObjectInGraph} When a property is an object.
54
+ */
55
+ propertiesOf(type: Function, excluded: readonly string[]): Record<string, JsonSchema> {
56
+ const skip = new Set(excluded.map(name => name.toLowerCase()));
57
+ const result: Record<string, JsonSchema> = {};
58
+ for (const [name, property] of Object.entries(JsonSchemaGenerator.generate(type).properties ?? {})) {
59
+ if (skip.has(name.toLowerCase())) continue;
60
+ if (property.type === 'object' || property.items?.type === 'object') throw new NestedObjectInGraph(type, name);
61
+ result[name] = property;
62
+ }
63
+
64
+ return result;
65
+ }
66
+
67
+ private element(type: Function, excluded: readonly string[]): Record<string, unknown> {
68
+ return { type: 'object', properties: this.propertiesOf(type, excluded) };
69
+ }
70
+
71
+ private assertProperty(type: Function, property: string, properties: Record<string, JsonSchema>): void {
72
+ if (!Object.hasOwn(properties, property)) throw new GraphKeyPropertyNotFound(type, property);
73
+ }
74
+
75
+ private labelOf(model: GraphModel, edgeType: string, nodeType: Function): string {
76
+ const node = model.nodes.find(candidate => candidate.type === nodeType);
77
+ if (!node) throw new UnknownGraphNode(edgeType, nodeType);
78
+ return node.label;
79
+ }
80
+ }
@@ -0,0 +1,165 @@
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 type { Constructor } from '@cratis/fundamentals';
5
+ import type { IClientArtifactsProvider } from '../../artifacts/index.js';
6
+ import type { ChronicleConnection } from '../../connection/index.js';
7
+ import { createLogger } from '../../logging/createLogger.js';
8
+ import { getReadModelMetadata } from '../../readModels/readModel.js';
9
+ import { hasFromEventMetadata } from '../modelBound/fromEvent.js';
10
+ import { registerProjectionWithRetry } from '../registerProjectionWithRetry.js';
11
+ import { GraphDeclaredMoreThanOnce } from './GraphDeclaredMoreThanOnce.js';
12
+ import { GraphDefinitionBuilder } from './GraphDefinitionBuilder.js';
13
+ import { GraphElementCannotBeReadModel } from './GraphElementCannotBeReadModel.js';
14
+ import type { GraphEdgeModel } from './GraphEdgeModel.js';
15
+ import type { GraphModel } from './GraphModel.js';
16
+ import type { GraphNodeModel } from './GraphNodeModel.js';
17
+ import { GraphProjectionBuilder } from './GraphProjectionBuilder.js';
18
+ import type { GraphRegistration } from './GraphRegistration.js';
19
+ import type { IGraphProjection } from './IGraphProjection.js';
20
+ import type { IGraphs } from './IGraphs.js';
21
+ import { getEdgeMetadata } from './edge.js';
22
+ import { getGraphProjectionMetadata } from './graphProjection.js';
23
+ import { getNodeMetadata } from './node.js';
24
+ import { ModelBoundGraphReader } from './ModelBoundGraphReader.js';
25
+
26
+ interface DeclaredGraph {
27
+ readonly source: Constructor;
28
+ readonly model: GraphModel;
29
+ readonly projectionId: string;
30
+ }
31
+
32
+ /**
33
+ * Implements {@link IGraphs}, discovering the graphs an application declares, with the decorators and with the fluent
34
+ * builder, and registering them with the Chronicle Kernel.
35
+ */
36
+ export class Graphs implements IGraphs {
37
+ private readonly _failures = new Map<Constructor, Error>();
38
+ private readonly _logger: ReturnType<typeof createLogger>;
39
+ private _registrations: readonly GraphRegistration[] = [];
40
+
41
+ /**
42
+ * Creates a new {@link Graphs} instance.
43
+ * @param _eventStore - The event store name.
44
+ * @param _connection - Chronicle connection.
45
+ * @param _clientArtifacts - Provider for discovered client artifact types.
46
+ * @param _graphSinkTypeId - The identifier of the sink type that stores graphs.
47
+ */
48
+ constructor(
49
+ private readonly _eventStore: string,
50
+ private readonly _connection: ChronicleConnection,
51
+ private readonly _clientArtifacts: IClientArtifactsProvider,
52
+ private readonly _graphSinkTypeId: string
53
+ ) {
54
+ this._logger = createLogger('@cratis/chronicle/graphs', _connection.logger);
55
+ }
56
+
57
+ /** @inheritdoc */
58
+ get registrations(): readonly GraphRegistration[] {
59
+ return this._registrations;
60
+ }
61
+
62
+ /** @inheritdoc */
63
+ get failures(): ReadonlyMap<Constructor, Error> {
64
+ return this._failures;
65
+ }
66
+
67
+ /** @inheritdoc */
68
+ async discover(): Promise<void> {
69
+ this._failures.clear();
70
+ const builder = new GraphDefinitionBuilder();
71
+ const registrations: GraphRegistration[] = [];
72
+ const names = new Set<string>();
73
+ for (const declared of [...this.modelBoundGraphs(), ...this.fluentGraphs()]) {
74
+ try {
75
+ if (names.has(declared.model.name)) throw new GraphDeclaredMoreThanOnce(declared.model.name);
76
+ registrations.push(builder.build(declared.model, declared.projectionId, this._graphSinkTypeId));
77
+ names.add(declared.model.name);
78
+ } catch (error) {
79
+ this.fail(declared.source, error);
80
+ }
81
+ }
82
+
83
+ this._registrations = registrations;
84
+ this._logger.debug('Graph discovery complete', { graphCount: registrations.length, failureCount: this._failures.size });
85
+ }
86
+
87
+ /** @inheritdoc */
88
+ async register(): Promise<void> {
89
+ if (this._registrations.length === 0) {
90
+ this._logger.debug('No graphs to register');
91
+ return;
92
+ }
93
+
94
+ this._logger.info('Registering graphs', { graphCount: this._registrations.length });
95
+ await this._connection.readModels.registerMany({
96
+ EventStore: this._eventStore,
97
+ Owner: 1,
98
+ ReadModels: this._registrations.map(registration => registration.readModel),
99
+ Source: 1
100
+ });
101
+
102
+ for (const registration of this._registrations) {
103
+ await registerProjectionWithRetry(
104
+ this._connection, this._eventStore, this._logger, registration.projection, registration.projection.Identifier);
105
+ }
106
+ }
107
+
108
+ private modelBoundGraphs(): DeclaredGraph[] {
109
+ const reader = new ModelBoundGraphReader();
110
+ const elements = new Map<string, { source: Constructor; nodes: GraphNodeModel[]; edges: GraphEdgeModel[] }>();
111
+ const broken = new Set<string>();
112
+ for (const type of this._clientArtifacts.graphElements ?? []) {
113
+ this.tryRead(type, () => {
114
+ const graph = ModelBoundGraphReader.graphNameOf(type);
115
+ try {
116
+ if (hasFromEventMetadata(type) || getReadModelMetadata(type) !== undefined) throw new GraphElementCannotBeReadModel(type);
117
+ const declared = elements.get(graph) ?? { source: type, nodes: [], edges: [] };
118
+ elements.set(graph, declared);
119
+ if (getNodeMetadata(type)) declared.nodes.push(reader.readNode(type));
120
+ if (getEdgeMetadata(type)) declared.edges.push(reader.readEdge(type));
121
+ } catch (error) {
122
+ // A graph without one of its nodes or edges is not what was declared. A replay would sweep away
123
+ // what the missing element left behind, so the whole graph is left unregistered.
124
+ broken.add(graph);
125
+ throw error;
126
+ }
127
+ });
128
+ }
129
+
130
+ return Array.from(elements)
131
+ .filter(([name]) => !broken.has(name))
132
+ .map(([name, declared]) => ({
133
+ source: declared.source,
134
+ model: { name, nodes: declared.nodes, edges: declared.edges },
135
+ projectionId: name
136
+ }));
137
+ }
138
+
139
+ private fluentGraphs(): DeclaredGraph[] {
140
+ const result: DeclaredGraph[] = [];
141
+ for (const type of this._clientArtifacts.graphProjections ?? []) {
142
+ this.tryRead(type, () => {
143
+ const name = getGraphProjectionMetadata(type)?.name ?? type.name;
144
+ const projection = new type() as IGraphProjection;
145
+ result.push({ source: type, model: new GraphProjectionBuilder().build(name, projection), projectionId: type.name });
146
+ });
147
+ }
148
+
149
+ return result;
150
+ }
151
+
152
+ private tryRead(type: Constructor, read: () => void): void {
153
+ try {
154
+ read();
155
+ } catch (error) {
156
+ this.fail(type, error);
157
+ }
158
+ }
159
+
160
+ private fail(type: Constructor, error: unknown): void {
161
+ const failure = error instanceof Error ? error : new Error(String(error));
162
+ this._failures.set(type, failure);
163
+ this._logger.error('Could not build a graph definition', { type: type.name, error: failure });
164
+ }
165
+ }
@@ -0,0 +1,43 @@
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 type { Constructor, PropertyAccessor } from '@cratis/fundamentals';
5
+ import type { IGraphEdgeFromBuilder } from './IGraphEdgeFromBuilder.js';
6
+ import type { IGraphEdgeRemovedWithBuilder } from './IGraphEdgeRemovedWithBuilder.js';
7
+
8
+ /**
9
+ * Defines a builder for an edge.
10
+ * @template TEdge - The type of edge.
11
+ */
12
+ export interface IGraphEdgeBuilder<TEdge> {
13
+ /**
14
+ * Names the edge type. Not needed when the class of the edge has the edge decorator.
15
+ * @param type - The edge type, for example MEMBER_OF.
16
+ * @returns The builder for continuation.
17
+ */
18
+ named(type: string): IGraphEdgeBuilder<TEdge>;
19
+
20
+ /**
21
+ * Declares the property that identifies the edge among edges of the same type between the same two nodes.
22
+ * Not needed when the property has the graphKey decorator.
23
+ * @param identityAccessor - Accessor for the identifying property.
24
+ * @returns The builder for continuation.
25
+ */
26
+ identifiedBy(identityAccessor: PropertyAccessor<TEdge>): IGraphEdgeBuilder<TEdge>;
27
+
28
+ /**
29
+ * Creates or updates the edge when an event is observed. Both end nodes are created when they do not exist.
30
+ * @param eventType - The event constructor.
31
+ * @param configure - Callback for the keys of the end nodes and the properties.
32
+ * @returns The builder for continuation.
33
+ */
34
+ from<TEvent>(eventType: Constructor<TEvent>, configure: (builder: IGraphEdgeFromBuilder<TEdge, TEvent>) => void): IGraphEdgeBuilder<TEdge>;
35
+
36
+ /**
37
+ * Deletes the edge when an event is observed. The nodes at both ends stay.
38
+ * @param eventType - The event constructor.
39
+ * @param configure - Callback for the keys of the end nodes.
40
+ * @returns The builder for continuation.
41
+ */
42
+ removedWith<TEvent>(eventType: Constructor<TEvent>, configure: (builder: IGraphEdgeRemovedWithBuilder<TEvent>) => void): IGraphEdgeBuilder<TEdge>;
43
+ }
@@ -0,0 +1,34 @@
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 type { PropertyAccessor } from '@cratis/fundamentals';
5
+ import type { IGraphMappingBuilder } from './IGraphMappingBuilder.js';
6
+
7
+ /**
8
+ * Defines the builder for how an event creates or updates an edge.
9
+ * @template TEdge - The type of edge.
10
+ * @template TEvent - The type of event.
11
+ */
12
+ export interface IGraphEdgeFromBuilder<TEdge, TEvent> extends IGraphMappingBuilder<TEdge, TEvent, IGraphEdgeFromBuilder<TEdge, TEvent>> {
13
+ /**
14
+ * Takes the key of the source node from a property on the event. By default it is the event source id.
15
+ * @param keyAccessor - Accessor for the event property.
16
+ * @returns The builder for continuation.
17
+ */
18
+ usingSourceKey(keyAccessor: PropertyAccessor<TEvent>): IGraphEdgeFromBuilder<TEdge, TEvent>;
19
+
20
+ /**
21
+ * Takes the key of the target node from a property on the event. By default it is the event source id.
22
+ * @param keyAccessor - Accessor for the event property.
23
+ * @returns The builder for continuation.
24
+ */
25
+ usingTargetKey(keyAccessor: PropertyAccessor<TEvent>): IGraphEdgeFromBuilder<TEdge, TEvent>;
26
+
27
+ /**
28
+ * Takes the identity of the edge from a property on the event, for an edge type with an identifying property.
29
+ * By default it is the event property named like the identifying property.
30
+ * @param identityAccessor - Accessor for the event property.
31
+ * @returns The builder for continuation.
32
+ */
33
+ usingIdentity(identityAccessor: PropertyAccessor<TEvent>): IGraphEdgeFromBuilder<TEdge, TEvent>;
34
+ }
@@ -0,0 +1,32 @@
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 type { PropertyAccessor } from '@cratis/fundamentals';
5
+
6
+ /**
7
+ * Defines the builder for how an event deletes an edge.
8
+ * @template TEvent - The type of event.
9
+ */
10
+ export interface IGraphEdgeRemovedWithBuilder<TEvent> {
11
+ /**
12
+ * Takes the key of the source node from a property on the event. By default it is the event source id.
13
+ * @param keyAccessor - Accessor for the event property.
14
+ * @returns The builder for continuation.
15
+ */
16
+ usingSourceKey(keyAccessor: PropertyAccessor<TEvent>): IGraphEdgeRemovedWithBuilder<TEvent>;
17
+
18
+ /**
19
+ * Takes the key of the target node from a property on the event. By default it is the event source id.
20
+ * @param keyAccessor - Accessor for the event property.
21
+ * @returns The builder for continuation.
22
+ */
23
+ usingTargetKey(keyAccessor: PropertyAccessor<TEvent>): IGraphEdgeRemovedWithBuilder<TEvent>;
24
+
25
+ /**
26
+ * Takes the identity of the edge from a property on the event, for an edge type with an identifying property.
27
+ * By default it is the event property named like the identifying property.
28
+ * @param identityAccessor - Accessor for the event property.
29
+ * @returns The builder for continuation.
30
+ */
31
+ usingIdentity(identityAccessor: PropertyAccessor<TEvent>): IGraphEdgeRemovedWithBuilder<TEvent>;
32
+ }
@@ -0,0 +1,57 @@
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 type { PropertyAccessor } from '@cratis/fundamentals';
5
+ import type { IAddBuilder } from '../declarative/IAddBuilder.js';
6
+ import type { ISetBuilder } from '../declarative/ISetBuilder.js';
7
+ import type { ISubtractBuilder } from '../declarative/ISubtractBuilder.js';
8
+
9
+ /**
10
+ * Defines the property mappings shared by nodes and edges.
11
+ * @template TElement - The type of the node or edge.
12
+ * @template TEvent - The type of event.
13
+ * @template TSelf - The type of the builder, for continuation.
14
+ */
15
+ export interface IGraphMappingBuilder<TElement, TEvent, TSelf> {
16
+ /**
17
+ * Sets a property.
18
+ * @param propertyAccessor - Accessor for the property on the node or edge.
19
+ * @returns The builder for what to set it to.
20
+ */
21
+ set(propertyAccessor: PropertyAccessor<TElement>): ISetBuilder<TEvent, TSelf>;
22
+
23
+ /**
24
+ * Adds the value of an event property to a counter property.
25
+ * @param propertyAccessor - Accessor for the counter property.
26
+ * @returns The builder for which event property to add.
27
+ */
28
+ add(propertyAccessor: PropertyAccessor<TElement>): IAddBuilder<TEvent, TSelf>;
29
+
30
+ /**
31
+ * Subtracts the value of an event property from a counter property.
32
+ * @param propertyAccessor - Accessor for the counter property.
33
+ * @returns The builder for which event property to subtract.
34
+ */
35
+ subtract(propertyAccessor: PropertyAccessor<TElement>): ISubtractBuilder<TEvent, TSelf>;
36
+
37
+ /**
38
+ * Increments a counter property by one.
39
+ * @param propertyAccessor - Accessor for the counter property.
40
+ * @returns The builder for continuation.
41
+ */
42
+ increment(propertyAccessor: PropertyAccessor<TElement>): TSelf;
43
+
44
+ /**
45
+ * Decrements a counter property by one.
46
+ * @param propertyAccessor - Accessor for the counter property.
47
+ * @returns The builder for continuation.
48
+ */
49
+ decrement(propertyAccessor: PropertyAccessor<TElement>): TSelf;
50
+
51
+ /**
52
+ * Counts the events on a counter property.
53
+ * @param propertyAccessor - Accessor for the counter property.
54
+ * @returns The builder for continuation.
55
+ */
56
+ count(propertyAccessor: PropertyAccessor<TElement>): TSelf;
57
+ }
@@ -0,0 +1,37 @@
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 type { Constructor } from '@cratis/fundamentals';
5
+ import type { PropertyAccessor } from '@cratis/fundamentals';
6
+ import type { IGraphNodeFromBuilder } from './IGraphNodeFromBuilder.js';
7
+ import type { IGraphNodeRemovedWithBuilder } from './IGraphNodeRemovedWithBuilder.js';
8
+
9
+ /**
10
+ * Defines a builder for a node.
11
+ * @template TNode - The type of node.
12
+ */
13
+ export interface IGraphNodeBuilder<TNode> {
14
+ /**
15
+ * Declares the property that holds the unique key of the node. Not needed when the property has the graphKey decorator.
16
+ * @param keyAccessor - Accessor for the key property.
17
+ * @returns The builder for continuation.
18
+ */
19
+ identifiedBy(keyAccessor: PropertyAccessor<TNode>): IGraphNodeBuilder<TNode>;
20
+
21
+ /**
22
+ * Creates or updates the node when an event is observed.
23
+ * @param eventType - The event constructor.
24
+ * @param configure - Optional callback for the key and the properties. By default the key is the event source id
25
+ * and properties are mapped by name.
26
+ * @returns The builder for continuation.
27
+ */
28
+ from<TEvent>(eventType: Constructor<TEvent>, configure?: (builder: IGraphNodeFromBuilder<TNode, TEvent>) => void): IGraphNodeBuilder<TNode>;
29
+
30
+ /**
31
+ * Deletes the node when an event is observed.
32
+ * @param eventType - The event constructor.
33
+ * @param configure - Optional callback for the key and for detaching. By default the key is the event source id.
34
+ * @returns The builder for continuation.
35
+ */
36
+ removedWith<TEvent>(eventType: Constructor<TEvent>, configure?: (builder: IGraphNodeRemovedWithBuilder<TEvent>) => void): IGraphNodeBuilder<TNode>;
37
+ }
@@ -0,0 +1,25 @@
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 type { PropertyAccessor } from '@cratis/fundamentals';
5
+ import type { IGraphMappingBuilder } from './IGraphMappingBuilder.js';
6
+
7
+ /**
8
+ * Defines the builder for how an event creates or updates a node.
9
+ * @template TNode - The type of node.
10
+ * @template TEvent - The type of event.
11
+ */
12
+ export interface IGraphNodeFromBuilder<TNode, TEvent> extends IGraphMappingBuilder<TNode, TEvent, IGraphNodeFromBuilder<TNode, TEvent>> {
13
+ /**
14
+ * Takes the key of the node from a property on the event. By default it is the event source id.
15
+ * @param keyAccessor - Accessor for the event property.
16
+ * @returns The builder for continuation.
17
+ */
18
+ usingKey(keyAccessor: PropertyAccessor<TEvent>): IGraphNodeFromBuilder<TNode, TEvent>;
19
+
20
+ /**
21
+ * Only sets properties on a node that already exists, instead of creating it.
22
+ * @returns The builder for continuation.
23
+ */
24
+ onlyWhenExisting(): IGraphNodeFromBuilder<TNode, TEvent>;
25
+ }
@@ -0,0 +1,23 @@
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 type { PropertyAccessor } from '@cratis/fundamentals';
5
+
6
+ /**
7
+ * Defines the builder for how an event deletes a node.
8
+ * @template TEvent - The type of event.
9
+ */
10
+ export interface IGraphNodeRemovedWithBuilder<TEvent> {
11
+ /**
12
+ * Takes the key of the node from a property on the event. By default it is the event source id.
13
+ * @param keyAccessor - Accessor for the event property.
14
+ * @returns The builder for continuation.
15
+ */
16
+ usingKey(keyAccessor: PropertyAccessor<TEvent>): IGraphNodeRemovedWithBuilder<TEvent>;
17
+
18
+ /**
19
+ * Deletes the edges attached to the node with it. Without it a node that still has edges cannot be deleted.
20
+ * @returns The builder for continuation.
21
+ */
22
+ detach(): IGraphNodeRemovedWithBuilder<TEvent>;
23
+ }
@@ -0,0 +1,16 @@
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 type { IGraphProjectionBuilder } from './IGraphProjectionBuilder.js';
5
+
6
+ /**
7
+ * Defines a projection of events onto a property graph, declared with a fluent builder.
8
+ * Implement it on a class decorated with graphProjection.
9
+ */
10
+ export interface IGraphProjection {
11
+ /**
12
+ * Defines the nodes and edges of the graph and the events they are projected from.
13
+ * @param builder - The builder to define with.
14
+ */
15
+ define(builder: IGraphProjectionBuilder): void;
16
+ }