@cratis/chronicle 6.63.0 → 6.65.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 (411) hide show
  1. package/README.md +1 -1
  2. package/artifacts/DefaultClientArtifactsProvider.ts +5 -0
  3. package/artifacts/IClientArtifactsProvider.ts +3 -0
  4. package/connection/ChronicleConnection.ts +17 -7
  5. package/connection/ChronicleConnectionString.spec.ts +85 -0
  6. package/connection/ChronicleConnectionString.ts +186 -12
  7. package/connection/ChronicleTlsMaterial.spec.ts +160 -0
  8. package/connection/ChronicleTlsMaterial.ts +121 -0
  9. package/connection/CompatibilityPreflight.ts +9 -1
  10. package/connection/LeastConnectionsLoadBalancerStrategy.ts +4 -2
  11. package/connection/LoadBalancerStrategyFactory.ts +7 -2
  12. package/connection/TokenProvider.ts +4 -1
  13. package/connection/fetchOAuthAccessToken.ts +4 -2
  14. package/connection/for_CompatibilityPreflight/when_verifying/with_the_check_skipped.spec.ts +23 -0
  15. package/dist/artifacts/DefaultClientArtifactsProvider.d.ts +2 -0
  16. package/dist/artifacts/DefaultClientArtifactsProvider.d.ts.map +1 -1
  17. package/dist/artifacts/DefaultClientArtifactsProvider.js +4 -0
  18. package/dist/artifacts/DefaultClientArtifactsProvider.js.map +1 -1
  19. package/dist/artifacts/IClientArtifactsProvider.d.ts +2 -0
  20. package/dist/artifacts/IClientArtifactsProvider.d.ts.map +1 -1
  21. package/dist/connection/ChronicleConnection.d.ts +1 -0
  22. package/dist/connection/ChronicleConnection.d.ts.map +1 -1
  23. package/dist/connection/ChronicleConnection.js +15 -7
  24. package/dist/connection/ChronicleConnection.js.map +1 -1
  25. package/dist/connection/ChronicleConnectionString.d.ts +50 -1
  26. package/dist/connection/ChronicleConnectionString.d.ts.map +1 -1
  27. package/dist/connection/ChronicleConnectionString.js +154 -12
  28. package/dist/connection/ChronicleConnectionString.js.map +1 -1
  29. package/dist/connection/ChronicleTlsMaterial.d.ts +54 -0
  30. package/dist/connection/ChronicleTlsMaterial.d.ts.map +1 -0
  31. package/dist/connection/ChronicleTlsMaterial.js +88 -0
  32. package/dist/connection/ChronicleTlsMaterial.js.map +1 -0
  33. package/dist/connection/CompatibilityPreflight.d.ts +2 -1
  34. package/dist/connection/CompatibilityPreflight.d.ts.map +1 -1
  35. package/dist/connection/CompatibilityPreflight.js +6 -1
  36. package/dist/connection/CompatibilityPreflight.js.map +1 -1
  37. package/dist/connection/LeastConnectionsLoadBalancerStrategy.d.ts +2 -1
  38. package/dist/connection/LeastConnectionsLoadBalancerStrategy.d.ts.map +1 -1
  39. package/dist/connection/LeastConnectionsLoadBalancerStrategy.js +3 -2
  40. package/dist/connection/LeastConnectionsLoadBalancerStrategy.js.map +1 -1
  41. package/dist/connection/LoadBalancerStrategyFactory.d.ts +2 -1
  42. package/dist/connection/LoadBalancerStrategyFactory.d.ts.map +1 -1
  43. package/dist/connection/LoadBalancerStrategyFactory.js +3 -2
  44. package/dist/connection/LoadBalancerStrategyFactory.js.map +1 -1
  45. package/dist/connection/TokenProvider.d.ts +4 -1
  46. package/dist/connection/TokenProvider.d.ts.map +1 -1
  47. package/dist/connection/TokenProvider.js +5 -1
  48. package/dist/connection/TokenProvider.js.map +1 -1
  49. package/dist/connection/fetchOAuthAccessToken.d.ts +2 -1
  50. package/dist/connection/fetchOAuthAccessToken.d.ts.map +1 -1
  51. package/dist/connection/fetchOAuthAccessToken.js +3 -2
  52. package/dist/connection/fetchOAuthAccessToken.js.map +1 -1
  53. package/dist/projections/for_Graphs/given/a_discovered_graph.d.ts +2 -1
  54. package/dist/projections/for_Graphs/given/a_discovered_graph.d.ts.map +1 -1
  55. package/dist/projections/for_Graphs/given/a_discovered_graph.js +3 -2
  56. package/dist/projections/for_Graphs/given/a_discovered_graph.js.map +1 -1
  57. package/dist/projections/for_Graphs/given/a_graph_with_views.d.ts +40 -0
  58. package/dist/projections/for_Graphs/given/a_graph_with_views.d.ts.map +1 -0
  59. package/dist/projections/for_Graphs/given/a_graph_with_views.js +80 -0
  60. package/dist/projections/for_Graphs/given/a_graph_with_views.js.map +1 -0
  61. package/dist/projections/for_Graphs/given/organization.d.ts +2 -1
  62. package/dist/projections/for_Graphs/given/organization.d.ts.map +1 -1
  63. package/dist/projections/for_Graphs/given/organization.js +3 -2
  64. package/dist/projections/for_Graphs/given/organization.js.map +1 -1
  65. package/dist/projections/graphs/Graphs.d.ts +5 -0
  66. package/dist/projections/graphs/Graphs.d.ts.map +1 -1
  67. package/dist/projections/graphs/Graphs.js +43 -0
  68. package/dist/projections/graphs/Graphs.js.map +1 -1
  69. package/dist/projections/graphs/IGraphs.d.ts +9 -2
  70. package/dist/projections/graphs/IGraphs.d.ts.map +1 -1
  71. package/dist/projections/graphs/index.d.ts +1 -0
  72. package/dist/projections/graphs/index.d.ts.map +1 -1
  73. package/dist/projections/graphs/index.js +1 -0
  74. package/dist/projections/graphs/index.js.map +1 -1
  75. package/dist/projections/graphs/views/AmbiguousDirection.d.ts +16 -0
  76. package/dist/projections/graphs/views/AmbiguousDirection.d.ts.map +1 -0
  77. package/dist/projections/graphs/views/AmbiguousDirection.js +21 -0
  78. package/dist/projections/graphs/views/AmbiguousDirection.js.map +1 -0
  79. package/dist/projections/graphs/views/DuplicateViewName.d.ts +16 -0
  80. package/dist/projections/graphs/views/DuplicateViewName.d.ts.map +1 -0
  81. package/dist/projections/graphs/views/DuplicateViewName.js +21 -0
  82. package/dist/projections/graphs/views/DuplicateViewName.js.map +1 -0
  83. package/dist/projections/graphs/views/EdgeNotIncidentOnRoot.d.ts +17 -0
  84. package/dist/projections/graphs/views/EdgeNotIncidentOnRoot.d.ts.map +1 -0
  85. package/dist/projections/graphs/views/EdgeNotIncidentOnRoot.js +22 -0
  86. package/dist/projections/graphs/views/EdgeNotIncidentOnRoot.js.map +1 -0
  87. package/dist/projections/graphs/views/EdgePropertyViewNotUsedAsTarget.d.ts +14 -0
  88. package/dist/projections/graphs/views/EdgePropertyViewNotUsedAsTarget.d.ts.map +1 -0
  89. package/dist/projections/graphs/views/EdgePropertyViewNotUsedAsTarget.js +19 -0
  90. package/dist/projections/graphs/views/EdgePropertyViewNotUsedAsTarget.js.map +1 -0
  91. package/dist/projections/graphs/views/EdgePropertyViewSharedAcrossEdges.d.ts +15 -0
  92. package/dist/projections/graphs/views/EdgePropertyViewSharedAcrossEdges.d.ts.map +1 -0
  93. package/dist/projections/graphs/views/EdgePropertyViewSharedAcrossEdges.js +20 -0
  94. package/dist/projections/graphs/views/EdgePropertyViewSharedAcrossEdges.js.map +1 -0
  95. package/dist/projections/graphs/views/FollowsOptions.d.ts +16 -0
  96. package/dist/projections/graphs/views/FollowsOptions.d.ts.map +1 -0
  97. package/dist/projections/graphs/views/FollowsOptions.js +4 -0
  98. package/dist/projections/graphs/views/FollowsOptions.js.map +1 -0
  99. package/dist/projections/graphs/views/GraphEdgeDirection.d.ts +10 -0
  100. package/dist/projections/graphs/views/GraphEdgeDirection.d.ts.map +1 -0
  101. package/dist/projections/graphs/views/GraphEdgeDirection.js +13 -0
  102. package/dist/projections/graphs/views/GraphEdgeDirection.js.map +1 -0
  103. package/dist/projections/graphs/views/GraphView.d.ts +13 -0
  104. package/dist/projections/graphs/views/GraphView.d.ts.map +1 -0
  105. package/dist/projections/graphs/views/GraphView.js +4 -0
  106. package/dist/projections/graphs/views/GraphView.js.map +1 -0
  107. package/dist/projections/graphs/views/GraphViewBuildResult.d.ts +15 -0
  108. package/dist/projections/graphs/views/GraphViewBuildResult.d.ts.map +1 -0
  109. package/dist/projections/graphs/views/GraphViewBuildResult.js +4 -0
  110. package/dist/projections/graphs/views/GraphViewBuildResult.js.map +1 -0
  111. package/dist/projections/graphs/views/GraphViewCardinality.d.ts +10 -0
  112. package/dist/projections/graphs/views/GraphViewCardinality.d.ts.map +1 -0
  113. package/dist/projections/graphs/views/GraphViewCardinality.js +13 -0
  114. package/dist/projections/graphs/views/GraphViewCardinality.js.map +1 -0
  115. package/dist/projections/graphs/views/GraphViewDefinition.d.ts +15 -0
  116. package/dist/projections/graphs/views/GraphViewDefinition.d.ts.map +1 -0
  117. package/dist/projections/graphs/views/GraphViewDefinition.js +4 -0
  118. package/dist/projections/graphs/views/GraphViewDefinition.js.map +1 -0
  119. package/dist/projections/graphs/views/GraphViewDefinitionBuilder.d.ts +30 -0
  120. package/dist/projections/graphs/views/GraphViewDefinitionBuilder.d.ts.map +1 -0
  121. package/dist/projections/graphs/views/GraphViewDefinitionBuilder.js +259 -0
  122. package/dist/projections/graphs/views/GraphViewDefinitionBuilder.js.map +1 -0
  123. package/dist/projections/graphs/views/GraphViewDefinitionSerializer.d.ts +21 -0
  124. package/dist/projections/graphs/views/GraphViewDefinitionSerializer.d.ts.map +1 -0
  125. package/dist/projections/graphs/views/GraphViewDefinitionSerializer.js +77 -0
  126. package/dist/projections/graphs/views/GraphViewDefinitionSerializer.js.map +1 -0
  127. package/dist/projections/graphs/views/GraphViewEdgeReference.d.ts +6 -0
  128. package/dist/projections/graphs/views/GraphViewEdgeReference.d.ts.map +1 -0
  129. package/dist/projections/graphs/views/GraphViewEdgeReference.js +4 -0
  130. package/dist/projections/graphs/views/GraphViewEdgeReference.js.map +1 -0
  131. package/dist/projections/graphs/views/GraphViewMember.d.ts +8 -0
  132. package/dist/projections/graphs/views/GraphViewMember.d.ts.map +1 -0
  133. package/dist/projections/graphs/views/GraphViewMember.js +4 -0
  134. package/dist/projections/graphs/views/GraphViewMember.js.map +1 -0
  135. package/dist/projections/graphs/views/GraphViewMemberKind.d.ts +12 -0
  136. package/dist/projections/graphs/views/GraphViewMemberKind.d.ts.map +1 -0
  137. package/dist/projections/graphs/views/GraphViewMemberKind.js +15 -0
  138. package/dist/projections/graphs/views/GraphViewMemberKind.js.map +1 -0
  139. package/dist/projections/graphs/views/GraphViewMemberMetadata.d.ts +22 -0
  140. package/dist/projections/graphs/views/GraphViewMemberMetadata.d.ts.map +1 -0
  141. package/dist/projections/graphs/views/GraphViewMemberMetadata.js +4 -0
  142. package/dist/projections/graphs/views/GraphViewMemberMetadata.js.map +1 -0
  143. package/dist/projections/graphs/views/GraphViewPropertyMember.d.ts +13 -0
  144. package/dist/projections/graphs/views/GraphViewPropertyMember.d.ts.map +1 -0
  145. package/dist/projections/graphs/views/GraphViewPropertyMember.js +4 -0
  146. package/dist/projections/graphs/views/GraphViewPropertyMember.js.map +1 -0
  147. package/dist/projections/graphs/views/GraphViewReason.d.ts +33 -0
  148. package/dist/projections/graphs/views/GraphViewReason.d.ts.map +1 -0
  149. package/dist/projections/graphs/views/GraphViewReason.js +36 -0
  150. package/dist/projections/graphs/views/GraphViewReason.js.map +1 -0
  151. package/dist/projections/graphs/views/GraphViewRelationMember.d.ts +21 -0
  152. package/dist/projections/graphs/views/GraphViewRelationMember.d.ts.map +1 -0
  153. package/dist/projections/graphs/views/GraphViewRelationMember.js +4 -0
  154. package/dist/projections/graphs/views/GraphViewRelationMember.js.map +1 -0
  155. package/dist/projections/graphs/views/GraphViewSchema.d.ts +10 -0
  156. package/dist/projections/graphs/views/GraphViewSchema.d.ts.map +1 -0
  157. package/dist/projections/graphs/views/GraphViewSchema.js +4 -0
  158. package/dist/projections/graphs/views/GraphViewSchema.js.map +1 -0
  159. package/dist/projections/graphs/views/GraphViewSchemaEdge.d.ts +14 -0
  160. package/dist/projections/graphs/views/GraphViewSchemaEdge.d.ts.map +1 -0
  161. package/dist/projections/graphs/views/GraphViewSchemaEdge.js +4 -0
  162. package/dist/projections/graphs/views/GraphViewSchemaEdge.js.map +1 -0
  163. package/dist/projections/graphs/views/GraphViewSchemaNode.d.ts +10 -0
  164. package/dist/projections/graphs/views/GraphViewSchemaNode.d.ts.map +1 -0
  165. package/dist/projections/graphs/views/GraphViewSchemaNode.js +4 -0
  166. package/dist/projections/graphs/views/GraphViewSchemaNode.js.map +1 -0
  167. package/dist/projections/graphs/views/GraphViewSerializerOptions.d.ts +9 -0
  168. package/dist/projections/graphs/views/GraphViewSerializerOptions.d.ts.map +1 -0
  169. package/dist/projections/graphs/views/GraphViewSerializerOptions.js +4 -0
  170. package/dist/projections/graphs/views/GraphViewSerializerOptions.js.map +1 -0
  171. package/dist/projections/graphs/views/RecursiveView.d.ts +15 -0
  172. package/dist/projections/graphs/views/RecursiveView.d.ts.map +1 -0
  173. package/dist/projections/graphs/views/RecursiveView.js +20 -0
  174. package/dist/projections/graphs/views/RecursiveView.js.map +1 -0
  175. package/dist/projections/graphs/views/RelationTargetNotAView.d.ts +16 -0
  176. package/dist/projections/graphs/views/RelationTargetNotAView.d.ts.map +1 -0
  177. package/dist/projections/graphs/views/RelationTargetNotAView.js +21 -0
  178. package/dist/projections/graphs/views/RelationTargetNotAView.js.map +1 -0
  179. package/dist/projections/graphs/views/TargetLabelMismatch.d.ts +18 -0
  180. package/dist/projections/graphs/views/TargetLabelMismatch.d.ts.map +1 -0
  181. package/dist/projections/graphs/views/TargetLabelMismatch.js +23 -0
  182. package/dist/projections/graphs/views/TargetLabelMismatch.js.map +1 -0
  183. package/dist/projections/graphs/views/UnknownEdge.d.ts +16 -0
  184. package/dist/projections/graphs/views/UnknownEdge.d.ts.map +1 -0
  185. package/dist/projections/graphs/views/UnknownEdge.js +21 -0
  186. package/dist/projections/graphs/views/UnknownEdge.js.map +1 -0
  187. package/dist/projections/graphs/views/UnknownEdgeProperty.d.ts +17 -0
  188. package/dist/projections/graphs/views/UnknownEdgeProperty.d.ts.map +1 -0
  189. package/dist/projections/graphs/views/UnknownEdgeProperty.js +22 -0
  190. package/dist/projections/graphs/views/UnknownEdgeProperty.js.map +1 -0
  191. package/dist/projections/graphs/views/UnknownNodeProperty.d.ts +17 -0
  192. package/dist/projections/graphs/views/UnknownNodeProperty.d.ts.map +1 -0
  193. package/dist/projections/graphs/views/UnknownNodeProperty.js +22 -0
  194. package/dist/projections/graphs/views/UnknownNodeProperty.js.map +1 -0
  195. package/dist/projections/graphs/views/ViewIsAlsoSchema.d.ts +14 -0
  196. package/dist/projections/graphs/views/ViewIsAlsoSchema.d.ts.map +1 -0
  197. package/dist/projections/graphs/views/ViewIsAlsoSchema.js +19 -0
  198. package/dist/projections/graphs/views/ViewIsAlsoSchema.js.map +1 -0
  199. package/dist/projections/graphs/views/ViewOfMetadata.d.ts +8 -0
  200. package/dist/projections/graphs/views/ViewOfMetadata.d.ts.map +1 -0
  201. package/dist/projections/graphs/views/ViewOfMetadata.js +4 -0
  202. package/dist/projections/graphs/views/ViewOfMetadata.js.map +1 -0
  203. package/dist/projections/graphs/views/ViewOfOptions.d.ts +6 -0
  204. package/dist/projections/graphs/views/ViewOfOptions.d.ts.map +1 -0
  205. package/dist/projections/graphs/views/ViewOfOptions.js +4 -0
  206. package/dist/projections/graphs/views/ViewOfOptions.js.map +1 -0
  207. package/dist/projections/graphs/views/ViewRootNotANode.d.ts +16 -0
  208. package/dist/projections/graphs/views/ViewRootNotANode.d.ts.map +1 -0
  209. package/dist/projections/graphs/views/ViewRootNotANode.js +21 -0
  210. package/dist/projections/graphs/views/ViewRootNotANode.js.map +1 -0
  211. package/dist/projections/graphs/views/declareGraphViewMember.d.ts +17 -0
  212. package/dist/projections/graphs/views/declareGraphViewMember.d.ts.map +1 -0
  213. package/dist/projections/graphs/views/declareGraphViewMember.js +31 -0
  214. package/dist/projections/graphs/views/declareGraphViewMember.js.map +1 -0
  215. package/dist/projections/graphs/views/follows.d.ts +13 -0
  216. package/dist/projections/graphs/views/follows.d.ts.map +1 -0
  217. package/dist/projections/graphs/views/follows.js +24 -0
  218. package/dist/projections/graphs/views/follows.js.map +1 -0
  219. package/dist/projections/graphs/views/fromEdge.d.ts +10 -0
  220. package/dist/projections/graphs/views/fromEdge.d.ts.map +1 -0
  221. package/dist/projections/graphs/views/fromEdge.js +15 -0
  222. package/dist/projections/graphs/views/fromEdge.js.map +1 -0
  223. package/dist/projections/graphs/views/index.d.ts +41 -0
  224. package/dist/projections/graphs/views/index.d.ts.map +1 -0
  225. package/dist/projections/graphs/views/index.js +28 -0
  226. package/dist/projections/graphs/views/index.js.map +1 -0
  227. package/dist/projections/graphs/views/viewKey.d.ts +8 -0
  228. package/dist/projections/graphs/views/viewKey.d.ts.map +1 -0
  229. package/dist/projections/graphs/views/viewKey.js +13 -0
  230. package/dist/projections/graphs/views/viewKey.js.map +1 -0
  231. package/dist/projections/graphs/views/viewOf.d.ts +22 -0
  232. package/dist/projections/graphs/views/viewOf.d.ts.map +1 -0
  233. package/dist/projections/graphs/views/viewOf.js +41 -0
  234. package/dist/projections/graphs/views/viewOf.js.map +1 -0
  235. package/dist/projections/graphs/views/viewProperty.d.ts +9 -0
  236. package/dist/projections/graphs/views/viewProperty.d.ts.map +1 -0
  237. package/dist/projections/graphs/views/viewProperty.js +14 -0
  238. package/dist/projections/graphs/views/viewProperty.js.map +1 -0
  239. package/dist/testing/InProcessAppendMetadata.d.ts +30 -0
  240. package/dist/testing/InProcessAppendMetadata.d.ts.map +1 -0
  241. package/dist/testing/InProcessAppendMetadata.js +107 -0
  242. package/dist/testing/InProcessAppendMetadata.js.map +1 -0
  243. package/dist/testing/InProcessBatchAppend.d.ts +62 -0
  244. package/dist/testing/InProcessBatchAppend.d.ts.map +1 -0
  245. package/dist/testing/InProcessBatchAppend.js +131 -0
  246. package/dist/testing/InProcessBatchAppend.js.map +1 -0
  247. package/dist/testing/InProcessEventPayload.d.ts +23 -0
  248. package/dist/testing/InProcessEventPayload.d.ts.map +1 -0
  249. package/dist/testing/InProcessEventPayload.js +94 -0
  250. package/dist/testing/InProcessEventPayload.js.map +1 -0
  251. package/dist/testing/InProcessEventReadCriteria.d.ts +9 -0
  252. package/dist/testing/InProcessEventReadCriteria.d.ts.map +1 -0
  253. package/dist/testing/InProcessEventReadCriteria.js +4 -0
  254. package/dist/testing/InProcessEventReadCriteria.js.map +1 -0
  255. package/dist/testing/InProcessEventReadFilter.d.ts +14 -0
  256. package/dist/testing/InProcessEventReadFilter.d.ts.map +1 -0
  257. package/dist/testing/InProcessEventReadFilter.js +31 -0
  258. package/dist/testing/InProcessEventReadFilter.js.map +1 -0
  259. package/dist/testing/InProcessEventSequence.d.ts +8 -5
  260. package/dist/testing/InProcessEventSequence.d.ts.map +1 -1
  261. package/dist/testing/InProcessEventSequence.js +59 -275
  262. package/dist/testing/InProcessEventSequence.js.map +1 -1
  263. package/dist/testing/InProcessEventSequenceEnvironment.d.ts +13 -0
  264. package/dist/testing/InProcessEventSequenceEnvironment.d.ts.map +1 -0
  265. package/dist/testing/InProcessEventSequenceEnvironment.js +4 -0
  266. package/dist/testing/InProcessEventSequenceEnvironment.js.map +1 -0
  267. package/dist/testing/InProcessSingleAppend.d.ts +34 -0
  268. package/dist/testing/InProcessSingleAppend.d.ts.map +1 -0
  269. package/dist/testing/InProcessSingleAppend.js +95 -0
  270. package/dist/testing/InProcessSingleAppend.js.map +1 -0
  271. package/dist/testing/projections/ProjectionCapabilities.d.ts +0 -8
  272. package/dist/testing/projections/ProjectionCapabilities.d.ts.map +1 -1
  273. package/dist/testing/projections/ProjectionCapabilities.js +21 -312
  274. package/dist/testing/projections/ProjectionCapabilities.js.map +1 -1
  275. package/dist/testing/projections/ProjectionCapabilityReject.d.ts +3 -0
  276. package/dist/testing/projections/ProjectionCapabilityReject.d.ts.map +1 -0
  277. package/dist/testing/projections/ProjectionCapabilityReject.js +4 -0
  278. package/dist/testing/projections/ProjectionCapabilityReject.js.map +1 -0
  279. package/dist/testing/projections/ProjectionCapabilityReporter.d.ts +12 -0
  280. package/dist/testing/projections/ProjectionCapabilityReporter.d.ts.map +1 -0
  281. package/dist/testing/projections/ProjectionCapabilityReporter.js +33 -0
  282. package/dist/testing/projections/ProjectionCapabilityReporter.js.map +1 -0
  283. package/dist/testing/projections/ProjectionDefinitionCapabilities.d.ts +11 -0
  284. package/dist/testing/projections/ProjectionDefinitionCapabilities.d.ts.map +1 -0
  285. package/dist/testing/projections/ProjectionDefinitionCapabilities.js +45 -0
  286. package/dist/testing/projections/ProjectionDefinitionCapabilities.js.map +1 -0
  287. package/dist/testing/projections/ProjectionEventSchemaResolver.d.ts +13 -0
  288. package/dist/testing/projections/ProjectionEventSchemaResolver.d.ts.map +1 -0
  289. package/dist/testing/projections/ProjectionEventSchemaResolver.js +22 -0
  290. package/dist/testing/projections/ProjectionEventSchemaResolver.js.map +1 -0
  291. package/dist/testing/projections/ProjectionExpressionCapabilities.d.ts +19 -0
  292. package/dist/testing/projections/ProjectionExpressionCapabilities.d.ts.map +1 -0
  293. package/dist/testing/projections/ProjectionExpressionCapabilities.js +103 -0
  294. package/dist/testing/projections/ProjectionExpressionCapabilities.js.map +1 -0
  295. package/dist/testing/projections/ProjectionInitialValueCapabilities.d.ts +16 -0
  296. package/dist/testing/projections/ProjectionInitialValueCapabilities.d.ts.map +1 -0
  297. package/dist/testing/projections/ProjectionInitialValueCapabilities.js +72 -0
  298. package/dist/testing/projections/ProjectionInitialValueCapabilities.js.map +1 -0
  299. package/dist/testing/projections/ProjectionMappingCapabilities.d.ts +21 -0
  300. package/dist/testing/projections/ProjectionMappingCapabilities.d.ts.map +1 -0
  301. package/dist/testing/projections/ProjectionMappingCapabilities.js +86 -0
  302. package/dist/testing/projections/ProjectionMappingCapabilities.js.map +1 -0
  303. package/dist/testing/projections/ProjectionMappingValidation.d.ts +9 -0
  304. package/dist/testing/projections/ProjectionMappingValidation.d.ts.map +1 -0
  305. package/dist/testing/projections/ProjectionMappingValidation.js +4 -0
  306. package/dist/testing/projections/ProjectionMappingValidation.js.map +1 -0
  307. package/dist/testing/projections/ProjectionReadModelCapabilities.d.ts +11 -0
  308. package/dist/testing/projections/ProjectionReadModelCapabilities.d.ts.map +1 -0
  309. package/dist/testing/projections/ProjectionReadModelCapabilities.js +40 -0
  310. package/dist/testing/projections/ProjectionReadModelCapabilities.js.map +1 -0
  311. package/dist/testing/projections/ProjectionRootCapabilities.d.ts +20 -0
  312. package/dist/testing/projections/ProjectionRootCapabilities.d.ts.map +1 -0
  313. package/dist/testing/projections/ProjectionRootCapabilities.js +73 -0
  314. package/dist/testing/projections/ProjectionRootCapabilities.js.map +1 -0
  315. package/dist/testing/projections/ProjectionScalarConverter.d.ts +21 -0
  316. package/dist/testing/projections/ProjectionScalarConverter.d.ts.map +1 -0
  317. package/dist/testing/projections/ProjectionScalarConverter.js +105 -0
  318. package/dist/testing/projections/ProjectionScalarConverter.js.map +1 -0
  319. package/dist/testing/projections/ProjectionSchemaCapabilities.d.ts +26 -0
  320. package/dist/testing/projections/ProjectionSchemaCapabilities.d.ts.map +1 -0
  321. package/dist/testing/projections/ProjectionSchemaCapabilities.js +109 -0
  322. package/dist/testing/projections/ProjectionSchemaCapabilities.js.map +1 -0
  323. package/dist/testing/projections/ProjectionValueConverter.d.ts +5 -0
  324. package/dist/testing/projections/ProjectionValueConverter.d.ts.map +1 -1
  325. package/dist/testing/projections/ProjectionValueConverter.js +36 -84
  326. package/dist/testing/projections/ProjectionValueConverter.js.map +1 -1
  327. package/dist/tsconfig.tsbuildinfo +1 -1
  328. package/dist/types/DecoratorType.d.ts +3 -1
  329. package/dist/types/DecoratorType.d.ts.map +1 -1
  330. package/dist/types/DecoratorType.js +2 -0
  331. package/dist/types/DecoratorType.js.map +1 -1
  332. package/for_ChronicleOptions/when_configuring_keep_alive/with_skip_keep_alive.spec.ts +1 -1
  333. package/package.json +2 -2
  334. package/projections/for_Graphs/given/a_discovered_graph.ts +3 -2
  335. package/projections/for_Graphs/given/a_graph_with_views.ts +91 -0
  336. package/projections/for_Graphs/given/organization.ts +3 -2
  337. package/projections/for_Graphs/given/organization_with_views.fixture.ts +129 -0
  338. package/projections/for_Graphs/when_building_graph_views.spec.ts +218 -0
  339. package/projections/for_Graphs/when_declaring_an_invalid_graph_view.spec.ts +229 -0
  340. package/projections/for_Graphs/when_declaring_graph_views.standard.spec.ts +49 -0
  341. package/projections/for_Graphs/when_discovering_graph_views.spec.ts +58 -0
  342. package/projections/graphs/Graphs.ts +44 -0
  343. package/projections/graphs/IGraphs.ts +10 -2
  344. package/projections/graphs/index.ts +1 -0
  345. package/projections/graphs/views/AmbiguousDirection.ts +23 -0
  346. package/projections/graphs/views/DuplicateViewName.ts +23 -0
  347. package/projections/graphs/views/EdgeNotIncidentOnRoot.ts +24 -0
  348. package/projections/graphs/views/EdgePropertyViewNotUsedAsTarget.ts +21 -0
  349. package/projections/graphs/views/EdgePropertyViewSharedAcrossEdges.ts +22 -0
  350. package/projections/graphs/views/FollowsOptions.ts +20 -0
  351. package/projections/graphs/views/GraphEdgeDirection.ts +13 -0
  352. package/projections/graphs/views/GraphView.ts +18 -0
  353. package/projections/graphs/views/GraphViewBuildResult.ts +19 -0
  354. package/projections/graphs/views/GraphViewCardinality.ts +13 -0
  355. package/projections/graphs/views/GraphViewDefinition.ts +20 -0
  356. package/projections/graphs/views/GraphViewDefinitionBuilder.ts +322 -0
  357. package/projections/graphs/views/GraphViewDefinitionSerializer.ts +90 -0
  358. package/projections/graphs/views/GraphViewEdgeReference.ts +8 -0
  359. package/projections/graphs/views/GraphViewMember.ts +11 -0
  360. package/projections/graphs/views/GraphViewMemberKind.ts +16 -0
  361. package/projections/graphs/views/GraphViewMemberMetadata.ts +31 -0
  362. package/projections/graphs/views/GraphViewPropertyMember.ts +18 -0
  363. package/projections/graphs/views/GraphViewReason.ts +47 -0
  364. package/projections/graphs/views/GraphViewRelationMember.ts +29 -0
  365. package/projections/graphs/views/GraphViewSchema.ts +14 -0
  366. package/projections/graphs/views/GraphViewSchemaEdge.ts +20 -0
  367. package/projections/graphs/views/GraphViewSchemaNode.ts +14 -0
  368. package/projections/graphs/views/GraphViewSerializerOptions.ts +11 -0
  369. package/projections/graphs/views/RecursiveView.ts +22 -0
  370. package/projections/graphs/views/RelationTargetNotAView.ts +23 -0
  371. package/projections/graphs/views/TargetLabelMismatch.ts +25 -0
  372. package/projections/graphs/views/UnknownEdge.ts +23 -0
  373. package/projections/graphs/views/UnknownEdgeProperty.ts +24 -0
  374. package/projections/graphs/views/UnknownNodeProperty.ts +24 -0
  375. package/projections/graphs/views/ViewIsAlsoSchema.ts +21 -0
  376. package/projections/graphs/views/ViewOfMetadata.ts +11 -0
  377. package/projections/graphs/views/ViewOfOptions.ts +8 -0
  378. package/projections/graphs/views/ViewRootNotANode.ts +23 -0
  379. package/projections/graphs/views/declareGraphViewMember.ts +36 -0
  380. package/projections/graphs/views/follows.ts +28 -0
  381. package/projections/graphs/views/fromEdge.ts +17 -0
  382. package/projections/graphs/views/index.ts +43 -0
  383. package/projections/graphs/views/viewKey.ts +15 -0
  384. package/projections/graphs/views/viewOf.ts +50 -0
  385. package/projections/graphs/views/viewProperty.ts +16 -0
  386. package/testing/InProcessAppendMetadata.ts +119 -0
  387. package/testing/InProcessBatchAppend.ts +142 -0
  388. package/testing/InProcessEventPayload.ts +100 -0
  389. package/testing/InProcessEventReadCriteria.ts +11 -0
  390. package/testing/InProcessEventReadFilter.ts +37 -0
  391. package/testing/InProcessEventSequence.ts +63 -257
  392. package/testing/InProcessEventSequenceEnvironment.ts +16 -0
  393. package/testing/InProcessSingleAppend.ts +99 -0
  394. package/testing/for_InProcessEventSequence/when_preserving_validation_and_commit_order.spec.ts +95 -0
  395. package/testing/projections/ProjectionCapabilities.ts +23 -279
  396. package/testing/projections/ProjectionCapabilityReject.ts +5 -0
  397. package/testing/projections/ProjectionCapabilityReporter.ts +31 -0
  398. package/testing/projections/ProjectionDefinitionCapabilities.ts +45 -0
  399. package/testing/projections/ProjectionEventSchemaResolver.ts +23 -0
  400. package/testing/projections/ProjectionExpressionCapabilities.ts +101 -0
  401. package/testing/projections/ProjectionInitialValueCapabilities.ts +73 -0
  402. package/testing/projections/ProjectionMappingCapabilities.ts +85 -0
  403. package/testing/projections/ProjectionMappingValidation.ts +12 -0
  404. package/testing/projections/ProjectionReadModelCapabilities.ts +42 -0
  405. package/testing/projections/ProjectionRootCapabilities.ts +75 -0
  406. package/testing/projections/ProjectionScalarConverter.ts +106 -0
  407. package/testing/projections/ProjectionSchemaCapabilities.ts +112 -0
  408. package/testing/projections/ProjectionValueConverter.ts +37 -76
  409. package/testing/projections/for_ProjectionCapabilities/when_reporting_the_first_unsupported_operation.spec.ts +74 -0
  410. package/testing/projections/for_ProjectionValueConverter/when_converting_structured_and_scalar_values.spec.ts +64 -0
  411. package/types/DecoratorType.ts +4 -1
