@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.
Files changed (124) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/lib/bs/.compiler.log +2 -2
  3. package/lib/bs/compiler-info.json +1 -1
  4. package/lib/bs/src/CatalogProduct/ReadModel/AvailableProducts_Projections-OrderingPlugin.cmi +0 -0
  5. package/lib/bs/src/CatalogProduct/ReadModel/AvailableProducts_Projections-OrderingPlugin.cmt +0 -0
  6. package/lib/bs/src/Customer/Aggregate/Customer-OrderingPlugin.cmi +0 -0
  7. package/lib/bs/src/Customer/Aggregate/Customer-OrderingPlugin.cmt +0 -0
  8. package/lib/bs/src/Customer/Aggregate/Customer.ast +0 -0
  9. package/lib/bs/src/Customer/Aggregate/Customer.res +6 -6
  10. package/lib/bs/src/Customer/Aggregate/Customer.res.mjs +9 -8
  11. package/lib/bs/src/Customer/Aggregate/Customer_Decision-OrderingPlugin.cmi +0 -0
  12. package/lib/bs/src/Customer/Aggregate/Customer_Decision-OrderingPlugin.cmt +0 -0
  13. package/lib/bs/src/Customer/Aggregate/Customer_Decision.ast +0 -0
  14. package/lib/bs/src/Customer/Aggregate/Customer_Decision.res +11 -7
  15. package/lib/bs/src/Customer/Aggregate/Customer_Decision.res.mjs +46 -33
  16. package/lib/bs/src/Customer/ReadModel/Customers_Projections-OrderingPlugin.cmi +0 -0
  17. package/lib/bs/src/Customer/ReadModel/Customers_Projections-OrderingPlugin.cmt +0 -0
  18. package/lib/bs/src/Customer/ReadModel/Customers_Projections.ast +0 -0
  19. package/lib/bs/src/Customer/ReadModel/Customers_Projections.res +15 -3
  20. package/lib/bs/src/Customer/ReadModel/Customers_Projections.res.mjs +5 -4
  21. package/lib/bs/src/Extension/Products_Extension-OrderingPlugin.cmi +0 -0
  22. package/lib/bs/src/Extension/Products_Extension-OrderingPlugin.cmt +0 -0
  23. package/lib/bs/src/ExtensionPoint/Orders_ExtensionPointMapping-OrderingPlugin.cmi +0 -0
  24. package/lib/bs/src/ExtensionPoint/Orders_ExtensionPointMapping-OrderingPlugin.cmt +0 -0
  25. package/lib/bs/src/LifecycleModel-OrderingPlugin.cmi +0 -0
  26. package/lib/bs/src/LifecycleModel-OrderingPlugin.cmt +0 -0
  27. package/lib/bs/src/Order/ReadModel/Orders_Projections-OrderingPlugin.cmi +0 -0
  28. package/lib/bs/src/Order/ReadModel/Orders_Projections-OrderingPlugin.cmt +0 -0
  29. package/lib/bs/src/Plugin-OrderingPlugin.cmi +0 -0
  30. package/lib/bs/src/Plugin-OrderingPlugin.cmt +0 -0
  31. package/lib/bs/src/Task/OrderNotifications-OrderingPlugin.cmi +0 -0
  32. package/lib/bs/src/Task/OrderNotifications-OrderingPlugin.cmt +0 -0
  33. package/lib/bs/tests/CatalogProduct/Aggregate/CatalogProduct_GWT-OrderingPlugin.cmi +0 -0
  34. package/lib/bs/tests/CatalogProduct/Aggregate/CatalogProduct_GWT-OrderingPlugin.cmt +0 -0
  35. package/lib/bs/tests/CatalogProduct/ReadModel/AvailableProducts_GWT-OrderingPlugin.cmi +0 -0
  36. package/lib/bs/tests/CatalogProduct/ReadModel/AvailableProducts_GWT-OrderingPlugin.cmt +0 -0
  37. package/lib/bs/tests/Customer/Aggregate/Customer_GWT-OrderingPlugin.cmi +0 -0
  38. package/lib/bs/tests/Customer/Aggregate/Customer_GWT-OrderingPlugin.cmt +0 -0
  39. package/lib/bs/tests/Customer/Aggregate/Customer_GWT.ast +0 -0
  40. package/lib/bs/tests/Customer/Aggregate/Customer_GWT.res +12 -12
  41. package/lib/bs/tests/Customer/Aggregate/Customer_GWT.res.mjs +88 -22
  42. package/lib/bs/tests/Customer/ReadModel/Customers_GWT-OrderingPlugin.cmi +0 -0
  43. package/lib/bs/tests/Customer/ReadModel/Customers_GWT-OrderingPlugin.cmt +0 -0
  44. package/lib/bs/tests/Customer/ReadModel/Customers_GWT.ast +0 -0
  45. package/lib/bs/tests/Customer/ReadModel/Customers_GWT.res +14 -6
  46. package/lib/bs/tests/Customer/ReadModel/Customers_GWT.res.mjs +40 -10
  47. package/lib/bs/tests/Extension/Products_Extension_GWT-OrderingPlugin.cmi +0 -0
  48. package/lib/bs/tests/Extension/Products_Extension_GWT-OrderingPlugin.cmt +0 -0
  49. package/lib/bs/tests/ExtensionPoint/Orders_ExtensionPointMapping_GWT-OrderingPlugin.cmi +0 -0
  50. package/lib/bs/tests/ExtensionPoint/Orders_ExtensionPointMapping_GWT-OrderingPlugin.cmt +0 -0
  51. package/lib/bs/tests/Order/Aggregate/OrderMappings_GWT-OrderingPlugin.cmi +0 -0
  52. package/lib/bs/tests/Order/Aggregate/OrderMappings_GWT-OrderingPlugin.cmt +0 -0
  53. package/lib/bs/tests/Order/Aggregate/Order_GWT-OrderingPlugin.cmi +0 -0
  54. package/lib/bs/tests/Order/Aggregate/Order_GWT-OrderingPlugin.cmt +0 -0
  55. package/lib/bs/tests/Order/ReadModel/Orders_GWT-OrderingPlugin.cmi +0 -0
  56. package/lib/bs/tests/Order/ReadModel/Orders_GWT-OrderingPlugin.cmt +0 -0
  57. package/lib/bs/tests/Order/SideEffect/EmailService_Mock-OrderingPlugin.cmi +0 -0
  58. package/lib/bs/tests/Order/SideEffect/EmailService_Mock-OrderingPlugin.cmt +0 -0
  59. package/lib/bs/tests/Order/SideEffect/Order_EmailNotification_GWT-OrderingPlugin.cmi +0 -0
  60. package/lib/bs/tests/Order/SideEffect/Order_EmailNotification_GWT-OrderingPlugin.cmt +0 -0
  61. package/lib/ocaml/.compiler.log +2 -2
  62. package/lib/ocaml/AvailableProducts_GWT-OrderingPlugin.cmi +0 -0
  63. package/lib/ocaml/AvailableProducts_GWT-OrderingPlugin.cmt +0 -0
  64. package/lib/ocaml/AvailableProducts_Projections-OrderingPlugin.cmi +0 -0
  65. package/lib/ocaml/AvailableProducts_Projections-OrderingPlugin.cmt +0 -0
  66. package/lib/ocaml/CatalogProduct_GWT-OrderingPlugin.cmi +0 -0
  67. package/lib/ocaml/CatalogProduct_GWT-OrderingPlugin.cmt +0 -0
  68. package/lib/ocaml/Customer-OrderingPlugin.cmi +0 -0
  69. package/lib/ocaml/Customer-OrderingPlugin.cmt +0 -0
  70. package/lib/ocaml/Customer.ast +0 -0
  71. package/lib/ocaml/Customer.res +6 -6
  72. package/lib/ocaml/Customer_Decision-OrderingPlugin.cmi +0 -0
  73. package/lib/ocaml/Customer_Decision-OrderingPlugin.cmt +0 -0
  74. package/lib/ocaml/Customer_Decision.ast +0 -0
  75. package/lib/ocaml/Customer_Decision.res +11 -7
  76. package/lib/ocaml/Customer_GWT-OrderingPlugin.cmi +0 -0
  77. package/lib/ocaml/Customer_GWT-OrderingPlugin.cmt +0 -0
  78. package/lib/ocaml/Customer_GWT.ast +0 -0
  79. package/lib/ocaml/Customer_GWT.res +12 -12
  80. package/lib/ocaml/Customers_GWT-OrderingPlugin.cmi +0 -0
  81. package/lib/ocaml/Customers_GWT-OrderingPlugin.cmt +0 -0
  82. package/lib/ocaml/Customers_GWT.ast +0 -0
  83. package/lib/ocaml/Customers_GWT.res +14 -6
  84. package/lib/ocaml/Customers_Projections-OrderingPlugin.cmi +0 -0
  85. package/lib/ocaml/Customers_Projections-OrderingPlugin.cmt +0 -0
  86. package/lib/ocaml/Customers_Projections.ast +0 -0
  87. package/lib/ocaml/Customers_Projections.res +15 -3
  88. package/lib/ocaml/EmailService_Mock-OrderingPlugin.cmi +0 -0
  89. package/lib/ocaml/EmailService_Mock-OrderingPlugin.cmt +0 -0
  90. package/lib/ocaml/LifecycleModel-OrderingPlugin.cmi +0 -0
  91. package/lib/ocaml/LifecycleModel-OrderingPlugin.cmt +0 -0
  92. package/lib/ocaml/OrderMappings_GWT-OrderingPlugin.cmi +0 -0
  93. package/lib/ocaml/OrderMappings_GWT-OrderingPlugin.cmt +0 -0
  94. package/lib/ocaml/OrderNotifications-OrderingPlugin.cmi +0 -0
  95. package/lib/ocaml/OrderNotifications-OrderingPlugin.cmt +0 -0
  96. package/lib/ocaml/Order_EmailNotification_GWT-OrderingPlugin.cmi +0 -0
  97. package/lib/ocaml/Order_EmailNotification_GWT-OrderingPlugin.cmt +0 -0
  98. package/lib/ocaml/Order_GWT-OrderingPlugin.cmi +0 -0
  99. package/lib/ocaml/Order_GWT-OrderingPlugin.cmt +0 -0
  100. package/lib/ocaml/Orders_ExtensionPointMapping-OrderingPlugin.cmi +0 -0
  101. package/lib/ocaml/Orders_ExtensionPointMapping-OrderingPlugin.cmt +0 -0
  102. package/lib/ocaml/Orders_ExtensionPointMapping_GWT-OrderingPlugin.cmi +0 -0
  103. package/lib/ocaml/Orders_ExtensionPointMapping_GWT-OrderingPlugin.cmt +0 -0
  104. package/lib/ocaml/Orders_GWT-OrderingPlugin.cmi +0 -0
  105. package/lib/ocaml/Orders_GWT-OrderingPlugin.cmt +0 -0
  106. package/lib/ocaml/Orders_Projections-OrderingPlugin.cmi +0 -0
  107. package/lib/ocaml/Orders_Projections-OrderingPlugin.cmt +0 -0
  108. package/lib/ocaml/Plugin-OrderingPlugin.cmi +0 -0
  109. package/lib/ocaml/Plugin-OrderingPlugin.cmt +0 -0
  110. package/lib/ocaml/Products_Extension-OrderingPlugin.cmi +0 -0
  111. package/lib/ocaml/Products_Extension-OrderingPlugin.cmt +0 -0
  112. package/lib/ocaml/Products_Extension_GWT-OrderingPlugin.cmi +0 -0
  113. package/lib/ocaml/Products_Extension_GWT-OrderingPlugin.cmt +0 -0
  114. package/package.json +7 -7
  115. package/src/Customer/Aggregate/Customer.res +6 -6
  116. package/src/Customer/Aggregate/Customer.res.mjs +9 -8
  117. package/src/Customer/Aggregate/Customer_Decision.res +11 -7
  118. package/src/Customer/Aggregate/Customer_Decision.res.mjs +46 -33
  119. package/src/Customer/ReadModel/Customers_Projections.res +15 -3
  120. package/src/Customer/ReadModel/Customers_Projections.res.mjs +5 -4
  121. package/tests/Customer/Aggregate/Customer_GWT.res +12 -12
  122. package/tests/Customer/Aggregate/Customer_GWT.res.mjs +88 -22
  123. package/tests/Customer/ReadModel/Customers_GWT.res +14 -6
  124. package/tests/Customer/ReadModel/Customers_GWT.res.mjs +40 -10
