@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,241 @@
|
|
|
1
|
+
// Unit tests for InboundTranslationSlice_Callback — tests receive function directly.
|
|
2
|
+
|
|
3
|
+
open JestGlobals
|
|
4
|
+
open InboundTranslationSliceFixtures
|
|
5
|
+
|
|
6
|
+
module PaymentWebhookTranslation = {
|
|
7
|
+
let translate = PaymentWebhookSpec.translate
|
|
8
|
+
let moduleUrl = PaymentWebhookSpec.moduleUrl
|
|
9
|
+
}
|
|
10
|
+
module Callback = ReventlessCore.InboundTranslationSlice_Callback.Make(
|
|
11
|
+
PaymentWebhookSpec,
|
|
12
|
+
PaymentWebhookTranslation,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
describe("InboundTranslationSlice Callback", () => {
|
|
16
|
+
let _ = beforeEach(() => {
|
|
17
|
+
Callback.auditLog->Dict.keysToArray->Array.forEach(k => Callback.auditLog->Dict.delete(k))
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
describe("receive", () => {
|
|
21
|
+
testPromise("valid input with completed status publishes command and returns Ok", async () => {
|
|
22
|
+
let publishedCommands = ref([])
|
|
23
|
+
let mockPublish: ReventlessInfra.CommandTopic.publishJsons = async cmds => {
|
|
24
|
+
publishedCommands := cmds
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let inputJson =
|
|
28
|
+
{
|
|
29
|
+
"paymentId": "pay-123",
|
|
30
|
+
"orderId": "ord-1",
|
|
31
|
+
"status": "completed",
|
|
32
|
+
}->Obj.magic
|
|
33
|
+
|
|
34
|
+
let result = await Callback.receive(mockPublish, inputJson)
|
|
35
|
+
|
|
36
|
+
switch result {
|
|
37
|
+
| Ok(targetIds) =>
|
|
38
|
+
expect(targetIds->Array.length)->toBe(1)
|
|
39
|
+
expect(targetIds->Array.getUnsafe(0))->toBe("ord-1")
|
|
40
|
+
| Error(_) => expect(true)->toBe(false)
|
|
41
|
+
}
|
|
42
|
+
expect(publishedCommands.contents->Array.length)->toBe(1)
|
|
43
|
+
let cmd = publishedCommands.contents->Array.getUnsafe(0)
|
|
44
|
+
expect(cmd.id)->toBe("ord-1")
|
|
45
|
+
|
|
46
|
+
// Audit log should have one entry
|
|
47
|
+
let auditEntries = Callback.auditLog->Dict.toArray
|
|
48
|
+
expect(auditEntries->Array.length)->toBe(1)
|
|
49
|
+
let (_, auditRow) = auditEntries->Array.getUnsafe(0)
|
|
50
|
+
expect(auditRow.status)->toBe(ReventlessCore.InboundTranslationSlice_Callback.Success)
|
|
51
|
+
expect(auditRow.commandCount)->toBe(Some(1))
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
testPromise("translate returns Error — no command published, audit logged", async () => {
|
|
55
|
+
let publishedCommands = ref([])
|
|
56
|
+
let mockPublish: ReventlessInfra.CommandTopic.publishJsons = async cmds => {
|
|
57
|
+
publishedCommands := cmds
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let inputJson =
|
|
61
|
+
{
|
|
62
|
+
"paymentId": "pay-123",
|
|
63
|
+
"orderId": "ord-1",
|
|
64
|
+
"status": "pending",
|
|
65
|
+
}->Obj.magic
|
|
66
|
+
|
|
67
|
+
let result = await Callback.receive(mockPublish, inputJson)
|
|
68
|
+
|
|
69
|
+
switch result {
|
|
70
|
+
| Error(msg) => expect(msg)->toBe("Unknown payment status: pending")
|
|
71
|
+
| Ok(_) => expect(true)->toBe(false)
|
|
72
|
+
}
|
|
73
|
+
expect(publishedCommands.contents->Array.length)->toBe(0)
|
|
74
|
+
|
|
75
|
+
let auditEntries = Callback.auditLog->Dict.toArray
|
|
76
|
+
expect(auditEntries->Array.length)->toBe(1)
|
|
77
|
+
let (_, auditRow) = auditEntries->Array.getUnsafe(0)
|
|
78
|
+
expect(auditRow.status)->toBe(ReventlessCore.InboundTranslationSlice_Callback.Failure)
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
testPromise("invalid JSON input returns Error and audit logged", async () => {
|
|
82
|
+
let mockPublish: ReventlessInfra.CommandTopic.publishJsons = async _cmds => ()
|
|
83
|
+
|
|
84
|
+
// Missing required fields
|
|
85
|
+
let inputJson = {"unexpected": "data"}->Obj.magic
|
|
86
|
+
|
|
87
|
+
let result = await Callback.receive(mockPublish, inputJson)
|
|
88
|
+
|
|
89
|
+
switch result {
|
|
90
|
+
| Error(_) => expect(true)->toBe(true)
|
|
91
|
+
| Ok(_) => expect(true)->toBe(false)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
let auditEntries = Callback.auditLog->Dict.toArray
|
|
95
|
+
expect(auditEntries->Array.length)->toBe(1)
|
|
96
|
+
let (_, auditRow) = auditEntries->Array.getUnsafe(0)
|
|
97
|
+
expect(auditRow.status)->toBe(ReventlessCore.InboundTranslationSlice_Callback.Failure)
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
testPromise("publishJsons failure returns Error and audit logged", async () => {
|
|
101
|
+
let failingPublish: ReventlessInfra.CommandTopic.publishJsons = async _cmds => {
|
|
102
|
+
JsError.throwWithMessage("publish failed")
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
let inputJson =
|
|
106
|
+
{
|
|
107
|
+
"paymentId": "pay-123",
|
|
108
|
+
"orderId": "ord-1",
|
|
109
|
+
"status": "completed",
|
|
110
|
+
}->Obj.magic
|
|
111
|
+
|
|
112
|
+
let result = await Callback.receive(failingPublish, inputJson)
|
|
113
|
+
|
|
114
|
+
switch result {
|
|
115
|
+
| Error(msg) => expect(msg)->toBe("publish failed")
|
|
116
|
+
| Ok(_) => expect(true)->toBe(false)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
let auditEntries = Callback.auditLog->Dict.toArray
|
|
120
|
+
expect(auditEntries->Array.length)->toBe(1)
|
|
121
|
+
let (_, auditRow) = auditEntries->Array.getUnsafe(0)
|
|
122
|
+
expect(auditRow.status)->toBe(ReventlessCore.InboundTranslationSlice_Callback.Failure)
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
describe("multi-command", () => {
|
|
127
|
+
testPromise("translate returning multiple pairs publishes all commands", async () => {
|
|
128
|
+
// Use a spec that returns multiple commands
|
|
129
|
+
module MultiSpec = {
|
|
130
|
+
let name = "BatchWebhook"
|
|
131
|
+
let moduleUrl: string = %raw(`import.meta.url`)
|
|
132
|
+
|
|
133
|
+
@schema
|
|
134
|
+
type externalInput = {orderId: string, items: array<string>}
|
|
135
|
+
|
|
136
|
+
@schema
|
|
137
|
+
type command = ConfirmPayment({
|
|
138
|
+
orderId: @s.matches(Reventless.DcbTag.string) string,
|
|
139
|
+
paymentId: string,
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
let targetName = "ConfirmPayment"
|
|
143
|
+
|
|
144
|
+
let translate = (input: externalInput) =>
|
|
145
|
+
Ok(
|
|
146
|
+
input.items->Array.map(item => (
|
|
147
|
+
input.orderId,
|
|
148
|
+
ConfirmPayment({orderId: input.orderId, paymentId: item}),
|
|
149
|
+
)),
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
let commandAuthorization = (_: command): Reventless.Authorization.permission =>
|
|
153
|
+
AllowAuthenticated
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
module MultiTranslation = {
|
|
157
|
+
let translate = MultiSpec.translate
|
|
158
|
+
let moduleUrl = MultiSpec.moduleUrl
|
|
159
|
+
}
|
|
160
|
+
module MultiCallback = ReventlessCore.InboundTranslationSlice_Callback.Make(
|
|
161
|
+
MultiSpec,
|
|
162
|
+
MultiTranslation,
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
let publishedCommands = ref([])
|
|
166
|
+
let mockPublish: ReventlessInfra.CommandTopic.publishJsons = async cmds => {
|
|
167
|
+
publishedCommands := cmds
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
let inputJson =
|
|
171
|
+
{
|
|
172
|
+
"orderId": "ord-1",
|
|
173
|
+
"items": ["pay-1", "pay-2", "pay-3"],
|
|
174
|
+
}->Obj.magic
|
|
175
|
+
|
|
176
|
+
let result = await MultiCallback.receive(mockPublish, inputJson)
|
|
177
|
+
|
|
178
|
+
switch result {
|
|
179
|
+
| Ok(targetIds) =>
|
|
180
|
+
expect(targetIds->Array.length)->toBe(3)
|
|
181
|
+
expect(targetIds->Array.getUnsafe(0))->toBe("ord-1")
|
|
182
|
+
| Error(_) => expect(true)->toBe(false)
|
|
183
|
+
}
|
|
184
|
+
// All 3 commands published in one batch
|
|
185
|
+
expect(publishedCommands.contents->Array.length)->toBe(3)
|
|
186
|
+
|
|
187
|
+
let auditEntries = MultiCallback.auditLog->Dict.toArray
|
|
188
|
+
expect(auditEntries->Array.length)->toBe(1)
|
|
189
|
+
let (_, auditRow) = auditEntries->Array.getUnsafe(0)
|
|
190
|
+
expect(auditRow.status)->toBe(ReventlessCore.InboundTranslationSlice_Callback.Success)
|
|
191
|
+
expect(auditRow.commandCount)->toBe(Some(3))
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
testPromise("translate returning empty array publishes nothing", async () => {
|
|
195
|
+
module EmptySpec = {
|
|
196
|
+
let name = "EmptyWebhook"
|
|
197
|
+
let moduleUrl: string = %raw(`import.meta.url`)
|
|
198
|
+
|
|
199
|
+
@schema
|
|
200
|
+
type externalInput = {orderId: string}
|
|
201
|
+
|
|
202
|
+
@schema
|
|
203
|
+
type command = ConfirmPayment({
|
|
204
|
+
orderId: @s.matches(Reventless.DcbTag.string) string,
|
|
205
|
+
paymentId: string,
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
let targetName = "ConfirmPayment"
|
|
209
|
+
|
|
210
|
+
let translate = (_input: externalInput) => Ok([])
|
|
211
|
+
|
|
212
|
+
let commandAuthorization = (_: command): Reventless.Authorization.permission =>
|
|
213
|
+
AllowAuthenticated
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
module EmptyTranslation = {
|
|
217
|
+
let translate = EmptySpec.translate
|
|
218
|
+
let moduleUrl = EmptySpec.moduleUrl
|
|
219
|
+
}
|
|
220
|
+
module EmptyCallback = ReventlessCore.InboundTranslationSlice_Callback.Make(
|
|
221
|
+
EmptySpec,
|
|
222
|
+
EmptyTranslation,
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
let publishedCommands = ref([])
|
|
226
|
+
let mockPublish: ReventlessInfra.CommandTopic.publishJsons = async cmds => {
|
|
227
|
+
publishedCommands := cmds
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
let inputJson = {"orderId": "ord-1"}->Obj.magic
|
|
231
|
+
|
|
232
|
+
let result = await EmptyCallback.receive(mockPublish, inputJson)
|
|
233
|
+
|
|
234
|
+
switch result {
|
|
235
|
+
| Ok(targetIds) => expect(targetIds->Array.length)->toBe(0)
|
|
236
|
+
| Error(_) => expect(true)->toBe(false)
|
|
237
|
+
}
|
|
238
|
+
expect(publishedCommands.contents->Array.length)->toBe(0)
|
|
239
|
+
})
|
|
240
|
+
})
|
|
241
|
+
})
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as S from "sury/src/S.res.mjs";
|
|
4
|
+
import * as Stdlib_Dict from "@rescript/runtime/lib/es6/Stdlib_Dict.js";
|
|
5
|
+
import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
|
|
6
|
+
import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
|
|
7
|
+
import * as InboundTranslationSliceFixtures$ReventlessLocal from "./InboundTranslationSliceFixtures.res.mjs";
|
|
8
|
+
import * as InboundTranslationSlice_Callback$ReventlessCore from "@reventlessdev/reventless-core/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res.mjs";
|
|
9
|
+
|
|
10
|
+
let translate = InboundTranslationSliceFixtures$ReventlessLocal.PaymentWebhookSpec.translate;
|
|
11
|
+
|
|
12
|
+
let moduleUrl = InboundTranslationSliceFixtures$ReventlessLocal.PaymentWebhookSpec.moduleUrl;
|
|
13
|
+
|
|
14
|
+
let PaymentWebhookTranslation = {
|
|
15
|
+
translate: translate,
|
|
16
|
+
moduleUrl: moduleUrl
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
let Callback = InboundTranslationSlice_Callback$ReventlessCore.Make({
|
|
20
|
+
name: InboundTranslationSliceFixtures$ReventlessLocal.PaymentWebhookSpec.name,
|
|
21
|
+
moduleUrl: InboundTranslationSliceFixtures$ReventlessLocal.PaymentWebhookSpec.moduleUrl,
|
|
22
|
+
externalInputSchema: InboundTranslationSliceFixtures$ReventlessLocal.PaymentWebhookSpec.externalInputSchema,
|
|
23
|
+
commandSchema: InboundTranslationSliceFixtures$ReventlessLocal.PaymentWebhookSpec.commandSchema,
|
|
24
|
+
targetName: InboundTranslationSliceFixtures$ReventlessLocal.PaymentWebhookSpec.targetName,
|
|
25
|
+
commandAuthorization: InboundTranslationSliceFixtures$ReventlessLocal.PaymentWebhookSpec.commandAuthorization
|
|
26
|
+
})(PaymentWebhookTranslation);
|
|
27
|
+
|
|
28
|
+
globalThis.describe("InboundTranslationSlice Callback", () => {
|
|
29
|
+
globalThis.beforeEach(() => {
|
|
30
|
+
Object.keys(Callback.auditLog).forEach(k => Stdlib_Dict.$$delete(Callback.auditLog, k));
|
|
31
|
+
});
|
|
32
|
+
globalThis.describe("receive", () => {
|
|
33
|
+
globalThis.test("valid input with completed status publishes command and returns Ok", async () => {
|
|
34
|
+
let publishedCommands = {
|
|
35
|
+
contents: []
|
|
36
|
+
};
|
|
37
|
+
let mockPublish = async cmds => {
|
|
38
|
+
publishedCommands.contents = cmds;
|
|
39
|
+
};
|
|
40
|
+
let inputJson = {
|
|
41
|
+
paymentId: "pay-123",
|
|
42
|
+
orderId: "ord-1",
|
|
43
|
+
status: "completed"
|
|
44
|
+
};
|
|
45
|
+
let result = await Callback.receive(mockPublish, inputJson);
|
|
46
|
+
if (result.TAG === "Ok") {
|
|
47
|
+
let targetIds = result._0;
|
|
48
|
+
globalThis.expect(targetIds.length).toBe(1);
|
|
49
|
+
globalThis.expect(targetIds[0]).toBe("ord-1");
|
|
50
|
+
} else {
|
|
51
|
+
globalThis.expect(true).toBe(false);
|
|
52
|
+
}
|
|
53
|
+
globalThis.expect(publishedCommands.contents.length).toBe(1);
|
|
54
|
+
let cmd = publishedCommands.contents[0];
|
|
55
|
+
globalThis.expect(cmd.id).toBe("ord-1");
|
|
56
|
+
let auditEntries = Object.entries(Callback.auditLog);
|
|
57
|
+
globalThis.expect(auditEntries.length).toBe(1);
|
|
58
|
+
let match = auditEntries[0];
|
|
59
|
+
let auditRow = match[1];
|
|
60
|
+
globalThis.expect(auditRow.status).toBe("Success");
|
|
61
|
+
globalThis.expect(auditRow.commandCount).toBe(1);
|
|
62
|
+
});
|
|
63
|
+
globalThis.test("translate returns Error — no command published, audit logged", async () => {
|
|
64
|
+
let publishedCommands = {
|
|
65
|
+
contents: []
|
|
66
|
+
};
|
|
67
|
+
let mockPublish = async cmds => {
|
|
68
|
+
publishedCommands.contents = cmds;
|
|
69
|
+
};
|
|
70
|
+
let inputJson = {
|
|
71
|
+
paymentId: "pay-123",
|
|
72
|
+
orderId: "ord-1",
|
|
73
|
+
status: "pending"
|
|
74
|
+
};
|
|
75
|
+
let result = await Callback.receive(mockPublish, inputJson);
|
|
76
|
+
if (result.TAG === "Ok") {
|
|
77
|
+
globalThis.expect(true).toBe(false);
|
|
78
|
+
} else {
|
|
79
|
+
globalThis.expect(result._0).toBe("Unknown payment status: pending");
|
|
80
|
+
}
|
|
81
|
+
globalThis.expect(publishedCommands.contents.length).toBe(0);
|
|
82
|
+
let auditEntries = Object.entries(Callback.auditLog);
|
|
83
|
+
globalThis.expect(auditEntries.length).toBe(1);
|
|
84
|
+
let match = auditEntries[0];
|
|
85
|
+
globalThis.expect(match[1].status).toBe("Failure");
|
|
86
|
+
});
|
|
87
|
+
globalThis.test("invalid JSON input returns Error and audit logged", async () => {
|
|
88
|
+
let mockPublish = async _cmds => {};
|
|
89
|
+
let inputJson = {
|
|
90
|
+
unexpected: "data"
|
|
91
|
+
};
|
|
92
|
+
let result = await Callback.receive(mockPublish, inputJson);
|
|
93
|
+
if (result.TAG === "Ok") {
|
|
94
|
+
globalThis.expect(true).toBe(false);
|
|
95
|
+
} else {
|
|
96
|
+
globalThis.expect(true).toBe(true);
|
|
97
|
+
}
|
|
98
|
+
let auditEntries = Object.entries(Callback.auditLog);
|
|
99
|
+
globalThis.expect(auditEntries.length).toBe(1);
|
|
100
|
+
let match = auditEntries[0];
|
|
101
|
+
globalThis.expect(match[1].status).toBe("Failure");
|
|
102
|
+
});
|
|
103
|
+
globalThis.test("publishJsons failure returns Error and audit logged", async () => {
|
|
104
|
+
let failingPublish = async _cmds => Stdlib_JsError.throwWithMessage("publish failed");
|
|
105
|
+
let inputJson = {
|
|
106
|
+
paymentId: "pay-123",
|
|
107
|
+
orderId: "ord-1",
|
|
108
|
+
status: "completed"
|
|
109
|
+
};
|
|
110
|
+
let result = await Callback.receive(failingPublish, inputJson);
|
|
111
|
+
if (result.TAG === "Ok") {
|
|
112
|
+
globalThis.expect(true).toBe(false);
|
|
113
|
+
} else {
|
|
114
|
+
globalThis.expect(result._0).toBe("publish failed");
|
|
115
|
+
}
|
|
116
|
+
let auditEntries = Object.entries(Callback.auditLog);
|
|
117
|
+
globalThis.expect(auditEntries.length).toBe(1);
|
|
118
|
+
let match = auditEntries[0];
|
|
119
|
+
globalThis.expect(match[1].status).toBe("Failure");
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
globalThis.describe("multi-command", () => {
|
|
123
|
+
globalThis.test("translate returning multiple pairs publishes all commands", async () => {
|
|
124
|
+
let moduleUrl = import.meta.url;
|
|
125
|
+
let externalInputSchema = S.schema(s => ({
|
|
126
|
+
orderId: s.m(S.string),
|
|
127
|
+
items: s.m(S.array(S.string))
|
|
128
|
+
}));
|
|
129
|
+
let commandSchema = S.schema(s => ({
|
|
130
|
+
TAG: "ConfirmPayment",
|
|
131
|
+
orderId: s.m(DcbTag$Reventless.string),
|
|
132
|
+
paymentId: s.m(S.string)
|
|
133
|
+
}));
|
|
134
|
+
let translate = input => ({
|
|
135
|
+
TAG: "Ok",
|
|
136
|
+
_0: input.items.map(item => [
|
|
137
|
+
input.orderId,
|
|
138
|
+
{
|
|
139
|
+
TAG: "ConfirmPayment",
|
|
140
|
+
orderId: input.orderId,
|
|
141
|
+
paymentId: item
|
|
142
|
+
}
|
|
143
|
+
])
|
|
144
|
+
});
|
|
145
|
+
let commandAuthorization = param => "AllowAuthenticated";
|
|
146
|
+
let MultiTranslation = {
|
|
147
|
+
translate: translate,
|
|
148
|
+
moduleUrl: moduleUrl
|
|
149
|
+
};
|
|
150
|
+
let MultiCallback = InboundTranslationSlice_Callback$ReventlessCore.Make({
|
|
151
|
+
name: "BatchWebhook",
|
|
152
|
+
moduleUrl: moduleUrl,
|
|
153
|
+
externalInputSchema: externalInputSchema,
|
|
154
|
+
commandSchema: commandSchema,
|
|
155
|
+
targetName: "ConfirmPayment",
|
|
156
|
+
commandAuthorization: commandAuthorization
|
|
157
|
+
})(MultiTranslation);
|
|
158
|
+
let publishedCommands = {
|
|
159
|
+
contents: []
|
|
160
|
+
};
|
|
161
|
+
let mockPublish = async cmds => {
|
|
162
|
+
publishedCommands.contents = cmds;
|
|
163
|
+
};
|
|
164
|
+
let inputJson = {
|
|
165
|
+
orderId: "ord-1",
|
|
166
|
+
items: [
|
|
167
|
+
"pay-1",
|
|
168
|
+
"pay-2",
|
|
169
|
+
"pay-3"
|
|
170
|
+
]
|
|
171
|
+
};
|
|
172
|
+
let result = await MultiCallback.receive(mockPublish, inputJson);
|
|
173
|
+
if (result.TAG === "Ok") {
|
|
174
|
+
let targetIds = result._0;
|
|
175
|
+
globalThis.expect(targetIds.length).toBe(3);
|
|
176
|
+
globalThis.expect(targetIds[0]).toBe("ord-1");
|
|
177
|
+
} else {
|
|
178
|
+
globalThis.expect(true).toBe(false);
|
|
179
|
+
}
|
|
180
|
+
globalThis.expect(publishedCommands.contents.length).toBe(3);
|
|
181
|
+
let auditEntries = Object.entries(MultiCallback.auditLog);
|
|
182
|
+
globalThis.expect(auditEntries.length).toBe(1);
|
|
183
|
+
let match = auditEntries[0];
|
|
184
|
+
let auditRow = match[1];
|
|
185
|
+
globalThis.expect(auditRow.status).toBe("Success");
|
|
186
|
+
globalThis.expect(auditRow.commandCount).toBe(3);
|
|
187
|
+
});
|
|
188
|
+
globalThis.test("translate returning empty array publishes nothing", async () => {
|
|
189
|
+
let moduleUrl = import.meta.url;
|
|
190
|
+
let externalInputSchema = S.schema(s => ({
|
|
191
|
+
orderId: s.m(S.string)
|
|
192
|
+
}));
|
|
193
|
+
let commandSchema = S.schema(s => ({
|
|
194
|
+
TAG: "ConfirmPayment",
|
|
195
|
+
orderId: s.m(DcbTag$Reventless.string),
|
|
196
|
+
paymentId: s.m(S.string)
|
|
197
|
+
}));
|
|
198
|
+
let translate = _input => ({
|
|
199
|
+
TAG: "Ok",
|
|
200
|
+
_0: []
|
|
201
|
+
});
|
|
202
|
+
let commandAuthorization = param => "AllowAuthenticated";
|
|
203
|
+
let EmptyTranslation = {
|
|
204
|
+
translate: translate,
|
|
205
|
+
moduleUrl: moduleUrl
|
|
206
|
+
};
|
|
207
|
+
let EmptyCallback = InboundTranslationSlice_Callback$ReventlessCore.Make({
|
|
208
|
+
name: "EmptyWebhook",
|
|
209
|
+
moduleUrl: moduleUrl,
|
|
210
|
+
externalInputSchema: externalInputSchema,
|
|
211
|
+
commandSchema: commandSchema,
|
|
212
|
+
targetName: "ConfirmPayment",
|
|
213
|
+
commandAuthorization: commandAuthorization
|
|
214
|
+
})(EmptyTranslation);
|
|
215
|
+
let publishedCommands = {
|
|
216
|
+
contents: []
|
|
217
|
+
};
|
|
218
|
+
let mockPublish = async cmds => {
|
|
219
|
+
publishedCommands.contents = cmds;
|
|
220
|
+
};
|
|
221
|
+
let inputJson = {
|
|
222
|
+
orderId: "ord-1"
|
|
223
|
+
};
|
|
224
|
+
let result = await EmptyCallback.receive(mockPublish, inputJson);
|
|
225
|
+
if (result.TAG === "Ok") {
|
|
226
|
+
globalThis.expect(result._0.length).toBe(0);
|
|
227
|
+
} else {
|
|
228
|
+
globalThis.expect(true).toBe(false);
|
|
229
|
+
}
|
|
230
|
+
globalThis.expect(publishedCommands.contents.length).toBe(0);
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
export {
|
|
236
|
+
PaymentWebhookTranslation,
|
|
237
|
+
Callback,
|
|
238
|
+
}
|
|
239
|
+
/* Callback Not a pure module */
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Test fixtures for InboundTranslationSlice callback tests.
|
|
2
|
+
|
|
3
|
+
// ─────────────────────────────────────────────────────────────
|
|
4
|
+
// Minimal DcbEventLog spec
|
|
5
|
+
// ─────────────────────────────────────────────────────────────
|
|
6
|
+
|
|
7
|
+
module OrderEventLog = {
|
|
8
|
+
let moduleUrl: string = %raw(`import.meta.url`)
|
|
9
|
+
@schema
|
|
10
|
+
type event =
|
|
11
|
+
| PaymentConfirmed({orderId: @s.matches(Reventless.DcbTag.string) string, paymentId: string})
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// ─────────────────────────────────────────────────────────────
|
|
15
|
+
// InboundTranslationSlice spec — payment webhook
|
|
16
|
+
// ─────────────────────────────────────────────────────────────
|
|
17
|
+
|
|
18
|
+
module PaymentWebhookSpec = {
|
|
19
|
+
let name = "PaymentWebhook"
|
|
20
|
+
let moduleUrl: string = %raw(`import.meta.url`)
|
|
21
|
+
|
|
22
|
+
@schema
|
|
23
|
+
type externalInput = {paymentId: string, orderId: string, status: string}
|
|
24
|
+
|
|
25
|
+
@schema
|
|
26
|
+
type command = ConfirmPayment({orderId: @s.matches(Reventless.DcbTag.string) string, paymentId: string})
|
|
27
|
+
|
|
28
|
+
let targetName = "ConfirmPayment"
|
|
29
|
+
|
|
30
|
+
let translate = (input: externalInput) =>
|
|
31
|
+
switch input.status {
|
|
32
|
+
| "completed" =>
|
|
33
|
+
Ok([(input.orderId, ConfirmPayment({orderId: input.orderId, paymentId: input.paymentId}))])
|
|
34
|
+
| status => Error("Unknown payment status: " ++ status)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as S from "sury/src/S.res.mjs";
|
|
4
|
+
import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
|
|
5
|
+
|
|
6
|
+
let moduleUrl = import.meta.url;
|
|
7
|
+
|
|
8
|
+
let eventSchema = S.schema(s => ({
|
|
9
|
+
TAG: "PaymentConfirmed",
|
|
10
|
+
orderId: s.m(DcbTag$Reventless.string),
|
|
11
|
+
paymentId: s.m(S.string)
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
let OrderEventLog = {
|
|
15
|
+
moduleUrl: moduleUrl,
|
|
16
|
+
eventSchema: eventSchema
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
let moduleUrl$1 = import.meta.url;
|
|
20
|
+
|
|
21
|
+
let externalInputSchema = S.schema(s => ({
|
|
22
|
+
paymentId: s.m(S.string),
|
|
23
|
+
orderId: s.m(S.string),
|
|
24
|
+
status: s.m(S.string)
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
let commandSchema = S.schema(s => ({
|
|
28
|
+
TAG: "ConfirmPayment",
|
|
29
|
+
orderId: s.m(DcbTag$Reventless.string),
|
|
30
|
+
paymentId: s.m(S.string)
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
function translate(input) {
|
|
34
|
+
let status = input.status;
|
|
35
|
+
if (status === "completed") {
|
|
36
|
+
return {
|
|
37
|
+
TAG: "Ok",
|
|
38
|
+
_0: [[
|
|
39
|
+
input.orderId,
|
|
40
|
+
{
|
|
41
|
+
TAG: "ConfirmPayment",
|
|
42
|
+
orderId: input.orderId,
|
|
43
|
+
paymentId: input.paymentId
|
|
44
|
+
}
|
|
45
|
+
]]
|
|
46
|
+
};
|
|
47
|
+
} else {
|
|
48
|
+
return {
|
|
49
|
+
TAG: "Error",
|
|
50
|
+
_0: "Unknown payment status: " + status
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function commandAuthorization(param) {
|
|
56
|
+
return "AllowAuthenticated";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let PaymentWebhookSpec = {
|
|
60
|
+
name: "PaymentWebhook",
|
|
61
|
+
moduleUrl: moduleUrl$1,
|
|
62
|
+
externalInputSchema: externalInputSchema,
|
|
63
|
+
commandSchema: commandSchema,
|
|
64
|
+
targetName: "ConfirmPayment",
|
|
65
|
+
translate: translate,
|
|
66
|
+
commandAuthorization: commandAuthorization
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
OrderEventLog,
|
|
71
|
+
PaymentWebhookSpec,
|
|
72
|
+
}
|
|
73
|
+
/* moduleUrl Not a pure module */
|