@reventlessdev/reventless-core 3.0.0-alpha.170 → 3.0.0-alpha.172

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 (83) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.json +14 -14
  3. package/src/components/ExtensionPoint/ExtensionPoint_Builder.res +5 -2
  4. package/src/components/ExtensionPoint/ExtensionPoint_Builder.res.mjs +3 -3
  5. package/src/components/Heartbeat/Heartbeat.res +2 -2
  6. package/src/components/Heartbeat/Heartbeat_Builder.res +2 -2
  7. package/src/components/Heartbeat/Heartbeat_Builder.res.mjs +2 -4
  8. package/src/components/Task/Task_Builder.res +6 -4
  9. package/src/components/Task/Task_Builder.res.mjs +4 -4
  10. package/src/plugin/component/Plugin_Builder.res +5 -1
  11. package/src/plugin/component/Plugin_Builder.res.mjs +1 -1
  12. package/src/plugin/component/Plugin_Helpers.res +6 -1
  13. package/src/plugin/connect/PluginExtensionPoint_Builder.res +2 -0
  14. package/src/plugin/connect/PluginExtensionPoint_Builder.res.mjs +3 -3
  15. package/src/plugin/connect/PluginExtensionPoint_Plugin.res +12 -5
  16. package/src/plugin/connect/PluginExtensionPoint_Plugin.res.mjs +8 -2
  17. package/tests/plugin/HeartbeatDisconnectGraceTest.res +98 -0
  18. package/tests/IdentityTest.res.mjs +0 -174
  19. package/tests/adapter/MonitoringTest.res.mjs +0 -82
  20. package/tests/admin/Platform_ComponentDefinitionsApiTest.res.mjs +0 -356
  21. package/tests/admin/Platform_UIFragmentsApiTest.res.mjs +0 -101
  22. package/tests/aggregate/AggregateCacheTest.res.mjs +0 -433
  23. package/tests/aggregate/AggregateCallbackTest.res.mjs +0 -143
  24. package/tests/aggregate/AggregateCausationTest.res.mjs +0 -47
  25. package/tests/aggregate/AggregateConflictTest.res.mjs +0 -386
  26. package/tests/aggregate/AggregateFixtures.res.mjs +0 -308
  27. package/tests/aggregate/AggregateRejectionTest.res.mjs +0 -166
  28. package/tests/aggregate/AggregateSnapshotTest.res.mjs +0 -645
  29. package/tests/api/ApiNoApiTest.res.mjs +0 -90
  30. package/tests/api/GraphQL_StitcherTest.res.mjs +0 -112
  31. package/tests/api/SimpleTest.res.mjs +0 -10
  32. package/tests/api/SuryToJsonSchemaTest.res.mjs +0 -674
  33. package/tests/commandgenerator/CommandGeneratorCallbackTest.res.mjs +0 -160
  34. package/tests/commandgenerator/CommandGeneratorFixtures.res.mjs +0 -197
  35. package/tests/commandtopic/CommandTopicCallbackFixtures.res.mjs +0 -152
  36. package/tests/commandtopic/CommandTopicCallbackTest.res.mjs +0 -106
  37. package/tests/commandtopic/CommandTopicHelpersRejectionTest.res.mjs +0 -109
  38. package/tests/counter/CounterCallbackTest.res.mjs +0 -140
  39. package/tests/counter/CounterFixtures.res.mjs +0 -67
  40. package/tests/dcb/DcbDecodeTest.res.mjs +0 -194
  41. package/tests/dcb/DcbEventLogOperationsTest.res.mjs +0 -268
  42. package/tests/dcb/DcbFixtures.res.mjs +0 -534
  43. package/tests/dcb/DcbScopeInferenceTest.res.mjs +0 -480
  44. package/tests/dcb/DcbStateChangeSliceTest.res.mjs +0 -540
  45. package/tests/dcb/DcbTagTest.res.mjs +0 -867
  46. package/tests/dcb/DcbValidationTest.res.mjs +0 -476
  47. package/tests/eventlog/EventLogFixtures.res.mjs +0 -196
  48. package/tests/eventlog/EventLogOperationsTest.res.mjs +0 -192
  49. package/tests/eventlog/EventLogRetryTest.res.mjs +0 -195
  50. package/tests/eventmapper/EventMapperCallbackTest.res.mjs +0 -141
  51. package/tests/eventmapper/EventMapperFixtures.res.mjs +0 -440
  52. package/tests/eventmapper/EventMapperTest.res.mjs +0 -83
  53. package/tests/eventtopic/EventTopicFixtures.res.mjs +0 -65
  54. package/tests/eventtopic/EventTopicOperationsTest.res.mjs +0 -71
  55. package/tests/extensionpoint/ExtensionPointCallbackTest.res.mjs +0 -94
  56. package/tests/extensionpoint/ExtensionPointFixtures.res.mjs +0 -205
  57. package/tests/extensionpoint/ExtensionPointOperationsTest.res.mjs +0 -304
  58. package/tests/ftp/FTPTest.res.mjs +0 -88
  59. package/tests/logger/LogFormatTest.res.mjs +0 -309
  60. package/tests/logger/LoggerLazyTest.res.mjs +0 -40
  61. package/tests/message/MessageTest.res.mjs +0 -218
  62. package/tests/message/MetaEnvelopeTest.res.mjs +0 -188
  63. package/tests/plugin/ManifestVisibilityTest.res.mjs +0 -215
  64. package/tests/plugin/PluginSpecExperiment.res.mjs +0 -31
  65. package/tests/plugin/PluginStructureTest.res.mjs +0 -419
  66. package/tests/plugin/PluginVersionTest.res.mjs +0 -30
  67. package/tests/plugin/SchemaWalkerTest.res.mjs +0 -160
  68. package/tests/plugin/StateChangeSlice/PsPlaceOrder.res.mjs +0 -62
  69. package/tests/plugin/StateChangeSlice/PsShipOrder.res.mjs +0 -69
  70. package/tests/plugin/StateViewSlice/PsAnnotatedView.res.mjs +0 -95
  71. package/tests/plugin/StateViewSlice/PsAvailableProductsView.res.mjs +0 -69
  72. package/tests/plugin/StateViewSlice/PsCustomersView.res.mjs +0 -69
  73. package/tests/plugin/StateViewSlice/PsOrdersView.res.mjs +0 -81
  74. package/tests/poc/StructuralSubtypingPoc.res.mjs +0 -61
  75. package/tests/projection/ProjectionOptimizeTest.res.mjs +0 -75
  76. package/tests/querydb/QueryDbFixtures.res.mjs +0 -135
  77. package/tests/querydb/QueryDbOperationsTest.res.mjs +0 -168
  78. package/tests/sideeffecthandler/SideEffectHandlerCallbackTest.res.mjs +0 -77
  79. package/tests/sideeffecthandler/SideEffectHandlerFixtures.res.mjs +0 -139
  80. package/tests/util/CommandPublisherTest.res.mjs +0 -78
  81. package/tests/util/CsvStreamTest.res.mjs +0 -51
  82. package/tests/util/LruTest.res.mjs +0 -105
  83. package/tests/util/MetricsTest.res.mjs +0 -53
