@reventlessdev/reventless-core 3.0.0-alpha.260 → 3.0.0-alpha.262

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 (208) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/package.json +10 -10
  3. package/src/Behavior.res +1 -4
  4. package/src/Message.res +17 -14
  5. package/src/Projection.res +51 -25
  6. package/src/RequestContext.res +8 -9
  7. package/src/ResourceAttribution.res +28 -14
  8. package/src/adapter/Adapter.res +48 -4
  9. package/src/adapter/EventLogProvisioning/EventLogProvisioning.res +5 -5
  10. package/src/adapter/Messaging/Messaging_Log_Backend.res +10 -7
  11. package/src/adapter/Messaging/Messaging_Log_Backend.res.mjs +2 -4
  12. package/src/adapter/Monitoring/Monitoring.res +16 -17
  13. package/src/adapter/QueryInterception/QueryInterception.res +0 -1
  14. package/src/adapter/Runtime/AggregateRuntime_Builder_Common.res +12 -5
  15. package/src/adapter/Runtime/EventCollectorRuntime_Builder_Single.res +11 -7
  16. package/src/adapter/Runtime/PluginRuntime_Builder_Micro.res +1 -7
  17. package/src/adapter/Runtime/PluginRuntime_Builder_Single.res +1 -7
  18. package/src/adapter/RuntimeExtension/RuntimeExtension.res +0 -1
  19. package/src/adapter/Secrets/Secrets_Node_Backend.res +60 -0
  20. package/src/adapter/Secrets/Secrets_Node_Backend.res.mjs +69 -0
  21. package/src/admin/Platform_Admin.res +17 -6
  22. package/src/admin/Platform_AdminApi.res +14 -9
  23. package/src/admin/Platform_Admin_Callback.res +1 -1
  24. package/src/admin/Platform_BakedManifest.res +34 -34
  25. package/src/admin/Platform_ComponentDefinitionsApi.res +9 -21
  26. package/src/admin/Platform_PluginStructuresApi.res +15 -12
  27. package/src/admin/UiFragmentRegistry/StateChange/UiFragmentRegistry.res +1 -1
  28. package/src/components/Aggregate/Aggregate.res +13 -12
  29. package/src/components/Aggregate/Aggregate_Builder.res +22 -21
  30. package/src/components/Aggregate/Aggregate_Callback.res +91 -86
  31. package/src/components/Api/ApiNoApiHelpers.res +1 -3
  32. package/src/components/Api/Api_Ids.res +0 -1
  33. package/src/components/Api/Api_Naming.res +41 -18
  34. package/src/components/Api/GraphQL_FragmentGenerator.res +38 -51
  35. package/src/components/Api/GraphQL_SchemaInspector.res +5 -3
  36. package/src/components/Api/GraphQL_Stitcher.res +9 -10
  37. package/src/components/Api/MCP_SchemaGenerator.res +8 -12
  38. package/src/components/Api/OwnerScopeDiagnostics.res +1 -2
  39. package/src/components/Api/QueryDbListQuery.res +13 -6
  40. package/src/components/Api/SchemaType.res +28 -23
  41. package/src/components/Api/SuryToJsonSchema.res +9 -10
  42. package/src/components/AutomationSlice/AutomationSlice.res +4 -4
  43. package/src/components/AutomationSlice/AutomationSlice_Builder.res +15 -14
  44. package/src/components/AutomationSlice/AutomationSlice_Callback.res +3 -3
  45. package/src/components/Builder_Helpers.res +12 -23
  46. package/src/components/CommandGenerator/CommandGenerator.res +6 -1
  47. package/src/components/CommandGenerator/CommandGenerator_Builder.res +29 -21
  48. package/src/components/CommandGenerator/CommandGenerator_Callback.res +17 -21
  49. package/src/components/CommandTopic/CommandTopic.res +3 -3
  50. package/src/components/CommandTopic/CommandTopic_Builder.res +10 -10
  51. package/src/components/CommandTopic/CommandTopic_Callback.res +1 -4
  52. package/src/components/CommandTopic/CommandTopic_Helpers.res +1 -2
  53. package/src/components/Counter/Counter_Builder.res +1 -6
  54. package/src/components/Counter/Counter_Callback.res +3 -3
  55. package/src/components/Dcb/Dcb_Builder.res +970 -956
  56. package/src/components/DcbEventLog/DcbEventLog.res +4 -4
  57. package/src/components/DcbEventLog/DcbEventLog_Builder.res +0 -1
  58. package/src/components/DcbEventLog/DcbEventLog_Operations.res +17 -18
  59. package/src/components/EventCollector/EventCollector_Builder.res +2 -1
  60. package/src/components/EventLog/EventLog.res +5 -1
  61. package/src/components/EventLog/EventLog_Operations.res +12 -8
  62. package/src/components/EventMapper/EventMapper.res +8 -10
  63. package/src/components/EventMapper/EventMapper_Builder.res +4 -1
  64. package/src/components/EventMapper/EventMapper_Callback.res +46 -31
  65. package/src/components/EventTopic/EventTopic.res +3 -3
  66. package/src/components/EventTopic/EventTopic_Builder.res +1 -1
  67. package/src/components/Extension/Extension.res +4 -1
  68. package/src/components/Extension/Extension_Operations.res +11 -3
  69. package/src/components/ExtensionPoint/ExtensionPoint.res +3 -3
  70. package/src/components/ExtensionPoint/ExtensionPoint_Builder.res +9 -10
  71. package/src/components/ExtensionPoint/ExtensionPoint_Callback.res +2 -6
  72. package/src/components/ExtensionPoint/ExtensionPoint_Operations.res +13 -5
  73. package/src/components/Heartbeat/Heartbeat_Callback.res +3 -3
  74. package/src/components/InboundTranslationSlice/InboundTranslationSlice.res +4 -4
  75. package/src/components/InboundTranslationSlice/InboundTranslationSlice_Builder.res +7 -10
  76. package/src/components/OutboundTranslationSlice/OutboundTranslationSlice.res +4 -4
  77. package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Builder.res +15 -14
  78. package/src/components/QueryDb/QueryDb_Adapter.res +1 -3
  79. package/src/components/QueryDb/QueryDb_Operations.res +10 -10
  80. package/src/components/ReadModel/ReadModel.res +3 -3
  81. package/src/components/ReadModel/ReadModel_Builder.res +1 -2
  82. package/src/components/ReadModel/ReadModel_Callback.res +2 -1
  83. package/src/components/SideEffectHandler/SideEffectHandler_Callback.res +5 -2
  84. package/src/components/StateChangeSlice/StateChangeSlice.res +3 -3
  85. package/src/components/StateChangeSlice/StateChangeSlice_Builder.res +23 -4
  86. package/src/components/StateChangeSlice/StateChangeSlice_Callback.res +22 -6
  87. package/src/components/StateTopic.res +1 -3
  88. package/src/components/StateViewSlice/StateViewSlice.res +4 -4
  89. package/src/components/StateViewSlice/StateViewSlice_Builder.res +79 -68
  90. package/src/components/StateViewSlice/StateViewSlice_Callback.res +3 -1
  91. package/src/components/Task/Task.res +3 -3
  92. package/src/components/Task/Task_Adapter.res +4 -1
  93. package/src/components/Task/Task_Builder.res +24 -21
  94. package/src/plugin/api/PluginBaseFragment.res +9 -3
  95. package/src/plugin/component/Capability_Inference.res +8 -10
  96. package/src/plugin/component/Plugin.res +6 -6
  97. package/src/plugin/component/Plugin_Builder.res +54 -50
  98. package/src/plugin/component/Plugin_Callback.res +10 -6
  99. package/src/plugin/component/Plugin_Helpers.res +264 -230
  100. package/src/plugin/component/Plugin_Structure.res +370 -324
  101. package/src/plugin/component/Plugin_SubscriptionSchema.res +8 -6
  102. package/src/plugin/component/SchemaWalker.res +11 -12
  103. package/src/plugin/connect/PluginConnectExtension_Mapping.res +45 -50
  104. package/src/plugin/lifecycle/PluginBehavior.res +3 -4
  105. package/src/plugin/lifecycle/PluginSpec.res +1 -2
  106. package/src/plugin/lifecycle/PluginsProjection.res +16 -5
  107. package/src/plugin/lifecycle/PluginsReadModelSpec.res +0 -2
  108. package/src/util/CommandPublisher.res +9 -2
  109. package/src/util/CsvStream.res +3 -3
  110. package/src/util/Interstack.res +7 -15
  111. package/src/util/Interstack.resi +3 -3
  112. package/src/util/LogFormat.res +5 -9
  113. package/src/util/Logger.res +1 -2
  114. package/src/util/Lru.res +2 -1
  115. package/src/util/Lru.resi +2 -3
  116. package/src/util/ScheduleOps.res +24 -27
  117. package/src/util/StorePrefixCollision.res +6 -9
  118. package/src/util/Util_Promise.res +4 -1
  119. package/src/util/Util_Promise.res.mjs +1 -1
  120. package/tests/IdentityTest.res +166 -113
  121. package/tests/ResourceAttributionTest.res +28 -25
  122. package/tests/Secrets_Node_BackendTest.res +141 -0
  123. package/tests/Secrets_Node_BackendTest.res.mjs +152 -0
  124. package/tests/StorePrefixCollisionTest.res +2 -1
  125. package/tests/TaskBucketNamingTest.res +3 -2
  126. package/tests/adapter/EventLogProvisioningTest.res +51 -48
  127. package/tests/adapter/MonitoringTest.res +81 -38
  128. package/tests/adapter/QueryInterceptionTest.res +2 -2
  129. package/tests/adapter/RefusalVocabularyTest.res +31 -23
  130. package/tests/adapter/RuntimeExtensionHookReachTest.res +9 -8
  131. package/tests/adapter/RuntimeExtensionTest.res +5 -3
  132. package/tests/admin/AdminApiSchemaDriftTest.res +22 -16
  133. package/tests/admin/Platform_Admin_StructureTest.res +22 -14
  134. package/tests/admin/Platform_Admin_StructureTest.res.mjs +4 -3
  135. package/tests/admin/Platform_BakedManifestTest.res +31 -35
  136. package/tests/admin/Platform_ComponentDefinitionsApiTest.res +18 -15
  137. package/tests/admin/Platform_PluginStructuresApiTest.res +5 -3
  138. package/tests/admin/Platform_UIFragmentsApiTest.res +6 -3
  139. package/tests/aggregate/AggregateCacheTest.res +10 -12
  140. package/tests/aggregate/AggregateCallbackTest.res +75 -46
  141. package/tests/aggregate/AggregateCausationTest.res +19 -20
  142. package/tests/aggregate/AggregateConflictTest.res +41 -19
  143. package/tests/aggregate/AggregateFixtures.res +15 -5
  144. package/tests/aggregate/AggregateRejectionTest.res +97 -80
  145. package/tests/aggregate/AggregateSnapshotTest.res +44 -16
  146. package/tests/api/Api_IdsTest.res +10 -4
  147. package/tests/api/BrandedMarkerCompositionTest.res +48 -36
  148. package/tests/api/GeolocationSemanticTest.res +3 -3
  149. package/tests/api/GraphQL_FragmentGeneratorTest.res +66 -54
  150. package/tests/api/OwnerScopeDiagnosticsTest.res +31 -27
  151. package/tests/api/StorageRefFieldsTest.res +30 -18
  152. package/tests/api/SuryToJsonSchemaTest.res +1315 -1014
  153. package/tests/api/TaggedUnionSchemaTest.res +17 -24
  154. package/tests/commandgenerator/CommandGeneratorCallbackTest.res +235 -179
  155. package/tests/commandgenerator/CommandGeneratorFixtures.res +8 -13
  156. package/tests/commandgenerator/OwnerStampingTest.res +91 -76
  157. package/tests/commandtopic/CommandOutcomeHookTest.res +198 -155
  158. package/tests/commandtopic/CommandTopicCallbackFixtures.res +5 -4
  159. package/tests/commandtopic/CommandTopicCallbackTest.res +61 -43
  160. package/tests/commandtopic/CommandTopicHelpersRejectionTest.res +70 -55
  161. package/tests/counter/CounterCallbackTest.res +40 -34
  162. package/tests/counter/CounterFixtures.res +4 -4
  163. package/tests/dcb/DcbDecodeTest.res +115 -84
  164. package/tests/dcb/DcbEventLogOperationsTest.res +194 -143
  165. package/tests/dcb/DcbEventLogSchemaTest.res +13 -13
  166. package/tests/dcb/DcbFixtures.res +4 -5
  167. package/tests/dcb/DcbScopeInferenceTest.res +173 -114
  168. package/tests/dcb/DcbStateChangeSliceTest.res +391 -262
  169. package/tests/dcb/DcbTagTest.res +22 -11
  170. package/tests/dcb/DcbValidationTest.res +288 -218
  171. package/tests/eventlog/EventLogFixtures.res +4 -4
  172. package/tests/eventlog/EventLogOperationsTest.res +102 -67
  173. package/tests/eventlog/EventLogRetryTest.res +104 -65
  174. package/tests/eventmapper/EventMapperCallbackTest.res +118 -83
  175. package/tests/eventmapper/EventMapperFixtures.res +15 -23
  176. package/tests/eventmapper/EventMapperTest.res +54 -38
  177. package/tests/eventtopic/EventTopicFixtures.res +3 -4
  178. package/tests/eventtopic/EventTopicOperationsTest.res +41 -29
  179. package/tests/extensionpoint/ExtensionPointCallbackTest.res +58 -45
  180. package/tests/extensionpoint/ExtensionPointFixtures.res +16 -20
  181. package/tests/extensionpoint/ExtensionPointOperationsTest.res +70 -49
  182. package/tests/extensionpoint/PluginDisconnectScheduleTest.res +2 -1
  183. package/tests/logger/LogFormatTest.res +104 -82
  184. package/tests/logger/LoggerLazyTest.res +21 -12
  185. package/tests/message/MessageTest.res +96 -93
  186. package/tests/message/MetaEnvelopeTest.res +26 -30
  187. package/tests/plugin/HeartbeatDisconnectGraceTest.res +31 -25
  188. package/tests/plugin/ManifestVisibilityTest.res +20 -12
  189. package/tests/plugin/PluginDefinitionScalars.res +1 -2
  190. package/tests/plugin/PluginLifecycleCorpusTest.res +15 -12
  191. package/tests/plugin/PluginSpecExperiment.res +0 -1
  192. package/tests/plugin/PluginStructureTest.res +1529 -1045
  193. package/tests/plugin/Plugin_EventQuerySchemaTest.res +21 -10
  194. package/tests/plugin/SchemaWalkerTest.res +116 -70
  195. package/tests/plugin/StateChange/PsReserveStock.res +4 -4
  196. package/tests/plugin/StateView/PsAnnotatedView.res +4 -4
  197. package/tests/plugin/StateView/PsCustomersView.res +4 -4
  198. package/tests/plugin/StateView/PsShipmentsView.res +3 -2
  199. package/tests/projection/LifecycleTrailTest.res +1 -4
  200. package/tests/projection/ProjectionOptimizeTest.res +13 -9
  201. package/tests/querydb/QueryDbFixtures.res +0 -1
  202. package/tests/querydb/QueryDbOperationsTest.res +99 -64
  203. package/tests/querydb/TaggedUnionStampTest.res +10 -8
  204. package/tests/sideeffecthandler/SideEffectHandlerCallbackTest.res +50 -35
  205. package/tests/sideeffecthandler/SideEffectHandlerFixtures.res +4 -10
  206. package/tests/util/CommandPublisherTest.res +0 -1
  207. package/tests/util/CsvStreamTest.res +3 -3
  208. package/tests/util/LruTest.res +84 -56
