@reventlessdev/reventless-local 3.0.0-alpha.245 → 3.0.0-alpha.247

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 (35) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/package.json +10 -10
  3. package/src/Platform.res +17 -0
  4. package/src/Platform.res.mjs +7 -2
  5. package/src/ShellConfig.res +20 -2
  6. package/src/ShellConfig.res.mjs +9 -4
  7. package/src/UiSlots.res +191 -0
  8. package/src/UiSlots.res.mjs +91 -0
  9. package/src/adapter/Api/LocalEvents_Server.res +18 -0
  10. package/src/adapter/Api/LocalEvents_Server.res.mjs +11 -0
  11. package/src/adapter/EventHistory/EventHistoryResolvers_GraphQL.res +50 -3
  12. package/src/adapter/EventHistory/EventHistoryResolvers_GraphQL.res.mjs +62 -2
  13. package/tests/ShellConfigTest.res +41 -0
  14. package/tests/ShellConfigTest.res.mjs +40 -17
  15. package/tests/UiSlotsTest.res +197 -0
  16. package/tests/UiSlotsTest.res.mjs +196 -0
  17. package/tests/adapter/EventHistoryResolverTest.res +46 -0
  18. package/tests/adapter/EventHistoryResolverTest.res.mjs +41 -0
  19. package/tests/components/aggregate/AggregateFixtures.res.mjs +1 -1
  20. package/tests/components/automationslice/AutomationSliceFixtures.res.mjs +2 -2
  21. package/tests/components/automationslice/AutomationSliceSelfDeadlockFixtures.res.mjs +3 -3
  22. package/tests/components/automationslice/MixedSourceAutomationSliceFixtures.res.mjs +1 -1
  23. package/tests/components/commandgenerator/CommandGeneratorFixtures.res.mjs +1 -1
  24. package/tests/components/commandtopic/CommandTopicFixtures.res.mjs +1 -1
  25. package/tests/components/commandtopic/CommandTopicStreamFixtures.res.mjs +1 -1
  26. package/tests/components/dcb/DcbCrossPartitionFixtures.res.mjs +1 -1
  27. package/tests/components/dcb/DcbFixtures.res.mjs +1 -1
  28. package/tests/components/extensionpoint/ExtensionPointFixtures.res.mjs +2 -2
  29. package/tests/components/inboundtranslationslice/InboundTranslationSliceFixtures.res.mjs +1 -1
  30. package/tests/components/outboundtranslationslice/OutboundTranslationSlicePlatformFixtures.res.mjs +1 -1
  31. package/tests/components/readmodel/DcbReadModelE2EFixtures.res.mjs +1 -1
  32. package/tests/components/stateviewslice/StateViewSliceDisplayNameFixtures.res +98 -0
  33. package/tests/components/stateviewslice/StateViewSliceDisplayNameFixtures.res.mjs +187 -0
  34. package/tests/components/stateviewslice/StateViewSliceDisplayNameTest.res +32 -0
  35. package/tests/components/stateviewslice/StateViewSliceDisplayNameTest.res.mjs +35 -0
@@ -206,3 +206,49 @@ describe("EventHistoryResolvers_GraphQL — pagination", () => {
206
206
  expect(page->hasNextPageOf)->toBe(false)
207
207
  })
208
208
  })
