@reventlessdev/online-shop-aggregates-catalog 3.0.0-alpha.264 → 3.0.0-alpha.265

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 (167) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/lib/bs/.compiler.log +2 -2
  3. package/lib/bs/CatalogPlugin.cmi +0 -0
  4. package/lib/bs/CatalogPlugin.cmt +0 -0
  5. package/lib/bs/CatalogPlugin.mlmap +1 -0
  6. package/lib/bs/compiler-info.json +1 -1
  7. package/lib/bs/src/Category/Aggregate/Category-CatalogPlugin.cmi +0 -0
  8. package/lib/bs/src/Category/Aggregate/Category-CatalogPlugin.cmt +0 -0
  9. package/lib/bs/src/Category/Aggregate/Category.ast +0 -0
  10. package/lib/bs/src/Category/Aggregate/Category.res +1 -1
  11. package/lib/bs/src/Category/Aggregate/Category.res.mjs +1 -1
  12. package/lib/bs/src/Category/Aggregate/Category_Behavior-CatalogPlugin.cmi +0 -0
  13. package/lib/bs/src/Category/Aggregate/Category_Behavior-CatalogPlugin.cmt +0 -0
  14. package/lib/bs/src/Category/CategoryId-CatalogPlugin.cmi +0 -0
  15. package/lib/bs/src/Category/CategoryId-CatalogPlugin.cmt +0 -0
  16. package/lib/bs/src/Category/ReadModel/Categories-CatalogPlugin.cmi +0 -0
  17. package/lib/bs/src/Category/ReadModel/Categories-CatalogPlugin.cmt +0 -0
  18. package/lib/bs/src/Category/ReadModel/Categories.ast +0 -0
  19. package/lib/bs/src/Category/ReadModel/Categories_Projections-CatalogPlugin.cmi +0 -0
  20. package/lib/bs/src/Category/ReadModel/Categories_Projections-CatalogPlugin.cmt +0 -0
  21. package/lib/bs/src/Extension/Orders_Extension-CatalogPlugin.cmi +0 -0
  22. package/lib/bs/src/Extension/Orders_Extension-CatalogPlugin.cmt +0 -0
  23. package/lib/bs/src/ExtensionPoint/Products_ExtensionPointMapping-CatalogPlugin.cmi +0 -0
  24. package/lib/bs/src/ExtensionPoint/Products_ExtensionPointMapping-CatalogPlugin.cmt +0 -0
  25. package/lib/bs/src/LifecycleModel-CatalogPlugin.cmi +0 -0
  26. package/lib/bs/src/LifecycleModel-CatalogPlugin.cmt +0 -0
  27. package/lib/bs/src/Plugin-CatalogPlugin.cmi +0 -0
  28. package/lib/bs/src/Plugin-CatalogPlugin.cmt +0 -0
  29. package/lib/bs/src/Product/Aggregate/Product-CatalogPlugin.cmi +0 -0
  30. package/lib/bs/src/Product/Aggregate/Product-CatalogPlugin.cmt +0 -0
  31. package/lib/bs/src/Product/Aggregate/Product.ast +0 -0
  32. package/lib/bs/src/Product/Aggregate/Product_Behavior-CatalogPlugin.cmi +0 -0
  33. package/lib/bs/src/Product/Aggregate/Product_Behavior-CatalogPlugin.cmt +0 -0
  34. package/lib/bs/src/Product/ReadModel/Products-CatalogPlugin.cmi +0 -0
  35. package/lib/bs/src/Product/ReadModel/Products-CatalogPlugin.cmt +0 -0
  36. package/lib/bs/src/Product/ReadModel/Products.ast +0 -0
  37. package/lib/bs/src/Product/ReadModel/Products_Projections-CatalogPlugin.cmi +0 -0
  38. package/lib/bs/src/Product/ReadModel/Products_Projections-CatalogPlugin.cmt +0 -0
  39. package/lib/bs/src/ProductDemand/Aggregate/ProductDemand-CatalogPlugin.cmi +0 -0
  40. package/lib/bs/src/ProductDemand/Aggregate/ProductDemand-CatalogPlugin.cmt +0 -0
  41. package/lib/bs/src/ProductDemand/Aggregate/ProductDemand.ast +0 -0
  42. package/lib/bs/src/ProductDemand/Aggregate/ProductDemand_Behavior-CatalogPlugin.cmi +0 -0
  43. package/lib/bs/src/ProductDemand/Aggregate/ProductDemand_Behavior-CatalogPlugin.cmt +0 -0
  44. package/lib/bs/src/ProductDemand/ReadModel/ProductDemands-CatalogPlugin.cmi +0 -0
  45. package/lib/bs/src/ProductDemand/ReadModel/ProductDemands-CatalogPlugin.cmt +0 -0
  46. package/lib/bs/src/ProductDemand/ReadModel/ProductDemands.ast +0 -0
  47. package/lib/bs/src/ProductDemand/ReadModel/ProductDemands_Projections-CatalogPlugin.cmi +0 -0
  48. package/lib/bs/src/ProductDemand/ReadModel/ProductDemands_Projections-CatalogPlugin.cmt +0 -0
  49. package/lib/bs/src/Roles-CatalogPlugin.cmi +0 -0
  50. package/lib/bs/src/Roles-CatalogPlugin.cmj +0 -0
  51. package/lib/bs/src/Roles-CatalogPlugin.cmt +0 -0
  52. package/lib/bs/src/Roles.ast +0 -0
  53. package/lib/bs/src/Roles.res +2 -0
  54. package/lib/bs/src/Roles.res.mjs +2 -0
  55. package/lib/bs/src/Task/ImportProducts-CatalogPlugin.cmi +0 -0
  56. package/lib/bs/src/Task/ImportProducts-CatalogPlugin.cmt +0 -0
  57. package/lib/bs/tests/Catalog_Examples-CatalogPlugin.cmi +0 -0
  58. package/lib/bs/tests/Catalog_Examples-CatalogPlugin.cmt +0 -0
  59. package/lib/bs/tests/Catalog_Examples.ast +0 -0
  60. package/lib/bs/tests/Catalog_Examples.res +1 -0
  61. package/lib/bs/tests/Catalog_Examples.res.mjs +3 -0
  62. package/lib/bs/tests/Category/Aggregate/Category_GWT-CatalogPlugin.cmi +0 -0
  63. package/lib/bs/tests/Category/Aggregate/Category_GWT-CatalogPlugin.cmt +0 -0
  64. package/lib/bs/tests/Category/Aggregate/Category_GWT.ast +0 -0
  65. package/lib/bs/tests/Category/Aggregate/Category_GWT.res +26 -0
  66. package/lib/bs/tests/Category/Aggregate/Category_GWT.res.mjs +25 -8
  67. package/lib/bs/tests/Category/ReadModel/Categories_GWT-CatalogPlugin.cmi +0 -0
  68. package/lib/bs/tests/Category/ReadModel/Categories_GWT-CatalogPlugin.cmt +0 -0
  69. package/lib/bs/tests/Extension/Orders_Extension_GWT-CatalogPlugin.cmi +0 -0
  70. package/lib/bs/tests/Extension/Orders_Extension_GWT-CatalogPlugin.cmt +0 -0
  71. package/lib/bs/tests/ExtensionPoint/Products_ExtensionPointMapping_GWT-CatalogPlugin.cmi +0 -0
  72. package/lib/bs/tests/ExtensionPoint/Products_ExtensionPointMapping_GWT-CatalogPlugin.cmt +0 -0
  73. package/lib/bs/tests/Product/Aggregate/Product_GWT-CatalogPlugin.cmi +0 -0
  74. package/lib/bs/tests/Product/Aggregate/Product_GWT-CatalogPlugin.cmt +0 -0
  75. package/lib/bs/tests/Product/Aggregate/Product_GWT.res.mjs +4 -2
  76. package/lib/bs/tests/Product/ReadModel/Products_GWT-CatalogPlugin.cmi +0 -0
  77. package/lib/bs/tests/Product/ReadModel/Products_GWT-CatalogPlugin.cmt +0 -0
  78. package/lib/bs/tests/ProductDemand/Aggregate/ProductDemand_GWT-CatalogPlugin.cmi +0 -0
  79. package/lib/bs/tests/ProductDemand/Aggregate/ProductDemand_GWT-CatalogPlugin.cmt +0 -0
  80. package/lib/bs/tests/ProductDemand/Aggregate/ProductDemand_GWT.res.mjs +4 -2
  81. package/lib/bs/tests/ProductDemand/ReadModel/ProductDemands_GWT-CatalogPlugin.cmi +0 -0
  82. package/lib/bs/tests/ProductDemand/ReadModel/ProductDemands_GWT-CatalogPlugin.cmt +0 -0
  83. package/lib/ocaml/.compiler.log +2 -2
  84. package/lib/ocaml/CatalogPlugin.cmi +0 -0
  85. package/lib/ocaml/CatalogPlugin.cmt +0 -0
  86. package/lib/ocaml/CatalogPlugin.mlmap +1 -0
  87. package/lib/ocaml/Catalog_Examples-CatalogPlugin.cmi +0 -0
  88. package/lib/ocaml/Catalog_Examples-CatalogPlugin.cmt +0 -0
  89. package/lib/ocaml/Catalog_Examples.ast +0 -0
  90. package/lib/ocaml/Catalog_Examples.res +1 -0
  91. package/lib/ocaml/Categories-CatalogPlugin.cmi +0 -0
  92. package/lib/ocaml/Categories-CatalogPlugin.cmt +0 -0
  93. package/lib/ocaml/Categories.ast +0 -0
  94. package/lib/ocaml/Categories_GWT-CatalogPlugin.cmi +0 -0
  95. package/lib/ocaml/Categories_GWT-CatalogPlugin.cmt +0 -0
  96. package/lib/ocaml/Categories_Projections-CatalogPlugin.cmi +0 -0
  97. package/lib/ocaml/Categories_Projections-CatalogPlugin.cmt +0 -0
  98. package/lib/ocaml/Category-CatalogPlugin.cmi +0 -0
  99. package/lib/ocaml/Category-CatalogPlugin.cmt +0 -0
  100. package/lib/ocaml/Category.ast +0 -0
  101. package/lib/ocaml/Category.res +1 -1
  102. package/lib/ocaml/CategoryId-CatalogPlugin.cmi +0 -0
  103. package/lib/ocaml/CategoryId-CatalogPlugin.cmt +0 -0
  104. package/lib/ocaml/Category_Behavior-CatalogPlugin.cmi +0 -0
  105. package/lib/ocaml/Category_Behavior-CatalogPlugin.cmt +0 -0
  106. package/lib/ocaml/Category_GWT-CatalogPlugin.cmi +0 -0
  107. package/lib/ocaml/Category_GWT-CatalogPlugin.cmt +0 -0
  108. package/lib/ocaml/Category_GWT.ast +0 -0
  109. package/lib/ocaml/Category_GWT.res +26 -0
  110. package/lib/ocaml/ImportProducts-CatalogPlugin.cmi +0 -0
  111. package/lib/ocaml/ImportProducts-CatalogPlugin.cmt +0 -0
  112. package/lib/ocaml/LifecycleModel-CatalogPlugin.cmi +0 -0
  113. package/lib/ocaml/LifecycleModel-CatalogPlugin.cmt +0 -0
  114. package/lib/ocaml/Orders_Extension-CatalogPlugin.cmi +0 -0
  115. package/lib/ocaml/Orders_Extension-CatalogPlugin.cmt +0 -0
  116. package/lib/ocaml/Orders_Extension_GWT-CatalogPlugin.cmi +0 -0
  117. package/lib/ocaml/Orders_Extension_GWT-CatalogPlugin.cmt +0 -0
  118. package/lib/ocaml/Plugin-CatalogPlugin.cmi +0 -0
  119. package/lib/ocaml/Plugin-CatalogPlugin.cmt +0 -0
  120. package/lib/ocaml/Product-CatalogPlugin.cmi +0 -0
  121. package/lib/ocaml/Product-CatalogPlugin.cmt +0 -0
  122. package/lib/ocaml/Product.ast +0 -0
  123. package/lib/ocaml/ProductDemand-CatalogPlugin.cmi +0 -0
  124. package/lib/ocaml/ProductDemand-CatalogPlugin.cmt +0 -0
  125. package/lib/ocaml/ProductDemand.ast +0 -0
  126. package/lib/ocaml/ProductDemand_Behavior-CatalogPlugin.cmi +0 -0
  127. package/lib/ocaml/ProductDemand_Behavior-CatalogPlugin.cmt +0 -0
  128. package/lib/ocaml/ProductDemand_GWT-CatalogPlugin.cmi +0 -0
  129. package/lib/ocaml/ProductDemand_GWT-CatalogPlugin.cmt +0 -0
  130. package/lib/ocaml/ProductDemands-CatalogPlugin.cmi +0 -0
  131. package/lib/ocaml/ProductDemands-CatalogPlugin.cmt +0 -0
  132. package/lib/ocaml/ProductDemands.ast +0 -0
  133. package/lib/ocaml/ProductDemands_GWT-CatalogPlugin.cmi +0 -0
  134. package/lib/ocaml/ProductDemands_GWT-CatalogPlugin.cmt +0 -0
  135. package/lib/ocaml/ProductDemands_Projections-CatalogPlugin.cmi +0 -0
  136. package/lib/ocaml/ProductDemands_Projections-CatalogPlugin.cmt +0 -0
  137. package/lib/ocaml/Product_Behavior-CatalogPlugin.cmi +0 -0
  138. package/lib/ocaml/Product_Behavior-CatalogPlugin.cmt +0 -0
  139. package/lib/ocaml/Product_GWT-CatalogPlugin.cmi +0 -0
  140. package/lib/ocaml/Product_GWT-CatalogPlugin.cmt +0 -0
  141. package/lib/ocaml/Products-CatalogPlugin.cmi +0 -0
  142. package/lib/ocaml/Products-CatalogPlugin.cmt +0 -0
  143. package/lib/ocaml/Products.ast +0 -0
  144. package/lib/ocaml/Products_ExtensionPointMapping-CatalogPlugin.cmi +0 -0
  145. package/lib/ocaml/Products_ExtensionPointMapping-CatalogPlugin.cmt +0 -0
  146. package/lib/ocaml/Products_ExtensionPointMapping_GWT-CatalogPlugin.cmi +0 -0
  147. package/lib/ocaml/Products_ExtensionPointMapping_GWT-CatalogPlugin.cmt +0 -0
  148. package/lib/ocaml/Products_GWT-CatalogPlugin.cmi +0 -0
  149. package/lib/ocaml/Products_GWT-CatalogPlugin.cmt +0 -0
  150. package/lib/ocaml/Products_Projections-CatalogPlugin.cmi +0 -0
  151. package/lib/ocaml/Products_Projections-CatalogPlugin.cmt +0 -0
  152. package/lib/ocaml/Roles-CatalogPlugin.cmi +0 -0
  153. package/lib/ocaml/Roles-CatalogPlugin.cmj +0 -0
  154. package/lib/ocaml/Roles-CatalogPlugin.cmt +0 -0
  155. package/lib/ocaml/Roles.ast +0 -0
  156. package/lib/ocaml/Roles.res +2 -0
  157. package/package.json +8 -8
  158. package/src/Category/Aggregate/Category.res +1 -1
  159. package/src/Category/Aggregate/Category.res.mjs +1 -1
  160. package/src/Roles.res +2 -0
  161. package/src/Roles.res.mjs +2 -0
  162. package/tests/Catalog_Examples.res +1 -0
  163. package/tests/Catalog_Examples.res.mjs +3 -0
  164. package/tests/Category/Aggregate/Category_GWT.res +26 -0
  165. package/tests/Category/Aggregate/Category_GWT.res.mjs +25 -8
  166. package/tests/Product/Aggregate/Product_GWT.res.mjs +4 -2
  167. package/tests/ProductDemand/Aggregate/ProductDemand_GWT.res.mjs +4 -2