@@ -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(Customer.Registered({email: "alice@example.com", address: "123 Main St"}))
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([Customer.Registered({email: "alice@example.com", address: "123 Main St"})])
14
- ->whenEvent(Customer.EmailUpdated({email: "alice2@example.com"}))
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([Customer.Registered({email: "alice@example.com", address: "123 Main St"})])
21
- ->whenEvent(Customer.AddressUpdated({address: "789 Pine Rd"}))
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([Customer.Registered({email: "alice@example.com", address: "123 Main St"})])
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: "alice@example.com",
22
- address: "123 Main St"
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: "alice@example.com",
31
- address: "123 Main St"
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: "alice2@example.com"
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: "alice@example.com",
43
- address: "123 Main St"
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: "789 Pine Rd"
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: "alice@example.com",
55
- address: "123 Main St"
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",
@@ -1,2 +1,2 @@
1
- #Start(1793347137712)
2
- #Done(1793347145021)
1
+ #Start(1793351455084)
2
+ #Done(1793351463033)
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
Binary file
@@ -13,10 +13,13 @@ let initialState = NotCreated
13
13
 
14
14
  let evolve = (state, event) =>
15
15
  switch (state, event) {
16
- | (NotCreated, Registered({email, address})) => Active({email, address})
17
- | (Active(_), Registered({email, address})) => Active({email, address})
18
- | (Active(s), EmailUpdated({email})) => Active({...s, email})
19
- | (Active(s), AddressUpdated({address})) => Active({...s, address})
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})) => Ok([Registered({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
@@ -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
@@ -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(Customer.Registered({email: "alice@example.com", address: "123 Main St"}))
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([Customer.Registered({email: "alice@example.com", address: "123 Main St"})])
14
- ->whenEvent(Customer.EmailUpdated({email: "alice2@example.com"}))
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([Customer.Registered({email: "alice@example.com", address: "123 Main St"})])
21
- ->whenEvent(Customer.AddressUpdated({address: "789 Pine Rd"}))
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([Customer.Registered({email: "alice@example.com", address: "123 Main St"})])
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
@@ -9,9 +9,21 @@ module CustomerMapping = Mapping.Make(
9
9
  open Customer
10
10
  let project = ({event, id, _}) =>
11
11
  switch event {
12
- | Registered({email, address}) => Set(id, {Customers.email, address, deactivated: false})
13
- | EmailUpdated({email}) => Update(id, state => {...state, email})
14
- | AddressUpdated({address}) => Update(id, state => {...state, address})
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reventlessdev/online-shop-aggregates-ordering",
3
- "version": "3.0.0-alpha.301",
3
+ "version": "3.0.0-alpha.302",
4
4
  "description": "Online Shop example — Ordering plugin (Customer & Order aggregates)",
5
5
  "license": "Apache-2.0",
6
6
  "jest": {
@@ -21,13 +21,13 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "sury": "11.0.0",
24
- "@reventlessdev/online-shop-aggregates-catalog-spec": "3.0.0-alpha.187",
25
- "@reventlessdev/online-shop-aggregates-ordering-spec": "3.0.0-alpha.187",
26
- "@reventlessdev/reventless-infra": "3.0.0-alpha.217",
27
- "@reventlessdev/reventless-gwt": "1.0.0-alpha.268",
24
+ "@reventlessdev/online-shop-aggregates-ordering-spec": "3.0.0-alpha.188",
28
25
  "@reventlessdev/rescript-pulumi-pulumi": "3.0.0-alpha.0",
29
- "@reventlessdev/reventless-local": "3.0.0-alpha.311",
30
- "@reventlessdev/reventless-spec": "3.0.0-alpha.188"
26
+ "@reventlessdev/reventless-gwt": "1.0.0-alpha.269",
27
+ "@reventlessdev/online-shop-aggregates-catalog-spec": "3.0.0-alpha.188",
28
+ "@reventlessdev/reventless-infra": "3.0.0-alpha.218",
29
+ "@reventlessdev/reventless-local": "3.0.0-alpha.312",
30
+ "@reventlessdev/reventless-spec": "3.0.0-alpha.189"
31
31
  },
32
32
  "devDependencies": {
33
33
  "rescript": "12.3.1",
@@ -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
  ]);