209
+
210
+ // The clause the "supply filter.entityId" warning ends with. A caller that
211
+ // cannot be named is the case that matters: the warning has to survive it.
212
+ describe("EventHistoryResolvers_GraphQL — naming the caller", () => {
213
+ let ctxOf = (~operationName=?, ~userId=?, ()) => {
214
+ let d = Dict.make()
215
+ operationName->Option.forEach(name =>
216
+ d->Dict.set(
217
+ "params",
218
+ Dict.fromArray([("operationName", JSON.Encode.string(name))])->JSON.Encode.object,
219
+ )
220
+ )
221
+ userId->Option.forEach(id =>
222
+ d->Dict.set(
223
+ "identity",
224
+ Dict.fromArray([
225
+ ("userId", JSON.Encode.string(id)),
226
+ ("username", JSON.Encode.string(id)),
227
+ ("groups", []->JSON.Encode.array),
228
+ ])->JSON.Encode.object,
229
+ )
230
+ )
231
+ JSON.Encode.object(d)
232
+ }
233
+
234
+ testSync("name the operation, the user and the filter keys that did arrive", () =>
235
+ expect(
236
+ EH.describeCaller(
237
+ ~ctx=ctxOf(~operationName="AuditTrail", ~userId="local-admin", ()),
238
+ ~filter={eventTypes: ["OrderPlaced"], user: "alice"},
239
+ ),
240
+ )->toBe(`operation "AuditTrail" as local-admin, with filter [eventTypes, user]`)
241
+ )
242
+
243
+ testSync("say so when the caller sent no filter at all", () =>
244
+ expect(
245
+ EH.describeCaller(~ctx=ctxOf(~operationName="AuditTrail", ~userId="local-admin", ()), ~filter={}),
246
+ )->toBe(`operation "AuditTrail" as local-admin, with no filter`)
247
+ )
248
+
249
+ testSync("still describe a context carrying neither operation nor identity", () =>
250
+ expect(EH.describeCaller(~ctx=ctxOf(), ~filter={}))->toBe(
251
+ "an unnamed operation as anonymous, with no filter",
252
+ )
253
+ )
254
+ })
@@ -271,6 +271,47 @@ globalThis.describe("EventHistoryResolvers_GraphQL — pagination", () => {
271
271
  });
272
272
  });
273
273
 
274
+ globalThis.describe("EventHistoryResolvers_GraphQL — naming the caller", () => {
275
+ let ctxOf = (operationName, userId, param) => {
276
+ let d = {};
277
+ Stdlib_Option.forEach(operationName, name => {
278
+ d["params"] = Object.fromEntries([[
279
+ "operationName",
280
+ name
281
+ ]]);
282
+ });
283
+ Stdlib_Option.forEach(userId, id => {
284
+ d["identity"] = Object.fromEntries([
285
+ [
286
+ "userId",
287
+ id
288
+ ],
289
+ [
290
+ "username",
291
+ id
292
+ ],
293
+ [
294
+ "groups",
295
+ []
296
+ ]
297
+ ]);
298
+ });
299
+ return d;
300
+ };
301
+ globalThis.test("name the operation, the user and the filter keys that did arrive", () => {
302
+ globalThis.expect(EventHistoryResolvers_GraphQL$ReventlessLocal.describeCaller(ctxOf("AuditTrail", "local-admin", undefined), {
303
+ eventTypes: ["OrderPlaced"],
304
+ user: "alice"
305
+ })).toBe(`operation "AuditTrail" as local-admin, with filter [eventTypes, user]`);
306
+ });
307
+ globalThis.test("say so when the caller sent no filter at all", () => {
308
+ globalThis.expect(EventHistoryResolvers_GraphQL$ReventlessLocal.describeCaller(ctxOf("AuditTrail", "local-admin", undefined), {})).toBe(`operation "AuditTrail" as local-admin, with no filter`);
309
+ });
310
+ globalThis.test("still describe a context carrying neither operation nor identity", () => {
311
+ globalThis.expect(EventHistoryResolvers_GraphQL$ReventlessLocal.describeCaller(ctxOf(undefined, undefined, undefined), {})).toBe("an unnamed operation as anonymous, with no filter");
312
+ });
313
+ });
314
+
274
315
  let EH;
275
316
 
