@reventlessdev/reventless-core 3.0.0-alpha.260 → 3.0.0-alpha.261
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/package.json +9 -9
- package/src/Behavior.res +1 -4
- package/src/Message.res +17 -14
- package/src/Projection.res +51 -25
- package/src/RequestContext.res +8 -9
- package/src/ResourceAttribution.res +28 -14
- package/src/adapter/Adapter.res +48 -4
- package/src/adapter/EventLogProvisioning/EventLogProvisioning.res +5 -5
- package/src/adapter/Messaging/Messaging_Log_Backend.res +10 -7
- package/src/adapter/Messaging/Messaging_Log_Backend.res.mjs +2 -4
- package/src/adapter/Monitoring/Monitoring.res +16 -17
- package/src/adapter/QueryInterception/QueryInterception.res +0 -1
- package/src/adapter/Runtime/AggregateRuntime_Builder_Common.res +12 -5
- package/src/adapter/Runtime/EventCollectorRuntime_Builder_Single.res +11 -7
- package/src/adapter/Runtime/PluginRuntime_Builder_Micro.res +1 -7
- package/src/adapter/Runtime/PluginRuntime_Builder_Single.res +1 -7
- package/src/adapter/RuntimeExtension/RuntimeExtension.res +0 -1
- package/src/admin/Platform_Admin.res +17 -6
- package/src/admin/Platform_AdminApi.res +14 -9
- package/src/admin/Platform_Admin_Callback.res +1 -1
- package/src/admin/Platform_BakedManifest.res +34 -34
- package/src/admin/Platform_ComponentDefinitionsApi.res +9 -21
- package/src/admin/Platform_PluginStructuresApi.res +15 -12
- package/src/admin/UiFragmentRegistry/StateChange/UiFragmentRegistry.res +1 -1
- package/src/components/Aggregate/Aggregate.res +13 -12
- package/src/components/Aggregate/Aggregate_Builder.res +22 -21
- package/src/components/Aggregate/Aggregate_Callback.res +91 -86
- package/src/components/Api/ApiNoApiHelpers.res +1 -3
- package/src/components/Api/Api_Ids.res +0 -1
- package/src/components/Api/Api_Naming.res +41 -18
- package/src/components/Api/GraphQL_FragmentGenerator.res +38 -51
- package/src/components/Api/GraphQL_SchemaInspector.res +5 -3
- package/src/components/Api/GraphQL_Stitcher.res +9 -10
- package/src/components/Api/MCP_SchemaGenerator.res +8 -12
- package/src/components/Api/OwnerScopeDiagnostics.res +1 -2
- package/src/components/Api/QueryDbListQuery.res +13 -6
- package/src/components/Api/SchemaType.res +28 -23
- package/src/components/Api/SuryToJsonSchema.res +9 -10
- package/src/components/AutomationSlice/AutomationSlice.res +4 -4
- package/src/components/AutomationSlice/AutomationSlice_Builder.res +15 -14
- package/src/components/AutomationSlice/AutomationSlice_Callback.res +3 -3
- package/src/components/Builder_Helpers.res +12 -23
- package/src/components/CommandGenerator/CommandGenerator.res +6 -1
- package/src/components/CommandGenerator/CommandGenerator_Builder.res +29 -21
- package/src/components/CommandGenerator/CommandGenerator_Callback.res +17 -21
- package/src/components/CommandTopic/CommandTopic.res +3 -3
- package/src/components/CommandTopic/CommandTopic_Builder.res +10 -10
- package/src/components/CommandTopic/CommandTopic_Callback.res +1 -4
- package/src/components/CommandTopic/CommandTopic_Helpers.res +1 -2
- package/src/components/Counter/Counter_Builder.res +1 -6
- package/src/components/Counter/Counter_Callback.res +3 -3
- package/src/components/Dcb/Dcb_Builder.res +970 -956
- package/src/components/DcbEventLog/DcbEventLog.res +4 -4
- package/src/components/DcbEventLog/DcbEventLog_Builder.res +0 -1
- package/src/components/DcbEventLog/DcbEventLog_Operations.res +17 -18
- package/src/components/EventCollector/EventCollector_Builder.res +2 -1
- package/src/components/EventLog/EventLog.res +5 -1
- package/src/components/EventLog/EventLog_Operations.res +12 -8
- package/src/components/EventMapper/EventMapper.res +8 -10
- package/src/components/EventMapper/EventMapper_Builder.res +4 -1
- package/src/components/EventMapper/EventMapper_Callback.res +46 -31
- package/src/components/EventTopic/EventTopic.res +3 -3
- package/src/components/EventTopic/EventTopic_Builder.res +1 -1
- package/src/components/Extension/Extension.res +4 -1
- package/src/components/Extension/Extension_Operations.res +11 -3
- package/src/components/ExtensionPoint/ExtensionPoint.res +3 -3
- package/src/components/ExtensionPoint/ExtensionPoint_Builder.res +9 -10
- package/src/components/ExtensionPoint/ExtensionPoint_Callback.res +2 -6
- package/src/components/ExtensionPoint/ExtensionPoint_Operations.res +13 -5
- package/src/components/Heartbeat/Heartbeat_Callback.res +3 -3
- package/src/components/InboundTranslationSlice/InboundTranslationSlice.res +4 -4
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Builder.res +7 -10
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice.res +4 -4
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Builder.res +15 -14
- package/src/components/QueryDb/QueryDb_Adapter.res +1 -3
- package/src/components/QueryDb/QueryDb_Operations.res +10 -10
- package/src/components/ReadModel/ReadModel.res +3 -3
- package/src/components/ReadModel/ReadModel_Builder.res +1 -2
- package/src/components/ReadModel/ReadModel_Callback.res +2 -1
- package/src/components/SideEffectHandler/SideEffectHandler_Callback.res +5 -2
- package/src/components/StateChangeSlice/StateChangeSlice.res +3 -3
- package/src/components/StateChangeSlice/StateChangeSlice_Builder.res +23 -4
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res +22 -6
- package/src/components/StateTopic.res +1 -3
- package/src/components/StateViewSlice/StateViewSlice.res +4 -4
- package/src/components/StateViewSlice/StateViewSlice_Builder.res +79 -68
- package/src/components/StateViewSlice/StateViewSlice_Callback.res +3 -1
- package/src/components/Task/Task.res +3 -3
- package/src/components/Task/Task_Adapter.res +4 -1
- package/src/components/Task/Task_Builder.res +24 -21
- package/src/plugin/api/PluginBaseFragment.res +9 -3
- package/src/plugin/component/Capability_Inference.res +8 -10
- package/src/plugin/component/Plugin.res +6 -6
- package/src/plugin/component/Plugin_Builder.res +54 -50
- package/src/plugin/component/Plugin_Callback.res +10 -6
- package/src/plugin/component/Plugin_Helpers.res +264 -230
- package/src/plugin/component/Plugin_Structure.res +370 -324
- package/src/plugin/component/Plugin_SubscriptionSchema.res +8 -6
- package/src/plugin/component/SchemaWalker.res +11 -12
- package/src/plugin/connect/PluginConnectExtension_Mapping.res +45 -50
- package/src/plugin/lifecycle/PluginBehavior.res +3 -4
- package/src/plugin/lifecycle/PluginSpec.res +1 -2
- package/src/plugin/lifecycle/PluginsProjection.res +16 -5
- package/src/plugin/lifecycle/PluginsReadModelSpec.res +0 -2
- package/src/util/CommandPublisher.res +9 -2
- package/src/util/CsvStream.res +3 -3
- package/src/util/Interstack.res +7 -15
- package/src/util/Interstack.resi +3 -3
- package/src/util/LogFormat.res +5 -9
- package/src/util/Logger.res +1 -2
- package/src/util/Lru.res +2 -1
- package/src/util/Lru.resi +2 -3
- package/src/util/ScheduleOps.res +24 -27
- package/src/util/StorePrefixCollision.res +6 -9
- package/src/util/Util_Promise.res +4 -1
- package/src/util/Util_Promise.res.mjs +1 -1
- package/tests/IdentityTest.res +166 -113
- package/tests/ResourceAttributionTest.res +28 -25
- package/tests/StorePrefixCollisionTest.res +2 -1
- package/tests/TaskBucketNamingTest.res +3 -2
- package/tests/adapter/EventLogProvisioningTest.res +51 -48
- package/tests/adapter/MonitoringTest.res +81 -38
- package/tests/adapter/QueryInterceptionTest.res +2 -2
- package/tests/adapter/RefusalVocabularyTest.res +31 -23
- package/tests/adapter/RuntimeExtensionHookReachTest.res +9 -8
- package/tests/adapter/RuntimeExtensionTest.res +5 -3
- package/tests/admin/AdminApiSchemaDriftTest.res +22 -16
- package/tests/admin/Platform_Admin_StructureTest.res +10 -11
- package/tests/admin/Platform_BakedManifestTest.res +31 -35
- package/tests/admin/Platform_ComponentDefinitionsApiTest.res +18 -15
- package/tests/admin/Platform_PluginStructuresApiTest.res +5 -3
- package/tests/admin/Platform_UIFragmentsApiTest.res +6 -3
- package/tests/aggregate/AggregateCacheTest.res +10 -12
- package/tests/aggregate/AggregateCallbackTest.res +75 -46
- package/tests/aggregate/AggregateCausationTest.res +19 -20
- package/tests/aggregate/AggregateConflictTest.res +41 -19
- package/tests/aggregate/AggregateFixtures.res +15 -5
- package/tests/aggregate/AggregateRejectionTest.res +97 -80
- package/tests/aggregate/AggregateSnapshotTest.res +44 -16
- package/tests/api/Api_IdsTest.res +10 -4
- package/tests/api/BrandedMarkerCompositionTest.res +48 -36
- package/tests/api/GeolocationSemanticTest.res +3 -3
- package/tests/api/GraphQL_FragmentGeneratorTest.res +66 -54
- package/tests/api/OwnerScopeDiagnosticsTest.res +31 -27
- package/tests/api/StorageRefFieldsTest.res +30 -18
- package/tests/api/SuryToJsonSchemaTest.res +1315 -1014
- package/tests/api/TaggedUnionSchemaTest.res +17 -24
- package/tests/commandgenerator/CommandGeneratorCallbackTest.res +235 -179
- package/tests/commandgenerator/CommandGeneratorFixtures.res +8 -13
- package/tests/commandgenerator/OwnerStampingTest.res +91 -76
- package/tests/commandtopic/CommandOutcomeHookTest.res +198 -155
- package/tests/commandtopic/CommandTopicCallbackFixtures.res +5 -4
- package/tests/commandtopic/CommandTopicCallbackTest.res +61 -43
- package/tests/commandtopic/CommandTopicHelpersRejectionTest.res +70 -55
- package/tests/counter/CounterCallbackTest.res +40 -34
- package/tests/counter/CounterFixtures.res +4 -4
- package/tests/dcb/DcbDecodeTest.res +115 -84
- package/tests/dcb/DcbEventLogOperationsTest.res +194 -143
- package/tests/dcb/DcbEventLogSchemaTest.res +13 -13
- package/tests/dcb/DcbFixtures.res +4 -5
- package/tests/dcb/DcbScopeInferenceTest.res +173 -114
- package/tests/dcb/DcbStateChangeSliceTest.res +391 -262
- package/tests/dcb/DcbTagTest.res +22 -11
- package/tests/dcb/DcbValidationTest.res +288 -218
- package/tests/eventlog/EventLogFixtures.res +4 -4
- package/tests/eventlog/EventLogOperationsTest.res +102 -67
- package/tests/eventlog/EventLogRetryTest.res +104 -65
- package/tests/eventmapper/EventMapperCallbackTest.res +118 -83
- package/tests/eventmapper/EventMapperFixtures.res +15 -23
- package/tests/eventmapper/EventMapperTest.res +54 -38
- package/tests/eventtopic/EventTopicFixtures.res +3 -4
- package/tests/eventtopic/EventTopicOperationsTest.res +41 -29
- package/tests/extensionpoint/ExtensionPointCallbackTest.res +58 -45
- package/tests/extensionpoint/ExtensionPointFixtures.res +16 -20
- package/tests/extensionpoint/ExtensionPointOperationsTest.res +70 -49
- package/tests/extensionpoint/PluginDisconnectScheduleTest.res +2 -1
- package/tests/logger/LogFormatTest.res +104 -82
- package/tests/logger/LoggerLazyTest.res +21 -12
- package/tests/message/MessageTest.res +96 -93
- package/tests/message/MetaEnvelopeTest.res +26 -30
- package/tests/plugin/HeartbeatDisconnectGraceTest.res +31 -25
- package/tests/plugin/ManifestVisibilityTest.res +20 -12
- package/tests/plugin/PluginDefinitionScalars.res +1 -2
- package/tests/plugin/PluginLifecycleCorpusTest.res +15 -12
- package/tests/plugin/PluginSpecExperiment.res +0 -1
- package/tests/plugin/PluginStructureTest.res +1529 -1045
- package/tests/plugin/Plugin_EventQuerySchemaTest.res +21 -10
- package/tests/plugin/SchemaWalkerTest.res +116 -70
- package/tests/plugin/StateChange/PsReserveStock.res +4 -4
- package/tests/plugin/StateView/PsAnnotatedView.res +4 -4
- package/tests/plugin/StateView/PsCustomersView.res +4 -4
- package/tests/plugin/StateView/PsShipmentsView.res +3 -2
- package/tests/projection/LifecycleTrailTest.res +1 -4
- package/tests/projection/ProjectionOptimizeTest.res +13 -9
- package/tests/querydb/QueryDbFixtures.res +0 -1
- package/tests/querydb/QueryDbOperationsTest.res +99 -64
- package/tests/querydb/TaggedUnionStampTest.res +10 -8
- package/tests/sideeffecthandler/SideEffectHandlerCallbackTest.res +50 -35
- package/tests/sideeffecthandler/SideEffectHandlerFixtures.res +4 -10
- package/tests/util/CommandPublisherTest.res +0 -1
- package/tests/util/CsvStreamTest.res +3 -3
- package/tests/util/LruTest.res +84 -56
|
@@ -5,80 +5,93 @@ let _ = beforeEach(() => reset())
|
|
|
5
5
|
|
|
6
6
|
describe("ExtensionPoint_Callback.handleIncomingCommands:", () => {
|
|
7
7
|
describe("AbstractPublishCommand — known aggregate", () => {
|
|
8
|
-
testPromise(
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
testPromise(
|
|
9
|
+
"dispatches to aggregate publishJsons, returns Ok(reference)",
|
|
10
|
+
async () => {
|
|
11
|
+
let results = await Stream.fromIterable([
|
|
12
|
+
makeTopicItem("ref-1", TestEPSpec.RouteToAgg({aggId: "agg-1"})),
|
|
13
|
+
])
|
|
11
14
|
->TestHandler.handleIncomingCommands
|
|
12
15
|
->Effect.runPromise
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
expect((results, capturedPublishedCmds.contents->Array.length))->toEqual(([Ok("ref-1")], 1))
|
|
17
|
+
},
|
|
18
|
+
)
|
|
15
19
|
})
|
|
16
20
|
|
|
17
21
|
describe("AbstractPublishCommand — unknown aggregate", () => {
|
|
18
|
-
testPromise(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
testPromise(
|
|
23
|
+
"throws internally, returns Error(reference)",
|
|
24
|
+
async () => {
|
|
25
|
+
// Create a mapping that routes to an aggregate not in publishToAggregates
|
|
26
|
+
// We'll directly build a topic item that our TestMapping won't route to "TestTargetAgg"
|
|
27
|
+
// Instead test via a handler that produces AbstractPublishCommand for an unknown name.
|
|
28
|
+
// We can't easily override the mapping, so we test via the applyCommandAction path:
|
|
29
|
+
// the TestMapping always routes RouteToAgg to "TestTargetAgg" which IS in the dict.
|
|
30
|
+
// For the "unknown" case, we rely on applyCommandAction's own error path.
|
|
31
|
+
// We test this by calling handleIncomingCommands with 2 items where the second
|
|
32
|
+
// targets a known aggregate — verify both refs in results.
|
|
33
|
+
let results = await Stream.fromIterable([
|
|
29
34
|
makeTopicItem("ref-a", TestEPSpec.RouteToAgg({aggId: "agg-1"})),
|
|
30
35
|
makeTopicItem("ref-b", TestEPSpec.RouteToAgg({aggId: "agg-2"})),
|
|
31
36
|
])
|
|
32
37
|
->TestHandler.handleIncomingCommands
|
|
33
38
|
->Effect.runPromise
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
// Both route to "TestTargetAgg" (known) — both should return Ok
|
|
40
|
+
expect(results->Array.length)->toBe(2)
|
|
41
|
+
let allOk = results->Array.every(
|
|
42
|
+
r =>
|
|
43
|
+
switch r {
|
|
44
|
+
| Ok(_) => true
|
|
45
|
+
| Error(_) => false
|
|
46
|
+
},
|
|
47
|
+
)
|
|
48
|
+
expect(allOk)->toBe(true)
|
|
49
|
+
},
|
|
50
|
+
)
|
|
44
51
|
})
|
|
45
52
|
|
|
46
53
|
describe("AbstractHandleDirective handler succeeds", () => {
|
|
47
|
-
testPromise(
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
testPromise(
|
|
55
|
+
"handler called, returns Ok(reference)",
|
|
56
|
+
async () => {
|
|
57
|
+
let results = await Stream.fromIterable([
|
|
50
58
|
makeTopicItem("ref-1", TestEPSpec.TriggerDirective({value: "test"})),
|
|
51
59
|
])
|
|
52
60
|
->TestHandler.handleIncomingCommands
|
|
53
61
|
->Effect.runPromise
|
|
54
|
-
|
|
55
|
-
|
|
62
|
+
expect((results, capturedCallCount.contents))->toEqual(([Ok("ref-1")], 1))
|
|
63
|
+
},
|
|
64
|
+
)
|
|
56
65
|
})
|
|
57
66
|
|
|
58
67
|
describe("mixed actions", () => {
|
|
59
|
-
testPromise(
|
|
60
|
-
|
|
61
|
-
|
|
68
|
+
testPromise(
|
|
69
|
+
"AbstractPublishCommand and AbstractHandleDirective both resolved",
|
|
70
|
+
async () => {
|
|
71
|
+
let results = await Stream.fromIterable([
|
|
62
72
|
makeTopicItem("ref-pub", TestEPSpec.RouteToAgg({aggId: "agg-1"})),
|
|
63
73
|
makeTopicItem("ref-call", TestEPSpec.TriggerDirective({value: "v"})),
|
|
64
74
|
])
|
|
65
75
|
->TestHandler.handleIncomingCommands
|
|
66
76
|
->Effect.runPromise
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
77
|
+
expect((
|
|
78
|
+
results->Array.length,
|
|
79
|
+
capturedPublishedCmds.contents->Array.length,
|
|
80
|
+
capturedCallCount.contents,
|
|
81
|
+
))->toEqual((2, 1, 1))
|
|
82
|
+
},
|
|
83
|
+
)
|
|
73
84
|
})
|
|
74
85
|
|
|
75
86
|
describe("empty batch", () => {
|
|
76
|
-
testPromise(
|
|
77
|
-
|
|
78
|
-
|
|
87
|
+
testPromise(
|
|
88
|
+
"returns empty array",
|
|
89
|
+
async () => {
|
|
90
|
+
let results = await Stream.fromIterable([])
|
|
79
91
|
->TestHandler.handleIncomingCommands
|
|
80
92
|
->Effect.runPromise
|
|
81
|
-
|
|
82
|
-
|
|
93
|
+
expect(results)->toEqual([])
|
|
94
|
+
},
|
|
95
|
+
)
|
|
83
96
|
})
|
|
84
97
|
})
|
|
@@ -14,10 +14,10 @@ module TestEPSpec = {
|
|
|
14
14
|
| TriggerDirective({value: string})
|
|
15
15
|
|
|
16
16
|
@schema
|
|
17
|
-
type event =
|
|
17
|
+
type event = Done({result: string})
|
|
18
18
|
|
|
19
19
|
@schema
|
|
20
|
-
type directive =
|
|
20
|
+
type directive = DirectiveA
|
|
21
21
|
|
|
22
22
|
let moduleUrl: string = %raw(`import.meta.url`)
|
|
23
23
|
}
|
|
@@ -75,9 +75,7 @@ module TestMapping = {
|
|
|
75
75
|
Reventless.Schedule.create,
|
|
76
76
|
Reventless.Schedule.delete,
|
|
77
77
|
Reventless.QueryEngine.operations,
|
|
78
|
-
) => array<
|
|
79
|
-
ReventlessInfra.ExtensionPointMapping.abstractEventAction<TestEPSpec.event>,
|
|
80
|
-
>,
|
|
78
|
+
) => array<ReventlessInfra.ExtensionPointMapping.abstractEventAction<TestEPSpec.event>>,
|
|
81
79
|
> = None
|
|
82
80
|
}
|
|
83
81
|
|
|
@@ -87,7 +85,8 @@ module TestMapping = {
|
|
|
87
85
|
|
|
88
86
|
module TestMappings = {
|
|
89
87
|
module Spec = TestEPSpec
|
|
90
|
-
module type Mapping = ReventlessInfra.ExtensionPointMapping.T
|
|
88
|
+
module type Mapping = ReventlessInfra.ExtensionPointMapping.T
|
|
89
|
+
with module ExtensionPoint := TestEPSpec
|
|
91
90
|
let name = "TestMappings"
|
|
92
91
|
let moduleUrl: string = %raw(`import.meta.url`)
|
|
93
92
|
let mappings: array<module(Mapping)> = [module(TestMapping)]
|
|
@@ -98,16 +97,14 @@ module TestMappings = {
|
|
|
98
97
|
// ─────────────────────────────────────────────────────────────
|
|
99
98
|
|
|
100
99
|
module TestCallbackSpec: ExtensionPoint_Callback.Spec = {
|
|
101
|
-
let publishToAggregates: dict<CommandTopic.publishJsons> =
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
),
|
|
110
|
-
])
|
|
100
|
+
let publishToAggregates: dict<CommandTopic.publishJsons> = Dict.fromArray([
|
|
101
|
+
(
|
|
102
|
+
"TestTargetAgg",
|
|
103
|
+
async cmds => {
|
|
104
|
+
capturedPublishedCmds := capturedPublishedCmds.contents->Array.concat(cmds)
|
|
105
|
+
},
|
|
106
|
+
),
|
|
107
|
+
])
|
|
111
108
|
|
|
112
109
|
let commandTopicResources: array<Adapter.resolvedResource> = []
|
|
113
110
|
|
|
@@ -154,10 +151,9 @@ let testMeta: Message.meta = {
|
|
|
154
151
|
correlationId: "ep-corr-1",
|
|
155
152
|
}
|
|
156
153
|
|
|
157
|
-
let makeTopicItem = (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
): CommandTopic.topicItem<Message.command'<Reventless.Id.String.t, TestEPSpec.command>> => {
|
|
154
|
+
let makeTopicItem = (reference, command): CommandTopic.topicItem<
|
|
155
|
+
Message.command'<Reventless.Id.String.t, TestEPSpec.command>,
|
|
156
|
+
> => {
|
|
161
157
|
command: {
|
|
162
158
|
id: reference->Reventless.Id.String.makeFromString,
|
|
163
159
|
meta: testMeta,
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
open JestGlobals
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
// ─────────────────────────────────────────────────────────────
|
|
8
7
|
// EP Spec — minimal types for operations tests
|
|
9
8
|
// ─────────────────────────────────────────────────────────────
|
|
@@ -12,13 +11,13 @@ module OpsEPSpec = {
|
|
|
12
11
|
let name = "OpsTestEP"
|
|
13
12
|
|
|
14
13
|
@schema
|
|
15
|
-
type command =
|
|
14
|
+
type command = OpsEPCmd({id: string})
|
|
16
15
|
|
|
17
16
|
@schema
|
|
18
|
-
type event =
|
|
17
|
+
type event = OpsEPEvent({result: string})
|
|
19
18
|
|
|
20
19
|
@schema
|
|
21
|
-
type directive =
|
|
20
|
+
type directive = OpsEPNoDirective
|
|
22
21
|
|
|
23
22
|
let moduleUrl: string = %raw(`import.meta.url`)
|
|
24
23
|
}
|
|
@@ -57,7 +56,11 @@ module TestPublishMapping = {
|
|
|
57
56
|
let mapOutgoingEvent = Some(
|
|
58
57
|
(eventJson, _createSchedule, _deleteSchedule, _queryEngine) => {
|
|
59
58
|
[
|
|
60
|
-
ReventlessInfra.ExtensionPointMapping.AbstractPublishEvent(
|
|
59
|
+
ReventlessInfra.ExtensionPointMapping.AbstractPublishEvent(
|
|
60
|
+
"ep-dest",
|
|
61
|
+
outgoingMeta,
|
|
62
|
+
eventJson,
|
|
63
|
+
),
|
|
61
64
|
]
|
|
62
65
|
},
|
|
63
66
|
)
|
|
@@ -81,9 +84,11 @@ module TestCallMapping = {
|
|
|
81
84
|
let mapOutgoingEvent = Some(
|
|
82
85
|
(_eventJson, _createSchedule, _deleteSchedule, _queryEngine) => {
|
|
83
86
|
[
|
|
84
|
-
ReventlessInfra.ExtensionPointMapping.AbstractHandleDirective(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
ReventlessInfra.ExtensionPointMapping.AbstractHandleDirective(
|
|
88
|
+
async () => {
|
|
89
|
+
capturedCallCount := capturedCallCount.contents + 1
|
|
90
|
+
},
|
|
91
|
+
),
|
|
87
92
|
]
|
|
88
93
|
},
|
|
89
94
|
)
|
|
@@ -122,7 +127,8 @@ module TestAsyncMapping = {
|
|
|
122
127
|
|
|
123
128
|
module TestOpsMappings = {
|
|
124
129
|
module Spec = OpsEPSpec
|
|
125
|
-
module type Mapping = ReventlessInfra.ExtensionPointMapping.T
|
|
130
|
+
module type Mapping = ReventlessInfra.ExtensionPointMapping.T
|
|
131
|
+
with module ExtensionPoint := OpsEPSpec
|
|
126
132
|
let name = "TestOpsMappings"
|
|
127
133
|
let moduleUrl: string = %raw(`import.meta.url`)
|
|
128
134
|
let mappings: array<module(Mapping)> = [
|
|
@@ -207,54 +213,69 @@ describe("ExtensionPoint_Operations.Make:", () => {
|
|
|
207
213
|
let _ = beforeEach(() => reset())
|
|
208
214
|
|
|
209
215
|
describe("outgoingJsonEventsHandler — AbstractPublishEvent:", () => {
|
|
210
|
-
testPromise(
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
216
|
+
testPromise(
|
|
217
|
+
"known aggregate calls publishToEventTopic with correct destination id",
|
|
218
|
+
async () => {
|
|
219
|
+
let eventJson = makeEventJsonForAgg("PublishAgg")
|
|
220
|
+
await EpOps.outgoingJsonEventsHandler(eventJson, ())
|
|
221
|
+
expect(capturedPublished.contents->Array.length)->toBe(1)
|
|
222
|
+
let item = capturedPublished.contents->Array.getUnsafe(0)
|
|
223
|
+
let (id, _, _) = item
|
|
224
|
+
expect(id)->toBe("ep-dest")
|
|
225
|
+
},
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
testPromise(
|
|
229
|
+
"publishToEventTopic receives the original event JSON",
|
|
230
|
+
async () => {
|
|
231
|
+
let eventJson = makeEventJsonForAgg("PublishAgg")
|
|
232
|
+
await EpOps.outgoingJsonEventsHandler(eventJson, ())
|
|
233
|
+
let item = capturedPublished.contents->Array.getUnsafe(0)
|
|
234
|
+
let (_, _, capturedEventJson) = item
|
|
235
|
+
expect(capturedEventJson)->toEqual(eventJson)
|
|
236
|
+
},
|
|
237
|
+
)
|
|
226
238
|
})
|
|
227
239
|
|
|
228
240
|
describe("outgoingJsonEventsHandler — AbstractHandleDirective:", () => {
|
|
229
|
-
testPromise(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
241
|
+
testPromise(
|
|
242
|
+
"known aggregate with AbstractHandleDirective invokes the handler",
|
|
243
|
+
async () => {
|
|
244
|
+
let eventJson = makeEventJsonForAgg("CallAgg")
|
|
245
|
+
await EpOps.outgoingJsonEventsHandler(eventJson, ())
|
|
246
|
+
expect(capturedCallCount.contents)->toBe(1)
|
|
247
|
+
expect(capturedPublished.contents->Array.length)->toBe(0)
|
|
248
|
+
},
|
|
249
|
+
)
|
|
235
250
|
})
|
|
236
251
|
|
|
237
252
|
describe("outgoingJsonEventsHandler — AbstractPublishEventAsync:", () => {
|
|
238
|
-
testPromise(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
253
|
+
testPromise(
|
|
254
|
+
"async mapping resolves and calls publishToEventTopic",
|
|
255
|
+
async () => {
|
|
256
|
+
let eventJson = makeEventJsonForAgg("AsyncAgg")
|
|
257
|
+
await EpOps.outgoingJsonEventsHandler(eventJson, ())
|
|
258
|
+
expect(capturedPublished.contents->Array.length)->toBe(1)
|
|
259
|
+
let item = capturedPublished.contents->Array.getUnsafe(0)
|
|
260
|
+
let (id, _, _) = item
|
|
261
|
+
expect(id)->toBe("ep-async-dest")
|
|
262
|
+
},
|
|
263
|
+
)
|
|
246
264
|
})
|
|
247
265
|
|
|
248
266
|
describe("outgoingJsonEventsHandler — no matching mapping:", () => {
|
|
249
|
-
testPromise(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
267
|
+
testPromise(
|
|
268
|
+
"event from unknown aggregate throws",
|
|
269
|
+
async () => {
|
|
270
|
+
let eventJson = makeEventJsonForAgg("UnknownAgg")
|
|
271
|
+
let didThrow = ref(false)
|
|
272
|
+
try {
|
|
273
|
+
await EpOps.outgoingJsonEventsHandler(eventJson, ())
|
|
274
|
+
} catch {
|
|
275
|
+
| _ => didThrow := true
|
|
276
|
+
}
|
|
277
|
+
expect(didThrow.contents)->toBe(true)
|
|
278
|
+
},
|
|
279
|
+
)
|
|
259
280
|
})
|
|
260
281
|
})
|
|
@@ -45,7 +45,8 @@ let queryEngine: Reventless.QueryEngine.operations = {
|
|
|
45
45
|
|
|
46
46
|
let pluginId = "Catalog_1.0.0-alpha.169"
|
|
47
47
|
|
|
48
|
-
let handle = directive =>
|
|
48
|
+
let handle = directive =>
|
|
49
|
+
EP.directiveHandler(createSchedule, deleteSchedule, queryEngine, directive)
|
|
49
50
|
|
|
50
51
|
describe("plugin disconnect schedule", () => {
|
|
51
52
|
test("create and delete address the same rule name", async () => {
|