@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,24 @@
1
+ import type { ChronicleConnection } from '../../../connection/index.js';
2
+ /**
3
+ * Creates a connection that records what is registered.
4
+ * @returns The connection and what was registered with it.
5
+ */
6
+ export declare function aFakeConnection(): {
7
+ connection: ChronicleConnection;
8
+ readModelRequests: {
9
+ EventStore: string;
10
+ Owner: number;
11
+ ReadModels: Array<{
12
+ Type: {
13
+ Identifier: string;
14
+ };
15
+ }>;
16
+ Source: number;
17
+ }[];
18
+ projectionRequests: {
19
+ EventStore: string;
20
+ Owner: number;
21
+ Projections: any[];
22
+ }[];
23
+ };
24
+ //# sourceMappingURL=a_fake_connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"a_fake_connection.d.ts","sourceRoot":"","sources":["../../../../projections/for_Graphs/given/a_fake_connection.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE;;;GAGG;AACH,wBAAgB,eAAe;;;oBACkB,MAAM;eAAS,MAAM;oBAAc,KAAK,CAAC;YAAE,IAAI,EAAE;gBAAE,UAAU,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,CAAC;gBAAU,MAAM;;;oBACzF,MAAM;eAAS,MAAM;qBAAe,GAAG,EAAE;;EAO1F"}
@@ -0,0 +1,17 @@
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
+ * Creates a connection that records what is registered.
5
+ * @returns The connection and what was registered with it.
6
+ */
7
+ export function aFakeConnection() {
8
+ const readModelRequests = [];
9
+ const projectionRequests = [];
10
+ const connection = {
11
+ logger: undefined,
12
+ readModels: { registerMany: async (request) => { readModelRequests.push(request); return {}; } },
13
+ projections: { register: async (request) => { projectionRequests.push(request); return {}; } }
14
+ };
15
+ return { connection, readModelRequests, projectionRequests };
16
+ }
17
+ //# sourceMappingURL=a_fake_connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"a_fake_connection.js","sourceRoot":"","sources":["../../../../projections/for_Graphs/given/a_fake_connection.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAIrG;;;GAGG;AACH,MAAM,UAAU,eAAe;IAC3B,MAAM,iBAAiB,GAAsH,EAAE,CAAC;IAChJ,MAAM,kBAAkB,GAAqE,EAAE,CAAC;IAChG,MAAM,UAAU,GAAG;QACf,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,OAA2C,EAAE,EAAE,GAAG,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE;QACpI,WAAW,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,OAA4C,EAAE,EAAE,GAAG,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE;KACpG,CAAC;IACpC,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,CAAC;AACjE,CAAC"}
@@ -0,0 +1,43 @@
1
+ import 'reflect-metadata';
2
+ import type { IClientArtifactsProvider } from '../../../artifacts/IClientArtifactsProvider.js';
3
+ import type { Constructor } from '@cratis/fundamentals';
4
+ export declare class PersonRegistered {
5
+ personId: string;
6
+ name: string;
7
+ }
8
+ export declare class PersonRemoved {
9
+ personId: string;
10
+ }
11
+ export declare class GroupCreated {
12
+ groupId: string;
13
+ name: string;
14
+ }
15
+ export declare class MemberAdded {
16
+ personId: string;
17
+ groupId: string;
18
+ }
19
+ export declare class MemberRemoved {
20
+ personId: string;
21
+ groupId: string;
22
+ }
23
+ export declare class Person {
24
+ personId: string;
25
+ name: string;
26
+ }
27
+ export declare class Group {
28
+ groupId: string;
29
+ name: string;
30
+ }
31
+ export declare class MemberOf {
32
+ personId: string;
33
+ groupId: string;
34
+ since: Date;
35
+ }
36
+ /**
37
+ * Creates a provider that finds only the given graph artifacts.
38
+ * @param graphElements - The nodes and edges.
39
+ * @param graphProjections - The fluent graph projections.
40
+ * @returns The provider.
41
+ */
42
+ export declare function artifactsWith(graphElements: Constructor[], graphProjections?: Constructor[]): IClientArtifactsProvider;
43
+ //# sourceMappingURL=organization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.d.ts","sourceRoot":"","sources":["../../../../projections/for_Graphs/given/organization.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAa/F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIxD,qBAAa,gBAAgB;IACzB,QAAQ,SAAM;IACd,IAAI,SAAM;CACb;AAGD,qBAAa,aAAa;IACtB,QAAQ,SAAM;CACjB;AAGD,qBAAa,YAAY;IACrB,OAAO,SAAM;IACb,IAAI,SAAM;CACb;AAGD,qBAAa,WAAW;IACpB,QAAQ,SAAM;IACd,OAAO,SAAM;CAChB;AAGD,qBAAa,aAAa;IACtB,QAAQ,SAAM;IACd,OAAO,SAAM;CAChB;AAGD,qBAAa,MAAM;IACf,QAAQ,SAAM;IACd,IAAI,SAAM;CACb;AAOD,qBAAa,KAAK;IACd,OAAO,SAAM;IACb,IAAI,SAAM;CACb;AAMD,qBAAa,QAAQ;IACjB,QAAQ,SAAM;IACd,OAAO,SAAM;IACb,KAAK,OAAc;CACtB;AAUD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,aAAa,EAAE,WAAW,EAAE,EAAE,gBAAgB,GAAE,WAAW,EAAO,GAAG,wBAAwB,CAK1H"}
@@ -0,0 +1,84 @@
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
+ import 'reflect-metadata';
4
+ import { field } from '@cratis/fundamentals';
5
+ import { eventType } from '../../../events/eventTypeDecorator.js';
6
+ import { edge } from '../../graphs/edge.js';
7
+ import { edgeFrom } from '../../graphs/edgeFrom.js';
8
+ import { edgeRemovedWith } from '../../graphs/edgeRemovedWith.js';
9
+ import { edgeSource } from '../../graphs/edgeSource.js';
10
+ import { edgeTarget } from '../../graphs/edgeTarget.js';
11
+ import { graph } from '../../graphs/graph.js';
12
+ import { graphKey } from '../../graphs/graphKey.js';
13
+ import { node } from '../../graphs/node.js';
14
+ import { nodeFrom } from '../../graphs/nodeFrom.js';
15
+ import { nodeRemovedWith } from '../../graphs/nodeRemovedWith.js';
16
+ import { setFromContext } from '../../modelBound/setFromContext.js';
17
+ // Decorators are applied as plain function calls so the fixtures do not depend on decorator-syntax support.
18
+ export class PersonRegistered {
19
+ personId = '';
20
+ name = '';
21
+ }
22
+ eventType()(PersonRegistered);
23
+ export class PersonRemoved {
24
+ personId = '';
25
+ }
26
+ eventType()(PersonRemoved);
27
+ export class GroupCreated {
28
+ groupId = '';
29
+ name = '';
30
+ }
31
+ eventType()(GroupCreated);
32
+ export class MemberAdded {
33
+ personId = '';
34
+ groupId = '';
35
+ }
36
+ eventType()(MemberAdded);
37
+ export class MemberRemoved {
38
+ personId = '';
39
+ groupId = '';
40
+ }
41
+ eventType()(MemberRemoved);
42
+ export class Person {
43
+ personId = '';
44
+ name = '';
45
+ }
46
+ graph('Organization')(Person);
47
+ node()(Person);
48
+ graphKey()(Person.prototype, 'personId');
49
+ nodeFrom(PersonRegistered, { key: 'personId' })(Person);
50
+ nodeRemovedWith(PersonRemoved, { key: 'personId', detach: true })(Person);
51
+ export class Group {
52
+ groupId = '';
53
+ name = '';
54
+ }
55
+ graph('Organization')(Group);
56
+ node()(Group);
57
+ graphKey()(Group.prototype, 'groupId');
58
+ nodeFrom(GroupCreated, { key: 'groupId' })(Group);
59
+ export class MemberOf {
60
+ personId = '';
61
+ groupId = '';
62
+ since = new Date();
63
+ }
64
+ field(Date)(MemberOf.prototype, 'since');
65
+ graph('Organization')(MemberOf);
66
+ edge('MEMBER_OF')(MemberOf);
67
+ edgeSource(Person)(MemberOf.prototype, 'personId');
68
+ edgeTarget(Group)(MemberOf.prototype, 'groupId');
69
+ setFromContext(MemberAdded, 'occurred')(MemberOf.prototype, 'since');
70
+ edgeFrom(MemberAdded, { sourceKey: 'personId', targetKey: 'groupId' })(MemberOf);
71
+ edgeRemovedWith(MemberRemoved, { sourceKey: 'personId', targetKey: 'groupId' })(MemberOf);
72
+ /**
73
+ * Creates a provider that finds only the given graph artifacts.
74
+ * @param graphElements - The nodes and edges.
75
+ * @param graphProjections - The fluent graph projections.
76
+ * @returns The provider.
77
+ */
78
+ export function artifactsWith(graphElements, graphProjections = []) {
79
+ return {
80
+ eventTypes: [], readModels: [], reactors: [], reducers: [], seeders: [], constraints: [], projections: [],
81
+ webhooks: [], eventTypeMigrations: [], globalForHandlers: [], graphElements, graphProjections
82
+ };
83
+ }
84
+ //# sourceMappingURL=organization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.js","sourceRoot":"","sources":["../../../../projections/for_Graphs/given/organization.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC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,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AACjD,cAAc,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACrE,QAAQ,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;AACjF,eAAe,CAAC,aAAa,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;AAE1F;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,aAA4B,EAAE,gBAAgB,GAAkB,EAAE;IAC5F,OAAO;QACH,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE;QACzG,QAAQ,EAAE,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE,iBAAiB,EAAE,EAAE,EAAE,aAAa,EAAE,gBAAgB;KAChG,CAAC;AACN,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Error thrown when an edge type has more than one identifying key.
3
+ */
4
+ export declare class EdgeCanHaveOnlyOneIdentifyingKey extends Error {
5
+ /**
6
+ * Creates a new {@link EdgeCanHaveOnlyOneIdentifyingKey}.
7
+ * @param type - The edge type.
8
+ */
9
+ constructor(type: Function);
10
+ }
11
+ //# sourceMappingURL=EdgeCanHaveOnlyOneIdentifyingKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EdgeCanHaveOnlyOneIdentifyingKey.d.ts","sourceRoot":"","sources":["../../../projections/graphs/EdgeCanHaveOnlyOneIdentifyingKey.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,qBAAa,gCAAiC,SAAQ,KAAK;IACvD;;;OAGG;IACH,YAAY,IAAI,EAAE,QAAQ,EAGzB;CACJ"}
@@ -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
+ * Error thrown when an edge type has more than one identifying key.
5
+ */
6
+ export class EdgeCanHaveOnlyOneIdentifyingKey extends Error {
7
+ /**
8
+ * Creates a new {@link EdgeCanHaveOnlyOneIdentifyingKey}.
9
+ * @param type - The edge type.
10
+ */
11
+ constructor(type) {
12
+ super(`The edge type '${type.name}' can have at most one member with the graphKey decorator, the one that identifies the edge.`);
13
+ this.name = 'EdgeCanHaveOnlyOneIdentifyingKey';
14
+ }
15
+ }
16
+ //# sourceMappingURL=EdgeCanHaveOnlyOneIdentifyingKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EdgeCanHaveOnlyOneIdentifyingKey.js","sourceRoot":"","sources":["../../../projections/graphs/EdgeCanHaveOnlyOneIdentifyingKey.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG;;GAEG;AACH,MAAM,OAAO,gCAAiC,SAAQ,KAAK;IACvD;;;OAGG;IACH,YAAY,IAAc;QACtB,KAAK,CAAC,kBAAkB,IAAI,CAAC,IAAI,8FAA8F,CAAC,CAAC;QACjI,IAAI,CAAC,IAAI,GAAG,kCAAkC,CAAC;IACnD,CAAC;CACJ"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Error thrown when an edge type does not name its end nodes.
3
+ */
4
+ export declare class EdgeMustHaveOneSourceAndOneTarget extends Error {
5
+ /**
6
+ * Creates a new {@link EdgeMustHaveOneSourceAndOneTarget}.
7
+ * @param type - The edge type.
8
+ */
9
+ constructor(type: Function);
10
+ }
11
+ //# sourceMappingURL=EdgeMustHaveOneSourceAndOneTarget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EdgeMustHaveOneSourceAndOneTarget.d.ts","sourceRoot":"","sources":["../../../projections/graphs/EdgeMustHaveOneSourceAndOneTarget.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,qBAAa,iCAAkC,SAAQ,KAAK;IACxD;;;OAGG;IACH,YAAY,IAAI,EAAE,QAAQ,EAGzB;CACJ"}
@@ -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
+ * Error thrown when an edge type does not name its end nodes.
5
+ */
6
+ export class EdgeMustHaveOneSourceAndOneTarget extends Error {
7
+ /**
8
+ * Creates a new {@link EdgeMustHaveOneSourceAndOneTarget}.
9
+ * @param type - The edge type.
10
+ */
11
+ constructor(type) {
12
+ super(`The edge type '${type.name}' must have exactly one member with the edgeSource decorator and exactly one with the edgeTarget decorator.`);
13
+ this.name = 'EdgeMustHaveOneSourceAndOneTarget';
14
+ }
15
+ }
16
+ //# sourceMappingURL=EdgeMustHaveOneSourceAndOneTarget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EdgeMustHaveOneSourceAndOneTarget.js","sourceRoot":"","sources":["../../../projections/graphs/EdgeMustHaveOneSourceAndOneTarget.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG;;GAEG;AACH,MAAM,OAAO,iCAAkC,SAAQ,KAAK;IACxD;;;OAGG;IACH,YAAY,IAAc;QACtB,KAAK,CAAC,kBAAkB,IAAI,CAAC,IAAI,6GAA6G,CAAC,CAAC;QAChJ,IAAI,CAAC,IAAI,GAAG,mCAAmC,CAAC;IACpD,CAAC;CACJ"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Error thrown when two declarations produce a graph with the same name.
3
+ */
4
+ export declare class GraphDeclaredMoreThanOnce extends Error {
5
+ /**
6
+ * Creates a new {@link GraphDeclaredMoreThanOnce}.
7
+ * @param graph - The name of the graph.
8
+ */
9
+ constructor(graph: string);
10
+ }
11
+ //# sourceMappingURL=GraphDeclaredMoreThanOnce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphDeclaredMoreThanOnce.d.ts","sourceRoot":"","sources":["../../../projections/graphs/GraphDeclaredMoreThanOnce.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;IAChD;;;OAGG;IACH,YAAY,KAAK,EAAE,MAAM,EAGxB;CACJ"}
@@ -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
+ * Error thrown when two declarations produce a graph with the same name.
5
+ */
6
+ export class GraphDeclaredMoreThanOnce extends Error {
7
+ /**
8
+ * Creates a new {@link GraphDeclaredMoreThanOnce}.
9
+ * @param graph - The name of the graph.
10
+ */
11
+ constructor(graph) {
12
+ super(`The graph '${graph}' is declared by more than one graph projection. A graph is the read model of exactly one projection.`);
13
+ this.name = 'GraphDeclaredMoreThanOnce';
14
+ }
15
+ }
16
+ //# sourceMappingURL=GraphDeclaredMoreThanOnce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphDeclaredMoreThanOnce.js","sourceRoot":"","sources":["../../../projections/graphs/GraphDeclaredMoreThanOnce.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAChD;;;OAGG;IACH,YAAY,KAAa;QACrB,KAAK,CAAC,cAAc,KAAK,uGAAuG,CAAC,CAAC;QAClI,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC5C,CAAC;CACJ"}
@@ -0,0 +1,24 @@
1
+ import type { GraphModel } from './GraphModel.js';
2
+ import type { GraphRegistration } from './GraphRegistration.js';
3
+ /**
4
+ * Turns a {@link GraphModel} into the definitions that are registered with the kernel. The shape follows the
5
+ * .NET client's GraphDefinitionBuilder, so the same graph declared with either client registers the same definition.
6
+ */
7
+ export declare class GraphDefinitionBuilder {
8
+ private readonly _schemaWriter;
9
+ /**
10
+ * Builds the registration of a graph.
11
+ * @param model - The {@link GraphModel}.
12
+ * @param projectionId - The identifier of the projection that fills the graph.
13
+ * @param sinkTypeId - The identifier of the sink type that stores the graph.
14
+ * @returns The {@link GraphRegistration}.
15
+ */
16
+ build(model: GraphModel, projectionId: string, sinkTypeId: string): GraphRegistration;
17
+ private node;
18
+ private edge;
19
+ private eventTypeOf;
20
+ private identity;
21
+ private properties;
22
+ private eventPropertyNamed;
23
+ }
24
+ //# sourceMappingURL=GraphDefinitionBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphDefinitionBuilder.d.ts","sourceRoot":"","sources":["../../../projections/graphs/GraphDefinitionBuilder.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAMhE;;;GAGG;AACH,qBAAa,sBAAsB;IAC/B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA2B;IAEzD;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,iBAAiB,CAiDpF;IAED,OAAO,CAAC,IAAI;IAmBZ,OAAO,CAAC,IAAI;IA0BZ,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,QAAQ;IAOhB,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,kBAAkB;CAM7B"}
@@ -0,0 +1,148 @@
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
+ import { AutoMap, EventGenerationDelivery, ReadModelObserverType } from '@cratis/chronicle.contracts';
4
+ import { EventSequenceId } from '../../eventSequences/EventSequenceId.js';
5
+ import { getEventTypeJsonSchemaFor } from '../../events/eventTypeDecorator.js';
6
+ import { buildReadModelDefinition } from '../../readModels/buildReadModelDefinition.js';
7
+ import { TypeIntrospector } from '../../types/index.js';
8
+ import { toContractEventType } from '../modelBound/childrenAndNestedBuilder.js';
9
+ import { GraphHasDuplicateElement } from './GraphHasDuplicateElement.js';
10
+ import { GraphSchemaWriter } from './GraphSchemaWriter.js';
11
+ import { UnknownGraphEventProperty } from './UnknownGraphEventProperty.js';
12
+ const eventSourceId = '$eventSourceId';
13
+ /**
14
+ * Turns a {@link GraphModel} into the definitions that are registered with the kernel. The shape follows the
15
+ * .NET client's GraphDefinitionBuilder, so the same graph declared with either client registers the same definition.
16
+ */
17
+ export class GraphDefinitionBuilder {
18
+ _schemaWriter = new GraphSchemaWriter();
19
+ /**
20
+ * Builds the registration of a graph.
21
+ * @param model - The {@link GraphModel}.
22
+ * @param projectionId - The identifier of the projection that fills the graph.
23
+ * @param sinkTypeId - The identifier of the sink type that stores the graph.
24
+ * @returns The {@link GraphRegistration}.
25
+ */
26
+ build(model, projectionId, sinkTypeId) {
27
+ const nodes = {};
28
+ for (const node of model.nodes) {
29
+ if (Object.hasOwn(nodes, node.label))
30
+ throw new GraphHasDuplicateElement(model.name, 'node', node.label);
31
+ nodes[node.label] = this.node(node);
32
+ }
33
+ const edges = {};
34
+ for (const edge of model.edges) {
35
+ if (Object.hasOwn(edges, edge.edgeType))
36
+ throw new GraphHasDuplicateElement(model.name, 'edge', edge.edgeType);
37
+ edges[edge.edgeType] = this.edge(edge);
38
+ }
39
+ const projection = {
40
+ EventSequenceId: EventSequenceId.eventLog.value,
41
+ Identifier: projectionId,
42
+ ReadModel: model.name,
43
+ IsActive: true,
44
+ IsRewindable: true,
45
+ InitialModelState: '{}',
46
+ From: [],
47
+ Join: [],
48
+ Children: {},
49
+ FromEvery: [],
50
+ All: { Properties: {}, IncludeChildren: false, AutoMap: AutoMap.Inherit, Key: '' },
51
+ FromEventProperty: undefined,
52
+ RemovedWith: [],
53
+ RemovedWithJoin: [],
54
+ LastUpdated: undefined,
55
+ Tags: [],
56
+ AutoMap: AutoMap.Inherit,
57
+ Nested: {},
58
+ SubscribesToAllEvents: false,
59
+ NoAutoMapProperties: [],
60
+ GenerationDelivery: EventGenerationDelivery.Compatibility,
61
+ Graph: { Nodes: nodes, Edges: edges }
62
+ };
63
+ return {
64
+ graphName: model.name,
65
+ readModel: buildReadModelDefinition({
66
+ identifier: model.name,
67
+ schema: this._schemaWriter.write(model),
68
+ sinkTypeId,
69
+ observerType: ReadModelObserverType.Projection,
70
+ observerIdentifier: projectionId
71
+ }),
72
+ projection
73
+ };
74
+ }
75
+ node(node) {
76
+ const properties = Object.keys(this._schemaWriter.propertiesOf(node.type, []));
77
+ const result = { From: {}, RemovedWith: {} };
78
+ for (const from of node.from) {
79
+ result.From[this.eventTypeOf(from.eventType)] = {
80
+ Key: from.key ?? eventSourceId,
81
+ Properties: this.properties(from.eventType, properties.filter(name => name !== node.keyProperty), from.properties),
82
+ UpdateOnly: from.updateOnly,
83
+ ForEach: ''
84
+ };
85
+ }
86
+ for (const removal of node.removedWith) {
87
+ result.RemovedWith[this.eventTypeOf(removal.eventType)] = { Key: removal.key ?? eventSourceId, Detach: removal.detach, ForEach: '' };
88
+ }
89
+ return result;
90
+ }
91
+ edge(edge) {
92
+ const properties = Object.keys(this._schemaWriter.propertiesOf(edge.type, edge.excludedProperties));
93
+ const result = { From: {}, RemovedWith: {} };
94
+ for (const from of edge.from) {
95
+ result.From[this.eventTypeOf(from.eventType)] = {
96
+ SourceKey: from.sourceKey ?? eventSourceId,
97
+ TargetKey: from.targetKey ?? eventSourceId,
98
+ Identity: this.identity(edge, from.eventType, from.identity),
99
+ Properties: this.properties(from.eventType, properties.filter(name => name !== edge.identifyingProperty), from.properties),
100
+ ForEach: ''
101
+ };
102
+ }
103
+ for (const removal of edge.removedWith) {
104
+ result.RemovedWith[this.eventTypeOf(removal.eventType)] = {
105
+ SourceKey: removal.sourceKey ?? eventSourceId,
106
+ TargetKey: removal.targetKey ?? eventSourceId,
107
+ Identity: this.identity(edge, removal.eventType, removal.identity),
108
+ ForEach: ''
109
+ };
110
+ }
111
+ return result;
112
+ }
113
+ // The kernel keys the event mappings of a graph by the string form of the event type: id+generation.
114
+ eventTypeOf(eventType) {
115
+ const contract = toContractEventType(eventType);
116
+ return `${contract.Id}+${contract.Generation}`;
117
+ }
118
+ identity(edge, eventType, identity) {
119
+ if (edge.identifyingProperty === undefined)
120
+ return '';
121
+ const resolved = identity ?? this.eventPropertyNamed(eventType, edge.identifyingProperty);
122
+ if (resolved === undefined)
123
+ throw new UnknownGraphEventProperty(edge.type, eventType, edge.identifyingProperty);
124
+ return resolved;
125
+ }
126
+ properties(eventType, candidates, explicit) {
127
+ const result = {};
128
+ for (const name of candidates) {
129
+ const expression = explicit[name] ?? this.eventPropertyNamed(eventType, name);
130
+ if (expression !== undefined)
131
+ result[name] = expression;
132
+ }
133
+ for (const [name, expression] of Object.entries(explicit)) {
134
+ if (!Object.hasOwn(result, name))
135
+ result[name] = expression;
136
+ }
137
+ return result;
138
+ }
139
+ // A graph property is mapped from the event property of the same name, unless that one is an object.
140
+ eventPropertyNamed(eventType, graphPropertyName) {
141
+ const schema = getEventTypeJsonSchemaFor(eventType).properties ?? {};
142
+ if (!TypeIntrospector.getMembers(eventType).has(graphPropertyName) && !Object.hasOwn(schema, graphPropertyName))
143
+ return undefined;
144
+ const property = schema[graphPropertyName];
145
+ return property !== undefined && (property.type === 'object' || property.items?.type === 'object') ? undefined : graphPropertyName;
146
+ }
147
+ }
148
+ //# sourceMappingURL=GraphDefinitionBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphDefinitionBuilder.js","sourceRoot":"","sources":["../../../projections/graphs/GraphDefinitionBuilder.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAMtG,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,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AAiB,CAAC;YAAE,OAAO,SAAS,CAAC;QAClI,MAAM,QAAQ,GAA2B,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACnE,OAAO,QAAQ,KAAK,SAAS,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,IAAI,QAAQ,CAAC,KAAK,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC;IACvI,CAAC;CACJ"}
@@ -0,0 +1,41 @@
1
+ import type { Constructor, PropertyAccessor } from '@cratis/fundamentals';
2
+ import type { GraphEdgeModel } from './GraphEdgeModel.js';
3
+ import type { IGraphEdgeBuilder } from './IGraphEdgeBuilder.js';
4
+ import type { IGraphEdgeFromBuilder } from './IGraphEdgeFromBuilder.js';
5
+ import type { IGraphEdgeRemovedWithBuilder } from './IGraphEdgeRemovedWithBuilder.js';
6
+ /**
7
+ * Implements {@link IGraphEdgeBuilder}.
8
+ * @template TEdge - The type of edge.
9
+ */
10
+ export declare class GraphEdgeBuilder<TEdge> implements IGraphEdgeBuilder<TEdge> {
11
+ private readonly _edge;
12
+ private readonly _source;
13
+ private readonly _target;
14
+ private readonly _from;
15
+ private readonly _removedWith;
16
+ private _type?;
17
+ private _identifyingProperty?;
18
+ /**
19
+ * Creates a new {@link GraphEdgeBuilder}.
20
+ * @param _edge - The type of the edge.
21
+ * @param _source - The type of the node the edge starts at.
22
+ * @param _target - The type of the node the edge ends at.
23
+ */
24
+ constructor(_edge: Constructor<TEdge>, _source: Function, _target: Function);
25
+ /** @inheritdoc */
26
+ named(type: string): IGraphEdgeBuilder<TEdge>;
27
+ /** @inheritdoc */
28
+ identifiedBy(identityAccessor: PropertyAccessor<TEdge>): IGraphEdgeBuilder<TEdge>;
29
+ /** @inheritdoc */
30
+ from<TEvent>(eventType: Constructor<TEvent>, configure: (builder: IGraphEdgeFromBuilder<TEdge, TEvent>) => void): IGraphEdgeBuilder<TEdge>;
31
+ /** @inheritdoc */
32
+ removedWith<TEvent>(eventType: Constructor<TEvent>, configure: (builder: IGraphEdgeRemovedWithBuilder<TEvent>) => void): IGraphEdgeBuilder<TEdge>;
33
+ /**
34
+ * Builds the {@link GraphEdgeModel}.
35
+ * @returns The model.
36
+ * @throws {EdgeMustHaveOneSourceAndOneTarget} When the end nodes are not types.
37
+ * @throws {EdgeCanHaveOnlyOneIdentifyingKey} When the type has more than one member with the graphKey decorator.
38
+ */
39
+ build(): GraphEdgeModel;
40
+ }
41
+ //# sourceMappingURL=GraphEdgeBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphEdgeBuilder.d.ts","sourceRoot":"","sources":["../../../projections/graphs/GraphEdgeBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAS1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAI1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAGtF;;;GAGG;AACH,qBAAa,gBAAgB,CAAC,KAAK,CAAE,YAAW,iBAAiB,CAAC,KAAK,CAAC;IAahE,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAd5B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA4B;IAClD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAmC;IAChE,OAAO,CAAC,KAAK,CAAC,CAAS;IACvB,OAAO,CAAC,oBAAoB,CAAC,CAAS;IAEtC;;;;;OAKG;IACH,YACqB,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,EACzB,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,QAAQ,EAClC;IAEJ,kBAAkB;IAClB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAG5C;IAED,kBAAkB;IAClB,YAAY,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAGhF;IAED,kBAAkB;IAClB,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,OAAO,EAAE,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAWzI;IAED,kBAAkB;IAClB,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,OAAO,EAAE,4BAA4B,CAAC,MAAM,CAAC,KAAK,IAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAKhJ;IAED;;;;;OAKG;IACH,KAAK,IAAI,cAAc,CAsBtB;CACJ"}
@@ -0,0 +1,94 @@
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
+ import { TypeIntrospector } from '../../types/index.js';
4
+ import { EdgeCanHaveOnlyOneIdentifyingKey } from './EdgeCanHaveOnlyOneIdentifyingKey.js';
5
+ import { EdgeMustHaveOneSourceAndOneTarget } from './EdgeMustHaveOneSourceAndOneTarget.js';
6
+ import { getEdgeMetadata } from './edge.js';
7
+ import { getEdgeSourceMetadata } from './edgeSource.js';
8
+ import { getEdgeTargetMetadata } from './edgeTarget.js';
9
+ import { GraphEdgeFromBuilder } from './GraphEdgeFromBuilder.js';
10
+ import { GraphEdgeRemovedWithBuilder } from './GraphEdgeRemovedWithBuilder.js';
11
+ import { isGraphKey } from './graphKey.js';
12
+ import { propertyPathOf } from './propertyPathOf.js';
13
+ /**
14
+ * Implements {@link IGraphEdgeBuilder}.
15
+ * @template TEdge - The type of edge.
16
+ */
17
+ export class GraphEdgeBuilder {
18
+ _edge;
19
+ _source;
20
+ _target;
21
+ _from = [];
22
+ _removedWith = [];
23
+ _type;
24
+ _identifyingProperty;
25
+ /**
26
+ * Creates a new {@link GraphEdgeBuilder}.
27
+ * @param _edge - The type of the edge.
28
+ * @param _source - The type of the node the edge starts at.
29
+ * @param _target - The type of the node the edge ends at.
30
+ */
31
+ constructor(_edge, _source, _target) {
32
+ this._edge = _edge;
33
+ this._source = _source;
34
+ this._target = _target;
35
+ }
36
+ /** @inheritdoc */
37
+ named(type) {
38
+ this._type = type;
39
+ return this;
40
+ }
41
+ /** @inheritdoc */
42
+ identifiedBy(identityAccessor) {
43
+ this._identifyingProperty = propertyPathOf(identityAccessor);
44
+ return this;
45
+ }
46
+ /** @inheritdoc */
47
+ from(eventType, configure) {
48
+ const builder = new GraphEdgeFromBuilder();
49
+ configure(builder);
50
+ this._from.push({
51
+ eventType,
52
+ sourceKey: builder.sourceKey,
53
+ targetKey: builder.targetKey,
54
+ identity: builder.identity,
55
+ properties: builder.properties
56
+ });
57
+ return this;
58
+ }
59
+ /** @inheritdoc */
60
+ removedWith(eventType, configure) {
61
+ const builder = new GraphEdgeRemovedWithBuilder();
62
+ configure(builder);
63
+ this._removedWith.push({ eventType, sourceKey: builder.sourceKey, targetKey: builder.targetKey, identity: builder.identity });
64
+ return this;
65
+ }
66
+ /**
67
+ * Builds the {@link GraphEdgeModel}.
68
+ * @returns The model.
69
+ * @throws {EdgeMustHaveOneSourceAndOneTarget} When the end nodes are not types.
70
+ * @throws {EdgeCanHaveOnlyOneIdentifyingKey} When the type has more than one member with the graphKey decorator.
71
+ */
72
+ build() {
73
+ if (typeof this._source !== 'function' || typeof this._target !== 'function') {
74
+ throw new EdgeMustHaveOneSourceAndOneTarget(this._edge);
75
+ }
76
+ const members = TypeIntrospector.getTrackedProperties(this._edge);
77
+ const keys = members.filter(member => isGraphKey(this._edge.prototype, member));
78
+ if (keys.length > 1)
79
+ throw new EdgeCanHaveOnlyOneIdentifyingKey(this._edge);
80
+ return {
81
+ type: this._edge,
82
+ edgeType: this._type ?? getEdgeMetadata(this._edge)?.type ?? this._edge.name,
83
+ sourceNode: this._source,
84
+ targetNode: this._target,
85
+ identifyingProperty: this._identifyingProperty ?? keys[0],
86
+ // The members that hold the keys of the end nodes are not properties of the edge.
87
+ excludedProperties: members.filter(member => getEdgeSourceMetadata(this._edge.prototype, member) !== undefined ||
88
+ getEdgeTargetMetadata(this._edge.prototype, member) !== undefined),
89
+ from: this._from,
90
+ removedWith: this._removedWith
91
+ };
92
+ }
93
+ }
94
+ //# sourceMappingURL=GraphEdgeBuilder.js.map