@@ -14,9 +14,9 @@ type appendStream = ReventlessInfra.DcbEventLog.appendStream
14
14
  type operations = ReventlessInfra.DcbEventLog.operations
15
15
  type component = ReventlessInfra.DcbEventLog.component
16
16
 
17
- let toResolvedOutputs = (
18
- outputs: outputs,
19
- ): Pulumi.Output.t<ReventlessInterop.DcbEventLog.resolvedOutputs> =>
17
+ let toResolvedOutputs = (outputs: outputs): Pulumi.Output.t<
18
+ ReventlessInterop.DcbEventLog.resolvedOutputs,
19
+ > =>
20
20
  (
21
21
  outputs.resources->Adapter.resourcesToInterop,
22
22
  outputs.eventTopic.resources->Adapter.resourcesToInterop,
@@ -24,7 +24,7 @@ let toResolvedOutputs = (
24
24
  ->Pulumi.Output.all2
25
25
  ->Pulumi.Output.apply(((resources, eventTopicResources)) => {
26
26
  let resolved: ReventlessInterop.DcbEventLog.resolvedOutputs = {
27
- resources: resources,
27
+ resources,
28
28
  eventTopic: {resources: eventTopicResources},
29
29
  }
30
30
  resolved
@@ -2,7 +2,6 @@ module Make = (
2
2
  Storage: DcbEventLog_Adapter.Storage,
3
3
  EventTopicPublisher: EventTopic_Adapter.Publisher,
4
4
  ): DcbEventLog.T => {
5
-
6
5
  // DcbEventLog uses a generic JSON event topic (no typed event schema needed)
7
6
  module EventTopicSpec = {
8
7
  module Id = Reventless.Id.String
@@ -35,12 +35,13 @@ module Make = (Ops: Ops): T => {
35
35
  | None => Message.generateMeta(~service=serviceName)
36
36
  }
37
37
 
38
- let rawEventsJson = rawEvents->Array.map(rawEvent =>
39
- Message.combineMessage(
40
- rawEvent.eventType,
41
- rawEvent.data->JSON.Decode.object->Option.getOr(Dict.make()),
38
+ let rawEventsJson =
39
+ rawEvents->Array.map(rawEvent =>
40
+ Message.combineMessage(
41
+ rawEvent.eventType,
42
+ rawEvent.data->JSON.Decode.object->Option.getOr(Dict.make()),
43
+ )
42
44
  )
43
- )
44
45
 
45
46
  // Run beforePublish hook — if it throws, log the error and publish original events.
46
47
  let finalRawEventsJson = switch EventPublish_Callback.beforePublishHook.contents {
@@ -75,13 +76,15 @@ module Make = (Ops: Ops): T => {
75
76
  let recordedAt = Message.nowAsISOString()
76
77
  let _ = await Array.zip(rawEvents, finalRawEventsJson)
77
78
  ->Array.map(async ((rawEvent, eventJson)) => {
78
- let entityId =
79
- rawEvent.tags->Array.get(0)->Option.map(t => t.value)->Option.getOr(name)
79
+ let entityId = rawEvent.tags->Array.get(0)->Option.map(t => t.value)->Option.getOr(name)
80
80
  let eventJson' = Message.composeEventJson'(entityId, rawEvent.meta, ~recordedAt, eventJson)
81
81
  try await Ops.publishJson(serviceName, rawEvent.meta, eventJson') catch {
82
82
  | JsExn(err) =>
83
83
  let errMsg = err->JsExn.message->Option.getOr("unknown")
84
- EffectLogger.logError(~comp=`DcbEventLog(${name})`, `EventTopic.publish Error: ${errMsg}`)->Effect.runSync
84
+ EffectLogger.logError(
85
+ ~comp=`DcbEventLog(${name})`,
86
+ `EventTopic.publish Error: ${errMsg}`,
87
+ )->Effect.runSync
85
88
  }
86
89
  })
87
90
  ->Promise.all
@@ -114,10 +117,7 @@ module Make = (Ops: Ops): T => {
114
117
  }
115
118
  }
116
119
 
117
- let append: DcbEventLog.append = async (
118
- rawEvents,
119
- ~condition=?,
120
- ) => {
120
+ let append: DcbEventLog.append = async (rawEvents, ~condition=?) => {
121
121
  // Normalise `meta.service` to the DcbEventLog's serviceName on every event
122
122
  // before BOTH storage append and SNS publish. EventCollector dispatch (via
123
123
  // Plugin_Callback.handleJsonEvents) keys on `meta.service`, and the catalog
@@ -140,10 +140,7 @@ module Make = (Ops: Ops): T => {
140
140
  }
141
141
  }
142
142
 
143
- let read: DcbEventLog.read = async (
144
- ~query,
145
- ~after=?,
146
- ) => {
143
+ let read: DcbEventLog.read = async (~query, ~after=?) => {
147
144
  let rawResult = await Ops.storage.read(~query, ~after?)
148
145
  // Adapter rawSequencedEvent is structurally identical to infra rawSequencedEvent
149
146
  let events: array<DcbEventLog.rawSequencedEvent> = rawResult.events->Obj.magic
@@ -155,14 +152,16 @@ module Make = (Ops: Ops): T => {
155
152
  }
156
153
 
157
154
  let readStream: DcbEventLog.readStream = (~query, ~after=?, ~strongConsistency=?) =>
158
- Ops.storage.readStream(~query, ~after?, ~strongConsistency?)->Stream.map(raw => (raw->Obj.magic: DcbEventLog.rawSequencedEvent))
155
+ Ops.storage.readStream(~query, ~after?, ~strongConsistency?)->Stream.map((
156
+ raw
157
+ ): DcbEventLog.rawSequencedEvent => raw->Obj.magic)
159
158
 
160
159
  // Streaming append — collects the stream into an array, then makes a single
161
160
  // storage.append call to preserve atomicity of the condition check.
162
161
  // Does not publish to EventTopic (use case: migration / bulk seeding).
163
162
  let appendStream: DcbEventLog.appendStream = (stream, ~condition=?) =>
164
163
  stream
165
- ->Stream.map(rawEvent => (rawEvent->Obj.magic: DcbEventLog_Adapter.rawStoredEvent))
164
+ ->Stream.map((rawEvent): DcbEventLog_Adapter.rawStoredEvent => rawEvent->Obj.magic)
166
165
  ->Stream.runCollect
167
166
  ->Effect.flatMap(rawEvents => Effect.promise(() => Ops.storage.append(rawEvents, ~condition?)))
168
167
  }
@@ -15,7 +15,8 @@ let makeStreamHandler = (
15
15
  )
16
16
  ->jsonEventsHandler
17
17
 
18
- let channel: EventCollector_Adapter.channel<_, _, _> = eventCollector->EventCollector_Adapter.channel
18
+ let channel: EventCollector_Adapter.channel<_, _, _> =
19
+ eventCollector->EventCollector_Adapter.channel
19
20
  channel.handleChannelEvent(jsonHandler)
20
21
  }
21
22
 
@@ -33,7 +33,11 @@ type replay<'id, 'event> = 'id => promise<array<'event>>
33
33
  // `fromSeq` starts the replay at that sequence number (inclusive; default 0) —
34
34
  // the delta read after seeding from a snapshot at seqNr = fromSeq.
35
35
  type replayStream<'id, 'event> = ('id, ~fromSeq: int=?) => Stream.t<'event, string, unit>
36
- type appendStream<'id, 'event> = (int, 'id, Stream.t<'event, string, unit>) => Effect.t<unit, string, unit>
36
+ type appendStream<'id, 'event> = (
37
+ int,
38
+ 'id,
39
+ Stream.t<'event, string, unit>,
40
+ ) => Effect.t<unit, string, unit>
37
41
  // Keep-one semantics: `writeSnapshot` overwrites the single snapshot per
38
42
  // aggregate; recovery from a corrupt snapshot is full replay, not older
39
43
  // snapshots. Failures are plain strings — a snapshot op failure must never
@@ -134,8 +134,9 @@ module Make = (Spec: ReventlessInfra.EventLog.T, Ops: Ops with module Spec = Spe
134
134
  // result (no Cause stringification / substring matching).
135
135
  let storageEffect =
136
136
  Effect.tryPromise(
137
- ~catch=(err: unknown) =>
138
- EventLog.StorageFailure(Util.Error.messageFromUnknown(err, "storage error")),
137
+ ~catch=(err: unknown) => EventLog.StorageFailure(
138
+ Util.Error.messageFromUnknown(err, "storage error"),
139
+ ),
139
140
  () => Ops.storage.append(sequenceNr, idStr, eventsJson),
140
141
  )
141
142
  ->Effect.flatMap(result =>
@@ -149,12 +150,16 @@ module Make = (Spec: ReventlessInfra.EventLog.T, Ops: Ops with module Spec = Spe
149
150
  ->Effect.catchAll(e => Effect.succeed(Error(e)))
150
151
  switch await storageEffect->Effect.runPromise {
151
152
  | Ok() =>
152
- (await publishToEventTopic(id, events', eventsJson))->Result.mapError(msg => EventLog.StorageFailure(
153
- msg,
154
- ))
153
+ (
154
+ await publishToEventTopic(id, events', eventsJson)
155
+ )->Result.mapError(msg => EventLog.StorageFailure(msg))
155
156
  | Error(EventLog.Conflict) => Error(EventLog.Conflict)
156
157
  | Error(StorageFailure(msg)) =>
157
- Error(EventLog.StorageFailure(`EventLog: Error: Couldn't append for ${Spec.name}(${idStr}): ${msg}`))
158
+ Error(
159
+ EventLog.StorageFailure(
160
+ `EventLog: Error: Couldn't append for ${Spec.name}(${idStr}): ${msg}`,
161
+ ),
162
+ )
158
163
  }
159
164
  }
160
165
 
@@ -190,8 +195,7 @@ module Make = (Spec: ReventlessInfra.EventLog.T, Ops: Ops with module Spec = Spe
190
195
  // Lazy streaming replay — wraps decodeEvent in Effect.sync so thrown exceptions
191
196
  // surface through the stream's error channel rather than as unhandled exceptions.
192
197
  let replayStream = (id, ~fromSeq=?) =>
193
- Ops.storage.replayStream(id->Spec.Id.toString, ~fromSeq=?fromSeq)
194
- ->Stream.mapEffect(json =>
198
+ Ops.storage.replayStream(id->Spec.Id.toString, ~fromSeq?)->Stream.mapEffect(json =>
195
199
  Effect.sync(() => decodeEvent(id->Spec.Id.toString, json))
196
200
  )
197
201
 
@@ -20,9 +20,9 @@ module type T = {
20
20
  ) => component
21
21
  }
22
22
 
23
- let toResolvedOutputs = (
24
- outputs: outputs,
25
- ): Pulumi.Output.t<ReventlessInterop.EventMapper.resolvedOutputs> => {
23
+ let toResolvedOutputs = (outputs: outputs): Pulumi.Output.t<
24
+ ReventlessInterop.EventMapper.resolvedOutputs,
25
+ > => {
26
26
  let eventCollectorOutput =
27
27
  outputs.eventCollector->Pulumi.Output.flatMap((ec: ReventlessEventCollector.outputs) =>
28
28
  ec.resources
@@ -30,7 +30,7 @@ let toResolvedOutputs = (
30
30
  ->Pulumi.Output.apply(resources => {
31
31
  let resolved: ReventlessInterop.EventCollector.resolvedOutputs = {
32
32
  name: ec.name,
33
- resources: resources,
33
+ resources,
34
34
  }
35
35
  resolved
36
36
  })
@@ -42,12 +42,10 @@ let toResolvedOutputs = (
42
42
  counter.countsDb.resources->Adapter.resourcesToInterop,
43
43
  )
44
44
  ->Pulumi.Output.all2
45
- ->Pulumi.Output.apply(((referencesDbResources, countsDbResources)) =>
46
- Some({
47
- ReventlessInterop.Counter.referencesDb: {resources: referencesDbResources},
48
- countsDb: {resources: countsDbResources},
49
- })
50
- )
45
+ ->Pulumi.Output.apply(((referencesDbResources, countsDbResources)) => Some({
46
+ ReventlessInterop.Counter.referencesDb: {resources: referencesDbResources},
47
+ countsDb: {resources: countsDbResources},
48
+ }))
51
49
  | None => Pulumi.Output.make(None)
52
50
  }
53
51
  (eventCollectorOutput, counterOutput)
@@ -38,7 +38,10 @@ module Make = (
38
38
  count: async _items =>
39
39
  log.warn(~comp="EventMapper", "No counter deployed, but trying to use count"),
40
40
  addToCounterTarget: async _target =>
41
- log.warn(~comp="EventMapper", "No counter deployed, but trying to use addToCounterTarget"),
41
+ log.warn(
42
+ ~comp="EventMapper",
43
+ "No counter deployed, but trying to use addToCounterTarget",
44
+ ),
42
45
  }
43
46
  ops
44
47
  }),
@@ -22,10 +22,11 @@ module MakeCounterHandler = (
22
22
  // Used to pre-filter incoming envelopes by TAG before attempting decode —
23
23
  // sibling variants on the same source aggregate that this mapping does not
24
24
  // declare are silently skipped instead of producing decode-failure noise.
25
- let mappingsWithTags = Mappings.mappings->Array.map((module(M: Mappings.Mapping)) => (
26
- module(M: Mappings.Mapping),
27
- Reventless.DcbTag.extractAllVariantNames(M.Source.eventSchema),
28
- ))
25
+ let mappingsWithTags =
26
+ Mappings.mappings->Array.map((module(M: Mappings.Mapping)) => (
27
+ module(M: Mappings.Mapping),
28
+ Reventless.DcbTag.extractAllVariantNames(M.Source.eventSchema),
29
+ ))
29
30
 
30
31
  // Looks up the event mapping for a given event JSON by matching the source service name
31
32
  // from the event's meta against the registered Mapping modules.
@@ -44,12 +45,18 @@ module MakeCounterHandler = (
44
45
  )
45
46
  switch entry {
46
47
  | None =>
47
- EffectLogger.logInfo(~comp="EventMapper", `map: No mapping ${source} -> ${target} found`)->Effect.runSync
48
+ EffectLogger.logInfo(
49
+ ~comp="EventMapper",
50
+ `map: No mapping ${source} -> ${target} found`,
51
+ )->Effect.runSync
48
52
  None
49
53
  | Some((mapping, acceptedTags)) =>
50
54
  module Mapping = unpack(mapping)
51
55
  let source = Mapping.Source.name
52
- EffectLogger.logInfo(~comp="EventMapper", `map: found mapping ${source} -> ${target}`)->Effect.runSync
56
+ EffectLogger.logInfo(
57
+ ~comp="EventMapper",
58
+ `map: found mapping ${source} -> ${target}`,
59
+ )->Effect.runSync
53
60
  Some((eventObj', eventMeta, mapping, acceptedTags))
54
61
  }
55
62
  | None =>
@@ -224,8 +231,9 @@ module MakeCounterHandler = (
224
231
  }
225
232
  )
226
233
  ->Effect.flatMap(((publisherEntries, _)) =>
227
- Effect.promise(() => publisherEntries)
228
- ->Effect.flatMap(entries => Effect.promise(() => Ops.publishJsons(entries)))
234
+ Effect.promise(() => publisherEntries)->Effect.flatMap(
235
+ entries => Effect.promise(() => Ops.publishJsons(entries)),
236
+ )
229
237
  )
230
238
  )
231
239
  }
@@ -271,8 +279,10 @@ module MakeEventCollectorHandler = (Ops: EventCollectorOps): EventCollectorHandl
271
279
  // 3. Publishes generated commands to the target aggregate
272
280
  let handleJsonEvents: EventCollector.jsonEventsHandler = stream =>
273
281
  stream->Stream.runForEach(eventJson' =>
274
- Effect.promise(() => Ops.commonEventsHandler([eventJson']))
275
- ->Effect.flatMap(((publisherEntries, counterActions)) => {
282
+ Effect.promise(() => Ops.commonEventsHandler([eventJson']))->Effect.flatMap(((
283
+ publisherEntries,
284
+ counterActions,
285
+ )) => {
276
286
  let (countActions, addToCounterTargetActions) = counterActions->Array.partition(
277
287
  x =>
278
288
  switch x {
@@ -294,29 +304,34 @@ module MakeEventCollectorHandler = (Ops: EventCollectorOps): EventCollectorHandl
294
304
  ->Int.toString}`,
295
305
  )
296
306
  ->Effect.flatMap(_ => doCount(countItems))
297
- ->Effect.flatMap(_ =>
298
- EffectLogger.logInfo(
299
- ~comp="EventMapper",
300
- `eventCollectorEventsHandler: addToCounterTargetActions: ${addToCounterTargetActions
301
- ->JSON.stringifyAny
302
- ->Option.getOr("[]")}`,
303
- )
304
- )
305
- ->Effect.flatMap(_ =>
306
- Effect.all(
307
- addToCounterTargetActions->Array.filterMap(x =>
308
- switch x {
309
- | AddToCounterTarget(counterTarget) =>
310
- Some(Effect.promise(() => Ops.addToCounterTarget(counterTarget)))
311
- | _ => None
312
- }
307
+ ->Effect.flatMap(
308
+ _ =>
309
+ EffectLogger.logInfo(
310
+ ~comp="EventMapper",
311
+ `eventCollectorEventsHandler: addToCounterTargetActions: ${addToCounterTargetActions
312
+ ->JSON.stringifyAny
313
+ ->Option.getOr("[]")}`,
313
314
  ),
314
- {"concurrency": "unbounded"},
315
- )->Effect.map(_ => ())
316
315
  )
317
- ->Effect.flatMap(_ =>
318
- Effect.promise(() => publisherEntries)
319
- ->Effect.flatMap(entries => Effect.promise(() => Ops.publishJsons(entries)))
316
+ ->Effect.flatMap(
317
+ _ =>
318
+ Effect.all(
319
+ addToCounterTargetActions->Array.filterMap(
320
+ x =>
321
+ switch x {
322
+ | AddToCounterTarget(counterTarget) =>
323
+ Some(Effect.promise(() => Ops.addToCounterTarget(counterTarget)))
324
+ | _ => None
325
+ },
326
+ ),
327
+ {"concurrency": "unbounded"},
328
+ )->Effect.map(_ => ()),
329
+ )
330
+ ->Effect.flatMap(
331
+ _ =>
332
+ Effect.promise(() => publisherEntries)->Effect.flatMap(
333
+ entries => Effect.promise(() => Ops.publishJsons(entries)),
334
+ ),
320
335
  )
321
336
  })
322
337
  )
@@ -32,9 +32,9 @@ module type T = {
32
32
  ) => component
33
33
  }
34
34
 
35
- let toResolvedOutputs = (
36
- outputs: outputs,
37
- ): Pulumi.Output.t<ReventlessInterop.EventTopic.resolvedOutputs> =>
35
+ let toResolvedOutputs = (outputs: outputs): Pulumi.Output.t<
36
+ ReventlessInterop.EventTopic.resolvedOutputs,
37
+ > =>
38
38
  outputs.resources
39
39
  ->Adapter.resourcesToInterop
40
40
  ->Pulumi.Output.apply(resources => {
@@ -35,7 +35,7 @@ module Make = (Spec: ReventlessInfra.EventTopic.T, Publisher: EventTopic_Adapter
35
35
  {
36
36
  publishJson,
37
37
  publish: Operations.publish,
38
- publishJsonStream: publishJsonStream,
38
+ publishJsonStream,
39
39
  }
40
40
  }),
41
41
  )
@@ -4,7 +4,10 @@ type outputs = ReventlessInfra.Extension.outputs
4
4
  type t
5
5
 
6
6
  type jsonEventsHandler = (JSON.t, Reventless.Plugin.pluginDefinition) => promise<unit>
7
- type operations = {incomingJsonEventsHandler: jsonEventsHandler, outgoingJsonEventsHandler: jsonEventsHandler}
7
+ type operations = {
8
+ incomingJsonEventsHandler: jsonEventsHandler,
9
+ outgoingJsonEventsHandler: jsonEventsHandler,
10
+ }
8
11
  type component = Component.t<t, outputs, operations>
9
12
 
10
13
  module type T = {
@@ -67,7 +67,9 @@ module Make = (
67
67
  let publishAggregateCommand = async (aggregateName, cmdJson: Message.commandJson) => {
68
68
  EffectLogger.logInfo(
69
69
  ~comp,
70
- `EP→${aggregateName}: ${cmdJson.commandJson->Message.variantNameOfJson->LogFormat.bold}(${cmdJson.id})`,
70
+ `EP→${aggregateName}: ${cmdJson.commandJson
71
+ ->Message.variantNameOfJson
72
+ ->LogFormat.bold}(${cmdJson.id})`,
71
73
  )->Effect.runSync
72
74
  let pub = Ops.publishToAggregates->Dict.get(aggregateName)->Option.getOrThrow
73
75
  try await pub([cmdJson]) catch {
@@ -152,7 +154,10 @@ module Make = (
152
154
  }
153
155
 
154
156
  let incomingJsonEventsHandler = async (eventJson', pluginDef) => {
155
- EffectLogger.logInfo(~comp=comp, `incoming EP event: ${LogFormat.eventSummary(eventJson')}`)->Effect.runSync
157
+ EffectLogger.logInfo(
158
+ ~comp,
159
+ `incoming EP event: ${LogFormat.eventSummary(eventJson')}`,
160
+ )->Effect.runSync
156
161
  switch eventJson'->Message.decodeEvent'(
157
162
  Reventless.Id.StringPure.schema,
158
163
  MappingSpec.eventSchema,
@@ -193,7 +198,10 @@ module Make = (
193
198
  }
194
199
 
195
200
  let outgoingJsonEventsHandler = (eventJson', pluginDef) => {
196
- EffectLogger.logInfo(~comp=comp, `outgoing delegate event: ${LogFormat.eventSummary(eventJson')}`)->Effect.runSync
201
+ EffectLogger.logInfo(
202
+ ~comp,
203
+ `outgoing delegate event: ${LogFormat.eventSummary(eventJson')}`,
204
+ )->Effect.runSync
197
205
  let commandActions = mapOutgoingEvent(eventJson', pluginDef)
198
206
  commandActions
199
207
  ->Array.map(applyOutgoingCommandAction)
@@ -33,9 +33,9 @@ module type Mappings = {
33
33
  let mappings: array<module(Mapping)>
34
34
  }
35
35
 
36
- let toResolvedOutputs = (
37
- outputs: outputs,
38
- ): Pulumi.Output.t<ReventlessInterop.ExtensionPoint.resolvedOutputs> =>
36
+ let toResolvedOutputs = (outputs: outputs): Pulumi.Output.t<
37
+ ReventlessInterop.ExtensionPoint.resolvedOutputs,
38
+ > =>
39
39
  (
40
40
  outputs.commandTopic->Pulumi.Output.flatMap(CommandTopic.toResolvedOutputs),
41
41
  outputs.eventTopic->Pulumi.Output.flatMap(EventTopic.toResolvedOutputs),
@@ -89,13 +89,12 @@ module Make = (
89
89
  // first command-topic resource's `id`. The in-memory ExtensionPoint
90
90
  // runtime builder ignores this dict, so including every aggregate
91
91
  // (not just mapping targets) and the empty fallback are both harmless.
92
- let publishToAggregatesQueueUrls =
93
- aggregateResources->Dict.mapValues(resources =>
94
- switch resources->Array.get(0) {
95
- | Some(r: ReventlessInfra.Adapter.resource) => r.id
96
- | None => Pulumi.Output.make("")
97
- }
98
- )
92
+ let publishToAggregatesQueueUrls = aggregateResources->Dict.mapValues(resources =>
93
+ switch resources->Array.get(0) {
94
+ | Some(r: ReventlessInfra.Adapter.resource) => r.id
95
+ | None => Pulumi.Output.make("")
96
+ }
97
+ )
99
98
 
100
99
  commandTopic->ExtensionPointRuntimeBuilder.forCommandTopic(
101
100
  ~handler,
@@ -138,9 +137,9 @@ module Make = (
138
137
  ->Pulumi.Output.unzip3
139
138
 
140
139
  self->Component.setOperations(
141
- outgoingJsonEventsHandler->Pulumi.Output.apply(outgoingJsonEventsHandler =>
142
- ({outgoingJsonEventsHandler: outgoingJsonEventsHandler}: ExtensionPoint.operations)
143
- ),
140
+ outgoingJsonEventsHandler->Pulumi.Output.apply((
141
+ outgoingJsonEventsHandler
142
+ ): ExtensionPoint.operations => {outgoingJsonEventsHandler: outgoingJsonEventsHandler}),
144
143
  )
145
144
 
146
145
  let epOutputs: ExtensionPoint.outputs = {
@@ -70,8 +70,7 @@ module Make = (
70
70
  let _ = result()
71
71
  Ok(reference)
72
72
  },
73
- )
74
- ->Effect.catchAll(((errorResult, errMsg)) =>
73
+ )->Effect.catchAll(((errorResult, errMsg)) =>
75
74
  EffectLogger.logError(~comp="ExtensionPoint", errMsg)->Effect.map(_ => errorResult)
76
75
  )
77
76
  | AbstractHandleDirective(reference, handler) =>
@@ -102,9 +101,6 @@ module Make = (
102
101
  Spec.resourceNaming,
103
102
  Spec.commandTopicResources,
104
103
  )
105
- Effect.all(
106
- commandActions->Array.map(applyCommandAction),
107
- {"concurrency": "unbounded"},
108
- )
104
+ Effect.all(commandActions->Array.map(applyCommandAction), {"concurrency": "unbounded"})
109
105
  })
110
106
  }
@@ -77,8 +77,7 @@ module Make = (
77
77
 
78
78
  try await Ops.publishToEventTopic(id, meta, finalEventJson) catch {
79
79
  | err =>
80
- let errMsg =
81
- err->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("unknown")
80
+ let errMsg = err->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("unknown")
82
81
  EffectLogger.logError(
83
82
  ~comp=`ExtensionPoint(${MappingSpec.name})`,
84
83
  `Error on publishToEventTopic command: ${errMsg}`,
@@ -113,7 +112,10 @@ module Make = (
113
112
  let applyEventAction = async action =>
114
113
  switch action {
115
114
  | ReventlessInfra.ExtensionPointMapping.AbstractPublishEvent(id, meta, eventJson) =>
116
- EffectLogger.logInfo(~comp=`ExtensionPoint(${MappingSpec.name})`, `applying event: ${LogFormat.eventSummary(eventJson)}`)->Effect.runSync
115
+ EffectLogger.logInfo(
116
+ ~comp=`ExtensionPoint(${MappingSpec.name})`,
117
+ `applying event: ${LogFormat.eventSummary(eventJson)}`,
118
+ )->Effect.runSync
117
119
  await publishWithHooks(id, meta, eventJson)
118
120
  | ReventlessInfra.ExtensionPointMapping.AbstractPublishEventAsync(promise) =>
119
121
  let (id, meta, eventJson) = await promise
@@ -123,12 +125,18 @@ module Make = (
123
125
  | err =>
124
126
  let errMsg =
125
127
  err->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("unknown")
126
- EffectLogger.logError(~comp=`ExtensionPoint(${MappingSpec.name})`, `Error on handling directive: ${errMsg}`)->Effect.runSync
128
+ EffectLogger.logError(
129
+ ~comp=`ExtensionPoint(${MappingSpec.name})`,
130
+ `Error on handling directive: ${errMsg}`,
131
+ )->Effect.runSync
127
132
  }
128
133
  }
129
134
 
130
135
  let outgoingJsonEventsHandler = async (eventJson', _pluginDef) => {
131
- EffectLogger.logInfo(~comp=`ExtensionPoint(${MappingSpec.name})`, `outgoing event: ${LogFormat.eventSummary(eventJson')}`)->Effect.runSync
136
+ EffectLogger.logInfo(
137
+ ~comp=`ExtensionPoint(${MappingSpec.name})`,
138
+ `outgoing event: ${LogFormat.eventSummary(eventJson')}`,
139
+ )->Effect.runSync
132
140
  let eventActions = mapOutgoingEvent(
133
141
  eventJson',
134
142
  Mappings.mappings,
@@ -23,9 +23,9 @@ module Make = (Spec: Spec) => {
23
23
  msgId,
24
24
  correlationId: msgId,
25
25
  },
26
- commandJson: PluginExtensionPointSpec.Heartbeat(
27
- Spec.timeout,
28
- )->Message.encode(PluginExtensionPointSpec.commandSchema),
26
+ commandJson: PluginExtensionPointSpec.Heartbeat(Spec.timeout)->Message.encode(
27
+ PluginExtensionPointSpec.commandSchema,
28
+ ),
29
29
  },
30
30
  ])
31
31
  }
@@ -7,9 +7,9 @@ type acceptedResult = ReventlessInfra.InboundTranslationSlice.acceptedResult
7
7
  type rejectedResult = ReventlessInfra.InboundTranslationSlice.rejectedResult
8
8
  type component = Component.t<t, outputs, operations>
9
9
 
10
- let toResolvedOutputs = (
11
- outputs: outputs,
12
- ): Pulumi.Output.t<ReventlessInterop.InboundTranslationSlice.resolvedOutputs> =>
10
+ let toResolvedOutputs = (outputs: outputs): Pulumi.Output.t<
11
+ ReventlessInterop.InboundTranslationSlice.resolvedOutputs,
12
+ > =>
13
13
  (
14
14
  outputs.resources->Adapter.resourcesToInterop,
15
15
  outputs.queryDb.resources->Adapter.resourcesToInterop,
@@ -17,7 +17,7 @@ let toResolvedOutputs = (
17
17
  ->Pulumi.Output.all2
18
18
  ->Pulumi.Output.apply(((resources, queryDbResources)) => {
19
19
  let resolved: ReventlessInterop.InboundTranslationSlice.resolvedOutputs = {
20
- resources: resources,
20
+ resources,
21
21
  queryDb: {resources: queryDbResources},
22
22
  }
23
23
  resolved
@@ -39,7 +39,11 @@ module Make = (
39
39
  let visibility: Reventless.Visibility.t = Public
40
40
  }
41
41
 
42
- module SpecificQueryDb = QueryDb_Builder.Make(AuditQueryDbSpec, QueryDbStorage, QueryDbResolvers)
42
+ module SpecificQueryDb = QueryDb_Builder.Make(
43
+ AuditQueryDbSpec,
44
+ QueryDbStorage,
45
+ QueryDbResolvers,
46
+ )
43
47
 
44
48
  // Persist just this request's audit row, taking it out of the in-memory log
45
49
  // as it goes — see `takeAuditRow` for why draining the whole dict is wrong.
@@ -78,10 +82,7 @@ module Make = (
78
82
  let ops: InboundTranslationSlice.operations = {
79
83
  receive: async inputJson => {
80
84
  let result = await Callback.receive(publishJsonsFn, inputJson)
81
- await syncToQueryDb(
82
- queryDbOps,
83
- result->InboundTranslationSlice_Callback.requestIdOf,
84
- )
85
+ await syncToQueryDb(queryDbOps, result->InboundTranslationSlice_Callback.requestIdOf)
85
86
  result
86
87
  },
87
88
  }
@@ -99,11 +100,7 @@ module Make = (
99
100
  // InboundTranslationSlice publishes commands + syncs its QueryDb inline; it
100
101
  // provisions no per-slice runtime environment, so the runtime hint is accepted
101
102
  // (for composition-surface parity) and discarded.
102
- let make = (
103
- ~publishJsons,
104
- ~runtime as _=?,
105
- ~opts=?,
106
- ): InboundTranslationSlice.component =>
103
+ let make = (~publishJsons, ~runtime as _=?, ~opts=?): InboundTranslationSlice.component =>
107
104
  Component.make(
108
105
  ~componentType=InboundTranslationSlice.componentType->ComponentType.toString,
109
106
  ~name=Spec.name,
@@ -5,9 +5,9 @@ type outputs = ReventlessInfra.OutboundTranslationSlice.outputs
5
5
  type operations = ReventlessInfra.OutboundTranslationSlice.operations
6
6
  type component = Component.t<t, outputs, operations>
7
7
 
8
- let toResolvedOutputs = (
9
- outputs: outputs,
10
- ): Pulumi.Output.t<ReventlessInterop.OutboundTranslationSlice.resolvedOutputs> =>
8
+ let toResolvedOutputs = (outputs: outputs): Pulumi.Output.t<
9
+ ReventlessInterop.OutboundTranslationSlice.resolvedOutputs,
10
+ > =>
11
11
  (
12
12
  outputs.resources->Adapter.resourcesToInterop,
13
13
  outputs.queryDb.resources->Adapter.resourcesToInterop,
@@ -15,7 +15,7 @@ let toResolvedOutputs = (
15
15
  ->Pulumi.Output.all2
16
16
  ->Pulumi.Output.apply(((resources, queryDbResources)) => {
17
17
  let resolved: ReventlessInterop.OutboundTranslationSlice.resolvedOutputs = {
18
- resources: resources,
18
+ resources,
19
19
  queryDb: {resources: queryDbResources},
20
20
  }
21
21
  resolved