@reventlessdev/online-shop-aggregates-ordering 3.0.0-alpha.301 → 3.0.0-alpha.302
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 +7 -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
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 3.0.0-alpha.302 (2026-10-30)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **examples:** the customer's email and address are marked personal data ([768e985](https://github.com/ReventlessDev/reventless-core/commit/768e9853c4943eaad8926b9cb4df55e2a54f4fa8))
|
|
11
|
+
|
|
12
|
+
|
|
6
13
|
# 3.0.0-alpha.301 (2026-10-30)
|
|
7
14
|
|
|
8
15
|
**Note:** Version bump only for package @reventlessdev/online-shop-aggregates-ordering
|
package/lib/bs/.compiler.log
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#Start(
|
|
2
|
-
#Done(
|
|
1
|
+
#Start(1793351455084)
|
|
2
|
+
#Done(1793351463033)
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
"bsc_hash": "1006241435e8d5052329c523202a7fe6359a37e1e1688c023d37d6a7ebb5fb6d",
|
|
5
5
|
"rescript_config_hash": "4c884bf958b93b21c77764e35498f269b81377cfcc324135f1ab7a1cc5b569cb",
|
|
6
6
|
"runtime_path": "/home/runner/work/reventless-core/reventless-core/node_modules/@rescript/runtime",
|
|
7
|
-
"generated_at": "
|
|
7
|
+
"generated_at": "1793351463041"
|
|
8
8
|
}
|
package/lib/bs/src/CatalogProduct/ReadModel/AvailableProducts_Projections-OrderingPlugin.cmi
CHANGED
|
Binary file
|
package/lib/bs/src/CatalogProduct/ReadModel/AvailableProducts_Projections-OrderingPlugin.cmt
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -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
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
3
|
import * as Sury from "sury";
|
|
4
|
+
import * as Pii$Reventless from "@reventlessdev/reventless-spec/src/components/Pii.res.mjs";
|
|
4
5
|
import * as Email$Reventless from "@reventlessdev/reventless-spec/src/semantic/Email.res.mjs";
|
|
5
6
|
|
|
6
7
|
let commandSchema = Sury.union([
|
|
7
8
|
Sury.$schema(s => ({
|
|
8
9
|
TAG: "Register",
|
|
9
|
-
email: s.m(Email$Reventless.schema),
|
|
10
|
-
address: s.m(Sury.string)
|
|
10
|
+
email: s.m(Pii$Reventless.mark("$stream", undefined, Email$Reventless.schema)),
|
|
11
|
+
address: s.m(Pii$Reventless.mark("$stream", undefined, Sury.string))
|
|
11
12
|
})),
|
|
12
13
|
Sury.$schema(s => ({
|
|
13
14
|
TAG: "UpdateEmail",
|
|
14
|
-
email: s.m(Email$Reventless.schema)
|
|
15
|
+
email: s.m(Pii$Reventless.mark("$stream", undefined, Email$Reventless.schema))
|
|
15
16
|
})),
|
|
16
17
|
Sury.$schema(s => ({
|
|
17
18
|
TAG: "UpdateAddress",
|
|
18
|
-
address: s.m(Sury.string)
|
|
19
|
+
address: s.m(Pii$Reventless.mark("$stream", undefined, Sury.string))
|
|
19
20
|
})),
|
|
20
21
|
Sury.literal("Deactivate")
|
|
21
22
|
]);
|
|
@@ -23,16 +24,16 @@ let commandSchema = Sury.union([
|
|
|
23
24
|
let eventSchema = Sury.union([
|
|
24
25
|
Sury.$schema(s => ({
|
|
25
26
|
TAG: "Registered",
|
|
26
|
-
email: s.m(Sury.string),
|
|
27
|
-
address: s.m(Sury.string)
|
|
27
|
+
email: s.m(Pii$Reventless.marked("$stream", undefined, Sury.string)),
|
|
28
|
+
address: s.m(Pii$Reventless.marked("$stream", undefined, Sury.string))
|
|
28
29
|
})),
|
|
29
30
|
Sury.$schema(s => ({
|
|
30
31
|
TAG: "EmailUpdated",
|
|
31
|
-
email: s.m(Sury.string)
|
|
32
|
+
email: s.m(Pii$Reventless.marked("$stream", undefined, Sury.string))
|
|
32
33
|
})),
|
|
33
34
|
Sury.$schema(s => ({
|
|
34
35
|
TAG: "AddressUpdated",
|
|
35
|
-
address: s.m(Sury.string)
|
|
36
|
+
address: s.m(Pii$Reventless.marked("$stream", undefined, Sury.string))
|
|
36
37
|
})),
|
|
37
38
|
Sury.literal("Deactivated")
|
|
38
39
|
]);
|
|
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)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
3
|
import * as Sury from "sury";
|
|
4
|
+
import * as Pii$Reventless from "@reventlessdev/reventless-spec/src/components/Pii.res.mjs";
|
|
4
5
|
|
|
5
6
|
let stateSchema = Sury.union([
|
|
6
7
|
Sury.literal("NotCreated"),
|
|
@@ -14,38 +15,38 @@ let stateSchema = Sury.union([
|
|
|
14
15
|
|
|
15
16
|
function evolve(state, event) {
|
|
16
17
|
if (typeof state !== "object") {
|
|
17
|
-
if (state
|
|
18
|
-
return {
|
|
19
|
-
TAG: "Active",
|
|
20
|
-
email: event.email,
|
|
21
|
-
address: event.address
|
|
22
|
-
};
|
|
23
|
-
} else {
|
|
18
|
+
if (state !== "NotCreated") {
|
|
24
19
|
return state;
|
|
25
20
|
}
|
|
21
|
+
} else {
|
|
22
|
+
if (typeof event !== "object") {
|
|
23
|
+
return "Deactivated";
|
|
24
|
+
}
|
|
25
|
+
switch (event.TAG) {
|
|
26
|
+
case "Registered" :
|
|
27
|
+
break;
|
|
28
|
+
case "EmailUpdated" :
|
|
29
|
+
return {
|
|
30
|
+
TAG: "Active",
|
|
31
|
+
email: Pii$Reventless.getOr(event.email, ""),
|
|
32
|
+
address: state.address
|
|
33
|
+
};
|
|
34
|
+
case "AddressUpdated" :
|
|
35
|
+
return {
|
|
36
|
+
TAG: "Active",
|
|
37
|
+
email: state.email,
|
|
38
|
+
address: Pii$Reventless.getOr(event.address, "")
|
|
39
|
+
};
|
|
40
|
+
}
|
|
26
41
|
}
|
|
27
|
-
if (typeof event !== "object") {
|
|
28
|
-
return
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
address: event.address
|
|
36
|
-
};
|
|
37
|
-
case "EmailUpdated" :
|
|
38
|
-
return {
|
|
39
|
-
TAG: "Active",
|
|
40
|
-
email: event.email,
|
|
41
|
-
address: state.address
|
|
42
|
-
};
|
|
43
|
-
case "AddressUpdated" :
|
|
44
|
-
return {
|
|
45
|
-
TAG: "Active",
|
|
46
|
-
email: state.email,
|
|
47
|
-
address: event.address
|
|
48
|
-
};
|
|
42
|
+
if (typeof event !== "object" || event.TAG !== "Registered") {
|
|
43
|
+
return state;
|
|
44
|
+
} else {
|
|
45
|
+
return {
|
|
46
|
+
TAG: "Active",
|
|
47
|
+
email: Pii$Reventless.getOr(event.email, ""),
|
|
48
|
+
address: Pii$Reventless.getOr(event.address, "")
|
|
49
|
+
};
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
|
|
@@ -62,8 +63,14 @@ function decide(state, command) {
|
|
|
62
63
|
TAG: "Ok",
|
|
63
64
|
_0: [{
|
|
64
65
|
TAG: "Registered",
|
|
65
|
-
email:
|
|
66
|
-
|
|
66
|
+
email: {
|
|
67
|
+
TAG: "Value",
|
|
68
|
+
_0: command.email
|
|
69
|
+
},
|
|
70
|
+
address: {
|
|
71
|
+
TAG: "Value",
|
|
72
|
+
_0: command.address
|
|
73
|
+
}
|
|
67
74
|
}]
|
|
68
75
|
};
|
|
69
76
|
}
|
|
@@ -103,7 +110,10 @@ function decide(state, command) {
|
|
|
103
110
|
TAG: "Ok",
|
|
104
111
|
_0: [{
|
|
105
112
|
TAG: "EmailUpdated",
|
|
106
|
-
email:
|
|
113
|
+
email: {
|
|
114
|
+
TAG: "Value",
|
|
115
|
+
_0: email
|
|
116
|
+
}
|
|
107
117
|
}]
|
|
108
118
|
};
|
|
109
119
|
}
|
|
@@ -119,7 +129,10 @@ function decide(state, command) {
|
|
|
119
129
|
TAG: "Ok",
|
|
120
130
|
_0: [{
|
|
121
131
|
TAG: "AddressUpdated",
|
|
122
|
-
address:
|
|
132
|
+
address: {
|
|
133
|
+
TAG: "Value",
|
|
134
|
+
_0: address
|
|
135
|
+
}
|
|
123
136
|
}]
|
|
124
137
|
};
|
|
125
138
|
}
|
|
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
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
+
import * as Pii$Reventless from "@reventlessdev/reventless-spec/src/components/Pii.res.mjs";
|
|
3
4
|
import * as Projection$Reventless from "@reventlessdev/reventless-spec/src/types/Projection.res.mjs";
|
|
4
5
|
import * as Customer$OrderingPlugin from "../Aggregate/Customer.res.mjs";
|
|
5
6
|
import * as Customers$OrderingPlugin from "./Customers.res.mjs";
|
|
@@ -32,8 +33,8 @@ function project(param) {
|
|
|
32
33
|
TAG: "Set",
|
|
33
34
|
_0: id,
|
|
34
35
|
_1: {
|
|
35
|
-
email: event.email,
|
|
36
|
-
address: event.address,
|
|
36
|
+
email: Pii$Reventless.getOr(event.email, ""),
|
|
37
|
+
address: Pii$Reventless.getOr(event.address, ""),
|
|
37
38
|
deactivated: false
|
|
38
39
|
}
|
|
39
40
|
};
|
|
@@ -43,7 +44,7 @@ function project(param) {
|
|
|
43
44
|
TAG: "Update",
|
|
44
45
|
_0: id,
|
|
45
46
|
_1: state => ({
|
|
46
|
-
email: email,
|
|
47
|
+
email: Pii$Reventless.getOr(email, ""),
|
|
47
48
|
address: state.address,
|
|
48
49
|
deactivated: state.deactivated
|
|
49
50
|
})
|
|
@@ -55,7 +56,7 @@ function project(param) {
|
|
|
55
56
|
_0: id,
|
|
56
57
|
_1: state => ({
|
|
57
58
|
email: state.email,
|
|
58
|
-
address: address,
|
|
59
|
+
address: Pii$Reventless.getOr(address, ""),
|
|
59
60
|
deactivated: state.deactivated
|
|
60
61
|
})
|
|
61
62
|
};
|
|
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
|
|
Binary file
|
|
Binary file
|
|
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
|
)
|
|
@@ -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
|