@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
package/README.md CHANGED
@@ -72,7 +72,7 @@ Chronicle decorators work with both TC39 standard decorators (TypeScript 5.2+; d
72
72
 
73
73
  Read models are inferred from `@projection('id', Model)`, `@reducer('id', sequenceId, Model)`, or an exported model with `@fromEvent(Event)` or other model-bound property mappings. Their schema comes from the model type; the default identifier is its class name. See [read models](https://github.com/Cratis/Chronicle.TypeScript/blob/main/Documentation/read-models.md) for preserving existing custom identifiers.
74
74
 
75
- Decorated artifacts register when their modules are imported. When the entry file is TypeScript (run through a loader such as `tsx`), the client also scans `**/*.ts` files by default; compiled JavaScript scans nothing unless you set `discoveryPatterns`. See [artifact discovery](https://github.com/Cratis/Chronicle.TypeScript/blob/main/Documentation/getting-started.md#artifact-discovery).
75
+ Decorated artifacts register when their modules are imported. When the process runs TypeScript (a `.ts`, `.tsx`, `.mts` or `.cts` entry file, a loader such as `tsx` or `ts-node`, Node's `--experimental-strip-types` or `--experimental-transform-types`, or Vitest), the client also scans `**/*.ts` and `**/*.tsx` files by default, excluding declaration files, specs, tests, `node_modules`, `dist` and `build`. Otherwise, as for compiled JavaScript, it scans nothing unless you set `discoveryPatterns`. See [artifact discovery](https://github.com/Cratis/Chronicle.TypeScript/blob/main/Documentation/getting-started.md#artifact-discovery).
76
76
 
77
77
  The client skips TLS certificate validation unless the connection string sets `skipTlsValidation=false` (the default stays `true` in this release; an explicit `false` requires validation). Set it for every server other than a local development kernel; the client logs a warning when it skips validation for a non-loopback host; see [Connect to Chronicle](https://github.com/Cratis/Chronicle.TypeScript/blob/main/Documentation/connecting.md).
78
78
 
@@ -98,4 +98,9 @@ export class DefaultClientArtifactsProvider implements IClientArtifactsProvider
98
98
  get graphProjections(): Constructor[] {
99
99
  return this.discoverer.getTypesByDecoratorType(DecoratorType.GraphProjection);
100
100
  }
101
+
102
+ /** @inheritdoc */
103
+ get graphViews(): Constructor[] {
104
+ return this.discoverer.getTypesByDecoratorType(DecoratorType.GraphView);
105
+ }
101
106
  }
@@ -45,4 +45,7 @@ export interface IClientArtifactsProvider {
45
45
 
46
46
  /** Gets discovered fluent graph projection constructors. Optional so existing providers keep working. */
47
47
  readonly graphProjections?: Constructor[];
48
+
49
+ /** Gets discovered graph view constructors. Optional so existing providers keep working. */
50
+ readonly graphViews?: Constructor[];
48
51
  }
@@ -42,6 +42,7 @@ import { ChronicleConnectionString, type ChronicleServerAddress } from './Chroni
42
42
  import { ChronicleServerAddressResolver } from './ChronicleServerAddressResolver.js';
43
43
  import { ChronicleServices } from './ChronicleServices.js';
44
44
  import './encodeExplicitFalse.js';
45
+ import { ChronicleTlsMaterial } from './ChronicleTlsMaterial.js';
45
46
  import { CompatibilityPreflight } from './CompatibilityPreflight.js';
46
47
  import { formatServerAddress } from './formatServerAddress.js';
47
48
  import type { ILoadBalancerStrategy } from './ILoadBalancerStrategy.js';
@@ -114,6 +115,7 @@ export class ChronicleConnection implements ChronicleServices {
114
115
  private readonly _tokenProviders = new Map<string, ITokenProvider>();
115
116
  private readonly _addressResolver: ChronicleServerAddressResolver;
116
117
  private readonly _loadBalancerStrategy: ILoadBalancerStrategy;
118
+ private readonly _tlsMaterial: ChronicleTlsMaterial;
117
119
  private _isConnected = false;
118
120
  private _warnedAboutSkippedTlsValidation = false;
119
121
  private _clientsReady?: Promise<void>;
@@ -129,12 +131,15 @@ export class ChronicleConnection implements ChronicleServices {
129
131
  this._connectionString = ChronicleConnectionString.Default;
130
132
  }
131
133
 
132
- if (!this._connectionString.apiKey && (!!this._connectionString.username !== !!this._connectionString.password)) {
134
+ if (!this._connectionString.noAuthentication && !this._connectionString.apiKey && (!!this._connectionString.username !== !!this._connectionString.password)) {
133
135
  throw new Error('Connection string must contain both username and password, or neither');
134
136
  }
135
137
 
136
138
  this._addressResolver = new ChronicleServerAddressResolver();
137
- this._loadBalancerStrategy = createLoadBalancerStrategy(this._connectionString.loadBalancer, this._connectionString.skipTlsValidation);
139
+ // Loaded once, up front: a missing or unreadable certificate file fails the connection setup here rather
140
+ // than on every reconnect - or not at all until validation is switched on.
141
+ this._tlsMaterial = this._connectionString.loadTlsMaterial();
142
+ this._loadBalancerStrategy = createLoadBalancerStrategy(this._connectionString.loadBalancer, this._connectionString.skipTlsValidation, this._tlsMaterial);
138
143
 
139
144
  if (!_options.deferClientCreation) {
140
145
  this._clientsReady = this.startClientCreation();
@@ -319,14 +324,14 @@ export class ChronicleConnection implements ChronicleServices {
319
324
  const selected = await this._loadBalancerStrategy.select(candidates);
320
325
  const serverAddress = formatServerAddress(selected);
321
326
  const tokenProvider = this.createTokenProvider(selected);
322
- const credentials = this._options.credentials ?? this._connectionString.createCredentials();
327
+ const credentials = this._options.credentials ?? this._connectionString.createCredentials(this._tlsMaterial);
323
328
 
324
329
  this._channel = createChannel(serverAddress, credentials, channelOptions);
325
330
 
326
331
  // nice-grpc invokes the last middleware first: auth retries re-enter propagation.
327
332
  const factory = createClientFactory().use(traceContextMiddleware).use(this.createAuthMiddleware(tokenProvider));
328
333
  this._connections = factory.create(ConnectionServiceDefinition, this._channel);
329
- this._compatibility = new CompatibilityPreflight(this._connections, this._options.connectTimeout ?? 10_000);
334
+ this._compatibility = new CompatibilityPreflight(this._connections, this._options.connectTimeout ?? 10_000, this._connectionString.skipCompatibilityCheck);
330
335
  const eventSequenceFactory = factory.use(this._compatibility.middleware());
331
336
  this._services = {
332
337
  eventStores: factory.create(EventStoresDefinition, this._channel),
@@ -368,7 +373,7 @@ export class ChronicleConnection implements ChronicleServices {
368
373
  const channelHosts = this._options.credentials ? [] : remoteOnly(candidateHosts);
369
374
  // OAuth token requests (every mode except an API key) always skip validation, against
370
375
  // the explicit authority when set, otherwise the selected server.
371
- const tokenHosts = this._connectionString.apiKey
376
+ const tokenHosts = this._connectionString.apiKey || this._connectionString.noAuthentication
372
377
  ? []
373
378
  : remoteOnly(this._options.authority ? [new URL(this._options.authority).hostname] : candidateHosts);
374
379
  if (channelHosts.length === 0 && tokenHosts.length === 0) return;
@@ -391,6 +396,11 @@ export class ChronicleConnection implements ChronicleServices {
391
396
  const hasUsername = !!this._connectionString.username;
392
397
  const hasApiKey = !!this._connectionString.apiKey;
393
398
 
399
+ // Asking for no authentication is deliberate and beats anything else the connection string carries.
400
+ if (this._connectionString.noAuthentication) {
401
+ return new NoOpTokenProvider();
402
+ }
403
+
394
404
  if (hasApiKey) {
395
405
  return new NoOpTokenProvider();
396
406
  }
@@ -426,7 +436,7 @@ export class ChronicleConnection implements ChronicleServices {
426
436
  const endpoint = `${scheme}://${authorityHost.includes(':') && !authorityHost.startsWith('[') ? `[${authorityHost}]` : authorityHost}:${authorityPort}/connect/token`;
427
437
  let provider = this._tokenProviders.get(endpoint);
428
438
  if (!provider) {
429
- provider = new OAuthTokenProvider(endpoint, username, password, this._connectionString.skipTlsValidation);
439
+ provider = new OAuthTokenProvider(endpoint, username, password, this._connectionString.skipTlsValidation, undefined, this._tlsMaterial);
430
440
  this._tokenProviders.set(endpoint, provider);
431
441
  }
432
442
  return provider;
@@ -456,7 +466,7 @@ export class ChronicleConnection implements ChronicleServices {
456
466
  const metadata = options.metadata ? Metadata(options.metadata) : Metadata();
457
467
  metadata.set('authorization', `Bearer ${token}`);
458
468
  options.metadata = metadata;
459
- } else if (connectionString.apiKey) {
469
+ } else if (connectionString.apiKey && !connectionString.noAuthentication) {
460
470
  const metadata = options.metadata ? Metadata(options.metadata) : Metadata();
461
471
  metadata.set('api-key', connectionString.apiKey);
462
472
  options.metadata = metadata;
@@ -177,6 +177,91 @@ describe('ChronicleConnectionStringBuilder', () => {
177
177
  });
178
178
  });
179
179
 
180
+ describe('ChronicleConnectionStringBuilder options', () => {
181
+ describe('when parsing caCertificatePath', () => {
182
+ const builder = new ChronicleConnectionStringBuilder('chronicle://host:35000?caCertificatePath=%2Fetc%2Fca.pem');
183
+ it('should have the decoded path', () => expect(builder.caCertificatePath).toBe('/etc/ca.pem'));
184
+ });
185
+
186
+ describe('when caCertificatePath holds an at sign', () => {
187
+ const builder = new ChronicleConnectionStringBuilder('chronicle://host:35000?caCertificatePath=%2Fhome%2Fme@corp%2Fca.pem');
188
+ it('should keep it', () => expect(builder.caCertificatePath).toBe('/home/me@corp/ca.pem'));
189
+ });
190
+
191
+ describe('when parsing auth=none together with credentials', () => {
192
+ const builder = new ChronicleConnectionStringBuilder('chronicle://user:pass@host:35000?auth=none');
193
+ it('should be flagged as no authentication', () => expect(builder.noAuthentication).toBe(true));
194
+ it('should beat the credentials', () => expect(builder.authenticationMode).toBe(AuthenticationMode.None));
195
+ });
196
+
197
+ describe('when auth=none is spelled in another case', () => {
198
+ const builder = new ChronicleConnectionStringBuilder('chronicle://host:35000?AUTH=None');
199
+ it('should still be no authentication', () => expect(builder.noAuthentication).toBe(true));
200
+ });
201
+
202
+ describe('when there are no credentials', () => {
203
+ it('should use the development client credentials', () =>
204
+ expect(new ChronicleConnectionStringBuilder('chronicle://host:35000').authenticationMode).toBe(AuthenticationMode.ClientCredentials));
205
+ });
206
+
207
+ describe('when only a username is given', () => {
208
+ it('should throw', () =>
209
+ expect(() => new ChronicleConnectionStringBuilder('chronicle://user@host:35000').authenticationMode).toThrow());
210
+ });
211
+
212
+ describe('when parsing skipCompatibilityCheck and skipKeepAlive', () => {
213
+ const builder = new ChronicleConnectionStringBuilder('chronicle://host:35000?skipCompatibilityCheck=true&skipKeepAlive=true');
214
+ it('should skip the compatibility check', () => expect(builder.skipCompatibilityCheck).toBe(true));
215
+ it('should skip the keep-alive', () => expect(builder.skipKeepAlive).toBe(true));
216
+ });
217
+
218
+ describe('when the new flags are absent', () => {
219
+ const builder = new ChronicleConnectionStringBuilder('chronicle://host:35000');
220
+ it('should not skip the compatibility check', () => expect(builder.skipCompatibilityCheck).toBe(false));
221
+ it('should not be no authentication', () => expect(builder.noAuthentication).toBe(false));
222
+ it('should have no CA certificate path', () => expect(builder.caCertificatePath).toBeUndefined());
223
+ });
224
+
225
+ describe('when a boolean option is neither true nor false', () => {
226
+ const builder = new ChronicleConnectionStringBuilder('chronicle://host:35000?skipTlsValidation=maybe');
227
+ it('should throw naming the option', () => expect(() => builder.skipTlsValidation).toThrow(/skipTlsValidation/));
228
+ });
229
+
230
+ describe('when option names are spelled in another case', () => {
231
+ const builder = new ChronicleConnectionStringBuilder('chronicle://host:35000?APIKEY=abc&SkipTlsValidation=false&DISABLETLS=TRUE');
232
+ it('should read the api key', () => expect(builder.apiKey).toBe('abc'));
233
+ it('should read skipTlsValidation', () => expect(builder.skipTlsValidation).toBe(false));
234
+ it('should read disableTls', () => expect(builder.disableTls).toBe(true));
235
+ });
236
+
237
+ describe('when percent-decoding option values', () => {
238
+ const builder = new ChronicleConnectionStringBuilder('chronicle://host:35000?apiKey=a%2Bb+c%3D');
239
+ it('should decode once and keep a literal plus', () => expect(builder.apiKey).toBe('a+b+c='));
240
+ });
241
+
242
+ describe('when user information spilled an unencoded separator into the query', () => {
243
+ it('should throw', () =>
244
+ expect(() => new ChronicleConnectionStringBuilder('chronicle://user:pa?ss@host:35000')).toThrow(/percent-encoded/));
245
+ it('should throw for an at sign in an option that cannot hold one', () =>
246
+ expect(() => new ChronicleConnectionStringBuilder('chronicle://host:35000?disableTls=x@y')).toThrow(/percent-encoded/));
247
+ });
248
+
249
+ describe('when building credentials containing reserved characters', () => {
250
+ const builder = new ChronicleConnectionStringBuilder('chronicle://host:35000');
251
+ builder.username = 'al@ice';
252
+ builder.password = 'p:ss/w?rd';
253
+ const roundTripped = new ChronicleConnectionStringBuilder(builder.build());
254
+ it('should round trip the username', () => expect(roundTripped.username).toBe('al@ice'));
255
+ it('should round trip the password', () => expect(roundTripped.password).toBe('p:ss/w?rd'));
256
+ });
257
+
258
+ describe('when round tripping every option', () => {
259
+ const original = 'chronicle://host:35000?auth=none&disableTls=true&skipCompatibilityCheck=true&skipKeepAlive=true' +
260
+ '&certificatePath=%2Fc.p12&certificatePassword=pw&caCertificatePath=%2Fca.pem&custom=value';
261
+ it('should reproduce it', () => expect(new ChronicleConnectionStringBuilder(original).build()).toBe(original));
262
+ });
263
+ });
264
+
180
265
  describe('ChronicleConnectionString', () => {
181
266
  describe('when parsing a connection string with multiple hosts', () => {
182
267
  const connectionString = new ChronicleConnectionString('chronicle://host1:35001,host2:35002');
@@ -2,8 +2,10 @@
2
2
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
 
4
4
  import * as grpc from '@grpc/grpc-js';
5
+ import * as tls from 'node:tls';
5
6
  import { formatServerAddress } from './formatServerAddress.js';
6
7
  import { LoadBalancerMode } from './LoadBalancerMode.js';
8
+ import { loadTlsMaterial, type ChronicleTlsMaterial } from './ChronicleTlsMaterial.js';
7
9
 
8
10
  const DEFAULT_PORT = 35000;
9
11
  const SRV_SCHEME = 'chronicle+srv';
@@ -12,6 +14,8 @@ const SRV_SCHEME = 'chronicle+srv';
12
14
  * Authentication mode for Chronicle connection.
13
15
  */
14
16
  export enum AuthenticationMode {
17
+ /** No authentication at all (`auth=none`, or a cleartext connection without credentials). */
18
+ None = 'None',
15
19
  ClientCredentials = 'ClientCredentials',
16
20
  ApiKey = 'ApiKey'
17
21
  }
@@ -105,6 +109,21 @@ export class ChronicleConnectionStringBuilder {
105
109
  private static readonly _apiKeyKey = 'apiKey';
106
110
  private static readonly _disableTlsKey = 'disableTls';
107
111
  private static readonly _skipKeepAliveKey = 'skipKeepAlive';
112
+ private static readonly _authKey = 'auth';
113
+ private static readonly _skipCompatibilityCheckKey = 'skipCompatibilityCheck';
114
+ private static readonly _caCertificatePathKey = 'caCertificatePath';
115
+ private static readonly _noAuthenticationValue = 'none';
116
+
117
+ /** Every option the builder knows, so a differently cased spelling folds to its canonical one. */
118
+ private static readonly _knownKeys = new Map<string, string>([
119
+ 'apiKey', 'auth', 'skipTlsValidation', 'disableTls', 'skipCompatibilityCheck', 'skipKeepAlive',
120
+ 'loadBalancer', 'srvNameServer', 'certificatePath', 'certificatePassword', 'caCertificatePath'
121
+ ].map(key => [key.toLowerCase(), key]));
122
+
123
+ /** Options whose value may legitimately hold an at sign, such as a path or a name server. */
124
+ private static readonly _keysThatMayHoldAtSign = new Set([
125
+ 'apikey', 'certificatepath', 'certificatepassword', 'cacertificatepath', 'loadbalancer', 'srvnameserver'
126
+ ]);
108
127
  private static readonly _skipTlsValidationKey = 'skipTlsValidation';
109
128
  private static readonly _certificatePathKey = 'certificatePath';
110
129
  private static readonly _certificatePasswordKey = 'certificatePassword';
@@ -198,14 +217,24 @@ export class ChronicleConnectionStringBuilder {
198
217
  }
199
218
 
200
219
  get authenticationMode(): AuthenticationMode {
201
- const hasClientCredentials = !!this.username && !!this.password;
220
+ const hasUsername = !!this.username;
221
+ const hasPassword = !!this.password;
222
+ const hasClientCredentials = hasUsername && hasPassword;
202
223
  const hasApiKey = !!this.apiKey;
224
+ const hasNoCredentials = !hasUsername && !hasPassword && !hasApiKey;
225
+
226
+ // Asking for no authentication is deliberate and beats anything else the connection string carries -
227
+ // credentials left in place by a shared configuration must not quietly turn the exchange back on.
228
+ if (this.noAuthentication) {
229
+ return AuthenticationMode.None;
230
+ }
203
231
 
204
232
  if (hasClientCredentials && hasApiKey) {
205
233
  throw new Error('Cannot specify both username/password and apiKey in the connection string');
206
234
  }
207
235
 
208
- if (hasClientCredentials) {
236
+ // No credentials at all means the development client credentials.
237
+ if (hasClientCredentials || hasNoCredentials) {
209
238
  return AuthenticationMode.ClientCredentials;
210
239
  }
211
240
 
@@ -213,7 +242,24 @@ export class ChronicleConnectionStringBuilder {
213
242
  return AuthenticationMode.ApiKey;
214
243
  }
215
244
 
216
- throw new Error('No authentication method specified. Provide either username/password or apiKey in the connection string');
245
+ throw new Error('Incomplete authentication. Provide both username and password, or an apiKey, in the connection string');
246
+ }
247
+
248
+ /**
249
+ * Whether `auth=none` is set: no authentication at all. It wins over any credentials or API key the
250
+ * connection string also carries.
251
+ */
252
+ get noAuthentication(): boolean {
253
+ return this._properties.get(ChronicleConnectionStringBuilder._authKey)?.toLowerCase() === ChronicleConnectionStringBuilder._noAuthenticationValue;
254
+ }
255
+
256
+ set noAuthentication(value: boolean) {
257
+ if (value) {
258
+ this._properties.set(ChronicleConnectionStringBuilder._authKey, ChronicleConnectionStringBuilder._noAuthenticationValue);
259
+ return;
260
+ }
261
+
262
+ this._properties.delete(ChronicleConnectionStringBuilder._authKey);
217
263
  }
218
264
 
219
265
  get apiKey(): string | undefined {
@@ -230,7 +276,7 @@ export class ChronicleConnectionStringBuilder {
230
276
  }
231
277
 
232
278
  get disableTls(): boolean {
233
- return this._properties.get(ChronicleConnectionStringBuilder._disableTlsKey) === 'true';
279
+ return this.booleanOption(ChronicleConnectionStringBuilder._disableTlsKey, false);
234
280
  }
235
281
 
236
282
  set disableTls(value: boolean) {
@@ -245,8 +291,7 @@ export class ChronicleConnectionStringBuilder {
245
291
  * always requires validation. A later major release will require validation by default.
246
292
  */
247
293
  get skipTlsValidation(): boolean {
248
- const raw = this._properties.get(ChronicleConnectionStringBuilder._skipTlsValidationKey);
249
- return raw === undefined || raw === 'true';
294
+ return this.booleanOption(ChronicleConnectionStringBuilder._skipTlsValidationKey, true);
250
295
  }
251
296
 
252
297
  set skipTlsValidation(value: boolean) {
@@ -260,7 +305,7 @@ export class ChronicleConnectionStringBuilder {
260
305
 
261
306
  /** Skip the client keep-alive connection for short-lived processes. Defaults to false. */
262
307
  get skipKeepAlive(): boolean {
263
- return this._properties.get(ChronicleConnectionStringBuilder._skipKeepAliveKey) === 'true';
308
+ return this.booleanOption(ChronicleConnectionStringBuilder._skipKeepAliveKey, false);
264
309
  }
265
310
 
266
311
  set skipKeepAlive(value: boolean) {
@@ -293,6 +338,37 @@ export class ChronicleConnectionStringBuilder {
293
338
  this._properties.delete(ChronicleConnectionStringBuilder._certificatePasswordKey);
294
339
  }
295
340
 
341
+ /**
342
+ * Whether to skip the server compatibility check on connect (`skipCompatibilityCheck=true`). An escape hatch
343
+ * for a known-safe client and kernel skew; it hides every other incompatibility too.
344
+ */
345
+ get skipCompatibilityCheck(): boolean {
346
+ return this.booleanOption(ChronicleConnectionStringBuilder._skipCompatibilityCheckKey, false);
347
+ }
348
+
349
+ set skipCompatibilityCheck(value: boolean) {
350
+ this._properties.set(ChronicleConnectionStringBuilder._skipCompatibilityCheckKey, value.toString());
351
+ }
352
+
353
+ /**
354
+ * The path to a PEM file with the certificate authorities the server certificate must chain to, in place of
355
+ * the system trust store (`caCertificatePath=`). Used only when `skipTlsValidation=false`; the file is
356
+ * nevertheless read when the connection is created, so a missing or unreadable file, or one without
357
+ * certificates, fails the connection setup.
358
+ */
359
+ get caCertificatePath(): string | undefined {
360
+ return this._properties.get(ChronicleConnectionStringBuilder._caCertificatePathKey);
361
+ }
362
+
363
+ set caCertificatePath(value: string | undefined) {
364
+ if (value) {
365
+ this._properties.set(ChronicleConnectionStringBuilder._caCertificatePathKey, value);
366
+ return;
367
+ }
368
+
369
+ this._properties.delete(ChronicleConnectionStringBuilder._caCertificatePathKey);
370
+ }
371
+
296
372
  /**
297
373
  * The strategy used to select one address from {@link hosts} (or the addresses
298
374
  * resolved from a `chronicle+srv://` host) on every connect/reconnect attempt.
@@ -342,9 +418,9 @@ export class ChronicleConnectionStringBuilder {
342
418
  let result = `${this.scheme}://`;
343
419
 
344
420
  if (this.username) {
345
- result += this.username;
421
+ result += encodeURIComponent(this.username);
346
422
  if (this.password) {
347
- result += `:${this.password}`;
423
+ result += `:${encodeURIComponent(this.password)}`;
348
424
  }
349
425
  result += '@';
350
426
  }
@@ -357,10 +433,18 @@ export class ChronicleConnectionStringBuilder {
357
433
  queryParameters.push(`apiKey=${encodeURIComponent(this.apiKey)}`);
358
434
  }
359
435
 
436
+ if (this.noAuthentication) {
437
+ queryParameters.push(`auth=${ChronicleConnectionStringBuilder._noAuthenticationValue}`);
438
+ }
439
+
360
440
  if (this.disableTls) {
361
441
  queryParameters.push('disableTls=true');
362
442
  }
363
443
 
444
+ if (this.skipCompatibilityCheck) {
445
+ queryParameters.push('skipCompatibilityCheck=true');
446
+ }
447
+
364
448
  this.appendSkipKeepAlive(queryParameters);
365
449
 
366
450
  if (this.hasExplicitSkipTlsValidation) {
@@ -375,6 +459,10 @@ export class ChronicleConnectionStringBuilder {
375
459
  queryParameters.push(`certificatePassword=${encodeURIComponent(this.certificatePassword)}`);
376
460
  }
377
461
 
462
+ if (this.caCertificatePath) {
463
+ queryParameters.push(`caCertificatePath=${encodeURIComponent(this.caCertificatePath)}`);
464
+ }
465
+
378
466
  if (this._properties.has(ChronicleConnectionStringBuilder._loadBalancerKey)) {
379
467
  queryParameters.push(`loadBalancer=${encodeURIComponent(this.loadBalancer)}`);
380
468
  }
@@ -389,6 +477,9 @@ export class ChronicleConnectionStringBuilder {
389
477
  key !== ChronicleConnectionStringBuilder._passwordKey &&
390
478
  key !== ChronicleConnectionStringBuilder._schemeKey &&
391
479
  key !== ChronicleConnectionStringBuilder._apiKeyKey &&
480
+ key !== ChronicleConnectionStringBuilder._authKey &&
481
+ key !== ChronicleConnectionStringBuilder._skipCompatibilityCheckKey &&
482
+ key !== ChronicleConnectionStringBuilder._caCertificatePathKey &&
392
483
  key !== ChronicleConnectionStringBuilder._disableTlsKey &&
393
484
  key !== ChronicleConnectionStringBuilder._skipTlsValidationKey &&
394
485
  key !== ChronicleConnectionStringBuilder._certificatePathKey &&
@@ -407,6 +498,37 @@ export class ChronicleConnectionStringBuilder {
407
498
  return result;
408
499
  }
409
500
 
501
+ private booleanOption(key: string, defaultValue: boolean): boolean {
502
+ const raw = this._properties.get(key);
503
+ if (raw === undefined) {
504
+ return defaultValue;
505
+ }
506
+
507
+ const normalized = raw.toLowerCase();
508
+ if (normalized === 'true') {
509
+ return true;
510
+ }
511
+
512
+ if (normalized === 'false') {
513
+ return false;
514
+ }
515
+
516
+ throw new Error(`The value of the '${key}' option is invalid.`);
517
+ }
518
+
519
+ private static hasMisplacedAtSign(pair: string): boolean {
520
+ if (!pair.includes('@')) {
521
+ return false;
522
+ }
523
+
524
+ const equalsIndex = pair.indexOf('=');
525
+ if (equalsIndex === -1 || pair.indexOf('@') < equalsIndex) {
526
+ return true;
527
+ }
528
+
529
+ return !ChronicleConnectionStringBuilder._keysThatMayHoldAtSign.has(decodeURIComponent(pair.slice(0, equalsIndex)).toLowerCase());
530
+ }
531
+
410
532
  private appendSkipKeepAlive(queryParameters: string[]): void {
411
533
  if (this.skipKeepAlive) queryParameters.push('skipKeepAlive=true');
412
534
  }
@@ -442,6 +564,13 @@ export class ChronicleConnectionStringBuilder {
442
564
  query = queryIndex === -1 ? '' : rest.slice(queryIndex + 1);
443
565
  }
444
566
 
567
+ // An at sign in the query means the user information held a separator that was not percent-encoded
568
+ // and spilled into it - unless the option is one that may hold one.
569
+ const pairs = query.length === 0 ? [] : query.split('&');
570
+ if (pairs.some(pair => ChronicleConnectionStringBuilder.hasMisplacedAtSign(pair))) {
571
+ throw new Error('The user information must be percent-encoded: it contains a separator');
572
+ }
573
+
445
574
  // The userinfo separator is the LAST '@' in the authority, so a host portion never
446
575
  // legitimately containing '@' can't be confused for one.
447
576
  const authoritySeparatorIndex = authority.lastIndexOf('@');
@@ -463,8 +592,17 @@ export class ChronicleConnectionStringBuilder {
463
592
  }
464
593
  this.hosts = hosts;
465
594
 
466
- for (const [key, queryValue] of new URLSearchParams(query)) {
467
- this._properties.set(key, decodeURIComponent(queryValue));
595
+ // Percent-decoding only: a literal '+' stays a plus, like the .NET client, and the value is decoded once.
596
+ for (const pair of pairs) {
597
+ const equalsIndex = pair.indexOf('=');
598
+ if (equalsIndex <= 0) {
599
+ continue;
600
+ }
601
+
602
+ const key = decodeURIComponent(pair.slice(0, equalsIndex));
603
+ this._properties.set(
604
+ ChronicleConnectionStringBuilder._knownKeys.get(key.toLowerCase()) ?? key,
605
+ decodeURIComponent(pair.slice(equalsIndex + 1)));
468
606
  }
469
607
  } catch (error) {
470
608
  throw new Error(`Invalid Chronicle connection string: ${error}`);
@@ -548,6 +686,21 @@ export class ChronicleConnectionString {
548
686
  return this._builder.skipKeepAlive;
549
687
  }
550
688
 
689
+ /** Whether `auth=none` is set: no authentication at all. */
690
+ get noAuthentication(): boolean {
691
+ return this._builder.noAuthentication;
692
+ }
693
+
694
+ /** Whether to skip the server compatibility check on connect. */
695
+ get skipCompatibilityCheck(): boolean {
696
+ return this._builder.skipCompatibilityCheck;
697
+ }
698
+
699
+ /** The path to a PEM file with the certificate authorities the server certificate must chain to. */
700
+ get caCertificatePath(): string | undefined {
701
+ return this._builder.caCertificatePath;
702
+ }
703
+
551
704
  /**
552
705
  * Whether TLS certificate validation is skipped. See
553
706
  * {@link ChronicleConnectionStringBuilder.skipTlsValidation}.
@@ -587,20 +740,41 @@ export class ChronicleConnectionString {
587
740
  const builder = new ChronicleConnectionStringBuilder(this.toString());
588
741
  builder.username = username;
589
742
  builder.password = password;
743
+ builder.noAuthentication = false;
590
744
  return new ChronicleConnectionString(builder.build());
591
745
  }
592
746
 
593
747
  withApiKey(apiKey: string): ChronicleConnectionString {
594
748
  const builder = new ChronicleConnectionStringBuilder(this.toString());
595
749
  builder.apiKey = apiKey;
750
+ builder.noAuthentication = false;
596
751
  return new ChronicleConnectionString(builder.build());
597
752
  }
598
753
 
599
- createCredentials(): grpc.ChannelCredentials {
754
+ /**
755
+ * Loads the TLS material the connection string names: the client certificate from `certificatePath` and the
756
+ * certificate authorities from `caCertificatePath`.
757
+ * @throws When a file is missing, unreadable or holds no usable material.
758
+ */
759
+ loadTlsMaterial(): ChronicleTlsMaterial {
760
+ return loadTlsMaterial(this);
761
+ }
762
+
763
+ /**
764
+ * Creates the gRPC channel credentials for this connection string.
765
+ * @param tlsMaterial - The TLS material to use. Defaults to loading what the connection string names.
766
+ */
767
+ createCredentials(tlsMaterial: ChronicleTlsMaterial = loadTlsMaterial(this)): grpc.ChannelCredentials {
600
768
  if (this.disableTls) {
601
769
  return grpc.credentials.createInsecure();
602
770
  }
603
771
 
772
+ if (!tlsMaterial.isEmpty) {
773
+ return grpc.credentials.createFromSecureContext(
774
+ tls.createSecureContext(tlsMaterial.connectOptions(this.skipTlsValidation)),
775
+ { rejectUnauthorized: !this.skipTlsValidation });
776
+ }
777
+
604
778
  if (this.skipTlsValidation) {
605
779
  // Chronicle generates a self-signed certificate in development, and skipTlsValidation
606
780
  // defaults to true so this works without extra configuration. grpc-js has no