@cratis/chronicle 6.58.0 → 6.60.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 (384) 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 +2 -2
  6. package/artifacts/DefaultClientArtifactsProvider.ts +13 -1
  7. package/artifacts/IClientArtifactsProvider.ts +6 -0
  8. package/connection/ChronicleConnection.ts +2 -2
  9. package/connection/ChronicleConnectionString.spec.ts +21 -0
  10. package/connection/ChronicleConnectionString.ts +16 -6
  11. package/connection/LeastConnectionsLoadBalancerStrategy.ts +1 -1
  12. package/connection/LoadBalancerStrategyFactory.ts +2 -2
  13. package/connection/TokenProvider.ts +2 -1
  14. package/connection/fetchOAuthAccessToken.ts +3 -3
  15. package/connection/for_ChronicleConnection/when_warning_about_tls_validation/tls_validation_warning.spec.ts +6 -1
  16. package/dist/ChronicleClient.js +1 -1
  17. package/dist/ChronicleClient.js.map +1 -1
  18. package/dist/ChronicleOptions.d.ts +7 -0
  19. package/dist/ChronicleOptions.d.ts.map +1 -1
  20. package/dist/ChronicleOptions.js +8 -0
  21. package/dist/ChronicleOptions.js.map +1 -1
  22. package/dist/EventStore.d.ts +3 -1
  23. package/dist/EventStore.d.ts.map +1 -1
  24. package/dist/EventStore.js +7 -1
  25. package/dist/EventStore.js.map +1 -1
  26. package/dist/IEventStore.d.ts +6 -0
  27. package/dist/IEventStore.d.ts.map +1 -1
  28. package/dist/artifacts/DefaultClientArtifactsProvider.d.ts +4 -0
  29. package/dist/artifacts/DefaultClientArtifactsProvider.d.ts.map +1 -1
  30. package/dist/artifacts/DefaultClientArtifactsProvider.js +11 -1
  31. package/dist/artifacts/DefaultClientArtifactsProvider.js.map +1 -1
  32. package/dist/artifacts/IClientArtifactsProvider.d.ts +4 -0
  33. package/dist/artifacts/IClientArtifactsProvider.d.ts.map +1 -1
  34. package/dist/connection/ChronicleConnection.js +2 -2
  35. package/dist/connection/ChronicleConnection.js.map +1 -1
  36. package/dist/connection/ChronicleConnectionString.d.ts +7 -2
  37. package/dist/connection/ChronicleConnectionString.d.ts.map +1 -1
  38. package/dist/connection/ChronicleConnectionString.js +14 -6
  39. package/dist/connection/ChronicleConnectionString.js.map +1 -1
  40. package/dist/connection/LeastConnectionsLoadBalancerStrategy.d.ts +1 -1
  41. package/dist/connection/LeastConnectionsLoadBalancerStrategy.js +1 -1
  42. package/dist/connection/LoadBalancerStrategyFactory.d.ts +2 -2
  43. package/dist/connection/LoadBalancerStrategyFactory.js +2 -2
  44. package/dist/connection/TokenProvider.d.ts +2 -1
  45. package/dist/connection/TokenProvider.d.ts.map +1 -1
  46. package/dist/connection/TokenProvider.js +2 -1
  47. package/dist/connection/TokenProvider.js.map +1 -1
  48. package/dist/connection/fetchOAuthAccessToken.d.ts +1 -1
  49. package/dist/connection/fetchOAuthAccessToken.js +3 -3
  50. package/dist/connection/fetchOAuthAccessToken.js.map +1 -1
  51. package/dist/projections/Projections.d.ts.map +1 -1
  52. package/dist/projections/Projections.js +3 -30
  53. package/dist/projections/Projections.js.map +1 -1
  54. package/dist/projections/for_Graphs/given/a_discovered_graph.d.ts +29 -0
  55. package/dist/projections/for_Graphs/given/a_discovered_graph.d.ts.map +1 -0
  56. package/dist/projections/for_Graphs/given/a_discovered_graph.js +19 -0
  57. package/dist/projections/for_Graphs/given/a_discovered_graph.js.map +1 -0
  58. package/dist/projections/for_Graphs/given/a_fake_connection.d.ts +24 -0
  59. package/dist/projections/for_Graphs/given/a_fake_connection.d.ts.map +1 -0
  60. package/dist/projections/for_Graphs/given/a_fake_connection.js +17 -0
  61. package/dist/projections/for_Graphs/given/a_fake_connection.js.map +1 -0
  62. package/dist/projections/for_Graphs/given/organization.d.ts +43 -0
  63. package/dist/projections/for_Graphs/given/organization.d.ts.map +1 -0
  64. package/dist/projections/for_Graphs/given/organization.js +84 -0
  65. package/dist/projections/for_Graphs/given/organization.js.map +1 -0
  66. package/dist/projections/graphs/EdgeCanHaveOnlyOneIdentifyingKey.d.ts +11 -0
  67. package/dist/projections/graphs/EdgeCanHaveOnlyOneIdentifyingKey.d.ts.map +1 -0
  68. package/dist/projections/graphs/EdgeCanHaveOnlyOneIdentifyingKey.js +16 -0
  69. package/dist/projections/graphs/EdgeCanHaveOnlyOneIdentifyingKey.js.map +1 -0
  70. package/dist/projections/graphs/EdgeMustHaveOneSourceAndOneTarget.d.ts +11 -0
  71. package/dist/projections/graphs/EdgeMustHaveOneSourceAndOneTarget.d.ts.map +1 -0
  72. package/dist/projections/graphs/EdgeMustHaveOneSourceAndOneTarget.js +16 -0
  73. package/dist/projections/graphs/EdgeMustHaveOneSourceAndOneTarget.js.map +1 -0
  74. package/dist/projections/graphs/GraphDeclaredMoreThanOnce.d.ts +11 -0
  75. package/dist/projections/graphs/GraphDeclaredMoreThanOnce.d.ts.map +1 -0
  76. package/dist/projections/graphs/GraphDeclaredMoreThanOnce.js +16 -0
  77. package/dist/projections/graphs/GraphDeclaredMoreThanOnce.js.map +1 -0
  78. package/dist/projections/graphs/GraphDefinitionBuilder.d.ts +24 -0
  79. package/dist/projections/graphs/GraphDefinitionBuilder.d.ts.map +1 -0
  80. package/dist/projections/graphs/GraphDefinitionBuilder.js +145 -0
  81. package/dist/projections/graphs/GraphDefinitionBuilder.js.map +1 -0
  82. package/dist/projections/graphs/GraphEdgeBuilder.d.ts +41 -0
  83. package/dist/projections/graphs/GraphEdgeBuilder.d.ts.map +1 -0
  84. package/dist/projections/graphs/GraphEdgeBuilder.js +94 -0
  85. package/dist/projections/graphs/GraphEdgeBuilder.js.map +1 -0
  86. package/dist/projections/graphs/GraphEdgeFromBuilder.d.ts +25 -0
  87. package/dist/projections/graphs/GraphEdgeFromBuilder.d.ts.map +1 -0
  88. package/dist/projections/graphs/GraphEdgeFromBuilder.js +37 -0
  89. package/dist/projections/graphs/GraphEdgeFromBuilder.js.map +1 -0
  90. package/dist/projections/graphs/GraphEdgeFromModel.d.ts +16 -0
  91. package/dist/projections/graphs/GraphEdgeFromModel.d.ts.map +1 -0
  92. package/dist/projections/graphs/GraphEdgeFromModel.js +4 -0
  93. package/dist/projections/graphs/GraphEdgeFromModel.js.map +1 -0
  94. package/dist/projections/graphs/GraphEdgeModel.d.ts +24 -0
  95. package/dist/projections/graphs/GraphEdgeModel.d.ts.map +1 -0
  96. package/dist/projections/graphs/GraphEdgeModel.js +4 -0
  97. package/dist/projections/graphs/GraphEdgeModel.js.map +1 -0
  98. package/dist/projections/graphs/GraphEdgeRemovedWithBuilder.d.ts +21 -0
  99. package/dist/projections/graphs/GraphEdgeRemovedWithBuilder.d.ts.map +1 -0
  100. package/dist/projections/graphs/GraphEdgeRemovedWithBuilder.js +31 -0
  101. package/dist/projections/graphs/GraphEdgeRemovedWithBuilder.js.map +1 -0
  102. package/dist/projections/graphs/GraphEdgeRemovedWithModel.d.ts +14 -0
  103. package/dist/projections/graphs/GraphEdgeRemovedWithModel.d.ts.map +1 -0
  104. package/dist/projections/graphs/GraphEdgeRemovedWithModel.js +4 -0
  105. package/dist/projections/graphs/GraphEdgeRemovedWithModel.js.map +1 -0
  106. package/dist/projections/graphs/GraphElementCannotBeReadModel.d.ts +11 -0
  107. package/dist/projections/graphs/GraphElementCannotBeReadModel.d.ts.map +1 -0
  108. package/dist/projections/graphs/GraphElementCannotBeReadModel.js +16 -0
  109. package/dist/projections/graphs/GraphElementCannotBeReadModel.js.map +1 -0
  110. package/dist/projections/graphs/GraphHasDuplicateElement.d.ts +13 -0
  111. package/dist/projections/graphs/GraphHasDuplicateElement.d.ts.map +1 -0
  112. package/dist/projections/graphs/GraphHasDuplicateElement.js +18 -0
  113. package/dist/projections/graphs/GraphHasDuplicateElement.js.map +1 -0
  114. package/dist/projections/graphs/GraphKeyPropertyNotFound.d.ts +12 -0
  115. package/dist/projections/graphs/GraphKeyPropertyNotFound.d.ts.map +1 -0
  116. package/dist/projections/graphs/GraphKeyPropertyNotFound.js +17 -0
  117. package/dist/projections/graphs/GraphKeyPropertyNotFound.js.map +1 -0
  118. package/dist/projections/graphs/GraphMappingBuilder.d.ts +32 -0
  119. package/dist/projections/graphs/GraphMappingBuilder.d.ts.map +1 -0
  120. package/dist/projections/graphs/GraphMappingBuilder.js +48 -0
  121. package/dist/projections/graphs/GraphMappingBuilder.js.map +1 -0
  122. package/dist/projections/graphs/GraphMemberMappings.d.ts +8 -0
  123. package/dist/projections/graphs/GraphMemberMappings.d.ts.map +1 -0
  124. package/dist/projections/graphs/GraphMemberMappings.js +54 -0
  125. package/dist/projections/graphs/GraphMemberMappings.js.map +1 -0
  126. package/dist/projections/graphs/GraphModel.d.ts +15 -0
  127. package/dist/projections/graphs/GraphModel.d.ts.map +1 -0
  128. package/dist/projections/graphs/GraphModel.js +4 -0
  129. package/dist/projections/graphs/GraphModel.js.map +1 -0
  130. package/dist/projections/graphs/GraphNameRequired.d.ts +11 -0
  131. package/dist/projections/graphs/GraphNameRequired.d.ts.map +1 -0
  132. package/dist/projections/graphs/GraphNameRequired.js +16 -0
  133. package/dist/projections/graphs/GraphNameRequired.js.map +1 -0
  134. package/dist/projections/graphs/GraphNodeBuilder.d.ts +34 -0
  135. package/dist/projections/graphs/GraphNodeBuilder.d.ts.map +1 -0
  136. package/dist/projections/graphs/GraphNodeBuilder.js +66 -0
  137. package/dist/projections/graphs/GraphNodeBuilder.js.map +1 -0
  138. package/dist/projections/graphs/GraphNodeFromBuilder.d.ts +21 -0
  139. package/dist/projections/graphs/GraphNodeFromBuilder.d.ts.map +1 -0
  140. package/dist/projections/graphs/GraphNodeFromBuilder.js +30 -0
  141. package/dist/projections/graphs/GraphNodeFromBuilder.js.map +1 -0
  142. package/dist/projections/graphs/GraphNodeFromModel.d.ts +14 -0
  143. package/dist/projections/graphs/GraphNodeFromModel.d.ts.map +1 -0
  144. package/dist/projections/graphs/GraphNodeFromModel.js +4 -0
  145. package/dist/projections/graphs/GraphNodeFromModel.js.map +1 -0
  146. package/dist/projections/graphs/GraphNodeModel.d.ts +18 -0
  147. package/dist/projections/graphs/GraphNodeModel.d.ts.map +1 -0
  148. package/dist/projections/graphs/GraphNodeModel.js +4 -0
  149. package/dist/projections/graphs/GraphNodeModel.js.map +1 -0
  150. package/dist/projections/graphs/GraphNodeRemovedWithBuilder.d.ts +17 -0
  151. package/dist/projections/graphs/GraphNodeRemovedWithBuilder.d.ts.map +1 -0
  152. package/dist/projections/graphs/GraphNodeRemovedWithBuilder.js +24 -0
  153. package/dist/projections/graphs/GraphNodeRemovedWithBuilder.js.map +1 -0
  154. package/dist/projections/graphs/GraphNodeRemovedWithModel.d.ts +12 -0
  155. package/dist/projections/graphs/GraphNodeRemovedWithModel.d.ts.map +1 -0
  156. package/dist/projections/graphs/GraphNodeRemovedWithModel.js +4 -0
  157. package/dist/projections/graphs/GraphNodeRemovedWithModel.js.map +1 -0
  158. package/dist/projections/graphs/GraphProjectionBuilder.d.ts +25 -0
  159. package/dist/projections/graphs/GraphProjectionBuilder.d.ts.map +1 -0
  160. package/dist/projections/graphs/GraphProjectionBuilder.js +36 -0
  161. package/dist/projections/graphs/GraphProjectionBuilder.js.map +1 -0
  162. package/dist/projections/graphs/GraphRegistration.d.ts +14 -0
  163. package/dist/projections/graphs/GraphRegistration.d.ts.map +1 -0
  164. package/dist/projections/graphs/GraphRegistration.js +4 -0
  165. package/dist/projections/graphs/GraphRegistration.js.map +1 -0
  166. package/dist/projections/graphs/GraphSchemaWriter.d.ts +28 -0
  167. package/dist/projections/graphs/GraphSchemaWriter.d.ts.map +1 -0
  168. package/dist/projections/graphs/GraphSchemaWriter.js +76 -0
  169. package/dist/projections/graphs/GraphSchemaWriter.js.map +1 -0
  170. package/dist/projections/graphs/Graphs.d.ts +39 -0
  171. package/dist/projections/graphs/Graphs.d.ts.map +1 -0
  172. package/dist/projections/graphs/Graphs.js +144 -0
  173. package/dist/projections/graphs/Graphs.js.map +1 -0
  174. package/dist/projections/graphs/IGraphEdgeBuilder.d.ts +37 -0
  175. package/dist/projections/graphs/IGraphEdgeBuilder.d.ts.map +1 -0
  176. package/dist/projections/graphs/IGraphEdgeBuilder.js +4 -0
  177. package/dist/projections/graphs/IGraphEdgeBuilder.js.map +1 -0
  178. package/dist/projections/graphs/IGraphEdgeFromBuilder.d.ts +29 -0
  179. package/dist/projections/graphs/IGraphEdgeFromBuilder.d.ts.map +1 -0
  180. package/dist/projections/graphs/IGraphEdgeFromBuilder.js +4 -0
  181. package/dist/projections/graphs/IGraphEdgeFromBuilder.js.map +1 -0
  182. package/dist/projections/graphs/IGraphEdgeRemovedWithBuilder.d.ts +27 -0
  183. package/dist/projections/graphs/IGraphEdgeRemovedWithBuilder.d.ts.map +1 -0
  184. package/dist/projections/graphs/IGraphEdgeRemovedWithBuilder.js +4 -0
  185. package/dist/projections/graphs/IGraphEdgeRemovedWithBuilder.js.map +1 -0
  186. package/dist/projections/graphs/IGraphMappingBuilder.d.ts +49 -0
  187. package/dist/projections/graphs/IGraphMappingBuilder.d.ts.map +1 -0
  188. package/dist/projections/graphs/IGraphMappingBuilder.js +4 -0
  189. package/dist/projections/graphs/IGraphMappingBuilder.js.map +1 -0
  190. package/dist/projections/graphs/IGraphNodeBuilder.d.ts +32 -0
  191. package/dist/projections/graphs/IGraphNodeBuilder.d.ts.map +1 -0
  192. package/dist/projections/graphs/IGraphNodeBuilder.js +4 -0
  193. package/dist/projections/graphs/IGraphNodeBuilder.js.map +1 -0
  194. package/dist/projections/graphs/IGraphNodeFromBuilder.d.ts +21 -0
  195. package/dist/projections/graphs/IGraphNodeFromBuilder.d.ts.map +1 -0
  196. package/dist/projections/graphs/IGraphNodeFromBuilder.js +4 -0
  197. package/dist/projections/graphs/IGraphNodeFromBuilder.js.map +1 -0
  198. package/dist/projections/graphs/IGraphNodeRemovedWithBuilder.d.ts +19 -0
  199. package/dist/projections/graphs/IGraphNodeRemovedWithBuilder.d.ts.map +1 -0
  200. package/dist/projections/graphs/IGraphNodeRemovedWithBuilder.js +4 -0
  201. package/dist/projections/graphs/IGraphNodeRemovedWithBuilder.js.map +1 -0
  202. package/dist/projections/graphs/IGraphProjection.d.ts +13 -0
  203. package/dist/projections/graphs/IGraphProjection.d.ts.map +1 -0
  204. package/dist/projections/graphs/IGraphProjection.js +4 -0
  205. package/dist/projections/graphs/IGraphProjection.js.map +1 -0
  206. package/dist/projections/graphs/IGraphProjectionBuilder.d.ts +26 -0
  207. package/dist/projections/graphs/IGraphProjectionBuilder.d.ts.map +1 -0
  208. package/dist/projections/graphs/IGraphProjectionBuilder.js +4 -0
  209. package/dist/projections/graphs/IGraphProjectionBuilder.js.map +1 -0
  210. package/dist/projections/graphs/IGraphs.d.ts +27 -0
  211. package/dist/projections/graphs/IGraphs.d.ts.map +1 -0
  212. package/dist/projections/graphs/IGraphs.js +4 -0
  213. package/dist/projections/graphs/IGraphs.js.map +1 -0
  214. package/dist/projections/graphs/ModelBoundGraphReader.d.ts +30 -0
  215. package/dist/projections/graphs/ModelBoundGraphReader.d.ts.map +1 -0
  216. package/dist/projections/graphs/ModelBoundGraphReader.js +112 -0
  217. package/dist/projections/graphs/ModelBoundGraphReader.js.map +1 -0
  218. package/dist/projections/graphs/NestedObjectInGraph.d.ts +12 -0
  219. package/dist/projections/graphs/NestedObjectInGraph.d.ts.map +1 -0
  220. package/dist/projections/graphs/NestedObjectInGraph.js +17 -0
  221. package/dist/projections/graphs/NestedObjectInGraph.js.map +1 -0
  222. package/dist/projections/graphs/NodeMustHaveExactlyOneKey.d.ts +12 -0
  223. package/dist/projections/graphs/NodeMustHaveExactlyOneKey.d.ts.map +1 -0
  224. package/dist/projections/graphs/NodeMustHaveExactlyOneKey.js +17 -0
  225. package/dist/projections/graphs/NodeMustHaveExactlyOneKey.js.map +1 -0
  226. package/dist/projections/graphs/UnknownGraphEventProperty.d.ts +13 -0
  227. package/dist/projections/graphs/UnknownGraphEventProperty.d.ts.map +1 -0
  228. package/dist/projections/graphs/UnknownGraphEventProperty.js +18 -0
  229. package/dist/projections/graphs/UnknownGraphEventProperty.js.map +1 -0
  230. package/dist/projections/graphs/UnknownGraphNode.d.ts +12 -0
  231. package/dist/projections/graphs/UnknownGraphNode.d.ts.map +1 -0
  232. package/dist/projections/graphs/UnknownGraphNode.js +17 -0
  233. package/dist/projections/graphs/UnknownGraphNode.js.map +1 -0
  234. package/dist/projections/graphs/edge.d.ts +23 -0
  235. package/dist/projections/graphs/edge.d.ts.map +1 -0
  236. package/dist/projections/graphs/edge.js +29 -0
  237. package/dist/projections/graphs/edge.js.map +1 -0
  238. package/dist/projections/graphs/edgeFrom.d.ts +31 -0
  239. package/dist/projections/graphs/edgeFrom.d.ts.map +1 -0
  240. package/dist/projections/graphs/edgeFrom.js +26 -0
  241. package/dist/projections/graphs/edgeFrom.js.map +1 -0
  242. package/dist/projections/graphs/edgeRemovedWith.d.ts +22 -0
  243. package/dist/projections/graphs/edgeRemovedWith.d.ts.map +1 -0
  244. package/dist/projections/graphs/edgeRemovedWith.js +25 -0
  245. package/dist/projections/graphs/edgeRemovedWith.js.map +1 -0
  246. package/dist/projections/graphs/edgeSource.d.ts +22 -0
  247. package/dist/projections/graphs/edgeSource.d.ts.map +1 -0
  248. package/dist/projections/graphs/edgeSource.js +30 -0
  249. package/dist/projections/graphs/edgeSource.js.map +1 -0
  250. package/dist/projections/graphs/edgeTarget.d.ts +22 -0
  251. package/dist/projections/graphs/edgeTarget.d.ts.map +1 -0
  252. package/dist/projections/graphs/edgeTarget.js +30 -0
  253. package/dist/projections/graphs/edgeTarget.js.map +1 -0
  254. package/dist/projections/graphs/graph.d.ts +16 -0
  255. package/dist/projections/graphs/graph.d.ts.map +1 -0
  256. package/dist/projections/graphs/graph.js +24 -0
  257. package/dist/projections/graphs/graph.js.map +1 -0
  258. package/dist/projections/graphs/graphKey.d.ts +16 -0
  259. package/dist/projections/graphs/graphKey.d.ts.map +1 -0
  260. package/dist/projections/graphs/graphKey.js +28 -0
  261. package/dist/projections/graphs/graphKey.js.map +1 -0
  262. package/dist/projections/graphs/graphProjection.d.ts +21 -0
  263. package/dist/projections/graphs/graphProjection.d.ts.map +1 -0
  264. package/dist/projections/graphs/graphProjection.js +28 -0
  265. package/dist/projections/graphs/graphProjection.js.map +1 -0
  266. package/dist/projections/graphs/index.d.ts +48 -0
  267. package/dist/projections/graphs/index.d.ts.map +1 -0
  268. package/dist/projections/graphs/index.js +27 -0
  269. package/dist/projections/graphs/index.js.map +1 -0
  270. package/dist/projections/graphs/isGraphElement.d.ts +7 -0
  271. package/dist/projections/graphs/isGraphElement.d.ts.map +1 -0
  272. package/dist/projections/graphs/isGraphElement.js +13 -0
  273. package/dist/projections/graphs/isGraphElement.js.map +1 -0
  274. package/dist/projections/graphs/node.d.ts +22 -0
  275. package/dist/projections/graphs/node.d.ts.map +1 -0
  276. package/dist/projections/graphs/node.js +29 -0
  277. package/dist/projections/graphs/node.js.map +1 -0
  278. package/dist/projections/graphs/nodeFrom.d.ts +31 -0
  279. package/dist/projections/graphs/nodeFrom.d.ts.map +1 -0
  280. package/dist/projections/graphs/nodeFrom.js +26 -0
  281. package/dist/projections/graphs/nodeFrom.js.map +1 -0
  282. package/dist/projections/graphs/nodeRemovedWith.d.ts +28 -0
  283. package/dist/projections/graphs/nodeRemovedWith.d.ts.map +1 -0
  284. package/dist/projections/graphs/nodeRemovedWith.js +25 -0
  285. package/dist/projections/graphs/nodeRemovedWith.js.map +1 -0
  286. package/dist/projections/graphs/propertyPathOf.d.ts +8 -0
  287. package/dist/projections/graphs/propertyPathOf.d.ts.map +1 -0
  288. package/dist/projections/graphs/propertyPathOf.js +14 -0
  289. package/dist/projections/graphs/propertyPathOf.js.map +1 -0
  290. package/dist/projections/index.d.ts +1 -0
  291. package/dist/projections/index.d.ts.map +1 -1
  292. package/dist/projections/index.js +1 -0
  293. package/dist/projections/index.js.map +1 -1
  294. package/dist/projections/registerProjectionWithRetry.d.ts +15 -0
  295. package/dist/projections/registerProjectionWithRetry.d.ts.map +1 -0
  296. package/dist/projections/registerProjectionWithRetry.js +44 -0
  297. package/dist/projections/registerProjectionWithRetry.js.map +1 -0
  298. package/dist/readModels/rootReadModelTypes.d.ts.map +1 -1
  299. package/dist/readModels/rootReadModelTypes.js +3 -1
  300. package/dist/readModels/rootReadModelTypes.js.map +1 -1
  301. package/dist/sinks/WellKnownSinks.d.ts +4 -0
  302. package/dist/sinks/WellKnownSinks.d.ts.map +1 -1
  303. package/dist/sinks/WellKnownSinks.js +5 -1
  304. package/dist/sinks/WellKnownSinks.js.map +1 -1
  305. package/dist/tsconfig.tsbuildinfo +1 -1
  306. package/dist/types/DecoratorType.d.ts +5 -1
  307. package/dist/types/DecoratorType.d.ts.map +1 -1
  308. package/dist/types/DecoratorType.js +4 -0
  309. package/dist/types/DecoratorType.js.map +1 -1
  310. package/for_ChronicleOptions/when_configuring_the_graph_sink/with_graph_sink_type.spec.ts +22 -0
  311. package/package.json +3 -3
  312. package/projections/Projections.ts +4 -29
  313. package/projections/for_Graphs/given/a_discovered_graph.ts +21 -0
  314. package/projections/for_Graphs/given/a_fake_connection.ts +19 -0
  315. package/projections/for_Graphs/given/organization.ts +96 -0
  316. package/projections/for_Graphs/when_building_a_fluent_graph.spec.ts +112 -0
  317. package/projections/for_Graphs/when_building_a_model_bound_graph.spec.ts +91 -0
  318. package/projections/for_Graphs/when_declaring_an_edge_with_an_identity.spec.ts +137 -0
  319. package/projections/for_Graphs/when_declaring_an_invalid_graph.spec.ts +199 -0
  320. package/projections/for_Graphs/when_declaring_with_standard_decorators.standard.spec.ts +92 -0
  321. package/projections/for_Graphs/when_discovering_graph_elements.spec.ts +32 -0
  322. package/projections/for_Graphs/when_mapping_properties.spec.ts +159 -0
  323. package/projections/for_Graphs/when_registering_graphs.spec.ts +56 -0
  324. package/projections/graphs/EdgeCanHaveOnlyOneIdentifyingKey.ts +16 -0
  325. package/projections/graphs/EdgeMustHaveOneSourceAndOneTarget.ts +16 -0
  326. package/projections/graphs/GraphDeclaredMoreThanOnce.ts +16 -0
  327. package/projections/graphs/GraphDefinitionBuilder.ts +166 -0
  328. package/projections/graphs/GraphEdgeBuilder.ts +107 -0
  329. package/projections/graphs/GraphEdgeFromBuilder.ts +47 -0
  330. package/projections/graphs/GraphEdgeFromModel.ts +22 -0
  331. package/projections/graphs/GraphEdgeModel.ts +34 -0
  332. package/projections/graphs/GraphEdgeRemovedWithBuilder.ts +39 -0
  333. package/projections/graphs/GraphEdgeRemovedWithModel.ts +19 -0
  334. package/projections/graphs/GraphElementCannotBeReadModel.ts +16 -0
  335. package/projections/graphs/GraphHasDuplicateElement.ts +18 -0
  336. package/projections/graphs/GraphKeyPropertyNotFound.ts +17 -0
  337. package/projections/graphs/GraphMappingBuilder.ts +65 -0
  338. package/projections/graphs/GraphMemberMappings.ts +57 -0
  339. package/projections/graphs/GraphModel.ts +20 -0
  340. package/projections/graphs/GraphNameRequired.ts +16 -0
  341. package/projections/graphs/GraphNodeBuilder.ts +76 -0
  342. package/projections/graphs/GraphNodeFromBuilder.ts +38 -0
  343. package/projections/graphs/GraphNodeFromModel.ts +19 -0
  344. package/projections/graphs/GraphNodeModel.ts +25 -0
  345. package/projections/graphs/GraphNodeRemovedWithBuilder.ts +30 -0
  346. package/projections/graphs/GraphNodeRemovedWithModel.ts +16 -0
  347. package/projections/graphs/GraphProjectionBuilder.ts +52 -0
  348. package/projections/graphs/GraphRegistration.ts +19 -0
  349. package/projections/graphs/GraphSchemaWriter.ts +80 -0
  350. package/projections/graphs/Graphs.ts +165 -0
  351. package/projections/graphs/IGraphEdgeBuilder.ts +43 -0
  352. package/projections/graphs/IGraphEdgeFromBuilder.ts +34 -0
  353. package/projections/graphs/IGraphEdgeRemovedWithBuilder.ts +32 -0
  354. package/projections/graphs/IGraphMappingBuilder.ts +57 -0
  355. package/projections/graphs/IGraphNodeBuilder.ts +37 -0
  356. package/projections/graphs/IGraphNodeFromBuilder.ts +25 -0
  357. package/projections/graphs/IGraphNodeRemovedWithBuilder.ts +23 -0
  358. package/projections/graphs/IGraphProjection.ts +16 -0
  359. package/projections/graphs/IGraphProjectionBuilder.ts +34 -0
  360. package/projections/graphs/IGraphs.ts +33 -0
  361. package/projections/graphs/ModelBoundGraphReader.ts +119 -0
  362. package/projections/graphs/NestedObjectInGraph.ts +17 -0
  363. package/projections/graphs/NodeMustHaveExactlyOneKey.ts +17 -0
  364. package/projections/graphs/UnknownGraphEventProperty.ts +18 -0
  365. package/projections/graphs/UnknownGraphNode.ts +17 -0
  366. package/projections/graphs/edge.ts +40 -0
  367. package/projections/graphs/edgeFrom.ts +48 -0
  368. package/projections/graphs/edgeRemovedWith.ts +36 -0
  369. package/projections/graphs/edgeSource.ts +39 -0
  370. package/projections/graphs/edgeTarget.ts +39 -0
  371. package/projections/graphs/graph.ts +28 -0
  372. package/projections/graphs/graphKey.ts +31 -0
  373. package/projections/graphs/graphProjection.ts +39 -0
  374. package/projections/graphs/index.ts +50 -0
  375. package/projections/graphs/isGraphElement.ts +14 -0
  376. package/projections/graphs/node.ts +40 -0
  377. package/projections/graphs/nodeFrom.ts +48 -0
  378. package/projections/graphs/nodeRemovedWith.ts +44 -0
  379. package/projections/graphs/propertyPathOf.ts +15 -0
  380. package/projections/index.ts +1 -0
  381. package/projections/registerProjectionWithRetry.ts +53 -0
  382. package/readModels/rootReadModelTypes.ts +3 -1
  383. package/sinks/WellKnownSinks.ts +7 -1
  384. package/types/DecoratorType.ts +7 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphProjectionBuilder.d.ts","sourceRoot":"","sources":["../../../projections/graphs/GraphProjectionBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAE5E;;GAEG;AACH,qBAAa,sBAAuB,YAAW,uBAAuB;IAClE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwB;IAC/C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwB;IAE/C,kBAAkB;IAClB,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,KAAK,IAAI,GAAG,uBAAuB,CAKzH;IAED,kBAAkB;IAClB,IAAI,CAAC,KAAK,EACN,QAAQ,EAAE,WAAW,CAAC,KAAK,CAAC,EAC5B,UAAU,EAAE,QAAQ,EACpB,UAAU,EAAE,QAAQ,EACpB,SAAS,EAAE,CAAC,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,KAAK,IAAI,GAAG,uBAAuB,CAKnF;IAED;;;;;OAKG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,GAAG,UAAU,CAG5D;CACJ"}
