@reventlessdev/reventless-core 3.0.0-alpha.134
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 +1355 -0
- package/LICENSE +202 -0
- package/README.md +173 -0
- package/__mocks__/emptyModule.js +2 -0
- package/jest.setup.cjs +5 -0
- package/package.json +73 -0
- package/rescript.json +41 -0
- package/scripts/deploy.sh +6 -0
- package/scripts/post-deploy.sh +5 -0
- package/scripts/pre-deploy.sh +18 -0
- package/scripts/pulumi-up.sh +30 -0
- package/src/Behavior.res +18 -0
- package/src/Behavior.res.mjs +2 -0
- package/src/ComponentType.res +125 -0
- package/src/ComponentType.res.mjs +199 -0
- package/src/Env.res +5 -0
- package/src/Env.res.mjs +2 -0
- package/src/Mapper.res +36 -0
- package/src/Mapper.res.mjs +18 -0
- package/src/Mapper1toN.res +107 -0
- package/src/Mapper1toN.res.mjs +2 -0
- package/src/MapperNto1.res +78 -0
- package/src/MapperNto1.res.mjs +35 -0
- package/src/Message.res +353 -0
- package/src/Message.res.mjs +418 -0
- package/src/PluginRuntimeOperations.res +15 -0
- package/src/PluginRuntimeOperations.res.mjs +2 -0
- package/src/Projection.res +447 -0
- package/src/Projection.res.mjs +712 -0
- package/src/ProjectionMapper.res +44 -0
- package/src/ProjectionMapper.res.mjs +51 -0
- package/src/RequestContext.res +42 -0
- package/src/RequestContext.res.mjs +39 -0
- package/src/adapter/Adapter.res +178 -0
- package/src/adapter/Adapter.res.mjs +201 -0
- package/src/adapter/AdapterDeploytime.res +56 -0
- package/src/adapter/AdapterDeploytime.res.mjs +42 -0
- package/src/adapter/Auth/Auth_Adapter.res +42 -0
- package/src/adapter/Auth/Auth_Adapter.res.mjs +2 -0
- package/src/adapter/Runtime/AggregateRuntime_Builder.res +22 -0
- package/src/adapter/Runtime/AggregateRuntime_Builder.res.mjs +2 -0
- package/src/adapter/Runtime/AggregateRuntime_Builder_Common.res +259 -0
- package/src/adapter/Runtime/AggregateRuntime_Builder_Common.res.mjs +190 -0
- package/src/adapter/Runtime/AggregateRuntime_Builder_Micro.res +92 -0
- package/src/adapter/Runtime/AggregateRuntime_Builder_Micro.res.mjs +59 -0
- package/src/adapter/Runtime/AggregateRuntime_Builder_PerAggregate.res +52 -0
- package/src/adapter/Runtime/AggregateRuntime_Builder_PerAggregate.res.mjs +49 -0
- package/src/adapter/Runtime/AggregateRuntime_Builder_Single.res +64 -0
- package/src/adapter/Runtime/AggregateRuntime_Builder_Single.res.mjs +59 -0
- package/src/adapter/Runtime/EventCollectorRuntime_Builder.res +11 -0
- package/src/adapter/Runtime/EventCollectorRuntime_Builder.res.mjs +2 -0
- package/src/adapter/Runtime/EventCollectorRuntime_Builder_PerEventCollector.res +46 -0
- package/src/adapter/Runtime/EventCollectorRuntime_Builder_PerEventCollector.res.mjs +40 -0
- package/src/adapter/Runtime/EventCollectorRuntime_Builder_Single.res +204 -0
- package/src/adapter/Runtime/EventCollectorRuntime_Builder_Single.res.mjs +150 -0
- package/src/adapter/Runtime/ExtensionPointRuntime_Builder.res +18 -0
- package/src/adapter/Runtime/ExtensionPointRuntime_Builder.res.mjs +2 -0
- package/src/adapter/Runtime/ExtensionPointRuntime_Builder_PerExtensionPoint.res +36 -0
- package/src/adapter/Runtime/ExtensionPointRuntime_Builder_PerExtensionPoint.res.mjs +28 -0
- package/src/adapter/Runtime/PluginRuntime_Builder.res +23 -0
- package/src/adapter/Runtime/PluginRuntime_Builder.res.mjs +2 -0
- package/src/adapter/Runtime/PluginRuntime_Builder_Micro.res +97 -0
- package/src/adapter/Runtime/PluginRuntime_Builder_Micro.res.mjs +62 -0
- package/src/adapter/Runtime/PluginRuntime_Builder_Single.res +89 -0
- package/src/adapter/Runtime/PluginRuntime_Builder_Single.res.mjs +62 -0
- package/src/adapter/Runtime/Runtime.res +106 -0
- package/src/adapter/Runtime/Runtime.res.mjs +22 -0
- package/src/adapter/Runtime/TaskRuntime_Builder.res +32 -0
- package/src/adapter/Runtime/TaskRuntime_Builder.res.mjs +2 -0
- package/src/adapter/Runtime/TaskRuntime_Builder_PerBucket.res +42 -0
- package/src/adapter/Runtime/TaskRuntime_Builder_PerBucket.res.mjs +29 -0
- package/src/admin/AdminApi.res +88 -0
- package/src/admin/AdminApi.res.mjs +89 -0
- package/src/admin/Admin_Callback.res +27 -0
- package/src/admin/Admin_Callback.res.mjs +20 -0
- package/src/admin/Platform_Admin.res +402 -0
- package/src/admin/Platform_Admin.res.mjs +250 -0
- package/src/admin/Platform_Admin_Structure.res +125 -0
- package/src/admin/Platform_Admin_Structure.res.mjs +182 -0
- package/src/admin/Platform_ComponentDefinitionsApi.res +160 -0
- package/src/admin/Platform_ComponentDefinitionsApi.res.mjs +299 -0
- package/src/admin/Platform_UIFragmentsApi.res +55 -0
- package/src/admin/Platform_UIFragmentsApi.res.mjs +124 -0
- package/src/admin/UIFragmentRegistryProjection.res +43 -0
- package/src/admin/UIFragmentRegistryProjection.res.mjs +81 -0
- package/src/admin/UIFragmentRegistryReadModelSpec.res +13 -0
- package/src/admin/UIFragmentRegistryReadModelSpec.res.mjs +40 -0
- package/src/components/Aggregate/Aggregate.res +96 -0
- package/src/components/Aggregate/Aggregate.res.mjs +82 -0
- package/src/components/Aggregate/Aggregate_Builder.res +175 -0
- package/src/components/Aggregate/Aggregate_Builder.res.mjs +119 -0
- package/src/components/Aggregate/Aggregate_Callback.res +273 -0
- package/src/components/Aggregate/Aggregate_Callback.res.mjs +208 -0
- package/src/components/Api/ApiAllowedStatesHelpers.res +19 -0
- package/src/components/Api/ApiAllowedStatesHelpers.res.mjs +16 -0
- package/src/components/Api/ApiNoApiHelpers.res +13 -0
- package/src/components/Api/ApiNoApiHelpers.res.mjs +29 -0
- package/src/components/Api/Api_Builder.res +40 -0
- package/src/components/Api/Api_Builder.res.mjs +33 -0
- package/src/components/Api/Api_Naming.res +92 -0
- package/src/components/Api/Api_Naming.res.mjs +103 -0
- package/src/components/Api/Api_Operations.res +13 -0
- package/src/components/Api/Api_Operations.res.mjs +12 -0
- package/src/components/Api/GraphQL_FragmentGenerator.res +612 -0
- package/src/components/Api/GraphQL_FragmentGenerator.res.mjs +503 -0
- package/src/components/Api/GraphQL_SchemaInspector.res +156 -0
- package/src/components/Api/GraphQL_SchemaInspector.res.mjs +123 -0
- package/src/components/Api/GraphQL_Stitcher.res +271 -0
- package/src/components/Api/GraphQL_Stitcher.res.mjs +229 -0
- package/src/components/Api/MCP_SchemaGenerator.res +185 -0
- package/src/components/Api/MCP_SchemaGenerator.res.mjs +146 -0
- package/src/components/Api/SchemaType.res +126 -0
- package/src/components/Api/SchemaType.res.mjs +143 -0
- package/src/components/Api/SuryToJsonSchema.res +142 -0
- package/src/components/Api/SuryToJsonSchema.res.mjs +210 -0
- package/src/components/AutomationSlice/AutomationSlice.res +39 -0
- package/src/components/AutomationSlice/AutomationSlice.res.mjs +24 -0
- package/src/components/AutomationSlice/AutomationSlice_Builder.res +207 -0
- package/src/components/AutomationSlice/AutomationSlice_Builder.res.mjs +123 -0
- package/src/components/AutomationSlice/AutomationSlice_Callback.res +212 -0
- package/src/components/AutomationSlice/AutomationSlice_Callback.res.mjs +189 -0
- package/src/components/Builder_Helpers.res +196 -0
- package/src/components/Builder_Helpers.res.mjs +142 -0
- package/src/components/Cloner.res +84 -0
- package/src/components/Cloner.res.mjs +88 -0
- package/src/components/CommandGenerator/CommandGenerator.res +54 -0
- package/src/components/CommandGenerator/CommandGenerator.res.mjs +15 -0
- package/src/components/CommandGenerator/CommandGenerator_Adapter.res +22 -0
- package/src/components/CommandGenerator/CommandGenerator_Adapter.res.mjs +2 -0
- package/src/components/CommandGenerator/CommandGenerator_Builder.res +70 -0
- package/src/components/CommandGenerator/CommandGenerator_Builder.res.mjs +68 -0
- package/src/components/CommandGenerator/CommandGenerator_Callback.res +191 -0
- package/src/components/CommandGenerator/CommandGenerator_Callback.res.mjs +161 -0
- package/src/components/CommandTopic/CommandTopic.res +79 -0
- package/src/components/CommandTopic/CommandTopic.res.mjs +68 -0
- package/src/components/CommandTopic/CommandTopic_Adapter.res +53 -0
- package/src/components/CommandTopic/CommandTopic_Adapter.res.mjs +2 -0
- package/src/components/CommandTopic/CommandTopic_Builder.res +146 -0
- package/src/components/CommandTopic/CommandTopic_Builder.res.mjs +127 -0
- package/src/components/CommandTopic/CommandTopic_Callback.res +38 -0
- package/src/components/CommandTopic/CommandTopic_Callback.res.mjs +49 -0
- package/src/components/CommandTopic/CommandTopic_Helpers.res +176 -0
- package/src/components/CommandTopic/CommandTopic_Helpers.res.mjs +195 -0
- package/src/components/CommandTopic/CommandTopic_Operations.res +40 -0
- package/src/components/CommandTopic/CommandTopic_Operations.res.mjs +49 -0
- package/src/components/Component.res +1 -0
- package/src/components/Component.res.mjs +34 -0
- package/src/components/Component.resi +1 -0
- package/src/components/Counter/Counter.res +47 -0
- package/src/components/Counter/Counter.res.mjs +55 -0
- package/src/components/Counter/Counter_Adapter.res +18 -0
- package/src/components/Counter/Counter_Adapter.res.mjs +2 -0
- package/src/components/Counter/Counter_Builder.res +142 -0
- package/src/components/Counter/Counter_Builder.res.mjs +112 -0
- package/src/components/Counter/Counter_Callback.res +94 -0
- package/src/components/Counter/Counter_Callback.res.mjs +70 -0
- package/src/components/Counter/Counter_Operations.res +70 -0
- package/src/components/Counter/Counter_Operations.res.mjs +91 -0
- package/src/components/Dcb/Dcb_Builder.res +971 -0
- package/src/components/Dcb/Dcb_Builder.res.mjs +572 -0
- package/src/components/DcbEventLog/DcbEventLog.res +43 -0
- package/src/components/DcbEventLog/DcbEventLog.res.mjs +24 -0
- package/src/components/DcbEventLog/DcbEventLog_Adapter.res +57 -0
- package/src/components/DcbEventLog/DcbEventLog_Adapter.res.mjs +2 -0
- package/src/components/DcbEventLog/DcbEventLog_Builder.res +72 -0
- package/src/components/DcbEventLog/DcbEventLog_Builder.res.mjs +67 -0
- package/src/components/DcbEventLog/DcbEventLog_Operations.res +160 -0
- package/src/components/DcbEventLog/DcbEventLog_Operations.res.mjs +121 -0
- package/src/components/EventCollector/EventCollector.res +34 -0
- package/src/components/EventCollector/EventCollector.res.mjs +9 -0
- package/src/components/EventCollector/EventCollector_Adapter.res +45 -0
- package/src/components/EventCollector/EventCollector_Adapter.res.mjs +2 -0
- package/src/components/EventCollector/EventCollector_Builder.res +91 -0
- package/src/components/EventCollector/EventCollector_Builder.res.mjs +64 -0
- package/src/components/EventLog/EventLog.res +27 -0
- package/src/components/EventLog/EventLog.res.mjs +13 -0
- package/src/components/EventLog/EventLog_Adapter.res +15 -0
- package/src/components/EventLog/EventLog_Adapter.res.mjs +2 -0
- package/src/components/EventLog/EventLog_Builder.res +65 -0
- package/src/components/EventLog/EventLog_Builder.res.mjs +57 -0
- package/src/components/EventLog/EventLog_Operations.res +209 -0
- package/src/components/EventLog/EventLog_Operations.res.mjs +202 -0
- package/src/components/EventLog/EventPublish_Callback.res +29 -0
- package/src/components/EventLog/EventPublish_Callback.res.mjs +32 -0
- package/src/components/EventMapper/EventMapper.res +72 -0
- package/src/components/EventMapper/EventMapper.res.mjs +54 -0
- package/src/components/EventMapper/EventMapper_Builder.res +128 -0
- package/src/components/EventMapper/EventMapper_Builder.res.mjs +81 -0
- package/src/components/EventMapper/EventMapper_Callback.res +323 -0
- package/src/components/EventMapper/EventMapper_Callback.res.mjs +231 -0
- package/src/components/EventTopic/EventTopic.res +69 -0
- package/src/components/EventTopic/EventTopic.res.mjs +50 -0
- package/src/components/EventTopic/EventTopic_Adapter.res +15 -0
- package/src/components/EventTopic/EventTopic_Adapter.res.mjs +2 -0
- package/src/components/EventTopic/EventTopic_Builder.res +53 -0
- package/src/components/EventTopic/EventTopic_Builder.res.mjs +46 -0
- package/src/components/EventTopic/EventTopic_Operations.res +37 -0
- package/src/components/EventTopic/EventTopic_Operations.res.mjs +39 -0
- package/src/components/Extension/Extension.res +32 -0
- package/src/components/Extension/Extension.res.mjs +9 -0
- package/src/components/Extension/Extension_Builder.res +82 -0
- package/src/components/Extension/Extension_Builder.res.mjs +57 -0
- package/src/components/Extension/Extension_Operations.res +203 -0
- package/src/components/Extension/Extension_Operations.res.mjs +154 -0
- package/src/components/ExtensionPoint/ExtensionPoint.res +49 -0
- package/src/components/ExtensionPoint/ExtensionPoint.res.mjs +25 -0
- package/src/components/ExtensionPoint/ExtensionPoint_Builder.res +163 -0
- package/src/components/ExtensionPoint/ExtensionPoint_Builder.res.mjs +113 -0
- package/src/components/ExtensionPoint/ExtensionPoint_Callback.res +110 -0
- package/src/components/ExtensionPoint/ExtensionPoint_Callback.res.mjs +76 -0
- package/src/components/ExtensionPoint/ExtensionPoint_Operations.res +146 -0
- package/src/components/ExtensionPoint/ExtensionPoint_Operations.res.mjs +122 -0
- package/src/components/Heartbeat/Heartbeat.res +25 -0
- package/src/components/Heartbeat/Heartbeat.res.mjs +9 -0
- package/src/components/Heartbeat/Heartbeat_Adapter.res +14 -0
- package/src/components/Heartbeat/Heartbeat_Adapter.res.mjs +2 -0
- package/src/components/Heartbeat/Heartbeat_Builder.res +43 -0
- package/src/components/Heartbeat/Heartbeat_Builder.res.mjs +47 -0
- package/src/components/Heartbeat/Heartbeat_Callback.res +32 -0
- package/src/components/Heartbeat/Heartbeat_Callback.res.mjs +40 -0
- package/src/components/InboundTranslationSlice/InboundTranslationSlice.res +34 -0
- package/src/components/InboundTranslationSlice/InboundTranslationSlice.res.mjs +24 -0
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Builder.res +98 -0
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Builder.res.mjs +87 -0
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res +191 -0
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res.mjs +175 -0
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice.res +35 -0
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice.res.mjs +24 -0
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Builder.res +181 -0
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Builder.res.mjs +137 -0
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res +173 -0
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res.mjs +173 -0
- package/src/components/QueryDb/QueryDb.res +74 -0
- package/src/components/QueryDb/QueryDb.res.mjs +37 -0
- package/src/components/QueryDb/QueryDb_Adapter.res +78 -0
- package/src/components/QueryDb/QueryDb_Adapter.res.mjs +17 -0
- package/src/components/QueryDb/QueryDb_Builder.res +76 -0
- package/src/components/QueryDb/QueryDb_Builder.res.mjs +53 -0
- package/src/components/QueryDb/QueryDb_Callback.res +18 -0
- package/src/components/QueryDb/QueryDb_Callback.res.mjs +21 -0
- package/src/components/QueryDb/QueryDb_Operations.res +116 -0
- package/src/components/QueryDb/QueryDb_Operations.res.mjs +165 -0
- package/src/components/ReadModel/ReadModel.res +42 -0
- package/src/components/ReadModel/ReadModel.res.mjs +27 -0
- package/src/components/ReadModel/ReadModel_Builder.res +155 -0
- package/src/components/ReadModel/ReadModel_Builder.res.mjs +101 -0
- package/src/components/ReadModel/ReadModel_Callback.res +48 -0
- package/src/components/ReadModel/ReadModel_Callback.res.mjs +48 -0
- package/src/components/Scheduler/Scheduler.res +13 -0
- package/src/components/Scheduler/Scheduler.res.mjs +9 -0
- package/src/components/Scheduler/Scheduler_Adapter.res +13 -0
- package/src/components/Scheduler/Scheduler_Adapter.res.mjs +2 -0
- package/src/components/Scheduler/Scheduler_Builder.res +19 -0
- package/src/components/Scheduler/Scheduler_Builder.res.mjs +29 -0
- package/src/components/SideEffectHandler/SideEffectHandler.res +30 -0
- package/src/components/SideEffectHandler/SideEffectHandler.res.mjs +12 -0
- package/src/components/SideEffectHandler/SideEffectHandler_Builder.res +117 -0
- package/src/components/SideEffectHandler/SideEffectHandler_Builder.res.mjs +64 -0
- package/src/components/SideEffectHandler/SideEffectHandler_Callback.res +116 -0
- package/src/components/SideEffectHandler/SideEffectHandler_Callback.res.mjs +95 -0
- package/src/components/StateChangeSlice/StateChangeSlice.res +38 -0
- package/src/components/StateChangeSlice/StateChangeSlice.res.mjs +17 -0
- package/src/components/StateChangeSlice/StateChangeSlice_Builder.res +91 -0
- package/src/components/StateChangeSlice/StateChangeSlice_Builder.res.mjs +81 -0
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res +412 -0
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res.mjs +299 -0
- package/src/components/StateTopic.res +91 -0
- package/src/components/StateTopic.res.mjs +41 -0
- package/src/components/StateViewSlice/StateViewSlice.res +33 -0
- package/src/components/StateViewSlice/StateViewSlice.res.mjs +24 -0
- package/src/components/StateViewSlice/StateViewSlice_Builder.res +176 -0
- package/src/components/StateViewSlice/StateViewSlice_Builder.res.mjs +134 -0
- package/src/components/StateViewSlice/StateViewSlice_Callback.res +64 -0
- package/src/components/StateViewSlice/StateViewSlice_Callback.res.mjs +56 -0
- package/src/components/Task/Task.res +81 -0
- package/src/components/Task/Task.res.mjs +51 -0
- package/src/components/Task/Task_Adapter.res +31 -0
- package/src/components/Task/Task_Adapter.res.mjs +2 -0
- package/src/components/Task/Task_Builder.res +223 -0
- package/src/components/Task/Task_Builder.res.mjs +115 -0
- package/src/plugin/api/PluginBaseFragment.res +104 -0
- package/src/plugin/api/PluginBaseFragment.res.mjs +64 -0
- package/src/plugin/component/Plugin.res +100 -0
- package/src/plugin/component/Plugin.res.mjs +61 -0
- package/src/plugin/component/Plugin_Builder.res +1017 -0
- package/src/plugin/component/Plugin_Builder.res.mjs +608 -0
- package/src/plugin/component/Plugin_BuiltHook.res +141 -0
- package/src/plugin/component/Plugin_BuiltHook.res.mjs +39 -0
- package/src/plugin/component/Plugin_Callback.res +98 -0
- package/src/plugin/component/Plugin_Callback.res.mjs +55 -0
- package/src/plugin/component/Plugin_Helpers.res +1730 -0
- package/src/plugin/component/Plugin_Helpers.res.mjs +1010 -0
- package/src/plugin/component/Plugin_ResolverError.res +27 -0
- package/src/plugin/component/Plugin_ResolverError.res.mjs +21 -0
- package/src/plugin/component/Plugin_Structure.res +570 -0
- package/src/plugin/component/Plugin_Structure.res.mjs +458 -0
- package/src/plugin/component/Plugin_SubscriptionSchema.res +103 -0
- package/src/plugin/component/Plugin_SubscriptionSchema.res.mjs +71 -0
- package/src/plugin/component/SchemaWalker.res +164 -0
- package/src/plugin/component/SchemaWalker.res.mjs +183 -0
- package/src/plugin/connect/PluginConnectExtension_Builder.res +14 -0
- package/src/plugin/connect/PluginConnectExtension_Builder.res.mjs +36 -0
- package/src/plugin/connect/PluginConnectExtension_Mapping.res +76 -0
- package/src/plugin/connect/PluginConnectExtension_Mapping.res.mjs +89 -0
- package/src/plugin/connect/PluginExtensionPoint_Builder.res +39 -0
- package/src/plugin/connect/PluginExtensionPoint_Builder.res.mjs +33 -0
- package/src/plugin/connect/PluginExtensionPoint_Plugin.res +231 -0
- package/src/plugin/connect/PluginExtensionPoint_Plugin.res.mjs +353 -0
- package/src/plugin/lifecycle/PluginBehavior.res +250 -0
- package/src/plugin/lifecycle/PluginBehavior.res.mjs +391 -0
- package/src/plugin/lifecycle/PluginSpec.res +84 -0
- package/src/plugin/lifecycle/PluginSpec.res.mjs +148 -0
- package/src/plugin/lifecycle/PluginsProjection.res +154 -0
- package/src/plugin/lifecycle/PluginsProjection.res.mjs +230 -0
- package/src/plugin/lifecycle/PluginsReadModelSpec.res +66 -0
- package/src/plugin/lifecycle/PluginsReadModelSpec.res.mjs +58 -0
- package/src/util/AWS.res +7 -0
- package/src/util/AWS.res.mjs +20 -0
- package/src/util/CSV.res +27 -0
- package/src/util/CSV.res.mjs +56 -0
- package/src/util/CommandPublisher.res +133 -0
- package/src/util/CommandPublisher.res.mjs +161 -0
- package/src/util/CsvStream.res +39 -0
- package/src/util/CsvStream.res.mjs +42 -0
- package/src/util/EffectLogger.res +178 -0
- package/src/util/EffectLogger.res.mjs +171 -0
- package/src/util/FTP.res +69 -0
- package/src/util/FTP.res.mjs +101 -0
- package/src/util/FTPHandler.res +142 -0
- package/src/util/FTPHandler.res.mjs +136 -0
- package/src/util/Hash.res +1 -0
- package/src/util/Hash.res.mjs +10 -0
- package/src/util/Interstack.res +74 -0
- package/src/util/Interstack.res.mjs +126 -0
- package/src/util/Interstack.resi +25 -0
- package/src/util/LogFormat.res +222 -0
- package/src/util/LogFormat.res.mjs +257 -0
- package/src/util/Logger.res +196 -0
- package/src/util/Logger.res.mjs +238 -0
- package/src/util/Lru.res +51 -0
- package/src/util/Lru.res.mjs +59 -0
- package/src/util/Lru.resi +32 -0
- package/src/util/Metrics.res +32 -0
- package/src/util/Metrics.res.mjs +42 -0
- package/src/util/OutputFailsafeDeploytime.res +16 -0
- package/src/util/OutputFailsafeDeploytime.res.mjs +20 -0
- package/src/util/OutputFailsafeRuntime.res +6 -0
- package/src/util/OutputFailsafeRuntime.res.mjs +15 -0
- package/src/util/OutputLogger.res +9 -0
- package/src/util/OutputLogger.res.mjs +19 -0
- package/src/util/ResourceQuery.res +14 -0
- package/src/util/ResourceQuery.res.mjs +17 -0
- package/src/util/ResourceQueryRuntime.res +17 -0
- package/src/util/ResourceQueryRuntime.res.mjs +18 -0
- package/src/util/ScheduleOps.res +124 -0
- package/src/util/ScheduleOps.res.mjs +132 -0
- package/src/util/Util.res +12 -0
- package/src/util/Util.res.mjs +42 -0
- package/src/util/Util_Adapter.res +97 -0
- package/src/util/Util_Adapter.res.mjs +82 -0
- package/src/util/Util_AdapterRuntime.res +39 -0
- package/src/util/Util_AdapterRuntime.res.mjs +42 -0
- package/src/util/Util_Array.res +2 -0
- package/src/util/Util_Array.res.mjs +12 -0
- package/src/util/Util_Error.res +16 -0
- package/src/util/Util_Error.res.mjs +19 -0
- package/src/util/Util_Promise.res +67 -0
- package/src/util/Util_Promise.res.mjs +105 -0
- package/src/util/Util_Pulumi.res +35 -0
- package/src/util/Util_Pulumi.res.mjs +55 -0
- package/src/util/Util_Pulumi.resi +21 -0
- package/src/util/Util_QueryDb.res +14 -0
- package/src/util/Util_QueryDb.res.mjs +21 -0
- package/src/util/Util_QueryDbRuntime.res +11 -0
- package/src/util/Util_QueryDbRuntime.res.mjs +19 -0
- package/src/util/Util_ReadModel.res +2 -0
- package/src/util/Util_ReadModel.res.mjs +10 -0
- package/src/util/Util_StackRefs.res +24 -0
- package/src/util/Util_StackRefs.res.mjs +39 -0
- package/src/util/Validation.res +75 -0
- package/src/util/Validation.res.mjs +181 -0
- package/tests/.gitkeep +0 -0
- package/tests/IdentityTest.res +155 -0
- package/tests/IdentityTest.res.mjs +174 -0
- package/tests/admin/Platform_ComponentDefinitionsApiTest.res +237 -0
- package/tests/admin/Platform_ComponentDefinitionsApiTest.res.mjs +298 -0
- package/tests/admin/Platform_UIFragmentsApiTest.res +96 -0
- package/tests/admin/Platform_UIFragmentsApiTest.res.mjs +101 -0
- package/tests/aggregate/AggregateCallbackTest.res +81 -0
- package/tests/aggregate/AggregateCallbackTest.res.mjs +140 -0
- package/tests/aggregate/AggregateCausationTest.res +49 -0
- package/tests/aggregate/AggregateCausationTest.res.mjs +44 -0
- package/tests/aggregate/AggregateConflictTest.res +212 -0
- package/tests/aggregate/AggregateConflictTest.res.mjs +363 -0
- package/tests/aggregate/AggregateFixtures.res +177 -0
- package/tests/aggregate/AggregateFixtures.res.mjs +285 -0
- package/tests/aggregate/AggregateRejectionTest.res +139 -0
- package/tests/aggregate/AggregateRejectionTest.res.mjs +163 -0
- package/tests/api/ApiNoApiTest.res +62 -0
- package/tests/api/ApiNoApiTest.res.mjs +90 -0
- package/tests/api/GraphQL_StitcherTest.res +107 -0
- package/tests/api/GraphQL_StitcherTest.res.mjs +99 -0
- package/tests/api/SimpleTest.res +7 -0
- package/tests/api/SimpleTest.res.mjs +10 -0
- package/tests/api/SuryToJsonSchemaTest.res +405 -0
- package/tests/api/SuryToJsonSchemaTest.res.mjs +623 -0
- package/tests/commandgenerator/CommandGeneratorCallbackTest.res +128 -0
- package/tests/commandgenerator/CommandGeneratorCallbackTest.res.mjs +160 -0
- package/tests/commandgenerator/CommandGeneratorFixtures.res +139 -0
- package/tests/commandgenerator/CommandGeneratorFixtures.res.mjs +197 -0
- package/tests/commandtopic/CommandTopicCallbackFixtures.res +87 -0
- package/tests/commandtopic/CommandTopicCallbackFixtures.res.mjs +152 -0
- package/tests/commandtopic/CommandTopicCallbackTest.res +66 -0
- package/tests/commandtopic/CommandTopicCallbackTest.res.mjs +106 -0
- package/tests/commandtopic/CommandTopicHelpersRejectionTest.res +83 -0
- package/tests/commandtopic/CommandTopicHelpersRejectionTest.res.mjs +109 -0
- package/tests/counter/CounterCallbackTest.res +83 -0
- package/tests/counter/CounterCallbackTest.res.mjs +140 -0
- package/tests/counter/CounterFixtures.res +57 -0
- package/tests/counter/CounterFixtures.res.mjs +67 -0
- package/tests/dcb/DcbDecodeTest.res +122 -0
- package/tests/dcb/DcbDecodeTest.res.mjs +194 -0
- package/tests/dcb/DcbEventLogOperationsTest.res +195 -0
- package/tests/dcb/DcbEventLogOperationsTest.res.mjs +268 -0
- package/tests/dcb/DcbFixtures.res +422 -0
- package/tests/dcb/DcbFixtures.res.mjs +534 -0
- package/tests/dcb/DcbScopeInferenceTest.res +242 -0
- package/tests/dcb/DcbScopeInferenceTest.res.mjs +480 -0
- package/tests/dcb/DcbStateChangeSliceTest.res +362 -0
- package/tests/dcb/DcbStateChangeSliceTest.res.mjs +546 -0
- package/tests/dcb/DcbTagTest.res +978 -0
- package/tests/dcb/DcbTagTest.res.mjs +867 -0
- package/tests/dcb/DcbValidationTest.res +349 -0
- package/tests/dcb/DcbValidationTest.res.mjs +476 -0
- package/tests/eventlog/EventLogFixtures.res +113 -0
- package/tests/eventlog/EventLogFixtures.res.mjs +166 -0
- package/tests/eventlog/EventLogOperationsTest.res +96 -0
- package/tests/eventlog/EventLogOperationsTest.res.mjs +192 -0
- package/tests/eventlog/EventLogRetryTest.res +121 -0
- package/tests/eventlog/EventLogRetryTest.res.mjs +171 -0
- package/tests/eventmapper/EventMapperCallbackTest.res +134 -0
- package/tests/eventmapper/EventMapperCallbackTest.res.mjs +141 -0
- package/tests/eventmapper/EventMapperFixtures.res +255 -0
- package/tests/eventmapper/EventMapperFixtures.res.mjs +440 -0
- package/tests/eventmapper/EventMapperTest.res +53 -0
- package/tests/eventmapper/EventMapperTest.res.mjs +83 -0
- package/tests/eventtopic/EventTopicFixtures.res +36 -0
- package/tests/eventtopic/EventTopicFixtures.res.mjs +65 -0
- package/tests/eventtopic/EventTopicOperationsTest.res +48 -0
- package/tests/eventtopic/EventTopicOperationsTest.res.mjs +71 -0
- package/tests/extensionpoint/ExtensionPointCallbackTest.res +84 -0
- package/tests/extensionpoint/ExtensionPointCallbackTest.res.mjs +94 -0
- package/tests/extensionpoint/ExtensionPointFixtures.res +173 -0
- package/tests/extensionpoint/ExtensionPointFixtures.res.mjs +205 -0
- package/tests/extensionpoint/ExtensionPointOperationsTest.res +261 -0
- package/tests/extensionpoint/ExtensionPointOperationsTest.res.mjs +304 -0
- package/tests/ftp/FTPTest.res +64 -0
- package/tests/ftp/FTPTest.res.mjs +88 -0
- package/tests/logger/LogFormatTest.res +348 -0
- package/tests/logger/LogFormatTest.res.mjs +309 -0
- package/tests/message/MessageTest.res +95 -0
- package/tests/message/MessageTest.res.mjs +93 -0
- package/tests/message/MetaEnvelopeTest.res +200 -0
- package/tests/message/MetaEnvelopeTest.res.mjs +188 -0
- package/tests/plugin/ManifestVisibilityTest.res +137 -0
- package/tests/plugin/ManifestVisibilityTest.res.mjs +205 -0
- package/tests/plugin/PluginSpecExperiment.res +13 -0
- package/tests/plugin/PluginSpecExperiment.res.mjs +31 -0
- package/tests/plugin/PluginStructureTest.res +298 -0
- package/tests/plugin/PluginStructureTest.res.mjs +388 -0
- package/tests/plugin/PluginVersionTest.res +34 -0
- package/tests/plugin/PluginVersionTest.res.mjs +30 -0
- package/tests/plugin/SchemaWalkerTest.res +115 -0
- package/tests/plugin/SchemaWalkerTest.res.mjs +160 -0
- package/tests/plugin/StateChangeSlice/PsPlaceOrder.res +24 -0
- package/tests/plugin/StateChangeSlice/PsPlaceOrder.res.mjs +62 -0
- package/tests/plugin/StateChangeSlice/PsShipOrder.res +29 -0
- package/tests/plugin/StateChangeSlice/PsShipOrder.res.mjs +69 -0
- package/tests/plugin/StateViewSlice/PsAnnotatedView.res +24 -0
- package/tests/plugin/StateViewSlice/PsAnnotatedView.res.mjs +94 -0
- package/tests/plugin/StateViewSlice/PsAvailableProductsView.res +18 -0
- package/tests/plugin/StateViewSlice/PsAvailableProductsView.res.mjs +69 -0
- package/tests/plugin/StateViewSlice/PsCustomersView.res +22 -0
- package/tests/plugin/StateViewSlice/PsCustomersView.res.mjs +69 -0
- package/tests/plugin/StateViewSlice/PsOrdersView.res +20 -0
- package/tests/plugin/StateViewSlice/PsOrdersView.res.mjs +81 -0
- package/tests/poc/StructuralSubtypingPoc.res +211 -0
- package/tests/poc/StructuralSubtypingPoc.res.mjs +61 -0
- package/tests/querydb/QueryDbFixtures.res +65 -0
- package/tests/querydb/QueryDbFixtures.res.mjs +135 -0
- package/tests/querydb/QueryDbOperationsTest.res +94 -0
- package/tests/querydb/QueryDbOperationsTest.res.mjs +168 -0
- package/tests/sideeffecthandler/SideEffectHandlerCallbackTest.res +56 -0
- package/tests/sideeffecthandler/SideEffectHandlerCallbackTest.res.mjs +77 -0
- package/tests/sideeffecthandler/SideEffectHandlerFixtures.res +96 -0
- package/tests/sideeffecthandler/SideEffectHandlerFixtures.res.mjs +139 -0
- package/tests/util/CsvStreamTest.res +54 -0
- package/tests/util/CsvStreamTest.res.mjs +51 -0
- package/tests/util/LruTest.res +73 -0
- package/tests/util/LruTest.res.mjs +105 -0
- package/tests/util/MetricsTest.res +36 -0
- package/tests/util/MetricsTest.res.mjs +53 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
module type CounterOps = {
|
|
2
|
+
let publishJsons: CommandTopic.publishJsons
|
|
3
|
+
let queryEngine: Reventless.QueryEngine.operations
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
module type CounterHandler = {
|
|
7
|
+
let commonEventsHandler: array<JSON.t> => promise<(
|
|
8
|
+
promise<array<Message.commandJson>>,
|
|
9
|
+
array<Counter.action>,
|
|
10
|
+
)>
|
|
11
|
+
let handleCounterEvents: Counter.jsonEventsHandler
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module MakeCounterHandler = (
|
|
15
|
+
Target: Reventless.EventMapping.Target,
|
|
16
|
+
Mappings: EventMapper.Mappings with module Target := Target,
|
|
17
|
+
Ops: CounterOps,
|
|
18
|
+
): CounterHandler => {
|
|
19
|
+
let target = Target.name
|
|
20
|
+
|
|
21
|
+
// Pair each mapping with the variant TAGs it declares via Source.eventSchema.
|
|
22
|
+
// Used to pre-filter incoming envelopes by TAG before attempting decode —
|
|
23
|
+
// sibling variants on the same source aggregate that this mapping does not
|
|
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
|
+
))
|
|
29
|
+
|
|
30
|
+
// Looks up the event mapping for a given event JSON by matching the source service name
|
|
31
|
+
// from the event's meta against the registered Mapping modules.
|
|
32
|
+
let findMapping = (mappingsWithTags, eventJson') => {
|
|
33
|
+
eventJson'
|
|
34
|
+
->JSON.Decode.object
|
|
35
|
+
->Option.flatMap(eventObj' => {
|
|
36
|
+
switch eventObj'
|
|
37
|
+
->Dict.get("meta")
|
|
38
|
+
->Option.map(metaJson => metaJson->Message.decode(Message.metaSchema)) {
|
|
39
|
+
| Some(eventMeta) =>
|
|
40
|
+
let source = eventMeta.service
|
|
41
|
+
let entry =
|
|
42
|
+
mappingsWithTags->Array.find(((module(Mapping: Mappings.Mapping), _)) =>
|
|
43
|
+
Mapping.Source.name == source
|
|
44
|
+
)
|
|
45
|
+
switch entry {
|
|
46
|
+
| None =>
|
|
47
|
+
EffectLogger.logInfo(~comp="EventMapper", `map: No mapping ${source} -> ${target} found`)->Effect.runSync
|
|
48
|
+
None
|
|
49
|
+
| Some((mapping, acceptedTags)) =>
|
|
50
|
+
module Mapping = unpack(mapping)
|
|
51
|
+
let source = Mapping.Source.name
|
|
52
|
+
EffectLogger.logInfo(~comp="EventMapper", `map: found mapping ${source} -> ${target}`)->Effect.runSync
|
|
53
|
+
Some((eventObj', eventMeta, mapping, acceptedTags))
|
|
54
|
+
}
|
|
55
|
+
| None =>
|
|
56
|
+
EffectLogger.logError(
|
|
57
|
+
~comp="EventMapper",
|
|
58
|
+
`findMapping: Invalid JSON object: ${eventJson'->JSON.stringify}`,
|
|
59
|
+
)->Effect.runSync
|
|
60
|
+
None
|
|
61
|
+
| exception err =>
|
|
62
|
+
let errMsg =
|
|
63
|
+
err->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("unknown")
|
|
64
|
+
EffectLogger.logError(
|
|
65
|
+
~comp="EventMapper",
|
|
66
|
+
`findMapping: Couldn't decode meta: ${errMsg}`,
|
|
67
|
+
)->Effect.runSync
|
|
68
|
+
None
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
type action =
|
|
74
|
+
| Counter(Counter.action)
|
|
75
|
+
| Publisher(promise<array<Message.commandJson>>)
|
|
76
|
+
|
|
77
|
+
let createCommandJson = (~delay=?, id, meta, command) => {
|
|
78
|
+
Message.id: id->Target.Id.toString,
|
|
79
|
+
// Derive a child meta from the source event:
|
|
80
|
+
// - fresh msgId + time
|
|
81
|
+
// - causationId = source event's msgId
|
|
82
|
+
// - service overridden to the target's name (this command is being routed to Target)
|
|
83
|
+
// - correlationId / ip / user / traceparent / schemaVersion / headers inherited
|
|
84
|
+
meta: Message.deriveMeta(~parent=meta, ~service=Target.name),
|
|
85
|
+
commandJson: command->Message.encode(Target.commandSchema),
|
|
86
|
+
?delay,
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Converts high-level EventMapping actions into concrete Publisher/Counter actions,
|
|
90
|
+
// stamping each with the event's meta (service name, correlation ID, timestamps).
|
|
91
|
+
let processMappingActions = (actions, eventMeta) =>
|
|
92
|
+
actions->Array.map(action =>
|
|
93
|
+
switch action {
|
|
94
|
+
| Reventless.EventMapping.Publish(id, command) =>
|
|
95
|
+
Publisher([createCommandJson(id, eventMeta, command)]->Promise.resolve)
|
|
96
|
+
| PublishDelayed(id, command, delay) =>
|
|
97
|
+
Publisher([createCommandJson(~delay, id, eventMeta, command)]->Promise.resolve)
|
|
98
|
+
| PublishAsync(promise) =>
|
|
99
|
+
let toCommandJson = async promise =>
|
|
100
|
+
{await promise}->Array.map(((id, command)) => createCommandJson(id, eventMeta, command))
|
|
101
|
+
Publisher(promise->toCommandJson)
|
|
102
|
+
| AddToCounterTarget({counterId, target}) =>
|
|
103
|
+
Counter(
|
|
104
|
+
AddToCounterTarget({
|
|
105
|
+
counterId,
|
|
106
|
+
target,
|
|
107
|
+
targetRef: eventMeta.correlationId,
|
|
108
|
+
}),
|
|
109
|
+
)
|
|
110
|
+
| Count(counterId) => Counter(Count({counterId, reference: eventMeta.correlationId, inc: 1}))
|
|
111
|
+
| CountMulti(counterId, inc) =>
|
|
112
|
+
Counter(Count({counterId, reference: eventMeta.correlationId, inc}))
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
// Shared event processing logic used by both Counter and EventCollector handlers.
|
|
117
|
+
// For each event: finds the mapping, decodes id+event, runs Mapping.map (EventMapping), then splits
|
|
118
|
+
// the resulting actions into (publisherEntries, counterActions).
|
|
119
|
+
let commonEventsHandler = async eventsJson' => {
|
|
120
|
+
let eventsCount = eventsJson'->Array.length
|
|
121
|
+
let (publisherActions, counterActions) =
|
|
122
|
+
eventsJson'
|
|
123
|
+
->Array.mapWithIndex((eventJson', idx) => {
|
|
124
|
+
let idx = idx + 1
|
|
125
|
+
EffectLogger.logInfo(
|
|
126
|
+
~comp="EventMapper",
|
|
127
|
+
`eventsHandler: incoming event ${idx->Int.toString}/${eventsCount->Int.toString}: ${LogFormat.event'JsonToLogMessage(
|
|
128
|
+
eventJson',
|
|
129
|
+
)}`,
|
|
130
|
+
)->Effect.runSync
|
|
131
|
+
switch findMapping(mappingsWithTags, eventJson') {
|
|
132
|
+
// TODO: support multiple mappings for the same source
|
|
133
|
+
| Some((eventObj, eventMeta, mapping, acceptedTags)) =>
|
|
134
|
+
module Mapping = unpack(mapping)
|
|
135
|
+
// Pre-filter by TAG: sibling variants from the same source aggregate
|
|
136
|
+
// that this mapping does not declare are not its concern — skip
|
|
137
|
+
// silently with no decode attempt. Real decode failures on declared
|
|
138
|
+
// variants still throw and are logged below.
|
|
139
|
+
let tag =
|
|
140
|
+
eventObj
|
|
141
|
+
->Dict.get("event")
|
|
142
|
+
->Option.map(Message.variantNameOfJson)
|
|
143
|
+
->Option.getOr("unknown")
|
|
144
|
+
if !(acceptedTags->Array.includes(tag)) {
|
|
145
|
+
None
|
|
146
|
+
} else {
|
|
147
|
+
try {
|
|
148
|
+
let idDecoded =
|
|
149
|
+
eventObj
|
|
150
|
+
->Dict.get("id")
|
|
151
|
+
->Option.map(id => id->Message.decode(Mapping.Source.Id.schema))
|
|
152
|
+
let eventDecoded =
|
|
153
|
+
eventObj
|
|
154
|
+
->Dict.get("event")
|
|
155
|
+
->Option.map(event => event->Message.decode(Mapping.Source.eventSchema))
|
|
156
|
+
|
|
157
|
+
switch (idDecoded, eventDecoded) {
|
|
158
|
+
| (Some(eventId), Some(event)) =>
|
|
159
|
+
Mapping.map(eventId, event, Ops.queryEngine)->processMappingActions(eventMeta)->Some
|
|
160
|
+
| _ =>
|
|
161
|
+
EffectLogger.logError(
|
|
162
|
+
~comp="EventMapper",
|
|
163
|
+
`map: Invalid event: ${eventJson'->JSON.stringify}`,
|
|
164
|
+
)->Effect.runSync
|
|
165
|
+
None
|
|
166
|
+
}
|
|
167
|
+
} catch {
|
|
168
|
+
| err =>
|
|
169
|
+
let errMsg =
|
|
170
|
+
err->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("unknown")
|
|
171
|
+
EffectLogger.logError(
|
|
172
|
+
~comp="EventMapper",
|
|
173
|
+
`map: Couldn't decode event: ${eventJson'->JSON.stringify} ${errMsg}`,
|
|
174
|
+
)->Effect.runSync
|
|
175
|
+
None
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
| None => None
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
->Array.filterMap(entry => entry)
|
|
182
|
+
->Array.flat
|
|
183
|
+
->Array.partition(resultType =>
|
|
184
|
+
switch resultType {
|
|
185
|
+
| Publisher(_) => true
|
|
186
|
+
| Counter(_) => false
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
let publisherEntries =
|
|
190
|
+
(
|
|
191
|
+
await publisherActions
|
|
192
|
+
->Array.map(action =>
|
|
193
|
+
switch action {
|
|
194
|
+
| Publisher(entries) => entries
|
|
195
|
+
| Counter(_) => JsError.throwWithMessage("Invalid EventMapper action")
|
|
196
|
+
}
|
|
197
|
+
)
|
|
198
|
+
->Promise.all
|
|
199
|
+
)
|
|
200
|
+
->Array.flat
|
|
201
|
+
->Promise.resolve
|
|
202
|
+
let counterActions = counterActions->Array.map(x =>
|
|
203
|
+
switch x {
|
|
204
|
+
| Counter(action) => action
|
|
205
|
+
| Publisher(_) => JsError.throwWithMessage("Invalid EventMapper action")
|
|
206
|
+
}
|
|
207
|
+
)
|
|
208
|
+
(publisherEntries, counterActions)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Counter stream handler — maps events via commonEventsHandler, rejects counter actions
|
|
212
|
+
// (counter-to-counter mapping is not allowed), and publishes generated commands.
|
|
213
|
+
let handleCounterEvents: Counter.jsonEventsHandler = stream =>
|
|
214
|
+
stream->Stream.runForEach(eventJson' =>
|
|
215
|
+
Effect.promise(() => commonEventsHandler([eventJson']))
|
|
216
|
+
->Effect.tap(((_, countActions)) =>
|
|
217
|
+
if countActions->Array.length > 0 {
|
|
218
|
+
EffectLogger.logError(
|
|
219
|
+
~comp="EventMapper",
|
|
220
|
+
"handleCounterEvents: Counter actions are not allowed in Count mapping!",
|
|
221
|
+
)
|
|
222
|
+
} else {
|
|
223
|
+
Effect.succeed()
|
|
224
|
+
}
|
|
225
|
+
)
|
|
226
|
+
->Effect.flatMap(((publisherEntries, _)) =>
|
|
227
|
+
Effect.promise(() => publisherEntries)
|
|
228
|
+
->Effect.flatMap(entries => Effect.promise(() => Ops.publishJsons(entries)))
|
|
229
|
+
)
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
module type EventCollectorOps = {
|
|
234
|
+
let publishJsons: CommandTopic.publishJsons
|
|
235
|
+
let count: Counter.count
|
|
236
|
+
let addToCounterTarget: Counter.addToCounterTarget
|
|
237
|
+
let commonEventsHandler: array<JSON.t> => promise<(
|
|
238
|
+
promise<array<Message.commandJson>>,
|
|
239
|
+
array<Counter.action>,
|
|
240
|
+
)>
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
module type EventCollectorHandler = {
|
|
244
|
+
let handleJsonEvents: EventCollector.jsonEventsHandler
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
module MakeEventCollectorHandler = (Ops: EventCollectorOps): EventCollectorHandler => {
|
|
248
|
+
let countRetrySchedule =
|
|
249
|
+
Schedule.exponential(Duration.millis(1000))
|
|
250
|
+
->Schedule.jittered
|
|
251
|
+
->Schedule.intersect(Schedule.recurs(10))
|
|
252
|
+
|
|
253
|
+
// Applies counter increments to the QueryDb with retry on failure.
|
|
254
|
+
let doCount = countItems =>
|
|
255
|
+
switch countItems->Array.length {
|
|
256
|
+
| 0 => Effect.succeed()
|
|
257
|
+
| _ =>
|
|
258
|
+
Effect.tryPromise(
|
|
259
|
+
~catch=e => Util.Error.messageFromUnknown(e, "unknown"),
|
|
260
|
+
() => Ops.count(countItems),
|
|
261
|
+
)
|
|
262
|
+
->Effect.retry(countRetrySchedule)
|
|
263
|
+
->Effect.catchAll(errMsg =>
|
|
264
|
+
EffectLogger.logError(~comp=__MODULE__, `doCount: count error after retries: ${errMsg}`)
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// EventCollector stream handler — maps events via commonEventsHandler, then:
|
|
269
|
+
// 1. Applies counter increments (with retry)
|
|
270
|
+
// 2. Registers counter targets
|
|
271
|
+
// 3. Publishes generated commands to the target aggregate
|
|
272
|
+
let handleJsonEvents: EventCollector.jsonEventsHandler = stream =>
|
|
273
|
+
stream->Stream.runForEach(eventJson' =>
|
|
274
|
+
Effect.promise(() => Ops.commonEventsHandler([eventJson']))
|
|
275
|
+
->Effect.flatMap(((publisherEntries, counterActions)) => {
|
|
276
|
+
let (countActions, addToCounterTargetActions) = counterActions->Array.partition(
|
|
277
|
+
x =>
|
|
278
|
+
switch x {
|
|
279
|
+
| Counter.Count(_) => true
|
|
280
|
+
| AddToCounterTarget(_) => false
|
|
281
|
+
},
|
|
282
|
+
)
|
|
283
|
+
let countItems = countActions->Array.filterMap(
|
|
284
|
+
countAction =>
|
|
285
|
+
switch countAction {
|
|
286
|
+
| Count(countItem) => Some(countItem)
|
|
287
|
+
| _ => None
|
|
288
|
+
},
|
|
289
|
+
)
|
|
290
|
+
EffectLogger.logInfo(
|
|
291
|
+
~comp="EventMapper",
|
|
292
|
+
`eventCollectorEventsHandler: countItems: ${countItems
|
|
293
|
+
->Array.length
|
|
294
|
+
->Int.toString}`,
|
|
295
|
+
)
|
|
296
|
+
->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
|
+
}
|
|
313
|
+
),
|
|
314
|
+
{"concurrency": "unbounded"},
|
|
315
|
+
)->Effect.map(_ => ())
|
|
316
|
+
)
|
|
317
|
+
->Effect.flatMap(_ =>
|
|
318
|
+
Effect.promise(() => publisherEntries)
|
|
319
|
+
->Effect.flatMap(entries => Effect.promise(() => Ops.publishJsons(entries)))
|
|
320
|
+
)
|
|
321
|
+
})
|
|
322
|
+
)
|
|
323
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Effect from "@reventlessdev/rescript-effect/src/Effect.res.mjs";
|
|
4
|
+
import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.js";
|
|
5
|
+
import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
|
|
6
|
+
import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
|
|
7
|
+
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
8
|
+
import * as Effect$1 from "effect/Effect";
|
|
9
|
+
import * as Stream from "effect/Stream";
|
|
10
|
+
import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
|
|
11
|
+
import * as Duration from "effect/Duration";
|
|
12
|
+
import * as Schedule from "effect/Schedule";
|
|
13
|
+
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
14
|
+
import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
|
|
15
|
+
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
16
|
+
import * as Message$ReventlessCore from "../../Message.res.mjs";
|
|
17
|
+
import * as LogFormat$ReventlessCore from "../../util/LogFormat.res.mjs";
|
|
18
|
+
import * as Util_Error$ReventlessCore from "../../util/Util_Error.res.mjs";
|
|
19
|
+
import * as EffectLogger$ReventlessCore from "../../util/EffectLogger.res.mjs";
|
|
20
|
+
|
|
21
|
+
function MakeCounterHandler(Target) {
|
|
22
|
+
return Mappings => (Ops => {
|
|
23
|
+
let target = Target.name;
|
|
24
|
+
let mappingsWithTags = Mappings.mappings.map(M => [
|
|
25
|
+
M,
|
|
26
|
+
DcbTag$Reventless.extractAllVariantNames(M.Source.eventSchema)
|
|
27
|
+
]);
|
|
28
|
+
let findMapping = (mappingsWithTags, eventJson$p) => Stdlib_Option.flatMap(Stdlib_JSON.Decode.object(eventJson$p), eventObj$p => {
|
|
29
|
+
let eventMeta;
|
|
30
|
+
try {
|
|
31
|
+
eventMeta = Stdlib_Option.map(eventObj$p["meta"], metaJson => Message$ReventlessCore.decode(metaJson, Message$ReventlessCore.metaSchema));
|
|
32
|
+
} catch (raw_err) {
|
|
33
|
+
let err = Primitive_exceptions.internalToException(raw_err);
|
|
34
|
+
let errMsg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(err), Stdlib_JsExn.message), "unknown");
|
|
35
|
+
Effect$1.runSync(EffectLogger$ReventlessCore.logError("EventMapper", undefined, `findMapping: Couldn't decode meta: ` + errMsg));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (eventMeta !== undefined) {
|
|
39
|
+
let source = eventMeta.service;
|
|
40
|
+
let entry = mappingsWithTags.find(param => param[0].Source.name === source);
|
|
41
|
+
if (entry !== undefined) {
|
|
42
|
+
let mapping = entry[0];
|
|
43
|
+
let source$1 = mapping.Source.name;
|
|
44
|
+
Effect$1.runSync(EffectLogger$ReventlessCore.logInfo("EventMapper", undefined, `map: found mapping ` + source$1 + ` -> ` + target));
|
|
45
|
+
return [
|
|
46
|
+
eventObj$p,
|
|
47
|
+
eventMeta,
|
|
48
|
+
mapping,
|
|
49
|
+
entry[1]
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
Effect$1.runSync(EffectLogger$ReventlessCore.logInfo("EventMapper", undefined, `map: No mapping ` + source + ` -> ` + target + ` found`));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
Effect$1.runSync(EffectLogger$ReventlessCore.logError("EventMapper", undefined, `findMapping: Invalid JSON object: ` + JSON.stringify(eventJson$p)));
|
|
56
|
+
});
|
|
57
|
+
let createCommandJson = (delay, id, meta, command) => ({
|
|
58
|
+
id: Target.Id.toString(id),
|
|
59
|
+
meta: Message$ReventlessCore.deriveMeta(meta, Target.name),
|
|
60
|
+
commandJson: Message$ReventlessCore.encode(command, Target.commandSchema),
|
|
61
|
+
delay: delay
|
|
62
|
+
});
|
|
63
|
+
let processMappingActions = (actions, eventMeta) => actions.map(action => {
|
|
64
|
+
switch (action.TAG) {
|
|
65
|
+
case "Publish" :
|
|
66
|
+
return {
|
|
67
|
+
TAG: "Publisher",
|
|
68
|
+
_0: Promise.resolve([createCommandJson(undefined, action._0, eventMeta, action._1)])
|
|
69
|
+
};
|
|
70
|
+
case "PublishDelayed" :
|
|
71
|
+
return {
|
|
72
|
+
TAG: "Publisher",
|
|
73
|
+
_0: Promise.resolve([createCommandJson(action._2, action._0, eventMeta, action._1)])
|
|
74
|
+
};
|
|
75
|
+
case "PublishAsync" :
|
|
76
|
+
let toCommandJson = async promise => (await promise).map(param => createCommandJson(undefined, param[0], eventMeta, param[1]));
|
|
77
|
+
return {
|
|
78
|
+
TAG: "Publisher",
|
|
79
|
+
_0: toCommandJson(action._0)
|
|
80
|
+
};
|
|
81
|
+
case "AddToCounterTarget" :
|
|
82
|
+
let match = action._0;
|
|
83
|
+
return {
|
|
84
|
+
TAG: "Counter",
|
|
85
|
+
_0: {
|
|
86
|
+
TAG: "AddToCounterTarget",
|
|
87
|
+
_0: {
|
|
88
|
+
counterId: match.counterId,
|
|
89
|
+
target: match.target,
|
|
90
|
+
targetRef: eventMeta.correlationId
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
case "Count" :
|
|
95
|
+
return {
|
|
96
|
+
TAG: "Counter",
|
|
97
|
+
_0: {
|
|
98
|
+
TAG: "Count",
|
|
99
|
+
_0: {
|
|
100
|
+
counterId: action._0,
|
|
101
|
+
reference: eventMeta.correlationId,
|
|
102
|
+
inc: 1
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
case "CountMulti" :
|
|
107
|
+
return {
|
|
108
|
+
TAG: "Counter",
|
|
109
|
+
_0: {
|
|
110
|
+
TAG: "Count",
|
|
111
|
+
_0: {
|
|
112
|
+
counterId: action._0,
|
|
113
|
+
reference: eventMeta.correlationId,
|
|
114
|
+
inc: action._1
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
let commonEventsHandler = async eventsJson$p => {
|
|
121
|
+
let eventsCount = eventsJson$p.length;
|
|
122
|
+
let match = Stdlib_Array.partition(Stdlib_Array.filterMap(eventsJson$p.map((eventJson$p, idx) => {
|
|
123
|
+
let idx$1 = idx + 1 | 0;
|
|
124
|
+
Effect$1.runSync(EffectLogger$ReventlessCore.logInfo("EventMapper", undefined, `eventsHandler: incoming event ` + idx$1.toString() + `/` + eventsCount.toString() + `: ` + LogFormat$ReventlessCore.event$pJsonToLogMessage(eventJson$p)));
|
|
125
|
+
let match = findMapping(mappingsWithTags, eventJson$p);
|
|
126
|
+
if (match === undefined) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
let mapping = match[2];
|
|
130
|
+
let eventObj = match[0];
|
|
131
|
+
let tag = Stdlib_Option.getOr(Stdlib_Option.map(eventObj["event"], Message$ReventlessCore.variantNameOfJson), "unknown");
|
|
132
|
+
if (!match[3].includes(tag)) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
let idDecoded = Stdlib_Option.map(eventObj["id"], id => Message$ReventlessCore.decode(id, mapping.Source.Id.schema));
|
|
137
|
+
let eventDecoded = Stdlib_Option.map(eventObj["event"], event => Message$ReventlessCore.decode(event, mapping.Source.eventSchema));
|
|
138
|
+
let exit = 0;
|
|
139
|
+
if (idDecoded !== undefined) {
|
|
140
|
+
if (eventDecoded !== undefined) {
|
|
141
|
+
return processMappingActions(mapping.map(Primitive_option.valFromOption(idDecoded), Primitive_option.valFromOption(eventDecoded), Ops.queryEngine), match[1]);
|
|
142
|
+
}
|
|
143
|
+
exit = 1;
|
|
144
|
+
} else {
|
|
145
|
+
exit = 1;
|
|
146
|
+
}
|
|
147
|
+
if (exit === 1) {
|
|
148
|
+
Effect$1.runSync(EffectLogger$ReventlessCore.logError("EventMapper", undefined, `map: Invalid event: ` + JSON.stringify(eventJson$p)));
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
} catch (raw_err) {
|
|
152
|
+
let err = Primitive_exceptions.internalToException(raw_err);
|
|
153
|
+
let errMsg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(err), Stdlib_JsExn.message), "unknown");
|
|
154
|
+
Effect$1.runSync(EffectLogger$ReventlessCore.logError("EventMapper", undefined, `map: Couldn't decode event: ` + JSON.stringify(eventJson$p) + ` ` + errMsg));
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
}), entry => entry).flat(), resultType => resultType.TAG !== "Counter");
|
|
158
|
+
let publisherEntries = Promise.resolve((await Promise.all(match[0].map(action => {
|
|
159
|
+
if (action.TAG === "Counter") {
|
|
160
|
+
return Stdlib_JsError.throwWithMessage("Invalid EventMapper action");
|
|
161
|
+
} else {
|
|
162
|
+
return action._0;
|
|
163
|
+
}
|
|
164
|
+
}))).flat());
|
|
165
|
+
let counterActions = match[1].map(x => {
|
|
166
|
+
if (x.TAG === "Counter") {
|
|
167
|
+
return x._0;
|
|
168
|
+
} else {
|
|
169
|
+
return Stdlib_JsError.throwWithMessage("Invalid EventMapper action");
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
return [
|
|
173
|
+
publisherEntries,
|
|
174
|
+
counterActions
|
|
175
|
+
];
|
|
176
|
+
};
|
|
177
|
+
let handleCounterEvents = stream => Stream.runForEach(stream, eventJson$p => Effect$1.flatMap(Effect$1.tap(Effect$1.promise(() => commonEventsHandler([eventJson$p])), param => {
|
|
178
|
+
if (param[1].length !== 0) {
|
|
179
|
+
return EffectLogger$ReventlessCore.logError("EventMapper", undefined, "handleCounterEvents: Counter actions are not allowed in Count mapping!");
|
|
180
|
+
} else {
|
|
181
|
+
return Effect$1.succeed();
|
|
182
|
+
}
|
|
183
|
+
}), param => {
|
|
184
|
+
let publisherEntries = param[0];
|
|
185
|
+
return Effect$1.flatMap(Effect$1.promise(() => publisherEntries), entries => Effect$1.promise(() => Ops.publishJsons(entries)));
|
|
186
|
+
}));
|
|
187
|
+
return {
|
|
188
|
+
commonEventsHandler: commonEventsHandler,
|
|
189
|
+
handleCounterEvents: handleCounterEvents
|
|
190
|
+
};
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function MakeEventCollectorHandler(Ops) {
|
|
195
|
+
let countRetrySchedule = Schedule.intersect(Schedule.jittered(Schedule.exponential(Duration.millis(1000))), Schedule.recurs(10));
|
|
196
|
+
let handleJsonEvents = stream => Stream.runForEach(stream, eventJson$p => Effect$1.flatMap(Effect$1.promise(() => Ops.commonEventsHandler([eventJson$p])), param => {
|
|
197
|
+
let publisherEntries = param[0];
|
|
198
|
+
let match = Stdlib_Array.partition(param[1], x => x.TAG === "Count");
|
|
199
|
+
let addToCounterTargetActions = match[1];
|
|
200
|
+
let countItems = Stdlib_Array.filterMap(match[0], countAction => {
|
|
201
|
+
if (countAction.TAG === "Count") {
|
|
202
|
+
return countAction._0;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
return Effect$1.flatMap(Effect$1.flatMap(Effect$1.flatMap(Effect$1.flatMap(EffectLogger$ReventlessCore.logInfo("EventMapper", undefined, `eventCollectorEventsHandler: countItems: ` + countItems.length.toString()), () => {
|
|
206
|
+
let match = countItems.length;
|
|
207
|
+
if (match !== 0) {
|
|
208
|
+
return Effect$1.catchAll(Effect$1.retry(Effect.tryPromise(e => Util_Error$ReventlessCore.messageFromUnknown(e, "unknown"), () => Ops.count(countItems)), countRetrySchedule), errMsg => EffectLogger$ReventlessCore.logError("EventMapper_Callback-ReventlessCore", undefined, `doCount: count error after retries: ` + errMsg));
|
|
209
|
+
} else {
|
|
210
|
+
return Effect$1.succeed();
|
|
211
|
+
}
|
|
212
|
+
}), () => EffectLogger$ReventlessCore.logInfo("EventMapper", undefined, `eventCollectorEventsHandler: addToCounterTargetActions: ` + Stdlib_Option.getOr(JSON.stringify(addToCounterTargetActions), "[]"))), () => Effect$1.map(Effect$1.all(Stdlib_Array.filterMap(addToCounterTargetActions, x => {
|
|
213
|
+
if (x.TAG === "Count") {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
let counterTarget = x._0;
|
|
217
|
+
return Primitive_option.some(Effect$1.promise(() => Ops.addToCounterTarget(counterTarget)));
|
|
218
|
+
}), {
|
|
219
|
+
concurrency: "unbounded"
|
|
220
|
+
}), param => {})), () => Effect$1.flatMap(Effect$1.promise(() => publisherEntries), entries => Effect$1.promise(() => Ops.publishJsons(entries))));
|
|
221
|
+
}));
|
|
222
|
+
return {
|
|
223
|
+
handleJsonEvents: handleJsonEvents
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export {
|
|
228
|
+
MakeCounterHandler,
|
|
229
|
+
MakeEventCollectorHandler,
|
|
230
|
+
}
|
|
231
|
+
/* Effect Not a pure module */
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
let log = Logger.fromEnv()
|
|
2
|
+
|
|
3
|
+
let componentType = ComponentType.EventTopic
|
|
4
|
+
|
|
5
|
+
type outputs = ReventlessInfra.EventTopic.outputs
|
|
6
|
+
type allOutputs = ReventlessInfra.EventTopic.allOutputs
|
|
7
|
+
|
|
8
|
+
type t
|
|
9
|
+
|
|
10
|
+
type publish<'id, 'event> = array<Message.event'<'id, 'event>> => promise<unit>
|
|
11
|
+
type publishJson = ReventlessInfra.EventTopic.publishJson
|
|
12
|
+
type publishJsonStream = ReventlessInfra.EventTopic.publishJsonStream
|
|
13
|
+
|
|
14
|
+
exception NotPublishedToPublisher(exn)
|
|
15
|
+
|
|
16
|
+
module type T = {
|
|
17
|
+
module Spec: ReventlessInfra.EventTopic.T
|
|
18
|
+
|
|
19
|
+
type publish = publish<Spec.Id.t, Spec.event>
|
|
20
|
+
type operations = {
|
|
21
|
+
publish: publish,
|
|
22
|
+
publishJson: publishJson,
|
|
23
|
+
publishJsonStream: ReventlessInfra.EventTopic.publishJsonStream,
|
|
24
|
+
}
|
|
25
|
+
type component = Component.t<t, outputs, operations>
|
|
26
|
+
|
|
27
|
+
let make: (
|
|
28
|
+
~name: string,
|
|
29
|
+
~storageResources: array<ReventlessInfra.Adapter.resource>,
|
|
30
|
+
~opts: Pulumi.ComponentResource.options=?,
|
|
31
|
+
) => component
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let toResolvedOutputs = (
|
|
35
|
+
outputs: outputs,
|
|
36
|
+
): Pulumi.Output.t<ReventlessInterop.EventTopic.resolvedOutputs> =>
|
|
37
|
+
outputs.resources
|
|
38
|
+
->Adapter.resourcesToInterop
|
|
39
|
+
->Pulumi.Output.apply(resources => {
|
|
40
|
+
let resolved: ReventlessInterop.EventTopic.resolvedOutputs = {resources: resources}
|
|
41
|
+
resolved
|
|
42
|
+
})
|
|
43
|
+
let allOutputsToResources = allOutputs =>
|
|
44
|
+
allOutputs
|
|
45
|
+
->Dict.valuesToArray
|
|
46
|
+
->Array.map((eventTopic: outputs) => eventTopic.resources)
|
|
47
|
+
->Array.flat
|
|
48
|
+
|
|
49
|
+
let filter = (allEventTopics: allOutputs, sourceNames) =>
|
|
50
|
+
sourceNames
|
|
51
|
+
->Belt.Set.String.toArray
|
|
52
|
+
->Array.filterMap(sourceName =>
|
|
53
|
+
allEventTopics->Dict.get(sourceName)->Option.map(eventTopic => (sourceName, eventTopic))
|
|
54
|
+
)
|
|
55
|
+
->Dict.fromArray
|
|
56
|
+
|
|
57
|
+
let log = (eventTopics, description) => {
|
|
58
|
+
let _ =
|
|
59
|
+
eventTopics
|
|
60
|
+
->Dict.mapValues((eventTopic: outputs) => eventTopic.resources->Array.getUnsafe(0))
|
|
61
|
+
->Dict.toArray
|
|
62
|
+
->Array.map(((name, {service})) =>
|
|
63
|
+
service->Pulumi.Output.apply(service => `${name}(${service})`)
|
|
64
|
+
)
|
|
65
|
+
->Pulumi.Output.all
|
|
66
|
+
->Pulumi.Output.apply(topics =>
|
|
67
|
+
log.info(~comp="EventTopic", `${description}: ${topics->Array.joinUnsafe(", ")}`)
|
|
68
|
+
)
|
|
69
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Stdlib_Dict from "@rescript/runtime/lib/es6/Stdlib_Dict.js";
|
|
4
|
+
import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
|
|
5
|
+
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
6
|
+
import * as Pulumi from "@pulumi/pulumi";
|
|
7
|
+
import * as Belt_SetString from "@rescript/runtime/lib/es6/Belt_SetString.js";
|
|
8
|
+
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
9
|
+
import * as Logger$ReventlessCore from "../../util/Logger.res.mjs";
|
|
10
|
+
import * as Adapter$ReventlessCore from "../../adapter/Adapter.res.mjs";
|
|
11
|
+
|
|
12
|
+
let log = Logger$ReventlessCore.fromEnv();
|
|
13
|
+
|
|
14
|
+
let NotPublishedToPublisher = /* @__PURE__ */Primitive_exceptions.create("EventTopic-ReventlessCore.NotPublishedToPublisher");
|
|
15
|
+
|
|
16
|
+
function toResolvedOutputs(outputs) {
|
|
17
|
+
return Adapter$ReventlessCore.resourcesToInterop(outputs.resources).apply(resources => ({
|
|
18
|
+
resources: resources
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function allOutputsToResources(allOutputs) {
|
|
23
|
+
return Object.values(allOutputs).map(eventTopic => eventTopic.resources).flat();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function filter(allEventTopics, sourceNames) {
|
|
27
|
+
return Object.fromEntries(Stdlib_Array.filterMap(Belt_SetString.toArray(sourceNames), sourceName => Stdlib_Option.map(allEventTopics[sourceName], eventTopic => [
|
|
28
|
+
sourceName,
|
|
29
|
+
eventTopic
|
|
30
|
+
])));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function log$1(eventTopics, description) {
|
|
34
|
+
Pulumi.all(Object.entries(Stdlib_Dict.mapValues(eventTopics, eventTopic => eventTopic.resources[0])).map(param => {
|
|
35
|
+
let name = param[0];
|
|
36
|
+
return param[1].service.apply(service => name + `(` + service + `)`);
|
|
37
|
+
})).apply(topics => log.info("EventTopic", undefined, description + `: ` + topics.join(", ")));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let componentType = "EventTopic";
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
componentType,
|
|
44
|
+
NotPublishedToPublisher,
|
|
45
|
+
toResolvedOutputs,
|
|
46
|
+
allOutputsToResources,
|
|
47
|
+
filter,
|
|
48
|
+
log$1 as log,
|
|
49
|
+
}
|
|
50
|
+
/* log Not a pure module */
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type publisher = {
|
|
2
|
+
resources: array<ReventlessInfra.Adapter.resource>,
|
|
3
|
+
publishJson: Pulumi.Output.t<EventTopic.publishJson>,
|
|
4
|
+
publishJsonStream: Pulumi.Output.t<ReventlessInfra.EventTopic.publishJsonStream>,
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
type publisherMaker = (
|
|
8
|
+
~name: string,
|
|
9
|
+
~storageResources: array<ReventlessInfra.Adapter.resource>,
|
|
10
|
+
~opts: Pulumi.CustomResourceOptions.t,
|
|
11
|
+
) => publisher
|
|
12
|
+
|
|
13
|
+
module type Publisher = {
|
|
14
|
+
let make: publisherMaker
|
|
15
|
+
}
|