@reventlessdev/reventless-core 3.0.0-alpha.259 → 3.0.0-alpha.261

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 (209) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/package.json +11 -11
  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/admin/Platform_Admin.res +17 -6
  20. package/src/admin/Platform_AdminApi.res +14 -9
  21. package/src/admin/Platform_Admin_Callback.res +1 -1
  22. package/src/admin/Platform_BakedManifest.res +34 -34
  23. package/src/admin/Platform_ComponentDefinitionsApi.res +9 -21
  24. package/src/admin/Platform_PluginStructuresApi.res +15 -12
  25. package/src/admin/UiFragmentRegistry/StateChange/UiFragmentRegistry.res +1 -1
  26. package/src/components/Aggregate/Aggregate.res +13 -12
  27. package/src/components/Aggregate/Aggregate_Builder.res +22 -21
  28. package/src/components/Aggregate/Aggregate_Callback.res +91 -86
  29. package/src/components/Api/ApiNoApiHelpers.res +1 -3
  30. package/src/components/Api/Api_Ids.res +0 -1
  31. package/src/components/Api/Api_Naming.res +41 -18
  32. package/src/components/Api/GraphQL_FragmentGenerator.res +42 -52
  33. package/src/components/Api/GraphQL_FragmentGenerator.res.mjs +11 -4
  34. package/src/components/Api/GraphQL_SchemaInspector.res +5 -3
  35. package/src/components/Api/GraphQL_Stitcher.res +9 -10
  36. package/src/components/Api/MCP_SchemaGenerator.res +8 -12
  37. package/src/components/Api/OwnerScopeDiagnostics.res +1 -2
  38. package/src/components/Api/QueryDbListQuery.res +13 -6
  39. package/src/components/Api/SchemaType.res +40 -20
  40. package/src/components/Api/SchemaType.res.mjs +16 -0
  41. package/src/components/Api/SuryToJsonSchema.res +18 -10
  42. package/src/components/Api/SuryToJsonSchema.res.mjs +135 -121
  43. package/src/components/AutomationSlice/AutomationSlice.res +4 -4
  44. package/src/components/AutomationSlice/AutomationSlice_Builder.res +15 -14
  45. package/src/components/AutomationSlice/AutomationSlice_Callback.res +3 -3
  46. package/src/components/Builder_Helpers.res +12 -23
  47. package/src/components/CommandGenerator/CommandGenerator.res +6 -1
  48. package/src/components/CommandGenerator/CommandGenerator_Builder.res +29 -21
  49. package/src/components/CommandGenerator/CommandGenerator_Callback.res +17 -21
  50. package/src/components/CommandTopic/CommandTopic.res +3 -3
  51. package/src/components/CommandTopic/CommandTopic_Builder.res +10 -10
  52. package/src/components/CommandTopic/CommandTopic_Callback.res +1 -4
  53. package/src/components/CommandTopic/CommandTopic_Helpers.res +1 -2
  54. package/src/components/Counter/Counter_Builder.res +1 -6
  55. package/src/components/Counter/Counter_Callback.res +3 -3
  56. package/src/components/Dcb/Dcb_Builder.res +970 -956
  57. package/src/components/DcbEventLog/DcbEventLog.res +4 -4
  58. package/src/components/DcbEventLog/DcbEventLog_Builder.res +0 -1
  59. package/src/components/DcbEventLog/DcbEventLog_Operations.res +17 -18
  60. package/src/components/EventCollector/EventCollector_Builder.res +2 -1
  61. package/src/components/EventLog/EventLog.res +5 -1
  62. package/src/components/EventLog/EventLog_Operations.res +12 -8
  63. package/src/components/EventMapper/EventMapper.res +8 -10
  64. package/src/components/EventMapper/EventMapper_Builder.res +4 -1
  65. package/src/components/EventMapper/EventMapper_Callback.res +46 -31
  66. package/src/components/EventTopic/EventTopic.res +3 -3
  67. package/src/components/EventTopic/EventTopic_Builder.res +1 -1
  68. package/src/components/Extension/Extension.res +4 -1
  69. package/src/components/Extension/Extension_Operations.res +11 -3
  70. package/src/components/ExtensionPoint/ExtensionPoint.res +3 -3
  71. package/src/components/ExtensionPoint/ExtensionPoint_Builder.res +9 -10
  72. package/src/components/ExtensionPoint/ExtensionPoint_Callback.res +2 -6
  73. package/src/components/ExtensionPoint/ExtensionPoint_Operations.res +13 -5
  74. package/src/components/Heartbeat/Heartbeat_Callback.res +3 -3
  75. package/src/components/InboundTranslationSlice/InboundTranslationSlice.res +4 -4
  76. package/src/components/InboundTranslationSlice/InboundTranslationSlice_Builder.res +7 -10
  77. package/src/components/OutboundTranslationSlice/OutboundTranslationSlice.res +4 -4
  78. package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Builder.res +15 -14
  79. package/src/components/QueryDb/QueryDb_Adapter.res +1 -3
  80. package/src/components/QueryDb/QueryDb_Operations.res +10 -10
  81. package/src/components/ReadModel/ReadModel.res +3 -3
  82. package/src/components/ReadModel/ReadModel_Builder.res +1 -2
  83. package/src/components/ReadModel/ReadModel_Callback.res +2 -1
  84. package/src/components/SideEffectHandler/SideEffectHandler_Callback.res +5 -2
  85. package/src/components/StateChangeSlice/StateChangeSlice.res +3 -3
  86. package/src/components/StateChangeSlice/StateChangeSlice_Builder.res +23 -4
  87. package/src/components/StateChangeSlice/StateChangeSlice_Callback.res +22 -6
  88. package/src/components/StateTopic.res +1 -3
  89. package/src/components/StateViewSlice/StateViewSlice.res +4 -4
  90. package/src/components/StateViewSlice/StateViewSlice_Builder.res +79 -68
  91. package/src/components/StateViewSlice/StateViewSlice_Callback.res +3 -1
  92. package/src/components/Task/Task.res +3 -3
  93. package/src/components/Task/Task_Adapter.res +4 -1
  94. package/src/components/Task/Task_Builder.res +24 -21
  95. package/src/plugin/api/PluginBaseFragment.res +9 -3
  96. package/src/plugin/component/Capability_Inference.res +8 -10
  97. package/src/plugin/component/Plugin.res +6 -6
  98. package/src/plugin/component/Plugin_Builder.res +54 -50
  99. package/src/plugin/component/Plugin_Callback.res +10 -6
  100. package/src/plugin/component/Plugin_Helpers.res +264 -230
  101. package/src/plugin/component/Plugin_Structure.res +370 -324
  102. package/src/plugin/component/Plugin_SubscriptionSchema.res +8 -6
  103. package/src/plugin/component/SchemaWalker.res +11 -12
  104. package/src/plugin/connect/PluginConnectExtension_Mapping.res +45 -50
  105. package/src/plugin/lifecycle/PluginBehavior.res +3 -4
  106. package/src/plugin/lifecycle/PluginSpec.res +1 -2
  107. package/src/plugin/lifecycle/PluginsProjection.res +16 -5
  108. package/src/plugin/lifecycle/PluginsReadModelSpec.res +0 -2
  109. package/src/util/CommandPublisher.res +9 -2
  110. package/src/util/CsvStream.res +3 -3
  111. package/src/util/Interstack.res +7 -15
  112. package/src/util/Interstack.resi +3 -3
  113. package/src/util/LogFormat.res +5 -9
  114. package/src/util/Logger.res +1 -2
  115. package/src/util/Lru.res +2 -1
  116. package/src/util/Lru.resi +2 -3
  117. package/src/util/ScheduleOps.res +24 -27
  118. package/src/util/StorePrefixCollision.res +6 -9
  119. package/src/util/Util_Promise.res +4 -1
  120. package/src/util/Util_Promise.res.mjs +1 -1
  121. package/tests/IdentityTest.res +166 -113
  122. package/tests/ResourceAttributionTest.res +28 -25
  123. package/tests/StorePrefixCollisionTest.res +2 -1
  124. package/tests/TaskBucketNamingTest.res +3 -2
  125. package/tests/adapter/EventLogProvisioningTest.res +51 -48
  126. package/tests/adapter/MonitoringTest.res +81 -38
  127. package/tests/adapter/QueryInterceptionTest.res +2 -2
  128. package/tests/adapter/RefusalVocabularyTest.res +31 -23
  129. package/tests/adapter/RuntimeExtensionHookReachTest.res +9 -8
  130. package/tests/adapter/RuntimeExtensionTest.res +5 -3
  131. package/tests/admin/AdminApiSchemaDriftTest.res +22 -16
  132. package/tests/admin/Platform_Admin_StructureTest.res +10 -11
  133. package/tests/admin/Platform_BakedManifestTest.res +31 -35
  134. package/tests/admin/Platform_ComponentDefinitionsApiTest.res +18 -15
  135. package/tests/admin/Platform_PluginStructuresApiTest.res +5 -3
  136. package/tests/admin/Platform_UIFragmentsApiTest.res +6 -3
  137. package/tests/aggregate/AggregateCacheTest.res +10 -12
  138. package/tests/aggregate/AggregateCallbackTest.res +75 -46
  139. package/tests/aggregate/AggregateCausationTest.res +19 -20
  140. package/tests/aggregate/AggregateConflictTest.res +41 -19
  141. package/tests/aggregate/AggregateFixtures.res +15 -5
  142. package/tests/aggregate/AggregateRejectionTest.res +97 -80
  143. package/tests/aggregate/AggregateSnapshotTest.res +44 -16
  144. package/tests/api/Api_IdsTest.res +10 -4
  145. package/tests/api/BrandedMarkerCompositionTest.res +48 -36
  146. package/tests/api/GeolocationSemanticTest.res +3 -3
  147. package/tests/api/GraphQL_FragmentGeneratorTest.res +66 -54
  148. package/tests/api/OwnerScopeDiagnosticsTest.res +31 -27
  149. package/tests/api/StorageRefFieldsTest.res +30 -18
  150. package/tests/api/SuryToJsonSchemaTest.res +1338 -981
  151. package/tests/api/SuryToJsonSchemaTest.res.mjs +31 -0
  152. package/tests/api/TaggedUnionSchemaTest.res +17 -24
  153. package/tests/commandgenerator/CommandGeneratorCallbackTest.res +235 -179
  154. package/tests/commandgenerator/CommandGeneratorFixtures.res +8 -13
  155. package/tests/commandgenerator/OwnerStampingTest.res +91 -76
  156. package/tests/commandtopic/CommandOutcomeHookTest.res +198 -155
  157. package/tests/commandtopic/CommandTopicCallbackFixtures.res +5 -4
  158. package/tests/commandtopic/CommandTopicCallbackTest.res +61 -43
  159. package/tests/commandtopic/CommandTopicHelpersRejectionTest.res +70 -55
  160. package/tests/counter/CounterCallbackTest.res +40 -34
  161. package/tests/counter/CounterFixtures.res +4 -4
  162. package/tests/dcb/DcbDecodeTest.res +115 -84
  163. package/tests/dcb/DcbEventLogOperationsTest.res +194 -143
  164. package/tests/dcb/DcbEventLogSchemaTest.res +13 -13
  165. package/tests/dcb/DcbFixtures.res +4 -5
  166. package/tests/dcb/DcbScopeInferenceTest.res +173 -114
  167. package/tests/dcb/DcbStateChangeSliceTest.res +391 -262
  168. package/tests/dcb/DcbTagTest.res +22 -11
  169. package/tests/dcb/DcbValidationTest.res +288 -218
  170. package/tests/eventlog/EventLogFixtures.res +4 -4
  171. package/tests/eventlog/EventLogOperationsTest.res +102 -67
  172. package/tests/eventlog/EventLogRetryTest.res +104 -65
  173. package/tests/eventmapper/EventMapperCallbackTest.res +118 -83
  174. package/tests/eventmapper/EventMapperFixtures.res +15 -23
  175. package/tests/eventmapper/EventMapperTest.res +54 -38
  176. package/tests/eventtopic/EventTopicFixtures.res +3 -4
  177. package/tests/eventtopic/EventTopicOperationsTest.res +41 -29
  178. package/tests/extensionpoint/ExtensionPointCallbackTest.res +58 -45
  179. package/tests/extensionpoint/ExtensionPointFixtures.res +16 -20
  180. package/tests/extensionpoint/ExtensionPointOperationsTest.res +70 -49
  181. package/tests/extensionpoint/PluginDisconnectScheduleTest.res +2 -1
  182. package/tests/logger/LogFormatTest.res +104 -82
  183. package/tests/logger/LoggerLazyTest.res +21 -12
  184. package/tests/message/MessageTest.res +96 -93
  185. package/tests/message/MetaEnvelopeTest.res +26 -30
  186. package/tests/plugin/HeartbeatDisconnectGraceTest.res +31 -25
  187. package/tests/plugin/ManifestVisibilityTest.res +20 -12
  188. package/tests/plugin/PluginDefinitionScalars.res +1 -2
  189. package/tests/plugin/PluginLifecycleCorpusTest.res +15 -12
  190. package/tests/plugin/PluginSpecExperiment.res +0 -1
  191. package/tests/plugin/PluginStructureTest.res +1533 -1030
  192. package/tests/plugin/PluginStructureTest.res.mjs +6 -0
  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 +6 -4
  197. package/tests/plugin/StateView/PsAnnotatedView.res.mjs +7 -3
  198. package/tests/plugin/StateView/PsCustomersView.res +4 -4
  199. package/tests/plugin/StateView/PsShipmentsView.res +3 -2
  200. package/tests/projection/LifecycleTrailTest.res +1 -4
  201. package/tests/projection/ProjectionOptimizeTest.res +13 -9
  202. package/tests/querydb/QueryDbFixtures.res +0 -1
  203. package/tests/querydb/QueryDbOperationsTest.res +99 -64
  204. package/tests/querydb/TaggedUnionStampTest.res +10 -8
  205. package/tests/sideeffecthandler/SideEffectHandlerCallbackTest.res +50 -35
  206. package/tests/sideeffecthandler/SideEffectHandlerFixtures.res +4 -10
  207. package/tests/util/CommandPublisherTest.res +0 -1
  208. package/tests/util/CsvStreamTest.res +3 -3
  209. package/tests/util/LruTest.res +84 -56