276
317
  export {
@@ -28,7 +28,7 @@ function commandAuthorization(param) {
28
28
  }
29
29
 
30
30
  function commandTransition(param) {
31
- return "Unrestricted";
31
+ return "Undeclared";
32
32
  }
33
33
 
34
34
  let traits = [];
@@ -64,7 +64,7 @@ function commandAuthorization(param) {
64
64
  }
65
65
 
66
66
  function commandTransition(param) {
67
- return "Unrestricted";
67
+ return "Undeclared";
68
68
  }
69
69
 
70
70
  let traits = [];
@@ -95,7 +95,7 @@ function commandAuthorization$1(param) {
95
95
  }
96
96
 
97
97
  function commandTransition$1(param) {
98
- return "Unrestricted";
98
+ return "Undeclared";
99
99
  }
100
100
 
101
101
  let traits$1 = [];
@@ -42,7 +42,7 @@ function commandAuthorization(param) {
42
42
  }
43
43
 
44
44
  function commandTransition(param) {
45
- return "Unrestricted";
45
+ return "Undeclared";
46
46
  }
47
47
 
48
48
  let traits = [];
@@ -121,7 +121,7 @@ function commandAuthorization$1(param) {
121
121
  }
122
122
 
123
123
  function commandTransition$1(param) {
124
- return "Unrestricted";
124
+ return "Undeclared";
125
125
  }
126
126
 
127
127
  let traits$1 = [];
@@ -230,7 +230,7 @@ function commandAuthorization$2(param) {
230
230
  }
231
231
 
232
232
  function commandTransition$2(param) {
233
- return "Unrestricted";
233
+ return "Undeclared";
234
234
  }
235
235
 
236
236
  let traits$2 = [];
@@ -69,7 +69,7 @@ function commandAuthorization(param) {
69
69
  }
70
70
 
71
71
  function commandTransition(param) {
72
- return "Unrestricted";
72
+ return "Undeclared";
73
73
  }
74
74
 
75
75
  let traits = [];
@@ -29,7 +29,7 @@ function commandAuthorization(param) {
29
29
  }
30
30
 
31
31
  function commandTransition(param) {
32
- return "Unrestricted";
32
+ return "Undeclared";
33
33
  }
34
34
 
35
35
  let traits = [];
@@ -34,7 +34,7 @@ function commandAuthorization(param) {
34
34
  }
35
35
 
36
36
  function commandTransition(param) {
37
- return "Unrestricted";
37
+ return "Undeclared";
38
38
  }
39
39
 
40
40
  let traits = [];
@@ -36,7 +36,7 @@ function commandAuthorization(param) {
36
36
  }
37
37
 
38
38
  function commandTransition(param) {
39
- return "Unrestricted";
39
+ return "Undeclared";
40
40
  }
41
41
 
42
42
  let traits = [];
@@ -74,7 +74,7 @@ function commandAuthorization(param) {
74
74
  }
75
75
 
76
76
  function commandTransition(param) {
77
- return "Unrestricted";
77
+ return "Undeclared";
78
78
  }
79
79
 
80
80
  let traits = [];
@@ -51,7 +51,7 @@ function commandAuthorization(param) {
51
51
  }
52
52
 
53
53
  function commandTransition(param) {
54
- return "Unrestricted";
54
+ return "Undeclared";
55
55
  }
56
56
 
57
57
  let traits = [];
@@ -30,7 +30,7 @@ function commandAuthorization(param) {
30
30
  }
31
31
 
32
32
  function commandTransition(param) {
33
- return "Unrestricted";
33
+ return "Undeclared";
34
34
  }
35
35
 
36
36
  let traits = [];
@@ -67,7 +67,7 @@ function commandAuthorization$1(param) {
67
67
  }
68
68
 
69
69
  function commandTransition$1(param) {
70
- return "Unrestricted";
70
+ return "Undeclared";
71
71
  }
72
72
 
73
73
  let traits$1 = [];
@@ -57,7 +57,7 @@ function commandAuthorization(param) {
57
57
  }
58
58
 
59
59
  function commandTransition(param) {
60
- return "Unrestricted";
60
+ return "Undeclared";
61
61
  }
62
62
 
63
63
  let traits = [];
@@ -43,7 +43,7 @@ function commandAuthorization(param) {
43
43
  }
44
44
 
45
45
  function commandTransition(param) {
46
- return "Unrestricted";
46
+ return "Undeclared";
47
47
  }
48
48
 
49
49
  let traits = [];
@@ -46,7 +46,7 @@ function commandAuthorization(param) {
46
46
  }
47
47
 
48
48
  function commandTransition(param) {
49
- return "Unrestricted";
49
+ return "Undeclared";
50
50
  }
51
51
 
52
52
  let traits = [];
@@ -0,0 +1,98 @@
1
+ // E2E fixtures for the @displayName overlay on a StateViewSlice.
2
+ // A slice's state carries the same synthetic `displayName` a read model's does;
3
+ // this builds one by hand (the ppx writes the field and the metadata) so the
4
+ // projection path can be asserted to compose it.
5
+
6
+ open Reventless.Projection
7
+
8
+ module OrderEventLog = {
9
+ @schema
10
+ type event =
11
+ | OrderPlaced({id: @s.matches(Reventless.DcbTag.string) string, placedAt: string})
12
+ | OrderShipped({id: @s.matches(Reventless.DcbTag.string) string, shippedAt: string})
13
+ }
14
+
15
+ module OrdersViewSpec = {
16
+ let name = "DnOrdersView"
17
+ let moduleUrl: string = %raw(`import.meta.url`)
18
+
19
+ @schema
20
+ type consumedEvent =
21
+ | OrderPlaced({id: string, placedAt: string})
22
+ | OrderShipped({id: string, shippedAt: string})
23
+
24
+ @schema
25
+ type state = {
26
+ id: string,
27
+ placedAt: string,
28
+ shippedAt: string,
29
+ displayName: option<string>,
30
+ }
31
+
32
+ // What the ppx emits for `@displayName placedAt`.
33
+ let stateSchema =
34
+ stateSchema->S.Metadata.set(
35
+ ~id=Reventless.DisplayName.displayNameId,
36
+ {Reventless.DisplayName.fields: ["placedAt"], separator: " "},
37
+ )
38
+
39
+ let config = Reventless.ReadModel.config()
40
+ let subIdConfig = None
41
+ }
42
+
43
+ module OrdersViewProjection = {
44
+ module Spec = OrdersViewSpec
45
+ open OrdersViewSpec
46
+
47
+ let moduleUrl: string = %raw(`import.meta.url`)
48
+
49
+ let project = ({event}: Reventless.StateViewSlice.consumed<consumedEvent>) =>
50
+ switch event {
51
+ | OrderPlaced({id, placedAt}) =>
52
+ [Set(id, {id, placedAt, shippedAt: "", displayName: None})]
53
+ | OrderShipped({id, shippedAt}) => [Update(id, s => {...s, shippedAt})]
54
+ }
55
+ }
56
+
57
+ module Bus = LocalBus.Make()
58
+
59
+ let _ = TestRunner.setup()
60
+
61
+ module OrderEventLogMaker = DcbEventLog_Builder.Make(Bus)
62
+ let eventLog = OrderEventLogMaker.make(
63
+ ~name="DnOrderEventLog",
64
+ ~partitionTag=Reventless.DcbTag.Simple({key: "id"}),
65
+ )
66
+
67
+ module SVMaker = StateViewSlice_Builder.Make(Bus)
68
+ module OrdersViewMaker = SVMaker.Make(OrdersViewSpec, OrdersViewProjection)
69
+ let sv = OrdersViewMaker.make(~dcbEventLog=eventLog)
70
+
71
+ let dcbEventTopicResource =
72
+ (eventLog->ReventlessCore.Component.outputs).eventTopic.resources->Array.getUnsafe(0)
73
+
74
+ let encodeEvent = (event: OrderEventLog.event): ReventlessInfra.DcbEventLog.rawEvent => {
75
+ let json = event->Reventless.Util_Sury.toJson(OrderEventLog.eventSchema)
76
+ let (eventType, data) = json->ReventlessCore.Message.splitMessage
77
+ let tags = Reventless.DcbTag.extractTags(OrderEventLog.eventSchema, event)
78
+ let meta = ReventlessCore.Message.generateMeta(~service="test")
79
+ {eventType, data: JSON.Object(data), tags, meta}
80
+ }
81
+
82
+ let appendEvent = async event => {
83
+ let ops = await eventLog->OrderEventLogMaker.operations->TestRunner.resolve
84
+ let _ = await ops.append([encodeEvent(event)])
85
+ }
86
+
87
+ let loadState = async id => {
88
+ switch Bus.getQueryDb("DnOrdersView") {
89
+ | None => []
90
+ | Some(ops) =>
91
+ let states =
92
+ await ops.loadStream(id)
93
+ ->Stream.runCollect
94
+ ->Effect.catchAll(_ => Effect.succeed([]))
95
+ ->Effect.runPromise
96
+ states->Array.map(json => json->Reventless.Util_Sury.fromJson(OrdersViewSpec.stateSchema))
97
+ }
98
+ }
@@ -0,0 +1,187 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Sury from "sury";
4
+ import * as Stream from "@reventlessdev/rescript-effect/src/Stream.res.mjs";
5
+ import * as Effect from "effect/Effect";
6
+ import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
7
+ import * as ReadModel$Reventless from "@reventlessdev/reventless-spec/src/components/ReadModel.res.mjs";
8
+ import * as Util_Sury$Reventless from "@reventlessdev/reventless-spec/src/util/Util_Sury.res.mjs";
9
+ import * as DisplayName$Reventless from "@reventlessdev/reventless-spec/src/components/DisplayName.res.mjs";
10
+ import * as Message$ReventlessCore from "@reventlessdev/reventless-core/src/Message.res.mjs";
11
+ import * as Component$ReventlessCore from "@reventlessdev/reventless-core/src/components/Component.res.mjs";
12
+ import * as LocalBus$ReventlessLocal from "../../../src/adapter/LocalBus.res.mjs";
13
+ import * as TestRunner$ReventlessLocal from "../../../src/test/TestRunner.res.mjs";
14
+ import * as DcbEventLog_Builder$ReventlessLocal from "../../../src/components/DcbEventLog_Builder.res.mjs";
15
+ import * as StateViewSlice_Builder$ReventlessLocal from "../../../src/components/StateViewSlice_Builder.res.mjs";
16
+
17
+ let eventSchema = Sury.union([
18
+ Sury.$schema(s => ({
19
+ TAG: "OrderPlaced",
20
+ id: s.m(DcbTag$Reventless.string),
21
+ placedAt: s.m(Sury.string)
22
+ })),
23
+ Sury.$schema(s => ({
24
+ TAG: "OrderShipped",
25
+ id: s.m(DcbTag$Reventless.string),
26
+ shippedAt: s.m(Sury.string)
27
+ }))
28
+ ]);
29
+
30
+ let OrderEventLog = {
31
+ eventSchema: eventSchema
32
+ };
33
+
34
+ let name = "DnOrdersView";
35
+
36
+ let moduleUrl = import.meta.url;
37
+
38
+ let consumedEventSchema = Sury.union([
39
+ Sury.$schema(s => ({
40
+ TAG: "OrderPlaced",
41
+ id: s.m(Sury.string),
42
+ placedAt: s.m(Sury.string)
43
+ })),
44
+ Sury.$schema(s => ({
45
+ TAG: "OrderShipped",
46
+ id: s.m(Sury.string),
47
+ shippedAt: s.m(Sury.string)
48
+ }))
49
+ ]);
50
+
51
+ let stateSchema = Sury.$schema(s => ({
52
+ id: s.m(Sury.string),
53
+ placedAt: s.m(Sury.string),
54
+ shippedAt: s.m(Sury.string),
55
+ displayName: s.m(Sury.$option(Sury.string))
56
+ }));
57
+
58
+ let stateSchema$1 = Sury.$Metadata_set(stateSchema, DisplayName$Reventless.displayNameId, {
59
+ fields: ["placedAt"],
60
+ separator: " "
61
+ });
62
+
63
+ let config = ReadModel$Reventless.config(undefined, undefined, undefined);
64
+
65
+ let OrdersViewSpec = {
66
+ name: name,
67
+ moduleUrl: moduleUrl,
68
+ consumedEventSchema: consumedEventSchema,
69
+ stateSchema: stateSchema$1,
70
+ config: config,
71
+ subIdConfig: undefined,
72
+ authorization: "AllowAuthenticated",
73
+ visibility: "Public"
74
+ };
75
+
76
+ let moduleUrl$1 = import.meta.url;
77
+
78
+ function project(param) {
79
+ let event = param.event;
80
+ if (event.TAG === "OrderPlaced") {
81
+ let id = event.id;
82
+ return [{
83
+ TAG: "Set",
84
+ _0: id,
85
+ _1: {
86
+ id: id,
87
+ placedAt: event.placedAt,
88
+ shippedAt: "",
89
+ displayName: undefined
90
+ }
91
+ }];
92
+ }
93
+ let shippedAt = event.shippedAt;
94
+ return [{
95
+ TAG: "Update",
96
+ _0: event.id,
97
+ _1: s => ({
98
+ id: s.id,
99
+ placedAt: s.placedAt,
100
+ shippedAt: shippedAt,
101
+ displayName: s.displayName
102
+ })
103
+ }];
104
+ }
105
+
106
+ let OrdersViewProjection = {
107
+ Spec: undefined,
108
+ moduleUrl: moduleUrl$1,
109
+ project: project
110
+ };
111
+
112
+ let Bus = LocalBus$ReventlessLocal.Make({});
113
+
114
+ TestRunner$ReventlessLocal.setup();
115
+
116
+ let OrderEventLogMaker = DcbEventLog_Builder$ReventlessLocal.Make(Bus);
117
+
118
+ let eventLog = OrderEventLogMaker.make("DnOrderEventLog", undefined, {
119
+ TAG: "Simple",
120
+ _0: {
121
+ key: "id"
122
+ }
123
+ }, undefined);
124
+
125
+ let SVMaker = StateViewSlice_Builder$ReventlessLocal.Make(Bus);
126
+
127
+ let OrdersViewMaker = SVMaker.Make({
128
+ name: name,
129
+ moduleUrl: moduleUrl,
130
+ stateSchema: stateSchema$1,
131
+ consumedEventSchema: consumedEventSchema,
132
+ config: config,
133
+ subIdConfig: undefined,
134
+ authorization: "AllowAuthenticated",
135
+ visibility: "Public"
136
+ })({
137
+ project: project,
138
+ moduleUrl: moduleUrl$1
139
+ });
140
+
141
+ let sv = OrdersViewMaker.make(eventLog, undefined, undefined);
142
+
143
+ let dcbEventTopicResource = Component$ReventlessCore.outputs(eventLog).eventTopic.resources[0];
144
+
145
+ function encodeEvent(event) {
146
+ let json = Util_Sury$Reventless.toJson(event, eventSchema);
147
+ let match = Message$ReventlessCore.splitMessage(json);
148
+ let tags = DcbTag$Reventless.extractTags(eventSchema, event);
149
+ let meta = Message$ReventlessCore.generateMeta("test", undefined, undefined, undefined, undefined, undefined, undefined, undefined);
150
+ return {
151
+ eventType: match[0],
152
+ data: match[1],
153
+ tags: tags,
154
+ meta: meta
155
+ };
156
+ }
157
+
158
+ async function appendEvent(event) {
159
+ let ops = await TestRunner$ReventlessLocal.resolve(OrderEventLogMaker.operations(eventLog));
160
+ await ops.append([encodeEvent(event)], undefined);
161
+ }
162
+
163
+ async function loadState(id) {
164
+ let ops = Bus.getQueryDb("DnOrdersView");
165
+ if (ops === undefined) {
166
+ return [];
167
+ }
168
+ let states = await Effect.runPromise(Effect.catchAll(Stream.runCollect(ops.loadStream(id)), param => Effect.succeed([])));
169
+ return states.map(json => Util_Sury$Reventless.fromJson(json, stateSchema$1));
170
+ }
171
+
172
+ export {
173
+ OrderEventLog,
174
+ OrdersViewSpec,
175
+ OrdersViewProjection,
176
+ Bus,
177
+ OrderEventLogMaker,
178
+ eventLog,
179
+ SVMaker,
180
+ OrdersViewMaker,
181
+ sv,
182
+ dcbEventTopicResource,
183
+ encodeEvent,
184
+ appendEvent,
185
+ loadState,
186
+ }
187
+ /* eventSchema Not a pure module */
@@ -0,0 +1,32 @@
1
+ // The @displayName overlay on the StateViewSlice projection path.
2
+ // Without it the column stays null and every surface names the row by its id.
3
+
4
+ open JestGlobals
5
+ open StateViewSliceDisplayNameFixtures
6
+
7
+ describe("StateViewSlice @displayName", () => {
8
+ let _ = beforeAllAsync(async () => {
9
+ let _ = await sv->OrdersViewMaker.operations->TestRunner.resolve
10
+ let _ = await dcbEventTopicResource.name->TestRunner.resolve
11
+ })
12
+
13
+ testPromise("a projected state carries the composed label", async () => {
14
+ let _ = await appendEvent(
15
+ OrderEventLog.OrderPlaced({id: "order-1", placedAt: "2026-09-01T10:00:00.000Z"}),
16
+ )
17
+ let states = await loadState("order-1")
18
+ expect(states->Array.length)->toBe(1)
19
+ let s = states->Array.getUnsafe(0)
20
+ expect(s.displayName)->toEqual(Some("2026-09-01T10:00:00.000Z"))
21
+ })
22
+
23
+ testPromise("an update recomposes it from the state it wrote", async () => {
24
+ let _ = await appendEvent(
25
+ OrderEventLog.OrderShipped({id: "order-1", shippedAt: "2026-09-02T10:00:00.000Z"}),
26
+ )
27
+ let states = await loadState("order-1")
28
+ let s = states->Array.getUnsafe(0)
29
+ expect(s.shippedAt)->toBe("2026-09-02T10:00:00.000Z")
30
+ expect(s.displayName)->toEqual(Some("2026-09-01T10:00:00.000Z"))
31
+ })
32
+ })
@@ -0,0 +1,35 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as TestRunner$ReventlessLocal from "../../../src/test/TestRunner.res.mjs";
4
+ import * as StateViewSliceDisplayNameFixtures$ReventlessLocal from "./StateViewSliceDisplayNameFixtures.res.mjs";
5
+
6
+ globalThis.describe("StateViewSlice @displayName", () => {
7
+ globalThis.beforeAll(async () => {
8
+ await TestRunner$ReventlessLocal.resolve(StateViewSliceDisplayNameFixtures$ReventlessLocal.OrdersViewMaker.operations(StateViewSliceDisplayNameFixtures$ReventlessLocal.sv));
9
+ await TestRunner$ReventlessLocal.resolve(StateViewSliceDisplayNameFixtures$ReventlessLocal.dcbEventTopicResource.name);
10
+ });
11
+ globalThis.test("a projected state carries the composed label", async () => {
12
+ await StateViewSliceDisplayNameFixtures$ReventlessLocal.appendEvent({
13
+ TAG: "OrderPlaced",
14
+ id: "order-1",
15
+ placedAt: "2026-09-01T10:00:00.000Z"
16
+ });
17
+ let states = await StateViewSliceDisplayNameFixtures$ReventlessLocal.loadState("order-1");
18
+ globalThis.expect(states.length).toBe(1);
19
+ let s = states[0];
20
+ globalThis.expect(s.displayName).toEqual("2026-09-01T10:00:00.000Z");
21
+ });
22
+ globalThis.test("an update recomposes it from the state it wrote", async () => {
23
+ await StateViewSliceDisplayNameFixtures$ReventlessLocal.appendEvent({
24
+ TAG: "OrderShipped",
25
+ id: "order-1",
26
+ shippedAt: "2026-09-02T10:00:00.000Z"
27
+ });
28
+ let states = await StateViewSliceDisplayNameFixtures$ReventlessLocal.loadState("order-1");
29
+ let s = states[0];
30
+ globalThis.expect(s.shippedAt).toBe("2026-09-02T10:00:00.000Z");
31
+ globalThis.expect(s.displayName).toEqual("2026-09-01T10:00:00.000Z");
32
+ });
33
+ });
34
+
35
+ /* Not a pure module */