@reventlessdev/reventless-local 3.0.0-alpha.249 → 3.0.0-alpha.250

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +13 -13
  3. package/src/BakedManifest.res +5 -6
  4. package/src/EmitCapabilities.res +3 -1
  5. package/src/LocalPlatformRegistry.res +3 -1
  6. package/src/LocalPlatformStart.res +7 -6
  7. package/src/LocalSeedTarget.res +3 -1
  8. package/src/Platform.res +291 -215
  9. package/src/ShellConfig.res +10 -17
  10. package/src/UiHints.res +8 -14
  11. package/src/UiSlots.res +10 -17
  12. package/src/adapter/Api/LocalEvents_Server.res +5 -3
  13. package/src/adapter/Api/LocalGraphQL_Adapter.res +4 -4
  14. package/src/adapter/Auth/LocalAuth.res +11 -15
  15. package/src/adapter/Auth/UserStore.res +5 -7
  16. package/src/adapter/Backend.res +1 -2
  17. package/src/adapter/CommandGenerator/CommandGeneratorResolvers_GraphQL.res +42 -26
  18. package/src/adapter/CommandGenerator/InboundTranslationResolvers_GraphQL.res +13 -3
  19. package/src/adapter/CommandTopic/LocalCommandTopicChannel.res +15 -17
  20. package/src/adapter/CommandTopic/LocalCommandTopicRemoteChannel.res +18 -22
  21. package/src/adapter/Counter/LocalCounterHandler.res +1 -1
  22. package/src/adapter/DcbEventLog/DcbEventLogStorage_InMemory.res +33 -22
  23. package/src/adapter/DcbEventLog/DcbEventLogStorage_Sqlite.res +57 -57
  24. package/src/adapter/DomainGraphQL_Server.res +35 -34
  25. package/src/adapter/DomainMCP_Server.res +45 -41
  26. package/src/adapter/EventCollector/LocalEventCollectorChannel.res +47 -36
  27. package/src/adapter/EventHistory/EventHistoryResolvers_GraphQL.res +15 -12
  28. package/src/adapter/EventLog/EventLogStorage_InMemory.res +9 -4
  29. package/src/adapter/EventLog/EventLogStorage_Sqlite.res +36 -24
  30. package/src/adapter/EventTopic/LocalEventTopicPublisher.res +9 -3
  31. package/src/adapter/Heartbeat/LocalHeartbeatRunner.res +9 -14
  32. package/src/adapter/LocalBus.res +12 -12
  33. package/src/adapter/LocalCapabilities.res.mjs +1 -1
  34. package/src/adapter/LocalGeocodeResolvers.res +1 -4
  35. package/src/adapter/LocalSideEffectHandler.res +1 -1
  36. package/src/adapter/LocalStateChangeDescriptor.res +2 -1
  37. package/src/adapter/MCP_ServerInstance.res +51 -39
  38. package/src/adapter/ObjectStore/LocalObjectStore.res +5 -2
  39. package/src/adapter/ObjectStore/ObjectStoreStorage_FileSystem.res +1 -2
  40. package/src/adapter/PlatformGraphQL_Server.res +9 -5
  41. package/src/adapter/ProjectionCheckpoint.res +8 -1
  42. package/src/adapter/ProjectionPending.res +1 -3
  43. package/src/adapter/QueryDb/LocalQueryDbStorage.res +2 -1
  44. package/src/adapter/QueryDb/QueryDbResolvers_GraphQL.res +367 -269
  45. package/src/adapter/QueryDb/QueryDbStorage_InMemory.res +5 -3
  46. package/src/adapter/QueryDb/QueryDbStorage_Sqlite.res +63 -40
  47. package/src/adapter/QueryDb/SortKey_Filter.res +14 -6
  48. package/src/adapter/Runtime/LocalAggregateRuntime_Builder.res +12 -10
  49. package/src/adapter/Runtime/LocalEventCollectorRuntime_Builder.res +8 -2
  50. package/src/adapter/Runtime/LocalPluginRuntime_Builder.res +1 -4
  51. package/src/adapter/Scheduler/LocalScheduledPublisher.res +12 -12
  52. package/src/adapter/SqliteDriver.res +16 -4
  53. package/src/adapter/Task/TaskBucket_Sqlite.res +5 -6
  54. package/src/components/Aggregate_Builder.res +6 -1
  55. package/src/components/Counter_Builder.res +1 -5
  56. package/src/components/DcbEventLog_Builder.res +5 -3
  57. package/src/components/ExtensionPoint_Builder.res +13 -15
  58. package/src/components/InboundTranslationSlice_Builder.res +3 -2
  59. package/src/components/OutboundTranslationSlice_Builder.res +3 -2
  60. package/src/components/ReadModel_Builder.res +18 -20
  61. package/src/components/StateViewSlice_Builder.res +3 -2
  62. package/src/components/Task_Builder.res +12 -13
  63. package/src/reset/LocalSeedReset.res +2 -5
  64. package/src/test/Mocks/MockDcbEventLogStorage.res +5 -1
  65. package/src/test/Mocks/MockEventLogStorage.res +8 -3
  66. package/src/test/Mocks/MockQueryDbStorage.res +3 -2
  67. package/src/test/TestRunner.res +1 -1
  68. package/tests/BakedManifestFilesTest.res +7 -10
  69. package/tests/LocalEventTapTest.res +26 -21
  70. package/tests/LocalPlatformStartTest.res +33 -28
  71. package/tests/PluginEventDecodeTest.res +3 -3
  72. package/tests/ShellConfigTest.res +30 -21
  73. package/tests/SplitApiFixtures.res +34 -10
  74. package/tests/SplitApiTest.res +92 -62
  75. package/tests/adapter/BackendParityTest.res +180 -130
  76. package/tests/adapter/CollectNEventsTest.res +6 -4
  77. package/tests/adapter/CommandAuthorizationTest.res +47 -41
  78. package/tests/adapter/CommandTopicChannelTest.res +163 -139
  79. package/tests/adapter/CounterHandlerTest.res +95 -77
  80. package/tests/adapter/DcbEventLogStorageSqliteTest.res +171 -168
  81. package/tests/adapter/DcbEventLogStorageTest.res +264 -207
  82. package/tests/adapter/DomainGraphQL_ServerTest.res +53 -43
  83. package/tests/adapter/EventCollectorChannelTest.res +153 -124
  84. package/tests/adapter/EventHistoryResolverTest.res +46 -18
  85. package/tests/adapter/EventLogSnapshotParityTest.res +57 -45
  86. package/tests/adapter/EventLogStorageSqliteTest.res +9 -10
  87. package/tests/adapter/EventTapTest.res +37 -20
  88. package/tests/adapter/EventTopicPublisherTest.res +74 -50
  89. package/tests/adapter/GraphQLSubscriptionBridgeTest.res +4 -3
  90. package/tests/adapter/GraphQL_SchemaInspectorTest.res +666 -568
  91. package/tests/adapter/GraphQL_SubscriptionResolversTest.res +105 -96
  92. package/tests/adapter/HeartbeatRunnerTest.res +99 -81
  93. package/tests/adapter/InboundTranslationMutationTest.res +4 -1
  94. package/tests/adapter/LocalAuthHttpTest.res +79 -85
  95. package/tests/adapter/LocalAuthLoginTest.res +42 -50
  96. package/tests/adapter/LocalAuthTest.res +8 -16
  97. package/tests/adapter/LocalAuthUserStoreTest.res +2 -7
  98. package/tests/adapter/LocalBusBoundedTest.res +187 -117
  99. package/tests/adapter/LocalBusPubSubTest.res +118 -76
  100. package/tests/adapter/LocalDispatchContextTest.res +1 -2
  101. package/tests/adapter/LocalEvents_ServerTest.res +242 -187
  102. package/tests/adapter/PgProjectionCatchupTest.res +44 -10
  103. package/tests/adapter/ProjectionCheckpointTest.res +261 -206
  104. package/tests/adapter/QueryDbGsiTtlTest.res +123 -83
  105. package/tests/adapter/QueryDbListPushdownParityTest.res +107 -67
  106. package/tests/adapter/QueryDbListResolverTest.res +225 -208
  107. package/tests/adapter/QueryDbResolvedFieldsTest.res +17 -14
  108. package/tests/adapter/QueryDbStorageSqliteTest.res +33 -49
  109. package/tests/adapter/QueryDbStorageTest.res +163 -117
  110. package/tests/adapter/QueryDbUnionRoundTripTest.res +8 -10
  111. package/tests/adapter/QueryEngineTest.res +179 -126
  112. package/tests/adapter/ScheduledPublisherTest.res +171 -135
  113. package/tests/adapter/ServedBucketHttpTest.res +65 -59
  114. package/tests/adapter/SortKey_FilterTest.res +19 -3
  115. package/tests/adapter/SqliteDriverTest.res +13 -10
  116. package/tests/adapter/TaskBucketTest.res +94 -80
  117. package/tests/components/aggregate/AggregateTest.res +31 -18
  118. package/tests/components/automationslice/AutomationSliceCallbackTest.res +259 -222
  119. package/tests/components/automationslice/AutomationSliceFixtures.res +4 -2
  120. package/tests/components/automationslice/AutomationSliceSelfDeadlockFixtures.res +38 -38
  121. package/tests/components/automationslice/MixedSourceAutomationSliceFixtures.res +12 -14
  122. package/tests/components/automationslice/MixedSourceAutomationSliceTest.res +8 -32
  123. package/tests/components/commandgenerator/CommandGeneratorFixtures.res +7 -5
  124. package/tests/components/commandgenerator/CommandGeneratorTest.res +40 -31
  125. package/tests/components/commandtopic/CommandTopicFixtures.res +3 -4
  126. package/tests/components/commandtopic/CommandTopicStreamFixtures.res +7 -5
  127. package/tests/components/commandtopic/CommandTopicTest.res +24 -15
  128. package/tests/components/counter/CounterFixtures.res +6 -8
  129. package/tests/components/dcb/DcbCrossPartitionFixtures.res +8 -2
  130. package/tests/components/dcb/DcbCrossPartitionReadTest.res +20 -13
  131. package/tests/components/dcb/DcbEventLogAppendStreamTest.res +12 -8
  132. package/tests/components/dcb/DcbEventLogStreamTest.res +88 -61
  133. package/tests/components/dcb/DcbFixtures.res +4 -1
  134. package/tests/components/dcb/DcbTest.res +9 -6
  135. package/tests/components/eventcollector/EventCollectorFixtures.res +0 -1
  136. package/tests/components/eventcollector/EventCollectorTest.res +6 -3
  137. package/tests/components/eventlog/EventLogAppendStreamTest.res +88 -68
  138. package/tests/components/eventlog/EventLogConflictTest.res +8 -4
  139. package/tests/components/eventlog/EventLogFixtures.res +3 -3
  140. package/tests/components/eventlog/EventLogProvisioningSeamTest.res +26 -13
  141. package/tests/components/eventlog/EventLogStreamTest.res +119 -56
  142. package/tests/components/eventlog/EventLogTest.res +20 -4
  143. package/tests/components/eventtopic/EventTopicFixtures.res +3 -3
  144. package/tests/components/eventtopic/EventTopicStreamFixtures.res +1 -2
  145. package/tests/components/eventtopic/EventTopicStreamTest.res +7 -1
  146. package/tests/components/extensionpoint/ExtensionPointFixtures.res +14 -9
  147. package/tests/components/extensionpoint/ExtensionPointTest.res +3 -2
  148. package/tests/components/heartbeat/HeartbeatFixtures.res +5 -6
  149. package/tests/components/heartbeat/HeartbeatTest.res +56 -47
  150. package/tests/components/inboundtranslationslice/InboundTranslationSliceCallbackTest.res +271 -249
  151. package/tests/components/inboundtranslationslice/InboundTranslationSliceFixtures.res +3 -2
  152. package/tests/components/outboundtranslationslice/OutboundTranslationSliceCallbackTest.res +361 -276
  153. package/tests/components/outboundtranslationslice/OutboundTranslationSliceFixtures.res +8 -10
  154. package/tests/components/outboundtranslationslice/OutboundTranslationSlicePlatformFixtures.res +37 -43
  155. package/tests/components/querydb/QueryDbFixtures.res +1 -5
  156. package/tests/components/querydb/QueryDbTest.res +2 -4
  157. package/tests/components/readmodel/DcbReadModelE2EFixtures.res +15 -18
  158. package/tests/components/readmodel/MixedSourceReadModelFixtures.res +5 -7
  159. package/tests/components/readmodel/ReadModelFixtures.res +8 -8
  160. package/tests/components/scheduler/SchedulerTest.res +76 -58
  161. package/tests/components/sideeffecthandler/SideEffectHandlerFixtures.res +4 -4
  162. package/tests/components/stateviewslice/StateViewSliceDisplayNameFixtures.res +5 -7
  163. package/tests/components/stateviewslice/StateViewSliceFixtures.res +8 -6
  164. package/tests/components/stateviewslice/StateViewSliceSubIdFixtures.res +17 -11
  165. package/tests/components/stateviewslice/StateViewSliceSubIdTest.res +12 -2
  166. package/tests/components/task/TaskFixtures.res +5 -5
  167. package/tests/components/task/TaskTest.res +95 -80
  168. package/tests/plugin/PluginsProjection_GWT.res +3 -1
  169. package/tests/plugin/UiFragments_GWT.res +6 -1
  170. package/tests/reset/LocalSeedResetTest.res +1 -0