@@ -110,8 +110,7 @@ module Make = (
110
110
  `AutomationSlice "${Spec.name}" has a Mapping with sourceName "${sourceName}", ` ++
111
111
  `but no EventTopic with that key exists in allEventTopics. ` ++
112
112
  `Available source names: [${availableNames}]. ` ++
113
- `Check Mapping.Make's first arg matches an Aggregate Spec.name or a DCB ` ++
114
- `source name (typically "<pluginName>DcbEventLog").`,
113
+ `Check Mapping.Make's first arg matches an Aggregate Spec.name or a DCB ` ++ `source name (typically "<pluginName>DcbEventLog").`,
115
114
  )
116
115
  }
117
116
  )
@@ -159,18 +158,20 @@ module Make = (
159
158
  let _ =
160
159
  Callback.phase2(publishJsonsFn)
161
160
  ->Promise.then(() => syncToQueryDb(queryDbOps))
162
- ->Promise.catch(exn => {
163
- let errMsg =
164
- exn
165
- ->JsExn.fromException
166
- ->Option.flatMap(JsExn.message)
167
- ->Option.getOr("unknown")
168
- EffectLogger.logError(
169
- ~comp=`AutomationSlice(${Spec.name})`,
170
- `detached phase 2 error: ${errMsg}`,
171
- )->Effect.runSync
172
- Promise.resolve()
173
- })
161
+ ->Promise.catch(
162
+ exn => {
163
+ let errMsg =
164
+ exn
165
+ ->JsExn.fromException
166
+ ->Option.flatMap(JsExn.message)
167
+ ->Option.getOr("unknown")
168
+ EffectLogger.logError(
169
+ ~comp=`AutomationSlice(${Spec.name})`,
170
+ `detached phase 2 error: ${errMsg}`,
171
+ )->Effect.runSync
172
+ Promise.resolve()
173
+ },
174
+ )
174
175
  },