@@ -0,0 +1,36 @@
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 { GraphEdgeBuilder } from './GraphEdgeBuilder.js';
4
+ import { GraphNodeBuilder } from './GraphNodeBuilder.js';
5
+ /**
6
+ * Implements {@link IGraphProjectionBuilder}, collecting the nodes and edges a graph projection defines.
7
+ */
8
+ export class GraphProjectionBuilder {
9
+ _nodes = [];
10
+ _edges = [];
11
+ /** @inheritdoc */
12
+ node(nodeType, configure) {
13
+ const builder = new GraphNodeBuilder(nodeType);
14
+ configure(builder);
15
+ this._nodes.push(builder.build());
16
+ return this;
17
+ }
18
+ /** @inheritdoc */
19
+ edge(edgeType, sourceType, targetType, configure) {
20
+ const builder = new GraphEdgeBuilder(edgeType, sourceType, targetType);
21
+ configure(builder);
22
+ this._edges.push(builder.build());
23
+ return this;
24
+ }
25
+ /**
26
+ * Builds the {@link GraphModel} of a graph projection.
27
+ * @param name - The name of the graph.
28
+ * @param projection - The graph projection to define the model with.
29
+ * @returns The model.
30
+ */
31
+ build(name, projection) {
32
+ projection.define(this);
33
+ return { name, nodes: this._nodes, edges: this._edges };
34
+ }
35
+ }
36
+ //# sourceMappingURL=GraphProjectionBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphProjectionBuilder.js","sourceRoot":"","sources":["../../../projections/graphs/GraphProjectionBuilder.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAGrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAQzD;;GAEG;AACH,MAAM,OAAO,sBAAsB;IACd,MAAM,GAAqB,EAAE,CAAC;IAC9B,MAAM,GAAqB,EAAE,CAAC;IAE/C,kBAAkB;IAClB,IAAI,CAAQ,QAA4B,EAAE,SAAsD;QAC5F,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAQ,QAAQ,CAAC,CAAC;QACtD,SAAS,CAAC,OAAO,CAAC,CAAC;QACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,kBAAkB;IAClB,IAAI,CACA,QAA4B,EAC5B,UAAoB,EACpB,UAAoB,EACpB,SAAsD;QACtD,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAQ,QAAQ,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;QAC9E,SAAS,CAAC,OAAO,CAAC,CAAC;QACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,IAAY,EAAE,UAA4B;QAC5C,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACxB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5D,CAAC;CACJ"}
@@ -0,0 +1,14 @@
1
+ import type { ProjectionDefinition } from '@cratis/chronicle.contracts';
2
+ import type { buildReadModelDefinition } from '../../readModels/buildReadModelDefinition.js';
3
+ /**
4
+ * Represents everything that is registered for a graph: the read model that describes it and the projection that fills it.
5
+ */
6
+ export interface GraphRegistration {
7
+ /** The name of the graph. */
8
+ readonly graphName: string;
9
+ /** The read model whose schema describes the graph. */
10
+ readonly readModel: ReturnType<typeof buildReadModelDefinition>;
11
+ /** The projection with the graph mappings. */
12
+ readonly projection: ProjectionDefinition;
13
+ }
14
+ //# sourceMappingURL=GraphRegistration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphRegistration.d.ts","sourceRoot":"","sources":["../../../projections/graphs/GraphRegistration.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AAE7F;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,6BAA6B;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,uDAAuD;IACvD,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC;IAEhE,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,oBAAoB,CAAC;CAC7C"}
@@ -0,0 +1,4 @@
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
+ export {};
4
+ //# sourceMappingURL=GraphRegistration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphRegistration.js","sourceRoot":"","sources":["../../../projections/graphs/GraphRegistration.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG"}
@@ -0,0 +1,28 @@
1
+ import { JsonSchema } from '../../schemas/index.js';
2
+ import type { GraphModel } from './GraphModel.js';
3
+ /**
4
+ * Writes the schema form of a graph: an object schema whose properties are the node labels and edge types.
5
+ * This is the form the kernel reads a graph from. The annotations are the ones of the kernel's graph definition.
6
+ */
7
+ export declare class GraphSchemaWriter {
8
+ /**
9
+ * Writes the schema of a graph.
10
+ * @param model - The {@link GraphModel}.
11
+ * @returns The schema as JSON.
12
+ * @throws {NestedObjectInGraph} When a node or an edge has an object property.
13
+ * @throws {UnknownGraphNode} When an edge connects a type that is not a node of the graph.
14
+ */
15
+ write(model: GraphModel): string;
16
+ /**
17
+ * Gets the properties of a node or edge type, as they are named in the graph.
18
+ * @param type - The node or edge type.
19
+ * @param excluded - Names of members that are not properties.
20
+ * @returns The property names with their schemas.
21
+ * @throws {NestedObjectInGraph} When a property is an object.
22
+ */
23
+ propertiesOf(type: Function, excluded: readonly string[]): Record<string, JsonSchema>;
24
+ private element;
25
+ private assertProperty;
26
+ private labelOf;
27
+ }
28
+ //# sourceMappingURL=GraphSchemaWriter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphSchemaWriter.d.ts","sourceRoot":"","sources":["../../../projections/graphs/GraphSchemaWriter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAuB,MAAM,wBAAwB,CAAC;AAEzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD;;;GAGG;AACH,qBAAa,iBAAiB;IAC1B;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAwB/B;IAED;;;;;;OAMG;IACH,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAUpF;IAED,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,OAAO;CAKlB"}
@@ -0,0 +1,76 @@
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 { JsonSchemaGenerator } from '../../schemas/index.js';
4
+ import { GraphKeyPropertyNotFound } from './GraphKeyPropertyNotFound.js';
5
+ import { NestedObjectInGraph } from './NestedObjectInGraph.js';
6
+ import { UnknownGraphNode } from './UnknownGraphNode.js';
7
+ /**
8
+ * Writes the schema form of a graph: an object schema whose properties are the node labels and edge types.
9
+ * This is the form the kernel reads a graph from. The annotations are the ones of the kernel's graph definition.
10
+ */
11
+ export class GraphSchemaWriter {
12
+ /**
13
+ * Writes the schema of a graph.
14
+ * @param model - The {@link GraphModel}.
15
+ * @returns The schema as JSON.
16
+ * @throws {NestedObjectInGraph} When a node or an edge has an object property.
17
+ * @throws {UnknownGraphNode} When an edge connects a type that is not a node of the graph.
18
+ */
19
+ write(model) {
20
+ const properties = {};
21
+ for (const node of model.nodes) {
22
+ this.assertProperty(node.type, node.keyProperty, this.propertiesOf(node.type, []));
23
+ properties[node.label] = {
24
+ ...this.element(node.type, []),
25
+ 'x-graph-kind': 'Node',
26
+ 'x-graph-key': node.keyProperty
27
+ };
28
+ }
29
+ for (const edge of model.edges) {
30
+ const identity = edge.identifyingProperty;
31
+ if (identity !== undefined)
32
+ this.assertProperty(edge.type, identity, this.propertiesOf(edge.type, edge.excludedProperties));
33
+ properties[edge.edgeType] = {
34
+ ...this.element(edge.type, edge.excludedProperties),
35
+ 'x-graph-kind': 'Edge',
36
+ 'x-graph-source': this.labelOf(model, edge.edgeType, edge.sourceNode),
37
+ 'x-graph-target': this.labelOf(model, edge.edgeType, edge.targetNode),
38
+ ...(identity === undefined ? {} : { 'x-graph-identity': identity })
39
+ };
40
+ }
41
+ return JSON.stringify({ type: 'object', title: model.name, 'x-graph': true, properties });
42
+ }
43
+ /**
44
+ * Gets the properties of a node or edge type, as they are named in the graph.
45
+ * @param type - The node or edge type.
46
+ * @param excluded - Names of members that are not properties.
47
+ * @returns The property names with their schemas.
48
+ * @throws {NestedObjectInGraph} When a property is an object.
49
+ */
50
+ propertiesOf(type, excluded) {
51
+ const skip = new Set(excluded.map(name => name.toLowerCase()));
52
+ const result = {};
53
+ for (const [name, property] of Object.entries(JsonSchemaGenerator.generate(type).properties ?? {})) {
54
+ if (skip.has(name.toLowerCase()))
55
+ continue;
56
+ if (property.type === 'object' || property.items?.type === 'object')
57
+ throw new NestedObjectInGraph(type, name);
58
+ result[name] = property;
59
+ }
60
+ return result;
61
+ }
62
+ element(type, excluded) {
63
+ return { type: 'object', properties: this.propertiesOf(type, excluded) };
64
+ }
65
+ assertProperty(type, property, properties) {
66
+ if (!Object.hasOwn(properties, property))
67
+ throw new GraphKeyPropertyNotFound(type, property);
68
+ }
69
+ labelOf(model, edgeType, nodeType) {
70
+ const node = model.nodes.find(candidate => candidate.type === nodeType);
71
+ if (!node)
72
+ throw new UnknownGraphNode(edgeType, nodeType);
73
+ return node.label;
74
+ }
75
+ }
76
+ //# sourceMappingURL=GraphSchemaWriter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphSchemaWriter.js","sourceRoot":"","sources":["../../../projections/graphs/GraphSchemaWriter.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,EAAc,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IAC1B;;;;;;OAMG;IACH,KAAK,CAAC,KAAiB;QACnB,MAAM,UAAU,GAA4B,EAAE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AAE,QAAQ,CAAC,CAAC;IACjG,CAAC;IAEO,OAAO,CAAC,KAAiB,EAAE,QAAgB,EAAE,QAAkB;QACnE,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;CACJ"}
@@ -0,0 +1,39 @@
1
+ import type { Constructor } from '@cratis/fundamentals';
2
+ import type { IClientArtifactsProvider } from '../../artifacts/index.js';
3
+ import type { ChronicleConnection } from '../../connection/index.js';
4
+ import type { GraphRegistration } from './GraphRegistration.js';
5
+ import type { IGraphs } from './IGraphs.js';
6
+ /**
7
+ * Implements {@link IGraphs}, discovering the graphs an application declares, with the decorators and with the fluent
8
+ * builder, and registering them with the Chronicle Kernel.
9
+ */
10
+ export declare class Graphs implements IGraphs {
11
+ private readonly _eventStore;
12
+ private readonly _connection;
13
+ private readonly _clientArtifacts;
14
+ private readonly _graphSinkTypeId;
15
+ private readonly _failures;
16
+ private readonly _logger;
17
+ private _registrations;
18
+ /**
19
+ * Creates a new {@link Graphs} instance.
20
+ * @param _eventStore - The event store name.
21
+ * @param _connection - Chronicle connection.
22
+ * @param _clientArtifacts - Provider for discovered client artifact types.
23
+ * @param _graphSinkTypeId - The identifier of the sink type that stores graphs.
24
+ */
25
+ constructor(_eventStore: string, _connection: ChronicleConnection, _clientArtifacts: IClientArtifactsProvider, _graphSinkTypeId: string);
26
+ /** @inheritdoc */
27
+ get registrations(): readonly GraphRegistration[];
28
+ /** @inheritdoc */
29
+ get failures(): ReadonlyMap<Constructor, Error>;
30
+ /** @inheritdoc */
31
+ discover(): Promise<void>;
32
+ /** @inheritdoc */
33
+ register(): Promise<void>;
34
+ private modelBoundGraphs;
35
+ private fluentGraphs;
36
+ private tryRead;
37
+ private fail;
38
+ }
39
+ //# sourceMappingURL=Graphs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Graphs.d.ts","sourceRoot":"","sources":["../../../projections/graphs/Graphs.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAYrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAY5C;;;GAGG;AACH,qBAAa,MAAO,YAAW,OAAO;IAa9B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IAfrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiC;IAC3D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAC1D,OAAO,CAAC,cAAc,CAAoC;IAE1D;;;;;;OAMG;IACH,YACqB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,mBAAmB,EAChC,gBAAgB,EAAE,wBAAwB,EAC1C,gBAAgB,EAAE,MAAM,EAG5C;IAED,kBAAkB;IAClB,IAAI,aAAa,IAAI,SAAS,iBAAiB,EAAE,CAEhD;IAED,kBAAkB;IAClB,IAAI,QAAQ,IAAI,WAAW,CAAC,WAAW,EAAE,KAAK,CAAC,CAE9C;IAED,kBAAkB;IACZ,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAiB9B;IAED,kBAAkB;IACZ,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAkB9B;IAED,OAAO,CAAC,gBAAgB;IA+BxB,OAAO,CAAC,YAAY;IAapB,OAAO,CAAC,OAAO;IAQf,OAAO,CAAC,IAAI;CAKf"}
@@ -0,0 +1,144 @@
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 { createLogger } from '../../logging/createLogger.js';
4
+ import { getReadModelMetadata } from '../../readModels/readModel.js';
5
+ import { hasFromEventMetadata } from '../modelBound/fromEvent.js';
6
+ import { registerProjectionWithRetry } from '../registerProjectionWithRetry.js';
7
+ import { GraphDeclaredMoreThanOnce } from './GraphDeclaredMoreThanOnce.js';
8
+ import { GraphDefinitionBuilder } from './GraphDefinitionBuilder.js';
9
+ import { GraphElementCannotBeReadModel } from './GraphElementCannotBeReadModel.js';
10
+ import { GraphProjectionBuilder } from './GraphProjectionBuilder.js';
11
+ import { getEdgeMetadata } from './edge.js';
12
+ import { getGraphProjectionMetadata } from './graphProjection.js';
13
+ import { getNodeMetadata } from './node.js';
14
+ import { ModelBoundGraphReader } from './ModelBoundGraphReader.js';
15
+ /**
16
+ * Implements {@link IGraphs}, discovering the graphs an application declares, with the decorators and with the fluent
17
+ * builder, and registering them with the Chronicle Kernel.
18
+ */
19
+ export class Graphs {
20
+ _eventStore;
21
+ _connection;
22
+ _clientArtifacts;
23
+ _graphSinkTypeId;
24
+ _failures = new Map();
25
+ _logger;
26
+ _registrations = [];
27
+ /**
28
+ * Creates a new {@link Graphs} instance.
29
+ * @param _eventStore - The event store name.
30
+ * @param _connection - Chronicle connection.
31
+ * @param _clientArtifacts - Provider for discovered client artifact types.
32
+ * @param _graphSinkTypeId - The identifier of the sink type that stores graphs.
33
+ */
34
+ constructor(_eventStore, _connection, _clientArtifacts, _graphSinkTypeId) {
35
+ this._eventStore = _eventStore;
36
+ this._connection = _connection;
37
+ this._clientArtifacts = _clientArtifacts;
38
+ this._graphSinkTypeId = _graphSinkTypeId;
39
+ this._logger = createLogger('@cratis/chronicle/graphs', _connection.logger);
40
+ }
41
+ /** @inheritdoc */
42
+ get registrations() {
43
+ return this._registrations;
44
+ }
45
+ /** @inheritdoc */
46
+ get failures() {
47
+ return this._failures;
48
+ }
49
+ /** @inheritdoc */
50
+ async discover() {
51
+ this._failures.clear();
52
+ const builder = new GraphDefinitionBuilder();
53
+ const registrations = [];
54
+ const names = new Set();
55
+ for (const declared of [...this.modelBoundGraphs(), ...this.fluentGraphs()]) {
56
+ try {
57
+ if (names.has(declared.model.name))
58
+ throw new GraphDeclaredMoreThanOnce(declared.model.name);
59
+ registrations.push(builder.build(declared.model, declared.projectionId, this._graphSinkTypeId));
60
+ names.add(declared.model.name);
61
+ }
62
+ catch (error) {
63
+ this.fail(declared.source, error);
64
+ }
65
+ }
66
+ this._registrations = registrations;
67
+ this._logger.debug('Graph discovery complete', { graphCount: registrations.length, failureCount: this._failures.size });
68
+ }
69
+ /** @inheritdoc */
70
+ async register() {
71
+ if (this._registrations.length === 0) {
72
+ this._logger.debug('No graphs to register');
73
+ return;
74
+ }
75
+ this._logger.info('Registering graphs', { graphCount: this._registrations.length });
76
+ await this._connection.readModels.registerMany({
77
+ EventStore: this._eventStore,
78
+ Owner: 1,
79
+ ReadModels: this._registrations.map(registration => registration.readModel),
80
+ Source: 1
81
+ });
82
+ for (const registration of this._registrations) {
83
+ await registerProjectionWithRetry(this._connection, this._eventStore, this._logger, registration.projection, registration.projection.Identifier);
84
+ }
85
+ }
86
+ modelBoundGraphs() {
87
+ const reader = new ModelBoundGraphReader();
88
+ const elements = new Map();
89
+ const broken = new Set();
90
+ for (const type of this._clientArtifacts.graphElements ?? []) {
91
+ this.tryRead(type, () => {
92
+ const graph = ModelBoundGraphReader.graphNameOf(type);
93
+ try {
94
+ if (hasFromEventMetadata(type) || getReadModelMetadata(type) !== undefined)
95
+ throw new GraphElementCannotBeReadModel(type);
96
+ const declared = elements.get(graph) ?? { source: type, nodes: [], edges: [] };
97
+ elements.set(graph, declared);
98
+ if (getNodeMetadata(type))
99
+ declared.nodes.push(reader.readNode(type));
100
+ if (getEdgeMetadata(type))
101
+ declared.edges.push(reader.readEdge(type));
102
+ }
103
+ catch (error) {
104
+ // A graph without one of its nodes or edges is not what was declared. A replay would sweep away
105
+ // what the missing element left behind, so the whole graph is left unregistered.
106
+ broken.add(graph);
107
+ throw error;
108
+ }
109
+ });
110
+ }
111
+ return Array.from(elements)
112
+ .filter(([name]) => !broken.has(name))
113
+ .map(([name, declared]) => ({
114
+ source: declared.source,
115
+ model: { name, nodes: declared.nodes, edges: declared.edges },
116
+ projectionId: name
117
+ }));
118
+ }
119
+ fluentGraphs() {
120
+ const result = [];
121
+ for (const type of this._clientArtifacts.graphProjections ?? []) {
122
+ this.tryRead(type, () => {
123
+ const name = getGraphProjectionMetadata(type)?.name ?? type.name;
124
+ const projection = new type();
125
+ result.push({ source: type, model: new GraphProjectionBuilder().build(name, projection), projectionId: type.name });
126
+ });
127
+ }
128
+ return result;
129
+ }
130
+ tryRead(type, read) {
131
+ try {
132
+ read();
133
+ }
134
+ catch (error) {
135
+ this.fail(type, error);
136
+ }
137
+ }
138
+ fail(type, error) {
139
+ const failure = error instanceof Error ? error : new Error(String(error));
140
+ this._failures.set(type, failure);
141
+ this._logger.error('Could not build a graph definition', { type: type.name, error: failure });
142
+ }
143
+ }
144
+ //# sourceMappingURL=Graphs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Graphs.js","sourceRoot":"","sources":["../../../projections/graphs/Graphs.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAKrG,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MA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AK,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACxH,CAAC,CAAC,CAAC;QACP,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAEO,OAAO,CAAC,IAAiB,EAAE,IAAgB;QAC/C,IAAI,CAAC;YACD,IAAI,EAAE,CAAC;QACX,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC3B,CAAC;IACL,CAAC;IAEO,IAAI,CAAC,IAAiB,EAAE,KAAc;QAC1C,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1E,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAClC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAClG,CAAC;CACJ"}
@@ -0,0 +1,37 @@
1
+ import type { Constructor, PropertyAccessor } from '@cratis/fundamentals';
2
+ import type { IGraphEdgeFromBuilder } from './IGraphEdgeFromBuilder.js';
3
+ import type { IGraphEdgeRemovedWithBuilder } from './IGraphEdgeRemovedWithBuilder.js';
4
+ /**
5
+ * Defines a builder for an edge.
6
+ * @template TEdge - The type of edge.
7
+ */
8
+ export interface IGraphEdgeBuilder<TEdge> {
9
+ /**
10
+ * Names the edge type. Not needed when the class of the edge has the edge decorator.
11
+ * @param type - The edge type, for example MEMBER_OF.
12
+ * @returns The builder for continuation.
13
+ */
14
+ named(type: string): IGraphEdgeBuilder<TEdge>;
15
+ /**
16
+ * Declares the property that identifies the edge among edges of the same type between the same two nodes.
17
+ * Not needed when the property has the graphKey decorator.
18
+ * @param identityAccessor - Accessor for the identifying property.
19
+ * @returns The builder for continuation.
20
+ */
21
+ identifiedBy(identityAccessor: PropertyAccessor<TEdge>): IGraphEdgeBuilder<TEdge>;
22
+ /**
23
+ * Creates or updates the edge when an event is observed. Both end nodes are created when they do not exist.
24
+ * @param eventType - The event constructor.
25
+ * @param configure - Callback for the keys of the end nodes and the properties.
26
+ * @returns The builder for continuation.
27
+ */
28
+ from<TEvent>(eventType: Constructor<TEvent>, configure: (builder: IGraphEdgeFromBuilder<TEdge, TEvent>) => void): IGraphEdgeBuilder<TEdge>;
29
+ /**
30
+ * Deletes the edge when an event is observed. The nodes at both ends stay.
31
+ * @param eventType - The event constructor.
32
+ * @param configure - Callback for the keys of the end nodes.
33
+ * @returns The builder for continuation.
34
+ */
35
+ removedWith<TEvent>(eventType: Constructor<TEvent>, configure: (builder: IGraphEdgeRemovedWithBuilder<TEvent>) => void): IGraphEdgeBuilder<TEdge>;
36
+ }
37
+ //# sourceMappingURL=IGraphEdgeBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IGraphEdgeBuilder.d.ts","sourceRoot":"","sources":["../../../projections/graphs/IGraphEdgeBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEtF;;;GAGG;AACH,MAAM,WAAW,iBAAiB,CAAC,KAAK;IACpC;;;;OAIG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAE9C;;;;;OAKG;IACH,YAAY,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAElF;;;;;OAKG;IACH,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,CAAC;IAE3I;;;;;OAKG;IACH,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,CAAC;CACrJ"}
@@ -0,0 +1,4 @@
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
+ export {};
4
+ //# sourceMappingURL=IGraphEdgeBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IGraphEdgeBuilder.js","sourceRoot":"","sources":["../../../projections/graphs/IGraphEdgeBuilder.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG"}
@@ -0,0 +1,29 @@
1
+ import type { PropertyAccessor } from '@cratis/fundamentals';
2
+ import type { IGraphMappingBuilder } from './IGraphMappingBuilder.js';
3
+ /**
4
+ * Defines the builder for how an event creates or updates an edge.
5
+ * @template TEdge - The type of edge.
6
+ * @template TEvent - The type of event.
7
+ */
8
+ export interface IGraphEdgeFromBuilder<TEdge, TEvent> extends IGraphMappingBuilder<TEdge, TEvent, IGraphEdgeFromBuilder<TEdge, TEvent>> {
9
+ /**
10
+ * Takes the key of the source node from a property on the event. By default it is the event source id.
11
+ * @param keyAccessor - Accessor for the event property.
12
+ * @returns The builder for continuation.
13
+ */
14
+ usingSourceKey(keyAccessor: PropertyAccessor<TEvent>): IGraphEdgeFromBuilder<TEdge, TEvent>;
15
+ /**
16
+ * Takes the key of the target node from a property on the event. By default it is the event source id.
17
+ * @param keyAccessor - Accessor for the event property.
18
+ * @returns The builder for continuation.
19
+ */
20
+ usingTargetKey(keyAccessor: PropertyAccessor<TEvent>): IGraphEdgeFromBuilder<TEdge, TEvent>;
21
+ /**
22
+ * Takes the identity of the edge from a property on the event, for an edge type with an identifying property.
23
+ * By default it is the event property named like the identifying property.
24
+ * @param identityAccessor - Accessor for the event property.
25
+ * @returns The builder for continuation.
26
+ */
27
+ usingIdentity(identityAccessor: PropertyAccessor<TEvent>): IGraphEdgeFromBuilder<TEdge, TEvent>;
28
+ }
29
+ //# sourceMappingURL=IGraphEdgeFromBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IGraphEdgeFromBuilder.d.ts","sourceRoot":"","sources":["../../../projections/graphs/IGraphEdgeFromBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEtE;;;;GAIG;AACH,MAAM,WAAW,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAE,SAAQ,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACnI;;;;OAIG;IACH,cAAc,CAAC,WAAW,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAE5F;;;;OAIG;IACH,cAAc,CAAC,WAAW,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAE5F;;;;;OAKG;IACH,aAAa,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CACnG"}
@@ -0,0 +1,4 @@
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
+ export {};
4
+ //# sourceMappingURL=IGraphEdgeFromBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IGraphEdgeFromBuilder.js","sourceRoot":"","sources":["../../../projections/graphs/IGraphEdgeFromBuilder.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG"}
@@ -0,0 +1,27 @@
1
+ import type { PropertyAccessor } from '@cratis/fundamentals';
2
+ /**
3
+ * Defines the builder for how an event deletes an edge.
4
+ * @template TEvent - The type of event.
5
+ */
6
+ export interface IGraphEdgeRemovedWithBuilder<TEvent> {
7
+ /**
8
+ * Takes the key of the source node from a property on the event. By default it is the event source id.
9
+ * @param keyAccessor - Accessor for the event property.
10
+ * @returns The builder for continuation.
11
+ */
12
+ usingSourceKey(keyAccessor: PropertyAccessor<TEvent>): IGraphEdgeRemovedWithBuilder<TEvent>;
13
+ /**
14
+ * Takes the key of the target 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
+ usingTargetKey(keyAccessor: PropertyAccessor<TEvent>): IGraphEdgeRemovedWithBuilder<TEvent>;
19
+ /**
20
+ * Takes the identity of the edge from a property on the event, for an edge type with an identifying property.
21
+ * By default it is the event property named like the identifying property.
22
+ * @param identityAccessor - Accessor for the event property.
23
+ * @returns The builder for continuation.
24
+ */
25
+ usingIdentity(identityAccessor: PropertyAccessor<TEvent>): IGraphEdgeRemovedWithBuilder<TEvent>;
26
+ }
27
+ //# sourceMappingURL=IGraphEdgeRemovedWithBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IGraphEdgeRemovedWithBuilder.d.ts","sourceRoot":"","sources":["../../../projections/graphs/IGraphEdgeRemovedWithBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D;;;GAGG;AACH,MAAM,WAAW,4BAA4B,CAAC,MAAM;IAChD;;;;OAIG;IACH,cAAc,CAAC,WAAW,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,4BAA4B,CAAC,MAAM,CAAC,CAAC;IAE5F;;;;OAIG;IACH,cAAc,CAAC,WAAW,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,4BAA4B,CAAC,MAAM,CAAC,CAAC;IAE5F;;;;;OAKG;IACH,aAAa,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,4BAA4B,CAAC,MAAM,CAAC,CAAC;CACnG"}
@@ -0,0 +1,4 @@
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
+ export {};
4
+ //# sourceMappingURL=IGraphEdgeRemovedWithBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IGraphEdgeRemovedWithBuilder.js","sourceRoot":"","sources":["../../../projections/graphs/IGraphEdgeRemovedWithBuilder.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG"}
@@ -0,0 +1,49 @@
1
+ import type { PropertyAccessor } from '@cratis/fundamentals';
2
+ import type { IAddBuilder } from '../declarative/IAddBuilder.js';
3
+ import type { ISetBuilder } from '../declarative/ISetBuilder.js';
4
+ import type { ISubtractBuilder } from '../declarative/ISubtractBuilder.js';
5
+ /**
6
+ * Defines the property mappings shared by nodes and edges.
7
+ * @template TElement - The type of the node or edge.
8
+ * @template TEvent - The type of event.
9
+ * @template TSelf - The type of the builder, for continuation.
10
+ */
11
+ export interface IGraphMappingBuilder<TElement, TEvent, TSelf> {
12
+ /**
13
+ * Sets a property.
14
+ * @param propertyAccessor - Accessor for the property on the node or edge.
15
+ * @returns The builder for what to set it to.
16
+ */
17
+ set(propertyAccessor: PropertyAccessor<TElement>): ISetBuilder<TEvent, TSelf>;
18
+ /**
19
+ * Adds the value of an event property to a counter property.
20
+ * @param propertyAccessor - Accessor for the counter property.
21
+ * @returns The builder for which event property to add.
22
+ */
23
+ add(propertyAccessor: PropertyAccessor<TElement>): IAddBuilder<TEvent, TSelf>;
24
+ /**
25
+ * Subtracts the value of an event property from a counter property.
26
+ * @param propertyAccessor - Accessor for the counter property.
27
+ * @returns The builder for which event property to subtract.
28
+ */
29
+ subtract(propertyAccessor: PropertyAccessor<TElement>): ISubtractBuilder<TEvent, TSelf>;
30
+ /**
31
+ * Increments a counter property by one.
32
+ * @param propertyAccessor - Accessor for the counter property.
33
+ * @returns The builder for continuation.
34
+ */
35
+ increment(propertyAccessor: PropertyAccessor<TElement>): TSelf;
36
+ /**
37
+ * Decrements a counter property by one.
38
+ * @param propertyAccessor - Accessor for the counter property.
39
+ * @returns The builder for continuation.
40
+ */
41
+ decrement(propertyAccessor: PropertyAccessor<TElement>): TSelf;
42
+ /**
43
+ * Counts the events on a counter property.
44
+ * @param propertyAccessor - Accessor for the counter property.
45
+ * @returns The builder for continuation.
46
+ */
47
+ count(propertyAccessor: PropertyAccessor<TElement>): TSelf;
48
+ }
49
+ //# sourceMappingURL=IGraphMappingBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IGraphMappingBuilder.d.ts","sourceRoot":"","sources":["../../../projections/graphs/IGraphMappingBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK;IACzD;;;;OAIG;IACH,GAAG,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAE9E;;;;OAIG;IACH,GAAG,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAE9E;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GAAG,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAExF;;;;OAIG;IACH,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;IAE/D;;;;OAIG;IACH,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;IAE/D;;;;OAIG;IACH,KAAK,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;CAC9D"}
@@ -0,0 +1,4 @@
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
+ export {};
4
+ //# sourceMappingURL=IGraphMappingBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IGraphMappingBuilder.js","sourceRoot":"","sources":["../../../projections/graphs/IGraphMappingBuilder.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG"}
@@ -0,0 +1,32 @@
1
+ import type { Constructor } from '@cratis/fundamentals';
2
+ import type { PropertyAccessor } from '@cratis/fundamentals';
3
+ import type { IGraphNodeFromBuilder } from './IGraphNodeFromBuilder.js';
4
+ import type { IGraphNodeRemovedWithBuilder } from './IGraphNodeRemovedWithBuilder.js';
5
+ /**
6
+ * Defines a builder for a node.
7
+ * @template TNode - The type of node.
8
+ */
9
+ export interface IGraphNodeBuilder<TNode> {
10
+ /**
11
+ * Declares the property that holds the unique key of the node. Not needed when the property has the graphKey decorator.
12
+ * @param keyAccessor - Accessor for the key property.
13
+ * @returns The builder for continuation.
14
+ */
15
+ identifiedBy(keyAccessor: PropertyAccessor<TNode>): IGraphNodeBuilder<TNode>;
16
+ /**
17
+ * Creates or updates the node when an event is observed.
18
+ * @param eventType - The event constructor.
19
+ * @param configure - Optional callback for the key and the properties. By default the key is the event source id
20
+ * and properties are mapped by name.
21
+ * @returns The builder for continuation.
22
+ */
23
+ from<TEvent>(eventType: Constructor<TEvent>, configure?: (builder: IGraphNodeFromBuilder<TNode, TEvent>) => void): IGraphNodeBuilder<TNode>;
24
+ /**
25
+ * Deletes the node when an event is observed.
26
+ * @param eventType - The event constructor.
27
+ * @param configure - Optional callback for the key and for detaching. By default the key is the event source id.
28
+ * @returns The builder for continuation.
29
+ */
30
+ removedWith<TEvent>(eventType: Constructor<TEvent>, configure?: (builder: IGraphNodeRemovedWithBuilder<TEvent>) => void): IGraphNodeBuilder<TNode>;
31
+ }
32
+ //# sourceMappingURL=IGraphNodeBuilder.d.ts.map