@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,447 @@
|
|
|
1
|
+
open Reventless.Projection // FIXME: open locally
|
|
2
|
+
open Reventless.ReadModel // FIXME: open locally
|
|
3
|
+
// Belt.Result removed — Ok/Error are global in RescriptCore
|
|
4
|
+
|
|
5
|
+
module Set = Belt.Set.String
|
|
6
|
+
|
|
7
|
+
let log = Logger.fromEnv()
|
|
8
|
+
|
|
9
|
+
module Mapping = {
|
|
10
|
+
module MakeGenericSource = (Mapping: Reventless.Projection.Mapping): (
|
|
11
|
+
Mapper.GenericSource with type t = Mapping.sourceEvent
|
|
12
|
+
) => {
|
|
13
|
+
let name = Mapping.sourceName
|
|
14
|
+
type t = Mapping.sourceEvent
|
|
15
|
+
let decode' = json => json->Message.decodeEvent'(S.string, Mapping.sourceEventSchema)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let logAction = str => log.debug(~comp="Projection", str)
|
|
20
|
+
|
|
21
|
+
// ── @displayName overlay ────────────────────────────────────────────────────
|
|
22
|
+
// When a read model's state schema carries DisplayName metadata, every state
|
|
23
|
+
// written by a projection action gets its [displayName] field overwritten with
|
|
24
|
+
// the composite label derived from the annotated source fields. The overlay
|
|
25
|
+
// encodes via sury, mutates the JSON dict, and parses back — unlocks fine
|
|
26
|
+
// work on partial/option fields without duplicating the record shape here.
|
|
27
|
+
|
|
28
|
+
let overlayDisplayName = (
|
|
29
|
+
state: 'state,
|
|
30
|
+
stateSchema: S.t<'state>,
|
|
31
|
+
spec: Reventless.DisplayName.displayNameSpec,
|
|
32
|
+
): 'state => {
|
|
33
|
+
let json = state->S.reverseConvertToJsonOrThrow(stateSchema)
|
|
34
|
+
switch json->JSON.Decode.object {
|
|
35
|
+
| None => state
|
|
36
|
+
| Some(stateDict) =>
|
|
37
|
+
let label = Reventless.DisplayName.computeLabel(spec, stateDict)
|
|
38
|
+
stateDict->Dict.set("displayName", JSON.Encode.string(label))
|
|
39
|
+
stateDict->JSON.Encode.object->S.parseJsonOrThrow(stateSchema)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let rewriteAction = (
|
|
44
|
+
action: action<'id, 'state>,
|
|
45
|
+
stateSchema: S.t<'state>,
|
|
46
|
+
): action<'id, 'state> =>
|
|
47
|
+
switch Reventless.DisplayName.getSpec(stateSchema->S.castToUnknown) {
|
|
48
|
+
| None => action
|
|
49
|
+
| Some(spec) =>
|
|
50
|
+
let overlay = state => overlayDisplayName(state, stateSchema, spec)
|
|
51
|
+
switch action {
|
|
52
|
+
| Create(id, state) => Create(id, overlay(state))
|
|
53
|
+
| CreateMany(pairs) => CreateMany(pairs->Array.map(((id, s)) => (id, overlay(s))))
|
|
54
|
+
| Set(id, state) => Set(id, overlay(state))
|
|
55
|
+
| SetMany(ids, fn) => SetMany(ids, id => overlay(fn(id)))
|
|
56
|
+
| Update(id, fn) => Update(id, state => overlay(fn(state)))
|
|
57
|
+
| UpdateMany(ids, fn) => UpdateMany(ids, (id, s) => overlay(fn(id, s)))
|
|
58
|
+
| UpdateWithDefault(id, default, fn) =>
|
|
59
|
+
UpdateWithDefault(id, overlay(default), state => overlay(fn(state)))
|
|
60
|
+
| UpdateManyWithDefault(ids, defFn, fn) =>
|
|
61
|
+
UpdateManyWithDefault(ids, id => overlay(defFn(id)), (id, s) => overlay(fn(id, s)))
|
|
62
|
+
| CreateMultiState(id, states) => CreateMultiState(id, states->Array.map(overlay))
|
|
63
|
+
| UpdateMultiState(id, fn) =>
|
|
64
|
+
UpdateMultiState(id, states => states->fn->Array.map(overlay))
|
|
65
|
+
| UpdateManyMultiStates(ids, fn) =>
|
|
66
|
+
UpdateManyMultiStates(ids, (id, states) => fn(id, states)->Array.map(overlay))
|
|
67
|
+
| Delete(_) | DeleteMany(_) | DeleteIf(_, _) | DeleteManyIf(_, _) | Ignore => action
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let applyChanges = async (
|
|
72
|
+
action,
|
|
73
|
+
id,
|
|
74
|
+
beforeStates,
|
|
75
|
+
afterStates,
|
|
76
|
+
{QueryDb.saveBatch: saveBatch, deleteBatch},
|
|
77
|
+
{subIdField, getSubId},
|
|
78
|
+
) => {
|
|
79
|
+
let beforeCount = beforeStates->Array.length
|
|
80
|
+
let beforeSubIds = beforeStates->Array.map(state => state->getSubId)->Set.fromArray
|
|
81
|
+
|
|
82
|
+
let afterCount = afterStates->Array.length
|
|
83
|
+
let afterSubIds = afterStates->Array.map(state => state->getSubId)->Set.fromArray
|
|
84
|
+
|
|
85
|
+
let addedSubIds = afterSubIds->Set.diff(beforeSubIds)
|
|
86
|
+
let addedStates = afterStates->Array.filter(state => addedSubIds->Set.has(state->getSubId))
|
|
87
|
+
let addedCount = addedStates->Array.length
|
|
88
|
+
|
|
89
|
+
let changedStates = beforeStates->Array.filterMap(before => {
|
|
90
|
+
let beforeSubId = before->getSubId
|
|
91
|
+
afterStates->Array.find(after => after->getSubId == beforeSubId && after != before)
|
|
92
|
+
})
|
|
93
|
+
let changedCount = changedStates->Array.length
|
|
94
|
+
|
|
95
|
+
let batchToSave =
|
|
96
|
+
changedStates->Array.concat(addedStates)->Array.map(state => (id, state, None))
|
|
97
|
+
|
|
98
|
+
let deletedSubIds = beforeSubIds->Set.diff(afterSubIds)->Set.toArray
|
|
99
|
+
let batchToDelete = deletedSubIds->Array.map(subId => (id, Some((subIdField, subId))))
|
|
100
|
+
let deletedCount = batchToDelete->Array.length
|
|
101
|
+
|
|
102
|
+
logAction(
|
|
103
|
+
`${action}(${id}): beforeStates:${beforeCount->Int.toString} afterStates:${afterCount->Int.toString} added:${addedCount->Int.toString} changed:${changedCount->Int.toString} deleted:${deletedCount->Int.toString}`,
|
|
104
|
+
)
|
|
105
|
+
let result = await [deleteBatch(batchToDelete), saveBatch(batchToSave)]->Promise.all
|
|
106
|
+
switch result {
|
|
107
|
+
| _ => Ok() // TODO: Error handling
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let stateToString: 'a => string = state => state->JSON.stringifyAny->Option.getOrThrow
|
|
112
|
+
let statesToString: array<'a> => string = states =>
|
|
113
|
+
states->Array.map(stateToString)->Array.joinUnsafe(", ")
|
|
114
|
+
|
|
115
|
+
let handleAction = async (
|
|
116
|
+
action,
|
|
117
|
+
{QueryDb.loadStream: loadStream, save, saveBatch, delete, deleteBatch} as operations,
|
|
118
|
+
subIdConfig,
|
|
119
|
+
) => {
|
|
120
|
+
let loadAtMost = (n, id) =>
|
|
121
|
+
loadStream(id)
|
|
122
|
+
->Stream.take(n)
|
|
123
|
+
->Stream.runCollect
|
|
124
|
+
->Effect.map(states => Ok(states))
|
|
125
|
+
->Effect.catchAll(e => Effect.succeed(Error(e)))
|
|
126
|
+
->Effect.runPromise
|
|
127
|
+
let loadAll = id =>
|
|
128
|
+
loadStream(id)
|
|
129
|
+
->Stream.runCollect
|
|
130
|
+
->Effect.map(states => Ok(states))
|
|
131
|
+
->Effect.catchAll(e => Effect.succeed(Error(e)))
|
|
132
|
+
->Effect.runPromise
|
|
133
|
+
switch action {
|
|
134
|
+
| Ignore =>
|
|
135
|
+
logAction("Ignore")
|
|
136
|
+
Ok()
|
|
137
|
+
|
|
138
|
+
| Create(id, state) =>
|
|
139
|
+
logAction(`Create(${id}, ${state->stateToString})`)
|
|
140
|
+
await save(id, state, Init, None)
|
|
141
|
+
| CreateMultiState(id, states) =>
|
|
142
|
+
logAction(
|
|
143
|
+
`CreateMultiState(${id}, ${states
|
|
144
|
+
->Array.map(state => state->stateToString)
|
|
145
|
+
->Array.joinUnsafe(", ")})`,
|
|
146
|
+
)
|
|
147
|
+
switch states {
|
|
148
|
+
| [] => Ok()
|
|
149
|
+
| [state] => await save(id, state, Init, None)
|
|
150
|
+
| states =>
|
|
151
|
+
let batch = states->Array.map(state => (id, state, None))
|
|
152
|
+
await saveBatch(batch)
|
|
153
|
+
}
|
|
154
|
+
| CreateMany(states) =>
|
|
155
|
+
let batch = states->Array.map(((id, state)) => (id, state, None))
|
|
156
|
+
let statesStr =
|
|
157
|
+
batch
|
|
158
|
+
->Array.map(((id, state, _)) => `(${id},${state->stateToString})`)
|
|
159
|
+
->Array.joinUnsafe(", ")
|
|
160
|
+
logAction(`CreateMany(${statesStr})`)
|
|
161
|
+
await saveBatch(batch) // TODO: think about using single saves with saveMode Init
|
|
162
|
+
|
|
163
|
+
| Set(id, state) =>
|
|
164
|
+
logAction(`Set(${id}, ${state->stateToString})`)
|
|
165
|
+
await save(id, state, Any, None)
|
|
166
|
+
| SetMany(ids, set) =>
|
|
167
|
+
let batch = ids->Array.map(id => (id, set(id), None))
|
|
168
|
+
let statesStr =
|
|
169
|
+
batch
|
|
170
|
+
->Array.map(((id, state, _)) => `(${id},${state->stateToString})`)
|
|
171
|
+
->Array.joinUnsafe(", ")
|
|
172
|
+
logAction(`SetMany(${statesStr})`)
|
|
173
|
+
await saveBatch(batch)
|
|
174
|
+
|
|
175
|
+
| Update(id, update) =>
|
|
176
|
+
switch await loadAtMost(2, id) {
|
|
177
|
+
| Ok(states) =>
|
|
178
|
+
switch states {
|
|
179
|
+
| [] =>
|
|
180
|
+
logAction(`Update Error: No oldState for ${id})`)
|
|
181
|
+
Error(ReventlessInfra.QueryDb.StaleState)
|
|
182
|
+
| [oldState] =>
|
|
183
|
+
let newState = oldState->update
|
|
184
|
+
logAction(`Update(${id}, ${oldState->stateToString} => ${newState->stateToString})`)
|
|
185
|
+
await save(id, newState, Overwrite, None)
|
|
186
|
+
| _ =>
|
|
187
|
+
logAction(`Update Error: Multiple oldStates for ${id})`)
|
|
188
|
+
Error(ReventlessInfra.QueryDb.StaleState)
|
|
189
|
+
}
|
|
190
|
+
| Error(err) => Error(err)
|
|
191
|
+
}
|
|
192
|
+
| UpdateWithDefault(id, default, update) =>
|
|
193
|
+
log.debug(~comp="Projection", `UpdateWithDefault(${id}, loading ...`)
|
|
194
|
+
switch await loadAtMost(2, id) {
|
|
195
|
+
| Ok(states) =>
|
|
196
|
+
switch states {
|
|
197
|
+
| [] =>
|
|
198
|
+
logAction(`UpdateWithDefault(${id}, default: ${default->stateToString})`)
|
|
199
|
+
await save(id, default, Init, None)
|
|
200
|
+
| [oldState] =>
|
|
201
|
+
let newState = oldState->update
|
|
202
|
+
logAction(
|
|
203
|
+
`UpdateWithDefault(${id}, ${oldState->stateToString} => ${newState->stateToString})`,
|
|
204
|
+
)
|
|
205
|
+
await save(id, newState, Overwrite, None)
|
|
206
|
+
| _ =>
|
|
207
|
+
logAction(`UpdateWithDefault Error: Multiple oldStates for ${id})`)
|
|
208
|
+
Error(ReventlessInfra.QueryDb.StaleState)
|
|
209
|
+
}
|
|
210
|
+
| Error(err) =>
|
|
211
|
+
logAction(
|
|
212
|
+
`UpdateWithDefault Error: Couldn't load oldState(s) for ${id}: ${err->QueryDb.storageErrorToString})`,
|
|
213
|
+
)
|
|
214
|
+
Error(err)
|
|
215
|
+
}
|
|
216
|
+
| UpdateMultiState(id, update) =>
|
|
217
|
+
switch (await loadAll(id), subIdConfig) {
|
|
218
|
+
| (Ok(states), Some(subIdConfig)) =>
|
|
219
|
+
let beforeStates = states
|
|
220
|
+
let afterStates = beforeStates->update
|
|
221
|
+
await applyChanges("UpdateMultiState", id, beforeStates, afterStates, operations, subIdConfig)
|
|
222
|
+
|
|
223
|
+
| (Error(err), Some(_)) =>
|
|
224
|
+
logAction(
|
|
225
|
+
`UpdateMultiState Error: Couldn't load states for ${id}: ${err->QueryDb.storageErrorToString})`,
|
|
226
|
+
)
|
|
227
|
+
Error(err)
|
|
228
|
+
| (_, None) =>
|
|
229
|
+
logAction("UpdateMultiState Error: Missing SubIdConfig !")
|
|
230
|
+
Error(ReventlessInfra.QueryDb.MissingSubIdConfig)
|
|
231
|
+
}
|
|
232
|
+
| Delete(id) =>
|
|
233
|
+
logAction(`Delete(${id})`)
|
|
234
|
+
await delete(id, None)
|
|
235
|
+
| DeleteMany(ids) =>
|
|
236
|
+
logAction(`DeleteMany(${ids->Array.joinUnsafe(", ")})`)
|
|
237
|
+
await deleteBatch(ids->Array.map(id => (id, None)))
|
|
238
|
+
|
|
239
|
+
// TODO: add missing actions
|
|
240
|
+
| _ =>
|
|
241
|
+
logAction("Error: Action not yet supported !")
|
|
242
|
+
Ok()
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
let actionsWithId = action =>
|
|
247
|
+
switch action {
|
|
248
|
+
| Ignore => []
|
|
249
|
+
| Create(id, _) => [(id, action)]
|
|
250
|
+
| CreateMultiState(id, _) => [(id, action)]
|
|
251
|
+
| CreateMany(states) => states->Array.map(((id, state)) => (id, Create(id, state)))
|
|
252
|
+
| Set(id, _) => [(id, action)]
|
|
253
|
+
| SetMany(ids, set) => ids->Array.map(id => (id, Set(id, id->set)))
|
|
254
|
+
| Update(id, _) => [(id, action)]
|
|
255
|
+
| UpdateWithDefault(id, _, _) => [(id, action)]
|
|
256
|
+
| UpdateMultiState(id, _) => [(id, action)]
|
|
257
|
+
| UpdateManyMultiStates(ids, update) =>
|
|
258
|
+
ids->Array.map(id => (id, UpdateMultiState(id, states => update(id, states))))
|
|
259
|
+
| Delete(id) => [(id, action)]
|
|
260
|
+
| DeleteMany(ids) => ids->Array.map(id => (id, Delete(id)))
|
|
261
|
+
|
|
262
|
+
// TODO: add missing actions
|
|
263
|
+
| _ =>
|
|
264
|
+
logAction("Error: Action not yet supported !")
|
|
265
|
+
[]
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
let groupActionsById = actions => {
|
|
269
|
+
let allActionsWithId = actions->Array.map(action => action->actionsWithId)->Array.flat
|
|
270
|
+
let ids = allActionsWithId->Array.map(((id, _)) => id)
|
|
271
|
+
ids
|
|
272
|
+
->Belt.Set.String.fromArray
|
|
273
|
+
->Belt.Set.String.toArray
|
|
274
|
+
->Array.map(id => (
|
|
275
|
+
id,
|
|
276
|
+
allActionsWithId->Array.filterMap(((actionId, action)) => actionId == id ? Some(action) : None),
|
|
277
|
+
))
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
let optimizeActions = actions => {
|
|
281
|
+
// [ UpdateMultiSate(f), UpdateMultiState(g), Create(..)] => [ UpdateMultiState(f(g)), Create(..) ]
|
|
282
|
+
actions->Array.reduce([], (optimizedActions, action) => {
|
|
283
|
+
let optimizedActionsCount = optimizedActions->Array.length
|
|
284
|
+
if optimizedActionsCount == 0 {
|
|
285
|
+
[action]
|
|
286
|
+
} else {
|
|
287
|
+
let lastAction = optimizedActions->Array.getUnsafe(optimizedActionsCount - 1)
|
|
288
|
+
let previousActions = if optimizedActionsCount == 1 {
|
|
289
|
+
[]
|
|
290
|
+
} else {
|
|
291
|
+
optimizedActions->Array.slice(~start=0, ~end=optimizedActionsCount)
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
switch (lastAction, action) {
|
|
295
|
+
// SINGLE STATES
|
|
296
|
+
| (Create(id1, state1), Update(id2, f)) if id1 == id2 =>
|
|
297
|
+
previousActions->Array.concat([Create(id1, f(state1))])
|
|
298
|
+
| (Create(id1, state1), UpdateWithDefault(id2, _defaultState2, f)) if id1 == id2 =>
|
|
299
|
+
previousActions->Array.concat([Create(id1, f(state1))])
|
|
300
|
+
| (Update(id1, f), Update(id2, g)) if id1 == id2 =>
|
|
301
|
+
previousActions->Array.concat([Update(id1, state => g(f(state)))])
|
|
302
|
+
| (UpdateWithDefault(id1, defaultState1, f), UpdateWithDefault(id2, _defaultState2, g))
|
|
303
|
+
if id1 == id2 =>
|
|
304
|
+
previousActions->Array.concat([
|
|
305
|
+
UpdateWithDefault(id1, g(defaultState1), state => g(f(state))),
|
|
306
|
+
])
|
|
307
|
+
| (Update(id1, f), UpdateWithDefault(id2, defaultState2, g)) if id1 == id2 =>
|
|
308
|
+
previousActions->Array.concat([
|
|
309
|
+
UpdateWithDefault(
|
|
310
|
+
id1,
|
|
311
|
+
/* if no state exists before the first upate, it is ignored */
|
|
312
|
+
defaultState2,
|
|
313
|
+
state => g(f(state)),
|
|
314
|
+
),
|
|
315
|
+
])
|
|
316
|
+
| (UpdateWithDefault(id1, defaultState1, f), Update(id2, g)) if id1 == id2 =>
|
|
317
|
+
previousActions->Array.concat([
|
|
318
|
+
UpdateWithDefault(id1, g(defaultState1), state => g(f(state))),
|
|
319
|
+
])
|
|
320
|
+
| (UpdateWithDefault(id1, defaultState1, f), Create(id2, _state2)) if id1 == id2 =>
|
|
321
|
+
log.warn(~comp="Projection", `optimizing Create after UpdateWithDefault for id=${id1}, ignoring the Create`)
|
|
322
|
+
previousActions->Array.concat([UpdateWithDefault(id1, defaultState1, f)])
|
|
323
|
+
| (Create(id1, state1), Create(id2, state2)) if id1 == id2 =>
|
|
324
|
+
log.warn(
|
|
325
|
+
~comp="Projection",
|
|
326
|
+
`optimizing 2 sequential Create for id=${id1}, ignoring second: ${state2->JSON.stringifyAny->Option.getOr("?")}`,
|
|
327
|
+
)
|
|
328
|
+
previousActions->Array.concat([Create(id1, state1)])
|
|
329
|
+
| (Create(id1, state1), Delete(id2)) if id1 == id2 =>
|
|
330
|
+
log.warn(
|
|
331
|
+
~comp="Projection",
|
|
332
|
+
`optimizing Delete after Create for id=${id1}, ignoring Create: ${state1->JSON.stringifyAny->Option.getOr("?")}`,
|
|
333
|
+
)
|
|
334
|
+
previousActions->Array.concat([Delete(id1)])
|
|
335
|
+
| (Update(id1, _f), Delete(id2)) if id1 == id2 =>
|
|
336
|
+
log.warn(~comp="Projection", `optimizing Delete after Update for id=${id1}, ignoring the Update`)
|
|
337
|
+
previousActions->Array.concat([Delete(id1)])
|
|
338
|
+
| (UpdateWithDefault(id1, _defaultState1, _f), Delete(id2)) if id1 == id2 =>
|
|
339
|
+
log.warn(~comp="Projection", `optimizing Delete after UpdateWithDefault for id=${id1}, ignoring the UpdateWithDefault`)
|
|
340
|
+
previousActions->Array.concat([Delete(id1)])
|
|
341
|
+
| (Delete(id1), Create(id2, state2)) if id1 == id2 =>
|
|
342
|
+
previousActions->Array.concat([Set(id1, state2)])
|
|
343
|
+
| (Create(id1, state1), Set(id2, state2)) if id1 == id2 =>
|
|
344
|
+
log.warn(
|
|
345
|
+
~comp="Projection",
|
|
346
|
+
`optimizing Set after Create for id=${id1}, ignoring Create: ${state1->JSON.stringifyAny->Option.getOr("?")}`,
|
|
347
|
+
)
|
|
348
|
+
previousActions->Array.concat([Set(id1, state2)])
|
|
349
|
+
| (Update(id1, _f), Set(id2, state2)) if id1 == id2 =>
|
|
350
|
+
log.warn(~comp="Projection", `optimizing Set after Update for id=${id1}, ignoring the Update`)
|
|
351
|
+
previousActions->Array.concat([Set(id1, state2)])
|
|
352
|
+
| (UpdateWithDefault(id1, _defaultState1, _f), Set(id2, state2)) if id1 == id2 =>
|
|
353
|
+
log.warn(~comp="Projection", `optimizing Set after UpdateWithDefault for id=${id1}, ignoring the UpdateWithDefault`)
|
|
354
|
+
previousActions->Array.concat([Set(id1, state2)])
|
|
355
|
+
// MULTI STATES
|
|
356
|
+
/*
|
|
357
|
+
| (CreateMultiState(id1, states1), UpdateMultiState(id2, f)) if id1 == id2 =>
|
|
358
|
+
THIS IS FALSE: previousActions->Array.concat([CreateMultiState(id1, f(states1))])
|
|
359
|
+
suggestion: UpdateMultiState with following updateFunction:
|
|
360
|
+
- apply f to states1 and states of UpdateMultiState separately
|
|
361
|
+
- concat unique states of both results
|
|
362
|
+
*/
|
|
363
|
+
| (UpdateMultiState(id1, f), UpdateMultiState(id2, g)) if id1 == id2 =>
|
|
364
|
+
previousActions->Array.concat([UpdateMultiState(id1, state => g(f(state)))])
|
|
365
|
+
/*
|
|
366
|
+
| (UpdateMultiState(id1, _f), CreateMultiState(id2, states2)) if id1 == id2 =>
|
|
367
|
+
Console..warn(
|
|
368
|
+
"optimizing CreateMultiState after UpdateMultiState, therefore ignoring the UpdateMultiState",
|
|
369
|
+
)
|
|
370
|
+
THIS IS FALSE: previousActions->Array.concat([CreateMultiState(id1, states2)])
|
|
371
|
+
suggestion: UpdateMultiState with following updateFunction:
|
|
372
|
+
- apply f to states of UpdateMultiState
|
|
373
|
+
- concat unique states of update results and states2
|
|
374
|
+
- if duplicates exist, prefer states2
|
|
375
|
+
*/
|
|
376
|
+
/*
|
|
377
|
+
| (CreateMultiState(id1, states1), CreateMultiState(id2, states2)) if id1 == id2 =>
|
|
378
|
+
Console..warn2(
|
|
379
|
+
"optimizing 2 sequential CreateMultiState actions, therefore ignoring the first one:",
|
|
380
|
+
states1->JSON.stringifyAny,
|
|
381
|
+
)
|
|
382
|
+
THIS IS FALSE: previousActions->Array.concat([CreateMultiState(id1, states2)])
|
|
383
|
+
suggestion: CreateMultiState with following updateFunction:
|
|
384
|
+
- concatenate states1 & states2
|
|
385
|
+
- if duplicates exist, prefer states2
|
|
386
|
+
*/
|
|
387
|
+
| (lastAction, action) =>
|
|
388
|
+
// any other action will be just appended
|
|
389
|
+
log.warn(
|
|
390
|
+
~comp="Projection",
|
|
391
|
+
`actions not optimized: ${lastAction->JSON.stringifyAny->Option.getOr("?")} + ${action->JSON.stringifyAny->Option.getOr("?")}`,
|
|
392
|
+
)
|
|
393
|
+
optimizedActions->Array.concat([action])
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
})
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
let handleActions = async (actions, operations, subIdConfig) => {
|
|
400
|
+
let handleActionsForId = async (actions, id) => {
|
|
401
|
+
let actionCount = actions->Array.length
|
|
402
|
+
if actionCount > 1 {
|
|
403
|
+
log.debug(
|
|
404
|
+
~comp="Projection",
|
|
405
|
+
`handleActions: optimizing ${actionCount->Int.toString} actions for id=${id}`,
|
|
406
|
+
)
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
let optimizedActions = optimizeActions(actions)
|
|
410
|
+
let optimizedActionCount = optimizedActions->Array.length
|
|
411
|
+
log.info(~comp="Projection", `handleActions: id=${id} actions=${optimizedActionCount->Int.toString}`)
|
|
412
|
+
|
|
413
|
+
// FIXME: handle errors!
|
|
414
|
+
await optimizedActions->Array.reduce(Ok()->Promise.resolve, async (p, action) => {
|
|
415
|
+
switch await p {
|
|
416
|
+
| Ok() => ()
|
|
417
|
+
| Error(err) =>
|
|
418
|
+
log.error(
|
|
419
|
+
~comp="Projection",
|
|
420
|
+
`storage error: ${err->Message.encode(ReventlessInfra.QueryDb.storageErrorSchema)->JSON.stringify}`,
|
|
421
|
+
)
|
|
422
|
+
}
|
|
423
|
+
await action->handleAction(operations, subIdConfig)
|
|
424
|
+
})
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
let results = await actions
|
|
428
|
+
->groupActionsById
|
|
429
|
+
->Array.map(((id, actions)) => actions->handleActionsForId(id))
|
|
430
|
+
->Promise.all
|
|
431
|
+
let errors = results->Array.filterMap(x =>
|
|
432
|
+
switch x {
|
|
433
|
+
| Error(err) => Some(err)
|
|
434
|
+
| _ => None
|
|
435
|
+
}
|
|
436
|
+
)
|
|
437
|
+
switch errors {
|
|
438
|
+
| [] => ()
|
|
439
|
+
| errors =>
|
|
440
|
+
let count = errors->Array.length
|
|
441
|
+
JsError.throwWithMessage(
|
|
442
|
+
`Projection.handleActions failed with ${count->Int.toString} errors: ${errors
|
|
443
|
+
->Array.map(QueryDb.storageErrorToString)
|
|
444
|
+
->Array.joinUnsafe(",")}`,
|
|
445
|
+
)
|
|
446
|
+
}
|
|
447
|
+
}
|