@reventlessdev/reventless-core 3.0.0-alpha.169 → 3.0.0-alpha.171

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 (110) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.json +16 -16
  3. package/src/admin/Platform_Admin.res +5 -2
  4. package/src/admin/Platform_Admin.res.mjs +4 -4
  5. package/src/components/Aggregate/Aggregate.res +5 -1
  6. package/src/components/Aggregate/Aggregate_Builder.res +21 -6
  7. package/src/components/Aggregate/Aggregate_Builder.res.mjs +10 -7
  8. package/src/components/AutomationSlice/AutomationSlice.res +1 -0
  9. package/src/components/AutomationSlice/AutomationSlice_Builder.res +13 -2
  10. package/src/components/AutomationSlice/AutomationSlice_Builder.res.mjs +5 -2
  11. package/src/components/Builder_Helpers.res +16 -2
  12. package/src/components/Builder_Helpers.res.mjs +6 -6
  13. package/src/components/Dcb/Dcb_Builder.res +46 -4
  14. package/src/components/Dcb/Dcb_Builder.res.mjs +13 -9
  15. package/src/components/ExtensionPoint/ExtensionPoint.res +2 -0
  16. package/src/components/ExtensionPoint/ExtensionPoint_Builder.res +10 -0
  17. package/src/components/ExtensionPoint/ExtensionPoint_Builder.res.mjs +6 -4
  18. package/src/components/InboundTranslationSlice/InboundTranslationSlice.res +1 -0
  19. package/src/components/InboundTranslationSlice/InboundTranslationSlice_Builder.res +8 -1
  20. package/src/components/InboundTranslationSlice/InboundTranslationSlice_Builder.res.mjs +1 -1
  21. package/src/components/OutboundTranslationSlice/OutboundTranslationSlice.res +1 -0
  22. package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Builder.res +12 -3
  23. package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Builder.res.mjs +5 -2
  24. package/src/components/ReadModel/ReadModel.res +1 -0
  25. package/src/components/ReadModel/ReadModel_Builder.res +9 -1
  26. package/src/components/ReadModel/ReadModel_Builder.res.mjs +5 -2
  27. package/src/components/StateChangeSlice/StateChangeSlice.res +1 -0
  28. package/src/components/StateChangeSlice/StateChangeSlice_Builder.res +6 -0
  29. package/src/components/StateChangeSlice/StateChangeSlice_Builder.res.mjs +1 -1
  30. package/src/components/StateViewSlice/StateViewSlice.res +1 -0
  31. package/src/components/StateViewSlice/StateViewSlice_Builder.res +11 -3
  32. package/src/components/StateViewSlice/StateViewSlice_Builder.res.mjs +5 -2
  33. package/src/components/Task/Task.res +1 -0
  34. package/src/components/Task/Task_Builder.res +11 -2
  35. package/src/components/Task/Task_Builder.res.mjs +7 -4
  36. package/src/plugin/component/Plugin.res +5 -0
  37. package/src/plugin/component/Plugin_Builder.res +10 -2
  38. package/src/plugin/component/Plugin_Builder.res.mjs +7 -6
  39. package/src/plugin/component/Plugin_Helpers.res +2 -0
  40. package/src/plugin/component/Plugin_Helpers.res.mjs +2 -2
  41. package/src/plugin/connect/PluginExtensionPoint_Builder.res +2 -0
  42. package/src/plugin/connect/PluginExtensionPoint_Builder.res.mjs +3 -3
  43. package/tests/plugin/ManifestVisibilityTest.res +2 -2
  44. package/tests/plugin/PluginStructureTest.res +6 -6
  45. package/tests/IdentityTest.res.mjs +0 -174
  46. package/tests/adapter/MonitoringTest.res.mjs +0 -82
  47. package/tests/admin/Platform_ComponentDefinitionsApiTest.res.mjs +0 -356
  48. package/tests/admin/Platform_UIFragmentsApiTest.res.mjs +0 -101
  49. package/tests/aggregate/AggregateCacheTest.res.mjs +0 -433
  50. package/tests/aggregate/AggregateCallbackTest.res.mjs +0 -143
  51. package/tests/aggregate/AggregateCausationTest.res.mjs +0 -47
  52. package/tests/aggregate/AggregateConflictTest.res.mjs +0 -386
  53. package/tests/aggregate/AggregateFixtures.res.mjs +0 -308
  54. package/tests/aggregate/AggregateRejectionTest.res.mjs +0 -166
  55. package/tests/aggregate/AggregateSnapshotTest.res.mjs +0 -645
  56. package/tests/api/ApiNoApiTest.res.mjs +0 -90
  57. package/tests/api/GraphQL_StitcherTest.res.mjs +0 -112
  58. package/tests/api/SimpleTest.res.mjs +0 -10
  59. package/tests/api/SuryToJsonSchemaTest.res.mjs +0 -674
  60. package/tests/commandgenerator/CommandGeneratorCallbackTest.res.mjs +0 -160
  61. package/tests/commandgenerator/CommandGeneratorFixtures.res.mjs +0 -197
  62. package/tests/commandtopic/CommandTopicCallbackFixtures.res.mjs +0 -152
  63. package/tests/commandtopic/CommandTopicCallbackTest.res.mjs +0 -106
  64. package/tests/commandtopic/CommandTopicHelpersRejectionTest.res.mjs +0 -109
  65. package/tests/counter/CounterCallbackTest.res.mjs +0 -140
  66. package/tests/counter/CounterFixtures.res.mjs +0 -67
  67. package/tests/dcb/DcbDecodeTest.res.mjs +0 -194
  68. package/tests/dcb/DcbEventLogOperationsTest.res.mjs +0 -268
  69. package/tests/dcb/DcbFixtures.res.mjs +0 -534
  70. package/tests/dcb/DcbScopeInferenceTest.res.mjs +0 -480
  71. package/tests/dcb/DcbStateChangeSliceTest.res.mjs +0 -540
  72. package/tests/dcb/DcbTagTest.res.mjs +0 -867
  73. package/tests/dcb/DcbValidationTest.res.mjs +0 -476
  74. package/tests/eventlog/EventLogFixtures.res.mjs +0 -196
  75. package/tests/eventlog/EventLogOperationsTest.res.mjs +0 -192
  76. package/tests/eventlog/EventLogRetryTest.res.mjs +0 -195
  77. package/tests/eventmapper/EventMapperCallbackTest.res.mjs +0 -141
  78. package/tests/eventmapper/EventMapperFixtures.res.mjs +0 -440
  79. package/tests/eventmapper/EventMapperTest.res.mjs +0 -83
  80. package/tests/eventtopic/EventTopicFixtures.res.mjs +0 -65
  81. package/tests/eventtopic/EventTopicOperationsTest.res.mjs +0 -71
  82. package/tests/extensionpoint/ExtensionPointCallbackTest.res.mjs +0 -94
  83. package/tests/extensionpoint/ExtensionPointFixtures.res.mjs +0 -205
  84. package/tests/extensionpoint/ExtensionPointOperationsTest.res.mjs +0 -304
  85. package/tests/ftp/FTPTest.res.mjs +0 -88
  86. package/tests/logger/LogFormatTest.res.mjs +0 -309
  87. package/tests/logger/LoggerLazyTest.res.mjs +0 -40
  88. package/tests/message/MessageTest.res.mjs +0 -218
  89. package/tests/message/MetaEnvelopeTest.res.mjs +0 -188
  90. package/tests/plugin/ManifestVisibilityTest.res.mjs +0 -215
  91. package/tests/plugin/PluginSpecExperiment.res.mjs +0 -31
  92. package/tests/plugin/PluginStructureTest.res.mjs +0 -419
  93. package/tests/plugin/PluginVersionTest.res.mjs +0 -30
  94. package/tests/plugin/SchemaWalkerTest.res.mjs +0 -160
  95. package/tests/plugin/StateChangeSlice/PsPlaceOrder.res.mjs +0 -62
  96. package/tests/plugin/StateChangeSlice/PsShipOrder.res.mjs +0 -69
  97. package/tests/plugin/StateViewSlice/PsAnnotatedView.res.mjs +0 -95
  98. package/tests/plugin/StateViewSlice/PsAvailableProductsView.res.mjs +0 -69
  99. package/tests/plugin/StateViewSlice/PsCustomersView.res.mjs +0 -69
  100. package/tests/plugin/StateViewSlice/PsOrdersView.res.mjs +0 -81
  101. package/tests/poc/StructuralSubtypingPoc.res.mjs +0 -61
  102. package/tests/projection/ProjectionOptimizeTest.res.mjs +0 -75
  103. package/tests/querydb/QueryDbFixtures.res.mjs +0 -135
  104. package/tests/querydb/QueryDbOperationsTest.res.mjs +0 -168
  105. package/tests/sideeffecthandler/SideEffectHandlerCallbackTest.res.mjs +0 -77
  106. package/tests/sideeffecthandler/SideEffectHandlerFixtures.res.mjs +0 -139
  107. package/tests/util/CommandPublisherTest.res.mjs +0 -78
  108. package/tests/util/CsvStreamTest.res.mjs +0 -51
  109. package/tests/util/LruTest.res.mjs +0 -105
  110. package/tests/util/MetricsTest.res.mjs +0 -53
