@reventlessdev/reventless-core 3.0.0-alpha.136 → 3.0.0-alpha.138
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 +19 -0
- package/package.json +7 -7
- package/src/Message.res +43 -10
- package/src/Message.res.mjs +21 -4
- package/src/Projection.res +65 -46
- package/src/Projection.res.mjs +53 -49
- package/src/components/Aggregate/Aggregate_Callback.res +207 -6
- package/src/components/Aggregate/Aggregate_Callback.res.mjs +160 -10
- package/src/components/DcbEventLog/DcbEventLog_Operations.res +3 -0
- package/src/components/DcbEventLog/DcbEventLog_Operations.res.mjs +3 -1
- package/src/components/EventLog/EventLog.res +20 -1
- package/src/components/EventLog/EventLog_Adapter.res +3 -1
- package/src/components/EventLog/EventLog_Builder.res +4 -0
- package/src/components/EventLog/EventLog_Builder.res.mjs +3 -1
- package/src/components/EventLog/EventLog_Operations.res +11 -2
- package/src/components/EventLog/EventLog_Operations.res.mjs +6 -2
- package/src/components/EventLog/EventPublish_Callback.res +7 -0
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res +26 -6
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res.mjs +21 -6
- package/src/plugin/lifecycle/PluginBehavior.res +6 -0
- package/src/plugin/lifecycle/PluginBehavior.res.mjs +3 -0
- package/src/util/Logger.res +10 -0
- package/src/util/Logger.res.mjs +12 -2
- package/tests/aggregate/AggregateCacheTest.res +271 -0
- package/tests/aggregate/AggregateCacheTest.res.mjs +433 -0
- package/tests/aggregate/AggregateCallbackTest.res +4 -1
- package/tests/aggregate/AggregateCallbackTest.res.mjs +4 -1
- package/tests/aggregate/AggregateCausationTest.res +4 -1
- package/tests/aggregate/AggregateCausationTest.res.mjs +4 -1
- package/tests/aggregate/AggregateConflictTest.res +14 -3
- package/tests/aggregate/AggregateConflictTest.res.mjs +26 -3
- package/tests/aggregate/AggregateFixtures.res +10 -2
- package/tests/aggregate/AggregateFixtures.res.mjs +22 -2
- package/tests/aggregate/AggregateRejectionTest.res +4 -1
- package/tests/aggregate/AggregateRejectionTest.res.mjs +4 -1
- package/tests/aggregate/AggregateSnapshotTest.res +357 -0
- package/tests/aggregate/AggregateSnapshotTest.res.mjs +645 -0
- package/tests/eventlog/EventLogFixtures.res +13 -2
- package/tests/eventlog/EventLogFixtures.res.mjs +27 -3
- package/tests/logger/LoggerLazyTest.res +36 -0
- package/tests/logger/LoggerLazyTest.res.mjs +40 -0
|
@@ -29,6 +29,10 @@ let storedEvents = {
|
|
|
29
29
|
contents: {}
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
let storedSnapshots = {
|
|
33
|
+
contents: {}
|
|
34
|
+
};
|
|
35
|
+
|
|
32
36
|
let failNextAppend = {
|
|
33
37
|
contents: false
|
|
34
38
|
};
|
|
@@ -75,8 +79,9 @@ async function mockStorage_replay(id) {
|
|
|
75
79
|
return Stdlib_Option.getOr(storedEvents.contents[id], []);
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
function mockStorage_replayStream(id) {
|
|
79
|
-
|
|
82
|
+
function mockStorage_replayStream(id, fromSeqOpt) {
|
|
83
|
+
let fromSeq = fromSeqOpt !== undefined ? fromSeqOpt : 0;
|
|
84
|
+
return Stream.fromIterable(Stdlib_Option.getOr(storedEvents.contents[id], []).slice(fromSeq));
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
function mockStorage_appendStream(_startingSeqNr, id, stream) {
|
|
@@ -86,11 +91,28 @@ function mockStorage_appendStream(_startingSeqNr, id, stream) {
|
|
|
86
91
|
}));
|
|
87
92
|
}
|
|
88
93
|
|
|
94
|
+
async function mockStorage_latestSnapshot(id) {
|
|
95
|
+
return {
|
|
96
|
+
TAG: "Ok",
|
|
97
|
+
_0: storedSnapshots.contents[id]
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function mockStorage_writeSnapshot(id, snap) {
|
|
102
|
+
storedSnapshots.contents[id] = snap;
|
|
103
|
+
return {
|
|
104
|
+
TAG: "Ok",
|
|
105
|
+
_0: undefined
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
89
109
|
let mockStorage = {
|
|
90
110
|
append: mockStorage_append,
|
|
91
111
|
replay: mockStorage_replay,
|
|
92
112
|
replayStream: mockStorage_replayStream,
|
|
93
|
-
appendStream: mockStorage_appendStream
|
|
113
|
+
appendStream: mockStorage_appendStream,
|
|
114
|
+
latestSnapshot: mockStorage_latestSnapshot,
|
|
115
|
+
writeSnapshot: mockStorage_writeSnapshot
|
|
94
116
|
};
|
|
95
117
|
|
|
96
118
|
let capturedPublishes = {
|
|
@@ -149,6 +171,7 @@ function makeEvent$p(id, event) {
|
|
|
149
171
|
|
|
150
172
|
function reset() {
|
|
151
173
|
storedEvents.contents = {};
|
|
174
|
+
storedSnapshots.contents = {};
|
|
152
175
|
failNextAppend.contents = false;
|
|
153
176
|
failNextAppendsWithTransient.contents = 0;
|
|
154
177
|
appendCallCount.contents = 0;
|
|
@@ -158,6 +181,7 @@ function reset() {
|
|
|
158
181
|
export {
|
|
159
182
|
ItemEventLogSpec,
|
|
160
183
|
storedEvents,
|
|
184
|
+
storedSnapshots,
|
|
161
185
|
failNextAppend,
|
|
162
186
|
failNextAppendsWithTransient,
|
|
163
187
|
appendCallCount,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Unit tests for Logger.debugLazy (B6): the message thunk must run only when
|
|
2
|
+
// debug output is actually enabled, so hot paths (per-projection-action logging)
|
|
3
|
+
// don't pay to build/serialize a string that is dropped at Info level.
|
|
4
|
+
|
|
5
|
+
open JestGlobals
|
|
6
|
+
|
|
7
|
+
describe("Logger.debugLazy", () => {
|
|
8
|
+
testSync("does NOT invoke the thunk at the default Info level", () => {
|
|
9
|
+
let called = ref(false)
|
|
10
|
+
let log = Logger.makeLogger(~minLevel=Logger.Info)
|
|
11
|
+
log.debugLazy(~comp="Test", () => {
|
|
12
|
+
called := true
|
|
13
|
+
"should never be built"
|
|
14
|
+
})
|
|
15
|
+
expect(called.contents)->toEqual(false)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
testSync("invokes the thunk when debug output is enabled", () => {
|
|
19
|
+
let called = ref(false)
|
|
20
|
+
let log = Logger.makeLogger(~minLevel=Logger.Debug)
|
|
21
|
+
log.debugLazy(~comp="Test", () => {
|
|
22
|
+
called := true
|
|
23
|
+
"built"
|
|
24
|
+
})
|
|
25
|
+
expect(called.contents)->toEqual(true)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
testSync("the silent logger never invokes the thunk", () => {
|
|
29
|
+
let called = ref(false)
|
|
30
|
+
Logger.silent.debugLazy(~comp="Test", () => {
|
|
31
|
+
called := true
|
|
32
|
+
"x"
|
|
33
|
+
})
|
|
34
|
+
expect(called.contents)->toEqual(false)
|
|
35
|
+
})
|
|
36
|
+
})
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Logger$ReventlessCore from "../../src/util/Logger.res.mjs";
|
|
4
|
+
|
|
5
|
+
globalThis.describe("Logger.debugLazy", () => {
|
|
6
|
+
globalThis.test("does NOT invoke the thunk at the default Info level", () => {
|
|
7
|
+
let called = {
|
|
8
|
+
contents: false
|
|
9
|
+
};
|
|
10
|
+
let log = Logger$ReventlessCore.makeLogger("Info");
|
|
11
|
+
log.debugLazy("Test", () => {
|
|
12
|
+
called.contents = true;
|
|
13
|
+
return "should never be built";
|
|
14
|
+
});
|
|
15
|
+
globalThis.expect(called.contents).toEqual(false);
|
|
16
|
+
});
|
|
17
|
+
globalThis.test("invokes the thunk when debug output is enabled", () => {
|
|
18
|
+
let called = {
|
|
19
|
+
contents: false
|
|
20
|
+
};
|
|
21
|
+
let log = Logger$ReventlessCore.makeLogger("Debug");
|
|
22
|
+
log.debugLazy("Test", () => {
|
|
23
|
+
called.contents = true;
|
|
24
|
+
return "built";
|
|
25
|
+
});
|
|
26
|
+
globalThis.expect(called.contents).toEqual(true);
|
|
27
|
+
});
|
|
28
|
+
globalThis.test("the silent logger never invokes the thunk", () => {
|
|
29
|
+
let called = {
|
|
30
|
+
contents: false
|
|
31
|
+
};
|
|
32
|
+
Logger$ReventlessCore.silent.debugLazy("Test", () => {
|
|
33
|
+
called.contents = true;
|
|
34
|
+
return "x";
|
|
35
|
+
});
|
|
36
|
+
globalThis.expect(called.contents).toEqual(false);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
/* Not a pure module */
|