@reventlessdev/reventless-local 3.0.0-alpha.113

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 (334) hide show
  1. package/CHANGELOG.md +1197 -0
  2. package/LICENSE +202 -0
  3. package/__mocks__/emptyModule.js +2 -0
  4. package/__mocks__/nodeSqlite.mjs +6 -0
  5. package/package.json +67 -0
  6. package/rescript.json +39 -0
  7. package/src/Platform.res +2162 -0
  8. package/src/Platform.res.mjs +3389 -0
  9. package/src/adapter/Api/LocalGraphQL_Adapter.res +29 -0
  10. package/src/adapter/Api/LocalGraphQL_Adapter.res.mjs +26 -0
  11. package/src/adapter/Api/LocalGraphQL_SubscriptionResolvers.res +146 -0
  12. package/src/adapter/Api/LocalGraphQL_SubscriptionResolvers.res.mjs +88 -0
  13. package/src/adapter/Auth/Auth_GraphqlContext.res +83 -0
  14. package/src/adapter/Auth/Auth_GraphqlContext.res.mjs +76 -0
  15. package/src/adapter/Auth/LocalAuth.res +239 -0
  16. package/src/adapter/Auth/LocalAuth.res.mjs +247 -0
  17. package/src/adapter/Auth/UserStore.res +134 -0
  18. package/src/adapter/Auth/UserStore.res.mjs +146 -0
  19. package/src/adapter/Backend.res +46 -0
  20. package/src/adapter/Backend.res.mjs +66 -0
  21. package/src/adapter/BackendState.res +34 -0
  22. package/src/adapter/BackendState.res.mjs +42 -0
  23. package/src/adapter/Cloner/LocalClonerRunner.res +13 -0
  24. package/src/adapter/Cloner/LocalClonerRunner.res.mjs +12 -0
  25. package/src/adapter/CommandGenerator/CommandGeneratorResolvers_GraphQL.res +329 -0
  26. package/src/adapter/CommandGenerator/CommandGeneratorResolvers_GraphQL.res.mjs +301 -0
  27. package/src/adapter/CommandGenerator/InboundTranslationResolvers_GraphQL.res +76 -0
  28. package/src/adapter/CommandGenerator/InboundTranslationResolvers_GraphQL.res.mjs +57 -0
  29. package/src/adapter/CommandGenerator/LocalCommandGeneratorResolvers.res +19 -0
  30. package/src/adapter/CommandGenerator/LocalCommandGeneratorResolvers.res.mjs +19 -0
  31. package/src/adapter/CommandTopic/LocalCommandTopicChannel.res +104 -0
  32. package/src/adapter/CommandTopic/LocalCommandTopicChannel.res.mjs +82 -0
  33. package/src/adapter/CommandTopic/LocalCommandTopicRemoteChannel.res +32 -0
  34. package/src/adapter/CommandTopic/LocalCommandTopicRemoteChannel.res.mjs +38 -0
  35. package/src/adapter/Counter/LocalCounterHandler.res +42 -0
  36. package/src/adapter/Counter/LocalCounterHandler.res.mjs +45 -0
  37. package/src/adapter/DcbEventLog/DcbEventLogStorage_InMemory.res +131 -0
  38. package/src/adapter/DcbEventLog/DcbEventLogStorage_InMemory.res.mjs +140 -0
  39. package/src/adapter/DcbEventLog/DcbEventLogStorage_Sqlite.res +334 -0
  40. package/src/adapter/DcbEventLog/DcbEventLogStorage_Sqlite.res.mjs +299 -0
  41. package/src/adapter/DomainGraphQL_Server.res +565 -0
  42. package/src/adapter/DomainGraphQL_Server.res.mjs +576 -0
  43. package/src/adapter/DomainMCP_Server.res +369 -0
  44. package/src/adapter/DomainMCP_Server.res.mjs +358 -0
  45. package/src/adapter/EventCollector/LocalEventCollectorChannel.res +87 -0
  46. package/src/adapter/EventCollector/LocalEventCollectorChannel.res.mjs +45 -0
  47. package/src/adapter/EventLog/EventLogStorage_InMemory.res +105 -0
  48. package/src/adapter/EventLog/EventLogStorage_InMemory.res.mjs +117 -0
  49. package/src/adapter/EventLog/EventLogStorage_Sqlite.res +145 -0
  50. package/src/adapter/EventLog/EventLogStorage_Sqlite.res.mjs +155 -0
  51. package/src/adapter/EventTopic/LocalEventTopicPublisher.res +36 -0
  52. package/src/adapter/EventTopic/LocalEventTopicPublisher.res.mjs +31 -0
  53. package/src/adapter/GraphQL_Server.res +6 -0
  54. package/src/adapter/GraphQL_Server.res.mjs +154 -0
  55. package/src/adapter/GraphQL_ServerInstance.res +310 -0
  56. package/src/adapter/GraphQL_ServerInstance.res.mjs +257 -0
  57. package/src/adapter/Heartbeat/LocalHeartbeatRunner.res +57 -0
  58. package/src/adapter/Heartbeat/LocalHeartbeatRunner.res.mjs +34 -0
  59. package/src/adapter/LocalBus.res +498 -0
  60. package/src/adapter/LocalBus.res.mjs +1011 -0
  61. package/src/adapter/LocalPluginSpec.res +16 -0
  62. package/src/adapter/LocalPluginSpec.res.mjs +33 -0
  63. package/src/adapter/LocalSideEffectHandler.res +44 -0
  64. package/src/adapter/LocalSideEffectHandler.res.mjs +34 -0
  65. package/src/adapter/MCP_Server.res +4 -0
  66. package/src/adapter/MCP_Server.res.mjs +67 -0
  67. package/src/adapter/MCP_ServerInstance.res +362 -0
  68. package/src/adapter/MCP_ServerInstance.res.mjs +313 -0
  69. package/src/adapter/PlatformGraphQL_Server.res +75 -0
  70. package/src/adapter/PlatformGraphQL_Server.res.mjs +84 -0
  71. package/src/adapter/PlatformMCP_Server.res +23 -0
  72. package/src/adapter/PlatformMCP_Server.res.mjs +46 -0
  73. package/src/adapter/QueryDb/QueryDbResolvers_GraphQL.res +793 -0
  74. package/src/adapter/QueryDb/QueryDbResolvers_GraphQL.res.mjs +569 -0
  75. package/src/adapter/QueryDb/QueryDbStorage_InMemory.res +242 -0
  76. package/src/adapter/QueryDb/QueryDbStorage_InMemory.res.mjs +241 -0
  77. package/src/adapter/QueryDb/QueryDbStorage_Sqlite.res +339 -0
  78. package/src/adapter/QueryDb/QueryDbStorage_Sqlite.res.mjs +318 -0
  79. package/src/adapter/QueryDb/SortKey_Filter.res +48 -0
  80. package/src/adapter/QueryDb/SortKey_Filter.res.mjs +46 -0
  81. package/src/adapter/QueryEngine/LocalQueryEngine.res +57 -0
  82. package/src/adapter/QueryEngine/LocalQueryEngine.res.mjs +56 -0
  83. package/src/adapter/Runtime/LocalAggregateRuntime_Builder.res +91 -0
  84. package/src/adapter/Runtime/LocalAggregateRuntime_Builder.res.mjs +50 -0
  85. package/src/adapter/Runtime/LocalEventCollectorRuntime_Builder.res +47 -0
  86. package/src/adapter/Runtime/LocalEventCollectorRuntime_Builder.res.mjs +37 -0
  87. package/src/adapter/Runtime/LocalPluginRuntime_Builder.res +11 -0
  88. package/src/adapter/Runtime/LocalPluginRuntime_Builder.res.mjs +30 -0
  89. package/src/adapter/Runtime/LocalRuntimeEnvironment.res +54 -0
  90. package/src/adapter/Runtime/LocalRuntimeEnvironment.res.mjs +40 -0
  91. package/src/adapter/Scheduler/LocalScheduledPublisher.res +102 -0
  92. package/src/adapter/Scheduler/LocalScheduledPublisher.res.mjs +84 -0
  93. package/src/adapter/SqliteDriver.res +52 -0
  94. package/src/adapter/SqliteDriver.res.mjs +76 -0
  95. package/src/adapter/SqliteDriver.resi +31 -0
  96. package/src/adapter/Task/LocalTaskBucket.res +75 -0
  97. package/src/adapter/Task/LocalTaskBucket.res.mjs +48 -0
  98. package/src/adapter/Task/TaskBucket_Sqlite.res +47 -0
  99. package/src/adapter/Task/TaskBucket_Sqlite.res.mjs +40 -0
  100. package/src/components/Aggregate_Builder.res +55 -0
  101. package/src/components/Aggregate_Builder.res.mjs +140 -0
  102. package/src/components/AutomationSlice_Builder.res +41 -0
  103. package/src/components/AutomationSlice_Builder.res.mjs +57 -0
  104. package/src/components/Counter_Builder.res +14 -0
  105. package/src/components/Counter_Builder.res.mjs +32 -0
  106. package/src/components/DcbEventLog_Builder.res +18 -0
  107. package/src/components/DcbEventLog_Builder.res.mjs +24 -0
  108. package/src/components/ExtensionPoint_Builder.res +25 -0
  109. package/src/components/ExtensionPoint_Builder.res.mjs +44 -0
  110. package/src/components/InboundTranslationSlice_Builder.res +34 -0
  111. package/src/components/InboundTranslationSlice_Builder.res.mjs +45 -0
  112. package/src/components/OutboundTranslationSlice_Builder.res +43 -0
  113. package/src/components/OutboundTranslationSlice_Builder.res.mjs +59 -0
  114. package/src/components/Plugin_Builder.res +37 -0
  115. package/src/components/Plugin_Builder.res.mjs +67 -0
  116. package/src/components/ReadModel_Builder.res +47 -0
  117. package/src/components/ReadModel_Builder.res.mjs +54 -0
  118. package/src/components/StateChangeSlice_Builder.res +19 -0
  119. package/src/components/StateChangeSlice_Builder.res.mjs +21 -0
  120. package/src/components/StateViewSlice_Builder.res +42 -0
  121. package/src/components/StateViewSlice_Builder.res.mjs +58 -0
  122. package/src/components/Task_Builder.res +28 -0
  123. package/src/components/Task_Builder.res.mjs +41 -0
  124. package/src/reexport/CommandTopic.res +3 -0
  125. package/src/reexport/CommandTopic.res.mjs +55 -0
  126. package/src/test/Mocks/MockDcbEventLogStorage.res +136 -0
  127. package/src/test/Mocks/MockDcbEventLogStorage.res.mjs +146 -0
  128. package/src/test/Mocks/MockEventLogStorage.res +57 -0
  129. package/src/test/Mocks/MockEventLogStorage.res.mjs +65 -0
  130. package/src/test/Mocks/MockPublisher.res +29 -0
  131. package/src/test/Mocks/MockPublisher.res.mjs +28 -0
  132. package/src/test/Mocks/MockQueryDbStorage.res +104 -0
  133. package/src/test/Mocks/MockQueryDbStorage.res.mjs +136 -0
  134. package/src/test/TestRunner.res +96 -0
  135. package/src/test/TestRunner.res.mjs +71 -0
  136. package/tests/SplitApiFixtures.res +84 -0
  137. package/tests/SplitApiFixtures.res.mjs +88 -0
  138. package/tests/SplitApiTest.res +102 -0
  139. package/tests/SplitApiTest.res.mjs +82 -0
  140. package/tests/TestFixtures.res +54 -0
  141. package/tests/TestFixtures.res.mjs +65 -0
  142. package/tests/adapter/BackendParityTest.res +94 -0
  143. package/tests/adapter/BackendParityTest.res.mjs +96 -0
  144. package/tests/adapter/CollectNEventsTest.res +82 -0
  145. package/tests/adapter/CollectNEventsTest.res.mjs +83 -0
  146. package/tests/adapter/CommandAuthorizationTest.res +200 -0
  147. package/tests/adapter/CommandAuthorizationTest.res.mjs +190 -0
  148. package/tests/adapter/CommandTopicChannelTest.res +174 -0
  149. package/tests/adapter/CommandTopicChannelTest.res.mjs +170 -0
  150. package/tests/adapter/CounterHandlerTest.res +113 -0
  151. package/tests/adapter/CounterHandlerTest.res.mjs +96 -0
  152. package/tests/adapter/DcbEventLogStorageSqliteTest.res +157 -0
  153. package/tests/adapter/DcbEventLogStorageSqliteTest.res.mjs +165 -0
  154. package/tests/adapter/DcbEventLogStorageTest.res +187 -0
  155. package/tests/adapter/DcbEventLogStorageTest.res.mjs +195 -0
  156. package/tests/adapter/EventCollectorChannelTest.res +166 -0
  157. package/tests/adapter/EventCollectorChannelTest.res.mjs +178 -0
  158. package/tests/adapter/EventLogStorageSqliteTest.res +105 -0
  159. package/tests/adapter/EventLogStorageSqliteTest.res.mjs +116 -0
  160. package/tests/adapter/EventTapTest.res +102 -0
  161. package/tests/adapter/EventTapTest.res.mjs +94 -0
  162. package/tests/adapter/EventTopicPublisherTest.res +76 -0
  163. package/tests/adapter/EventTopicPublisherTest.res.mjs +86 -0
  164. package/tests/adapter/GraphQL_SchemaInspectorTest.res +763 -0
  165. package/tests/adapter/GraphQL_SchemaInspectorTest.res.mjs +578 -0
  166. package/tests/adapter/GraphQL_SubscriptionResolversTest.res +161 -0
  167. package/tests/adapter/GraphQL_SubscriptionResolversTest.res.mjs +134 -0
  168. package/tests/adapter/HeartbeatRunnerTest.res +136 -0
  169. package/tests/adapter/HeartbeatRunnerTest.res.mjs +96 -0
  170. package/tests/adapter/LocalAuthHttpTest.res +224 -0
  171. package/tests/adapter/LocalAuthHttpTest.res.mjs +237 -0
  172. package/tests/adapter/LocalAuthLoginTest.res +180 -0
  173. package/tests/adapter/LocalAuthLoginTest.res.mjs +207 -0
  174. package/tests/adapter/LocalAuthTest.res +106 -0
  175. package/tests/adapter/LocalAuthTest.res.mjs +145 -0
  176. package/tests/adapter/LocalAuthUserStoreTest.res +172 -0
  177. package/tests/adapter/LocalAuthUserStoreTest.res.mjs +208 -0
  178. package/tests/adapter/LocalBusBoundedTest.res +157 -0
  179. package/tests/adapter/LocalBusBoundedTest.res.mjs +168 -0
  180. package/tests/adapter/LocalBusPubSubTest.res +81 -0
  181. package/tests/adapter/LocalBusPubSubTest.res.mjs +81 -0
  182. package/tests/adapter/QueryDbGsiTtlTest.res +268 -0
  183. package/tests/adapter/QueryDbGsiTtlTest.res.mjs +209 -0
  184. package/tests/adapter/QueryDbListResolverTest.res +361 -0
  185. package/tests/adapter/QueryDbListResolverTest.res.mjs +426 -0
  186. package/tests/adapter/QueryDbStorageSqliteTest.res +159 -0
  187. package/tests/adapter/QueryDbStorageSqliteTest.res.mjs +126 -0
  188. package/tests/adapter/QueryDbStorageTest.res +171 -0
  189. package/tests/adapter/QueryDbStorageTest.res.mjs +170 -0
  190. package/tests/adapter/QueryEngineTest.res +152 -0
  191. package/tests/adapter/QueryEngineTest.res.mjs +148 -0
  192. package/tests/adapter/ScheduledPublisherTest.res +199 -0
  193. package/tests/adapter/ScheduledPublisherTest.res.mjs +203 -0
  194. package/tests/adapter/SortKey_FilterTest.res +103 -0
  195. package/tests/adapter/SortKey_FilterTest.res.mjs +135 -0
  196. package/tests/adapter/SqliteDriverTest.res +86 -0
  197. package/tests/adapter/SqliteDriverTest.res.mjs +101 -0
  198. package/tests/adapter/TaskBucketSqliteTest.res +44 -0
  199. package/tests/adapter/TaskBucketSqliteTest.res.mjs +40 -0
  200. package/tests/adapter/TaskBucketTest.res +106 -0
  201. package/tests/adapter/TaskBucketTest.res.mjs +118 -0
  202. package/tests/components/aggregate/AggregateFixtures.res +78 -0
  203. package/tests/components/aggregate/AggregateFixtures.res.mjs +109 -0
  204. package/tests/components/aggregate/AggregateTest.res +129 -0
  205. package/tests/components/aggregate/AggregateTest.res.mjs +129 -0
  206. package/tests/components/automationslice/AutomationSliceCallbackTest.res +212 -0
  207. package/tests/components/automationslice/AutomationSliceCallbackTest.res.mjs +233 -0
  208. package/tests/components/automationslice/AutomationSliceFixtures.res +189 -0
  209. package/tests/components/automationslice/AutomationSliceFixtures.res.mjs +276 -0
  210. package/tests/components/automationslice/AutomationSliceSelfDeadlockFixtures.res +289 -0
  211. package/tests/components/automationslice/AutomationSliceSelfDeadlockFixtures.res.mjs +453 -0
  212. package/tests/components/automationslice/AutomationSliceSelfDeadlockTest.res +47 -0
  213. package/tests/components/automationslice/AutomationSliceSelfDeadlockTest.res.mjs +31 -0
  214. package/tests/components/automationslice/MixedSourceAutomationSliceFixtures.res +213 -0
  215. package/tests/components/automationslice/MixedSourceAutomationSliceFixtures.res.mjs +268 -0
  216. package/tests/components/automationslice/MixedSourceAutomationSliceTest.res +118 -0
  217. package/tests/components/automationslice/MixedSourceAutomationSliceTest.res.mjs +99 -0
  218. package/tests/components/commandgenerator/CommandGeneratorFixtures.res +73 -0
  219. package/tests/components/commandgenerator/CommandGeneratorFixtures.res.mjs +109 -0
  220. package/tests/components/commandgenerator/CommandGeneratorTest.res +43 -0
  221. package/tests/components/commandgenerator/CommandGeneratorTest.res.mjs +46 -0
  222. package/tests/components/commandtopic/CommandTopicFixtures.res +37 -0
  223. package/tests/components/commandtopic/CommandTopicFixtures.res.mjs +68 -0
  224. package/tests/components/commandtopic/CommandTopicStreamFixtures.res +43 -0
  225. package/tests/components/commandtopic/CommandTopicStreamFixtures.res.mjs +91 -0
  226. package/tests/components/commandtopic/CommandTopicStreamTest.res +30 -0
  227. package/tests/components/commandtopic/CommandTopicStreamTest.res.mjs +35 -0
  228. package/tests/components/commandtopic/CommandTopicTest.res +55 -0
  229. package/tests/components/commandtopic/CommandTopicTest.res.mjs +62 -0
  230. package/tests/components/counter/CounterFixtures.res +42 -0
  231. package/tests/components/counter/CounterFixtures.res.mjs +34 -0
  232. package/tests/components/counter/CounterTest.res +46 -0
  233. package/tests/components/counter/CounterTest.res.mjs +61 -0
  234. package/tests/components/dcb/DcbCrossPartitionFixtures.res +170 -0
  235. package/tests/components/dcb/DcbCrossPartitionFixtures.res.mjs +276 -0
  236. package/tests/components/dcb/DcbCrossPartitionReadTest.res +68 -0
  237. package/tests/components/dcb/DcbCrossPartitionReadTest.res.mjs +78 -0
  238. package/tests/components/dcb/DcbEventLogAppendStreamTest.res +72 -0
  239. package/tests/components/dcb/DcbEventLogAppendStreamTest.res.mjs +82 -0
  240. package/tests/components/dcb/DcbEventLogStreamTest.res +103 -0
  241. package/tests/components/dcb/DcbEventLogStreamTest.res.mjs +91 -0
  242. package/tests/components/dcb/DcbFixtures.res +145 -0
  243. package/tests/components/dcb/DcbFixtures.res.mjs +221 -0
  244. package/tests/components/dcb/DcbTest.res +55 -0
  245. package/tests/components/dcb/DcbTest.res.mjs +55 -0
  246. package/tests/components/eventcollector/EventCollectorFixtures.res +42 -0
  247. package/tests/components/eventcollector/EventCollectorFixtures.res.mjs +49 -0
  248. package/tests/components/eventcollector/EventCollectorTest.res +37 -0
  249. package/tests/components/eventcollector/EventCollectorTest.res.mjs +36 -0
  250. package/tests/components/eventlog/EventLogAppendStreamTest.res +93 -0
  251. package/tests/components/eventlog/EventLogAppendStreamTest.res.mjs +113 -0
  252. package/tests/components/eventlog/EventLogConflictTest.res +86 -0
  253. package/tests/components/eventlog/EventLogConflictTest.res.mjs +81 -0
  254. package/tests/components/eventlog/EventLogFixtures.res +52 -0
  255. package/tests/components/eventlog/EventLogFixtures.res.mjs +80 -0
  256. package/tests/components/eventlog/EventLogStreamTest.res +98 -0
  257. package/tests/components/eventlog/EventLogStreamTest.res.mjs +142 -0
  258. package/tests/components/eventlog/EventLogTest.res +53 -0
  259. package/tests/components/eventlog/EventLogTest.res.mjs +74 -0
  260. package/tests/components/eventtopic/EventTopicFixtures.res +47 -0
  261. package/tests/components/eventtopic/EventTopicFixtures.res.mjs +77 -0
  262. package/tests/components/eventtopic/EventTopicStreamFixtures.res +27 -0
  263. package/tests/components/eventtopic/EventTopicStreamFixtures.res.mjs +62 -0
  264. package/tests/components/eventtopic/EventTopicStreamTest.res +35 -0
  265. package/tests/components/eventtopic/EventTopicStreamTest.res.mjs +44 -0
  266. package/tests/components/eventtopic/EventTopicTest.res +35 -0
  267. package/tests/components/eventtopic/EventTopicTest.res.mjs +43 -0
  268. package/tests/components/extensionpoint/ExtensionPointFixtures.res +145 -0
  269. package/tests/components/extensionpoint/ExtensionPointFixtures.res.mjs +188 -0
  270. package/tests/components/extensionpoint/ExtensionPointTest.res +62 -0
  271. package/tests/components/extensionpoint/ExtensionPointTest.res.mjs +55 -0
  272. package/tests/components/heartbeat/HeartbeatFixtures.res +48 -0
  273. package/tests/components/heartbeat/HeartbeatFixtures.res.mjs +46 -0
  274. package/tests/components/heartbeat/HeartbeatTest.res +67 -0
  275. package/tests/components/heartbeat/HeartbeatTest.res.mjs +65 -0
  276. package/tests/components/inboundtranslationslice/InboundTranslationSliceCallbackTest.res +241 -0
  277. package/tests/components/inboundtranslationslice/InboundTranslationSliceCallbackTest.res.mjs +239 -0
  278. package/tests/components/inboundtranslationslice/InboundTranslationSliceFixtures.res +36 -0
  279. package/tests/components/inboundtranslationslice/InboundTranslationSliceFixtures.res.mjs +73 -0
  280. package/tests/components/outboundtranslationslice/OutboundTranslationSliceCallbackTest.res +191 -0
  281. package/tests/components/outboundtranslationslice/OutboundTranslationSliceCallbackTest.res.mjs +297 -0
  282. package/tests/components/outboundtranslationslice/OutboundTranslationSliceFixtures.res +78 -0
  283. package/tests/components/outboundtranslationslice/OutboundTranslationSliceFixtures.res.mjs +137 -0
  284. package/tests/components/querydb/QueryDbFixtures.res +39 -0
  285. package/tests/components/querydb/QueryDbFixtures.res.mjs +73 -0
  286. package/tests/components/querydb/QueryDbSubIdFixtures.res +44 -0
  287. package/tests/components/querydb/QueryDbSubIdFixtures.res.mjs +80 -0
  288. package/tests/components/querydb/QueryDbSubIdTest.res +104 -0
  289. package/tests/components/querydb/QueryDbSubIdTest.res.mjs +104 -0
  290. package/tests/components/querydb/QueryDbTest.res +81 -0
  291. package/tests/components/querydb/QueryDbTest.res.mjs +126 -0
  292. package/tests/components/readmodel/DcbReadModelE2EFixtures.res +215 -0
  293. package/tests/components/readmodel/DcbReadModelE2EFixtures.res.mjs +308 -0
  294. package/tests/components/readmodel/DcbReadModelE2ETest.res +45 -0
  295. package/tests/components/readmodel/DcbReadModelE2ETest.res.mjs +37 -0
  296. package/tests/components/readmodel/DcbReadModelTypoFailFastTest.res +88 -0
  297. package/tests/components/readmodel/DcbReadModelTypoFailFastTest.res.mjs +152 -0
  298. package/tests/components/readmodel/MixedSourceReadModelFixtures.res +181 -0
  299. package/tests/components/readmodel/MixedSourceReadModelFixtures.res.mjs +277 -0
  300. package/tests/components/readmodel/MixedSourceReadModelTest.res +61 -0
  301. package/tests/components/readmodel/MixedSourceReadModelTest.res.mjs +68 -0
  302. package/tests/components/readmodel/ReadModelFixtures.res +138 -0
  303. package/tests/components/readmodel/ReadModelFixtures.res.mjs +169 -0
  304. package/tests/components/readmodel/ReadModelTest.res +46 -0
  305. package/tests/components/readmodel/ReadModelTest.res.mjs +36 -0
  306. package/tests/components/scheduler/SchedulerFixtures.res +59 -0
  307. package/tests/components/scheduler/SchedulerFixtures.res.mjs +63 -0
  308. package/tests/components/scheduler/SchedulerTest.res +76 -0
  309. package/tests/components/scheduler/SchedulerTest.res.mjs +86 -0
  310. package/tests/components/sideeffecthandler/SideEffectHandlerFixtures.res +133 -0
  311. package/tests/components/sideeffecthandler/SideEffectHandlerFixtures.res.mjs +149 -0
  312. package/tests/components/sideeffecthandler/SideEffectHandlerTest.res +39 -0
  313. package/tests/components/sideeffecthandler/SideEffectHandlerTest.res.mjs +28 -0
  314. package/tests/components/stateviewslice/StateViewSliceFixtures.res +117 -0
  315. package/tests/components/stateviewslice/StateViewSliceFixtures.res.mjs +188 -0
  316. package/tests/components/stateviewslice/StateViewSliceSubIdFixtures.res +117 -0
  317. package/tests/components/stateviewslice/StateViewSliceSubIdFixtures.res.mjs +183 -0
  318. package/tests/components/stateviewslice/StateViewSliceSubIdTest.res +78 -0
  319. package/tests/components/stateviewslice/StateViewSliceSubIdTest.res.mjs +107 -0
  320. package/tests/components/stateviewslice/StateViewSliceTest.res +59 -0
  321. package/tests/components/stateviewslice/StateViewSliceTest.res.mjs +72 -0
  322. package/tests/components/task/TaskFixtures.res +87 -0
  323. package/tests/components/task/TaskFixtures.res.mjs +82 -0
  324. package/tests/components/task/TaskTest.res +98 -0
  325. package/tests/components/task/TaskTest.res.mjs +46 -0
  326. package/tests/plugin/PluginBehavior_GWT.res +146 -0
  327. package/tests/plugin/PluginBehavior_GWT.res.mjs +281 -0
  328. package/tests/plugin/Plugin_Fixtures.res +61 -0
  329. package/tests/plugin/Plugin_Fixtures.res.mjs +105 -0
  330. package/tests/plugin/PluginsProjection_GWT.res +95 -0
  331. package/tests/plugin/PluginsProjection_GWT.res.mjs +120 -0
  332. package/tests/plugin/UIFragmentRegistryProjection_GWT.res +72 -0
  333. package/tests/plugin/UIFragmentRegistryProjection_GWT.res.mjs +117 -0
  334. package/tests/setup/sqliteGlobal.cjs +12 -0