@@ -1,440 +0,0 @@
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 Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
6
- import * as Message$Reventless from "@reventlessdev/reventless-spec/src/types/Message.res.mjs";
7
- import * as ReadModel$Reventless from "@reventlessdev/reventless-spec/src/components/ReadModel.res.mjs";
8
- import * as Projection$Reventless from "@reventlessdev/reventless-spec/src/types/Projection.res.mjs";
9
- import * as EventMapper_Callback$ReventlessCore from "../../src/components/EventMapper/EventMapper_Callback.res.mjs";
10
-
11
- S.enableJson();
12
-
13
- let name = "SourceAggregate";
14
-
15
- let eventSchema = S.union([
16
- S.schema(s => ({
17
- TAG: "ItemCreated",
18
- name: s.m(S.string),
19
- price: s.m(S.float)
20
- })),
21
- S.schema(s => ({
22
- TAG: "ItemPriceUpdated",
23
- newPrice: s.m(S.float)
24
- })),
25
- S.literal("ItemRemoved")
26
- ]);
27
-
28
- let moduleUrl = import.meta.url;
29
-
30
- let SourceSpec = {
31
- Id: undefined,
32
- name: name,
33
- eventSchema: eventSchema,
34
- moduleUrl: moduleUrl
35
- };
36
-
37
- let name$1 = "ItemCatalog";
38
-
39
- let stateSchema = S.schema(s => ({
40
- name: s.m(S.string),
41
- price: s.m(S.float)
42
- }));
43
-
44
- let config = ReadModel$Reventless.config(undefined, undefined, undefined);
45
-
46
- let TargetSpec = {
47
- Id: undefined,
48
- name: name$1,
49
- stateSchema: stateSchema,
50
- config: config,
51
- subIdConfig: undefined,
52
- authorization: "AllowAuthenticated",
53
- visibility: "Public"
54
- };
55
-
56
- function project(msg) {
57
- let match = msg.event;
58
- if (typeof match !== "object") {
59
- return {
60
- TAG: "Delete",
61
- _0: msg.id
62
- };
63
- }
64
- if (match.TAG === "ItemCreated") {
65
- return {
66
- TAG: "Create",
67
- _0: msg.id,
68
- _1: {
69
- name: match.name,
70
- price: match.price
71
- }
72
- };
73
- }
74
- let newPrice = match.newPrice;
75
- return {
76
- TAG: "Update",
77
- _0: msg.id,
78
- _1: s => ({
79
- name: s.name,
80
- price: newPrice
81
- })
82
- };
83
- }
84
-
85
- let ItemMapping = Projection$Reventless.Mapping.Make({
86
- Id: Id$Reventless.$$String,
87
- name: name,
88
- eventSchema: eventSchema
89
- })({
90
- Id: Id$Reventless.$$String,
91
- name: name$1,
92
- stateSchema: stateSchema,
93
- subIdConfig: undefined
94
- })({
95
- project: project
96
- });
97
-
98
- let testMeta = {
99
- service: "SourceAggregate",
100
- time: "2024-01-01T00:00:00.000Z",
101
- ip: "127.0.0.1",
102
- user: "testuser",
103
- msgId: "msg-001",
104
- correlationId: "corr-001"
105
- };
106
-
107
- function makeSourceEvent$p(id, event) {
108
- return {
109
- id: id,
110
- meta: testMeta,
111
- event: event
112
- };
113
- }
114
-
115
- let name$2 = "TestCmdSource";
116
-
117
- let eventSchema$1 = S.union([
118
- S.schema(s => ({
119
- TAG: "OrderPlaced",
120
- orderId: s.m(S.string),
121
- amount: s.m(S.float)
122
- })),
123
- S.schema(s => ({
124
- TAG: "OrderShipped",
125
- orderId: s.m(S.string)
126
- }))
127
- ]);
128
-
129
- let moduleUrl$1 = import.meta.url;
130
-
131
- let CmdSourceSpec = {
132
- Id: undefined,
133
- name: name$2,
134
- eventSchema: eventSchema$1,
135
- moduleUrl: moduleUrl$1
136
- };
137
-
138
- let name$3 = "TestCmdTarget";
139
-
140
- let commandSchema = S.union([
141
- S.schema(s => ({
142
- TAG: "ProcessOrder",
143
- orderId: s.m(S.string),
144
- amount: s.m(S.float)
145
- })),
146
- S.schema(s => ({
147
- TAG: "ShipOrder",
148
- orderId: s.m(S.string)
149
- }))
150
- ]);
151
-
152
- let moduleUrl$2 = import.meta.url;
153
-
154
- function commandAuthorization(param) {
155
- return "AllowAuthenticated";
156
- }
157
-
158
- let CmdTargetSpec = {
159
- Id: undefined,
160
- name: name$3,
161
- commandSchema: commandSchema,
162
- moduleUrl: moduleUrl$2,
163
- commandAuthorization: commandAuthorization
164
- };
165
-
166
- function map(id, event, _queryEngine) {
167
- if (event.TAG === "OrderPlaced") {
168
- return [{
169
- TAG: "Publish",
170
- _0: id,
171
- _1: {
172
- TAG: "ProcessOrder",
173
- orderId: event.orderId,
174
- amount: event.amount
175
- }
176
- }];
177
- }
178
- let cmd = {
179
- TAG: "ShipOrder",
180
- orderId: event.orderId
181
- };
182
- return [{
183
- TAG: "Publish",
184
- _0: id,
185
- _1: cmd
186
- }];
187
- }
188
-
189
- let OrderMapping = {
190
- Source: undefined,
191
- Target: undefined,
192
- map: map
193
- };
194
-
195
- function map$1(_id, event, _queryEngine) {
196
- if (event.TAG === "OrderPlaced") {
197
- return [{
198
- TAG: "Count",
199
- _0: "order-counter"
200
- }];
201
- } else {
202
- return [{
203
- TAG: "AddToCounterTarget",
204
- _0: {
205
- counterId: "order-counter",
206
- target: 5
207
- }
208
- }];
209
- }
210
- }
211
-
212
- let CountOrderMapping = {
213
- Source: undefined,
214
- Target: undefined,
215
- map: map$1
216
- };
217
-
218
- let mappings = [{
219
- Source: {
220
- name: name$2,
221
- Id: {
222
- schema: Id$Reventless.StringPure.schema,
223
- make: prim => prim,
224
- makeFromString: prim => prim,
225
- toString: prim => prim,
226
- cmp: Id$Reventless.StringPure.cmp
227
- },
228
- eventSchema: eventSchema$1
229
- },
230
- map: map
231
- }];
232
-
233
- let OrderMappings_Target = {
234
- Id: Id$Reventless.StringPure,
235
- name: name$3,
236
- commandSchema: commandSchema,
237
- moduleUrl: moduleUrl$2,
238
- commandAuthorization: commandAuthorization
239
- };
240
-
241
- let OrderMappings = {
242
- Target: OrderMappings_Target,
243
- mappings: mappings,
244
- counter: undefined
245
- };
246
-
247
- let mappings$1 = [{
248
- Source: {
249
- name: name$2,
250
- Id: {
251
- schema: Id$Reventless.StringPure.schema,
252
- make: prim => prim,
253
- makeFromString: prim => prim,
254
- toString: prim => prim,
255
- cmp: Id$Reventless.StringPure.cmp
256
- },
257
- eventSchema: eventSchema$1
258
- },
259
- map: map$1
260
- }];
261
-
262
- let CountOrderMappings_Target = {
263
- Id: Id$Reventless.StringPure,
264
- name: name$3,
265
- commandSchema: commandSchema,
266
- moduleUrl: moduleUrl$2,
267
- commandAuthorization: commandAuthorization
268
- };
269
-
270
- let CountOrderMappings = {
271
- Target: CountOrderMappings_Target,
272
- mappings: mappings$1,
273
- counter: undefined
274
- };
275
-
276
- let capturedCmds = {
277
- contents: []
278
- };
279
-
280
- let capturedCountItems = {
281
- contents: []
282
- };
283
-
284
- let capturedCounterTargets = {
285
- contents: []
286
- };
287
-
288
- async function mockQueryEngine_scan(param, param$1, param$2) {
289
- return [];
290
- }
291
-
292
- async function mockQueryEngine_query(param, param$1, param$2, param$3, param$4, param$5, param$6) {
293
- return [];
294
- }
295
-
296
- let mockQueryEngine = {
297
- scan: mockQueryEngine_scan,
298
- query: mockQueryEngine_query
299
- };
300
-
301
- async function publishJsons(cmds) {
302
- capturedCmds.contents = capturedCmds.contents.concat(cmds);
303
- }
304
-
305
- let MockCounterOps = {
306
- publishJsons: publishJsons,
307
- queryEngine: mockQueryEngine
308
- };
309
-
310
- let TestCounterHandler = EventMapper_Callback$ReventlessCore.MakeCounterHandler({
311
- name: name$3,
312
- Id: {
313
- schema: Id$Reventless.StringPure.schema,
314
- make: prim => prim,
315
- makeFromString: prim => prim,
316
- toString: prim => prim,
317
- cmp: Id$Reventless.StringPure.cmp
318
- },
319
- commandSchema: commandSchema
320
- })({
321
- mappings: mappings,
322
- counter: undefined
323
- })(MockCounterOps);
324
-
325
- let mockCommonHandler = {
326
- contents: async param => [
327
- Promise.resolve([]),
328
- []
329
- ]
330
- };
331
-
332
- let mockCountFailUntil = {
333
- contents: 0
334
- };
335
-
336
- let mockCountCallCount = {
337
- contents: 0
338
- };
339
-
340
- async function publishJsons$1(cmds) {
341
- capturedCmds.contents = capturedCmds.contents.concat(cmds);
342
- }
343
-
344
- async function count(items) {
345
- mockCountCallCount.contents = mockCountCallCount.contents + 1 | 0;
346
- capturedCountItems.contents = capturedCountItems.contents.concat(items);
347
- if (mockCountCallCount.contents <= mockCountFailUntil.contents) {
348
- return Stdlib_JsError.throwWithMessage("count failed");
349
- }
350
- }
351
-
352
- async function addToCounterTarget(target) {
353
- capturedCounterTargets.contents = capturedCounterTargets.contents.concat([target]);
354
- }
355
-
356
- async function commonEventsHandler(eventsJson$p) {
357
- return await mockCommonHandler.contents(eventsJson$p);
358
- }
359
-
360
- let MockECOps = {
361
- publishJsons: publishJsons$1,
362
- count: count,
363
- addToCounterTarget: addToCounterTarget,
364
- commonEventsHandler: commonEventsHandler
365
- };
366
-
367
- let TestECHandler = EventMapper_Callback$ReventlessCore.MakeEventCollectorHandler(MockECOps);
368
-
369
- let evtMapTestMeta_ip = "127.0.0.1";
370
-
371
- let evtMapTestMeta_user = "test-user";
372
-
373
- let evtMapTestMeta = {
374
- service: name$2,
375
- time: "2024-01-01T00:00:00Z",
376
- ip: evtMapTestMeta_ip,
377
- user: evtMapTestMeta_user,
378
- msgId: "test-msg-1",
379
- correlationId: "test-corr-1"
380
- };
381
-
382
- function makeEventJson(serviceOpt, id, eventJson) {
383
- let service = serviceOpt !== undefined ? serviceOpt : name$2;
384
- let newrecord = {...evtMapTestMeta};
385
- return Object.fromEntries([
386
- [
387
- "id",
388
- id
389
- ],
390
- [
391
- "meta",
392
- Message$Reventless.encode((newrecord.service = service, newrecord), Message$Reventless.metaSchema)
393
- ],
394
- [
395
- "event",
396
- eventJson
397
- ]
398
- ]);
399
- }
400
-
401
- function resetMocks() {
402
- capturedCmds.contents = [];
403
- capturedCountItems.contents = [];
404
- capturedCounterTargets.contents = [];
405
- mockCountFailUntil.contents = 0;
406
- mockCountCallCount.contents = 0;
407
- mockCommonHandler.contents = async param => [
408
- Promise.resolve([]),
409
- []
410
- ];
411
- }
412
-
413
- export {
414
- SourceSpec,
415
- TargetSpec,
416
- ItemMapping,
417
- testMeta,
418
- makeSourceEvent$p,
419
- CmdSourceSpec,
420
- CmdTargetSpec,
421
- OrderMapping,
422
- CountOrderMapping,
423
- OrderMappings,
424
- CountOrderMappings,
425
- capturedCmds,
426
- capturedCountItems,
427
- capturedCounterTargets,
428
- mockQueryEngine,
429
- MockCounterOps,
430
- TestCounterHandler,
431
- mockCommonHandler,
432
- mockCountFailUntil,
433
- mockCountCallCount,
434
- MockECOps,
435
- TestECHandler,
436
- evtMapTestMeta,
437
- makeEventJson,
438
- resetMocks,
439
- }
440
- /* Not a pure module */
@@ -1,83 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
- import * as JestGlobals from "@reventlessdev/rescript-jest/src/JestGlobals.res.mjs";
4
- import * as EventMapperFixtures$ReventlessCore from "./EventMapperFixtures.res.mjs";
5
-
6
- globalThis.describe("Mapping.Make:", () => {
7
- globalThis.describe("sourceName", () => {
8
- globalThis.test("equals source spec name", () => {
9
- globalThis.expect(EventMapperFixtures$ReventlessCore.ItemMapping.sourceName).toBe("SourceAggregate");
10
- });
11
- });
12
- globalThis.describe("project", () => {
13
- globalThis.test("ItemCreated maps to Create action", () => {
14
- let event$p = EventMapperFixtures$ReventlessCore.makeSourceEvent$p("item-1", {
15
- TAG: "ItemCreated",
16
- name: "Widget",
17
- price: 9.99
18
- });
19
- let action = EventMapperFixtures$ReventlessCore.ItemMapping.project(event$p);
20
- if (typeof action !== "object") {
21
- return JestGlobals.fail("Expected Create action");
22
- }
23
- if (action.TAG !== "Create") {
24
- return JestGlobals.fail("Expected Create action");
25
- }
26
- let state = action._1;
27
- globalThis.expect([
28
- action._0,
29
- state.name,
30
- state.price
31
- ]).toEqual([
32
- "item-1",
33
- "Widget",
34
- 9.99
35
- ]);
36
- });
37
- globalThis.test("ItemPriceUpdated maps to Update action", () => {
38
- let event$p = EventMapperFixtures$ReventlessCore.makeSourceEvent$p("item-1", {
39
- TAG: "ItemPriceUpdated",
40
- newPrice: 14.99
41
- });
42
- let action = EventMapperFixtures$ReventlessCore.ItemMapping.project(event$p);
43
- if (typeof action !== "object") {
44
- return JestGlobals.fail("Expected Update action");
45
- }
46
- if (action.TAG !== "Update") {
47
- return JestGlobals.fail("Expected Update action");
48
- }
49
- globalThis.expect(action._0).toBe("item-1");
50
- });
51
- globalThis.test("ItemRemoved maps to Delete action", () => {
52
- let event$p = EventMapperFixtures$ReventlessCore.makeSourceEvent$p("item-1", "ItemRemoved");
53
- let action = EventMapperFixtures$ReventlessCore.ItemMapping.project(event$p);
54
- if (typeof action !== "object") {
55
- return JestGlobals.fail("Expected Delete action");
56
- }
57
- if (action.TAG !== "Delete") {
58
- return JestGlobals.fail("Expected Delete action");
59
- }
60
- globalThis.expect(action._0).toBe("item-1");
61
- });
62
- globalThis.test("Update action applies function correctly", () => {
63
- let event$p = EventMapperFixtures$ReventlessCore.makeSourceEvent$p("item-1", {
64
- TAG: "ItemPriceUpdated",
65
- newPrice: 14.99
66
- });
67
- let action = EventMapperFixtures$ReventlessCore.ItemMapping.project(event$p);
68
- if (typeof action !== "object") {
69
- return JestGlobals.fail("Expected Update action");
70
- }
71
- if (action.TAG !== "Update") {
72
- return JestGlobals.fail("Expected Update action");
73
- }
74
- let updated = action._1({
75
- name: "Widget",
76
- price: 9.99
77
- });
78
- globalThis.expect(updated.price).toBe(14.99);
79
- });
80
- });
81
- });
82
-
83
- /* Not a pure module */
@@ -1,65 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
- import * as S from "sury/src/S.res.mjs";
4
-
5
- S.enableJson();
6
-
7
- let eventSchema = S.union([
8
- S.schema(s => ({
9
- TAG: "ItemPublished",
10
- name: s.m(S.string)
11
- })),
12
- S.schema(s => ({
13
- TAG: "ItemRemoved",
14
- id: s.m(S.string)
15
- }))
16
- ]);
17
-
18
- let ItemEventTopicSpec = {
19
- Id: undefined,
20
- name: "TestItemEventTopic",
21
- eventSchema: eventSchema
22
- };
23
-
24
- let capturedCalls = {
25
- contents: []
26
- };
27
-
28
- async function mockPublishJson(service, meta, json) {
29
- capturedCalls.contents = capturedCalls.contents.concat([[
30
- service,
31
- meta,
32
- json
33
- ]]);
34
- }
35
-
36
- let testMeta = {
37
- service: "test",
38
- time: "2024-01-01T00:00:00.000Z",
39
- ip: "127.0.0.1",
40
- user: "testuser",
41
- msgId: "msg-001",
42
- correlationId: "corr-001"
43
- };
44
-
45
- function makeEvent$p(id, event) {
46
- return {
47
- id: id,
48
- meta: testMeta,
49
- event: event
50
- };
51
- }
52
-
53
- function reset() {
54
- capturedCalls.contents = [];
55
- }
56
-
57
- export {
58
- ItemEventTopicSpec,
59
- capturedCalls,
60
- mockPublishJson,
61
- testMeta,
62
- makeEvent$p,
63
- reset,
64
- }
65
- /* Not a pure module */
@@ -1,71 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
- import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.js";
4
- import * as Id$Reventless from "@reventlessdev/reventless-spec/src/types/Id.res.mjs";
5
- import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
6
- import * as EventTopicFixtures$ReventlessCore from "./EventTopicFixtures.res.mjs";
7
- import * as EventTopic_Operations$ReventlessCore from "../../src/components/EventTopic/EventTopic_Operations.res.mjs";
8
-
9
- let Ops = EventTopic_Operations$ReventlessCore.Make({
10
- Id: {
11
- schema: Id$Reventless.StringPure.schema,
12
- make: prim => prim,
13
- makeFromString: prim => prim,
14
- toString: prim => prim,
15
- cmp: Id$Reventless.StringPure.cmp
16
- },
17
- name: EventTopicFixtures$ReventlessCore.ItemEventTopicSpec.name,
18
- eventSchema: EventTopicFixtures$ReventlessCore.ItemEventTopicSpec.eventSchema
19
- })({
20
- publishJson: EventTopicFixtures$ReventlessCore.mockPublishJson
21
- });
22
-
23
- globalThis.beforeEach(() => EventTopicFixtures$ReventlessCore.reset());
24
-
25
- globalThis.describe("EventTopic_Operations:", () => {
26
- globalThis.describe("publish", () => {
27
- globalThis.test("calls publishJson for each event", async () => {
28
- let events = [
29
- EventTopicFixtures$ReventlessCore.makeEvent$p("item-1", {
30
- TAG: "ItemPublished",
31
- name: "Widget"
32
- }),
33
- EventTopicFixtures$ReventlessCore.makeEvent$p("item-2", {
34
- TAG: "ItemRemoved",
35
- id: "item-2"
36
- })
37
- ];
38
- await Ops.publish(events);
39
- globalThis.expect(EventTopicFixtures$ReventlessCore.capturedCalls.contents.length).toBe(2);
40
- });
41
- globalThis.test("calls publishJson with correct service (id string)", async () => {
42
- let event$p = EventTopicFixtures$ReventlessCore.makeEvent$p("item-1", {
43
- TAG: "ItemPublished",
44
- name: "Widget"
45
- });
46
- await Ops.publish([event$p]);
47
- let first = EventTopicFixtures$ReventlessCore.capturedCalls.contents[0];
48
- globalThis.expect(first[0]).toBe("item-1");
49
- });
50
- globalThis.test("publishes empty array without error", async () => {
51
- await Ops.publish([]);
52
- globalThis.expect(EventTopicFixtures$ReventlessCore.capturedCalls.contents.length).toBe(0);
53
- });
54
- globalThis.test("encodes event with correct JSON structure", async () => {
55
- let event$p = EventTopicFixtures$ReventlessCore.makeEvent$p("item-1", {
56
- TAG: "ItemPublished",
57
- name: "Widget"
58
- });
59
- await Ops.publish([event$p]);
60
- let match = EventTopicFixtures$ReventlessCore.capturedCalls.contents[0];
61
- let json = match[2];
62
- let hasExpectedFields = Stdlib_Option.getOr(Stdlib_Option.map(Stdlib_JSON.Decode.object(json), d => "event" in d), false) || Stdlib_Option.getOr(Stdlib_Option.map(Stdlib_JSON.Decode.object(json), d => "id" in d), false);
63
- globalThis.expect(hasExpectedFields).toBe(true);
64
- });
65
- });
66
- });
67
-
68
- export {
69
- Ops,
70
- }
71
- /* Ops Not a pure module */