@@ -0,0 +1,23 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { GraphViewReason } from './GraphViewReason.js';
5
+
6
+ /**
7
+ * Error raised when the target of a relation is not a declared view of the graph.
8
+ */
9
+ export class RelationTargetNotAView extends Error {
10
+ /** The stable reason code of the rule that was broken. */
11
+ readonly reason = GraphViewReason.RelationTargetNotAView;
12
+
13
+ /**
14
+ * Creates a new {@link RelationTargetNotAView}.
15
+ * @param view - The view type.
16
+ * @param member - The name of the member.
17
+ * @param target - The type that is not a view of the graph.
18
+ */
19
+ constructor(view: Function, member: string, target: Function) {
20
+ super(`The member '${member}' of the view '${view.name}' yields '${target.name}', which is not a view of the graph. Declare it with viewOf and the same graph.`);
21
+ this.name = 'RelationTargetNotAView';
22
+ }
23
+ }
@@ -0,0 +1,25 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { GraphViewReason } from './GraphViewReason.js';
5
+
6
+ /**
7
+ * Error raised when the root of the target view of a relation is not the label at the far end of the edge.
8
+ */
9
+ export class TargetLabelMismatch extends Error {
10
+ /** The stable reason code of the rule that was broken. */
11
+ readonly reason = GraphViewReason.TargetLabelMismatch;
12
+
13
+ /**
14
+ * Creates a new {@link TargetLabelMismatch}.
15
+ * @param view - The view type.
16
+ * @param member - The name of the member.
17
+ * @param target - The target view type.
18
+ * @param expected - The label at the far end of the edge.
19
+ * @param actual - The label of the root of the target view.
20
+ */
21
+ constructor(view: Function, member: string, target: Function, expected: string, actual: string) {
22
+ super(`The member '${member}' of the view '${view.name}' reaches '${expected}', but the view '${target.name}' is anchored at '${actual}'.`);
23
+ this.name = 'TargetLabelMismatch';
24
+ }
25
+ }
@@ -0,0 +1,23 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { GraphViewReason } from './GraphViewReason.js';
5
+
6
+ /**
7
+ * Error raised when a relation of a view names an edge type the graph does not declare.
8
+ */
9
+ export class UnknownEdge extends Error {
10
+ /** The stable reason code of the rule that was broken. */
11
+ readonly reason = GraphViewReason.UnknownEdge;
12
+
13
+ /**
14
+ * Creates a new {@link UnknownEdge}.
15
+ * @param view - The view type.
16
+ * @param member - The name of the member.
17
+ * @param edge - The edge that is not declared.
18
+ */
19
+ constructor(view: Function, member: string, edge: string) {
20
+ super(`The member '${member}' of the view '${view.name}' follows '${edge}', which is not an edge of the graph.`);
21
+ this.name = 'UnknownEdge';
22
+ }
23
+ }
@@ -0,0 +1,24 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { GraphViewReason } from './GraphViewReason.js';
5
+
6
+ /**
7
+ * Error raised when an edge property member of a view names a property the edge does not declare.
8
+ */
9
+ export class UnknownEdgeProperty extends Error {
10
+ /** The stable reason code of the rule that was broken. */
11
+ readonly reason = GraphViewReason.UnknownEdgeProperty;
12
+
13
+ /**
14
+ * Creates a new {@link UnknownEdgeProperty}.
15
+ * @param view - The view type.
16
+ * @param member - The name of the member.
17
+ * @param edge - The edge type that is followed to reach the view.
18
+ * @param source - The name of the property that is not declared.
19
+ */
20
+ constructor(view: Function, member: string, edge: string, source: string) {
21
+ super(`The member '${member}' of the view '${view.name}' reads '${source}', which is not a property of the edge '${edge}'.`);
22
+ this.name = 'UnknownEdgeProperty';
23
+ }
24
+ }
@@ -0,0 +1,24 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { GraphViewReason } from './GraphViewReason.js';
5
+
6
+ /**
7
+ * Error raised when a property member of a view names a property the root node does not declare.
8
+ */
9
+ export class UnknownNodeProperty extends Error {
10
+ /** The stable reason code of the rule that was broken. */
11
+ readonly reason = GraphViewReason.UnknownNodeProperty;
12
+
13
+ /**
14
+ * Creates a new {@link UnknownNodeProperty}.
15
+ * @param view - The view type.
16
+ * @param member - The name of the member.
17
+ * @param node - The label of the root node.
18
+ * @param source - The name of the property that is not declared.
19
+ */
20
+ constructor(view: Function, member: string, node: string, source: string) {
21
+ super(`The member '${member}' of the view '${view.name}' reads '${source}', which is not a property of the node '${node}'.`);
22
+ this.name = 'UnknownNodeProperty';
23
+ }
24
+ }
@@ -0,0 +1,21 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { GraphViewReason } from './GraphViewReason.js';
5
+
6
+ /**
7
+ * Error raised when a view type is also a node or an edge.
8
+ */
9
+ export class ViewIsAlsoSchema extends Error {
10
+ /** The stable reason code of the rule that was broken. */
11
+ readonly reason = GraphViewReason.ViewIsAlsoSchema;
12
+
13
+ /**
14
+ * Creates a new {@link ViewIsAlsoSchema}.
15
+ * @param view - The view type.
16
+ */
17
+ constructor(view: Function) {
18
+ super(`The view '${view.name}' is also a node or an edge. A view is a read model over the graph and cannot be part of its schema.`);
19
+ this.name = 'ViewIsAlsoSchema';
20
+ }
21
+ }
@@ -0,0 +1,11 @@
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
+ /** Metadata stored by the viewOf class decorator. */
5
+ export interface ViewOfMetadata {
6
+ /** A function returning the class of the node the view is anchored at. */
7
+ readonly root: () => Function;
8
+
9
+ /** The name of the view. */
10
+ readonly name: string;
11
+ }
@@ -0,0 +1,8 @@
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
+ /** Options of the viewOf decorator. */
5
+ export interface ViewOfOptions {
6
+ /** The name of the view. View names are unique in a graph. Defaults to the name of the class. */
7
+ readonly name?: string;
8
+ }
@@ -0,0 +1,23 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { GraphViewReason } from './GraphViewReason.js';
5
+
6
+ /**
7
+ * Error raised when the root of a view is not a node declared in the graph of the view.
8
+ */
9
+ export class ViewRootNotANode extends Error {
10
+ /** The stable reason code of the rule that was broken. */
11
+ readonly reason = GraphViewReason.ViewRootNotANode;
12
+
13
+ /**
14
+ * Creates a new {@link ViewRootNotANode}.
15
+ * @param view - The view type.
16
+ * @param graph - The name of the graph.
17
+ * @param root - The type the view is anchored at.
18
+ */
19
+ constructor(view: Function, graph: string, root: Function) {
20
+ super(`The view '${view.name}' is anchored at '${root.name}', which is not a node of the graph '${graph}'.`);
21
+ this.name = 'ViewRootNotANode';
22
+ }
23
+ }
@@ -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
+
4
+ import 'reflect-metadata';
5
+ import { TypeIntrospector } from '../../../types/index.js';
6
+ import { decorateProperty, getPropertyMetadata, type ChroniclePropertyDecorator } from '../../../types/propertyDecoratorMetadata.js';
7
+ import type { GraphViewMemberMetadata } from './GraphViewMemberMetadata.js';
8
+
9
+ const METADATA_KEY = 'chronicle:graph:view:member';
10
+
11
+ /**
12
+ * Creates a property decorator that declares a member of a graph view. Members are read in the order they are declared.
13
+ * @param metadata - What the member is.
14
+ * @returns A property decorator.
15
+ */
16
+ export function declareGraphViewMember(metadata: GraphViewMemberMetadata): ChroniclePropertyDecorator {
17
+ return decorateProperty((target: object, propertyKey: string | symbol) => {
18
+ const key = propertyKey.toString();
19
+ if (Reflect.getOwnMetadata(METADATA_KEY, target, key) !== undefined) {
20
+ throw new TypeError(`The member '${key}' of a graph view can be declared as one kind of member only.`);
21
+ }
22
+
23
+ TypeIntrospector.trackProperty((target as { constructor: Function }).constructor, key);
24
+ Reflect.defineMetadata(METADATA_KEY, metadata, target, key);
25
+ });
26
+ }
27
+
28
+ /**
29
+ * Retrieves the metadata stored by the member decorators of a graph view on a property.
30
+ * @param target - The class prototype.
31
+ * @param propertyKey - The property name.
32
+ * @returns The metadata, or undefined when the property is not a member of a view.
33
+ */
34
+ export function getGraphViewMemberMetadata(target: object, propertyKey: string): GraphViewMemberMetadata | undefined {
35
+ return getPropertyMetadata<GraphViewMemberMetadata>(METADATA_KEY, target, propertyKey);
36
+ }
@@ -0,0 +1,28 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import type { ChroniclePropertyDecorator } from '../../../types/propertyDecoratorMetadata.js';
5
+ import type { FollowsOptions } from './FollowsOptions.js';
6
+ import { GraphViewCardinality } from './GraphViewCardinality.js';
7
+ import type { GraphViewEdgeReference } from './GraphViewEdgeReference.js';
8
+ import { GraphViewMemberKind } from './GraphViewMemberKind.js';
9
+ import { declareGraphViewMember } from './declareGraphViewMember.js';
10
+
11
+ /**
12
+ * Property decorator that declares a member of a graph view that follows one edge type to a nested view.
13
+ * @param edge - The edge to follow: a function returning the edge class, or the edge type string.
14
+ * @param view - A function returning the class of the nested view.
15
+ * @param options - The cardinality, which is many by default, and the direction, which is derived unless the edge
16
+ * starts and ends at the same label.
17
+ * @returns A property decorator.
18
+ */
19
+ export function follows(edge: GraphViewEdgeReference, view: () => Function, options: FollowsOptions = {}): ChroniclePropertyDecorator {
20
+ return declareGraphViewMember({
21
+ kind: GraphViewMemberKind.Relation,
22
+ isKey: false,
23
+ edge,
24
+ view,
25
+ direction: options.direction,
26
+ cardinality: options.cardinality ?? GraphViewCardinality.Many
27
+ });
28
+ }
@@ -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
+ import type { ChroniclePropertyDecorator } from '../../../types/propertyDecoratorMetadata.js';
5
+ import { GraphViewMemberKind } from './GraphViewMemberKind.js';
6
+ import { declareGraphViewMember } from './declareGraphViewMember.js';
7
+
8
+ /**
9
+ * Property decorator that declares a member of a graph view that reads a property of the edge that was followed to
10
+ * reach the view. It is valid only in a view that is the target of relations of exactly one edge type.
11
+ * @param source - The name of the property of the edge. It is matched without regard to case. When missing, the
12
+ * name of the member is matched against the properties of the edge.
13
+ * @returns A property decorator.
14
+ */
15
+ export function fromEdge(source?: string): ChroniclePropertyDecorator {
16
+ return declareGraphViewMember({ kind: GraphViewMemberKind.EdgeProperty, isKey: false, source });
17
+ }
@@ -0,0 +1,43 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ export { viewOf, getViewOfMetadata } from './viewOf.js';
5
+ export type { ViewOfOptions } from './ViewOfOptions.js';
6
+ export type { ViewOfMetadata } from './ViewOfMetadata.js';
7
+ export { viewKey } from './viewKey.js';
8
+ export { viewProperty } from './viewProperty.js';
9
+ export { fromEdge } from './fromEdge.js';
10
+ export { follows } from './follows.js';
11
+ export type { FollowsOptions } from './FollowsOptions.js';
12
+ export { getGraphViewMemberMetadata } from './declareGraphViewMember.js';
13
+ export type { GraphViewMemberMetadata } from './GraphViewMemberMetadata.js';
14
+ export type { GraphViewEdgeReference } from './GraphViewEdgeReference.js';
15
+ export { GraphViewMemberKind } from './GraphViewMemberKind.js';
16
+ export { GraphEdgeDirection } from './GraphEdgeDirection.js';
17
+ export { GraphViewCardinality } from './GraphViewCardinality.js';
18
+ export { GraphViewReason } from './GraphViewReason.js';
19
+ export type { GraphViewDefinition } from './GraphViewDefinition.js';
20
+ export type { GraphView } from './GraphView.js';
21
+ export type { GraphViewMember } from './GraphViewMember.js';
22
+ export type { GraphViewPropertyMember } from './GraphViewPropertyMember.js';
23
+ export type { GraphViewRelationMember } from './GraphViewRelationMember.js';
24
+ export type { GraphViewBuildResult } from './GraphViewBuildResult.js';
25
+ export { GraphViewDefinitionBuilder } from './GraphViewDefinitionBuilder.js';
26
+ export { GraphViewDefinitionSerializer } from './GraphViewDefinitionSerializer.js';
27
+ export { ViewRootNotANode } from './ViewRootNotANode.js';
28
+ export { ViewIsAlsoSchema } from './ViewIsAlsoSchema.js';
29
+ export { DuplicateViewName } from './DuplicateViewName.js';
30
+ export { UnknownNodeProperty } from './UnknownNodeProperty.js';
31
+ export { UnknownEdge } from './UnknownEdge.js';
32
+ export { UnknownEdgeProperty } from './UnknownEdgeProperty.js';
33
+ export { EdgeNotIncidentOnRoot } from './EdgeNotIncidentOnRoot.js';
34
+ export { AmbiguousDirection } from './AmbiguousDirection.js';
35
+ export { TargetLabelMismatch } from './TargetLabelMismatch.js';
36
+ export { RelationTargetNotAView } from './RelationTargetNotAView.js';
37
+ export { RecursiveView } from './RecursiveView.js';
38
+ export { EdgePropertyViewNotUsedAsTarget } from './EdgePropertyViewNotUsedAsTarget.js';
39
+ export { EdgePropertyViewSharedAcrossEdges } from './EdgePropertyViewSharedAcrossEdges.js';
40
+ export type { GraphViewSchema } from './GraphViewSchema.js';
41
+ export type { GraphViewSchemaNode } from './GraphViewSchemaNode.js';
42
+ export type { GraphViewSchemaEdge } from './GraphViewSchemaEdge.js';
43
+ export type { GraphViewSerializerOptions } from './GraphViewSerializerOptions.js';
@@ -0,0 +1,15 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import type { ChroniclePropertyDecorator } from '../../../types/propertyDecoratorMetadata.js';
5
+ import { GraphViewMemberKind } from './GraphViewMemberKind.js';
6
+ import { declareGraphViewMember } from './declareGraphViewMember.js';
7
+
8
+ /**
9
+ * Property decorator that declares the member of a graph view that holds the key of the root node. The member reads
10
+ * whatever property the node uses as its key, so the view does not repeat the name of it.
11
+ * @returns A property decorator.
12
+ */
13
+ export function viewKey(): ChroniclePropertyDecorator {
14
+ return declareGraphViewMember({ kind: GraphViewMemberKind.Property, isKey: true });
15
+ }
@@ -0,0 +1,50 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import 'reflect-metadata';
5
+ import type { Constructor } from '@cratis/fundamentals';
6
+ import { DecoratorType, TypeDiscoverer } from '../../../types/index.js';
7
+ import type { ChronicleClassDecorator } from '../../../types/standardDecoratorMetadata.js';
8
+ import type { ViewOfMetadata } from './ViewOfMetadata.js';
9
+ import type { ViewOfOptions } from './ViewOfOptions.js';
10
+
11
+ const METADATA_KEY = 'chronicle:graph:view';
12
+
13
+ /**
14
+ * Class decorator that marks a class as a view over a property graph. A view is a read model that is anchored at one
15
+ * node. Its members are properties of that node (viewKey and viewProperty), relations along declared edges to other
16
+ * views (follows) and properties of the edge that was followed (fromEdge). Name the graph with the graph decorator.
17
+ * A view only declares what is read; the class is never a node or an edge.
18
+ * @param root - A function returning the class of the node the view is anchored at. It is resolved when the views
19
+ * are validated, so the classes can be declared in any order.
20
+ * @param options - The name of the view, which defaults to the name of the class.
21
+ * @returns A class decorator.
22
+ */
23
+ export function viewOf(root: () => Function, options: ViewOfOptions = {}): ChronicleClassDecorator {
24
+ return (target: object) => {
25
+ const type = target as Function;
26
+ const metadata: ViewOfMetadata = { root, name: options.name ?? type.name };
27
+ Reflect.defineMetadata(METADATA_KEY, metadata, target);
28
+
29
+ // Discovery is keyed by name. Views of different graphs may share a class name, so they must not replace each other.
30
+ const registered = TypeDiscoverer.default.getTypesByDecoratorType(DecoratorType.GraphView);
31
+ if (!registered.includes(type as Constructor)) {
32
+ let key = type.name;
33
+ let suffix = 2;
34
+ while (TypeDiscoverer.default.getTypeByDecoratorTypeAndName(DecoratorType.GraphView, key) !== undefined) {
35
+ key = `${type.name}#${suffix++}`;
36
+ }
37
+
38
+ TypeDiscoverer.default.register(DecoratorType.GraphView, type as Constructor, key);
39
+ }
40
+ };
41
+ }
42
+
43
+ /**
44
+ * Retrieves the metadata stored by the viewOf decorator.
45
+ * @param target - The class constructor.
46
+ * @returns The metadata, or undefined when the class is not a view.
47
+ */
48
+ export function getViewOfMetadata(target: Function): ViewOfMetadata | undefined {
49
+ return Reflect.getMetadata(METADATA_KEY, target) as ViewOfMetadata | undefined;
50
+ }
@@ -0,0 +1,16 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import type { ChroniclePropertyDecorator } from '../../../types/propertyDecoratorMetadata.js';
5
+ import { GraphViewMemberKind } from './GraphViewMemberKind.js';
6
+ import { declareGraphViewMember } from './declareGraphViewMember.js';
7
+
8
+ /**
9
+ * Property decorator that declares a member of a graph view that reads a property of the root node.
10
+ * @param source - The name of the property of the node. It is matched without regard to case. When missing, the
11
+ * name of the member is matched against the properties of the node.
12
+ * @returns A property decorator.
13
+ */
14
+ export function viewProperty(source?: string): ChroniclePropertyDecorator {
15
+ return declareGraphViewMember({ kind: GraphViewMemberKind.Property, isKey: false, source });
16
+ }
@@ -0,0 +1,119 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { Guid } from '@cratis/fundamentals';
5
+ import { toContractsGuid } from '../connection/Guid.js';
6
+ import { Identity } from '../identity/Identity.js';
7
+ import type { prepareSingleAppend } from '../eventSequences/prepareSingleAppend.js';
8
+ import type { AppendOptions } from '../eventSequences/AppendOptions.js';
9
+ import type { EventForEventSourceId } from '../eventSequences/EventForEventSourceId.js';
10
+ import { hasNamedTags } from './singleAppendRoute.js';
11
+ import type { InProcessEventSequenceEnvironment } from './InProcessEventSequenceEnvironment.js';
12
+
13
+ /** Prepares only the metadata domain proven by the in-process append fixtures. */
14
+ export class InProcessAppendMetadata {
15
+ constructor(private readonly environment: InProcessEventSequenceEnvironment) {}
16
+
17
+ batch(options?: AppendOptions): void {
18
+ if (options === undefined) return;
19
+ if (!this.optionsObject(options)) {
20
+ throw this.environment.unsupported('appendMany.options', this.environment.sequenceId, 'Append options must be an object.');
21
+ }
22
+ if (hasNamedTags(options.namedTags)) throw this.environment.unsupported('appendMany.namedTags', this.environment.sequenceId, 'Named tags are not fixture-backed.');
23
+ this.batchKeys(options);
24
+ this.subject(options);
25
+ this.tags(options);
26
+ }
27
+
28
+ entry(entry: EventForEventSourceId): void {
29
+ if (!this.entryObject(entry) || this.unknown(entry,
30
+ ['eventSourceId', 'event', 'eventSourceType', 'eventStreamType', 'eventStreamId', 'subject', 'occurred', 'tags', 'namedTags'])) {
31
+ throw this.environment.unsupported('appendMany.entry', this.environment.sequenceId, 'Unrecognized per-entry metadata.');
32
+ }
33
+ if (hasNamedTags(entry.namedTags)) throw this.environment.unsupported('appendMany.namedTags', this.environment.sequenceId, 'Named tags are not fixture-backed.');
34
+ if (entry.occurred !== undefined) this.checkedDate(entry.occurred, 'appendMany.occurred');
35
+ this.subject(entry);
36
+ this.tags(entry);
37
+ }
38
+
39
+ guid(value: string | Guid, operation: string): void {
40
+ try {
41
+ toContractsGuid(Guid.as(value));
42
+ if (!/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test(value.toString())) throw new Error('Invalid GUID.');
43
+ } catch { throw this.environment.unsupported(operation, this.environment.sequenceId, 'Correlation ID must be a valid GUID.'); }
44
+ }
45
+
46
+ checkedDate(value: Date, operation: string): Date {
47
+ if (!(value instanceof Date) || !this.validTime(value)) {
48
+ throw this.environment.unsupported(operation, this.environment.sequenceId, 'Occurrence must be within UTC years 1–9999 at millisecond precision.');
49
+ }
50
+ return new Date(value);
51
+ }
52
+
53
+ source(source: string, operation: string): void {
54
+ if (typeof source !== 'string' || !/^[A-Za-z0-9_-]+$/.test(source)) {
55
+ throw this.environment.unsupported(operation, String(source), 'Only simple source identifiers are fixture-backed.');
56
+ }
57
+ }
58
+
59
+ private subject(metadata: Pick<AppendOptions, 'subject'>): void {
60
+ if (!this.validSubject(metadata)) {
61
+ throw this.environment.unsupported('appendMany.subject', this.environment.sequenceId, 'Subject must be a string.');
62
+ }
63
+ }
64
+
65
+ private validSubject(metadata: Pick<AppendOptions, 'subject'>): boolean {
66
+ return metadata.subject === undefined || metadata.subject === null || typeof metadata.subject === 'string';
67
+ }
68
+
69
+ private tags(metadata: Pick<AppendOptions, 'tags'>): void {
70
+ if (metadata.tags && !this.stringTags(metadata)) {
71
+ throw this.environment.unsupported('appendMany.tags', this.environment.sequenceId, 'Only plain string tags are fixture-backed.');
72
+ }
73
+ }
74
+
75
+ unsupportedOptions(options?: AppendOptions): boolean {
76
+ if (options?.concurrencyScope !== undefined || options?.concurrencyScopes !== undefined) return true;
77
+ return options?.eventSourceId !== undefined;
78
+ }
79
+
80
+ storedSubject(subject: string | undefined, eventSourceId: string): string {
81
+ // Match the kernel's string.IsNullOrWhiteSpace, including U+0085 but not U+FEFF.
82
+ return subject && !/^\p{White_Space}*$/u.test(subject) ? subject : eventSourceId;
83
+ }
84
+
85
+ private batchKeys(options: AppendOptions): void {
86
+ const allowed = ['correlationId', 'sourceType', 'streamType', 'streamId', 'subject', 'occurred', 'tags', 'namedTags'];
87
+ if (this.unknown(options, allowed) || this.unsupportedOptions(options)) {
88
+ throw this.environment.unsupported('appendMany.options', this.environment.sequenceId, 'Concurrency and unrecognized metadata are not fixture-backed.');
89
+ }
90
+ }
91
+
92
+ private unknown(value: object, allowed: string[]): boolean {
93
+ return Reflect.ownKeys(value).some(key => !allowed.includes(String(key)));
94
+ }
95
+
96
+ private validTime(value: Date): boolean {
97
+ return !Number.isNaN(value.getTime()) && value.getUTCFullYear() >= 1 && value.getUTCFullYear() <= 9999;
98
+ }
99
+
100
+ private stringTags(metadata: Pick<AppendOptions, 'tags'>): boolean {
101
+ return Array.isArray(metadata.tags) && !metadata.tags.some(tag => typeof tag !== 'string');
102
+ }
103
+
104
+ private entryObject(value: unknown): boolean {
105
+ return !!value && typeof value === 'object';
106
+ }
107
+
108
+ private optionsObject(value: unknown): boolean {
109
+ return this.entryObject(value) && !Array.isArray(value);
110
+ }
111
+
112
+ ambientContext(identity: Identity, chain: ReturnType<typeof prepareSingleAppend>['causationChain']): boolean {
113
+ return identity === Identity.system && this.emptyRoot(chain);
114
+ }
115
+
116
+ private emptyRoot(chain: ReturnType<typeof prepareSingleAppend>['causationChain']): boolean {
117
+ return chain.length === 2 && Object.keys(chain[0].properties).length === 0;
118
+ }
119
+ }