175
176
  )
176
177
  )
@@ -172,9 +172,9 @@ module Make = (
172
172
  handle: (JSON.t, ~sourceId: string, Reventless.AutomationSlice.context) => unit,
173
173
  }
174
174
 
175
- let dispatches: array<dispatch> = Automation.mappings->Array.map((
176
- module(M: Automation.Mapping),
177
- ) => {
175
+ let dispatches: array<
176
+ dispatch,
177
+ > = Automation.mappings->Array.map((module(M: Automation.Mapping)) => {
178
178
  let decoder = Reventless.DcbDecode.makeDecoder(M.sourceEventSchema)
179
179
  let handle = (json: JSON.t, ~sourceId: string, ctx: Reventless.AutomationSlice.context) => {
180
180
  let (eventType, dataDict) = json->Message.splitMessage
@@ -30,14 +30,9 @@ let createAggregatesWithoutEventMappers = (
30
30
  ~opts,
31
31
  )
32
32
  let aggOutputs = SpecificAggregate.outputs(aggregate)
33
- addEventMapperFns->Dict.set(
34
- SpecificAggregate.Spec.name,
35
- aggOutputs.addEventMapper,
36
- )
33
+ addEventMapperFns->Dict.set(SpecificAggregate.Spec.name, aggOutputs.addEventMapper)
37
34
  let resources =
38
- aggOutputs.commandTopic->Pulumi.Output.apply(commandTopic =>
39
- commandTopic.resources
40
- )
35
+ aggOutputs.commandTopic->Pulumi.Output.apply(commandTopic => commandTopic.resources)
41
36
  aggregateResources->Dict.set(SpecificAggregate.Spec.name, resources)
42
37
  let publishJsons =
43
38
  SpecificAggregate.operations(aggregate)->Pulumi.Output.apply(({publishJsons}) => publishJsons)
@@ -54,10 +49,7 @@ let createAggregatesWithoutEventMappers = (
54
49
  ->Array.map(aggregate => {(aggregate.name, aggregate)})
55
50
  ->Dict.fromArray
56
51
 
57
-
58
- let finishAggregates = (
59
- aggregatesOutputs: dict<Aggregate.outputs>,
60
- ) => {
52
+ let finishAggregates = (aggregatesOutputs: dict<Aggregate.outputs>) => {
61
53
  let allOutputs = aggregatesOutputs->Dict.valuesToArray
62
54
 
63
55
  // Wait for ALL commandTopicOutputs (not just those with event mappers)
@@ -89,10 +81,7 @@ let finishAggregates = (
89
81
  )
90
82
  }
91
83
 
92
- let addEventMappers = (
93
- allEventTopics,
94
- queryEngine,
95
- ) => {
84
+ let addEventMappers = (allEventTopics, queryEngine) => {
96
85
  let aggregatesOutputs =
97
86
  addEventMapperFns->Dict.mapValues(addEventMapperFn =>
98
87
  addEventMapperFn(allEventTopics, queryEngine)
@@ -126,9 +115,7 @@ let finishTasks = () =>
126
115
  let _ =
127
116
  taskSideEffectGates
128
117
  ->Pulumi.Output.all
129
- ->Pulumi.Output.apply(_ =>
130
- taskSideEffectFinishFns->Array.forEach(finishFn => finishFn())
131
- )
118
+ ->Pulumi.Output.apply(_ => taskSideEffectFinishFns->Array.forEach(finishFn => finishFn()))
132
119
  }
133
120
 
134
121
  let readModelNamesForSourceName = Dict.make()
@@ -154,8 +141,7 @@ let extractReadModelsOutputs = readModels =>
154
141
  ->Dict.fromArray
155
142
 
156
143
  let createReadModels = (
157
- type a,
158
- type r,
144
+ type a r,
159
145
  readModels: array<module(ReventlessInfra.ReadModel.T with type api = a and type role = r)>,
160
146
  ~api: a,
161
147
  ~apiRole: r,
@@ -163,7 +149,9 @@ let createReadModels = (
163
149
  allEventTopics,
164
150
  opts,
165
151
  ) => {
166
- let readModels = readModels->Array.map((module(SpecificReadModel: ReventlessInfra.ReadModel.T with type api = a and type role = r)) => {
152
+ let readModels = readModels->Array.map((
153
+ module(SpecificReadModel: ReventlessInfra.ReadModel.T with type api = a and type role = r),
154
+ ) => {
167
155
  let readModel = SpecificReadModel.make(
168
156
  ~api,
169
157
  ~apiRole,
@@ -222,8 +210,9 @@ let createExtensionPoints = (
222
210
  ~opts,
223
211
  ) => {
224
212
  let triples =
225
- extensionPoints
226
- ->Array.map((module(SpecificExtensionPoint: ReventlessInfra.ExtensionPoint.T)) => {
213
+ extensionPoints->Array.map((
214
+ module(SpecificExtensionPoint: ReventlessInfra.ExtensionPoint.T),
215
+ ) => {
227
216
  let extensionPoint = SpecificExtensionPoint.make(
228
217
  ~aggregateResources,
229
218
  ~publishToAggregates,
@@ -27,7 +27,12 @@ external asEvent: 'a => event = "%identity"
27
27
  let metaInfo = event => (event->asEvent).meta->Option.map(({info}) => info)
28
28
 
29
29
  type commandGenerator = payload => Effect.t<CommandTopic.commandOutcome, unit, unit>
30
- type effectEventHandler<'context> = Runtime.effectHandler<payload, 'context, CommandTopic.commandOutcome, unit>
30
+ type effectEventHandler<'context> = Runtime.effectHandler<
31
+ payload,
32
+ 'context,
33
+ CommandTopic.commandOutcome,
34
+ unit,
35
+ >
31
36
 
32
37
  type publishJsons = CommandTopic.publishJsons
33
38
 
@@ -1,25 +1,29 @@
1
- module Make = (
2
- Spec: Reventless.Aggregate.Spec,
3
- Resolvers: CommandGenerator_Adapter.Resolvers,
4
- ): (
1
+ module Make = (Spec: Reventless.Aggregate.Spec, Resolvers: CommandGenerator_Adapter.Resolvers): (
5
2
  CommandGenerator.T with type runtimeParts := Resolvers.runtimeParts and type api := Resolvers.api
6
3
  ) => {
7
4
  let construct = (self, _name) => {
8
- let resources = Plugin_Helpers.aggregateMutationFieldsRegistry->Dict.get(Spec.name)->Option.getOr([])->Array.map(field => {
9
- let r: ReventlessInfra.Adapter.resource = {
10
- id: ""->Pulumi.Output.make,
11
- resourceInfo: ReventlessInfra.Adapter.ApiResolver({typeName: "Mutation", fieldName: field})->Pulumi.Output.make,
12
- name: ""->Pulumi.Output.make,
13
- urn: ""->Pulumi.Output.make,
14
- service: ""->Pulumi.Output.make,
15
- role: "commandGenerator"->Pulumi.Output.make,
16
- region: ""->Pulumi.Output.make,
17
- resourceType: ""->Pulumi.Output.make,
18
- configuration: Dict.make()->Pulumi.Output.make,
19
- tags: Dict.make()->Pulumi.Output.make,
20
- }
21
- r
22
- })
5
+ let resources =
6
+ Plugin_Helpers.aggregateMutationFieldsRegistry
7
+ ->Dict.get(Spec.name)
8
+ ->Option.getOr([])
9
+ ->Array.map(field => {
10
+ let r: ReventlessInfra.Adapter.resource = {
11
+ id: ""->Pulumi.Output.make,
12
+ resourceInfo: ReventlessInfra.Adapter.ApiResolver({
13
+ typeName: "Mutation",
14
+ fieldName: field,
15
+ })->Pulumi.Output.make,
16
+ name: ""->Pulumi.Output.make,
17
+ urn: ""->Pulumi.Output.make,
18
+ service: ""->Pulumi.Output.make,
19
+ role: "commandGenerator"->Pulumi.Output.make,
20
+ region: ""->Pulumi.Output.make,
21
+ resourceType: ""->Pulumi.Output.make,
22
+ configuration: Dict.make()->Pulumi.Output.make,
23
+ tags: Dict.make()->Pulumi.Output.make,
24
+ }
25
+ r
26
+ })
23
27
  let outputs: CommandGenerator.outputs = {resources: resources}
24
28
  let _ = self->Component.setOutputs(outputs)
25
29
  }
@@ -32,7 +36,8 @@ module Make = (
32
36
  ->ComponentType.name(CommandGenerator.componentType)
33
37
  let opts = {Pulumi.ComponentResource.parent: commandGeneratorResource}
34
38
 
35
- let fields = Plugin_Helpers.aggregateMutationFieldsRegistry->Dict.get(Spec.name)->Option.getOr([])
39
+ let fields =
40
+ Plugin_Helpers.aggregateMutationFieldsRegistry->Dict.get(Spec.name)->Option.getOr([])
36
41
 
37
42
  let resolvers = Resolvers.make(
38
43
  ~name,
@@ -48,7 +53,10 @@ module Make = (
48
53
  let _ = commandGenerator->Component.setOutputs(cgOutputs)
49
54
  }
50
55
 
51
- let makeHandler = (~publishJsons, ~publishJsonsAndWait: option<CommandTopic.publishJsonsAndWait>) => {
56
+ let makeHandler = (
57
+ ~publishJsons,
58
+ ~publishJsonsAndWait: option<CommandTopic.publishJsonsAndWait>,
59
+ ) => {
52
60
  module Callback = CommandGenerator_Callback.Make(
53
61
  {
54
62
  let publishJsons = publishJsons
@@ -168,9 +168,7 @@ let makeGenerateCommand = (
168
168
  | Some(idValue) => idValue
169
169
  | None =>
170
170
  try {
171
- let derived = Reventless.DcbTag.derivePartitionTag([
172
- (serviceName, "", commandSchema),
173
- ])
171
+ let derived = Reventless.DcbTag.derivePartitionTag([(serviceName, "", commandSchema)])
174
172
  switch derived {
175
173
  | Simple(pt) =>
176
174
  let tags = Reventless.DcbTag.extractTagsFromJson(commandSchema, commandJson)
@@ -221,22 +219,23 @@ let makeGenerateCommand = (
221
219
  | Allow =>
222
220
  switch publishJsonsAndWait {
223
221
  | Some(publishAndWait) =>
224
- Effect.promise(() => publishAndWait([{id, meta, commandJson}]))
225
- ->Effect.map(outcomes => {
226
- // For aggregates, entityId comes from the envelope id.
227
- // DCB slices populate entityId via the side-channel; don't override it.
228
- switch outcomes->Array.getUnsafe(0) {
229
- | CommandTopic.Accepted(payload) when payload.entityId->Option.isNone =>
230
- CommandTopic.Accepted({...payload, entityId: id})
231
- | outcome => outcome
232
- }
233
- })
222
+ Effect.promise(() => publishAndWait([{id, meta, commandJson}]))->Effect.map(
223
+ outcomes => {
224
+ // For aggregates, entityId comes from the envelope id.
225
+ // DCB slices populate entityId via the side-channel; don't override it.
226
+ switch outcomes->Array.getUnsafe(0) {
227
+ | CommandTopic.Accepted(payload) if payload.entityId->Option.isNone =>
228
+ CommandTopic.Accepted({...payload, entityId: id})
229
+ | outcome => outcome
230
+ }
231
+ },
232
+ )
234
233
  | None =>
235
- Effect.promise(() => publishJsons([{id, meta, commandJson}]))
236
- ->Effect.map(_ => CommandTopic.Pending({msgId: meta.msgId}))
234
+ Effect.promise(() => publishJsons([{id, meta, commandJson}]))->Effect.map(
235
+ _ => CommandTopic.Pending({msgId: meta.msgId}),
236
+ )
237
237
  }
238
- | Deny(msg) =>
239
- JsError.throwWithMessage(msg)
238
+ | Deny(msg) => JsError.throwWithMessage(msg)
240
239
  }
241
240
  )
242
241
  | exception err =>
@@ -265,10 +264,7 @@ let makeGenerateCommand = (
265
264
  })
266
265
  }
267
266
 
268
- module Make = (
269
- Spec: Spec,
270
- AggregateSpec: Reventless.Aggregate.Spec,
271
- ): T => {
267
+ module Make = (Spec: Spec, AggregateSpec: Reventless.Aggregate.Spec): T => {
272
268
  let generateCommand = makeGenerateCommand(
273
269
  ~publishJsons=Spec.publishJsons,
274
270
  ~publishJsonsAndWait=?Spec.publishJsonsAndWait,
@@ -63,9 +63,9 @@ module type T = {
63
63
  ) => component
64
64
  }
65
65
 
66
- let toResolvedOutputs = (
67
- outputs: outputs,
68
- ): Pulumi.Output.t<ReventlessInterop.CommandTopic.resolvedOutputs> =>
66
+ let toResolvedOutputs = (outputs: outputs): Pulumi.Output.t<
67
+ ReventlessInterop.CommandTopic.resolvedOutputs,
68
+ > =>
69
69
  outputs.resources
70
70
  ->Adapter.resourcesToInterop
71
71
  ->Pulumi.Output.apply(resources => {
@@ -49,21 +49,21 @@ module Make = (Spec: ReventlessInfra.CommandTopic.T, Channel: CommandTopic_Adapt
49
49
  let handlers = CommandTopic.getHandlers(typeName)
50
50
  Effect.promise(async () => {
51
51
  let allResults: array<result<string, string>> = []
52
- let _ =
53
- await handlers
54
- ->Array.map(async handlerEntry => {
52
+ let _ = await handlers
53
+ ->Array.map(
54
+ async handlerEntry => {
55
55
  let {CommandTopic.handler: handler} = handlerEntry
56
56
  try {
57
- let results =
58
- await handler(
59
- Stream.fromIterable([{ReventlessInfra.CommandTopic.reference, command: json}]),
60
- )->Effect.runPromise
57
+ let results = await handler(
58
+ Stream.fromIterable([{ReventlessInfra.CommandTopic.reference, command: json}]),
59
+ )->Effect.runPromise
61
60
  allResults->Array.pushMany(results)
62
61
  } catch {
63
62
  | _ => () // Skip if handler fails
64
63
  }
65
- })
66
- ->Promise.all
64
+ },
65
+ )
66
+ ->Promise.all
67
67
  allResults
68
68
  })
69
69
  })
@@ -89,7 +89,7 @@ module Make = (Spec: ReventlessInfra.CommandTopic.T, Channel: CommandTopic_Adapt
89
89
  {
90
90
  publish: Operations.publish,
91
91
  publishJsons: Operations.publishJsons,
92
- publishJsonsStream: publishJsonsStream,
92
+ publishJsonsStream,
93
93
  publishJsonsAndWait,
94
94
  }
95
95
  }),
@@ -19,10 +19,7 @@ module Make = (Spec: ReventlessInfra.CommandTopic.T, Ops: Ops with module Spec =
19
19
  | exception err =>
20
20
  let commandStr = json->JSON.stringify
21
21
  let errMsg = err->Reventless.Util_Sury.exnMessage
22
- EffectLogger.logError(
23
- ~comp,
24
- `decode failed: ${commandStr} err=${errMsg}`,
25
- )->Effect.runSync
22
+ EffectLogger.logError(~comp, `decode failed: ${commandStr} err=${errMsg}`)->Effect.runSync
26
23
  None
27
24
  }
28
25
  )
@@ -206,8 +206,7 @@ let runInlineAndCollect = async (
206
206
  Rejected({msgId, errorCode, errorDetail: detail})
207
207
  | None =>
208
208
  switch results->Array.get(i) {
209
- | Some(Error(msg)) =>
210
- Rejected({msgId, errorCode: "Conflict", errorDetail: Some(msg)})
209
+ | Some(Error(msg)) => Rejected({msgId, errorCode: "Conflict", errorDetail: Some(msg)})
211
210
  | _ =>
212
211
  let ar = acceptedResults->Dict.get(msgId)->Option.getOr({eventCount: 0})
213
212
  switch ar.entityId {
@@ -57,12 +57,7 @@ module Make = (
57
57
  QueryDb_Adapter.NoResolvers(QueryDbStorage),
58
58
  )
59
59
 
60
- let referencesDb = ReferencesDb.make(
61
- ~api=Api.api(),
62
- ~apiRole=Api.apiRole(),
63
- ~ttl?,
64
- ~opts,
65
- )
60
+ let referencesDb = ReferencesDb.make(~api=Api.api(), ~apiRole=Api.apiRole(), ~ttl?, ~opts)
66
61
  let countsDb = CountsDb.make(
67
62
  ~api=Api.api(),
68
63
  ~apiRole=Api.apiRole(),
@@ -37,7 +37,7 @@ module Make = (Spec: Spec) => {
37
37
  EffectLogger.logInfo(
38
38
  ~comp="Counter",
39
39
  `counterHandler: counts: ${counts->JSON.stringifyAny->Option.getOr("[]")}`,
40
- )
40
+ ),
41
41
  )
42
42
  ->Effect.zipRight(
43
43
  Effect.all(
@@ -53,7 +53,7 @@ module Make = (Spec: Spec) => {
53
53
  )
54
54
  ),
55
55
  {"concurrency": "unbounded"},
56
- )->Effect.map(_ => ())
56
+ )->Effect.map(_ => ()),
57
57
  )
58
58
  ->Effect.zipRight(
59
59
  Spec.jsonEventsHandler(
@@ -88,7 +88,7 @@ module Make = (Spec: Spec) => {
88
88
  }
89
89
  ),
90
90
  ),
91
- )
91
+ ),
92
92
  )
93
93
  ->Effect.runPromise
94
94
  }