@@ -0,0 +1,170 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
4
+ import * as Effect from "effect/Effect";
5
+ import * as Deferred from "effect/Deferred";
6
+ import * as LocalBus$ReventlessLocal from "../../src/adapter/LocalBus.res.mjs";
7
+ import * as TestRunner$ReventlessLocal from "../../src/test/TestRunner.res.mjs";
8
+ import * as CommandTopic$ReventlessCore from "@reventlessdev/reventless-core/src/components/CommandTopic/CommandTopic.res.mjs";
9
+ import * as LocalCommandTopicChannel$ReventlessLocal from "../../src/adapter/CommandTopic/LocalCommandTopicChannel.res.mjs";
10
+
11
+ TestRunner$ReventlessLocal.setup();
12
+
13
+ let testMeta = {
14
+ service: "test",
15
+ time: "2024-01-01T00:00:00.000Z",
16
+ ip: "127.0.0.1",
17
+ user: "testuser",
18
+ msgId: "msg-001",
19
+ correlationId: "corr-001"
20
+ };
21
+
22
+ globalThis.describe("LocalCommandTopicChannel", () => {
23
+ globalThis.describe("encodeCommandJson", () => {
24
+ globalThis.test("produces {id, meta, command} JSON shape", async () => {
25
+ let cmdJson = {
26
+ id: "agg-1",
27
+ meta: testMeta,
28
+ commandJson: "DoSomething"
29
+ };
30
+ let encoded = CommandTopic$ReventlessCore.encodeCommandJson(cmdJson);
31
+ let dict;
32
+ dict = typeof encoded === "object" && encoded !== null && !Array.isArray(encoded) ? encoded : ({});
33
+ globalThis.expect(dict["id"]).toEqual("agg-1");
34
+ globalThis.expect(dict["command"]).toEqual("DoSomething");
35
+ globalThis.expect(Stdlib_Option.isSome(dict["meta"])).toBe(true);
36
+ });
37
+ });
38
+ globalThis.describe("decodeId", () => {
39
+ globalThis.test("extracts id string from encoded message body", async () => {
40
+ let TestBus = LocalBus$ReventlessLocal.Make({});
41
+ let TestChannel = LocalCommandTopicChannel$ReventlessLocal.Make(TestBus);
42
+ let body = Object.fromEntries([[
43
+ "id",
44
+ "agg-42"
45
+ ]]);
46
+ globalThis.expect(TestChannel.decodeId(body)).toBe("agg-42");
47
+ });
48
+ globalThis.test("returns empty string for non-object input", async () => {
49
+ let TestBus = LocalBus$ReventlessLocal.Make({});
50
+ let TestChannel = LocalCommandTopicChannel$ReventlessLocal.Make(TestBus);
51
+ globalThis.expect(TestChannel.decodeId("not-an-object")).toBe("");
52
+ });
53
+ globalThis.test("returns empty string when id field is missing", async () => {
54
+ let TestBus = LocalBus$ReventlessLocal.Make({});
55
+ let TestChannel = LocalCommandTopicChannel$ReventlessLocal.Make(TestBus);
56
+ let body = Object.fromEntries([[
57
+ "other",
58
+ 1
59
+ ]]);
60
+ globalThis.expect(TestChannel.decodeId(body)).toBe("");
61
+ });
62
+ globalThis.test("returns empty string when id field is not a string", async () => {
63
+ let TestBus = LocalBus$ReventlessLocal.Make({});
64
+ let TestChannel = LocalCommandTopicChannel$ReventlessLocal.Make(TestBus);
65
+ let body = Object.fromEntries([[
66
+ "id",
67
+ 99
68
+ ]]);
69
+ globalThis.expect(TestChannel.decodeId(body)).toBe("");
70
+ });
71
+ });
72
+ globalThis.describe("publishJsons", () => {
73
+ globalThis.test("dispatches each command to the bus with full {id, meta, command} body", async () => {
74
+ let TestBus = LocalBus$ReventlessLocal.Make({});
75
+ let TestChannel = LocalCommandTopicChannel$ReventlessLocal.Make(TestBus);
76
+ let received = {
77
+ contents: undefined
78
+ };
79
+ TestBus.registerCommandHandler("myCmd", async (json, param) => {
80
+ received.contents = json;
81
+ });
82
+ let ch = TestChannel.make("myCmd", undefined);
83
+ let publishFn = await TestRunner$ReventlessLocal.resolve(ch.publishJsons);
84
+ await publishFn([{
85
+ id: "item-1",
86
+ meta: testMeta,
87
+ commandJson: "CreateItem"
88
+ }]);
89
+ let receivedJson = Stdlib_Option.getOr(received.contents, null);
90
+ let receivedDict;
91
+ receivedDict = typeof receivedJson === "object" && receivedJson !== null && !Array.isArray(receivedJson) ? receivedJson : ({});
92
+ globalThis.expect(receivedDict["id"]).toEqual("item-1");
93
+ });
94
+ globalThis.test("dispatches multiple commands in order", async () => {
95
+ let TestBus = LocalBus$ReventlessLocal.Make({});
96
+ let TestChannel = LocalCommandTopicChannel$ReventlessLocal.Make(TestBus);
97
+ let count = {
98
+ contents: 0
99
+ };
100
+ TestBus.registerCommandHandler("multiCmd", async (param, param$1) => {
101
+ count.contents = count.contents + 1 | 0;
102
+ });
103
+ let ch = TestChannel.make("multiCmd", undefined);
104
+ let publishFn = await TestRunner$ReventlessLocal.resolve(ch.publishJsons);
105
+ await publishFn([
106
+ {
107
+ id: "id-1",
108
+ meta: testMeta,
109
+ commandJson: null
110
+ },
111
+ {
112
+ id: "id-2",
113
+ meta: testMeta,
114
+ commandJson: null
115
+ }
116
+ ]);
117
+ globalThis.expect(count.contents).toBe(2);
118
+ });
119
+ });
120
+ globalThis.describe("connect", () => {
121
+ globalThis.test("registers handler; dispatch reaches the runtime handlerDeferred", async () => {
122
+ let TestBus = LocalBus$ReventlessLocal.Make({});
123
+ let TestChannel = LocalCommandTopicChannel$ReventlessLocal.Make(TestBus);
124
+ let received = {
125
+ contents: undefined
126
+ };
127
+ let handlerDeferred = Effect.runSync(Deferred.make());
128
+ Effect.runSync(Deferred.succeed(handlerDeferred, async (json, _ctx) => {
129
+ received.contents = json;
130
+ }));
131
+ let runtime_parts = {
132
+ handlerDeferred: handlerDeferred,
133
+ subscriptionLatch: Effect.runSync(Effect.makeLatch(false))
134
+ };
135
+ let runtime_resources = [];
136
+ let runtime = {
137
+ parts: runtime_parts,
138
+ resources: runtime_resources
139
+ };
140
+ let ch = TestChannel.make("testCmd", undefined);
141
+ ch.connect("testCmd", ch, runtime, [], {});
142
+ await TestBus.dispatchCommand("testCmd", "test-payload");
143
+ globalThis.expect(received.contents).toEqual("test-payload");
144
+ });
145
+ globalThis.test("unresolved Deferred does not crash on dispatch", async () => {
146
+ let TestBus = LocalBus$ReventlessLocal.Make({});
147
+ let TestChannel = LocalCommandTopicChannel$ReventlessLocal.Make(TestBus);
148
+ let handlerDeferred = Effect.runSync(Deferred.make());
149
+ let runtime_parts = {
150
+ handlerDeferred: handlerDeferred,
151
+ subscriptionLatch: Effect.runSync(Effect.makeLatch(false))
152
+ };
153
+ let runtime_resources = [];
154
+ let runtime = {
155
+ parts: runtime_parts,
156
+ resources: runtime_resources
157
+ };
158
+ let ch = TestChannel.make("noHandlerCmd", undefined);
159
+ ch.connect("noHandlerCmd", ch, runtime, [], {});
160
+ TestBus.dispatchCommand("noHandlerCmd", null);
161
+ globalThis.expect(true).toBe(true);
162
+ Effect.runSync(Deferred.succeed(handlerDeferred, async (param, param$1) => {}));
163
+ });
164
+ });
165
+ });
166
+
167
+ export {
168
+ testMeta,
169
+ }
170
+ /* Not a pure module */
@@ -0,0 +1,113 @@
1
+ // Unit tests for LocalCounterHandler.
2
+ // CounterHandler uses module-level refs — call reset() in beforeEach for isolation.
3
+
4
+ open JestGlobals
5
+
6
+ // No Pulumi mock needed (LocalCounterHandler uses no Output)
7
+
8
+ let _ = beforeEach(() => {
9
+ LocalCounterHandler.reset()
10
+ })
11
+
12
+ // Create a handler instance; all parameters are ignored by the in-memory implementation
13
+ let makeHandler = () =>
14
+ LocalCounterHandler.make(
15
+ ~name="counter",
16
+ ~referencesName="refs",
17
+ ~referencesDb=Obj.magic(()),
18
+ ~countsName="counts",
19
+ ~countsDb=Obj.magic(()),
20
+ ~counterHandler=Obj.magic(()),
21
+ ~specModulePath="",
22
+ ~mappingsModulePath="",
23
+ ~publishChannelId=Pulumi.Output.make(""),
24
+ ~opts={},
25
+ )
26
+
27
+ describe("LocalCounterHandler", () => {
28
+ describe("addToCounterTarget", () => {
29
+ testPromise("increments counter by target amount", async () => {
30
+ let handler = makeHandler()
31
+ await handler.addToCounterTarget({
32
+ ReventlessInfra.Counter.counterId: "likes",
33
+ target: 3,
34
+ targetRef: "ref-1",
35
+ })
36
+ expect(LocalCounterHandler.getCount("likes"))->toBe(3)
37
+ })
38
+
39
+ testPromise("same (counterId, targetRef) pair is counted only once", async () => {
40
+ let handler = makeHandler()
41
+ await handler.addToCounterTarget({
42
+ ReventlessInfra.Counter.counterId: "likes",
43
+ target: 5,
44
+ targetRef: "ref-dup",
45
+ })
46
+ // Duplicate — should be ignored
47
+ await handler.addToCounterTarget({
48
+ ReventlessInfra.Counter.counterId: "likes",
49
+ target: 5,
50
+ targetRef: "ref-dup",
51
+ })
52
+ expect(LocalCounterHandler.getCount("likes"))->toBe(5)
53
+ })
54
+
55
+ testPromise("different targetRef values for same counterId accumulate", async () => {
56
+ let handler = makeHandler()
57
+ await handler.addToCounterTarget({
58
+ ReventlessInfra.Counter.counterId: "views",
59
+ target: 2,
60
+ targetRef: "ref-a",
61
+ })
62
+ await handler.addToCounterTarget({
63
+ ReventlessInfra.Counter.counterId: "views",
64
+ target: 3,
65
+ targetRef: "ref-b",
66
+ })
67
+ expect(LocalCounterHandler.getCount("views"))->toBe(5)
68
+ })
69
+
70
+ testPromise("multiple counters are tracked independently", async () => {
71
+ let handler = makeHandler()
72
+ await handler.addToCounterTarget({
73
+ ReventlessInfra.Counter.counterId: "alpha",
74
+ target: 10,
75
+ targetRef: "r1",
76
+ })
77
+ await handler.addToCounterTarget({
78
+ ReventlessInfra.Counter.counterId: "beta",
79
+ target: 7,
80
+ targetRef: "r1",
81
+ })
82
+ expect(LocalCounterHandler.getCount("alpha"))->toBe(10)
83
+ expect(LocalCounterHandler.getCount("beta"))->toBe(7)
84
+ })
85
+ })
86
+
87
+ describe("getCount", () => {
88
+ testPromise("returns 0 for unknown counterId", async () => {
89
+ expect(LocalCounterHandler.getCount("no-such-counter"))->toBe(0)
90
+ })
91
+ })
92
+
93
+ describe("reset", () => {
94
+ testPromise("clears all counter values and deduplication state", async () => {
95
+ let handler = makeHandler()
96
+ await handler.addToCounterTarget({
97
+ ReventlessInfra.Counter.counterId: "x",
98
+ target: 99,
99
+ targetRef: "ref-x",
100
+ })
101
+ expect(LocalCounterHandler.getCount("x"))->toBe(99)
102
+ LocalCounterHandler.reset()
103
+ expect(LocalCounterHandler.getCount("x"))->toBe(0)
104
+ // After reset, the same (counterId, targetRef) pair should count again
105
+ await handler.addToCounterTarget({
106
+ ReventlessInfra.Counter.counterId: "x",
107
+ target: 99,
108
+ targetRef: "ref-x",
109
+ })
110
+ expect(LocalCounterHandler.getCount("x"))->toBe(99)
111
+ })
112
+ })
113
+ })
@@ -0,0 +1,96 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Pulumi from "@pulumi/pulumi";
4
+ import * as LocalCounterHandler$ReventlessLocal from "../../src/adapter/Counter/LocalCounterHandler.res.mjs";
5
+
6
+ globalThis.beforeEach(() => LocalCounterHandler$ReventlessLocal.reset());
7
+
8
+ function makeHandler() {
9
+ return LocalCounterHandler$ReventlessLocal.make("counter", "refs", undefined, "counts", undefined, undefined, "", "", Pulumi.output(""), {});
10
+ }
11
+
12
+ globalThis.describe("LocalCounterHandler", () => {
13
+ globalThis.describe("addToCounterTarget", () => {
14
+ globalThis.test("increments counter by target amount", async () => {
15
+ let handler = makeHandler();
16
+ await handler.addToCounterTarget({
17
+ counterId: "likes",
18
+ target: 3,
19
+ targetRef: "ref-1"
20
+ });
21
+ globalThis.expect(LocalCounterHandler$ReventlessLocal.getCount("likes")).toBe(3);
22
+ });
23
+ globalThis.test("same (counterId, targetRef) pair is counted only once", async () => {
24
+ let handler = makeHandler();
25
+ await handler.addToCounterTarget({
26
+ counterId: "likes",
27
+ target: 5,
28
+ targetRef: "ref-dup"
29
+ });
30
+ await handler.addToCounterTarget({
31
+ counterId: "likes",
32
+ target: 5,
33
+ targetRef: "ref-dup"
34
+ });
35
+ globalThis.expect(LocalCounterHandler$ReventlessLocal.getCount("likes")).toBe(5);
36
+ });
37
+ globalThis.test("different targetRef values for same counterId accumulate", async () => {
38
+ let handler = makeHandler();
39
+ await handler.addToCounterTarget({
40
+ counterId: "views",
41
+ target: 2,
42
+ targetRef: "ref-a"
43
+ });
44
+ await handler.addToCounterTarget({
45
+ counterId: "views",
46
+ target: 3,
47
+ targetRef: "ref-b"
48
+ });
49
+ globalThis.expect(LocalCounterHandler$ReventlessLocal.getCount("views")).toBe(5);
50
+ });
51
+ globalThis.test("multiple counters are tracked independently", async () => {
52
+ let handler = makeHandler();
53
+ await handler.addToCounterTarget({
54
+ counterId: "alpha",
55
+ target: 10,
56
+ targetRef: "r1"
57
+ });
58
+ await handler.addToCounterTarget({
59
+ counterId: "beta",
60
+ target: 7,
61
+ targetRef: "r1"
62
+ });
63
+ globalThis.expect(LocalCounterHandler$ReventlessLocal.getCount("alpha")).toBe(10);
64
+ globalThis.expect(LocalCounterHandler$ReventlessLocal.getCount("beta")).toBe(7);
65
+ });
66
+ });
67
+ globalThis.describe("getCount", () => {
68
+ globalThis.test("returns 0 for unknown counterId", async () => {
69
+ globalThis.expect(LocalCounterHandler$ReventlessLocal.getCount("no-such-counter")).toBe(0);
70
+ });
71
+ });
72
+ globalThis.describe("reset", () => {
73
+ globalThis.test("clears all counter values and deduplication state", async () => {
74
+ let handler = makeHandler();
75
+ await handler.addToCounterTarget({
76
+ counterId: "x",
77
+ target: 99,
78
+ targetRef: "ref-x"
79
+ });
80
+ globalThis.expect(LocalCounterHandler$ReventlessLocal.getCount("x")).toBe(99);
81
+ LocalCounterHandler$ReventlessLocal.reset();
82
+ globalThis.expect(LocalCounterHandler$ReventlessLocal.getCount("x")).toBe(0);
83
+ await handler.addToCounterTarget({
84
+ counterId: "x",
85
+ target: 99,
86
+ targetRef: "ref-x"
87
+ });
88
+ globalThis.expect(LocalCounterHandler$ReventlessLocal.getCount("x")).toBe(99);
89
+ });
90
+ });
91
+ });
92
+
93
+ export {
94
+ makeHandler,
95
+ }
96
+ /* Not a pure module */
@@ -0,0 +1,157 @@
1
+ // Round-trip test for DcbEventLogStorage_Sqlite.
2
+
3
+ open JestGlobals
4
+
5
+ let _ = TestRunner.setup()
6
+ let opts: Pulumi.CustomResourceOptions.t = {}
7
+
8
+ let runUnderSqlite = async fn => {
9
+ let db = SqliteDriver.openDb(~path=":memory:")
10
+ BackendState.setSqlite(~db, ~path=":memory:")
11
+ await fn()
12
+ BackendState.setMemory()
13
+ db->SqliteDriver.close
14
+ }
15
+
16
+ let stored = (eventType, tags, data): ReventlessCore.DcbEventLog_Adapter.rawStoredEvent => {
17
+ eventType,
18
+ data,
19
+ tags,
20
+ meta: ReventlessCore.Message.generateMeta(~service="test"),
21
+ }
22
+
23
+ describe("DcbEventLogStorage_Sqlite", () => {
24
+ testPromise("append + read round-trips events with tags", async () => {
25
+ await runUnderSqlite(async () => {
26
+ module TestBus = LocalBus.Make()
27
+ module Storage = DcbEventLogStorage_InMemory.Make(TestBus)
28
+ let s = Storage.make(
29
+ ~name="dcb-rt",
30
+ ~indexes=[],
31
+ ~partitionTag=Reventless.DcbTag.Simple({key: "k"}),
32
+ ~opts,
33
+ )
34
+ let ops = await s.operations->TestRunner.resolve
35
+
36
+ let tag1: Reventless.DcbTag.tag = {key: "itemId", value: "x1"}
37
+ let e1 = stored(
38
+ "ItemAdded",
39
+ [tag1],
40
+ JSON.Encode.object(Dict.fromArray([("name", JSON.Encode.string("widget"))])),
41
+ )
42
+ let result = await ops.append([e1])
43
+ switch result {
44
+ | Ok(_) => expect(true)->toBe(true)
45
+ | Error(m) => expect(m)->toBe("Ok")
46
+ }
47
+
48
+ let read = await ops.read(~query=[])
49
+ expect(read.events->Array.length)->toBe(1)
50
+ let first = read.events->Array.getUnsafe(0)
51
+ expect(first.eventType)->toBe("ItemAdded")
52
+ expect(first.tags->Array.length)->toBe(1)
53
+ expect((first.tags->Array.getUnsafe(0)).key)->toBe("itemId")
54
+ expect((first.tags->Array.getUnsafe(0)).value)->toBe("x1")
55
+ })
56
+ })
57
+
58
+ testPromise("read filters by tag", async () => {
59
+ await runUnderSqlite(async () => {
60
+ module TestBus = LocalBus.Make()
61
+ module Storage = DcbEventLogStorage_InMemory.Make(TestBus)
62
+ let s = Storage.make(
63
+ ~name="dcb-tagfilter",
64
+ ~indexes=[],
65
+ ~partitionTag=Reventless.DcbTag.Simple({key: "k"}),
66
+ ~opts,
67
+ )
68
+ let ops = await s.operations->TestRunner.resolve
69
+
70
+ let mk = (id, name) =>
71
+ stored(
72
+ "ItemAdded",
73
+ [{key: "itemId", value: id}],
74
+ JSON.Encode.object(Dict.fromArray([("name", JSON.Encode.string(name))])),
75
+ )
76
+
77
+ let _ = await ops.append([mk("a1", "alpha")])
78
+ let _ = await ops.append([mk("b1", "beta")])
79
+ let _ = await ops.append([mk("a1", "again")])
80
+
81
+ let read = await ops.read(~query=[{tags: [{key: "itemId", value: "a1"}]}])
82
+ expect(read.events->Array.length)->toBe(2)
83
+ })
84
+ })
85
+
86
+ testPromise("append with conflicting condition returns Error", async () => {
87
+ await runUnderSqlite(async () => {
88
+ module TestBus = LocalBus.Make()
89
+ module Storage = DcbEventLogStorage_InMemory.Make(TestBus)
90
+ let s = Storage.make(
91
+ ~name="dcb-conflict",
92
+ ~indexes=[],
93
+ ~partitionTag=Reventless.DcbTag.Simple({key: "k"}),
94
+ ~opts,
95
+ )
96
+ let ops = await s.operations->TestRunner.resolve
97
+
98
+ let e = stored(
99
+ "Created",
100
+ [{key: "id", value: "x"}],
101
+ JSON.Encode.string("first"),
102
+ )
103
+ let _ = await ops.append([e])
104
+
105
+ let cond: Reventless.DcbTag.appendCondition = {
106
+ query: [{tags: [{key: "id", value: "x"}]}],
107
+ }
108
+ let result = await ops.append([e], ~condition=cond)
109
+ switch result {
110
+ | Error(_) => expect(true)->toBe(true)
111
+ | Ok(_) => expect("expected conflict")->toBe("got Ok")
112
+ }
113
+ })
114
+ })
115
+
116
+ testPromise("events persist across a file reopen", async () => {
117
+ let path = `/tmp/reventless-test-dcb-${Float.toString(Date.now())}.db`
118
+
119
+ {
120
+ let db = SqliteDriver.openDb(~path)
121
+ BackendState.setSqlite(~db, ~path)
122
+ module TestBus = LocalBus.Make()
123
+ module Storage = DcbEventLogStorage_InMemory.Make(TestBus)
124
+ let s = Storage.make(
125
+ ~name="persist",
126
+ ~indexes=[],
127
+ ~partitionTag=Reventless.DcbTag.Simple({key: "k"}),
128
+ ~opts,
129
+ )
130
+ let ops = await s.operations->TestRunner.resolve
131
+ let e = stored(
132
+ "Created",
133
+ [{key: "id", value: "p"}],
134
+ JSON.Encode.int(1),
135
+ )
136
+ let _ = await ops.append([e])
137
+ db->SqliteDriver.close
138
+ BackendState.setMemory()
139
+ }
140
+
141
+ let db2 = SqliteDriver.openDb(~path)
142
+ BackendState.setSqlite(~db=db2, ~path)
143
+ module TestBus2 = LocalBus.Make()
144
+ module Storage2 = DcbEventLogStorage_InMemory.Make(TestBus2)
145
+ let s2 = Storage2.make(
146
+ ~name="persist",
147
+ ~indexes=[],
148
+ ~partitionTag=Reventless.DcbTag.Simple({key: "k"}),
149
+ ~opts,
150
+ )
151
+ let ops2 = await s2.operations->TestRunner.resolve
152
+ let read = await ops2.read(~query=[])
153
+ expect(read.events->Array.length)->toBe(1)
154
+ db2->SqliteDriver.close
155
+ BackendState.setMemory()
156
+ })
157
+ })