@reventlessdev/reventless-core 3.0.0-alpha.179 → 3.0.0-alpha.181

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/package.json +8 -8
  3. package/src/Message.res +2 -1
  4. package/src/Message.res.mjs +5 -1
  5. package/src/adapter/Monitoring/Monitoring.res +14 -2
  6. package/src/adapter/Monitoring/Monitoring.res.mjs +4 -2
  7. package/src/admin/Platform_Admin_Structure.res +2 -0
  8. package/src/admin/Platform_Admin_Structure.res.mjs +2 -0
  9. package/src/admin/Platform_ComponentDefinitionsApi.res +2 -1
  10. package/src/admin/Platform_ComponentDefinitionsApi.res.mjs +5 -1
  11. package/src/admin/UiFragmentRegistry/StateViewSlice/UiFragments_Projection.res +1 -1
  12. package/src/admin/UiFragmentRegistry/StateViewSlice/UiFragments_Projection.res.mjs +2 -1
  13. package/src/components/Api/ApiTargetStateHelpers.res +20 -0
  14. package/src/components/Api/ApiTargetStateHelpers.res.mjs +16 -0
  15. package/src/components/Api/GraphQL_FragmentGenerator.res +1 -0
  16. package/src/components/Api/GraphQL_FragmentGenerator.res.mjs +1 -0
  17. package/src/components/Api/SchemaType.res +3 -0
  18. package/src/components/Api/SchemaType.res.mjs +10 -2
  19. package/src/components/Api/SuryToJsonSchema.res +16 -0
  20. package/src/components/Api/SuryToJsonSchema.res.mjs +28 -0
  21. package/src/components/Dcb/Dcb_Builder.res +4 -5
  22. package/src/components/Dcb/Dcb_Builder.res.mjs +3 -5
  23. package/src/components/DcbEventLog/DcbEventLog_Operations.res +6 -1
  24. package/src/components/DcbEventLog/DcbEventLog_Operations.res.mjs +2 -1
  25. package/src/components/InboundTranslationSlice/InboundTranslationSlice.res +25 -0
  26. package/src/components/InboundTranslationSlice/InboundTranslationSlice.res.mjs +31 -0
  27. package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res +8 -8
  28. package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res.mjs +26 -6
  29. package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Builder.res +44 -37
  30. package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Builder.res.mjs +17 -25
  31. package/src/components/StateChangeSlice/StateChangeSlice_Callback.res +27 -2
  32. package/src/components/StateChangeSlice/StateChangeSlice_Callback.res.mjs +4 -0
  33. package/src/components/StateViewSlice/StateViewSlice_Builder.res +20 -6
  34. package/src/components/StateViewSlice/StateViewSlice_Builder.res.mjs +23 -5
  35. package/src/components/StateViewSlice/StateViewSlice_Callback.res +1 -1
  36. package/src/components/StateViewSlice/StateViewSlice_Callback.res.mjs +5 -1
  37. package/src/plugin/component/Plugin_Helpers.res +4 -1
  38. package/src/plugin/component/Plugin_Structure.res +15 -1
  39. package/src/plugin/component/Plugin_Structure.res.mjs +4 -1
  40. package/src/plugin/lifecycle/PluginsReadModelSpec.res.mjs +2 -0
  41. package/tests/IdentityTest.res.mjs +174 -0
  42. package/tests/ResourceAttributionTest.res.mjs +75 -0
  43. package/tests/adapter/MonitoringTest.res +32 -2
  44. package/tests/adapter/MonitoringTest.res.mjs +116 -0
  45. package/tests/admin/Platform_ComponentDefinitionsApiTest.res +10 -0
  46. package/tests/admin/Platform_ComponentDefinitionsApiTest.res.mjs +365 -0
  47. package/tests/admin/Platform_UIFragmentsApiTest.res.mjs +101 -0
  48. package/tests/aggregate/AggregateCacheTest.res.mjs +433 -0
  49. package/tests/aggregate/AggregateCallbackTest.res.mjs +143 -0
  50. package/tests/aggregate/AggregateCausationTest.res.mjs +47 -0
  51. package/tests/aggregate/AggregateConflictTest.res.mjs +386 -0
  52. package/tests/aggregate/AggregateFixtures.res.mjs +308 -0
  53. package/tests/aggregate/AggregateRejectionTest.res.mjs +166 -0
  54. package/tests/aggregate/AggregateSnapshotTest.res.mjs +645 -0
  55. package/tests/api/ApiNoApiTest.res.mjs +90 -0
  56. package/tests/api/GraphQL_StitcherTest.res.mjs +112 -0
  57. package/tests/api/SimpleTest.res.mjs +10 -0
  58. package/tests/api/SuryToJsonSchemaTest.res +68 -0
  59. package/tests/api/SuryToJsonSchemaTest.res.mjs +843 -0
  60. package/tests/commandgenerator/CommandGeneratorCallbackTest.res.mjs +160 -0
  61. package/tests/commandgenerator/CommandGeneratorFixtures.res.mjs +197 -0
  62. package/tests/commandtopic/CommandTopicCallbackFixtures.res.mjs +152 -0
  63. package/tests/commandtopic/CommandTopicCallbackTest.res.mjs +106 -0
  64. package/tests/commandtopic/CommandTopicHelpersRejectionTest.res.mjs +109 -0
  65. package/tests/counter/CounterCallbackTest.res.mjs +140 -0
  66. package/tests/counter/CounterFixtures.res.mjs +67 -0
  67. package/tests/dcb/DcbDecodeTest.res.mjs +194 -0
  68. package/tests/dcb/DcbEventLogOperationsTest.res.mjs +268 -0
  69. package/tests/dcb/DcbFixtures.res.mjs +534 -0
  70. package/tests/dcb/DcbScopeInferenceTest.res.mjs +480 -0
  71. package/tests/dcb/DcbStateChangeSliceTest.res.mjs +540 -0
  72. package/tests/dcb/DcbTagTest.res.mjs +867 -0
  73. package/tests/dcb/DcbValidationTest.res.mjs +476 -0
  74. package/tests/eventlog/EventLogFixtures.res.mjs +196 -0
  75. package/tests/eventlog/EventLogOperationsTest.res.mjs +192 -0
  76. package/tests/eventlog/EventLogRetryTest.res.mjs +195 -0
  77. package/tests/eventmapper/EventMapperCallbackTest.res.mjs +141 -0
  78. package/tests/eventmapper/EventMapperFixtures.res.mjs +440 -0
  79. package/tests/eventmapper/EventMapperTest.res.mjs +83 -0
  80. package/tests/eventtopic/EventTopicFixtures.res.mjs +65 -0
  81. package/tests/eventtopic/EventTopicOperationsTest.res.mjs +71 -0
  82. package/tests/extensionpoint/ExtensionPointCallbackTest.res.mjs +94 -0
  83. package/tests/extensionpoint/ExtensionPointFixtures.res.mjs +205 -0
  84. package/tests/extensionpoint/ExtensionPointOperationsTest.res.mjs +304 -0
  85. package/tests/extensionpoint/PluginDisconnectScheduleTest.res.mjs +92 -0
  86. package/tests/ftp/FTPTest.res.mjs +88 -0
  87. package/tests/logger/LogFormatTest.res.mjs +329 -0
  88. package/tests/logger/LoggerLazyTest.res.mjs +40 -0
  89. package/tests/message/MessageTest.res.mjs +218 -0
  90. package/tests/message/MetaEnvelopeTest.res.mjs +188 -0
  91. package/tests/plugin/HeartbeatDisconnectGraceTest.res.mjs +91 -0
  92. package/tests/plugin/ManifestVisibilityTest.res.mjs +215 -0
  93. package/tests/plugin/PluginSpecExperiment.res.mjs +31 -0
  94. package/tests/plugin/PluginStructureTest.res +55 -0
  95. package/tests/plugin/PluginStructureTest.res.mjs +467 -0
  96. package/tests/plugin/PluginVersionTest.res.mjs +30 -0
  97. package/tests/plugin/SchemaWalkerTest.res.mjs +160 -0
  98. package/tests/plugin/StateChangeSlice/PsPlaceOrder.res.mjs +62 -0
  99. package/tests/plugin/StateChangeSlice/PsShipOrder.res +4 -1
  100. package/tests/plugin/StateChangeSlice/PsShipOrder.res.mjs +77 -0
  101. package/tests/plugin/StateViewSlice/PsAnnotatedView.res +5 -4
  102. package/tests/plugin/StateViewSlice/PsAnnotatedView.res.mjs +110 -0
  103. package/tests/plugin/StateViewSlice/PsAvailableProductsView.res +1 -1
  104. package/tests/plugin/StateViewSlice/PsAvailableProductsView.res.mjs +70 -0
  105. package/tests/plugin/StateViewSlice/PsCustomersView.res +1 -1
  106. package/tests/plugin/StateViewSlice/PsCustomersView.res.mjs +70 -0
  107. package/tests/plugin/StateViewSlice/PsOrdersView.res +1 -1
  108. package/tests/plugin/StateViewSlice/PsOrdersView.res.mjs +82 -0
  109. package/tests/poc/StructuralSubtypingPoc.res.mjs +61 -0
  110. package/tests/projection/ProjectionOptimizeTest.res.mjs +75 -0
  111. package/tests/querydb/QueryDbFixtures.res.mjs +135 -0
  112. package/tests/querydb/QueryDbOperationsTest.res.mjs +168 -0
  113. package/tests/sideeffecthandler/SideEffectHandlerCallbackTest.res.mjs +77 -0
  114. package/tests/sideeffecthandler/SideEffectHandlerFixtures.res.mjs +139 -0
  115. package/tests/util/CommandPublisherTest.res.mjs +78 -0
  116. package/tests/util/CsvStreamTest.res.mjs +51 -0
  117. package/tests/util/LruTest.res.mjs +105 -0
  118. package/tests/util/MetricsTest.res.mjs +53 -0
