@reventlessdev/online-shop-aggregates-ordering 3.0.0-alpha.301 → 3.0.0-alpha.303
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 +15 -0
- package/lib/bs/.compiler.log +2 -2
- package/lib/bs/compiler-info.json +1 -1
- package/lib/bs/src/CatalogProduct/ReadModel/AvailableProducts_Projections-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/CatalogProduct/ReadModel/AvailableProducts_Projections-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/Customer/Aggregate/Customer-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/Customer/Aggregate/Customer-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/Customer/Aggregate/Customer.ast +0 -0
- package/lib/bs/src/Customer/Aggregate/Customer.res +6 -6
- package/lib/bs/src/Customer/Aggregate/Customer.res.mjs +9 -8
- package/lib/bs/src/Customer/Aggregate/Customer_Decision-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/Customer/Aggregate/Customer_Decision-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/Customer/Aggregate/Customer_Decision.ast +0 -0
- package/lib/bs/src/Customer/Aggregate/Customer_Decision.res +11 -7
- package/lib/bs/src/Customer/Aggregate/Customer_Decision.res.mjs +46 -33
- package/lib/bs/src/Customer/ReadModel/Customers_Projections-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/Customer/ReadModel/Customers_Projections-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/Customer/ReadModel/Customers_Projections.ast +0 -0
- package/lib/bs/src/Customer/ReadModel/Customers_Projections.res +15 -3
- package/lib/bs/src/Customer/ReadModel/Customers_Projections.res.mjs +5 -4
- package/lib/bs/src/Extension/Products_Extension-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/Extension/Products_Extension-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/ExtensionPoint/Orders_ExtensionPointMapping-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/ExtensionPoint/Orders_ExtensionPointMapping-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/LifecycleModel-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/LifecycleModel-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/Order/ReadModel/Orders_Projections-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/Order/ReadModel/Orders_Projections-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/Plugin-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/Plugin-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/Task/OrderNotifications-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/Task/OrderNotifications-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/CatalogProduct/Aggregate/CatalogProduct_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/CatalogProduct/Aggregate/CatalogProduct_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/CatalogProduct/ReadModel/AvailableProducts_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/CatalogProduct/ReadModel/AvailableProducts_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/Customer/Aggregate/Customer_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/Customer/Aggregate/Customer_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/Customer/Aggregate/Customer_GWT.ast +0 -0
- package/lib/bs/tests/Customer/Aggregate/Customer_GWT.res +12 -12
- package/lib/bs/tests/Customer/Aggregate/Customer_GWT.res.mjs +88 -22
- package/lib/bs/tests/Customer/ReadModel/Customers_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/Customer/ReadModel/Customers_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/Customer/ReadModel/Customers_GWT.ast +0 -0
- package/lib/bs/tests/Customer/ReadModel/Customers_GWT.res +14 -6
- package/lib/bs/tests/Customer/ReadModel/Customers_GWT.res.mjs +40 -10
- package/lib/bs/tests/Extension/Products_Extension_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/Extension/Products_Extension_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/ExtensionPoint/Orders_ExtensionPointMapping_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/ExtensionPoint/Orders_ExtensionPointMapping_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/Order/Aggregate/OrderMappings_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/Order/Aggregate/OrderMappings_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/Order/Aggregate/Order_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/Order/Aggregate/Order_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/Order/ReadModel/Orders_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/Order/ReadModel/Orders_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/Order/SideEffect/EmailService_Mock-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/Order/SideEffect/EmailService_Mock-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/Order/SideEffect/Order_EmailNotification_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/Order/SideEffect/Order_EmailNotification_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/.compiler.log +2 -2
- package/lib/ocaml/AvailableProducts_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/AvailableProducts_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/AvailableProducts_Projections-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/AvailableProducts_Projections-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/CatalogProduct_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/CatalogProduct_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Customer-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Customer-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Customer.ast +0 -0
- package/lib/ocaml/Customer.res +6 -6
- package/lib/ocaml/Customer_Decision-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Customer_Decision-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Customer_Decision.ast +0 -0
- package/lib/ocaml/Customer_Decision.res +11 -7
- package/lib/ocaml/Customer_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Customer_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Customer_GWT.ast +0 -0
- package/lib/ocaml/Customer_GWT.res +12 -12
- package/lib/ocaml/Customers_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Customers_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Customers_GWT.ast +0 -0
- package/lib/ocaml/Customers_GWT.res +14 -6
- package/lib/ocaml/Customers_Projections-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Customers_Projections-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Customers_Projections.ast +0 -0
- package/lib/ocaml/Customers_Projections.res +15 -3
- package/lib/ocaml/EmailService_Mock-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/EmailService_Mock-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/LifecycleModel-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/LifecycleModel-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/OrderMappings_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/OrderMappings_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/OrderNotifications-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/OrderNotifications-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Order_EmailNotification_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Order_EmailNotification_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Order_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Order_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Orders_ExtensionPointMapping-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Orders_ExtensionPointMapping-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Orders_ExtensionPointMapping_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Orders_ExtensionPointMapping_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Orders_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Orders_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Orders_Projections-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Orders_Projections-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Plugin-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Plugin-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Products_Extension-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Products_Extension-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Products_Extension_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Products_Extension_GWT-OrderingPlugin.cmt +0 -0
- package/package.json +7 -7
- package/src/Customer/Aggregate/Customer.res +6 -6
- package/src/Customer/Aggregate/Customer.res.mjs +9 -8
- package/src/Customer/Aggregate/Customer_Decision.res +11 -7
- package/src/Customer/Aggregate/Customer_Decision.res.mjs +46 -33
- package/src/Customer/ReadModel/Customers_Projections.res +15 -3
- package/src/Customer/ReadModel/Customers_Projections.res.mjs +5 -4
- package/tests/Customer/Aggregate/Customer_GWT.res +12 -12
- package/tests/Customer/Aggregate/Customer_GWT.res.mjs +88 -22
- package/tests/Customer/ReadModel/Customers_GWT.res +14 -6
- package/tests/Customer/ReadModel/Customers_GWT.res.mjs +40 -10
|
@@ -47,13 +47,25 @@ describe("Customer Decision", () => {
|
|
|
47
47
|
address: Ordering_Examples$OrderingPlugin.mainStreet
|
|
48
48
|
}), {
|
|
49
49
|
TAG: "Registered",
|
|
50
|
-
email:
|
|
51
|
-
|
|
50
|
+
email: {
|
|
51
|
+
TAG: "Value",
|
|
52
|
+
_0: Ordering_Examples$OrderingPlugin.aliceEmail
|
|
53
|
+
},
|
|
54
|
+
address: {
|
|
55
|
+
TAG: "Value",
|
|
56
|
+
_0: Ordering_Examples$OrderingPlugin.mainStreet
|
|
57
|
+
}
|
|
52
58
|
}));
|
|
53
59
|
test("Register on existing aggregate returns CustomerAlreadyRegistered", () => thenError(whenCmd(givenEvents([{
|
|
54
60
|
TAG: "Registered",
|
|
55
|
-
email:
|
|
56
|
-
|
|
61
|
+
email: {
|
|
62
|
+
TAG: "Value",
|
|
63
|
+
_0: Ordering_Examples$OrderingPlugin.aliceEmail
|
|
64
|
+
},
|
|
65
|
+
address: {
|
|
66
|
+
TAG: "Value",
|
|
67
|
+
_0: Ordering_Examples$OrderingPlugin.mainStreet
|
|
68
|
+
}
|
|
57
69
|
}]), {
|
|
58
70
|
TAG: "Register",
|
|
59
71
|
email: Ordering_Examples$OrderingPlugin.bobEmail,
|
|
@@ -62,8 +74,14 @@ describe("Customer Decision", () => {
|
|
|
62
74
|
test("Register on deactivated aggregate returns CustomerAlreadyDeactivated", () => thenError(whenCmd(givenEvents([
|
|
63
75
|
{
|
|
64
76
|
TAG: "Registered",
|
|
65
|
-
email:
|
|
66
|
-
|
|
77
|
+
email: {
|
|
78
|
+
TAG: "Value",
|
|
79
|
+
_0: Ordering_Examples$OrderingPlugin.aliceEmail
|
|
80
|
+
},
|
|
81
|
+
address: {
|
|
82
|
+
TAG: "Value",
|
|
83
|
+
_0: Ordering_Examples$OrderingPlugin.mainStreet
|
|
84
|
+
}
|
|
67
85
|
},
|
|
68
86
|
"Deactivated"
|
|
69
87
|
]), {
|
|
@@ -77,19 +95,34 @@ describe("Customer Decision", () => {
|
|
|
77
95
|
}), "CustomerNotFound"));
|
|
78
96
|
test("UpdateEmail on active customer produces EmailUpdated", () => thenEvent(whenCmd(givenEvents([{
|
|
79
97
|
TAG: "Registered",
|
|
80
|
-
email:
|
|
81
|
-
|
|
98
|
+
email: {
|
|
99
|
+
TAG: "Value",
|
|
100
|
+
_0: Ordering_Examples$OrderingPlugin.aliceEmail
|
|
101
|
+
},
|
|
102
|
+
address: {
|
|
103
|
+
TAG: "Value",
|
|
104
|
+
_0: Ordering_Examples$OrderingPlugin.mainStreet
|
|
105
|
+
}
|
|
82
106
|
}]), {
|
|
83
107
|
TAG: "UpdateEmail",
|
|
84
108
|
email: "alice2@example.com"
|
|
85
109
|
}), {
|
|
86
110
|
TAG: "EmailUpdated",
|
|
87
|
-
email:
|
|
111
|
+
email: {
|
|
112
|
+
TAG: "Value",
|
|
113
|
+
_0: "alice2@example.com"
|
|
114
|
+
}
|
|
88
115
|
}));
|
|
89
116
|
test("UpdateEmail to same email produces no events (idempotent)", () => thenNoEvent(whenCmd(givenEvents([{
|
|
90
117
|
TAG: "Registered",
|
|
91
|
-
email:
|
|
92
|
-
|
|
118
|
+
email: {
|
|
119
|
+
TAG: "Value",
|
|
120
|
+
_0: Ordering_Examples$OrderingPlugin.aliceEmail
|
|
121
|
+
},
|
|
122
|
+
address: {
|
|
123
|
+
TAG: "Value",
|
|
124
|
+
_0: Ordering_Examples$OrderingPlugin.mainStreet
|
|
125
|
+
}
|
|
93
126
|
}]), {
|
|
94
127
|
TAG: "UpdateEmail",
|
|
95
128
|
email: Ordering_Examples$OrderingPlugin.aliceEmail
|
|
@@ -97,8 +130,14 @@ describe("Customer Decision", () => {
|
|
|
97
130
|
test("UpdateEmail on deactivated customer returns CustomerAlreadyDeactivated", () => thenError(whenCmd(givenEvents([
|
|
98
131
|
{
|
|
99
132
|
TAG: "Registered",
|
|
100
|
-
email:
|
|
101
|
-
|
|
133
|
+
email: {
|
|
134
|
+
TAG: "Value",
|
|
135
|
+
_0: Ordering_Examples$OrderingPlugin.aliceEmail
|
|
136
|
+
},
|
|
137
|
+
address: {
|
|
138
|
+
TAG: "Value",
|
|
139
|
+
_0: Ordering_Examples$OrderingPlugin.mainStreet
|
|
140
|
+
}
|
|
102
141
|
},
|
|
103
142
|
"Deactivated"
|
|
104
143
|
]), {
|
|
@@ -111,19 +150,34 @@ describe("Customer Decision", () => {
|
|
|
111
150
|
}), "CustomerNotFound"));
|
|
112
151
|
test("UpdateAddress on active customer produces AddressUpdated", () => thenEvent(whenCmd(givenEvents([{
|
|
113
152
|
TAG: "Registered",
|
|
114
|
-
email:
|
|
115
|
-
|
|
153
|
+
email: {
|
|
154
|
+
TAG: "Value",
|
|
155
|
+
_0: Ordering_Examples$OrderingPlugin.aliceEmail
|
|
156
|
+
},
|
|
157
|
+
address: {
|
|
158
|
+
TAG: "Value",
|
|
159
|
+
_0: Ordering_Examples$OrderingPlugin.mainStreet
|
|
160
|
+
}
|
|
116
161
|
}]), {
|
|
117
162
|
TAG: "UpdateAddress",
|
|
118
163
|
address: "789 Pine Rd"
|
|
119
164
|
}), {
|
|
120
165
|
TAG: "AddressUpdated",
|
|
121
|
-
address:
|
|
166
|
+
address: {
|
|
167
|
+
TAG: "Value",
|
|
168
|
+
_0: "789 Pine Rd"
|
|
169
|
+
}
|
|
122
170
|
}));
|
|
123
171
|
test("UpdateAddress to same address produces no events (idempotent)", () => thenNoEvent(whenCmd(givenEvents([{
|
|
124
172
|
TAG: "Registered",
|
|
125
|
-
email:
|
|
126
|
-
|
|
173
|
+
email: {
|
|
174
|
+
TAG: "Value",
|
|
175
|
+
_0: Ordering_Examples$OrderingPlugin.aliceEmail
|
|
176
|
+
},
|
|
177
|
+
address: {
|
|
178
|
+
TAG: "Value",
|
|
179
|
+
_0: Ordering_Examples$OrderingPlugin.mainStreet
|
|
180
|
+
}
|
|
127
181
|
}]), {
|
|
128
182
|
TAG: "UpdateAddress",
|
|
129
183
|
address: Ordering_Examples$OrderingPlugin.mainStreet
|
|
@@ -131,14 +185,26 @@ describe("Customer Decision", () => {
|
|
|
131
185
|
test("Deactivate on non-existent aggregate returns CustomerNotFound", () => thenError(whenCmd(givenEvents([]), "Deactivate"), "CustomerNotFound"));
|
|
132
186
|
test("Deactivate on active customer produces Deactivated", () => thenEvent(whenCmd(givenEvents([{
|
|
133
187
|
TAG: "Registered",
|
|
134
|
-
email:
|
|
135
|
-
|
|
188
|
+
email: {
|
|
189
|
+
TAG: "Value",
|
|
190
|
+
_0: Ordering_Examples$OrderingPlugin.aliceEmail
|
|
191
|
+
},
|
|
192
|
+
address: {
|
|
193
|
+
TAG: "Value",
|
|
194
|
+
_0: Ordering_Examples$OrderingPlugin.mainStreet
|
|
195
|
+
}
|
|
136
196
|
}]), "Deactivate"), "Deactivated"));
|
|
137
197
|
test("Deactivate on deactivated customer produces no events (idempotent)", () => thenNoEvent(whenCmd(givenEvents([
|
|
138
198
|
{
|
|
139
199
|
TAG: "Registered",
|
|
140
|
-
email:
|
|
141
|
-
|
|
200
|
+
email: {
|
|
201
|
+
TAG: "Value",
|
|
202
|
+
_0: Ordering_Examples$OrderingPlugin.aliceEmail
|
|
203
|
+
},
|
|
204
|
+
address: {
|
|
205
|
+
TAG: "Value",
|
|
206
|
+
_0: Ordering_Examples$OrderingPlugin.mainStreet
|
|
207
|
+
}
|
|
142
208
|
},
|
|
143
209
|
"Deactivated"
|
|
144
210
|
]), "Deactivate")));
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -4,27 +4,35 @@ describe("Customers ReadModel ← Customer", () => {
|
|
|
4
4
|
// scenario-id: d64df451-1238-400b-b146-4bd84dfb232b
|
|
5
5
|
test("Registered sets initial read model state", () =>
|
|
6
6
|
givenEvents([])
|
|
7
|
-
->whenEvent(
|
|
7
|
+
->whenEvent(
|
|
8
|
+
Customer.Registered({email: Value("alice@example.com"), address: Value("123 Main St")}),
|
|
9
|
+
)
|
|
8
10
|
->thenState({Customers.email: "alice@example.com", address: "123 Main St", deactivated: false})
|
|
9
11
|
)
|
|
10
12
|
|
|
11
13
|
// scenario-id: 80d62196-a14f-4da6-9993-384996b0be93
|
|
12
14
|
test("EmailUpdated updates the email", () =>
|
|
13
|
-
givenEvents([
|
|
14
|
-
|
|
15
|
+
givenEvents([
|
|
16
|
+
Customer.Registered({email: Value("alice@example.com"), address: Value("123 Main St")}),
|
|
17
|
+
])
|
|
18
|
+
->whenEvent(Customer.EmailUpdated({email: Value("alice2@example.com")}))
|
|
15
19
|
->thenState({Customers.email: "alice2@example.com", address: "123 Main St", deactivated: false})
|
|
16
20
|
)
|
|
17
21
|
|
|
18
22
|
// scenario-id: 55ce1763-d498-440d-8c19-2dc8adfa69e2
|
|
19
23
|
test("AddressUpdated updates the address", () =>
|
|
20
|
-
givenEvents([
|
|
21
|
-
|
|
24
|
+
givenEvents([
|
|
25
|
+
Customer.Registered({email: Value("alice@example.com"), address: Value("123 Main St")}),
|
|
26
|
+
])
|
|
27
|
+
->whenEvent(Customer.AddressUpdated({address: Value("789 Pine Rd")}))
|
|
22
28
|
->thenState({Customers.email: "alice@example.com", address: "789 Pine Rd", deactivated: false})
|
|
23
29
|
)
|
|
24
30
|
|
|
25
31
|
// scenario-id: 9885a011-7448-431f-ae96-629aae5f9823
|
|
26
32
|
test("Deactivated sets deactivated flag", () =>
|
|
27
|
-
givenEvents([
|
|
33
|
+
givenEvents([
|
|
34
|
+
Customer.Registered({email: Value("alice@example.com"), address: Value("123 Main St")}),
|
|
35
|
+
])
|
|
28
36
|
->whenEvent(Customer.Deactivated)
|
|
29
37
|
->thenState({Customers.email: "alice@example.com", address: "123 Main St", deactivated: true})
|
|
30
38
|
)
|
|
@@ -18,8 +18,14 @@ let thenState = include.thenState;
|
|
|
18
18
|
describe("Customers ReadModel ← Customer", () => {
|
|
19
19
|
test("Registered sets initial read model state", undefined, () => thenState(whenEvent(givenEvents([]), {
|
|
20
20
|
TAG: "Registered",
|
|
21
|
-
email:
|
|
22
|
-
|
|
21
|
+
email: {
|
|
22
|
+
TAG: "Value",
|
|
23
|
+
_0: "alice@example.com"
|
|
24
|
+
},
|
|
25
|
+
address: {
|
|
26
|
+
TAG: "Value",
|
|
27
|
+
_0: "123 Main St"
|
|
28
|
+
}
|
|
23
29
|
}), {
|
|
24
30
|
email: "alice@example.com",
|
|
25
31
|
address: "123 Main St",
|
|
@@ -27,11 +33,20 @@ describe("Customers ReadModel ← Customer", () => {
|
|
|
27
33
|
}));
|
|
28
34
|
test("EmailUpdated updates the email", undefined, () => thenState(whenEvent(givenEvents([{
|
|
29
35
|
TAG: "Registered",
|
|
30
|
-
email:
|
|
31
|
-
|
|
36
|
+
email: {
|
|
37
|
+
TAG: "Value",
|
|
38
|
+
_0: "alice@example.com"
|
|
39
|
+
},
|
|
40
|
+
address: {
|
|
41
|
+
TAG: "Value",
|
|
42
|
+
_0: "123 Main St"
|
|
43
|
+
}
|
|
32
44
|
}]), {
|
|
33
45
|
TAG: "EmailUpdated",
|
|
34
|
-
email:
|
|
46
|
+
email: {
|
|
47
|
+
TAG: "Value",
|
|
48
|
+
_0: "alice2@example.com"
|
|
49
|
+
}
|
|
35
50
|
}), {
|
|
36
51
|
email: "alice2@example.com",
|
|
37
52
|
address: "123 Main St",
|
|
@@ -39,11 +54,20 @@ describe("Customers ReadModel ← Customer", () => {
|
|
|
39
54
|
}));
|
|
40
55
|
test("AddressUpdated updates the address", undefined, () => thenState(whenEvent(givenEvents([{
|
|
41
56
|
TAG: "Registered",
|
|
42
|
-
email:
|
|
43
|
-
|
|
57
|
+
email: {
|
|
58
|
+
TAG: "Value",
|
|
59
|
+
_0: "alice@example.com"
|
|
60
|
+
},
|
|
61
|
+
address: {
|
|
62
|
+
TAG: "Value",
|
|
63
|
+
_0: "123 Main St"
|
|
64
|
+
}
|
|
44
65
|
}]), {
|
|
45
66
|
TAG: "AddressUpdated",
|
|
46
|
-
address:
|
|
67
|
+
address: {
|
|
68
|
+
TAG: "Value",
|
|
69
|
+
_0: "789 Pine Rd"
|
|
70
|
+
}
|
|
47
71
|
}), {
|
|
48
72
|
email: "alice@example.com",
|
|
49
73
|
address: "789 Pine Rd",
|
|
@@ -51,8 +75,14 @@ describe("Customers ReadModel ← Customer", () => {
|
|
|
51
75
|
}));
|
|
52
76
|
test("Deactivated sets deactivated flag", undefined, () => thenState(whenEvent(givenEvents([{
|
|
53
77
|
TAG: "Registered",
|
|
54
|
-
email:
|
|
55
|
-
|
|
78
|
+
email: {
|
|
79
|
+
TAG: "Value",
|
|
80
|
+
_0: "alice@example.com"
|
|
81
|
+
},
|
|
82
|
+
address: {
|
|
83
|
+
TAG: "Value",
|
|
84
|
+
_0: "123 Main St"
|
|
85
|
+
}
|
|
56
86
|
}]), "Deactivated"), {
|
|
57
87
|
email: "alice@example.com",
|
|
58
88
|
address: "123 Main St",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/ocaml/.compiler.log
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#Start(
|
|
2
|
-
#Done(
|
|
1
|
+
#Start(1793352728334)
|
|
2
|
+
#Done(1793352733387)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/ocaml/Customer.ast
CHANGED
|
Binary file
|
package/lib/ocaml/Customer.res
CHANGED
|
@@ -11,16 +11,16 @@ module Id = CustomerId
|
|
|
11
11
|
// on read is the risk a branded scalar exists to avoid.
|
|
12
12
|
@schema
|
|
13
13
|
type command =
|
|
14
|
-
| Register({email: @s.matches(Reventless.Email.schema) string, address: string})
|
|
15
|
-
| UpdateEmail({email: @s.matches(Reventless.Email.schema) string})
|
|
16
|
-
| UpdateAddress({address: string})
|
|
14
|
+
| Register({@pii email: @s.matches(Reventless.Email.schema) string, @pii address: string})
|
|
15
|
+
| UpdateEmail({@pii email: @s.matches(Reventless.Email.schema) string})
|
|
16
|
+
| UpdateAddress({@pii address: string})
|
|
17
17
|
| Deactivate
|
|
18
18
|
|
|
19
19
|
@schema
|
|
20
20
|
type event =
|
|
21
|
-
| Registered({email: string, address: string})
|
|
22
|
-
| EmailUpdated({email: string})
|
|
23
|
-
| AddressUpdated({address: string})
|
|
21
|
+
| Registered({@pii email: string, @pii address: string})
|
|
22
|
+
| EmailUpdated({@pii email: string})
|
|
23
|
+
| AddressUpdated({@pii address: string})
|
|
24
24
|
| Deactivated
|
|
25
25
|
|
|
26
26
|
@schema
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -13,10 +13,13 @@ let initialState = NotCreated
|
|
|
13
13
|
|
|
14
14
|
let evolve = (state, event) =>
|
|
15
15
|
switch (state, event) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
| (Active(
|
|
19
|
-
|
|
16
|
+
// A personal field reads `Erased` once its customer is erased; the state then
|
|
17
|
+
// holds nothing in its place, as a profile never written would.
|
|
18
|
+
| (NotCreated | Active(_), Registered({email, address})) =>
|
|
19
|
+
Active({email: email->Reventless.Pii.getOr(""), address: address->Reventless.Pii.getOr("")})
|
|
20
|
+
| (Active(s), EmailUpdated({email})) => Active({...s, email: email->Reventless.Pii.getOr("")})
|
|
21
|
+
| (Active(s), AddressUpdated({address})) =>
|
|
22
|
+
Active({...s, address: address->Reventless.Pii.getOr("")})
|
|
20
23
|
| (Active(_), Customer.Deactivated) => Deactivated
|
|
21
24
|
| (Deactivated, _) => state
|
|
22
25
|
| (NotCreated, _) => state
|
|
@@ -24,15 +27,16 @@ let evolve = (state, event) =>
|
|
|
24
27
|
|
|
25
28
|
let decide = (state, command) =>
|
|
26
29
|
switch (state, command) {
|
|
27
|
-
| (NotCreated, Register({email, address})) =>
|
|
30
|
+
| (NotCreated, Register({email, address})) =>
|
|
31
|
+
Ok([Registered({email: Value(email), address: Value(address)})])
|
|
28
32
|
| (NotCreated, UpdateEmail(_)) => Error(CustomerNotFound)
|
|
29
33
|
| (NotCreated, UpdateAddress(_)) => Error(CustomerNotFound)
|
|
30
34
|
| (NotCreated, Deactivate) => Error(CustomerNotFound)
|
|
31
35
|
| (Active(_), Register(_)) => Error(CustomerAlreadyRegistered)
|
|
32
36
|
| (Active(s), UpdateEmail({email})) if email == s.email => Ok([])
|
|
33
|
-
| (Active(_), UpdateEmail({email})) => Ok([EmailUpdated({email: email})])
|
|
37
|
+
| (Active(_), UpdateEmail({email})) => Ok([EmailUpdated({email: Value(email)})])
|
|
34
38
|
| (Active(s), UpdateAddress({address})) if address == s.address => Ok([])
|
|
35
|
-
| (Active(_), UpdateAddress({address})) => Ok([AddressUpdated({address: address})])
|
|
39
|
+
| (Active(_), UpdateAddress({address})) => Ok([AddressUpdated({address: Value(address)})])
|
|
36
40
|
| (Active(_), Deactivate) => Ok([Customer.Deactivated])
|
|
37
41
|
| (Deactivated, Register(_)) => Error(CustomerAlreadyDeactivated)
|
|
38
42
|
| (Deactivated, UpdateEmail(_)) => Error(CustomerAlreadyDeactivated)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -7,19 +7,19 @@ describe("Customer Decision", () => {
|
|
|
7
7
|
test("Register on new aggregate produces Registered", () =>
|
|
8
8
|
givenEvents([])
|
|
9
9
|
->whenCmd(Register({email: aliceEmail, address: mainStreet}))
|
|
10
|
-
->thenEvent(Registered({email: aliceEmail, address: mainStreet}))
|
|
10
|
+
->thenEvent(Registered({email: Value(aliceEmail), address: Value(mainStreet)}))
|
|
11
11
|
)
|
|
12
12
|
|
|
13
13
|
// scenario-id: 93201f16-17d6-4f94-a096-2dbec3c4306c
|
|
14
14
|
test("Register on existing aggregate returns CustomerAlreadyRegistered", () =>
|
|
15
|
-
givenEvents([Registered({email: aliceEmail, address: mainStreet})])
|
|
15
|
+
givenEvents([Registered({email: Value(aliceEmail), address: Value(mainStreet)})])
|
|
16
16
|
->whenCmd(Register({email: bobEmail, address: oakAvenue}))
|
|
17
17
|
->thenError(CustomerAlreadyRegistered)
|
|
18
18
|
)
|
|
19
19
|
|
|
20
20
|
// scenario-id: fcbc5972-10f0-43ae-a402-21fa7e398e2b
|
|
21
21
|
test("Register on deactivated aggregate returns CustomerAlreadyDeactivated", () =>
|
|
22
|
-
givenEvents([Registered({email: aliceEmail, address: mainStreet}), Deactivated])
|
|
22
|
+
givenEvents([Registered({email: Value(aliceEmail), address: Value(mainStreet)}), Deactivated])
|
|
23
23
|
->whenCmd(Register({email: bobEmail, address: oakAvenue}))
|
|
24
24
|
->thenError(CustomerAlreadyDeactivated)
|
|
25
25
|
)
|
|
@@ -33,21 +33,21 @@ describe("Customer Decision", () => {
|
|
|
33
33
|
|
|
34
34
|
// scenario-id: 0da39fef-7112-4f6b-93d6-f1479d8d384b
|
|
35
35
|
test("UpdateEmail on active customer produces EmailUpdated", () =>
|
|
36
|
-
givenEvents([Registered({email: aliceEmail, address: mainStreet})])
|
|
36
|
+
givenEvents([Registered({email: Value(aliceEmail), address: Value(mainStreet)})])
|
|
37
37
|
->whenCmd(UpdateEmail({email: "alice2@example.com"}))
|
|
38
|
-
->thenEvent(EmailUpdated({email: "alice2@example.com"}))
|
|
38
|
+
->thenEvent(EmailUpdated({email: Value("alice2@example.com")}))
|
|
39
39
|
)
|
|
40
40
|
|
|
41
41
|
// scenario-id: 27d8e526-daa8-4b11-be68-c1107394f75d
|
|
42
42
|
test("UpdateEmail to same email produces no events (idempotent)", () =>
|
|
43
|
-
givenEvents([Registered({email: aliceEmail, address: mainStreet})])
|
|
43
|
+
givenEvents([Registered({email: Value(aliceEmail), address: Value(mainStreet)})])
|
|
44
44
|
->whenCmd(UpdateEmail({email: aliceEmail}))
|
|
45
45
|
->thenNoEvent
|
|
46
46
|
)
|
|
47
47
|
|
|
48
48
|
// scenario-id: f95d0cde-1011-4566-975b-ef086015d811
|
|
49
49
|
test("UpdateEmail on deactivated customer returns CustomerAlreadyDeactivated", () =>
|
|
50
|
-
givenEvents([Registered({email: aliceEmail, address: mainStreet}), Deactivated])
|
|
50
|
+
givenEvents([Registered({email: Value(aliceEmail), address: Value(mainStreet)}), Deactivated])
|
|
51
51
|
->whenCmd(UpdateEmail({email: bobEmail}))
|
|
52
52
|
->thenError(CustomerAlreadyDeactivated)
|
|
53
53
|
)
|
|
@@ -61,14 +61,14 @@ describe("Customer Decision", () => {
|
|
|
61
61
|
|
|
62
62
|
// scenario-id: 2f4959d6-b687-4659-b5a6-282a6463d1d8
|
|
63
63
|
test("UpdateAddress on active customer produces AddressUpdated", () =>
|
|
64
|
-
givenEvents([Registered({email: aliceEmail, address: mainStreet})])
|
|
64
|
+
givenEvents([Registered({email: Value(aliceEmail), address: Value(mainStreet)})])
|
|
65
65
|
->whenCmd(UpdateAddress({address: "789 Pine Rd"}))
|
|
66
|
-
->thenEvent(AddressUpdated({address: "789 Pine Rd"}))
|
|
66
|
+
->thenEvent(AddressUpdated({address: Value("789 Pine Rd")}))
|
|
67
67
|
)
|
|
68
68
|
|
|
69
69
|
// scenario-id: 004ce506-1231-43d7-a659-263af800b815
|
|
70
70
|
test("UpdateAddress to same address produces no events (idempotent)", () =>
|
|
71
|
-
givenEvents([Registered({email: aliceEmail, address: mainStreet})])
|
|
71
|
+
givenEvents([Registered({email: Value(aliceEmail), address: Value(mainStreet)})])
|
|
72
72
|
->whenCmd(UpdateAddress({address: mainStreet}))
|
|
73
73
|
->thenNoEvent
|
|
74
74
|
)
|
|
@@ -82,14 +82,14 @@ describe("Customer Decision", () => {
|
|
|
82
82
|
|
|
83
83
|
// scenario-id: 54c0ec8c-f937-41b7-bed0-963c54702564
|
|
84
84
|
test("Deactivate on active customer produces Deactivated", () =>
|
|
85
|
-
givenEvents([Registered({email: aliceEmail, address: mainStreet})])
|
|
85
|
+
givenEvents([Registered({email: Value(aliceEmail), address: Value(mainStreet)})])
|
|
86
86
|
->whenCmd(Deactivate)
|
|
87
87
|
->thenEvent(Deactivated)
|
|
88
88
|
)
|
|
89
89
|
|
|
90
90
|
// scenario-id: 083c8024-7e68-44d6-b9ff-61a3250202bf
|
|
91
91
|
test("Deactivate on deactivated customer produces no events (idempotent)", () =>
|
|
92
|
-
givenEvents([Registered({email: aliceEmail, address: mainStreet}), Deactivated])
|
|
92
|
+
givenEvents([Registered({email: Value(aliceEmail), address: Value(mainStreet)}), Deactivated])
|
|
93
93
|
->whenCmd(Deactivate)
|
|
94
94
|
->thenNoEvent
|
|
95
95
|
)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -4,27 +4,35 @@ describe("Customers ReadModel ← Customer", () => {
|
|
|
4
4
|
// scenario-id: d64df451-1238-400b-b146-4bd84dfb232b
|
|
5
5
|
test("Registered sets initial read model state", () =>
|
|
6
6
|
givenEvents([])
|
|
7
|
-
->whenEvent(
|
|
7
|
+
->whenEvent(
|
|
8
|
+
Customer.Registered({email: Value("alice@example.com"), address: Value("123 Main St")}),
|
|
9
|
+
)
|
|
8
10
|
->thenState({Customers.email: "alice@example.com", address: "123 Main St", deactivated: false})
|
|
9
11
|
)
|
|
10
12
|
|
|
11
13
|
// scenario-id: 80d62196-a14f-4da6-9993-384996b0be93
|
|
12
14
|
test("EmailUpdated updates the email", () =>
|
|
13
|
-
givenEvents([
|
|
14
|
-
|
|
15
|
+
givenEvents([
|
|
16
|
+
Customer.Registered({email: Value("alice@example.com"), address: Value("123 Main St")}),
|
|
17
|
+
])
|
|
18
|
+
->whenEvent(Customer.EmailUpdated({email: Value("alice2@example.com")}))
|
|
15
19
|
->thenState({Customers.email: "alice2@example.com", address: "123 Main St", deactivated: false})
|
|
16
20
|
)
|
|
17
21
|
|
|
18
22
|
// scenario-id: 55ce1763-d498-440d-8c19-2dc8adfa69e2
|
|
19
23
|
test("AddressUpdated updates the address", () =>
|
|
20
|
-
givenEvents([
|
|
21
|
-
|
|
24
|
+
givenEvents([
|
|
25
|
+
Customer.Registered({email: Value("alice@example.com"), address: Value("123 Main St")}),
|
|
26
|
+
])
|
|
27
|
+
->whenEvent(Customer.AddressUpdated({address: Value("789 Pine Rd")}))
|
|
22
28
|
->thenState({Customers.email: "alice@example.com", address: "789 Pine Rd", deactivated: false})
|
|
23
29
|
)
|
|
24
30
|
|
|
25
31
|
// scenario-id: 9885a011-7448-431f-ae96-629aae5f9823
|
|
26
32
|
test("Deactivated sets deactivated flag", () =>
|
|
27
|
-
givenEvents([
|
|
33
|
+
givenEvents([
|
|
34
|
+
Customer.Registered({email: Value("alice@example.com"), address: Value("123 Main St")}),
|
|
35
|
+
])
|
|
28
36
|
->whenEvent(Customer.Deactivated)
|
|
29
37
|
->thenState({Customers.email: "alice@example.com", address: "123 Main St", deactivated: true})
|
|
30
38
|
)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -9,9 +9,21 @@ module CustomerMapping = Mapping.Make(
|
|
|
9
9
|
open Customer
|
|
10
10
|
let project = ({event, id, _}) =>
|
|
11
11
|
switch event {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
|
12
|
+
// The read model holds plaintext; an erased customer's row is cleared by the
|
|
13
|
+
// app's erasure, and a rebuild after it writes nothing in its place.
|
|
14
|
+
| Registered({email, address}) =>
|
|
15
|
+
Set(
|
|
16
|
+
id,
|
|
17
|
+
{
|
|
18
|
+
Customers.email: email->Reventless.Pii.getOr(""),
|
|
19
|
+
address: address->Reventless.Pii.getOr(""),
|
|
20
|
+
deactivated: false,
|
|
21
|
+
},
|
|
22
|
+
)
|
|
23
|
+
| EmailUpdated({email}) =>
|
|
24
|
+
Update(id, state => {...state, email: email->Reventless.Pii.getOr("")})
|
|
25
|
+
| AddressUpdated({address}) =>
|
|
26
|
+
Update(id, state => {...state, address: address->Reventless.Pii.getOr("")})
|
|
15
27
|
| Deactivated => Update(id, state => {...state, deactivated: true})
|
|
16
28
|
}
|
|
17
29
|
},
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|