@@ -1,109 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
- import * as Stream from "@reventlessdev/rescript-effect/src/Stream.res.mjs";
4
- import * as Effect from "effect/Effect";
5
- import * as CommandTopic_Helpers$ReventlessCore from "../../src/components/CommandTopic/CommandTopic_Helpers.res.mjs";
6
-
7
- function metaWithMsgId(msgId) {
8
- return {
9
- service: "TestService",
10
- time: "2024-01-01T00:00:00Z",
11
- ip: "127.0.0.1",
12
- user: "test-user",
13
- msgId: msgId,
14
- correlationId: "corr-1"
15
- };
16
- }
17
-
18
- function cmdJson(msgId) {
19
- return {
20
- id: "agg-1",
21
- meta: metaWithMsgId(msgId),
22
- commandJson: Object.fromEntries([[
23
- "TAG",
24
- "Noop"
25
- ]])
26
- };
27
- }
28
-
29
- globalThis.describe("CommandTopic_Helpers.runInlineAndCollect:", () => {
30
- globalThis.test("Rejected from rejectedResultChannel beats Accepted from acceptedResultChannel", async () => {
31
- let handler = stream => Effect.map(Stream.runCollect(stream), items => {
32
- items.forEach(item => {
33
- CommandTopic_Helpers$ReventlessCore.reportAccepted(item.reference, {
34
- entityId: "agg-1",
35
- eventCount: 0
36
- });
37
- CommandTopic_Helpers$ReventlessCore.reportRejected(item.reference, {
38
- errorCode: "AlreadyExists",
39
- errorDetail: ""
40
- });
41
- });
42
- return items.map(item => ({
43
- TAG: "Ok",
44
- _0: item.reference
45
- }));
46
- });
47
- let outcomes = await CommandTopic_Helpers$ReventlessCore.runInlineAndCollect([cmdJson("msg-1")], handler);
48
- globalThis.expect(outcomes.length).toBe(1);
49
- let match = outcomes[0];
50
- switch (match.TAG) {
51
- case "Rejected" :
52
- globalThis.expect(match.msgId).toEqual("msg-1");
53
- globalThis.expect(match.errorCode).toEqual("AlreadyExists");
54
- globalThis.expect(match.errorDetail).toEqual(undefined);
55
- return;
56
- case "Accepted" :
57
- case "Pending" :
58
- globalThis.expect("expected Rejected").toEqual("got other");
59
- return;
60
- }
61
- });
62
- globalThis.test("Rejected from rejectedResultChannel beats Error result (synthesized Conflict)", async () => {
63
- let handler = stream => Effect.map(Stream.runCollect(stream), items => {
64
- items.forEach(item => CommandTopic_Helpers$ReventlessCore.reportRejected(item.reference, {
65
- errorCode: "BusinessRuleViolated",
66
- errorDetail: "{\"reason\":\"x\"}"
67
- }));
68
- return items.map(item => ({
69
- TAG: "Error",
70
- _0: item.reference
71
- }));
72
- });
73
- let outcomes = await CommandTopic_Helpers$ReventlessCore.runInlineAndCollect([cmdJson("msg-1")], handler);
74
- let match = outcomes[0];
75
- switch (match.TAG) {
76
- case "Rejected" :
77
- globalThis.expect(match.errorCode).toEqual("BusinessRuleViolated");
78
- globalThis.expect(match.errorDetail).toEqual("{\"reason\":\"x\"}");
79
- return;
80
- case "Accepted" :
81
- case "Pending" :
82
- globalThis.expect("expected Rejected").toEqual("got other");
83
- return;
84
- }
85
- });
86
- globalThis.test("Error result without rejectedChannel still synthesizes Conflict", async () => {
87
- let handler = stream => Effect.map(Stream.runCollect(stream), items => items.map(item => ({
88
- TAG: "Error",
89
- _0: item.reference
90
- })));
91
- let outcomes = await CommandTopic_Helpers$ReventlessCore.runInlineAndCollect([cmdJson("msg-1")], handler);
92
- let match = outcomes[0];
93
- switch (match.TAG) {
94
- case "Rejected" :
95
- globalThis.expect(match.errorCode).toEqual("Conflict");
96
- return;
97
- case "Accepted" :
98
- case "Pending" :
99
- globalThis.expect("expected Rejected(Conflict)").toEqual("got other");
100
- return;
101
- }
102
- });
103
- });
104
-
105
- export {
106
- metaWithMsgId,
107
- cmdJson,
108
- }
109
- /* Not a pure module */
@@ -1,140 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
- import * as Primitive_string from "@rescript/runtime/lib/es6/Primitive_string.js";
4
- import * as Counter$ReventlessCore from "../../src/components/Counter/Counter.res.mjs";
5
- import * as CounterFixtures$ReventlessCore from "./CounterFixtures.res.mjs";
6
- import * as Counter_Callback$ReventlessCore from "../../src/components/Counter/Counter_Callback.res.mjs";
7
-
8
- globalThis.beforeEach(() => CounterFixtures$ReventlessCore.reset());
9
-
10
- globalThis.describe("Counter_Callback.groupByCounterId:", () => {
11
- globalThis.test("groups references by counter ID and sums increments", async () => {
12
- let result = Counter_Callback$ReventlessCore.groupByCounterId([
13
- [
14
- Counter$ReventlessCore.makeId([
15
- "counter-a",
16
- "ref-1"
17
- ]),
18
- 1
19
- ],
20
- [
21
- Counter$ReventlessCore.makeId([
22
- "counter-a",
23
- "ref-2"
24
- ]),
25
- 2
26
- ]
27
- ]);
28
- let sorted = result.toSorted((param, param$1) => Primitive_string.compare(param[0], param$1[0]));
29
- globalThis.expect(sorted).toEqual([[
30
- "counter-a",
31
- 3
32
- ]]);
33
- });
34
- globalThis.test("groups different counter IDs independently", async () => {
35
- let result = Counter_Callback$ReventlessCore.groupByCounterId([
36
- [
37
- Counter$ReventlessCore.makeId([
38
- "counter-a",
39
- "ref-1"
40
- ]),
41
- 1
42
- ],
43
- [
44
- Counter$ReventlessCore.makeId([
45
- "counter-b",
46
- "ref-2"
47
- ]),
48
- 1
49
- ]
50
- ]);
51
- let sorted = result.toSorted((param, param$1) => Primitive_string.compare(param[0], param$1[0]));
52
- globalThis.expect(sorted).toEqual([
53
- [
54
- "counter-a",
55
- 1
56
- ],
57
- [
58
- "counter-b",
59
- 1
60
- ]
61
- ]);
62
- });
63
- globalThis.test("returns empty array for empty input", async () => {
64
- let result = Counter_Callback$ReventlessCore.groupByCounterId([]);
65
- globalThis.expect(result).toEqual([]);
66
- });
67
- });
68
-
69
- globalThis.describe("Counter_Callback.counterHandler:", () => {
70
- globalThis.describe("count reaches zero", () => {
71
- globalThis.test("CountFinished event dispatched via jsonEventsHandler", async () => {
72
- let ref1 = Counter$ReventlessCore.makeId([
73
- "counter-1",
74
- "ref-a"
75
- ]);
76
- let counts = [CounterFixtures$ReventlessCore.makeCountsJson(ref1, 0)];
77
- await CounterFixtures$ReventlessCore.TestCounterHandler.counterHandler([[
78
- ref1,
79
- 1
80
- ]], counts);
81
- let batches = CounterFixtures$ReventlessCore.capturedEventBatches.contents;
82
- globalThis.expect([
83
- batches.length,
84
- batches[0].length
85
- ]).toEqual([
86
- 1,
87
- 1
88
- ]);
89
- });
90
- });
91
- globalThis.describe("count above zero", () => {
92
- globalThis.test("no CountFinished event, countsDbCount still called", async () => {
93
- let ref1 = Counter$ReventlessCore.makeId([
94
- "counter-1",
95
- "ref-a"
96
- ]);
97
- let counts = [CounterFixtures$ReventlessCore.makeCountsJson(ref1, 3)];
98
- await CounterFixtures$ReventlessCore.TestCounterHandler.counterHandler([[
99
- ref1,
100
- 1
101
- ]], counts);
102
- let batches = CounterFixtures$ReventlessCore.capturedEventBatches.contents;
103
- let events = batches[0];
104
- globalThis.expect(events.length).toBe(0);
105
- globalThis.expect(CounterFixtures$ReventlessCore.capturedCountCalls.contents.length).toBe(1);
106
- });
107
- });
108
- globalThis.describe("multiple counters in batch", () => {
109
- globalThis.test("each decremented independently", async () => {
110
- let refA = Counter$ReventlessCore.makeId([
111
- "counter-a",
112
- "ref-1"
113
- ]);
114
- let refB = Counter$ReventlessCore.makeId([
115
- "counter-b",
116
- "ref-2"
117
- ]);
118
- let counts = [
119
- CounterFixtures$ReventlessCore.makeCountsJson(refA, 2),
120
- CounterFixtures$ReventlessCore.makeCountsJson(refB, 0)
121
- ];
122
- await CounterFixtures$ReventlessCore.TestCounterHandler.counterHandler([
123
- [
124
- refA,
125
- 1
126
- ],
127
- [
128
- refB,
129
- 1
130
- ]
131
- ], counts);
132
- globalThis.expect(CounterFixtures$ReventlessCore.capturedCountCalls.contents.length).toBe(2);
133
- let batches = CounterFixtures$ReventlessCore.capturedEventBatches.contents;
134
- let events = batches[0];
135
- globalThis.expect(events.length).toBe(1);
136
- });
137
- });
138
- });
139
-
140
- /* Not a pure module */
@@ -1,67 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
- import * as S from "sury/src/S.res.mjs";
4
- import * as Stream from "@reventlessdev/rescript-effect/src/Stream.res.mjs";
5
- import * as Effect from "effect/Effect";
6
- import * as Message$ReventlessCore from "../../src/Message.res.mjs";
7
- import * as Counter_Callback$ReventlessCore from "../../src/components/Counter/Counter_Callback.res.mjs";
8
-
9
- S.enableJson();
10
-
11
- let capturedCountCalls = {
12
- contents: []
13
- };
14
-
15
- let capturedEventBatches = {
16
- contents: []
17
- };
18
-
19
- async function mockCountsDbCount(id, field, delta) {
20
- capturedCountCalls.contents = capturedCountCalls.contents.concat([[
21
- id,
22
- field,
23
- delta
24
- ]]);
25
- return {
26
- TAG: "Ok",
27
- _0: 0
28
- };
29
- }
30
-
31
- function mockJsonEventsHandler(stream) {
32
- return Effect.map(Stream.runCollect(stream), chunk => {
33
- capturedEventBatches.contents = capturedEventBatches.contents.concat([chunk]);
34
- });
35
- }
36
-
37
- let TestCounterSpec = {
38
- name: "TestCounter",
39
- countsDbCount: mockCountsDbCount,
40
- jsonEventsHandler: mockJsonEventsHandler
41
- };
42
-
43
- let TestCounterHandler = Counter_Callback$ReventlessCore.Make(TestCounterSpec);
44
-
45
- function makeCountsJson(id, count) {
46
- return Message$ReventlessCore.encode({
47
- id: id,
48
- count: count
49
- }, Counter_Callback$ReventlessCore.countsStateSchema);
50
- }
51
-
52
- function reset() {
53
- capturedCountCalls.contents = [];
54
- capturedEventBatches.contents = [];
55
- }
56
-
57
- export {
58
- capturedCountCalls,
59
- capturedEventBatches,
60
- mockCountsDbCount,
61
- mockJsonEventsHandler,
62
- TestCounterSpec,
63
- TestCounterHandler,
64
- makeCountsJson,
65
- reset,
66
- }
67
- /* Not a pure module */
@@ -1,194 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
- import * as S from "sury/src/S.res.mjs";
4
- import * as Primitive_string from "@rescript/runtime/lib/es6/Primitive_string.js";
5
- import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
6
- import * as DcbDecode$Reventless from "@reventlessdev/reventless-spec/src/components/DcbDecode.res.mjs";
7
-
8
- let eventSchema = S.union([
9
- S.schema(s => ({
10
- TAG: "ItemCreated",
11
- itemId: s.m(DcbTag$Reventless.string),
12
- name: s.m(S.string)
13
- })),
14
- S.schema(s => ({
15
- TAG: "ItemRenamed",
16
- itemId: s.m(DcbTag$Reventless.string),
17
- newName: s.m(S.string)
18
- })),
19
- S.schema(s => ({
20
- TAG: "ItemArchived",
21
- itemId: s.m(DcbTag$Reventless.string)
22
- }))
23
- ]);
24
-
25
- let consumedPayloadLessSchema = S.union([
26
- S.literal("ItemCreated"),
27
- S.literal("ItemArchived")
28
- ]);
29
-
30
- let consumedPartialSchema = S.union([
31
- S.schema(s => ({
32
- TAG: "ItemCreated",
33
- itemId: s.m(S.string)
34
- })),
35
- S.schema(s => ({
36
- TAG: "ItemRenamed",
37
- itemId: s.m(S.string)
38
- }))
39
- ]);
40
-
41
- let consumedFullSchema = S.union([
42
- S.schema(s => ({
43
- TAG: "ItemCreated",
44
- itemId: s.m(S.string),
45
- name: s.m(S.string)
46
- })),
47
- S.schema(s => ({
48
- TAG: "ItemRenamed",
49
- itemId: s.m(S.string),
50
- newName: s.m(S.string)
51
- })),
52
- S.schema(s => ({
53
- TAG: "ItemArchived",
54
- itemId: s.m(S.string)
55
- }))
56
- ]);
57
-
58
- globalThis.describe("DcbDecode:", () => {
59
- globalThis.describe("makeDecoder — payload-less", () => {
60
- let match = DcbDecode$Reventless.makeDecoder(consumedPayloadLessSchema);
61
- let eventTypes = match.eventTypes;
62
- let decode = match.decode;
63
- globalThis.test("returns correct eventTypes", () => {
64
- let sorted = eventTypes.toSorted(Primitive_string.compare);
65
- globalThis.expect(sorted).toEqual([
66
- "ItemArchived",
67
- "ItemCreated"
68
- ]);
69
- });
70
- globalThis.test("decodes ItemCreated as payload-less variant", () => {
71
- let result = decode("ItemCreated", Object.fromEntries([
72
- [
73
- "itemId",
74
- "i-1"
75
- ],
76
- [
77
- "name",
78
- "Test"
79
- ]
80
- ]));
81
- globalThis.expect(result).toEqual("ItemCreated");
82
- });
83
- globalThis.test("decodes ItemArchived as payload-less variant", () => {
84
- let result = decode("ItemArchived", Object.fromEntries([[
85
- "itemId",
86
- "i-1"
87
- ]]));
88
- globalThis.expect(result).toEqual("ItemArchived");
89
- });
90
- globalThis.test("returns None for unknown event type", () => {
91
- let result = decode("ItemRenamed", Object.fromEntries([[
92
- "itemId",
93
- "i-1"
94
- ]]));
95
- globalThis.expect(result).toEqual(undefined);
96
- });
97
- });
98
- globalThis.describe("makeDecoder — partial projection", () => {
99
- let match = DcbDecode$Reventless.makeDecoder(consumedPartialSchema);
100
- let decode = match.decode;
101
- globalThis.test("decodes ItemCreated with only itemId field", () => {
102
- let result = decode("ItemCreated", Object.fromEntries([
103
- [
104
- "itemId",
105
- "i-1"
106
- ],
107
- [
108
- "name",
109
- "Test"
110
- ]
111
- ]));
112
- globalThis.expect(result).toEqual({
113
- TAG: "ItemCreated",
114
- itemId: "i-1"
115
- });
116
- });
117
- globalThis.test("decodes ItemRenamed with only itemId field", () => {
118
- let result = decode("ItemRenamed", Object.fromEntries([
119
- [
120
- "itemId",
121
- "i-1"
122
- ],
123
- [
124
- "newName",
125
- "New"
126
- ]
127
- ]));
128
- globalThis.expect(result).toEqual({
129
- TAG: "ItemRenamed",
130
- itemId: "i-1"
131
- });
132
- });
133
- globalThis.test("returns None for unknown event type", () => {
134
- let result = decode("ItemArchived", Object.fromEntries([]));
135
- globalThis.expect(result).toEqual(undefined);
136
- });
137
- });
138
- globalThis.describe("makeDecoder — full shape", () => {
139
- let match = DcbDecode$Reventless.makeDecoder(consumedFullSchema);
140
- let decode = match.decode;
141
- globalThis.test("decodes ItemCreated with all fields", () => {
142
- let result = decode("ItemCreated", Object.fromEntries([
143
- [
144
- "itemId",
145
- "i-1"
146
- ],
147
- [
148
- "name",
149
- "Test"
150
- ]
151
- ]));
152
- globalThis.expect(result).toEqual({
153
- TAG: "ItemCreated",
154
- itemId: "i-1",
155
- name: "Test"
156
- });
157
- });
158
- globalThis.test("decodes ItemRenamed with all fields", () => {
159
- let result = decode("ItemRenamed", Object.fromEntries([
160
- [
161
- "itemId",
162
- "i-1"
163
- ],
164
- [
165
- "newName",
166
- "New"
167
- ]
168
- ]));
169
- globalThis.expect(result).toEqual({
170
- TAG: "ItemRenamed",
171
- itemId: "i-1",
172
- newName: "New"
173
- });
174
- });
175
- globalThis.test("decodes ItemArchived with all fields", () => {
176
- let result = decode("ItemArchived", Object.fromEntries([[
177
- "itemId",
178
- "i-1"
179
- ]]));
180
- globalThis.expect(result).toEqual({
181
- TAG: "ItemArchived",
182
- itemId: "i-1"
183
- });
184
- });
185
- });
186
- });
187
-
188
- export {
189
- eventSchema,
190
- consumedPayloadLessSchema,
191
- consumedPartialSchema,
192
- consumedFullSchema,
193
- }
194
- /* eventSchema Not a pure module */