@@ -0,0 +1,94 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Effect from "effect/Effect";
4
+ import * as Stream from "effect/Stream";
5
+ import * as ExtensionPointFixtures$ReventlessCore from "./ExtensionPointFixtures.res.mjs";
6
+
7
+ globalThis.beforeEach(() => ExtensionPointFixtures$ReventlessCore.reset());
8
+
9
+ globalThis.describe("ExtensionPoint_Callback.handleIncomingCommands:", () => {
10
+ globalThis.describe("AbstractPublishCommand — known aggregate", () => {
11
+ globalThis.test("dispatches to aggregate publishJsons, returns Ok(reference)", async () => {
12
+ let results = await Effect.runPromise(ExtensionPointFixtures$ReventlessCore.TestHandler.handleIncomingCommands(Stream.fromIterable([ExtensionPointFixtures$ReventlessCore.makeTopicItem("ref-1", {
13
+ TAG: "RouteToAgg",
14
+ aggId: "agg-1"
15
+ })])));
16
+ globalThis.expect([
17
+ results,
18
+ ExtensionPointFixtures$ReventlessCore.capturedPublishedCmds.contents.length
19
+ ]).toEqual([
20
+ [{
21
+ TAG: "Ok",
22
+ _0: "ref-1"
23
+ }],
24
+ 1
25
+ ]);
26
+ });
27
+ });
28
+ globalThis.describe("AbstractPublishCommand — unknown aggregate", () => {
29
+ globalThis.test("throws internally, returns Error(reference)", async () => {
30
+ let results = await Effect.runPromise(ExtensionPointFixtures$ReventlessCore.TestHandler.handleIncomingCommands(Stream.fromIterable([
31
+ ExtensionPointFixtures$ReventlessCore.makeTopicItem("ref-a", {
32
+ TAG: "RouteToAgg",
33
+ aggId: "agg-1"
34
+ }),
35
+ ExtensionPointFixtures$ReventlessCore.makeTopicItem("ref-b", {
36
+ TAG: "RouteToAgg",
37
+ aggId: "agg-2"
38
+ })
39
+ ])));
40
+ globalThis.expect(results.length).toBe(2);
41
+ let allOk = results.every(r => r.TAG === "Ok");
42
+ globalThis.expect(allOk).toBe(true);
43
+ });
44
+ });
45
+ globalThis.describe("AbstractHandleDirective handler succeeds", () => {
46
+ globalThis.test("handler called, returns Ok(reference)", async () => {
47
+ let results = await Effect.runPromise(ExtensionPointFixtures$ReventlessCore.TestHandler.handleIncomingCommands(Stream.fromIterable([ExtensionPointFixtures$ReventlessCore.makeTopicItem("ref-1", {
48
+ TAG: "TriggerDirective",
49
+ value: "test"
50
+ })])));
51
+ globalThis.expect([
52
+ results,
53
+ ExtensionPointFixtures$ReventlessCore.capturedCallCount.contents
54
+ ]).toEqual([
55
+ [{
56
+ TAG: "Ok",
57
+ _0: "ref-1"
58
+ }],
59
+ 1
60
+ ]);
61
+ });
62
+ });
63
+ globalThis.describe("mixed actions", () => {
64
+ globalThis.test("AbstractPublishCommand and AbstractHandleDirective both resolved", async () => {
65
+ let results = await Effect.runPromise(ExtensionPointFixtures$ReventlessCore.TestHandler.handleIncomingCommands(Stream.fromIterable([
66
+ ExtensionPointFixtures$ReventlessCore.makeTopicItem("ref-pub", {
67
+ TAG: "RouteToAgg",
68
+ aggId: "agg-1"
69
+ }),
70
+ ExtensionPointFixtures$ReventlessCore.makeTopicItem("ref-call", {
71
+ TAG: "TriggerDirective",
72
+ value: "v"
73
+ })
74
+ ])));
75
+ globalThis.expect([
76
+ results.length,
77
+ ExtensionPointFixtures$ReventlessCore.capturedPublishedCmds.contents.length,
78
+ ExtensionPointFixtures$ReventlessCore.capturedCallCount.contents
79
+ ]).toEqual([
80
+ 2,
81
+ 1,
82
+ 1
83
+ ]);
84
+ });
85
+ });
86
+ globalThis.describe("empty batch", () => {
87
+ globalThis.test("returns empty array", async () => {
88
+ let results = await Effect.runPromise(ExtensionPointFixtures$ReventlessCore.TestHandler.handleIncomingCommands(Stream.fromIterable([])));
89
+ globalThis.expect(results).toEqual([]);
90
+ });
91
+ });
92
+ });
93
+
94
+ /* Not a pure module */
@@ -0,0 +1,205 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as S from "sury/src/S.res.mjs";
4
+ import * as Id$Reventless from "@reventlessdev/reventless-spec/src/types/Id.res.mjs";
5
+ import * as ExtensionPoint_Callback$ReventlessCore from "../../src/components/ExtensionPoint/ExtensionPoint_Callback.res.mjs";
6
+
7
+ S.enableJson();
8
+
9
+ let name = "TestExtensionPoint";
10
+
11
+ let commandSchema = S.union([
12
+ S.schema(s => ({
13
+ TAG: "RouteToAgg",
14
+ aggId: s.m(S.string)
15
+ })),
16
+ S.schema(s => ({
17
+ TAG: "TriggerDirective",
18
+ value: s.m(S.string)
19
+ }))
20
+ ]);
21
+
22
+ let eventSchema = S.schema(s => ({
23
+ TAG: "Done",
24
+ result: s.m(S.string)
25
+ }));
26
+
27
+ let directiveSchema = S.literal("DirectiveA");
28
+
29
+ let moduleUrl = import.meta.url;
30
+
31
+ function commandAuthorization(param) {
32
+ return "AllowAuthenticated";
33
+ }
34
+
35
+ let TestEPSpec = {
36
+ name: name,
37
+ commandSchema: commandSchema,
38
+ eventSchema: eventSchema,
39
+ directiveSchema: directiveSchema,
40
+ moduleUrl: moduleUrl,
41
+ commandAuthorization: commandAuthorization
42
+ };
43
+
44
+ let capturedPublishedCmds = {
45
+ contents: []
46
+ };
47
+
48
+ let capturedCallCount = {
49
+ contents: 0
50
+ };
51
+
52
+ let delegateName = "TestTargetAgg";
53
+
54
+ function mapIncomingCommands(topicItems, _createSchedule, _deleteSchedule, _queryEngine) {
55
+ return topicItems.flatMap(topicItem => {
56
+ let match = topicItem.command.command;
57
+ if (match.TAG === "RouteToAgg") {
58
+ return [{
59
+ TAG: "AbstractPublishCommand",
60
+ _0: "TestTargetAgg",
61
+ _1: topicItem.reference,
62
+ _2: {
63
+ id: match.aggId,
64
+ meta: topicItem.command.meta,
65
+ commandJson: "Create"
66
+ }
67
+ }];
68
+ } else {
69
+ return [{
70
+ TAG: "AbstractHandleDirective",
71
+ _0: topicItem.reference,
72
+ _1: async () => {
73
+ capturedCallCount.contents = capturedCallCount.contents + 1 | 0;
74
+ }
75
+ }];
76
+ }
77
+ });
78
+ }
79
+
80
+ let TestMapping = {
81
+ ExtensionPoint: undefined,
82
+ delegateName: delegateName,
83
+ mapIncomingCommands: mapIncomingCommands,
84
+ mapOutgoingEvent: undefined
85
+ };
86
+
87
+ let moduleUrl$1 = import.meta.url;
88
+
89
+ let mappings = [{
90
+ delegateName: delegateName,
91
+ mapIncomingCommands: mapIncomingCommands,
92
+ mapOutgoingEvent: undefined
93
+ }];
94
+
95
+ let TestMappings = {
96
+ Spec: undefined,
97
+ name: "TestMappings",
98
+ moduleUrl: moduleUrl$1,
99
+ mappings: mappings
100
+ };
101
+
102
+ let publishToAggregates = Object.fromEntries([[
103
+ "TestTargetAgg",
104
+ async cmds => {
105
+ capturedPublishedCmds.contents = capturedPublishedCmds.contents.concat(cmds);
106
+ }
107
+ ]]);
108
+
109
+ let commandTopicResources = [];
110
+
111
+ async function scheduler_createSchedule(_resources, _schedule) {
112
+
113
+ }
114
+
115
+ async function scheduler_deleteSchedule(_resources, _name) {
116
+
117
+ }
118
+
119
+ let scheduler = {
120
+ createSchedule: scheduler_createSchedule,
121
+ deleteSchedule: scheduler_deleteSchedule
122
+ };
123
+
124
+ async function queryEngine_scan(param, param$1, param$2) {
125
+ return [];
126
+ }
127
+
128
+ async function queryEngine_query(param, param$1, param$2, param$3, param$4, param$5, param$6) {
129
+ return [];
130
+ }
131
+
132
+ let queryEngine = {
133
+ scan: queryEngine_scan,
134
+ query: queryEngine_query
135
+ };
136
+
137
+ function resourceNaming_validateName(name) {
138
+ return name;
139
+ }
140
+
141
+ function resourceNaming_urnName(name) {
142
+ return name;
143
+ }
144
+
145
+ let resourceNaming = {
146
+ validateName: resourceNaming_validateName,
147
+ urnName: resourceNaming_urnName
148
+ };
149
+
150
+ let TestCallbackSpec = {
151
+ publishToAggregates: publishToAggregates,
152
+ commandTopicResources: commandTopicResources,
153
+ scheduler: scheduler,
154
+ queryEngine: queryEngine,
155
+ resourceNaming: resourceNaming
156
+ };
157
+
158
+ let TestHandler = ExtensionPoint_Callback$ReventlessCore.Make(TestCallbackSpec)({
159
+ name: name,
160
+ moduleUrl: moduleUrl,
161
+ commandSchema: commandSchema,
162
+ eventSchema: eventSchema,
163
+ directiveSchema: directiveSchema
164
+ })({
165
+ mappings: mappings
166
+ });
167
+
168
+ let testMeta = {
169
+ service: "TestExtensionPoint",
170
+ time: "2024-01-01T00:00:00Z",
171
+ ip: "127.0.0.1",
172
+ user: "test-user",
173
+ msgId: "ep-msg-1",
174
+ correlationId: "ep-corr-1"
175
+ };
176
+
177
+ function makeTopicItem(reference, command) {
178
+ return {
179
+ command: {
180
+ id: Id$Reventless.$$String.makeFromString(reference),
181
+ meta: testMeta,
182
+ command: command
183
+ },
184
+ reference: reference
185
+ };
186
+ }
187
+
188
+ function reset() {
189
+ capturedPublishedCmds.contents = [];
190
+ capturedCallCount.contents = 0;
191
+ }
192
+
193
+ export {
194
+ TestEPSpec,
195
+ capturedPublishedCmds,
196
+ capturedCallCount,
197
+ TestMapping,
198
+ TestMappings,
199
+ TestCallbackSpec,
200
+ TestHandler,
201
+ testMeta,
202
+ makeTopicItem,
203
+ reset,
204
+ }
205
+ /* Not a pure module */
@@ -0,0 +1,304 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as S from "sury/src/S.res.mjs";
4
+ import * as Message$Reventless from "@reventlessdev/reventless-spec/src/types/Message.res.mjs";
5
+ import * as ExtensionPoint_Operations$ReventlessCore from "../../src/components/ExtensionPoint/ExtensionPoint_Operations.res.mjs";
6
+
7
+ S.enableJson();
8
+
9
+ let name = "OpsTestEP";
10
+
11
+ let commandSchema = S.schema(s => ({
12
+ TAG: "OpsEPCmd",
13
+ id: s.m(S.string)
14
+ }));
15
+
16
+ let eventSchema = S.schema(s => ({
17
+ TAG: "OpsEPEvent",
18
+ result: s.m(S.string)
19
+ }));
20
+
21
+ let directiveSchema = S.literal("OpsEPNoDirective");
22
+
23
+ let moduleUrl = import.meta.url;
24
+
25
+ function commandAuthorization(param) {
26
+ return "AllowAuthenticated";
27
+ }
28
+
29
+ let OpsEPSpec = {
30
+ name: name,
31
+ commandSchema: commandSchema,
32
+ eventSchema: eventSchema,
33
+ directiveSchema: directiveSchema,
34
+ moduleUrl: moduleUrl,
35
+ commandAuthorization: commandAuthorization
36
+ };
37
+
38
+ let capturedPublished = {
39
+ contents: []
40
+ };
41
+
42
+ let capturedCallCount = {
43
+ contents: 0
44
+ };
45
+
46
+ let outgoingMeta = {
47
+ service: "PublishAgg",
48
+ time: "2024-01-01T00:00:00Z",
49
+ ip: "127.0.0.1",
50
+ user: "tester",
51
+ msgId: "ops-msg-1",
52
+ correlationId: "ops-corr-1"
53
+ };
54
+
55
+ let delegateName = "PublishAgg";
56
+
57
+ function mapIncomingCommands(_topicItems, _createSchedule, _deleteSchedule, _queryEngine) {
58
+ return [];
59
+ }
60
+
61
+ let mapOutgoingEvent = (eventJson, _createSchedule, _deleteSchedule, _queryEngine) => [{
62
+ TAG: "AbstractPublishEvent",
63
+ _0: "ep-dest",
64
+ _1: outgoingMeta,
65
+ _2: eventJson
66
+ }];
67
+
68
+ let TestPublishMapping = {
69
+ ExtensionPoint: undefined,
70
+ delegateName: delegateName,
71
+ mapIncomingCommands: mapIncomingCommands,
72
+ mapOutgoingEvent: mapOutgoingEvent
73
+ };
74
+
75
+ let delegateName$1 = "CallAgg";
76
+
77
+ function mapIncomingCommands$1(_topicItems, _createSchedule, _deleteSchedule, _queryEngine) {
78
+ return [];
79
+ }
80
+
81
+ let mapOutgoingEvent$1 = (_eventJson, _createSchedule, _deleteSchedule, _queryEngine) => [{
82
+ TAG: "AbstractHandleDirective",
83
+ _0: async () => {
84
+ capturedCallCount.contents = capturedCallCount.contents + 1 | 0;
85
+ }
86
+ }];
87
+
88
+ let TestCallMapping = {
89
+ ExtensionPoint: undefined,
90
+ delegateName: delegateName$1,
91
+ mapIncomingCommands: mapIncomingCommands$1,
92
+ mapOutgoingEvent: mapOutgoingEvent$1
93
+ };
94
+
95
+ let delegateName$2 = "AsyncAgg";
96
+
97
+ function mapIncomingCommands$2(_topicItems, _createSchedule, _deleteSchedule, _queryEngine) {
98
+ return [];
99
+ }
100
+
101
+ let mapOutgoingEvent$2 = (eventJson, _createSchedule, _deleteSchedule, _queryEngine) => {
102
+ let asyncResult = Promise.resolve([
103
+ "ep-async-dest",
104
+ outgoingMeta,
105
+ eventJson
106
+ ]);
107
+ return [{
108
+ TAG: "AbstractPublishEventAsync",
109
+ _0: asyncResult
110
+ }];
111
+ };
112
+
113
+ let TestAsyncMapping = {
114
+ ExtensionPoint: undefined,
115
+ delegateName: delegateName$2,
116
+ mapIncomingCommands: mapIncomingCommands$2,
117
+ mapOutgoingEvent: mapOutgoingEvent$2
118
+ };
119
+
120
+ let moduleUrl$1 = import.meta.url;
121
+
122
+ let mappings = [
123
+ {
124
+ delegateName: delegateName,
125
+ mapIncomingCommands: mapIncomingCommands,
126
+ mapOutgoingEvent: mapOutgoingEvent
127
+ },
128
+ {
129
+ delegateName: delegateName$1,
130
+ mapIncomingCommands: mapIncomingCommands$1,
131
+ mapOutgoingEvent: mapOutgoingEvent$1
132
+ },
133
+ {
134
+ delegateName: delegateName$2,
135
+ mapIncomingCommands: mapIncomingCommands$2,
136
+ mapOutgoingEvent: mapOutgoingEvent$2
137
+ }
138
+ ];
139
+
140
+ let TestOpsMappings = {
141
+ Spec: undefined,
142
+ name: "TestOpsMappings",
143
+ moduleUrl: moduleUrl$1,
144
+ mappings: mappings
145
+ };
146
+
147
+ async function publishToEventTopic(id, meta, eventJson) {
148
+ capturedPublished.contents = capturedPublished.contents.concat([[
149
+ id,
150
+ meta,
151
+ eventJson
152
+ ]]);
153
+ }
154
+
155
+ let commandTopicResources = [];
156
+
157
+ async function scheduler_createSchedule(param, param$1) {
158
+
159
+ }
160
+
161
+ async function scheduler_deleteSchedule(param, param$1) {
162
+
163
+ }
164
+
165
+ let scheduler = {
166
+ createSchedule: scheduler_createSchedule,
167
+ deleteSchedule: scheduler_deleteSchedule
168
+ };
169
+
170
+ async function queryEngine_scan(param, param$1, param$2) {
171
+ return [];
172
+ }
173
+
174
+ async function queryEngine_query(param, param$1, param$2, param$3, param$4, param$5, param$6) {
175
+ return [];
176
+ }
177
+
178
+ let queryEngine = {
179
+ scan: queryEngine_scan,
180
+ query: queryEngine_query
181
+ };
182
+
183
+ function resourceNaming_validateName(n) {
184
+ return n;
185
+ }
186
+
187
+ function resourceNaming_urnName(n) {
188
+ return n;
189
+ }
190
+
191
+ let resourceNaming = {
192
+ validateName: resourceNaming_validateName,
193
+ urnName: resourceNaming_urnName
194
+ };
195
+
196
+ let TestOps = {
197
+ publishToEventTopic: publishToEventTopic,
198
+ commandTopicResources: commandTopicResources,
199
+ scheduler: scheduler,
200
+ queryEngine: queryEngine,
201
+ resourceNaming: resourceNaming
202
+ };
203
+
204
+ let EpOps = ExtensionPoint_Operations$ReventlessCore.Make({
205
+ name: name,
206
+ moduleUrl: moduleUrl,
207
+ commandSchema: commandSchema,
208
+ eventSchema: eventSchema,
209
+ directiveSchema: directiveSchema
210
+ })({
211
+ mappings: mappings
212
+ })(TestOps);
213
+
214
+ function makeEventJsonForAgg(aggregateName) {
215
+ let meta_ip = "127.0.0.1";
216
+ let meta_user = "tester";
217
+ let meta = {
218
+ service: aggregateName,
219
+ time: "2024-01-01T00:00:00Z",
220
+ ip: meta_ip,
221
+ user: meta_user,
222
+ msgId: "msg-test",
223
+ correlationId: "corr-test"
224
+ };
225
+ return Object.fromEntries([
226
+ [
227
+ "meta",
228
+ S.reverseConvertToJsonOrThrow(meta, Message$Reventless.metaSchema)
229
+ ],
230
+ [
231
+ "event",
232
+ "SomeEvent"
233
+ ]
234
+ ]);
235
+ }
236
+
237
+ function reset() {
238
+ capturedPublished.contents = [];
239
+ capturedCallCount.contents = 0;
240
+ }
241
+
242
+ globalThis.describe("ExtensionPoint_Operations.Make:", () => {
243
+ globalThis.beforeEach(() => reset());
244
+ globalThis.describe("outgoingJsonEventsHandler — AbstractPublishEvent:", () => {
245
+ globalThis.test("known aggregate calls publishToEventTopic with correct destination id", async () => {
246
+ let eventJson = makeEventJsonForAgg("PublishAgg");
247
+ await EpOps.outgoingJsonEventsHandler(eventJson, undefined);
248
+ globalThis.expect(capturedPublished.contents.length).toBe(1);
249
+ let item = capturedPublished.contents[0];
250
+ globalThis.expect(item[0]).toBe("ep-dest");
251
+ });
252
+ globalThis.test("publishToEventTopic receives the original event JSON", async () => {
253
+ let eventJson = makeEventJsonForAgg("PublishAgg");
254
+ await EpOps.outgoingJsonEventsHandler(eventJson, undefined);
255
+ let item = capturedPublished.contents[0];
256
+ globalThis.expect(item[2]).toEqual(eventJson);
257
+ });
258
+ });
259
+ globalThis.describe("outgoingJsonEventsHandler — AbstractHandleDirective:", () => {
260
+ globalThis.test("known aggregate with AbstractHandleDirective invokes the handler", async () => {
261
+ let eventJson = makeEventJsonForAgg("CallAgg");
262
+ await EpOps.outgoingJsonEventsHandler(eventJson, undefined);
263
+ globalThis.expect(capturedCallCount.contents).toBe(1);
264
+ globalThis.expect(capturedPublished.contents.length).toBe(0);
265
+ });
266
+ });
267
+ globalThis.describe("outgoingJsonEventsHandler — AbstractPublishEventAsync:", () => {
268
+ globalThis.test("async mapping resolves and calls publishToEventTopic", async () => {
269
+ let eventJson = makeEventJsonForAgg("AsyncAgg");
270
+ await EpOps.outgoingJsonEventsHandler(eventJson, undefined);
271
+ globalThis.expect(capturedPublished.contents.length).toBe(1);
272
+ let item = capturedPublished.contents[0];
273
+ globalThis.expect(item[0]).toBe("ep-async-dest");
274
+ });
275
+ });
276
+ globalThis.describe("outgoingJsonEventsHandler — no matching mapping:", () => {
277
+ globalThis.test("event from unknown aggregate throws", async () => {
278
+ let eventJson = makeEventJsonForAgg("UnknownAgg");
279
+ let didThrow = false;
280
+ try {
281
+ await EpOps.outgoingJsonEventsHandler(eventJson, undefined);
282
+ } catch (exn) {
283
+ didThrow = true;
284
+ }
285
+ globalThis.expect(didThrow).toBe(true);
286
+ });
287
+ });
288
+ });
289
+
290
+ export {
291
+ OpsEPSpec,
292
+ capturedPublished,
293
+ capturedCallCount,
294
+ outgoingMeta,
295
+ TestPublishMapping,
296
+ TestCallMapping,
297
+ TestAsyncMapping,
298
+ TestOpsMappings,
299
+ TestOps,
300
+ EpOps,
301
+ makeEventJsonForAgg,
302
+ reset,
303
+ }
304
+ /* Not a pure module */
@@ -0,0 +1,92 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as PluginExtensionPoint_Plugin$ReventlessCore from "../../src/plugin/connect/PluginExtensionPoint_Plugin.res.mjs";
4
+
5
+ let created = {
6
+ contents: []
7
+ };
8
+
9
+ let deleted = {
10
+ contents: []
11
+ };
12
+
13
+ let runtimeOps = {
14
+ messagePublish: {
15
+ sendMessageToChannel: async (param, param$1) => {}
16
+ }
17
+ };
18
+
19
+ let DisconnectSpec = {
20
+ runtimeOps: runtimeOps,
21
+ environment: "teststack",
22
+ updateApiSchema: undefined,
23
+ manageSubscriptions: undefined
24
+ };
25
+
26
+ let EP = PluginExtensionPoint_Plugin$ReventlessCore.Make(DisconnectSpec);
27
+
28
+ async function createSchedule(schedule) {
29
+ created.contents = created.contents.concat([schedule.name]);
30
+ }
31
+
32
+ async function deleteSchedule(name) {
33
+ deleted.contents = deleted.contents.concat([name]);
34
+ }
35
+
36
+ async function queryEngine_scan(param, param$1, param$2) {
37
+ return [];
38
+ }
39
+
40
+ async function queryEngine_query(param, param$1, param$2, param$3, param$4, param$5, param$6) {
41
+ return [];
42
+ }
43
+
44
+ let queryEngine = {
45
+ scan: queryEngine_scan,
46
+ query: queryEngine_query
47
+ };
48
+
49
+ let pluginId = "Catalog_1.0.0-alpha.169";
50
+
51
+ function handle(directive) {
52
+ return EP.directiveHandler(createSchedule, deleteSchedule, queryEngine, directive);
53
+ }
54
+
55
+ globalThis.describe("plugin disconnect schedule", () => {
56
+ globalThis.test("create and delete address the same rule name", async () => {
57
+ created.contents = [];
58
+ deleted.contents = [];
59
+ await handle({
60
+ TAG: "CreateDisconnectSchedule",
61
+ _0: pluginId,
62
+ _1: 5
63
+ });
64
+ await handle({
65
+ TAG: "DeleteDisconnectSchedule",
66
+ _0: pluginId
67
+ });
68
+ globalThis.expect(deleted.contents).toEqual(created.contents);
69
+ });
70
+ globalThis.test("the rule name is namespaced by stack", async () => {
71
+ created.contents = [];
72
+ await handle({
73
+ TAG: "CreateDisconnectSchedule",
74
+ _0: pluginId,
75
+ _1: 5
76
+ });
77
+ globalThis.expect(created.contents).toEqual(["teststack-" + pluginId]);
78
+ });
79
+ });
80
+
81
+ export {
82
+ created,
83
+ deleted,
84
+ DisconnectSpec,
85
+ EP,
86
+ createSchedule,
87
+ deleteSchedule,
88
+ queryEngine,
89
+ pluginId,
90
+ handle,
91
+ }
92
+ /* EP Not a pure module */