@@ -20,93 +20,135 @@ let defaultMeta: Reventless.Message.meta = {
20
20
 
21
21
  describe("LocalBus PubSub (Phase F)", () => {
22
22
  describe("publishEvent timing", () => {
23
- testPromise("resolves after exactly 2 microtask ticks", async () => {
24
- module TestBus = LocalBus.Make()
25
- let delivered = ref(false)
26
- TestBus.subscribeToEvents("T", async (_, _, _) => {
27
- delivered := true
28
- })
29
- // Start publishEvent without awaiting — drive manually tick by tick.
30
- let pubPromise = TestBus.publishEvent("T", "svc", defaultMeta, JSON.parseOrThrow("{}"))
31
- // Tick 0: publish is synchronous; drain fiber hasn't run yet.
32
- expect(delivered.contents)->toBe(false)
33
- // Tick 1: Effect scheduler runs drain fiber; handler sets delivered.
34
- let _ = await Promise.resolve()
35
- // Tick 2: allDone Deferred resolves; pubPromise completes.
36
- let _ = await Promise.resolve()
37
- let _ = await pubPromise
38
- expect(delivered.contents)->toBe(true)
39
- })
23
+ testPromise(
24
+ "resolves after exactly 2 microtask ticks",
25
+ async () => {
26
+ module TestBus = LocalBus.Make()
27
+ let delivered = ref(false)
28
+ TestBus.subscribeToEvents(
29
+ "T",
30
+ async (_, _, _) => {
31
+ delivered := true
32
+ },
33
+ )
34
+ // Start publishEvent without awaiting — drive manually tick by tick.
35
+ let pubPromise = TestBus.publishEvent("T", "svc", defaultMeta, JSON.parseOrThrow("{}"))
36
+ // Tick 0: publish is synchronous; drain fiber hasn't run yet.
37
+ expect(delivered.contents)->toBe(false)
38
+ // Tick 1: Effect scheduler runs drain fiber; handler sets delivered.
39
+ let _ = await Promise.resolve()
40
+ // Tick 2: allDone Deferred resolves; pubPromise completes.
41
+ let _ = await Promise.resolve()
42
+ let _ = await pubPromise
43
+ expect(delivered.contents)->toBe(true)
44
+ },
45
+ )
40
46
 
41
- testPromise("publishEvent with no subscribers returns immediately", async () => {
42
- module TestBus = LocalBus.Make()
43
- // No subscribers registered — should not hang.
44
- await TestBus.publishEvent("empty-topic", "svc", defaultMeta, JSON.Null)
45
- // If we reach here the test passes (no timeout/hang).
46
- })
47
+ testPromise(
48
+ "publishEvent with no subscribers returns immediately",
49
+ async () => {
50
+ module TestBus = LocalBus.Make()
51
+ // No subscribers registered should not hang.
52
+ await TestBus.publishEvent("empty-topic", "svc", defaultMeta, JSON.Null)
53
+ // If we reach here the test passes (no timeout/hang).
54
+ },
55
+ )
47
56
  })
48
57
 
49
58
  describe("fan-out", () => {
50
- testPromise("delivers to all subscribers on the same topic", async () => {
51
- module TestBus = LocalBus.Make()
52
- let count = ref(0)
53
- TestBus.subscribeToEvents("T", async (_, _, _) => {
54
- count := count.contents + 1
55
- })
56
- TestBus.subscribeToEvents("T", async (_, _, _) => {
57
- count := count.contents + 1
58
- })
59
- TestBus.subscribeToEvents("T", async (_, _, _) => {
60
- count := count.contents + 1
61
- })
62
- let _ = await TestBus.publishEvent("T", "svc", defaultMeta, JSON.parseOrThrow("{}"))
63
- expect(count.contents)->toBe(3)
64
- })
59
+ testPromise(
60
+ "delivers to all subscribers on the same topic",
61
+ async () => {
62
+ module TestBus = LocalBus.Make()
63
+ let count = ref(0)
64
+ TestBus.subscribeToEvents(
65
+ "T",
66
+ async (_, _, _) => {
67
+ count := count.contents + 1
68
+ },
69
+ )
70
+ TestBus.subscribeToEvents(
71
+ "T",
72
+ async (_, _, _) => {
73
+ count := count.contents + 1
74
+ },
75
+ )
76
+ TestBus.subscribeToEvents(
77
+ "T",
78
+ async (_, _, _) => {
79
+ count := count.contents + 1
80
+ },
81
+ )
82
+ let _ = await TestBus.publishEvent("T", "svc", defaultMeta, JSON.parseOrThrow("{}"))
83
+ expect(count.contents)->toBe(3)
84
+ },
85
+ )
65
86
 
66
- testPromise("publishing to topic-a does not reach topic-b subscribers", async () => {
67
- module TestBus = LocalBus.Make()
68
- let countA = ref(0)
69
- let countB = ref(0)
70
- TestBus.subscribeToEvents("topic-a", async (_, _, _) => {
71
- countA := countA.contents + 1
72
- })
73
- TestBus.subscribeToEvents("topic-b", async (_, _, _) => {
74
- countB := countB.contents + 1
75
- })
76
- let _ = await TestBus.publishEvent("topic-a", "svc", defaultMeta, JSON.Null)
77
- expect(countA.contents)->toBe(1)
78
- expect(countB.contents)->toBe(0)
79
- })
87
+ testPromise(
88
+ "publishing to topic-a does not reach topic-b subscribers",
89
+ async () => {
90
+ module TestBus = LocalBus.Make()
91
+ let countA = ref(0)
92
+ let countB = ref(0)
93
+ TestBus.subscribeToEvents(
94
+ "topic-a",
95
+ async (_, _, _) => {
96
+ countA := countA.contents + 1
97
+ },
98
+ )
99
+ TestBus.subscribeToEvents(
100
+ "topic-b",
101
+ async (_, _, _) => {
102
+ countB := countB.contents + 1
103
+ },
104
+ )
105
+ let _ = await TestBus.publishEvent("topic-a", "svc", defaultMeta, JSON.Null)
106
+ expect(countA.contents)->toBe(1)
107
+ expect(countB.contents)->toBe(0)
108
+ },
109
+ )
80
110
  })
81
111
 
82
112
  // A5: a throwing/rejecting subscriber must not (a) hang publishEvent (its
83
113
  // done_ countdown never reaching zero) nor (b) kill the drain fiber so the
84
114
  // topic stops working. If either regressed, these tests would time out.
85
115
  describe("failing subscriber", () => {
86
- testPromise("a throwing subscriber does not hang publish; healthy siblings still receive it", async () => {
87
- module TestBus = LocalBus.Make()
88
- let healthy = ref(0)
89
- TestBus.subscribeToEvents("T", async (_, _, _) => JsError.throwWithMessage("boom"))
90
- TestBus.subscribeToEvents("T", async (_, _, _) => {
91
- healthy := healthy.contents + 1
92
- })
93
- // Must resolve — not hang — even though one subscriber threw.
94
- await TestBus.publishEvent("T", "svc", defaultMeta, JSON.Null)
95
- expect(healthy.contents)->toBe(1)
96
- })
116
+ testPromise(
117
+ "a throwing subscriber does not hang publish; healthy siblings still receive it",
118
+ async () => {
119
+ module TestBus = LocalBus.Make()
120
+ let healthy = ref(0)
121
+ TestBus.subscribeToEvents("T", async (_, _, _) => JsError.throwWithMessage("boom"))
122
+ TestBus.subscribeToEvents(
123
+ "T",
124
+ async (_, _, _) => {
125
+ healthy := healthy.contents + 1
126
+ },
127
+ )
128
+ // Must resolve — not hang — even though one subscriber threw.
129
+ await TestBus.publishEvent("T", "svc", defaultMeta, JSON.Null)
130
+ expect(healthy.contents)->toBe(1)
131
+ },
132
+ )
97
133
 
98
- testPromise("the topic keeps working after a subscriber throws (drain fiber survives)", async () => {
99
- module TestBus = LocalBus.Make()
100
- let healthy = ref(0)
101
- TestBus.subscribeToEvents("T", async (_, _, _) => JsError.throwWithMessage("boom"))
102
- TestBus.subscribeToEvents("T", async (_, _, _) => {
103
- healthy := healthy.contents + 1
104
- })
105
- await TestBus.publishEvent("T", "svc", defaultMeta, JSON.Null)
106
- // Second publish on the same topic must also complete and be delivered —
107
- // proving the dead-fiber cascade is gone.
108
- await TestBus.publishEvent("T", "svc", defaultMeta, JSON.Null)
109
- expect(healthy.contents)->toBe(2)
110
- })
134
+ testPromise(
135
+ "the topic keeps working after a subscriber throws (drain fiber survives)",
136
+ async () => {
137
+ module TestBus = LocalBus.Make()
138
+ let healthy = ref(0)
139
+ TestBus.subscribeToEvents("T", async (_, _, _) => JsError.throwWithMessage("boom"))
140
+ TestBus.subscribeToEvents(
141
+ "T",
142
+ async (_, _, _) => {
143
+ healthy := healthy.contents + 1
144
+ },
145
+ )
146
+ await TestBus.publishEvent("T", "svc", defaultMeta, JSON.Null)
147
+ // Second publish on the same topic must also complete and be delivered —
148
+ // proving the dead-fiber cascade is gone.
149
+ await TestBus.publishEvent("T", "svc", defaultMeta, JSON.Null)
150
+ expect(healthy.contents)->toBe(2)
151
+ },
152
+ )
111
153
  })
112
154
  })
@@ -16,8 +16,7 @@ let _ = TestRunner.setup()
16
16
 
17
17
  // Hand the provided context back as the handler's result — the assertions then
18
18
  // see exactly what an application handler would.
19
- let capture = (_event, _ctx) =>
20
- Effect.serviceWith(ReventlessCore.RequestContext.tag, ctx => ctx)
19
+ let capture = (_event, _ctx) => Effect.serviceWith(ReventlessCore.RequestContext.tag, ctx => ctx)
21
20
 
22
21
  let comp = "EventCollector(TestCollector)"
23
22