@reventlessdev/reventless-core 3.0.0-alpha.180 → 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.
- package/CHANGELOG.md +14 -0
- package/package.json +7 -7
- package/src/Message.res +2 -1
- package/src/Message.res.mjs +5 -1
- package/src/admin/Platform_Admin_Structure.res +2 -0
- package/src/admin/Platform_Admin_Structure.res.mjs +2 -0
- package/src/admin/Platform_ComponentDefinitionsApi.res +2 -1
- package/src/admin/Platform_ComponentDefinitionsApi.res.mjs +5 -1
- package/src/admin/UiFragmentRegistry/StateViewSlice/UiFragments_Projection.res +1 -1
- package/src/admin/UiFragmentRegistry/StateViewSlice/UiFragments_Projection.res.mjs +2 -1
- package/src/components/Api/ApiTargetStateHelpers.res +20 -0
- package/src/components/Api/ApiTargetStateHelpers.res.mjs +16 -0
- package/src/components/Api/GraphQL_FragmentGenerator.res +1 -0
- package/src/components/Api/GraphQL_FragmentGenerator.res.mjs +1 -0
- package/src/components/Api/SchemaType.res +3 -0
- package/src/components/Api/SchemaType.res.mjs +10 -2
- package/src/components/Api/SuryToJsonSchema.res +16 -0
- package/src/components/Api/SuryToJsonSchema.res.mjs +28 -0
- package/src/components/Dcb/Dcb_Builder.res +4 -5
- package/src/components/Dcb/Dcb_Builder.res.mjs +3 -5
- package/src/components/DcbEventLog/DcbEventLog_Operations.res +6 -1
- package/src/components/DcbEventLog/DcbEventLog_Operations.res.mjs +2 -1
- package/src/components/InboundTranslationSlice/InboundTranslationSlice.res +25 -0
- package/src/components/InboundTranslationSlice/InboundTranslationSlice.res.mjs +31 -0
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res +8 -8
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res.mjs +26 -6
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Builder.res +44 -37
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Builder.res.mjs +17 -25
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res +27 -2
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res.mjs +4 -0
- package/src/components/StateViewSlice/StateViewSlice_Builder.res +20 -6
- package/src/components/StateViewSlice/StateViewSlice_Builder.res.mjs +23 -5
- package/src/components/StateViewSlice/StateViewSlice_Callback.res +1 -1
- package/src/components/StateViewSlice/StateViewSlice_Callback.res.mjs +5 -1
- package/src/plugin/component/Plugin_Helpers.res +4 -1
- package/src/plugin/component/Plugin_Structure.res +15 -1
- package/src/plugin/component/Plugin_Structure.res.mjs +4 -1
- package/src/plugin/lifecycle/PluginsReadModelSpec.res.mjs +2 -0
- package/tests/IdentityTest.res.mjs +174 -0
- package/tests/ResourceAttributionTest.res.mjs +75 -0
- package/tests/adapter/MonitoringTest.res.mjs +116 -0
- package/tests/admin/Platform_ComponentDefinitionsApiTest.res +10 -0
- package/tests/admin/Platform_ComponentDefinitionsApiTest.res.mjs +365 -0
- package/tests/admin/Platform_UIFragmentsApiTest.res.mjs +101 -0
- package/tests/aggregate/AggregateCacheTest.res.mjs +433 -0
- package/tests/aggregate/AggregateCallbackTest.res.mjs +143 -0
- package/tests/aggregate/AggregateCausationTest.res.mjs +47 -0
- package/tests/aggregate/AggregateConflictTest.res.mjs +386 -0
- package/tests/aggregate/AggregateFixtures.res.mjs +308 -0
- package/tests/aggregate/AggregateRejectionTest.res.mjs +166 -0
- package/tests/aggregate/AggregateSnapshotTest.res.mjs +645 -0
- package/tests/api/ApiNoApiTest.res.mjs +90 -0
- package/tests/api/GraphQL_StitcherTest.res.mjs +112 -0
- package/tests/api/SimpleTest.res.mjs +10 -0
- package/tests/api/SuryToJsonSchemaTest.res +68 -0
- package/tests/api/SuryToJsonSchemaTest.res.mjs +843 -0
- package/tests/commandgenerator/CommandGeneratorCallbackTest.res.mjs +160 -0
- package/tests/commandgenerator/CommandGeneratorFixtures.res.mjs +197 -0
- package/tests/commandtopic/CommandTopicCallbackFixtures.res.mjs +152 -0
- package/tests/commandtopic/CommandTopicCallbackTest.res.mjs +106 -0
- package/tests/commandtopic/CommandTopicHelpersRejectionTest.res.mjs +109 -0
- package/tests/counter/CounterCallbackTest.res.mjs +140 -0
- package/tests/counter/CounterFixtures.res.mjs +67 -0
- package/tests/dcb/DcbDecodeTest.res.mjs +194 -0
- package/tests/dcb/DcbEventLogOperationsTest.res.mjs +268 -0
- package/tests/dcb/DcbFixtures.res.mjs +534 -0
- package/tests/dcb/DcbScopeInferenceTest.res.mjs +480 -0
- package/tests/dcb/DcbStateChangeSliceTest.res.mjs +540 -0
- package/tests/dcb/DcbTagTest.res.mjs +867 -0
- package/tests/dcb/DcbValidationTest.res.mjs +476 -0
- package/tests/eventlog/EventLogFixtures.res.mjs +196 -0
- package/tests/eventlog/EventLogOperationsTest.res.mjs +192 -0
- package/tests/eventlog/EventLogRetryTest.res.mjs +195 -0
- package/tests/eventmapper/EventMapperCallbackTest.res.mjs +141 -0
- package/tests/eventmapper/EventMapperFixtures.res.mjs +440 -0
- package/tests/eventmapper/EventMapperTest.res.mjs +83 -0
- package/tests/eventtopic/EventTopicFixtures.res.mjs +65 -0
- package/tests/eventtopic/EventTopicOperationsTest.res.mjs +71 -0
- package/tests/extensionpoint/ExtensionPointCallbackTest.res.mjs +94 -0
- package/tests/extensionpoint/ExtensionPointFixtures.res.mjs +205 -0
- package/tests/extensionpoint/ExtensionPointOperationsTest.res.mjs +304 -0
- package/tests/extensionpoint/PluginDisconnectScheduleTest.res.mjs +92 -0
- package/tests/ftp/FTPTest.res.mjs +88 -0
- package/tests/logger/LogFormatTest.res.mjs +329 -0
- package/tests/logger/LoggerLazyTest.res.mjs +40 -0
- package/tests/message/MessageTest.res.mjs +218 -0
- package/tests/message/MetaEnvelopeTest.res.mjs +188 -0
- package/tests/plugin/HeartbeatDisconnectGraceTest.res.mjs +91 -0
- package/tests/plugin/ManifestVisibilityTest.res.mjs +215 -0
- package/tests/plugin/PluginSpecExperiment.res.mjs +31 -0
- package/tests/plugin/PluginStructureTest.res +55 -0
- package/tests/plugin/PluginStructureTest.res.mjs +467 -0
- package/tests/plugin/PluginVersionTest.res.mjs +30 -0
- package/tests/plugin/SchemaWalkerTest.res.mjs +160 -0
- package/tests/plugin/StateChangeSlice/PsPlaceOrder.res.mjs +62 -0
- package/tests/plugin/StateChangeSlice/PsShipOrder.res +4 -1
- package/tests/plugin/StateChangeSlice/PsShipOrder.res.mjs +77 -0
- package/tests/plugin/StateViewSlice/PsAnnotatedView.res +5 -4
- package/tests/plugin/StateViewSlice/PsAnnotatedView.res.mjs +110 -0
- package/tests/plugin/StateViewSlice/PsAvailableProductsView.res +1 -1
- package/tests/plugin/StateViewSlice/PsAvailableProductsView.res.mjs +70 -0
- package/tests/plugin/StateViewSlice/PsCustomersView.res +1 -1
- package/tests/plugin/StateViewSlice/PsCustomersView.res.mjs +70 -0
- package/tests/plugin/StateViewSlice/PsOrdersView.res +1 -1
- package/tests/plugin/StateViewSlice/PsOrdersView.res.mjs +82 -0
- package/tests/poc/StructuralSubtypingPoc.res.mjs +61 -0
- package/tests/projection/ProjectionOptimizeTest.res.mjs +75 -0
- package/tests/querydb/QueryDbFixtures.res.mjs +135 -0
- package/tests/querydb/QueryDbOperationsTest.res.mjs +168 -0
- package/tests/sideeffecthandler/SideEffectHandlerCallbackTest.res.mjs +77 -0
- package/tests/sideeffecthandler/SideEffectHandlerFixtures.res.mjs +139 -0
- package/tests/util/CommandPublisherTest.res.mjs +78 -0
- package/tests/util/CsvStreamTest.res.mjs +51 -0
- package/tests/util/LruTest.res.mjs +105 -0
- package/tests/util/MetricsTest.res.mjs +53 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as S from "sury/src/S.res.mjs";
|
|
4
|
+
import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
|
|
5
|
+
|
|
6
|
+
let consumedEventSchema = S.schema(s => ({
|
|
7
|
+
TAG: "CatalogProductSynced",
|
|
8
|
+
productId: s.m(DcbTag$Reventless.string)
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
function evolve(_state, _event) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let commandSchema = S.schema(s => ({
|
|
16
|
+
TAG: "PlaceOrder",
|
|
17
|
+
orderId: s.m(DcbTag$Reventless.string)
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
let errorSchema = S.literal("AlreadyPlaced");
|
|
21
|
+
|
|
22
|
+
let eventSchema = S.schema(s => ({
|
|
23
|
+
TAG: "OrderPlaced",
|
|
24
|
+
orderId: s.m(DcbTag$Reventless.string)
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
function decide(_state, _command) {
|
|
28
|
+
return {
|
|
29
|
+
TAG: "Ok",
|
|
30
|
+
_0: []
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function commandAuthorization(param) {
|
|
35
|
+
return "AllowAuthenticated";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let name = "PlaceOrder";
|
|
39
|
+
|
|
40
|
+
let Id;
|
|
41
|
+
|
|
42
|
+
let initialState = false;
|
|
43
|
+
|
|
44
|
+
let moduleUrl = "@reventlessdev/reventless-core/tests/plugin/StateChangeSlice/PsPlaceOrder.res.mjs";
|
|
45
|
+
|
|
46
|
+
let readConsistency = "EscalateOnRetry";
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
name,
|
|
50
|
+
Id,
|
|
51
|
+
initialState,
|
|
52
|
+
consumedEventSchema,
|
|
53
|
+
evolve,
|
|
54
|
+
commandSchema,
|
|
55
|
+
errorSchema,
|
|
56
|
+
eventSchema,
|
|
57
|
+
decide,
|
|
58
|
+
moduleUrl,
|
|
59
|
+
commandAuthorization,
|
|
60
|
+
readConsistency,
|
|
61
|
+
}
|
|
62
|
+
/* consumedEventSchema Not a pure module */
|
|
@@ -15,8 +15,11 @@ let evolve = (_state, _event) => true
|
|
|
15
15
|
|
|
16
16
|
// CancelShipment is payload-less — it compiles to a bare string literal, so it
|
|
17
17
|
// exercises toCommandDef's payload-less branch (still surfaced in `commands`).
|
|
18
|
+
// It is also `@noApi` (internal/admin only): a two-variant slice with exactly
|
|
19
|
+
// one API-exposed command, which is the case that used to leak the exposed
|
|
20
|
+
// command's slice mutation field onto the non-exposed variant.
|
|
18
21
|
@schema
|
|
19
|
-
type command = ShipOrder({orderId: string}) | CancelShipment
|
|
22
|
+
type command = @targetState("Shipped") ShipOrder({orderId: string}) | @noApi CancelShipment
|
|
20
23
|
|
|
21
24
|
@schema
|
|
22
25
|
type error = OrderNotFound
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as S from "sury/src/S.res.mjs";
|
|
4
|
+
import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
|
|
5
|
+
import * as Api$ReventlessInfra from "@reventlessdev/reventless-infra/src/components/Api.res.mjs";
|
|
6
|
+
|
|
7
|
+
let consumedEventSchema = S.union([
|
|
8
|
+
S.literal("OrderPlaced"),
|
|
9
|
+
S.literal("OrderShipped"),
|
|
10
|
+
S.literal("OrderCancelled")
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
function evolve(_state, _event) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let commandSchema = S.union([
|
|
18
|
+
S.schema(s => ({
|
|
19
|
+
TAG: "ShipOrder",
|
|
20
|
+
orderId: s.m(DcbTag$Reventless.string)
|
|
21
|
+
})),
|
|
22
|
+
S.literal("CancelShipment")
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
let errorSchema = S.literal("OrderNotFound");
|
|
26
|
+
|
|
27
|
+
let eventSchema = S.union([
|
|
28
|
+
S.schema(s => ({
|
|
29
|
+
TAG: "OrderShipped",
|
|
30
|
+
orderId: s.m(DcbTag$Reventless.string)
|
|
31
|
+
})),
|
|
32
|
+
S.literal("ShipmentVoided")
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
function decide(_state, _command) {
|
|
36
|
+
return {
|
|
37
|
+
TAG: "Ok",
|
|
38
|
+
_0: []
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let commandSchema$1 = Api$ReventlessInfra.markNoApiVariants(commandSchema, ["CancelShipment"]);
|
|
43
|
+
|
|
44
|
+
let commandSchema$2 = Api$ReventlessInfra.markTargetState(commandSchema$1, [[
|
|
45
|
+
"ShipOrder",
|
|
46
|
+
"Shipped"
|
|
47
|
+
]]);
|
|
48
|
+
|
|
49
|
+
function commandAuthorization(param) {
|
|
50
|
+
return "AllowAuthenticated";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let name = "ShipOrder";
|
|
54
|
+
|
|
55
|
+
let Id;
|
|
56
|
+
|
|
57
|
+
let initialState = false;
|
|
58
|
+
|
|
59
|
+
let moduleUrl = "@reventlessdev/reventless-core/tests/plugin/StateChangeSlice/PsShipOrder.res.mjs";
|
|
60
|
+
|
|
61
|
+
let readConsistency = "EscalateOnRetry";
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
name,
|
|
65
|
+
Id,
|
|
66
|
+
initialState,
|
|
67
|
+
consumedEventSchema,
|
|
68
|
+
evolve,
|
|
69
|
+
errorSchema,
|
|
70
|
+
eventSchema,
|
|
71
|
+
decide,
|
|
72
|
+
commandSchema$2 as commandSchema,
|
|
73
|
+
moduleUrl,
|
|
74
|
+
commandAuthorization,
|
|
75
|
+
readConsistency,
|
|
76
|
+
}
|
|
77
|
+
/* consumedEventSchema Not a pure module */
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
@schema
|
|
9
9
|
type consumedEvent =
|
|
10
|
-
| ItemRecorded({itemId: string, ownerId: string, version: string, name: string})
|
|
10
|
+
| ItemRecorded({itemId: string, ownerId: string, version: string, name: string, total: float})
|
|
11
11
|
|
|
12
12
|
@schema
|
|
13
13
|
type state = {
|
|
@@ -15,10 +15,11 @@ type state = {
|
|
|
15
15
|
@subId version: string,
|
|
16
16
|
@index("byOwner") ownerId: string,
|
|
17
17
|
name: string,
|
|
18
|
+
@semantic("currency") @metric({aggregate: "sum", label: "Revenue"}) total: float,
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
let project = event =>
|
|
21
|
+
let project = ({event}: Reventless.StateViewSlice.consumed<consumedEvent>) =>
|
|
21
22
|
switch event {
|
|
22
|
-
| ItemRecorded({itemId, ownerId, version, name}) =>
|
|
23
|
-
[Set(itemId, {itemId, ownerId, version, name})]
|
|
23
|
+
| ItemRecorded({itemId, ownerId, version, name, total}) =>
|
|
24
|
+
[Set(itemId, {itemId, ownerId, version, name, total})]
|
|
24
25
|
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as S from "sury/src/S.res.mjs";
|
|
4
|
+
import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
|
|
5
|
+
import * as ReadModel$Reventless from "@reventlessdev/reventless-spec/src/components/ReadModel.res.mjs";
|
|
6
|
+
import * as StateAnnotations$Reventless from "@reventlessdev/reventless-spec/src/components/StateAnnotations.res.mjs";
|
|
7
|
+
|
|
8
|
+
let consumedEventSchema = S.schema(s => ({
|
|
9
|
+
TAG: "ItemRecorded",
|
|
10
|
+
itemId: s.m(DcbTag$Reventless.string),
|
|
11
|
+
ownerId: s.m(DcbTag$Reventless.string),
|
|
12
|
+
version: s.m(S.string),
|
|
13
|
+
name: s.m(S.string),
|
|
14
|
+
total: s.m(S.float)
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
let stateSchema = S.schema(s => ({
|
|
18
|
+
itemId: s.m(S.string),
|
|
19
|
+
version: s.m(S.string),
|
|
20
|
+
ownerId: s.m(S.string),
|
|
21
|
+
name: s.m(S.string),
|
|
22
|
+
total: s.m(S.float)
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
function project(param) {
|
|
26
|
+
let event = param.event;
|
|
27
|
+
let itemId = event.itemId;
|
|
28
|
+
return [{
|
|
29
|
+
TAG: "Set",
|
|
30
|
+
_0: itemId,
|
|
31
|
+
_1: {
|
|
32
|
+
itemId: itemId,
|
|
33
|
+
version: event.version,
|
|
34
|
+
ownerId: event.ownerId,
|
|
35
|
+
name: event.name,
|
|
36
|
+
total: event.total
|
|
37
|
+
}
|
|
38
|
+
}];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let config = ReadModel$Reventless.config(undefined, undefined, [{
|
|
42
|
+
index: "byOwner",
|
|
43
|
+
type_: "S",
|
|
44
|
+
idField: "ownerId",
|
|
45
|
+
projectionType: "ALL"
|
|
46
|
+
}]);
|
|
47
|
+
|
|
48
|
+
let subIdConfig = {
|
|
49
|
+
subIdField: "version",
|
|
50
|
+
getSubId: (state => state.version)
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
let makeId = (state => state.itemId);
|
|
54
|
+
|
|
55
|
+
let stateSchema$1 = S.Metadata.set(stateSchema, StateAnnotations$Reventless.stateAnnotationsId, {
|
|
56
|
+
ids: ["itemId"],
|
|
57
|
+
compositeIds: [],
|
|
58
|
+
subIds: ["version"],
|
|
59
|
+
compositeSubIds: [],
|
|
60
|
+
indexes: [[
|
|
61
|
+
"ownerId",
|
|
62
|
+
"byOwner"
|
|
63
|
+
]],
|
|
64
|
+
hidden: [],
|
|
65
|
+
summary: [],
|
|
66
|
+
drillTargets: [],
|
|
67
|
+
drillTargetKeys: [],
|
|
68
|
+
collapsed: [],
|
|
69
|
+
scan: [],
|
|
70
|
+
scanSort: [],
|
|
71
|
+
semantic: [[
|
|
72
|
+
"total",
|
|
73
|
+
"currency"
|
|
74
|
+
]],
|
|
75
|
+
metric: [[
|
|
76
|
+
"total",
|
|
77
|
+
{
|
|
78
|
+
aggregate: "sum",
|
|
79
|
+
label: "Revenue"
|
|
80
|
+
}
|
|
81
|
+
]],
|
|
82
|
+
status: undefined,
|
|
83
|
+
groupBy: undefined,
|
|
84
|
+
visibility: undefined
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
let name = "AnnotatedView";
|
|
88
|
+
|
|
89
|
+
let Id;
|
|
90
|
+
|
|
91
|
+
let moduleUrl = "@reventlessdev/reventless-core/tests/plugin/StateViewSlice/PsAnnotatedView.res.mjs";
|
|
92
|
+
|
|
93
|
+
let authorization = "AllowAuthenticated";
|
|
94
|
+
|
|
95
|
+
let visibility = "Public";
|
|
96
|
+
|
|
97
|
+
export {
|
|
98
|
+
name,
|
|
99
|
+
Id,
|
|
100
|
+
consumedEventSchema,
|
|
101
|
+
project,
|
|
102
|
+
config,
|
|
103
|
+
subIdConfig,
|
|
104
|
+
makeId,
|
|
105
|
+
stateSchema$1 as stateSchema,
|
|
106
|
+
moduleUrl,
|
|
107
|
+
authorization,
|
|
108
|
+
visibility,
|
|
109
|
+
}
|
|
110
|
+
/* consumedEventSchema Not a pure module */
|
|
@@ -11,7 +11,7 @@ type consumedEvent =
|
|
|
11
11
|
@schema
|
|
12
12
|
type state = {productId: string, name: string}
|
|
13
13
|
|
|
14
|
-
let project = event =>
|
|
14
|
+
let project = ({event}: Reventless.StateViewSlice.consumed<consumedEvent>) =>
|
|
15
15
|
switch event {
|
|
16
16
|
| CatalogProductSynced({productId, name}) => [Set(productId, {productId, name})]
|
|
17
17
|
| CatalogProductPriceChanged({productId}) => [Update(productId, s => s)]
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as S from "sury/src/S.res.mjs";
|
|
4
|
+
import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
|
|
5
|
+
import * as ReadModel$Reventless from "@reventlessdev/reventless-spec/src/components/ReadModel.res.mjs";
|
|
6
|
+
|
|
7
|
+
let consumedEventSchema = S.union([
|
|
8
|
+
S.schema(s => ({
|
|
9
|
+
TAG: "CatalogProductSynced",
|
|
10
|
+
productId: s.m(DcbTag$Reventless.string),
|
|
11
|
+
name: s.m(S.string)
|
|
12
|
+
})),
|
|
13
|
+
S.schema(s => ({
|
|
14
|
+
TAG: "CatalogProductPriceChanged",
|
|
15
|
+
productId: s.m(DcbTag$Reventless.string)
|
|
16
|
+
}))
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
let stateSchema = S.schema(s => ({
|
|
20
|
+
productId: s.m(S.string),
|
|
21
|
+
name: s.m(S.string)
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
function project(param) {
|
|
25
|
+
let event = param.event;
|
|
26
|
+
if (event.TAG !== "CatalogProductSynced") {
|
|
27
|
+
return [{
|
|
28
|
+
TAG: "Update",
|
|
29
|
+
_0: event.productId,
|
|
30
|
+
_1: s => s
|
|
31
|
+
}];
|
|
32
|
+
}
|
|
33
|
+
let productId = event.productId;
|
|
34
|
+
return [{
|
|
35
|
+
TAG: "Set",
|
|
36
|
+
_0: productId,
|
|
37
|
+
_1: {
|
|
38
|
+
productId: productId,
|
|
39
|
+
name: event.name
|
|
40
|
+
}
|
|
41
|
+
}];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let config = ReadModel$Reventless.config(undefined, undefined, undefined);
|
|
45
|
+
|
|
46
|
+
let name = "AvailableProducts";
|
|
47
|
+
|
|
48
|
+
let Id;
|
|
49
|
+
|
|
50
|
+
let subIdConfig;
|
|
51
|
+
|
|
52
|
+
let moduleUrl = "@reventlessdev/reventless-core/tests/plugin/StateViewSlice/PsAvailableProductsView.res.mjs";
|
|
53
|
+
|
|
54
|
+
let authorization = "AllowAuthenticated";
|
|
55
|
+
|
|
56
|
+
let visibility = "Public";
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
name,
|
|
60
|
+
Id,
|
|
61
|
+
consumedEventSchema,
|
|
62
|
+
stateSchema,
|
|
63
|
+
project,
|
|
64
|
+
config,
|
|
65
|
+
subIdConfig,
|
|
66
|
+
moduleUrl,
|
|
67
|
+
authorization,
|
|
68
|
+
visibility,
|
|
69
|
+
}
|
|
70
|
+
/* consumedEventSchema Not a pure module */
|
|
@@ -15,7 +15,7 @@ type state = {
|
|
|
15
15
|
@displayName lastName: string,
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
let project = event =>
|
|
18
|
+
let project = ({event}: Reventless.StateViewSlice.consumed<consumedEvent>) =>
|
|
19
19
|
switch event {
|
|
20
20
|
| CustomerAdded({customerId, firstName, lastName}) =>
|
|
21
21
|
[Set(customerId, {customerId, firstName, lastName})]
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as S from "sury/src/S.res.mjs";
|
|
4
|
+
import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
|
|
5
|
+
import * as ReadModel$Reventless from "@reventlessdev/reventless-spec/src/components/ReadModel.res.mjs";
|
|
6
|
+
import * as DisplayName$Reventless from "@reventlessdev/reventless-spec/src/components/DisplayName.res.mjs";
|
|
7
|
+
|
|
8
|
+
let consumedEventSchema = S.schema(s => ({
|
|
9
|
+
TAG: "CustomerAdded",
|
|
10
|
+
customerId: s.m(DcbTag$Reventless.string),
|
|
11
|
+
firstName: s.m(S.string),
|
|
12
|
+
lastName: s.m(S.string)
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
let stateSchema = S.schema(s => ({
|
|
16
|
+
customerId: s.m(S.string),
|
|
17
|
+
firstName: s.m(S.string),
|
|
18
|
+
lastName: s.m(S.string),
|
|
19
|
+
displayName: s.m(S.option(S.string))
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
let stateSchema$1 = S.Metadata.set(stateSchema, DisplayName$Reventless.displayNameId, {
|
|
23
|
+
fields: [
|
|
24
|
+
"firstName",
|
|
25
|
+
"lastName"
|
|
26
|
+
],
|
|
27
|
+
separator: " "
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
function project(param) {
|
|
31
|
+
let event = param.event;
|
|
32
|
+
let customerId = event.customerId;
|
|
33
|
+
return [{
|
|
34
|
+
TAG: "Set",
|
|
35
|
+
_0: customerId,
|
|
36
|
+
_1: {
|
|
37
|
+
customerId: customerId,
|
|
38
|
+
firstName: event.firstName,
|
|
39
|
+
lastName: event.lastName
|
|
40
|
+
}
|
|
41
|
+
}];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let config = ReadModel$Reventless.config(undefined, undefined, undefined);
|
|
45
|
+
|
|
46
|
+
let name = "Customers";
|
|
47
|
+
|
|
48
|
+
let Id;
|
|
49
|
+
|
|
50
|
+
let subIdConfig;
|
|
51
|
+
|
|
52
|
+
let moduleUrl = "@reventlessdev/reventless-core/tests/plugin/StateViewSlice/PsCustomersView.res.mjs";
|
|
53
|
+
|
|
54
|
+
let authorization = "AllowAuthenticated";
|
|
55
|
+
|
|
56
|
+
let visibility = "Public";
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
name,
|
|
60
|
+
Id,
|
|
61
|
+
consumedEventSchema,
|
|
62
|
+
stateSchema$1 as stateSchema,
|
|
63
|
+
project,
|
|
64
|
+
config,
|
|
65
|
+
subIdConfig,
|
|
66
|
+
moduleUrl,
|
|
67
|
+
authorization,
|
|
68
|
+
visibility,
|
|
69
|
+
}
|
|
70
|
+
/* consumedEventSchema Not a pure module */
|
|
@@ -12,7 +12,7 @@ type consumedEvent =
|
|
|
12
12
|
@schema
|
|
13
13
|
type state = {orderId: string, customerName: string}
|
|
14
14
|
|
|
15
|
-
let project = event =>
|
|
15
|
+
let project = ({event}: Reventless.StateViewSlice.consumed<consumedEvent>) =>
|
|
16
16
|
switch event {
|
|
17
17
|
| OrderPlaced({orderId, customerName}) => [Set(orderId, {orderId, customerName})]
|
|
18
18
|
| OrderShipped({orderId}) => [Update(orderId, s => s)]
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as S from "sury/src/S.res.mjs";
|
|
4
|
+
import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
|
|
5
|
+
import * as ReadModel$Reventless from "@reventlessdev/reventless-spec/src/components/ReadModel.res.mjs";
|
|
6
|
+
|
|
7
|
+
let consumedEventSchema = S.union([
|
|
8
|
+
S.schema(s => ({
|
|
9
|
+
TAG: "OrderPlaced",
|
|
10
|
+
orderId: s.m(DcbTag$Reventless.string),
|
|
11
|
+
customerName: s.m(S.string)
|
|
12
|
+
})),
|
|
13
|
+
S.schema(s => ({
|
|
14
|
+
TAG: "OrderShipped",
|
|
15
|
+
orderId: s.m(DcbTag$Reventless.string)
|
|
16
|
+
})),
|
|
17
|
+
S.schema(s => ({
|
|
18
|
+
TAG: "OrderCancelled",
|
|
19
|
+
orderId: s.m(DcbTag$Reventless.string)
|
|
20
|
+
}))
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
let stateSchema = S.schema(s => ({
|
|
24
|
+
orderId: s.m(S.string),
|
|
25
|
+
customerName: s.m(S.string)
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
function project(param) {
|
|
29
|
+
let event = param.event;
|
|
30
|
+
switch (event.TAG) {
|
|
31
|
+
case "OrderPlaced" :
|
|
32
|
+
let orderId = event.orderId;
|
|
33
|
+
return [{
|
|
34
|
+
TAG: "Set",
|
|
35
|
+
_0: orderId,
|
|
36
|
+
_1: {
|
|
37
|
+
orderId: orderId,
|
|
38
|
+
customerName: event.customerName
|
|
39
|
+
}
|
|
40
|
+
}];
|
|
41
|
+
case "OrderShipped" :
|
|
42
|
+
return [{
|
|
43
|
+
TAG: "Update",
|
|
44
|
+
_0: event.orderId,
|
|
45
|
+
_1: s => s
|
|
46
|
+
}];
|
|
47
|
+
case "OrderCancelled" :
|
|
48
|
+
return [{
|
|
49
|
+
TAG: "Update",
|
|
50
|
+
_0: event.orderId,
|
|
51
|
+
_1: s => s
|
|
52
|
+
}];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let config = ReadModel$Reventless.config(undefined, undefined, undefined);
|
|
57
|
+
|
|
58
|
+
let name = "Orders";
|
|
59
|
+
|
|
60
|
+
let Id;
|
|
61
|
+
|
|
62
|
+
let subIdConfig;
|
|
63
|
+
|
|
64
|
+
let moduleUrl = "@reventlessdev/reventless-core/tests/plugin/StateViewSlice/PsOrdersView.res.mjs";
|
|
65
|
+
|
|
66
|
+
let authorization = "AllowAuthenticated";
|
|
67
|
+
|
|
68
|
+
let visibility = "Public";
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
name,
|
|
72
|
+
Id,
|
|
73
|
+
consumedEventSchema,
|
|
74
|
+
stateSchema,
|
|
75
|
+
project,
|
|
76
|
+
config,
|
|
77
|
+
subIdConfig,
|
|
78
|
+
moduleUrl,
|
|
79
|
+
authorization,
|
|
80
|
+
visibility,
|
|
81
|
+
}
|
|
82
|
+
/* consumedEventSchema Not a pure module */
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function acceptSubset(M) {
|
|
5
|
+
return M.Spec.name;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function coerceSuperset(M) {
|
|
9
|
+
return M;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function passSupersetsAsSubsets(aggregates) {
|
|
13
|
+
return aggregates.map(M => M);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function finishAggregates(aggregates) {
|
|
17
|
+
aggregates.forEach(M => M.AggregateRuntimeBuilder.finish());
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function platformImplSatisfiesSpec(P) {
|
|
21
|
+
let $$let = P.Aggregate.Make;
|
|
22
|
+
return {
|
|
23
|
+
Aggregate: {
|
|
24
|
+
Make: funarg => $$let(funarg)
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function coerceReadModelSuperset(M) {
|
|
30
|
+
return M;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function coerceSupersetV2(M) {
|
|
34
|
+
return M;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function passSupersetsAsSubsetsV2(aggregates) {
|
|
38
|
+
return aggregates.map(M => M);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function platformImplSatisfiesSpecV2(P) {
|
|
42
|
+
let $$let = P.Aggregate.Make;
|
|
43
|
+
return {
|
|
44
|
+
Aggregate: {
|
|
45
|
+
Make: funarg => $$let(funarg)
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
acceptSubset,
|
|
52
|
+
coerceSuperset,
|
|
53
|
+
passSupersetsAsSubsets,
|
|
54
|
+
finishAggregates,
|
|
55
|
+
platformImplSatisfiesSpec,
|
|
56
|
+
coerceReadModelSuperset,
|
|
57
|
+
coerceSupersetV2,
|
|
58
|
+
passSupersetsAsSubsetsV2,
|
|
59
|
+
platformImplSatisfiesSpecV2,
|
|
60
|
+
}
|
|
61
|
+
/* No side effect */
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
|
|
4
|
+
import * as Projection$ReventlessCore from "../../src/Projection.res.mjs";
|
|
5
|
+
|
|
6
|
+
globalThis.describe("Projection.optimizeActions", () => {
|
|
7
|
+
globalThis.test("does not duplicate the pre-merge action (off-by-one regression)", () => {
|
|
8
|
+
let optimized = Projection$ReventlessCore.optimizeActions([
|
|
9
|
+
{
|
|
10
|
+
TAG: "Delete",
|
|
11
|
+
_0: "a"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
TAG: "Update",
|
|
15
|
+
_0: "a",
|
|
16
|
+
_1: x => x + 1 | 0
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
TAG: "Set",
|
|
20
|
+
_0: "a",
|
|
21
|
+
_1: 99
|
|
22
|
+
}
|
|
23
|
+
]);
|
|
24
|
+
globalThis.expect(optimized.length).toBe(2);
|
|
25
|
+
let sets = Stdlib_Array.filterMap(optimized, a => {
|
|
26
|
+
if (typeof a !== "object" || a.TAG !== "Set") {
|
|
27
|
+
return;
|
|
28
|
+
} else {
|
|
29
|
+
return [
|
|
30
|
+
a._0,
|
|
31
|
+
a._1
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
globalThis.expect(sets).toEqual([[
|
|
36
|
+
"a",
|
|
37
|
+
99
|
|
38
|
+
]]);
|
|
39
|
+
});
|
|
40
|
+
globalThis.test("merges a same-id Create+Update chain into a single Create", () => {
|
|
41
|
+
let optimized = Projection$ReventlessCore.optimizeActions([
|
|
42
|
+
{
|
|
43
|
+
TAG: "Create",
|
|
44
|
+
_0: "a",
|
|
45
|
+
_1: 0
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
TAG: "Update",
|
|
49
|
+
_0: "a",
|
|
50
|
+
_1: x => x + 1 | 0
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
TAG: "Update",
|
|
54
|
+
_0: "a",
|
|
55
|
+
_1: x => x + 10 | 0
|
|
56
|
+
}
|
|
57
|
+
]);
|
|
58
|
+
let creates = Stdlib_Array.filterMap(optimized, a => {
|
|
59
|
+
if (typeof a !== "object" || a.TAG !== "Create") {
|
|
60
|
+
return;
|
|
61
|
+
} else {
|
|
62
|
+
return [
|
|
63
|
+
a._0,
|
|
64
|
+
a._1
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
globalThis.expect(creates).toEqual([[
|
|
69
|
+
"a",
|
|
70
|
+
11
|
|
71
|
+
]]);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
/* Not a pure module */
|