@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,181 @@
|
|
|
1
|
+
// OutboundTranslationSlice builder — creates the TODO list QueryDb, EventCollector,
|
|
2
|
+
// and wires the event handler (Phase 1 + Phase 2) plus exposes translatePending.
|
|
3
|
+
//
|
|
4
|
+
// Follows the AutomationSlice_Builder pattern for adapter injection.
|
|
5
|
+
|
|
6
|
+
let log = Logger.fromEnv()
|
|
7
|
+
|
|
8
|
+
module Make = (
|
|
9
|
+
RuntimeEnvironment: Runtime.Environment,
|
|
10
|
+
QueryDbStorage: QueryDb_Adapter.Storage,
|
|
11
|
+
QueryDbResolvers: QueryDb_Adapter.Resolvers
|
|
12
|
+
with type api = QueryDbStorage.api
|
|
13
|
+
and type role = QueryDbStorage.role,
|
|
14
|
+
EventCollectorChannel: EventCollector_Adapter.Channel
|
|
15
|
+
with type runtimeParts = RuntimeEnvironment.parts,
|
|
16
|
+
EventCollectorRuntimeBuilder: EventCollectorRuntime_Builder.T
|
|
17
|
+
with module EventCollectorChannel = EventCollectorChannel,
|
|
18
|
+
Api: {
|
|
19
|
+
let api: unit => QueryDbStorage.api
|
|
20
|
+
let apiRole: unit => QueryDbStorage.role
|
|
21
|
+
},
|
|
22
|
+
) => {
|
|
23
|
+
let finish = EventCollectorRuntimeBuilder.finish
|
|
24
|
+
module Make = (
|
|
25
|
+
Spec: Reventless.OutboundTranslationSlice.Spec,
|
|
26
|
+
Translation: Reventless.OutboundTranslationSlice.Translation with module Spec := Spec,
|
|
27
|
+
): OutboundTranslationSlice.T => {
|
|
28
|
+
module Spec = Spec
|
|
29
|
+
module Translation = Translation
|
|
30
|
+
type component = OutboundTranslationSlice.component
|
|
31
|
+
|
|
32
|
+
module Callback = OutboundTranslationSlice_Callback.Make(Spec, Translation)
|
|
33
|
+
|
|
34
|
+
let queryDbName = Spec.name ++ "Todo"
|
|
35
|
+
|
|
36
|
+
// QueryDb for TODO list — stores todoRow keyed by string ID
|
|
37
|
+
module TodoQueryDbSpec = {
|
|
38
|
+
module Id = Reventless.Id.String
|
|
39
|
+
let name = queryDbName
|
|
40
|
+
let moduleUrl: string = %raw(`import.meta.url`)
|
|
41
|
+
type state = OutboundTranslationSlice_Callback.todoRow
|
|
42
|
+
let stateSchema = OutboundTranslationSlice_Callback.todoRowSchema
|
|
43
|
+
let config = Reventless.ReadModel.config()
|
|
44
|
+
let subIdConfig: option<Reventless.ReadModel.subIdConfig<state>> = None
|
|
45
|
+
let authorization: Reventless.Authorization.permission = AllowAuthenticated
|
|
46
|
+
let visibility: Reventless.Visibility.t = Public
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module SpecificQueryDb = QueryDb_Builder.Make(TodoQueryDbSpec, QueryDbStorage, QueryDbResolvers)
|
|
50
|
+
module SpecificEventCollector = EventCollector_Builder.Make(
|
|
51
|
+
RuntimeEnvironment,
|
|
52
|
+
EventCollectorChannel,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
let decoder = Reventless.DcbDecode.makeDecoder(Spec.consumedEventSchema)
|
|
56
|
+
|
|
57
|
+
let syncToQueryDb = async (queryDbOps: SpecificQueryDb.operations) => {
|
|
58
|
+
let items = Callback.todoItems->Dict.toArray
|
|
59
|
+
let _ = await items->Array.reduce(Promise.resolve(), async (prev, (id, row)) => {
|
|
60
|
+
let _ = await prev
|
|
61
|
+
let _ = await queryDbOps.save(
|
|
62
|
+
id->Reventless.Id.String.makeFromString,
|
|
63
|
+
row,
|
|
64
|
+
QueryDb.Overwrite,
|
|
65
|
+
None,
|
|
66
|
+
)
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let construct = (~dcbEventLog: DcbEventLog.component, ~publishJsons, self, _name) => {
|
|
71
|
+
let opts = {Pulumi.ComponentResource.parent: self->Component.toPulumiResource}
|
|
72
|
+
|
|
73
|
+
let queryDb = SpecificQueryDb.make(~api=Api.api(), ~apiRole=Api.apiRole(), ~opts)
|
|
74
|
+
|
|
75
|
+
let dcbEventTopicOutputs: EventTopic.outputs = (dcbEventLog->Component.outputs).eventTopic
|
|
76
|
+
let allEventTopics = Dict.fromArray([(Spec.name, dcbEventTopicOutputs)])
|
|
77
|
+
|
|
78
|
+
// Resolve publishJsons so it's available for Phase 2
|
|
79
|
+
let publishJsonsRef: ref<option<ReventlessInfra.CommandTopic.publishJsons>> = ref(None)
|
|
80
|
+
let _ = publishJsons->Pulumi.Output.apply(pj => {
|
|
81
|
+
publishJsonsRef := Some(pj)
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
let eventCollector =
|
|
85
|
+
queryDb
|
|
86
|
+
->Component.operations
|
|
87
|
+
->Pulumi.Output.apply(queryDbOps => {
|
|
88
|
+
let ec = SpecificEventCollector.make(~name=Spec.name, ~eventTopics=allEventTopics, ~opts)
|
|
89
|
+
|
|
90
|
+
let jsonEventsHandler: EventCollector.jsonEventsHandler = stream =>
|
|
91
|
+
stream
|
|
92
|
+
->Stream.mapEffect(json =>
|
|
93
|
+
Effect.sync(
|
|
94
|
+
() => {
|
|
95
|
+
let (eventType, dataDict) = json->Message.splitMessage
|
|
96
|
+
switch decoder.decode(~eventType, ~data=dataDict) {
|
|
97
|
+
| Some(event) => [event]
|
|
98
|
+
| None => []
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
->Stream.flatMap(events => Stream.fromIterable(events))
|
|
104
|
+
->Stream.runCollect
|
|
105
|
+
->Effect.flatMap(eventsArr =>
|
|
106
|
+
Effect.promise(
|
|
107
|
+
async () => {
|
|
108
|
+
// Phase 1: collect outbound items
|
|
109
|
+
Callback.phase1(eventsArr)
|
|
110
|
+
// Sync the post-phase-1 TODO state so consumers awaiting the
|
|
111
|
+
// originating publishEvent observe Pending rows immediately.
|
|
112
|
+
await syncToQueryDb(queryDbOps)
|
|
113
|
+
// Phase 2 must NOT be awaited here. If a translation publishes
|
|
114
|
+
// an inbound command whose downstream events fan back to this
|
|
115
|
+
// same topic, awaiting would self-deadlock the bus — same
|
|
116
|
+
// shape as AutomationSlice. Detach it; errors are logged.
|
|
117
|
+
switch publishJsonsRef.contents {
|
|
118
|
+
| Some(pj) =>
|
|
119
|
+
let _ =
|
|
120
|
+
Callback.phase2(pj)
|
|
121
|
+
->Promise.then(() => syncToQueryDb(queryDbOps))
|
|
122
|
+
->Promise.catch(exn => {
|
|
123
|
+
let errMsg =
|
|
124
|
+
exn
|
|
125
|
+
->JsExn.fromException
|
|
126
|
+
->Option.flatMap(JsExn.message)
|
|
127
|
+
->Option.getOr("unknown")
|
|
128
|
+
EffectLogger.logError(
|
|
129
|
+
~comp=`OutboundTranslationSlice(${Spec.name})`,
|
|
130
|
+
`detached phase 2 error: ${errMsg}`,
|
|
131
|
+
)->Effect.runSync
|
|
132
|
+
Promise.resolve()
|
|
133
|
+
})
|
|
134
|
+
| None =>
|
|
135
|
+
log.error(
|
|
136
|
+
~comp=`OutboundTranslationSlice(${Spec.name})`,
|
|
137
|
+
`publishJsons not yet resolved`,
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
)
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
let handler = SpecificEventCollector.makeHandler(~eventCollector=ec, ~jsonEventsHandler)
|
|
145
|
+
let resources = (queryDb->Component.outputs).resources
|
|
146
|
+
ec->EventCollectorRuntimeBuilder.forEventCollector(
|
|
147
|
+
~handler,
|
|
148
|
+
~eventTopics=allEventTopics,
|
|
149
|
+
~resources,
|
|
150
|
+
)
|
|
151
|
+
ec
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
self->Component.setOperations(
|
|
155
|
+
(eventCollector->Pulumi.Output.flatMap(ec => ec->Component.operations), publishJsons)
|
|
156
|
+
->Pulumi.Output.all2
|
|
157
|
+
->Pulumi.Output.apply(((ecOps, publishJsonsFn)) => {
|
|
158
|
+
let ops: OutboundTranslationSlice.operations = {
|
|
159
|
+
enqueueEvent: ecOps.enqueueEvent,
|
|
160
|
+
translatePending: async () => await Callback.phase2(publishJsonsFn),
|
|
161
|
+
}
|
|
162
|
+
ops
|
|
163
|
+
}),
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
let outputs: OutboundTranslationSlice.outputs = {
|
|
167
|
+
resources: dcbEventTopicOutputs.resources,
|
|
168
|
+
queryDb: queryDb->Component.outputs,
|
|
169
|
+
}
|
|
170
|
+
self->Component.setOutputs(outputs)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
let make = (~dcbEventLog, ~publishJsons, ~opts=?): OutboundTranslationSlice.component =>
|
|
174
|
+
Component.make(
|
|
175
|
+
~componentType=OutboundTranslationSlice.componentType->ComponentType.toString,
|
|
176
|
+
~name=Spec.name,
|
|
177
|
+
~construct=construct(~dcbEventLog, ~publishJsons, ...),
|
|
178
|
+
~opts,
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Stream from "@reventlessdev/rescript-effect/src/Stream.res.mjs";
|
|
4
|
+
import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
|
|
5
|
+
import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
|
|
6
|
+
import * as Id$Reventless from "@reventlessdev/reventless-spec/src/types/Id.res.mjs";
|
|
7
|
+
import * as Output$Pulumi from "@reventlessdev/rescript-pulumi-pulumi/src/Output.res.mjs";
|
|
8
|
+
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
import * as Stream$1 from "effect/Stream";
|
|
11
|
+
import * as Pulumi from "@pulumi/pulumi";
|
|
12
|
+
import * as Stdlib_Promise from "@rescript/runtime/lib/es6/Stdlib_Promise.js";
|
|
13
|
+
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
14
|
+
import * as DcbDecode$Reventless from "@reventlessdev/reventless-spec/src/components/DcbDecode.res.mjs";
|
|
15
|
+
import * as ReadModel$Reventless from "@reventlessdev/reventless-spec/src/components/ReadModel.res.mjs";
|
|
16
|
+
import * as Logger$ReventlessCore from "../../util/Logger.res.mjs";
|
|
17
|
+
import * as Message$ReventlessCore from "../../Message.res.mjs";
|
|
18
|
+
import * as Component$ReventlessCore from "../Component.res.mjs";
|
|
19
|
+
import * as EffectLogger$ReventlessCore from "../../util/EffectLogger.res.mjs";
|
|
20
|
+
import * as ComponentType$ReventlessCore from "../../ComponentType.res.mjs";
|
|
21
|
+
import * as QueryDb_Builder$ReventlessCore from "../QueryDb/QueryDb_Builder.res.mjs";
|
|
22
|
+
import * as EventCollector_Builder$ReventlessCore from "../EventCollector/EventCollector_Builder.res.mjs";
|
|
23
|
+
import * as OutboundTranslationSlice$ReventlessCore from "./OutboundTranslationSlice.res.mjs";
|
|
24
|
+
import * as OutboundTranslationSlice_Callback$ReventlessCore from "./OutboundTranslationSlice_Callback.res.mjs";
|
|
25
|
+
|
|
26
|
+
let log = Logger$ReventlessCore.fromEnv();
|
|
27
|
+
|
|
28
|
+
function Make(RuntimeEnvironment) {
|
|
29
|
+
return QueryDbStorage => (QueryDbResolvers => (EventCollectorChannel => (EventCollectorRuntimeBuilder => (Api => {
|
|
30
|
+
let Make = Spec => (Translation => {
|
|
31
|
+
let Callback = OutboundTranslationSlice_Callback$ReventlessCore.Make(Spec)(Translation);
|
|
32
|
+
let queryDbName = Spec.name + "Todo";
|
|
33
|
+
let moduleUrl = import.meta.url;
|
|
34
|
+
let config = ReadModel$Reventless.config(undefined, undefined, undefined);
|
|
35
|
+
let SpecificQueryDb = QueryDb_Builder$ReventlessCore.Make({
|
|
36
|
+
Id: Id$Reventless.$$String,
|
|
37
|
+
name: queryDbName,
|
|
38
|
+
moduleUrl: moduleUrl,
|
|
39
|
+
stateSchema: OutboundTranslationSlice_Callback$ReventlessCore.todoRowSchema,
|
|
40
|
+
config: config,
|
|
41
|
+
subIdConfig: undefined,
|
|
42
|
+
authorization: "AllowAuthenticated",
|
|
43
|
+
visibility: "Public"
|
|
44
|
+
})(QueryDbStorage)(QueryDbResolvers);
|
|
45
|
+
let SpecificEventCollector = EventCollector_Builder$ReventlessCore.Make(RuntimeEnvironment)(EventCollectorChannel);
|
|
46
|
+
let decoder = DcbDecode$Reventless.makeDecoder(Spec.consumedEventSchema);
|
|
47
|
+
let syncToQueryDb = async queryDbOps => {
|
|
48
|
+
let items = Object.entries(Callback.todoItems);
|
|
49
|
+
await Stdlib_Array.reduce(items, Promise.resolve(), async (prev, param) => {
|
|
50
|
+
await prev;
|
|
51
|
+
await queryDbOps.save(Id$Reventless.$$String.makeFromString(param[0]), param[1], "Overwrite", undefined);
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
let make = (dcbEventLog, publishJsons, opts) => Component$ReventlessCore.make(ComponentType$ReventlessCore.toString(OutboundTranslationSlice$ReventlessCore.componentType), Spec.name, (extra, extra$1) => {
|
|
55
|
+
let opts_parent = Component$ReventlessCore.toPulumiResource(extra);
|
|
56
|
+
let opts = {
|
|
57
|
+
parent: opts_parent
|
|
58
|
+
};
|
|
59
|
+
let queryDb = SpecificQueryDb.make(Api.api(), Api.apiRole(), undefined, opts);
|
|
60
|
+
let dcbEventTopicOutputs = Component$ReventlessCore.outputs(dcbEventLog).eventTopic;
|
|
61
|
+
let allEventTopics = Object.fromEntries([[
|
|
62
|
+
Spec.name,
|
|
63
|
+
dcbEventTopicOutputs
|
|
64
|
+
]]);
|
|
65
|
+
let publishJsonsRef = {
|
|
66
|
+
contents: undefined
|
|
67
|
+
};
|
|
68
|
+
publishJsons.apply(pj => {
|
|
69
|
+
publishJsonsRef.contents = pj;
|
|
70
|
+
});
|
|
71
|
+
let eventCollector = Component$ReventlessCore.operations(queryDb).apply(queryDbOps => {
|
|
72
|
+
let ec = SpecificEventCollector.make(Spec.name, allEventTopics, opts);
|
|
73
|
+
let jsonEventsHandler = stream => Effect.flatMap(Stream.runCollect(Stream$1.flatMap(Stream$1.mapEffect(stream, json => Effect.sync(() => {
|
|
74
|
+
let match = Message$ReventlessCore.splitMessage(json);
|
|
75
|
+
let event = decoder.decode(match[0], match[1]);
|
|
76
|
+
if (event !== undefined) {
|
|
77
|
+
return [Primitive_option.valFromOption(event)];
|
|
78
|
+
} else {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
})), events => Stream$1.fromIterable(events))), eventsArr => Effect.promise(async () => {
|
|
82
|
+
Callback.phase1(eventsArr);
|
|
83
|
+
await syncToQueryDb(queryDbOps);
|
|
84
|
+
let pj = publishJsonsRef.contents;
|
|
85
|
+
if (pj !== undefined) {
|
|
86
|
+
Stdlib_Promise.$$catch(Callback.phase2(pj).then(() => syncToQueryDb(queryDbOps)), exn => {
|
|
87
|
+
let errMsg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn), Stdlib_JsExn.message), "unknown");
|
|
88
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `detached phase 2 error: ` + errMsg));
|
|
89
|
+
return Promise.resolve();
|
|
90
|
+
});
|
|
91
|
+
return;
|
|
92
|
+
} else {
|
|
93
|
+
return log.error(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `publishJsons not yet resolved`);
|
|
94
|
+
}
|
|
95
|
+
}));
|
|
96
|
+
let handler = SpecificEventCollector.makeHandler(ec, jsonEventsHandler);
|
|
97
|
+
let resources = Component$ReventlessCore.outputs(queryDb).resources;
|
|
98
|
+
EventCollectorRuntimeBuilder.forEventCollector(handler, allEventTopics, resources, undefined, undefined, ec);
|
|
99
|
+
return ec;
|
|
100
|
+
});
|
|
101
|
+
Component$ReventlessCore.setOperations(extra, Pulumi.all([
|
|
102
|
+
Output$Pulumi.flatMap(eventCollector, Component$ReventlessCore.operations),
|
|
103
|
+
publishJsons
|
|
104
|
+
]).apply(param => {
|
|
105
|
+
let publishJsonsFn = param[1];
|
|
106
|
+
return {
|
|
107
|
+
enqueueEvent: param[0].enqueueEvent,
|
|
108
|
+
translatePending: async () => await Callback.phase2(publishJsonsFn)
|
|
109
|
+
};
|
|
110
|
+
}));
|
|
111
|
+
let outputs_resources = dcbEventTopicOutputs.resources;
|
|
112
|
+
let outputs_queryDb = Component$ReventlessCore.outputs(queryDb);
|
|
113
|
+
let outputs = {
|
|
114
|
+
resources: outputs_resources,
|
|
115
|
+
queryDb: outputs_queryDb
|
|
116
|
+
};
|
|
117
|
+
return Component$ReventlessCore.setOutputs(extra, outputs);
|
|
118
|
+
}, opts);
|
|
119
|
+
return {
|
|
120
|
+
Spec: Spec,
|
|
121
|
+
Translation: Translation,
|
|
122
|
+
queryDbName: queryDbName,
|
|
123
|
+
make: make
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
return {
|
|
127
|
+
finish: EventCollectorRuntimeBuilder.finish,
|
|
128
|
+
Make: Make
|
|
129
|
+
};
|
|
130
|
+
}))));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export {
|
|
134
|
+
log,
|
|
135
|
+
Make,
|
|
136
|
+
}
|
|
137
|
+
/* log Not a pure module */
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
S.enableJson()
|
|
2
|
+
// OutboundTranslationSlice callback — implements the tracked external call pattern.
|
|
3
|
+
//
|
|
4
|
+
// Phase 1 (collect): updates the in-memory TODO list from events (no resolve)
|
|
5
|
+
// Phase 2 (translate): calls Translation.translate for each pending item individually
|
|
6
|
+
|
|
7
|
+
@schema
|
|
8
|
+
type todoStatus =
|
|
9
|
+
| Pending
|
|
10
|
+
| Processing
|
|
11
|
+
| Completed
|
|
12
|
+
| Failed
|
|
13
|
+
|
|
14
|
+
@schema
|
|
15
|
+
type todoRow = {
|
|
16
|
+
item: JSON.t,
|
|
17
|
+
status: todoStatus,
|
|
18
|
+
createdAt: string,
|
|
19
|
+
processedAt?: string,
|
|
20
|
+
completedAt?: string,
|
|
21
|
+
retryCount: int,
|
|
22
|
+
lastError?: string,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module type T = {
|
|
26
|
+
module Spec: Reventless.OutboundTranslationSlice.Spec
|
|
27
|
+
module Translation: Reventless.OutboundTranslationSlice.Translation with module Spec := Spec
|
|
28
|
+
|
|
29
|
+
/** The in-memory TODO list -- maps item ID to row. */
|
|
30
|
+
let todoItems: Dict.t<todoRow>
|
|
31
|
+
|
|
32
|
+
/** Phase 1: update TODO list from a batch of events (collect only, no resolve). */
|
|
33
|
+
let phase1: array<Spec.consumedEvent> => unit
|
|
34
|
+
|
|
35
|
+
/** Phase 2: translate all pending items, optionally publishing commands via publishJsons. */
|
|
36
|
+
let phase2: ReventlessInfra.CommandTopic.publishJsons => promise<unit>
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module Make = (
|
|
40
|
+
Spec: Reventless.OutboundTranslationSlice.Spec,
|
|
41
|
+
Translation: Reventless.OutboundTranslationSlice.Translation with module Spec := Spec,
|
|
42
|
+
): (T with module Spec = Spec and module Translation := Translation) => {
|
|
43
|
+
module Spec = Spec
|
|
44
|
+
module Translation = Translation
|
|
45
|
+
|
|
46
|
+
let todoItems: Dict.t<todoRow> = Dict.make()
|
|
47
|
+
|
|
48
|
+
let now = () => Date.make()->Date.toISOString
|
|
49
|
+
|
|
50
|
+
// Root meta for messages emitted by this OutboundTranslationSlice. Source-event
|
|
51
|
+
// meta is not threaded from phase1 → phase2 today, so causation across the
|
|
52
|
+
// translation hop is not preserved. If sources later carry meta into todoItems,
|
|
53
|
+
// switch to Message.deriveMeta.
|
|
54
|
+
let makeMeta = (): Reventless.Message.meta =>
|
|
55
|
+
Message.generateMeta(~service=`OutboundTranslationSlice:${Spec.name}`)
|
|
56
|
+
|
|
57
|
+
let phase1 = (events: array<Spec.consumedEvent>) => {
|
|
58
|
+
events->Array.forEach(event => {
|
|
59
|
+
// Collect new outbound items
|
|
60
|
+
Translation.collect(event)->Array.forEach(((id, item)) => {
|
|
61
|
+
switch todoItems->Dict.get(id) {
|
|
62
|
+
| Some(_) => () // Already exists -- skip (idempotent)
|
|
63
|
+
| None =>
|
|
64
|
+
let row: todoRow = {
|
|
65
|
+
item: item->S.reverseConvertToJsonOrThrow(Spec.outboundItemSchema),
|
|
66
|
+
status: Pending,
|
|
67
|
+
createdAt: now(),
|
|
68
|
+
retryCount: 0,
|
|
69
|
+
}
|
|
70
|
+
todoItems->Dict.set(id, row)
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let phase2 = async (publishJsons: ReventlessInfra.CommandTopic.publishJsons) => {
|
|
77
|
+
let pending =
|
|
78
|
+
todoItems
|
|
79
|
+
->Dict.toArray
|
|
80
|
+
->Array.filter(((_, row)) =>
|
|
81
|
+
row.status == Pending || (row.status == Failed && row.retryCount < Spec.maxRetries)
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
// Process each item individually -- each translate call is independent
|
|
85
|
+
let _ = await pending->Array.reduce(Promise.resolve(), async (prev, (id, row)) => {
|
|
86
|
+
let _ = await prev
|
|
87
|
+
|
|
88
|
+
let item = try row.item->S.parseJsonOrThrow(Spec.outboundItemSchema)->Some catch {
|
|
89
|
+
| exn =>
|
|
90
|
+
let errMsg =
|
|
91
|
+
exn->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("unknown")
|
|
92
|
+
EffectLogger.logError(
|
|
93
|
+
~comp=`OutboundTranslationSlice(${Spec.name})`,
|
|
94
|
+
`failed to decode outboundItem: ${errMsg}`,
|
|
95
|
+
)->Effect.runSync
|
|
96
|
+
None
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
switch item {
|
|
100
|
+
| None => ()
|
|
101
|
+
| Some(item) =>
|
|
102
|
+
todoItems->Dict.set(id, {...row, status: Processing, processedAt: now()})
|
|
103
|
+
|
|
104
|
+
let result = try await Translation.translate(id, item) catch {
|
|
105
|
+
| exn =>
|
|
106
|
+
let msg =
|
|
107
|
+
exn
|
|
108
|
+
->JsExn.fromException
|
|
109
|
+
->Option.flatMap(JsExn.message)
|
|
110
|
+
->Option.getOr("unknown error")
|
|
111
|
+
Error(msg)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
switch result {
|
|
115
|
+
| Ok(Some((targetId, cmd))) =>
|
|
116
|
+
// Encode command and publish
|
|
117
|
+
let commandJson = try cmd
|
|
118
|
+
->S.reverseConvertToJsonOrThrow(Spec.inboundCommandSchema)
|
|
119
|
+
->Some catch {
|
|
120
|
+
| exn =>
|
|
121
|
+
let errMsg =
|
|
122
|
+
exn->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("unknown")
|
|
123
|
+
EffectLogger.logError(
|
|
124
|
+
~comp=`OutboundTranslationSlice(${Spec.name})`,
|
|
125
|
+
`failed to encode inbound command: ${errMsg}`,
|
|
126
|
+
)->Effect.runSync
|
|
127
|
+
None
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
switch commandJson {
|
|
131
|
+
| Some(commandJson) =>
|
|
132
|
+
try {
|
|
133
|
+
let msg: Reventless.Message.commandJson = {
|
|
134
|
+
id: targetId,
|
|
135
|
+
meta: makeMeta(),
|
|
136
|
+
commandJson,
|
|
137
|
+
}
|
|
138
|
+
await publishJsons([msg])
|
|
139
|
+
todoItems->Dict.set(id, {...row, status: Completed, completedAt: now()})
|
|
140
|
+
} catch {
|
|
141
|
+
| exn =>
|
|
142
|
+
let errMsg =
|
|
143
|
+
exn->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("unknown")
|
|
144
|
+
EffectLogger.logError(
|
|
145
|
+
~comp=`OutboundTranslationSlice(${Spec.name})`,
|
|
146
|
+
`failed to publish command: ${errMsg}`,
|
|
147
|
+
)->Effect.runSync
|
|
148
|
+
todoItems->Dict.set(
|
|
149
|
+
id,
|
|
150
|
+
{...row, status: Failed, retryCount: row.retryCount + 1},
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
| None =>
|
|
154
|
+
todoItems->Dict.set(
|
|
155
|
+
id,
|
|
156
|
+
{...row, status: Failed, retryCount: row.retryCount + 1},
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
| Ok(None) =>
|
|
161
|
+
// Fire-and-forget: no command to publish
|
|
162
|
+
todoItems->Dict.set(id, {...row, status: Completed, completedAt: now()})
|
|
163
|
+
|
|
164
|
+
| Error(msg) =>
|
|
165
|
+
todoItems->Dict.set(
|
|
166
|
+
id,
|
|
167
|
+
{...row, status: Failed, retryCount: row.retryCount + 1, lastError: msg},
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as S from "sury/src/S.res.mjs";
|
|
4
|
+
import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
|
|
5
|
+
import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
|
|
6
|
+
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
9
|
+
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
10
|
+
import * as Message$ReventlessCore from "../../Message.res.mjs";
|
|
11
|
+
import * as EffectLogger$ReventlessCore from "../../util/EffectLogger.res.mjs";
|
|
12
|
+
|
|
13
|
+
S.enableJson();
|
|
14
|
+
|
|
15
|
+
let todoStatusSchema = S.union([
|
|
16
|
+
S.literal("Pending"),
|
|
17
|
+
S.literal("Processing"),
|
|
18
|
+
S.literal("Completed"),
|
|
19
|
+
S.literal("Failed")
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
let todoRowSchema = S.schema(s => ({
|
|
23
|
+
item: s.m(S.json),
|
|
24
|
+
status: s.m(todoStatusSchema),
|
|
25
|
+
createdAt: s.m(S.string),
|
|
26
|
+
processedAt: s.m(S.option(S.string)),
|
|
27
|
+
completedAt: s.m(S.option(S.string)),
|
|
28
|
+
retryCount: s.m(S.int),
|
|
29
|
+
lastError: s.m(S.option(S.string))
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
function Make(Spec) {
|
|
33
|
+
return Translation => {
|
|
34
|
+
let todoItems = {};
|
|
35
|
+
let makeMeta = () => Message$ReventlessCore.generateMeta(`OutboundTranslationSlice:` + Spec.name, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
|
|
36
|
+
let phase1 = events => {
|
|
37
|
+
events.forEach(event => {
|
|
38
|
+
Translation.collect(event).forEach(param => {
|
|
39
|
+
let id = param[0];
|
|
40
|
+
let match = todoItems[id];
|
|
41
|
+
if (match !== undefined) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let row_item = S.reverseConvertToJsonOrThrow(param[1], Spec.outboundItemSchema);
|
|
45
|
+
let row_createdAt = new Date().toISOString();
|
|
46
|
+
let row = {
|
|
47
|
+
item: row_item,
|
|
48
|
+
status: "Pending",
|
|
49
|
+
createdAt: row_createdAt,
|
|
50
|
+
retryCount: 0
|
|
51
|
+
};
|
|
52
|
+
todoItems[id] = row;
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
let phase2 = async publishJsons => {
|
|
57
|
+
let pending = Object.entries(todoItems).filter(param => {
|
|
58
|
+
let row = param[1];
|
|
59
|
+
if (row.status === "Pending") {
|
|
60
|
+
return true;
|
|
61
|
+
} else if (row.status === "Failed") {
|
|
62
|
+
return row.retryCount < Spec.maxRetries;
|
|
63
|
+
} else {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
await Stdlib_Array.reduce(pending, Promise.resolve(), async (prev, param) => {
|
|
68
|
+
let row = param[1];
|
|
69
|
+
let id = param[0];
|
|
70
|
+
await prev;
|
|
71
|
+
let item;
|
|
72
|
+
try {
|
|
73
|
+
item = Primitive_option.some(S.parseJsonOrThrow(row.item, Spec.outboundItemSchema));
|
|
74
|
+
} catch (raw_exn) {
|
|
75
|
+
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
76
|
+
let errMsg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn), Stdlib_JsExn.message), "unknown");
|
|
77
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `failed to decode outboundItem: ` + errMsg));
|
|
78
|
+
item = undefined;
|
|
79
|
+
}
|
|
80
|
+
if (item === undefined) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
let newrecord = {...row};
|
|
84
|
+
newrecord.processedAt = new Date().toISOString();
|
|
85
|
+
newrecord.status = "Processing";
|
|
86
|
+
todoItems[id] = newrecord;
|
|
87
|
+
let result;
|
|
88
|
+
try {
|
|
89
|
+
result = await Translation.translate(id, Primitive_option.valFromOption(item));
|
|
90
|
+
} catch (raw_exn$1) {
|
|
91
|
+
let exn$1 = Primitive_exceptions.internalToException(raw_exn$1);
|
|
92
|
+
let msg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn$1), Stdlib_JsExn.message), "unknown error");
|
|
93
|
+
result = {
|
|
94
|
+
TAG: "Error",
|
|
95
|
+
_0: msg
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (result.TAG === "Ok") {
|
|
99
|
+
let match = result._0;
|
|
100
|
+
if (match !== undefined) {
|
|
101
|
+
let commandJson;
|
|
102
|
+
try {
|
|
103
|
+
commandJson = S.reverseConvertToJsonOrThrow(match[1], Spec.inboundCommandSchema);
|
|
104
|
+
} catch (raw_exn$2) {
|
|
105
|
+
let exn$2 = Primitive_exceptions.internalToException(raw_exn$2);
|
|
106
|
+
let errMsg$1 = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn$2), Stdlib_JsExn.message), "unknown");
|
|
107
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `failed to encode inbound command: ` + errMsg$1));
|
|
108
|
+
commandJson = undefined;
|
|
109
|
+
}
|
|
110
|
+
if (commandJson !== undefined) {
|
|
111
|
+
try {
|
|
112
|
+
let msg_id = match[0];
|
|
113
|
+
let msg_meta = makeMeta();
|
|
114
|
+
let msg$1 = {
|
|
115
|
+
id: msg_id,
|
|
116
|
+
meta: msg_meta,
|
|
117
|
+
commandJson: commandJson
|
|
118
|
+
};
|
|
119
|
+
await publishJsons([msg$1]);
|
|
120
|
+
let newrecord$1 = {...row};
|
|
121
|
+
newrecord$1.completedAt = new Date().toISOString();
|
|
122
|
+
newrecord$1.status = "Completed";
|
|
123
|
+
todoItems[id] = newrecord$1;
|
|
124
|
+
return;
|
|
125
|
+
} catch (raw_exn$3) {
|
|
126
|
+
let exn$3 = Primitive_exceptions.internalToException(raw_exn$3);
|
|
127
|
+
let errMsg$2 = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn$3), Stdlib_JsExn.message), "unknown");
|
|
128
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `failed to publish command: ` + errMsg$2));
|
|
129
|
+
let newrecord$2 = {...row};
|
|
130
|
+
newrecord$2.retryCount = row.retryCount + 1 | 0;
|
|
131
|
+
newrecord$2.status = "Failed";
|
|
132
|
+
todoItems[id] = newrecord$2;
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
} else {
|
|
136
|
+
let newrecord$3 = {...row};
|
|
137
|
+
newrecord$3.retryCount = row.retryCount + 1 | 0;
|
|
138
|
+
newrecord$3.status = "Failed";
|
|
139
|
+
todoItems[id] = newrecord$3;
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
let newrecord$4 = {...row};
|
|
144
|
+
newrecord$4.completedAt = new Date().toISOString();
|
|
145
|
+
newrecord$4.status = "Completed";
|
|
146
|
+
todoItems[id] = newrecord$4;
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
let newrecord$5 = {...row};
|
|
151
|
+
newrecord$5.lastError = result._0;
|
|
152
|
+
newrecord$5.retryCount = row.retryCount + 1 | 0;
|
|
153
|
+
newrecord$5.status = "Failed";
|
|
154
|
+
todoItems[id] = newrecord$5;
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
return {
|
|
160
|
+
Spec: Spec,
|
|
161
|
+
todoItems: todoItems,
|
|
162
|
+
phase1: phase1,
|
|
163
|
+
phase2: phase2
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export {
|
|
169
|
+
todoStatusSchema,
|
|
170
|
+
todoRowSchema,
|
|
171
|
+
Make,
|
|
172
|
+
}
|
|
173
|
+
/* Not a pure module */
|