@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.
- package/CHANGELOG.md +1197 -0
- package/LICENSE +202 -0
- package/__mocks__/emptyModule.js +2 -0
- package/__mocks__/nodeSqlite.mjs +6 -0
- package/package.json +67 -0
- package/rescript.json +39 -0
- package/src/Platform.res +2162 -0
- package/src/Platform.res.mjs +3389 -0
- package/src/adapter/Api/LocalGraphQL_Adapter.res +29 -0
- package/src/adapter/Api/LocalGraphQL_Adapter.res.mjs +26 -0
- package/src/adapter/Api/LocalGraphQL_SubscriptionResolvers.res +146 -0
- package/src/adapter/Api/LocalGraphQL_SubscriptionResolvers.res.mjs +88 -0
- package/src/adapter/Auth/Auth_GraphqlContext.res +83 -0
- package/src/adapter/Auth/Auth_GraphqlContext.res.mjs +76 -0
- package/src/adapter/Auth/LocalAuth.res +239 -0
- package/src/adapter/Auth/LocalAuth.res.mjs +247 -0
- package/src/adapter/Auth/UserStore.res +134 -0
- package/src/adapter/Auth/UserStore.res.mjs +146 -0
- package/src/adapter/Backend.res +46 -0
- package/src/adapter/Backend.res.mjs +66 -0
- package/src/adapter/BackendState.res +34 -0
- package/src/adapter/BackendState.res.mjs +42 -0
- package/src/adapter/Cloner/LocalClonerRunner.res +13 -0
- package/src/adapter/Cloner/LocalClonerRunner.res.mjs +12 -0
- package/src/adapter/CommandGenerator/CommandGeneratorResolvers_GraphQL.res +329 -0
- package/src/adapter/CommandGenerator/CommandGeneratorResolvers_GraphQL.res.mjs +301 -0
- package/src/adapter/CommandGenerator/InboundTranslationResolvers_GraphQL.res +76 -0
- package/src/adapter/CommandGenerator/InboundTranslationResolvers_GraphQL.res.mjs +57 -0
- package/src/adapter/CommandGenerator/LocalCommandGeneratorResolvers.res +19 -0
- package/src/adapter/CommandGenerator/LocalCommandGeneratorResolvers.res.mjs +19 -0
- package/src/adapter/CommandTopic/LocalCommandTopicChannel.res +104 -0
- package/src/adapter/CommandTopic/LocalCommandTopicChannel.res.mjs +82 -0
- package/src/adapter/CommandTopic/LocalCommandTopicRemoteChannel.res +32 -0
- package/src/adapter/CommandTopic/LocalCommandTopicRemoteChannel.res.mjs +38 -0
- package/src/adapter/Counter/LocalCounterHandler.res +42 -0
- package/src/adapter/Counter/LocalCounterHandler.res.mjs +45 -0
- package/src/adapter/DcbEventLog/DcbEventLogStorage_InMemory.res +131 -0
- package/src/adapter/DcbEventLog/DcbEventLogStorage_InMemory.res.mjs +140 -0
- package/src/adapter/DcbEventLog/DcbEventLogStorage_Sqlite.res +334 -0
- package/src/adapter/DcbEventLog/DcbEventLogStorage_Sqlite.res.mjs +299 -0
- package/src/adapter/DomainGraphQL_Server.res +565 -0
- package/src/adapter/DomainGraphQL_Server.res.mjs +576 -0
- package/src/adapter/DomainMCP_Server.res +369 -0
- package/src/adapter/DomainMCP_Server.res.mjs +358 -0
- package/src/adapter/EventCollector/LocalEventCollectorChannel.res +87 -0
- package/src/adapter/EventCollector/LocalEventCollectorChannel.res.mjs +45 -0
- package/src/adapter/EventLog/EventLogStorage_InMemory.res +105 -0
- package/src/adapter/EventLog/EventLogStorage_InMemory.res.mjs +117 -0
- package/src/adapter/EventLog/EventLogStorage_Sqlite.res +145 -0
- package/src/adapter/EventLog/EventLogStorage_Sqlite.res.mjs +155 -0
- package/src/adapter/EventTopic/LocalEventTopicPublisher.res +36 -0
- package/src/adapter/EventTopic/LocalEventTopicPublisher.res.mjs +31 -0
- package/src/adapter/GraphQL_Server.res +6 -0
- package/src/adapter/GraphQL_Server.res.mjs +154 -0
- package/src/adapter/GraphQL_ServerInstance.res +310 -0
- package/src/adapter/GraphQL_ServerInstance.res.mjs +257 -0
- package/src/adapter/Heartbeat/LocalHeartbeatRunner.res +57 -0
- package/src/adapter/Heartbeat/LocalHeartbeatRunner.res.mjs +34 -0
- package/src/adapter/LocalBus.res +498 -0
- package/src/adapter/LocalBus.res.mjs +1011 -0
- package/src/adapter/LocalPluginSpec.res +16 -0
- package/src/adapter/LocalPluginSpec.res.mjs +33 -0
- package/src/adapter/LocalSideEffectHandler.res +44 -0
- package/src/adapter/LocalSideEffectHandler.res.mjs +34 -0
- package/src/adapter/MCP_Server.res +4 -0
- package/src/adapter/MCP_Server.res.mjs +67 -0
- package/src/adapter/MCP_ServerInstance.res +362 -0
- package/src/adapter/MCP_ServerInstance.res.mjs +313 -0
- package/src/adapter/PlatformGraphQL_Server.res +75 -0
- package/src/adapter/PlatformGraphQL_Server.res.mjs +84 -0
- package/src/adapter/PlatformMCP_Server.res +23 -0
- package/src/adapter/PlatformMCP_Server.res.mjs +46 -0
- package/src/adapter/QueryDb/QueryDbResolvers_GraphQL.res +793 -0
- package/src/adapter/QueryDb/QueryDbResolvers_GraphQL.res.mjs +569 -0
- package/src/adapter/QueryDb/QueryDbStorage_InMemory.res +242 -0
- package/src/adapter/QueryDb/QueryDbStorage_InMemory.res.mjs +241 -0
- package/src/adapter/QueryDb/QueryDbStorage_Sqlite.res +339 -0
- package/src/adapter/QueryDb/QueryDbStorage_Sqlite.res.mjs +318 -0
- package/src/adapter/QueryDb/SortKey_Filter.res +48 -0
- package/src/adapter/QueryDb/SortKey_Filter.res.mjs +46 -0
- package/src/adapter/QueryEngine/LocalQueryEngine.res +57 -0
- package/src/adapter/QueryEngine/LocalQueryEngine.res.mjs +56 -0
- package/src/adapter/Runtime/LocalAggregateRuntime_Builder.res +91 -0
- package/src/adapter/Runtime/LocalAggregateRuntime_Builder.res.mjs +50 -0
- package/src/adapter/Runtime/LocalEventCollectorRuntime_Builder.res +47 -0
- package/src/adapter/Runtime/LocalEventCollectorRuntime_Builder.res.mjs +37 -0
- package/src/adapter/Runtime/LocalPluginRuntime_Builder.res +11 -0
- package/src/adapter/Runtime/LocalPluginRuntime_Builder.res.mjs +30 -0
- package/src/adapter/Runtime/LocalRuntimeEnvironment.res +54 -0
- package/src/adapter/Runtime/LocalRuntimeEnvironment.res.mjs +40 -0
- package/src/adapter/Scheduler/LocalScheduledPublisher.res +102 -0
- package/src/adapter/Scheduler/LocalScheduledPublisher.res.mjs +84 -0
- package/src/adapter/SqliteDriver.res +52 -0
- package/src/adapter/SqliteDriver.res.mjs +76 -0
- package/src/adapter/SqliteDriver.resi +31 -0
- package/src/adapter/Task/LocalTaskBucket.res +75 -0
- package/src/adapter/Task/LocalTaskBucket.res.mjs +48 -0
- package/src/adapter/Task/TaskBucket_Sqlite.res +47 -0
- package/src/adapter/Task/TaskBucket_Sqlite.res.mjs +40 -0
- package/src/components/Aggregate_Builder.res +55 -0
- package/src/components/Aggregate_Builder.res.mjs +140 -0
- package/src/components/AutomationSlice_Builder.res +41 -0
- package/src/components/AutomationSlice_Builder.res.mjs +57 -0
- package/src/components/Counter_Builder.res +14 -0
- package/src/components/Counter_Builder.res.mjs +32 -0
- package/src/components/DcbEventLog_Builder.res +18 -0
- package/src/components/DcbEventLog_Builder.res.mjs +24 -0
- package/src/components/ExtensionPoint_Builder.res +25 -0
- package/src/components/ExtensionPoint_Builder.res.mjs +44 -0
- package/src/components/InboundTranslationSlice_Builder.res +34 -0
- package/src/components/InboundTranslationSlice_Builder.res.mjs +45 -0
- package/src/components/OutboundTranslationSlice_Builder.res +43 -0
- package/src/components/OutboundTranslationSlice_Builder.res.mjs +59 -0
- package/src/components/Plugin_Builder.res +37 -0
- package/src/components/Plugin_Builder.res.mjs +67 -0
- package/src/components/ReadModel_Builder.res +47 -0
- package/src/components/ReadModel_Builder.res.mjs +54 -0
- package/src/components/StateChangeSlice_Builder.res +19 -0
- package/src/components/StateChangeSlice_Builder.res.mjs +21 -0
- package/src/components/StateViewSlice_Builder.res +42 -0
- package/src/components/StateViewSlice_Builder.res.mjs +58 -0
- package/src/components/Task_Builder.res +28 -0
- package/src/components/Task_Builder.res.mjs +41 -0
- package/src/reexport/CommandTopic.res +3 -0
- package/src/reexport/CommandTopic.res.mjs +55 -0
- package/src/test/Mocks/MockDcbEventLogStorage.res +136 -0
- package/src/test/Mocks/MockDcbEventLogStorage.res.mjs +146 -0
- package/src/test/Mocks/MockEventLogStorage.res +57 -0
- package/src/test/Mocks/MockEventLogStorage.res.mjs +65 -0
- package/src/test/Mocks/MockPublisher.res +29 -0
- package/src/test/Mocks/MockPublisher.res.mjs +28 -0
- package/src/test/Mocks/MockQueryDbStorage.res +104 -0
- package/src/test/Mocks/MockQueryDbStorage.res.mjs +136 -0
- package/src/test/TestRunner.res +96 -0
- package/src/test/TestRunner.res.mjs +71 -0
- package/tests/SplitApiFixtures.res +84 -0
- package/tests/SplitApiFixtures.res.mjs +88 -0
- package/tests/SplitApiTest.res +102 -0
- package/tests/SplitApiTest.res.mjs +82 -0
- package/tests/TestFixtures.res +54 -0
- package/tests/TestFixtures.res.mjs +65 -0
- package/tests/adapter/BackendParityTest.res +94 -0
- package/tests/adapter/BackendParityTest.res.mjs +96 -0
- package/tests/adapter/CollectNEventsTest.res +82 -0
- package/tests/adapter/CollectNEventsTest.res.mjs +83 -0
- package/tests/adapter/CommandAuthorizationTest.res +200 -0
- package/tests/adapter/CommandAuthorizationTest.res.mjs +190 -0
- package/tests/adapter/CommandTopicChannelTest.res +174 -0
- package/tests/adapter/CommandTopicChannelTest.res.mjs +170 -0
- package/tests/adapter/CounterHandlerTest.res +113 -0
- package/tests/adapter/CounterHandlerTest.res.mjs +96 -0
- package/tests/adapter/DcbEventLogStorageSqliteTest.res +157 -0
- package/tests/adapter/DcbEventLogStorageSqliteTest.res.mjs +165 -0
- package/tests/adapter/DcbEventLogStorageTest.res +187 -0
- package/tests/adapter/DcbEventLogStorageTest.res.mjs +195 -0
- package/tests/adapter/EventCollectorChannelTest.res +166 -0
- package/tests/adapter/EventCollectorChannelTest.res.mjs +178 -0
- package/tests/adapter/EventLogStorageSqliteTest.res +105 -0
- package/tests/adapter/EventLogStorageSqliteTest.res.mjs +116 -0
- package/tests/adapter/EventTapTest.res +102 -0
- package/tests/adapter/EventTapTest.res.mjs +94 -0
- package/tests/adapter/EventTopicPublisherTest.res +76 -0
- package/tests/adapter/EventTopicPublisherTest.res.mjs +86 -0
- package/tests/adapter/GraphQL_SchemaInspectorTest.res +763 -0
- package/tests/adapter/GraphQL_SchemaInspectorTest.res.mjs +578 -0
- package/tests/adapter/GraphQL_SubscriptionResolversTest.res +161 -0
- package/tests/adapter/GraphQL_SubscriptionResolversTest.res.mjs +134 -0
- package/tests/adapter/HeartbeatRunnerTest.res +136 -0
- package/tests/adapter/HeartbeatRunnerTest.res.mjs +96 -0
- package/tests/adapter/LocalAuthHttpTest.res +224 -0
- package/tests/adapter/LocalAuthHttpTest.res.mjs +237 -0
- package/tests/adapter/LocalAuthLoginTest.res +180 -0
- package/tests/adapter/LocalAuthLoginTest.res.mjs +207 -0
- package/tests/adapter/LocalAuthTest.res +106 -0
- package/tests/adapter/LocalAuthTest.res.mjs +145 -0
- package/tests/adapter/LocalAuthUserStoreTest.res +172 -0
- package/tests/adapter/LocalAuthUserStoreTest.res.mjs +208 -0
- package/tests/adapter/LocalBusBoundedTest.res +157 -0
- package/tests/adapter/LocalBusBoundedTest.res.mjs +168 -0
- package/tests/adapter/LocalBusPubSubTest.res +81 -0
- package/tests/adapter/LocalBusPubSubTest.res.mjs +81 -0
- package/tests/adapter/QueryDbGsiTtlTest.res +268 -0
- package/tests/adapter/QueryDbGsiTtlTest.res.mjs +209 -0
- package/tests/adapter/QueryDbListResolverTest.res +361 -0
- package/tests/adapter/QueryDbListResolverTest.res.mjs +426 -0
- package/tests/adapter/QueryDbStorageSqliteTest.res +159 -0
- package/tests/adapter/QueryDbStorageSqliteTest.res.mjs +126 -0
- package/tests/adapter/QueryDbStorageTest.res +171 -0
- package/tests/adapter/QueryDbStorageTest.res.mjs +170 -0
- package/tests/adapter/QueryEngineTest.res +152 -0
- package/tests/adapter/QueryEngineTest.res.mjs +148 -0
- package/tests/adapter/ScheduledPublisherTest.res +199 -0
- package/tests/adapter/ScheduledPublisherTest.res.mjs +203 -0
- package/tests/adapter/SortKey_FilterTest.res +103 -0
- package/tests/adapter/SortKey_FilterTest.res.mjs +135 -0
- package/tests/adapter/SqliteDriverTest.res +86 -0
- package/tests/adapter/SqliteDriverTest.res.mjs +101 -0
- package/tests/adapter/TaskBucketSqliteTest.res +44 -0
- package/tests/adapter/TaskBucketSqliteTest.res.mjs +40 -0
- package/tests/adapter/TaskBucketTest.res +106 -0
- package/tests/adapter/TaskBucketTest.res.mjs +118 -0
- package/tests/components/aggregate/AggregateFixtures.res +78 -0
- package/tests/components/aggregate/AggregateFixtures.res.mjs +109 -0
- package/tests/components/aggregate/AggregateTest.res +129 -0
- package/tests/components/aggregate/AggregateTest.res.mjs +129 -0
- package/tests/components/automationslice/AutomationSliceCallbackTest.res +212 -0
- package/tests/components/automationslice/AutomationSliceCallbackTest.res.mjs +233 -0
- package/tests/components/automationslice/AutomationSliceFixtures.res +189 -0
- package/tests/components/automationslice/AutomationSliceFixtures.res.mjs +276 -0
- package/tests/components/automationslice/AutomationSliceSelfDeadlockFixtures.res +289 -0
- package/tests/components/automationslice/AutomationSliceSelfDeadlockFixtures.res.mjs +453 -0
- package/tests/components/automationslice/AutomationSliceSelfDeadlockTest.res +47 -0
- package/tests/components/automationslice/AutomationSliceSelfDeadlockTest.res.mjs +31 -0
- package/tests/components/automationslice/MixedSourceAutomationSliceFixtures.res +213 -0
- package/tests/components/automationslice/MixedSourceAutomationSliceFixtures.res.mjs +268 -0
- package/tests/components/automationslice/MixedSourceAutomationSliceTest.res +118 -0
- package/tests/components/automationslice/MixedSourceAutomationSliceTest.res.mjs +99 -0
- package/tests/components/commandgenerator/CommandGeneratorFixtures.res +73 -0
- package/tests/components/commandgenerator/CommandGeneratorFixtures.res.mjs +109 -0
- package/tests/components/commandgenerator/CommandGeneratorTest.res +43 -0
- package/tests/components/commandgenerator/CommandGeneratorTest.res.mjs +46 -0
- package/tests/components/commandtopic/CommandTopicFixtures.res +37 -0
- package/tests/components/commandtopic/CommandTopicFixtures.res.mjs +68 -0
- package/tests/components/commandtopic/CommandTopicStreamFixtures.res +43 -0
- package/tests/components/commandtopic/CommandTopicStreamFixtures.res.mjs +91 -0
- package/tests/components/commandtopic/CommandTopicStreamTest.res +30 -0
- package/tests/components/commandtopic/CommandTopicStreamTest.res.mjs +35 -0
- package/tests/components/commandtopic/CommandTopicTest.res +55 -0
- package/tests/components/commandtopic/CommandTopicTest.res.mjs +62 -0
- package/tests/components/counter/CounterFixtures.res +42 -0
- package/tests/components/counter/CounterFixtures.res.mjs +34 -0
- package/tests/components/counter/CounterTest.res +46 -0
- package/tests/components/counter/CounterTest.res.mjs +61 -0
- package/tests/components/dcb/DcbCrossPartitionFixtures.res +170 -0
- package/tests/components/dcb/DcbCrossPartitionFixtures.res.mjs +276 -0
- package/tests/components/dcb/DcbCrossPartitionReadTest.res +68 -0
- package/tests/components/dcb/DcbCrossPartitionReadTest.res.mjs +78 -0
- package/tests/components/dcb/DcbEventLogAppendStreamTest.res +72 -0
- package/tests/components/dcb/DcbEventLogAppendStreamTest.res.mjs +82 -0
- package/tests/components/dcb/DcbEventLogStreamTest.res +103 -0
- package/tests/components/dcb/DcbEventLogStreamTest.res.mjs +91 -0
- package/tests/components/dcb/DcbFixtures.res +145 -0
- package/tests/components/dcb/DcbFixtures.res.mjs +221 -0
- package/tests/components/dcb/DcbTest.res +55 -0
- package/tests/components/dcb/DcbTest.res.mjs +55 -0
- package/tests/components/eventcollector/EventCollectorFixtures.res +42 -0
- package/tests/components/eventcollector/EventCollectorFixtures.res.mjs +49 -0
- package/tests/components/eventcollector/EventCollectorTest.res +37 -0
- package/tests/components/eventcollector/EventCollectorTest.res.mjs +36 -0
- package/tests/components/eventlog/EventLogAppendStreamTest.res +93 -0
- package/tests/components/eventlog/EventLogAppendStreamTest.res.mjs +113 -0
- package/tests/components/eventlog/EventLogConflictTest.res +86 -0
- package/tests/components/eventlog/EventLogConflictTest.res.mjs +81 -0
- package/tests/components/eventlog/EventLogFixtures.res +52 -0
- package/tests/components/eventlog/EventLogFixtures.res.mjs +80 -0
- package/tests/components/eventlog/EventLogStreamTest.res +98 -0
- package/tests/components/eventlog/EventLogStreamTest.res.mjs +142 -0
- package/tests/components/eventlog/EventLogTest.res +53 -0
- package/tests/components/eventlog/EventLogTest.res.mjs +74 -0
- package/tests/components/eventtopic/EventTopicFixtures.res +47 -0
- package/tests/components/eventtopic/EventTopicFixtures.res.mjs +77 -0
- package/tests/components/eventtopic/EventTopicStreamFixtures.res +27 -0
- package/tests/components/eventtopic/EventTopicStreamFixtures.res.mjs +62 -0
- package/tests/components/eventtopic/EventTopicStreamTest.res +35 -0
- package/tests/components/eventtopic/EventTopicStreamTest.res.mjs +44 -0
- package/tests/components/eventtopic/EventTopicTest.res +35 -0
- package/tests/components/eventtopic/EventTopicTest.res.mjs +43 -0
- package/tests/components/extensionpoint/ExtensionPointFixtures.res +145 -0
- package/tests/components/extensionpoint/ExtensionPointFixtures.res.mjs +188 -0
- package/tests/components/extensionpoint/ExtensionPointTest.res +62 -0
- package/tests/components/extensionpoint/ExtensionPointTest.res.mjs +55 -0
- package/tests/components/heartbeat/HeartbeatFixtures.res +48 -0
- package/tests/components/heartbeat/HeartbeatFixtures.res.mjs +46 -0
- package/tests/components/heartbeat/HeartbeatTest.res +67 -0
- package/tests/components/heartbeat/HeartbeatTest.res.mjs +65 -0
- package/tests/components/inboundtranslationslice/InboundTranslationSliceCallbackTest.res +241 -0
- package/tests/components/inboundtranslationslice/InboundTranslationSliceCallbackTest.res.mjs +239 -0
- package/tests/components/inboundtranslationslice/InboundTranslationSliceFixtures.res +36 -0
- package/tests/components/inboundtranslationslice/InboundTranslationSliceFixtures.res.mjs +73 -0
- package/tests/components/outboundtranslationslice/OutboundTranslationSliceCallbackTest.res +191 -0
- package/tests/components/outboundtranslationslice/OutboundTranslationSliceCallbackTest.res.mjs +297 -0
- package/tests/components/outboundtranslationslice/OutboundTranslationSliceFixtures.res +78 -0
- package/tests/components/outboundtranslationslice/OutboundTranslationSliceFixtures.res.mjs +137 -0
- package/tests/components/querydb/QueryDbFixtures.res +39 -0
- package/tests/components/querydb/QueryDbFixtures.res.mjs +73 -0
- package/tests/components/querydb/QueryDbSubIdFixtures.res +44 -0
- package/tests/components/querydb/QueryDbSubIdFixtures.res.mjs +80 -0
- package/tests/components/querydb/QueryDbSubIdTest.res +104 -0
- package/tests/components/querydb/QueryDbSubIdTest.res.mjs +104 -0
- package/tests/components/querydb/QueryDbTest.res +81 -0
- package/tests/components/querydb/QueryDbTest.res.mjs +126 -0
- package/tests/components/readmodel/DcbReadModelE2EFixtures.res +215 -0
- package/tests/components/readmodel/DcbReadModelE2EFixtures.res.mjs +308 -0
- package/tests/components/readmodel/DcbReadModelE2ETest.res +45 -0
- package/tests/components/readmodel/DcbReadModelE2ETest.res.mjs +37 -0
- package/tests/components/readmodel/DcbReadModelTypoFailFastTest.res +88 -0
- package/tests/components/readmodel/DcbReadModelTypoFailFastTest.res.mjs +152 -0
- package/tests/components/readmodel/MixedSourceReadModelFixtures.res +181 -0
- package/tests/components/readmodel/MixedSourceReadModelFixtures.res.mjs +277 -0
- package/tests/components/readmodel/MixedSourceReadModelTest.res +61 -0
- package/tests/components/readmodel/MixedSourceReadModelTest.res.mjs +68 -0
- package/tests/components/readmodel/ReadModelFixtures.res +138 -0
- package/tests/components/readmodel/ReadModelFixtures.res.mjs +169 -0
- package/tests/components/readmodel/ReadModelTest.res +46 -0
- package/tests/components/readmodel/ReadModelTest.res.mjs +36 -0
- package/tests/components/scheduler/SchedulerFixtures.res +59 -0
- package/tests/components/scheduler/SchedulerFixtures.res.mjs +63 -0
- package/tests/components/scheduler/SchedulerTest.res +76 -0
- package/tests/components/scheduler/SchedulerTest.res.mjs +86 -0
- package/tests/components/sideeffecthandler/SideEffectHandlerFixtures.res +133 -0
- package/tests/components/sideeffecthandler/SideEffectHandlerFixtures.res.mjs +149 -0
- package/tests/components/sideeffecthandler/SideEffectHandlerTest.res +39 -0
- package/tests/components/sideeffecthandler/SideEffectHandlerTest.res.mjs +28 -0
- package/tests/components/stateviewslice/StateViewSliceFixtures.res +117 -0
- package/tests/components/stateviewslice/StateViewSliceFixtures.res.mjs +188 -0
- package/tests/components/stateviewslice/StateViewSliceSubIdFixtures.res +117 -0
- package/tests/components/stateviewslice/StateViewSliceSubIdFixtures.res.mjs +183 -0
- package/tests/components/stateviewslice/StateViewSliceSubIdTest.res +78 -0
- package/tests/components/stateviewslice/StateViewSliceSubIdTest.res.mjs +107 -0
- package/tests/components/stateviewslice/StateViewSliceTest.res +59 -0
- package/tests/components/stateviewslice/StateViewSliceTest.res.mjs +72 -0
- package/tests/components/task/TaskFixtures.res +87 -0
- package/tests/components/task/TaskFixtures.res.mjs +82 -0
- package/tests/components/task/TaskTest.res +98 -0
- package/tests/components/task/TaskTest.res.mjs +46 -0
- package/tests/plugin/PluginBehavior_GWT.res +146 -0
- package/tests/plugin/PluginBehavior_GWT.res.mjs +281 -0
- package/tests/plugin/Plugin_Fixtures.res +61 -0
- package/tests/plugin/Plugin_Fixtures.res.mjs +105 -0
- package/tests/plugin/PluginsProjection_GWT.res +95 -0
- package/tests/plugin/PluginsProjection_GWT.res.mjs +120 -0
- package/tests/plugin/UIFragmentRegistryProjection_GWT.res +72 -0
- package/tests/plugin/UIFragmentRegistryProjection_GWT.res.mjs +117 -0
- package/tests/setup/sqliteGlobal.cjs +12 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Message$ReventlessCore from "@reventlessdev/reventless-core/src/Message.res.mjs";
|
|
4
|
+
import * as Component$ReventlessCore from "@reventlessdev/reventless-core/src/components/Component.res.mjs";
|
|
5
|
+
import * as TestRunner$ReventlessLocal from "../../../src/test/TestRunner.res.mjs";
|
|
6
|
+
import * as TestFixtures$ReventlessLocal from "../../TestFixtures.res.mjs";
|
|
7
|
+
import * as CommandTopicFixtures$ReventlessLocal from "./CommandTopicFixtures.res.mjs";
|
|
8
|
+
|
|
9
|
+
globalThis.describe("CommandTopic (in-memory)", () => {
|
|
10
|
+
globalThis.beforeAll(async () => {
|
|
11
|
+
await TestRunner$ReventlessLocal.resolve(Component$ReventlessCore.operations(CommandTopicFixtures$ReventlessLocal.cmdTopic));
|
|
12
|
+
});
|
|
13
|
+
globalThis.test("publishJsons succeeds without throwing", async () => {
|
|
14
|
+
let ops = await TestRunner$ReventlessLocal.resolve(Component$ReventlessCore.operations(CommandTopicFixtures$ReventlessLocal.cmdTopic));
|
|
15
|
+
let commandJson = Message$ReventlessCore.encode({
|
|
16
|
+
TAG: "CreateItem",
|
|
17
|
+
name: "Widget"
|
|
18
|
+
}, CommandTopicFixtures$ReventlessLocal.ItemSpec.commandSchema);
|
|
19
|
+
let didThrow = false;
|
|
20
|
+
try {
|
|
21
|
+
await ops.publishJsons([{
|
|
22
|
+
id: "item-1",
|
|
23
|
+
meta: TestFixtures$ReventlessLocal.testMeta,
|
|
24
|
+
commandJson: commandJson
|
|
25
|
+
}]);
|
|
26
|
+
} catch (exn) {
|
|
27
|
+
didThrow = true;
|
|
28
|
+
}
|
|
29
|
+
globalThis.expect(didThrow).toBe(false);
|
|
30
|
+
});
|
|
31
|
+
globalThis.test("publishJsons with empty array succeeds", async () => {
|
|
32
|
+
let ops = await TestRunner$ReventlessLocal.resolve(Component$ReventlessCore.operations(CommandTopicFixtures$ReventlessLocal.cmdTopic));
|
|
33
|
+
let didThrow = false;
|
|
34
|
+
try {
|
|
35
|
+
await ops.publishJsons([]);
|
|
36
|
+
} catch (exn) {
|
|
37
|
+
didThrow = true;
|
|
38
|
+
}
|
|
39
|
+
globalThis.expect(didThrow).toBe(false);
|
|
40
|
+
});
|
|
41
|
+
globalThis.test("publishJsons dispatches to bus channel (TestCommandTopicCmdTopic)", async () => {
|
|
42
|
+
let ops = await TestRunner$ReventlessLocal.resolve(Component$ReventlessCore.operations(CommandTopicFixtures$ReventlessLocal.cmdTopic));
|
|
43
|
+
let received = {
|
|
44
|
+
contents: false
|
|
45
|
+
};
|
|
46
|
+
CommandTopicFixtures$ReventlessLocal.Bus.registerCommandHandler("TestCommandTopicCmdTopic", async (_json, _ctx) => {
|
|
47
|
+
received.contents = true;
|
|
48
|
+
});
|
|
49
|
+
let commandJson = Message$ReventlessCore.encode({
|
|
50
|
+
TAG: "DeleteItem",
|
|
51
|
+
id: "item-99"
|
|
52
|
+
}, CommandTopicFixtures$ReventlessLocal.ItemSpec.commandSchema);
|
|
53
|
+
await ops.publishJsons([{
|
|
54
|
+
id: "item-99",
|
|
55
|
+
meta: TestFixtures$ReventlessLocal.testMeta,
|
|
56
|
+
commandJson: commandJson
|
|
57
|
+
}]);
|
|
58
|
+
globalThis.expect(received.contents).toBe(true);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
/* Not a pure module */
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// E2E test fixtures for Counter builder.
|
|
2
|
+
// Verifies addToCounterTarget (in-memory deduplication) and count (ReferencesDb save).
|
|
3
|
+
|
|
4
|
+
// ─────────────────────────────────────────────────────────────
|
|
5
|
+
// Isolated bus for this test suite
|
|
6
|
+
// ─────────────────────────────────────────────────────────────
|
|
7
|
+
|
|
8
|
+
module Bus = LocalBus.Make()
|
|
9
|
+
|
|
10
|
+
// ─────────────────────────────────────────────────────────────
|
|
11
|
+
// Activate Pulumi mock mode (must be before any Component.make)
|
|
12
|
+
// ─────────────────────────────────────────────────────────────
|
|
13
|
+
|
|
14
|
+
let _ = TestRunner.setup()
|
|
15
|
+
|
|
16
|
+
// ─────────────────────────────────────────────────────────────
|
|
17
|
+
// Build Counter
|
|
18
|
+
// jsonEventsHandler fires when a count reaches zero;
|
|
19
|
+
// capture events for assertion.
|
|
20
|
+
// ─────────────────────────────────────────────────────────────
|
|
21
|
+
|
|
22
|
+
module CounterMaker = Counter_Builder.Make(Bus)
|
|
23
|
+
|
|
24
|
+
let counterEvents: ref<array<JSON.t>> = ref([])
|
|
25
|
+
|
|
26
|
+
let counter = CounterMaker.make(
|
|
27
|
+
~name="TestCounter",
|
|
28
|
+
~jsonEventsHandler=stream =>
|
|
29
|
+
stream
|
|
30
|
+
->Stream.runCollect
|
|
31
|
+
->Effect.map(chunk => {
|
|
32
|
+
counterEvents := counterEvents.contents->Array.concat(chunk)
|
|
33
|
+
}),
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
// ─────────────────────────────────────────────────────────────
|
|
37
|
+
// Resolve counter operations.
|
|
38
|
+
// ─────────────────────────────────────────────────────────────
|
|
39
|
+
|
|
40
|
+
let resolveOps = async () => {
|
|
41
|
+
await CounterMaker.operations(counter)->TestRunner.resolve
|
|
42
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Stream from "@reventlessdev/rescript-effect/src/Stream.res.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as LocalBus$ReventlessLocal from "../../../src/adapter/LocalBus.res.mjs";
|
|
6
|
+
import * as TestRunner$ReventlessLocal from "../../../src/test/TestRunner.res.mjs";
|
|
7
|
+
import * as Counter_Builder$ReventlessLocal from "../../../src/components/Counter_Builder.res.mjs";
|
|
8
|
+
|
|
9
|
+
let Bus = LocalBus$ReventlessLocal.Make({});
|
|
10
|
+
|
|
11
|
+
TestRunner$ReventlessLocal.setup();
|
|
12
|
+
|
|
13
|
+
let CounterMaker = Counter_Builder$ReventlessLocal.Make(Bus);
|
|
14
|
+
|
|
15
|
+
let counterEvents = {
|
|
16
|
+
contents: []
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
let counter = CounterMaker.make("TestCounter", stream => Effect.map(Stream.runCollect(stream), chunk => {
|
|
20
|
+
counterEvents.contents = counterEvents.contents.concat(chunk);
|
|
21
|
+
}), undefined, undefined, undefined, undefined, undefined);
|
|
22
|
+
|
|
23
|
+
async function resolveOps() {
|
|
24
|
+
return await TestRunner$ReventlessLocal.resolve(CounterMaker.operations(counter));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
Bus,
|
|
29
|
+
CounterMaker,
|
|
30
|
+
counterEvents,
|
|
31
|
+
counter,
|
|
32
|
+
resolveOps,
|
|
33
|
+
}
|
|
34
|
+
/* Bus Not a pure module */
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// E2E tests for Counter_Builder.
|
|
2
|
+
// Verifies addToCounterTarget deduplication and count persistence.
|
|
3
|
+
|
|
4
|
+
open JestGlobals
|
|
5
|
+
open CounterFixtures
|
|
6
|
+
|
|
7
|
+
describe("Counter E2E", () => {
|
|
8
|
+
// Resolve operations once before all tests.
|
|
9
|
+
let _ = beforeAllAsync(async () => {
|
|
10
|
+
let _ = await resolveOps()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
// Reset in-memory counter state between tests.
|
|
14
|
+
let _ = beforeEach(() => {
|
|
15
|
+
LocalCounterHandler.reset()
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
testPromise("addToCounterTarget increments count", async () => {
|
|
19
|
+
let ops = await resolveOps()
|
|
20
|
+
await ops.addToCounterTarget({counterId: "item-1", target: 1, targetRef: "ref-1"})
|
|
21
|
+
expect(LocalCounterHandler.getCount("item-1"))->toBe(1)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
testPromise("addToCounterTarget with same targetRef is deduplicated", async () => {
|
|
25
|
+
let ops = await resolveOps()
|
|
26
|
+
await ops.addToCounterTarget({counterId: "item-1", target: 1, targetRef: "ref-1"})
|
|
27
|
+
await ops.addToCounterTarget({counterId: "item-1", target: 1, targetRef: "ref-1"})
|
|
28
|
+
expect(LocalCounterHandler.getCount("item-1"))->toBe(1)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
testPromise("addToCounterTarget with different targetRefs accumulates", async () => {
|
|
32
|
+
let ops = await resolveOps()
|
|
33
|
+
await ops.addToCounterTarget({counterId: "item-1", target: 1, targetRef: "ref-1"})
|
|
34
|
+
await ops.addToCounterTarget({counterId: "item-1", target: 1, targetRef: "ref-2"})
|
|
35
|
+
expect(LocalCounterHandler.getCount("item-1"))->toBe(2)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
testPromise("count saves references to ReferencesDb", async () => {
|
|
39
|
+
let ops = await resolveOps()
|
|
40
|
+
let _ = await ops.count([{counterId: "counter-1", reference: "ref-1", inc: 1}])
|
|
41
|
+
// Counter component name = "TestCounter" ++ "Counter" = "TestCounterCounter"
|
|
42
|
+
// ReferencesDb name = CounterComponentName ++ "References"
|
|
43
|
+
let db = Bus.getQueryDb("TestCounterCounterReferences")
|
|
44
|
+
expect(db->Option.isSome)->toBe(true)
|
|
45
|
+
})
|
|
46
|
+
})
|
|
@@ -0,0 +1,61 @@
|
|
|
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 CounterFixtures$ReventlessLocal from "./CounterFixtures.res.mjs";
|
|
5
|
+
import * as LocalCounterHandler$ReventlessLocal from "../../../src/adapter/Counter/LocalCounterHandler.res.mjs";
|
|
6
|
+
|
|
7
|
+
globalThis.describe("Counter E2E", () => {
|
|
8
|
+
globalThis.beforeAll(async () => {
|
|
9
|
+
await CounterFixtures$ReventlessLocal.resolveOps();
|
|
10
|
+
});
|
|
11
|
+
globalThis.beforeEach(() => LocalCounterHandler$ReventlessLocal.reset());
|
|
12
|
+
globalThis.test("addToCounterTarget increments count", async () => {
|
|
13
|
+
let ops = await CounterFixtures$ReventlessLocal.resolveOps();
|
|
14
|
+
await ops.addToCounterTarget({
|
|
15
|
+
counterId: "item-1",
|
|
16
|
+
target: 1,
|
|
17
|
+
targetRef: "ref-1"
|
|
18
|
+
});
|
|
19
|
+
globalThis.expect(LocalCounterHandler$ReventlessLocal.getCount("item-1")).toBe(1);
|
|
20
|
+
});
|
|
21
|
+
globalThis.test("addToCounterTarget with same targetRef is deduplicated", async () => {
|
|
22
|
+
let ops = await CounterFixtures$ReventlessLocal.resolveOps();
|
|
23
|
+
await ops.addToCounterTarget({
|
|
24
|
+
counterId: "item-1",
|
|
25
|
+
target: 1,
|
|
26
|
+
targetRef: "ref-1"
|
|
27
|
+
});
|
|
28
|
+
await ops.addToCounterTarget({
|
|
29
|
+
counterId: "item-1",
|
|
30
|
+
target: 1,
|
|
31
|
+
targetRef: "ref-1"
|
|
32
|
+
});
|
|
33
|
+
globalThis.expect(LocalCounterHandler$ReventlessLocal.getCount("item-1")).toBe(1);
|
|
34
|
+
});
|
|
35
|
+
globalThis.test("addToCounterTarget with different targetRefs accumulates", async () => {
|
|
36
|
+
let ops = await CounterFixtures$ReventlessLocal.resolveOps();
|
|
37
|
+
await ops.addToCounterTarget({
|
|
38
|
+
counterId: "item-1",
|
|
39
|
+
target: 1,
|
|
40
|
+
targetRef: "ref-1"
|
|
41
|
+
});
|
|
42
|
+
await ops.addToCounterTarget({
|
|
43
|
+
counterId: "item-1",
|
|
44
|
+
target: 1,
|
|
45
|
+
targetRef: "ref-2"
|
|
46
|
+
});
|
|
47
|
+
globalThis.expect(LocalCounterHandler$ReventlessLocal.getCount("item-1")).toBe(2);
|
|
48
|
+
});
|
|
49
|
+
globalThis.test("count saves references to ReferencesDb", async () => {
|
|
50
|
+
let ops = await CounterFixtures$ReventlessLocal.resolveOps();
|
|
51
|
+
await ops.count([{
|
|
52
|
+
counterId: "counter-1",
|
|
53
|
+
reference: "ref-1",
|
|
54
|
+
inc: 1
|
|
55
|
+
}]);
|
|
56
|
+
let db = CounterFixtures$ReventlessLocal.Bus.getQueryDb("TestCounterCounterReferences");
|
|
57
|
+
globalThis.expect(Stdlib_Option.isSome(db)).toBe(true);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
/* Not a pure module */
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// E2E fixtures for the inferred cross-partition read (sibling-exclusion) — the
|
|
2
|
+
// AddProduct scenario through real in-memory DcbEventLog storage.
|
|
3
|
+
//
|
|
4
|
+
// The slice is built with the values the inference derives and Dcb_Builder threads:
|
|
5
|
+
// crossPartitionTagKeys = ["categoryId"] (a foreign reference, read in its own clause)
|
|
6
|
+
// tagKeysByEventType = {ProductAdded: ["productId"], CategoryAdded: ["categoryId"]}
|
|
7
|
+
// so the `categoryId` clause narrows `ProductAdded` out and reads only the category's
|
|
8
|
+
// lifecycle — sibling products tagged the same `categoryId` are never returned.
|
|
9
|
+
|
|
10
|
+
open TestFixtures
|
|
11
|
+
|
|
12
|
+
// ─── DcbEventLog event types (used to encode preseeded events) ───
|
|
13
|
+
module CatalogLog = {
|
|
14
|
+
@schema
|
|
15
|
+
type event =
|
|
16
|
+
| ProductAdded({
|
|
17
|
+
productId: @s.matches(Reventless.DcbTag.partition) string,
|
|
18
|
+
categoryId: @s.matches(Reventless.DcbTag.string) string,
|
|
19
|
+
name: string,
|
|
20
|
+
})
|
|
21
|
+
| CategoryAdded({categoryId: @s.matches(Reventless.DcbTag.string) string, name: string})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// ─── AddProduct StateChangeSlice ───
|
|
25
|
+
module AddProductSpec = {
|
|
26
|
+
let name = "AddProduct"
|
|
27
|
+
module Id = Reventless.Id.String
|
|
28
|
+
let moduleUrl: string = %raw(`import.meta.url`)
|
|
29
|
+
|
|
30
|
+
@schema
|
|
31
|
+
type event =
|
|
32
|
+
| ProductAdded({
|
|
33
|
+
productId: @s.matches(Reventless.DcbTag.partition) string,
|
|
34
|
+
categoryId: @s.matches(Reventless.DcbTag.string) string,
|
|
35
|
+
name: string,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
@schema
|
|
39
|
+
type consumedEvent =
|
|
40
|
+
| ProductAdded({productId: string})
|
|
41
|
+
| CategoryAdded({categoryId: string})
|
|
42
|
+
|
|
43
|
+
@schema
|
|
44
|
+
type command =
|
|
45
|
+
| AddProduct({
|
|
46
|
+
productId: @s.matches(Reventless.DcbTag.partition) string,
|
|
47
|
+
categoryId: @s.matches(Reventless.DcbTag.string) string,
|
|
48
|
+
name: string,
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
@schema
|
|
52
|
+
type error =
|
|
53
|
+
| ProductAlreadyExists
|
|
54
|
+
| CategoryNotFound
|
|
55
|
+
|
|
56
|
+
let commandSchema = commandSchema
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module AddProductBehavior = {
|
|
60
|
+
module Spec = AddProductSpec
|
|
61
|
+
let moduleUrl: string = %raw(`import.meta.url`)
|
|
62
|
+
|
|
63
|
+
// `exists` flips true if the decision read returns ANY ProductAdded — so if a
|
|
64
|
+
// sibling leaked into the read, p2 would be wrongly rejected. `liveCats` holds
|
|
65
|
+
// categories seen via CategoryAdded.
|
|
66
|
+
type state = {exists: bool, liveCats: array<string>}
|
|
67
|
+
let initialState = {exists: false, liveCats: []}
|
|
68
|
+
|
|
69
|
+
let evolve = (state: state, event: Spec.consumedEvent): state =>
|
|
70
|
+
switch event {
|
|
71
|
+
| ProductAdded(_) => {...state, exists: true}
|
|
72
|
+
| CategoryAdded({categoryId}) => {...state, liveCats: Array.concat(state.liveCats, [categoryId])}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let decide = (state: state, command: Spec.command): result<array<Spec.event>, Spec.error> =>
|
|
76
|
+
switch command {
|
|
77
|
+
| AddProduct({productId, categoryId, name}) =>
|
|
78
|
+
if state.exists {
|
|
79
|
+
Error(ProductAlreadyExists)
|
|
80
|
+
} else if !(state.liveCats->Array.includes(categoryId)) {
|
|
81
|
+
Error(CategoryNotFound)
|
|
82
|
+
} else {
|
|
83
|
+
Ok([Spec.ProductAdded({productId, categoryId, name})])
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ─── Isolated bus + event-topic counter ───
|
|
89
|
+
module Bus = LocalBus.Make()
|
|
90
|
+
|
|
91
|
+
let capturedEventCount: ref<int> = ref(0)
|
|
92
|
+
let _ = Bus.subscribeToEvents("CatalogLogEventTopic", async (_, _, _) => {
|
|
93
|
+
capturedEventCount := capturedEventCount.contents + 1
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
let _ = TestRunner.setup()
|
|
97
|
+
|
|
98
|
+
// ─── DcbEventLog (partitioned by productId, with a categoryId secondary index) ───
|
|
99
|
+
module CatalogLogMaker = DcbEventLog_Builder.Make(Bus)
|
|
100
|
+
let eventLog = CatalogLogMaker.make(
|
|
101
|
+
~name="CatalogLog",
|
|
102
|
+
~partitionTag=Reventless.DcbTag.Simple({key: "productId"}),
|
|
103
|
+
~indexes=["tag_categoryId"],
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
// ─── StateChangeSlice, threaded with the INFERRED scope ───
|
|
107
|
+
module AddProductMaker = StateChangeSlice_Builder.Make(AddProductSpec, AddProductBehavior)
|
|
108
|
+
|
|
109
|
+
let publishJsons: ReventlessInfra.CommandTopic.publishJsons = async cmdJsons => {
|
|
110
|
+
let _ = await cmdJsons
|
|
111
|
+
->Array.map(async cmdJson => {
|
|
112
|
+
let typeName = switch cmdJson.commandJson {
|
|
113
|
+
| JSON.Object(dict) =>
|
|
114
|
+
dict
|
|
115
|
+
->Dict.get("TAG")
|
|
116
|
+
->Option.flatMap(j =>
|
|
117
|
+
switch j {
|
|
118
|
+
| JSON.String(s) => Some(s)
|
|
119
|
+
| _ => None
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
->Option.getOr("")
|
|
123
|
+
| _ => ""
|
|
124
|
+
}
|
|
125
|
+
let fullBody = JSON.Encode.object(
|
|
126
|
+
Dict.fromArray([
|
|
127
|
+
("id", JSON.Encode.string(cmdJson.id)),
|
|
128
|
+
("meta", cmdJson.meta->S.reverseConvertToJsonOrThrow(Reventless.Message.metaSchema)),
|
|
129
|
+
("command", cmdJson.commandJson),
|
|
130
|
+
]),
|
|
131
|
+
)
|
|
132
|
+
let handlers = ReventlessCore.CommandTopic.getHandlers(typeName)
|
|
133
|
+
let _ = await handlers
|
|
134
|
+
->Array.map(async entry => {
|
|
135
|
+
let item: ReventlessInfra.CommandTopic.topicItem<JSON.t> = {
|
|
136
|
+
reference: cmdJson.id,
|
|
137
|
+
command: fullBody,
|
|
138
|
+
}
|
|
139
|
+
let _ = await entry.handler(Stream.fromIterable([item]))->Effect.runPromise
|
|
140
|
+
})
|
|
141
|
+
->Promise.all
|
|
142
|
+
})
|
|
143
|
+
->Promise.all
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
let publishJsonsOutput = publishJsons->Pulumi.Output.make
|
|
147
|
+
|
|
148
|
+
let _addProductSlice = AddProductMaker.make(
|
|
149
|
+
~dcbEventLog=eventLog,
|
|
150
|
+
~publishJsons=publishJsonsOutput,
|
|
151
|
+
~tagKeysByEventType=Dict.fromArray([("ProductAdded", ["productId"]), ("CategoryAdded", ["categoryId"])]),
|
|
152
|
+
~crossPartitionTagKeys=["categoryId"],
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
// ─── Helpers ───
|
|
156
|
+
let dispatch = async (commandJson, id) =>
|
|
157
|
+
await publishJsons([{Reventless.Message.id, meta: testMeta, commandJson}])
|
|
158
|
+
|
|
159
|
+
let encodeEvent = (event: CatalogLog.event): ReventlessInfra.DcbEventLog.rawEvent => {
|
|
160
|
+
let json = event->S.reverseConvertToJsonOrThrow(CatalogLog.eventSchema)
|
|
161
|
+
let (eventType, data) = json->ReventlessCore.Message.splitMessage
|
|
162
|
+
let tags = Reventless.DcbTag.extractTags(CatalogLog.eventSchema, event)
|
|
163
|
+
let meta = ReventlessCore.Message.generateMeta(~service="test")
|
|
164
|
+
{eventType, data: JSON.Object(data), tags, meta}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
let addProductJson = (productId, categoryId, name) =>
|
|
168
|
+
AddProductSpec.AddProduct({productId, categoryId, name})->S.reverseConvertToJsonOrThrow(
|
|
169
|
+
AddProductSpec.commandSchema,
|
|
170
|
+
)
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as S from "sury/src/S.res.mjs";
|
|
4
|
+
import * as Id$Reventless from "@reventlessdev/reventless-spec/src/types/Id.res.mjs";
|
|
5
|
+
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Stream from "effect/Stream";
|
|
8
|
+
import * as Pulumi from "@pulumi/pulumi";
|
|
9
|
+
import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
|
|
10
|
+
import * as Message$Reventless from "@reventlessdev/reventless-spec/src/types/Message.res.mjs";
|
|
11
|
+
import * as Message$ReventlessCore from "@reventlessdev/reventless-core/src/Message.res.mjs";
|
|
12
|
+
import * as LocalBus$ReventlessLocal from "../../../src/adapter/LocalBus.res.mjs";
|
|
13
|
+
import * as TestRunner$ReventlessLocal from "../../../src/test/TestRunner.res.mjs";
|
|
14
|
+
import * as CommandTopic$ReventlessCore from "@reventlessdev/reventless-core/src/components/CommandTopic/CommandTopic.res.mjs";
|
|
15
|
+
import * as TestFixtures$ReventlessLocal from "../../TestFixtures.res.mjs";
|
|
16
|
+
import * as DcbEventLog_Builder$ReventlessLocal from "../../../src/components/DcbEventLog_Builder.res.mjs";
|
|
17
|
+
import * as StateChangeSlice_Builder$ReventlessLocal from "../../../src/components/StateChangeSlice_Builder.res.mjs";
|
|
18
|
+
|
|
19
|
+
let eventSchema = S.union([
|
|
20
|
+
S.schema(s => ({
|
|
21
|
+
TAG: "ProductAdded",
|
|
22
|
+
productId: s.m(DcbTag$Reventless.partition),
|
|
23
|
+
categoryId: s.m(DcbTag$Reventless.string),
|
|
24
|
+
name: s.m(S.string)
|
|
25
|
+
})),
|
|
26
|
+
S.schema(s => ({
|
|
27
|
+
TAG: "CategoryAdded",
|
|
28
|
+
categoryId: s.m(DcbTag$Reventless.string),
|
|
29
|
+
name: s.m(S.string)
|
|
30
|
+
}))
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
let CatalogLog = {
|
|
34
|
+
eventSchema: eventSchema
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
let name = "AddProduct";
|
|
38
|
+
|
|
39
|
+
let moduleUrl = import.meta.url;
|
|
40
|
+
|
|
41
|
+
let eventSchema$1 = S.schema(s => ({
|
|
42
|
+
TAG: "ProductAdded",
|
|
43
|
+
productId: s.m(DcbTag$Reventless.partition),
|
|
44
|
+
categoryId: s.m(DcbTag$Reventless.string),
|
|
45
|
+
name: s.m(S.string)
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
let consumedEventSchema = S.union([
|
|
49
|
+
S.schema(s => ({
|
|
50
|
+
TAG: "ProductAdded",
|
|
51
|
+
productId: s.m(S.string)
|
|
52
|
+
})),
|
|
53
|
+
S.schema(s => ({
|
|
54
|
+
TAG: "CategoryAdded",
|
|
55
|
+
categoryId: s.m(S.string)
|
|
56
|
+
}))
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
let commandSchema = S.schema(s => ({
|
|
60
|
+
TAG: "AddProduct",
|
|
61
|
+
productId: s.m(DcbTag$Reventless.partition),
|
|
62
|
+
categoryId: s.m(DcbTag$Reventless.string),
|
|
63
|
+
name: s.m(S.string)
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
let errorSchema = S.union([
|
|
67
|
+
S.literal("ProductAlreadyExists"),
|
|
68
|
+
S.literal("CategoryNotFound")
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
function commandAuthorization(param) {
|
|
72
|
+
return "AllowAuthenticated";
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let AddProductSpec = {
|
|
76
|
+
name: name,
|
|
77
|
+
Id: undefined,
|
|
78
|
+
moduleUrl: moduleUrl,
|
|
79
|
+
eventSchema: eventSchema$1,
|
|
80
|
+
consumedEventSchema: consumedEventSchema,
|
|
81
|
+
errorSchema: errorSchema,
|
|
82
|
+
commandSchema: commandSchema,
|
|
83
|
+
commandAuthorization: commandAuthorization,
|
|
84
|
+
readConsistency: "EscalateOnRetry"
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
let moduleUrl$1 = import.meta.url;
|
|
88
|
+
|
|
89
|
+
let initialState_liveCats = [];
|
|
90
|
+
|
|
91
|
+
let initialState = {
|
|
92
|
+
exists: false,
|
|
93
|
+
liveCats: initialState_liveCats
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
function evolve(state, event) {
|
|
97
|
+
if (event.TAG === "ProductAdded") {
|
|
98
|
+
return {
|
|
99
|
+
exists: true,
|
|
100
|
+
liveCats: state.liveCats
|
|
101
|
+
};
|
|
102
|
+
} else {
|
|
103
|
+
return {
|
|
104
|
+
exists: state.exists,
|
|
105
|
+
liveCats: state.liveCats.concat([event.categoryId])
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function decide(state, command) {
|
|
111
|
+
if (state.exists) {
|
|
112
|
+
return {
|
|
113
|
+
TAG: "Error",
|
|
114
|
+
_0: "ProductAlreadyExists"
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
let categoryId = command.categoryId;
|
|
118
|
+
if (state.liveCats.includes(categoryId)) {
|
|
119
|
+
return {
|
|
120
|
+
TAG: "Ok",
|
|
121
|
+
_0: [{
|
|
122
|
+
TAG: "ProductAdded",
|
|
123
|
+
productId: command.productId,
|
|
124
|
+
categoryId: categoryId,
|
|
125
|
+
name: command.name
|
|
126
|
+
}]
|
|
127
|
+
};
|
|
128
|
+
} else {
|
|
129
|
+
return {
|
|
130
|
+
TAG: "Error",
|
|
131
|
+
_0: "CategoryNotFound"
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let AddProductBehavior = {
|
|
137
|
+
Spec: undefined,
|
|
138
|
+
moduleUrl: moduleUrl$1,
|
|
139
|
+
initialState: initialState,
|
|
140
|
+
evolve: evolve,
|
|
141
|
+
decide: decide
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
let Bus = LocalBus$ReventlessLocal.Make({});
|
|
145
|
+
|
|
146
|
+
let capturedEventCount = {
|
|
147
|
+
contents: 0
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
Bus.subscribeToEvents("CatalogLogEventTopic", async (param, param$1, param$2) => {
|
|
151
|
+
capturedEventCount.contents = capturedEventCount.contents + 1 | 0;
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
TestRunner$ReventlessLocal.setup();
|
|
155
|
+
|
|
156
|
+
let CatalogLogMaker = DcbEventLog_Builder$ReventlessLocal.Make(Bus);
|
|
157
|
+
|
|
158
|
+
let eventLog = CatalogLogMaker.make("CatalogLog", ["tag_categoryId"], {
|
|
159
|
+
TAG: "Simple",
|
|
160
|
+
_0: {
|
|
161
|
+
key: "productId"
|
|
162
|
+
}
|
|
163
|
+
}, undefined);
|
|
164
|
+
|
|
165
|
+
let AddProductMaker = StateChangeSlice_Builder$ReventlessLocal.Make({
|
|
166
|
+
name: name,
|
|
167
|
+
moduleUrl: moduleUrl,
|
|
168
|
+
Id: Id$Reventless.$$String,
|
|
169
|
+
consumedEventSchema: consumedEventSchema,
|
|
170
|
+
errorSchema: errorSchema,
|
|
171
|
+
eventSchema: eventSchema$1,
|
|
172
|
+
commandSchema: commandSchema,
|
|
173
|
+
commandAuthorization: commandAuthorization,
|
|
174
|
+
readConsistency: "EscalateOnRetry"
|
|
175
|
+
})({
|
|
176
|
+
initialState: initialState,
|
|
177
|
+
evolve: evolve,
|
|
178
|
+
decide: decide,
|
|
179
|
+
moduleUrl: moduleUrl$1
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
async function publishJsons(cmdJsons) {
|
|
183
|
+
await Promise.all(cmdJsons.map(async cmdJson => {
|
|
184
|
+
let dict = cmdJson.commandJson;
|
|
185
|
+
let typeName;
|
|
186
|
+
typeName = typeof dict === "object" && dict !== null && !Array.isArray(dict) ? Stdlib_Option.getOr(Stdlib_Option.flatMap(dict["TAG"], j => {
|
|
187
|
+
if (typeof j === "string") {
|
|
188
|
+
return j;
|
|
189
|
+
}
|
|
190
|
+
}), "") : "";
|
|
191
|
+
let fullBody = Object.fromEntries([
|
|
192
|
+
[
|
|
193
|
+
"id",
|
|
194
|
+
cmdJson.id
|
|
195
|
+
],
|
|
196
|
+
[
|
|
197
|
+
"meta",
|
|
198
|
+
S.reverseConvertToJsonOrThrow(cmdJson.meta, Message$Reventless.metaSchema)
|
|
199
|
+
],
|
|
200
|
+
[
|
|
201
|
+
"command",
|
|
202
|
+
cmdJson.commandJson
|
|
203
|
+
]
|
|
204
|
+
]);
|
|
205
|
+
let handlers = CommandTopic$ReventlessCore.getHandlers(typeName);
|
|
206
|
+
await Promise.all(handlers.map(async entry => {
|
|
207
|
+
let item_reference = cmdJson.id;
|
|
208
|
+
let item = {
|
|
209
|
+
command: fullBody,
|
|
210
|
+
reference: item_reference
|
|
211
|
+
};
|
|
212
|
+
await Effect.runPromise(entry.handler(Stream.fromIterable([item])));
|
|
213
|
+
}));
|
|
214
|
+
}));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
let publishJsonsOutput = Pulumi.output(publishJsons);
|
|
218
|
+
|
|
219
|
+
let _addProductSlice = AddProductMaker.make(eventLog, publishJsonsOutput, Object.fromEntries([
|
|
220
|
+
[
|
|
221
|
+
"ProductAdded",
|
|
222
|
+
["productId"]
|
|
223
|
+
],
|
|
224
|
+
[
|
|
225
|
+
"CategoryAdded",
|
|
226
|
+
["categoryId"]
|
|
227
|
+
]
|
|
228
|
+
]), ["categoryId"], undefined);
|
|
229
|
+
|
|
230
|
+
async function dispatch(commandJson, id) {
|
|
231
|
+
return await publishJsons([{
|
|
232
|
+
id: id,
|
|
233
|
+
meta: TestFixtures$ReventlessLocal.testMeta,
|
|
234
|
+
commandJson: commandJson
|
|
235
|
+
}]);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function encodeEvent(event) {
|
|
239
|
+
let json = S.reverseConvertToJsonOrThrow(event, eventSchema);
|
|
240
|
+
let match = Message$ReventlessCore.splitMessage(json);
|
|
241
|
+
let tags = DcbTag$Reventless.extractTags(eventSchema, event);
|
|
242
|
+
let meta = Message$ReventlessCore.generateMeta("test", undefined, undefined, undefined, undefined, undefined, undefined, undefined);
|
|
243
|
+
return {
|
|
244
|
+
eventType: match[0],
|
|
245
|
+
data: match[1],
|
|
246
|
+
tags: tags,
|
|
247
|
+
meta: meta
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function addProductJson(productId, categoryId, name) {
|
|
252
|
+
return S.reverseConvertToJsonOrThrow({
|
|
253
|
+
TAG: "AddProduct",
|
|
254
|
+
productId: productId,
|
|
255
|
+
categoryId: categoryId,
|
|
256
|
+
name: name
|
|
257
|
+
}, commandSchema);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export {
|
|
261
|
+
CatalogLog,
|
|
262
|
+
AddProductSpec,
|
|
263
|
+
AddProductBehavior,
|
|
264
|
+
Bus,
|
|
265
|
+
capturedEventCount,
|
|
266
|
+
CatalogLogMaker,
|
|
267
|
+
eventLog,
|
|
268
|
+
AddProductMaker,
|
|
269
|
+
publishJsons,
|
|
270
|
+
publishJsonsOutput,
|
|
271
|
+
_addProductSlice,
|
|
272
|
+
dispatch,
|
|
273
|
+
encodeEvent,
|
|
274
|
+
addProductJson,
|
|
275
|
+
}
|
|
276
|
+
/* eventSchema Not a pure module */
|