package/CHANGELOG.md CHANGED
@@ -3,6 +3,21 @@
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.265 (2026-10-01)
7
+
8
+ * feat!: roles a plugin declares, groups a platform provides ([43daace](https://github.com/ReventlessDev/reventless-core/commit/43daace6ca588afe22562d079af1e6f1da81942e))
9
+
10
+ ### BREAKING CHANGES
11
+
12
+ * AllowGroups and AdminGroup are removed — write AllowRoles over
13
+ the plugin's Roles.t, and use Role.admin / Platform.adminGroup(). Spec module
14
+ types declare `type role`, and their rules are Authorization.rule<role>; a spec
15
+ that writes its own rule declares `type role` (Reventless.Role.name for a rule
16
+ over Authorization.permission). Role.name is a private string: make one from a
17
+ string with Role.make.
18
+
19
+
20
+
6
21
  # 3.0.0-alpha.264 (2026-10-01)
7
22
 
8
23
  **Note:** Version bump only for package @reventlessdev/online-shop-aggregates-catalog
@@ -1,2 +1,2 @@
1
- #Start(1790818270914)
2
- #Done(1790818277109)
1
+ #Start(1790854925300)
2
+ #Done(1790854931571)
Binary file
Binary file
@@ -26,3 +26,4 @@ Products_ExtensionPointMapping
26
26
  Products_ExtensionPointMapping_GWT
27
27
  Products_GWT
28
28
  Products_Projections
29
+ Roles
@@ -4,5 +4,5 @@
4
4
  "bsc_hash": "1006241435e8d5052329c523202a7fe6359a37e1e1688c023d37d6a7ebb5fb6d",
5
5
  "rescript_config_hash": "50d5358a2cbe328e82ae9b442e4615b86dbfe6b2ce05e9eca04a0c78da0e4708",
6
6
  "runtime_path": "/home/runner/work/reventless-core/reventless-core/node_modules/@rescript/runtime",
7
- "generated_at": "1790818277124"
7
+ "generated_at": "1790854931587"
8
8
  }
@@ -9,7 +9,7 @@ module Id = CategoryId
9
9
  type command =
10
10
  | Add({name: string})
11
11
  | Rename({name: string})
12
- | @authorize(AllowGroups(["Admin"])) Archive
12
+ | @authorize(AllowRoles([Admin])) Archive
13
13
 
14
14
  @schema
15
15
  type event =
@@ -35,7 +35,7 @@ let errorSchema = Sury.union([
35
35
  function commandAuthorization(command) {
36
36
  if (typeof command !== "object") {
37
37
  return {
38
- TAG: "AllowGroups",
38
+ TAG: "AllowRoles",
39
39
  _0: ["Admin"]
40
40
  };
41
41
  } else {
Binary file
Binary file
Binary file
@@ -0,0 +1,2 @@
1
+ // The roles the catalog's commands require: the framework's administrator.
2
+ type t = Admin
@@ -0,0 +1,2 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+ /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
Binary file
@@ -7,3 +7,4 @@ let laptopImage: string = "/productImages/laptop.jpg"
7
7
  let order1: string = "order-1"
8
8
  let order2: string = "order-2"
9
9
  let renamedTo: string = "New Name"
10
+ let shopper: string = "shopper"
@@ -15,6 +15,8 @@ let order2 = "order-2";
15
15
 
16
16
  let renamedTo = "New Name";
17
17
 
18
+ let shopper = "shopper";
19
+
18
20
  export {
19
21
  electronics,
20
22
  laptop,
@@ -23,5 +25,6 @@ export {
23
25
  order1,
24
26
  order2,
25
27
  renamedTo,
28
+ shopper,
26
29
  }
27
30
  /* No side effect */
@@ -59,3 +59,29 @@ describe("Category Behavior", () => {
59
59
  ->thenNoEvent
60
60
  )
61
61
  })
62
+
63
+ describe("Who may Archive", () => {
64
+ // scenario-id: 5164cae5-bd41-4802-aa03-3d42b3e2fb9f
65
+ test("an Admin may archive a category", () =>
66
+ givenEvents([Added({name: electronics})])
67
+ ->asCaller(Caller.inRoles([Admin]))
68
+ ->whenCmd(Archive)
69
+ ->thenEvent(Archived)
70
+ )
71
+
72
+ // scenario-id: 92a627eb-e78c-48ed-88f4-5065dc505885
73
+ test("a shopper may not archive a category", () =>
74
+ givenEvents([Added({name: electronics})])
75
+ ->asCaller(Caller.owner(shopper))
76
+ ->whenCmd(Archive)
77
+ ->thenRefused
78
+ )
79
+
80
+ // scenario-id: c4c8e733-7e07-4f3c-b3f2-01bc6b52f601
81
+ test("an anonymous caller may not archive a category", () =>
82
+ givenEvents([Added({name: electronics})])
83
+ ->asCaller(Caller.anonymous)
84
+ ->whenCmd(Archive)
85
+ ->thenRefused
86
+ )
87
+ })
@@ -9,13 +9,15 @@ let include = Behavior_GWT$ReventlessGwt.MakeFromAggregate({
9
9
  name: Category$CatalogPlugin.name,
10
10
  commandSchema: Category$CatalogPlugin.commandSchema,
11
11
  eventSchema: Category$CatalogPlugin.eventSchema,
12
- errorSchema: Category$CatalogPlugin.errorSchema
12
+ errorSchema: Category$CatalogPlugin.errorSchema,
13
+ commandAuthorization: Category$CatalogPlugin.commandAuthorization
13
14
  })({
14
15
  Spec: {
15
16
  name: Category$CatalogPlugin.name,
16
17
  commandSchema: Category$CatalogPlugin.commandSchema,
17
18
  eventSchema: Category$CatalogPlugin.eventSchema,
18
- errorSchema: Category$CatalogPlugin.errorSchema
19
+ errorSchema: Category$CatalogPlugin.errorSchema,
20
+ commandAuthorization: Category$CatalogPlugin.commandAuthorization
19
21
  },
20
22
  initialState: Category_Behavior$CatalogPlugin.initialState,
21
23
  evolve: Category_Behavior$CatalogPlugin.evolve,
@@ -30,6 +32,10 @@ let test = include.test;
30
32
 
31
33
  let givenEvents = include.givenEvents;
32
34
 
35
+ let Caller = include.Caller;
36
+
37
+ let asCaller = include.asCaller;
38
+
33
39
  let whenCmd = include.whenCmd;
34
40
 
35
41
  let thenEvent = include.thenEvent;
@@ -38,6 +44,8 @@ let thenNoEvent = include.thenNoEvent;
38
44
 
39
45
  let thenError = include.thenError;
40
46
 
47
+ let thenRefused = include.thenRefused;
48
+
41
49
  describe("Category Behavior", () => {
42
50
  test("Add on new aggregate produces Added", () => thenEvent(whenCmd(givenEvents([]), {
43
51
  TAG: "Add",
@@ -97,11 +105,22 @@ describe("Category Behavior", () => {
97
105
  ]), "Archive")));
98
106
  });
99
107
 
100
- let Spec = include.Spec;
101
-
102
- let Caller = include.Caller;
108
+ describe("Who may Archive", () => {
109
+ test("an Admin may archive a category", () => thenEvent(whenCmd(asCaller(givenEvents([{
110
+ TAG: "Added",
111
+ name: Catalog_Examples$CatalogPlugin.electronics
112
+ }]), Caller.inRoles(["Admin"])), "Archive"), "Archived"));
113
+ test("a shopper may not archive a category", () => thenRefused(whenCmd(asCaller(givenEvents([{
114
+ TAG: "Added",
115
+ name: Catalog_Examples$CatalogPlugin.electronics
116
+ }]), Caller.owner(Catalog_Examples$CatalogPlugin.shopper, undefined)), "Archive")));
117
+ test("an anonymous caller may not archive a category", () => thenRefused(whenCmd(asCaller(givenEvents([{
118
+ TAG: "Added",
119
+ name: Catalog_Examples$CatalogPlugin.electronics
120
+ }]), Caller.anonymous), "Archive")));
121
+ });
103
122
 
104
- let asCaller = include.asCaller;
123
+ let Spec = include.Spec;
105
124
 
106
125
  let thenCompareEvent = include.thenCompareEvent;
107
126
 
@@ -113,8 +132,6 @@ let thenCompareEvents = include.thenCompareEvents;
113
132
 
114
133
  let thenEventsWithError = include.thenEventsWithError;
115
134
 
116
- let thenRefused = include.thenRefused;
117
-
118
135
  export {
119
136
  Spec,
120
137
  describe,
@@ -9,13 +9,15 @@ let include = Behavior_GWT$ReventlessGwt.MakeFromAggregate({
9
9
  name: Product$CatalogPlugin.name,
10
10
  commandSchema: Product$CatalogPlugin.commandSchema,
11
11
  eventSchema: Product$CatalogPlugin.eventSchema,
12
- errorSchema: Product$CatalogPlugin.errorSchema
12
+ errorSchema: Product$CatalogPlugin.errorSchema,
13
+ commandAuthorization: Product$CatalogPlugin.commandAuthorization
13
14
  })({
14
15
  Spec: {
15
16
  name: Product$CatalogPlugin.name,
16
17
  commandSchema: Product$CatalogPlugin.commandSchema,
17
18
  eventSchema: Product$CatalogPlugin.eventSchema,
18
- errorSchema: Product$CatalogPlugin.errorSchema
19
+ errorSchema: Product$CatalogPlugin.errorSchema,
20
+ commandAuthorization: Product$CatalogPlugin.commandAuthorization
19
21
  },
20
22
  initialState: Product_Behavior$CatalogPlugin.initialState,
21
23
  evolve: Product_Behavior$CatalogPlugin.evolve,
@@ -9,13 +9,15 @@ let include = Behavior_GWT$ReventlessGwt.MakeFromAggregate({
9
9
  name: ProductDemand$CatalogPlugin.name,
10
10
  commandSchema: ProductDemand$CatalogPlugin.commandSchema,
11
11
  eventSchema: ProductDemand$CatalogPlugin.eventSchema,
12
- errorSchema: ProductDemand$CatalogPlugin.errorSchema
12
+ errorSchema: ProductDemand$CatalogPlugin.errorSchema,
13
+ commandAuthorization: ProductDemand$CatalogPlugin.commandAuthorization
13
14
  })({
14
15
  Spec: {
15
16
  name: ProductDemand$CatalogPlugin.name,
16
17
  commandSchema: ProductDemand$CatalogPlugin.commandSchema,
17
18
  eventSchema: ProductDemand$CatalogPlugin.eventSchema,
18
- errorSchema: ProductDemand$CatalogPlugin.errorSchema
19
+ errorSchema: ProductDemand$CatalogPlugin.errorSchema,
20
+ commandAuthorization: ProductDemand$CatalogPlugin.commandAuthorization
19
21
  },
20
22
  initialState: ProductDemand_Behavior$CatalogPlugin.initialState,
21
23
  evolve: ProductDemand_Behavior$CatalogPlugin.evolve,
@@ -1,2 +1,2 @@
1
- #Start(1790818270914)
2
- #Done(1790818277109)
1
+ #Start(1790854925300)
2
+ #Done(1790854931571)
Binary file
Binary file
@@ -26,3 +26,4 @@ Products_ExtensionPointMapping
26
26
  Products_ExtensionPointMapping_GWT
27
27
  Products_GWT
28
28
  Products_Projections
29
+ Roles
Binary file
@@ -7,3 +7,4 @@ let laptopImage: string = "/productImages/laptop.jpg"
7
7
  let order1: string = "order-1"
8
8
  let order2: string = "order-2"
9
9
  let renamedTo: string = "New Name"
10
+ let shopper: string = "shopper"
Binary file
Binary file
@@ -9,7 +9,7 @@ module Id = CategoryId
9
9
  type command =
10
10
  | Add({name: string})
11
11
  | Rename({name: string})
12
- | @authorize(AllowGroups(["Admin"])) Archive
12
+ | @authorize(AllowRoles([Admin])) Archive
13
13
 
14
14
  @schema
15
15
  type event =
Binary file
@@ -59,3 +59,29 @@ describe("Category Behavior", () => {
59
59
  ->thenNoEvent
60
60
  )
61
61
  })
62
+
63
+ describe("Who may Archive", () => {
64
+ // scenario-id: 5164cae5-bd41-4802-aa03-3d42b3e2fb9f
65
+ test("an Admin may archive a category", () =>
66
+ givenEvents([Added({name: electronics})])
67
+ ->asCaller(Caller.inRoles([Admin]))
68
+ ->whenCmd(Archive)
69
+ ->thenEvent(Archived)
70
+ )
71
+
72
+ // scenario-id: 92a627eb-e78c-48ed-88f4-5065dc505885
73
+ test("a shopper may not archive a category", () =>
74
+ givenEvents([Added({name: electronics})])
75
+ ->asCaller(Caller.owner(shopper))
76
+ ->whenCmd(Archive)
77
+ ->thenRefused
78
+ )
79
+
80
+ // scenario-id: c4c8e733-7e07-4f3c-b3f2-01bc6b52f601
81
+ test("an anonymous caller may not archive a category", () =>
82
+ givenEvents([Added({name: electronics})])
83
+ ->asCaller(Caller.anonymous)
84
+ ->whenCmd(Archive)
85
+ ->thenRefused
86
+ )
87
+ })
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,2 @@
1
+ // The roles the catalog's commands require: the framework's administrator.
2
+ type t = Admin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reventlessdev/online-shop-aggregates-catalog",
3
- "version": "3.0.0-alpha.264",
3
+ "version": "3.0.0-alpha.265",
4
4
  "description": "Online Shop example — Catalog plugin (Product & Category aggregates)",
5
5
  "license": "Apache-2.0",
6
6
  "jest": {
@@ -21,18 +21,18 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "sury": "11.0.0",
24
- "@reventlessdev/online-shop-aggregates-catalog-spec": "3.0.0-alpha.154",
24
+ "@reventlessdev/online-shop-aggregates-catalog-spec": "3.0.0-alpha.155",
25
+ "@reventlessdev/online-shop-aggregates-ordering-spec": "3.0.0-alpha.155",
26
+ "@reventlessdev/reventless-gwt": "1.0.0-alpha.233",
27
+ "@reventlessdev/reventless-infra": "3.0.0-alpha.184",
25
28
  "@reventlessdev/rescript-pulumi-pulumi": "2.3.0-alpha.22",
26
- "@reventlessdev/reventless-gwt": "1.0.0-alpha.232",
27
- "@reventlessdev/reventless-infra": "3.0.0-alpha.183",
28
- "@reventlessdev/online-shop-aggregates-ordering-spec": "3.0.0-alpha.154",
29
- "@reventlessdev/reventless-spec": "3.0.0-alpha.155",
30
- "@reventlessdev/reventless-local": "3.0.0-alpha.275"
29
+ "@reventlessdev/reventless-local": "3.0.0-alpha.276",
30
+ "@reventlessdev/reventless-spec": "3.0.0-alpha.156"
31
31
  },
32
32
  "devDependencies": {
33
33
  "rescript": "12.3.1",
34
34
  "sury-ppx": "11.0.0",
35
- "@reventlessdev/reventless-ppx": "1.0.0-alpha.95"
35
+ "@reventlessdev/reventless-ppx": "1.0.0-alpha.96"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "rescript": "^12.3.1"
@@ -9,7 +9,7 @@ module Id = CategoryId
9
9
  type command =
10
10
  | Add({name: string})
11
11
  | Rename({name: string})
12
- | @authorize(AllowGroups(["Admin"])) Archive
12
+ | @authorize(AllowRoles([Admin])) Archive
13
13
 
14
14
  @schema
15
15
  type event =
@@ -35,7 +35,7 @@ let errorSchema = Sury.union([
35
35
  function commandAuthorization(command) {
36
36
  if (typeof command !== "object") {
37
37
  return {
38
- TAG: "AllowGroups",
38
+ TAG: "AllowRoles",
39
39
  _0: ["Admin"]
40
40
  };
41
41
  } else {
package/src/Roles.res ADDED
@@ -0,0 +1,2 @@
1
+ // The roles the catalog's commands require: the framework's administrator.
2
+ type t = Admin
@@ -0,0 +1,2 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+ /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
@@ -7,3 +7,4 @@ let laptopImage: string = "/productImages/laptop.jpg"
7
7
  let order1: string = "order-1"
8
8
  let order2: string = "order-2"
9
9
  let renamedTo: string = "New Name"
10
+ let shopper: string = "shopper"
@@ -15,6 +15,8 @@ let order2 = "order-2";
15
15
 
16
16
  let renamedTo = "New Name";
17
17
 
18
+ let shopper = "shopper";
19
+
18
20
  export {
19
21
  electronics,
20
22
  laptop,
@@ -23,5 +25,6 @@ export {
23
25
  order1,
24
26
  order2,
25
27
  renamedTo,
28
+ shopper,
26
29
  }
27
30
  /* No side effect */
@@ -59,3 +59,29 @@ describe("Category Behavior", () => {
59
59
  ->thenNoEvent
60
60
  )
61
61
  })
62
+
63
+ describe("Who may Archive", () => {
64
+ // scenario-id: 5164cae5-bd41-4802-aa03-3d42b3e2fb9f
65
+ test("an Admin may archive a category", () =>
66
+ givenEvents([Added({name: electronics})])
67
+ ->asCaller(Caller.inRoles([Admin]))
68
+ ->whenCmd(Archive)
69
+ ->thenEvent(Archived)
70
+ )
71
+
72
+ // scenario-id: 92a627eb-e78c-48ed-88f4-5065dc505885
73
+ test("a shopper may not archive a category", () =>
74
+ givenEvents([Added({name: electronics})])
75
+ ->asCaller(Caller.owner(shopper))
76
+ ->whenCmd(Archive)
77
+ ->thenRefused
78
+ )
79
+
80
+ // scenario-id: c4c8e733-7e07-4f3c-b3f2-01bc6b52f601
81
+ test("an anonymous caller may not archive a category", () =>
82
+ givenEvents([Added({name: electronics})])
83
+ ->asCaller(Caller.anonymous)
84
+ ->whenCmd(Archive)
85
+ ->thenRefused
86
+ )
87
+ })
@@ -9,13 +9,15 @@ let include = Behavior_GWT$ReventlessGwt.MakeFromAggregate({
9
9
  name: Category$CatalogPlugin.name,
10
10
  commandSchema: Category$CatalogPlugin.commandSchema,
11
11
  eventSchema: Category$CatalogPlugin.eventSchema,
12
- errorSchema: Category$CatalogPlugin.errorSchema
12
+ errorSchema: Category$CatalogPlugin.errorSchema,
13
+ commandAuthorization: Category$CatalogPlugin.commandAuthorization
13
14
  })({
14
15
  Spec: {
15
16
  name: Category$CatalogPlugin.name,
16
17
  commandSchema: Category$CatalogPlugin.commandSchema,
17
18
  eventSchema: Category$CatalogPlugin.eventSchema,
18
- errorSchema: Category$CatalogPlugin.errorSchema
19
+ errorSchema: Category$CatalogPlugin.errorSchema,
20
+ commandAuthorization: Category$CatalogPlugin.commandAuthorization
19
21
  },
20
22
  initialState: Category_Behavior$CatalogPlugin.initialState,
21
23
  evolve: Category_Behavior$CatalogPlugin.evolve,
@@ -30,6 +32,10 @@ let test = include.test;
30
32
 
31
33
  let givenEvents = include.givenEvents;
32
34
 
35
+ let Caller = include.Caller;
36
+
37
+ let asCaller = include.asCaller;
38
+
33
39
  let whenCmd = include.whenCmd;
34
40
 
35
41
  let thenEvent = include.thenEvent;
@@ -38,6 +44,8 @@ let thenNoEvent = include.thenNoEvent;
38
44
 
39
45
  let thenError = include.thenError;
40
46
 
47
+ let thenRefused = include.thenRefused;
48
+
41
49
  describe("Category Behavior", () => {
42
50
  test("Add on new aggregate produces Added", () => thenEvent(whenCmd(givenEvents([]), {
43
51
  TAG: "Add",
@@ -97,11 +105,22 @@ describe("Category Behavior", () => {
97
105
  ]), "Archive")));
98
106
  });
99
107
 
100
- let Spec = include.Spec;
101
-
102
- let Caller = include.Caller;
108
+ describe("Who may Archive", () => {
109
+ test("an Admin may archive a category", () => thenEvent(whenCmd(asCaller(givenEvents([{
110
+ TAG: "Added",
111
+ name: Catalog_Examples$CatalogPlugin.electronics
112
+ }]), Caller.inRoles(["Admin"])), "Archive"), "Archived"));
113
+ test("a shopper may not archive a category", () => thenRefused(whenCmd(asCaller(givenEvents([{
114
+ TAG: "Added",
115
+ name: Catalog_Examples$CatalogPlugin.electronics
116
+ }]), Caller.owner(Catalog_Examples$CatalogPlugin.shopper, undefined)), "Archive")));
117
+ test("an anonymous caller may not archive a category", () => thenRefused(whenCmd(asCaller(givenEvents([{
118
+ TAG: "Added",
119
+ name: Catalog_Examples$CatalogPlugin.electronics
120
+ }]), Caller.anonymous), "Archive")));
121
+ });
103
122
 
104
- let asCaller = include.asCaller;
123
+ let Spec = include.Spec;
105
124
 
106
125
  let thenCompareEvent = include.thenCompareEvent;
107
126
 
@@ -113,8 +132,6 @@ let thenCompareEvents = include.thenCompareEvents;
113
132
 
114
133
  let thenEventsWithError = include.thenEventsWithError;
115
134
 
116
- let thenRefused = include.thenRefused;
117
-
118
135
  export {
119
136
  Spec,
120
137
  describe,
@@ -9,13 +9,15 @@ let include = Behavior_GWT$ReventlessGwt.MakeFromAggregate({
9
9
  name: Product$CatalogPlugin.name,
10
10
  commandSchema: Product$CatalogPlugin.commandSchema,
11
11
  eventSchema: Product$CatalogPlugin.eventSchema,
12
- errorSchema: Product$CatalogPlugin.errorSchema
12
+ errorSchema: Product$CatalogPlugin.errorSchema,
13
+ commandAuthorization: Product$CatalogPlugin.commandAuthorization
13
14
  })({
14
15
  Spec: {
15
16
  name: Product$CatalogPlugin.name,
16
17
  commandSchema: Product$CatalogPlugin.commandSchema,
17
18
  eventSchema: Product$CatalogPlugin.eventSchema,
18
- errorSchema: Product$CatalogPlugin.errorSchema
19
+ errorSchema: Product$CatalogPlugin.errorSchema,
20
+ commandAuthorization: Product$CatalogPlugin.commandAuthorization
19
21
  },
20
22
  initialState: Product_Behavior$CatalogPlugin.initialState,
21
23
  evolve: Product_Behavior$CatalogPlugin.evolve,
@@ -9,13 +9,15 @@ let include = Behavior_GWT$ReventlessGwt.MakeFromAggregate({
9
9
  name: ProductDemand$CatalogPlugin.name,
10
10
  commandSchema: ProductDemand$CatalogPlugin.commandSchema,
11
11
  eventSchema: ProductDemand$CatalogPlugin.eventSchema,
12
- errorSchema: ProductDemand$CatalogPlugin.errorSchema
12
+ errorSchema: ProductDemand$CatalogPlugin.errorSchema,
13
+ commandAuthorization: ProductDemand$CatalogPlugin.commandAuthorization
13
14
  })({
14
15
  Spec: {
15
16
  name: ProductDemand$CatalogPlugin.name,
16
17
  commandSchema: ProductDemand$CatalogPlugin.commandSchema,
17
18
  eventSchema: ProductDemand$CatalogPlugin.eventSchema,
18
- errorSchema: ProductDemand$CatalogPlugin.errorSchema
19
+ errorSchema: ProductDemand$CatalogPlugin.errorSchema,
20
+ commandAuthorization: ProductDemand$CatalogPlugin.commandAuthorization
19
21
  },
20
22
  initialState: ProductDemand_Behavior$CatalogPlugin.initialState,
21
23
  evolve: ProductDemand_Behavior$CatalogPlugin.evolve,