@reventlessdev/online-shop-hybrid-ordering 1.0.0-alpha.263 → 1.0.0-alpha.264
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/package.json +10 -10
- package/src/Customer/ReadModelStream/Customers.res +1 -1
- package/src/Customer/ReadModelStream/Customers.res.mjs +1 -1
- package/src/Order/StateChange/ShipOrder.res +1 -1
- package/src/Order/StateChange/ShipOrder.res.mjs +1 -1
- package/src/Roles.res +5 -0
- package/src/Roles.res.mjs +2 -0
- package/tests/CatalogProduct/StateChange/SyncCatalogProduct_GWT.res.mjs +2 -1
- package/tests/Customer/AddressGeocodingConformance_GWT.res.mjs +4 -2
- package/tests/Customer/Aggregate/Customer_GWT.res.mjs +4 -2
- package/tests/Customer/StateChange/EmailVerificationChallenges_GWT.res.mjs +2 -1
- package/tests/Flow/OrderingFlow_GWT.res.mjs +6 -3
- package/tests/Notification/NotificationConformance_GWT.res.mjs +4 -2
- package/tests/Notification/StateChange/NotificationPreferences_GWT.res.mjs +2 -1
- package/tests/Notification/StateChange/NotificationSourceClaims_GWT.res.mjs +2 -1
- package/tests/Order/StateChange/CancelOrder_GWT.res.mjs +4 -3
- package/tests/Order/StateChange/PlaceOrder_GWT.res.mjs +2 -1
- package/tests/Order/StateChange/ShipOrder_GWT.res +34 -0
- package/tests/Order/StateChange/ShipOrder_GWT.res.mjs +51 -7
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
|
+
# 1.0.0-alpha.264 (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
|
# 1.0.0-alpha.263 (2026-10-01)
|
|
7
22
|
|
|
8
23
|
### Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reventlessdev/online-shop-hybrid-ordering",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.264",
|
|
4
4
|
"description": "Online Shop Hybrid example — Ordering plugin (Customer aggregate + Order/CatalogProduct DCB)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"jest": {
|
|
@@ -21,20 +21,20 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"sury": "11.0.0",
|
|
24
|
-
"@reventlessdev/online-shop-hybrid-catalog-spec": "1.0.0-alpha.
|
|
25
|
-
"@reventlessdev/reventless-gwt": "1.0.0-alpha.232",
|
|
24
|
+
"@reventlessdev/online-shop-hybrid-catalog-spec": "1.0.0-alpha.153",
|
|
26
25
|
"@reventlessdev/rescript-pulumi-pulumi": "2.3.0-alpha.22",
|
|
27
|
-
"@reventlessdev/online-shop-hybrid-ordering-spec": "1.0.0-alpha.
|
|
28
|
-
"@reventlessdev/reventless-
|
|
29
|
-
"@reventlessdev/reventless-
|
|
30
|
-
"@reventlessdev/reventless-
|
|
31
|
-
"@reventlessdev/
|
|
32
|
-
"@reventlessdev/trait-
|
|
26
|
+
"@reventlessdev/online-shop-hybrid-ordering-spec": "1.0.0-alpha.152",
|
|
27
|
+
"@reventlessdev/reventless-gwt": "1.0.0-alpha.233",
|
|
28
|
+
"@reventlessdev/reventless-infra": "3.0.0-alpha.184",
|
|
29
|
+
"@reventlessdev/reventless-local": "3.0.0-alpha.276",
|
|
30
|
+
"@reventlessdev/reventless-spec": "3.0.0-alpha.156",
|
|
31
|
+
"@reventlessdev/trait-address-geocoding": "1.0.0-alpha.35",
|
|
32
|
+
"@reventlessdev/trait-notification": "1.0.0-alpha.35"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"rescript": "12.3.1",
|
|
36
36
|
"sury-ppx": "11.0.0",
|
|
37
|
-
"@reventlessdev/reventless-ppx": "1.0.0-alpha.
|
|
37
|
+
"@reventlessdev/reventless-ppx": "1.0.0-alpha.96"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"rescript": "^12.3.1"
|
|
@@ -7,7 +7,7 @@ module Id = CustomerId
|
|
|
7
7
|
|
|
8
8
|
// Operator surface: everyone's profile, so operator-only. A shopper reads their
|
|
9
9
|
// own orders instead.
|
|
10
|
-
@@reventless.authorize(
|
|
10
|
+
@@reventless.authorize(AllowRoles([Admin, Fulfilment]))
|
|
11
11
|
|
|
12
12
|
// A state rather than a flag beside one, so a command can say where it belongs:
|
|
13
13
|
// `Moves([Deactivated], Active)` on `Reactivate`. `@retired` withdraws
|
|
@@ -29,7 +29,7 @@ type consumedEvent =
|
|
|
29
29
|
| OrderReopened
|
|
30
30
|
|
|
31
31
|
@schema
|
|
32
|
-
type command = | @authorize(
|
|
32
|
+
type command = | @authorize(AllowRoles([Admin, Fulfilment])) ShipOrder({orderId: OrderId.t})
|
|
33
33
|
|
|
34
34
|
@schema
|
|
35
35
|
type error =
|
package/src/Roles.res
ADDED
|
@@ -10,7 +10,8 @@ let include = Behavior_GWT$ReventlessGwt.Make({
|
|
|
10
10
|
consumedEventSchema: SyncCatalogProduct$OrderingPlugin.consumedEventSchema,
|
|
11
11
|
commandSchema: SyncCatalogProduct$OrderingPlugin.commandSchema,
|
|
12
12
|
errorSchema: SyncCatalogProduct$OrderingPlugin.errorSchema,
|
|
13
|
-
eventSchema: SyncCatalogProduct$OrderingPlugin.eventSchema
|
|
13
|
+
eventSchema: SyncCatalogProduct$OrderingPlugin.eventSchema,
|
|
14
|
+
commandAuthorization: SyncCatalogProduct$OrderingPlugin.commandAuthorization
|
|
14
15
|
})({
|
|
15
16
|
initialState: SyncCatalogProduct_Behavior$OrderingPlugin.initialState,
|
|
16
17
|
evolve: SyncCatalogProduct_Behavior$OrderingPlugin.evolve,
|
|
@@ -147,14 +147,16 @@ let Conformance = AddressGeocoding_Conformance$TraitAddressGeocoding.Make({
|
|
|
147
147
|
name: Customer$OrderingPlugin.name,
|
|
148
148
|
commandSchema: Customer$OrderingPlugin.commandSchema,
|
|
149
149
|
eventSchema: Customer$OrderingPlugin.eventSchema,
|
|
150
|
-
errorSchema: Customer$OrderingPlugin.errorSchema
|
|
150
|
+
errorSchema: Customer$OrderingPlugin.errorSchema,
|
|
151
|
+
commandAuthorization: Customer$OrderingPlugin.commandAuthorization
|
|
151
152
|
},
|
|
152
153
|
Behavior: {
|
|
153
154
|
Spec: {
|
|
154
155
|
name: Customer$OrderingPlugin.name,
|
|
155
156
|
commandSchema: Customer$OrderingPlugin.commandSchema,
|
|
156
157
|
eventSchema: Customer$OrderingPlugin.eventSchema,
|
|
157
|
-
errorSchema: Customer$OrderingPlugin.errorSchema
|
|
158
|
+
errorSchema: Customer$OrderingPlugin.errorSchema,
|
|
159
|
+
commandAuthorization: Customer$OrderingPlugin.commandAuthorization
|
|
158
160
|
},
|
|
159
161
|
initialState: Customer_Behavior$OrderingPlugin.initialState,
|
|
160
162
|
evolve: Customer_Behavior$OrderingPlugin.evolve,
|
|
@@ -9,13 +9,15 @@ let include = Behavior_GWT$ReventlessGwt.MakeFromAggregate({
|
|
|
9
9
|
name: Customer$OrderingPlugin.name,
|
|
10
10
|
commandSchema: Customer$OrderingPlugin.commandSchema,
|
|
11
11
|
eventSchema: Customer$OrderingPlugin.eventSchema,
|
|
12
|
-
errorSchema: Customer$OrderingPlugin.errorSchema
|
|
12
|
+
errorSchema: Customer$OrderingPlugin.errorSchema,
|
|
13
|
+
commandAuthorization: Customer$OrderingPlugin.commandAuthorization
|
|
13
14
|
})({
|
|
14
15
|
Spec: {
|
|
15
16
|
name: Customer$OrderingPlugin.name,
|
|
16
17
|
commandSchema: Customer$OrderingPlugin.commandSchema,
|
|
17
18
|
eventSchema: Customer$OrderingPlugin.eventSchema,
|
|
18
|
-
errorSchema: Customer$OrderingPlugin.errorSchema
|
|
19
|
+
errorSchema: Customer$OrderingPlugin.errorSchema,
|
|
20
|
+
commandAuthorization: Customer$OrderingPlugin.commandAuthorization
|
|
19
21
|
},
|
|
20
22
|
initialState: Customer_Behavior$OrderingPlugin.initialState,
|
|
21
23
|
evolve: Customer_Behavior$OrderingPlugin.evolve,
|
|
@@ -10,7 +10,8 @@ let include = Behavior_GWT$ReventlessGwt.Make({
|
|
|
10
10
|
consumedEventSchema: EmailVerificationChallenges$OrderingPlugin.consumedEventSchema,
|
|
11
11
|
commandSchema: EmailVerificationChallenges$OrderingPlugin.commandSchema,
|
|
12
12
|
errorSchema: EmailVerificationChallenges$OrderingPlugin.errorSchema,
|
|
13
|
-
eventSchema: EmailVerificationChallenges$OrderingPlugin.eventSchema
|
|
13
|
+
eventSchema: EmailVerificationChallenges$OrderingPlugin.eventSchema,
|
|
14
|
+
commandAuthorization: EmailVerificationChallenges$OrderingPlugin.commandAuthorization
|
|
14
15
|
})({
|
|
15
16
|
initialState: EmailVerificationChallenges_Behavior$OrderingPlugin.initialState,
|
|
16
17
|
evolve: EmailVerificationChallenges_Behavior$OrderingPlugin.evolve,
|
|
@@ -95,7 +95,8 @@ let Sync = Flow_GWT$ReventlessGwt.CommandStep({
|
|
|
95
95
|
consumedEventSchema: SyncCatalogProduct$OrderingPlugin.consumedEventSchema,
|
|
96
96
|
commandSchema: SyncCatalogProduct$OrderingPlugin.commandSchema,
|
|
97
97
|
errorSchema: SyncCatalogProduct$OrderingPlugin.errorSchema,
|
|
98
|
-
eventSchema: SyncCatalogProduct$OrderingPlugin.eventSchema
|
|
98
|
+
eventSchema: SyncCatalogProduct$OrderingPlugin.eventSchema,
|
|
99
|
+
commandAuthorization: SyncCatalogProduct$OrderingPlugin.commandAuthorization
|
|
99
100
|
})({
|
|
100
101
|
initialState: SyncCatalogProduct_Behavior$OrderingPlugin.initialState,
|
|
101
102
|
evolve: SyncCatalogProduct_Behavior$OrderingPlugin.evolve,
|
|
@@ -107,7 +108,8 @@ let Place = Flow_GWT$ReventlessGwt.CommandStep({
|
|
|
107
108
|
consumedEventSchema: PlaceOrder$OrderingPlugin.consumedEventSchema,
|
|
108
109
|
commandSchema: PlaceOrder$OrderingPlugin.commandSchema,
|
|
109
110
|
errorSchema: PlaceOrder$OrderingPlugin.errorSchema,
|
|
110
|
-
eventSchema: PlaceOrder$OrderingPlugin.eventSchema
|
|
111
|
+
eventSchema: PlaceOrder$OrderingPlugin.eventSchema,
|
|
112
|
+
commandAuthorization: PlaceOrder$OrderingPlugin.commandAuthorization
|
|
111
113
|
})({
|
|
112
114
|
initialState: PlaceOrder_Behavior$OrderingPlugin.initialState,
|
|
113
115
|
evolve: PlaceOrder_Behavior$OrderingPlugin.evolve,
|
|
@@ -129,7 +131,8 @@ let Ship = Flow_GWT$ReventlessGwt.CommandStep({
|
|
|
129
131
|
consumedEventSchema: ShipOrder$OrderingPlugin.consumedEventSchema,
|
|
130
132
|
commandSchema: ShipOrder$OrderingPlugin.commandSchema,
|
|
131
133
|
errorSchema: ShipOrder$OrderingPlugin.errorSchema,
|
|
132
|
-
eventSchema: ShipOrder$OrderingPlugin.eventSchema
|
|
134
|
+
eventSchema: ShipOrder$OrderingPlugin.eventSchema,
|
|
135
|
+
commandAuthorization: ShipOrder$OrderingPlugin.commandAuthorization
|
|
133
136
|
})({
|
|
134
137
|
initialState: ShipOrder_Behavior$OrderingPlugin.initialState,
|
|
135
138
|
evolve: ShipOrder_Behavior$OrderingPlugin.evolve,
|
|
@@ -248,7 +248,8 @@ let Conformance = Notification_Conformance$TraitNotification.Make({
|
|
|
248
248
|
consumedEventSchema: NotificationPreferences$OrderingPlugin.consumedEventSchema,
|
|
249
249
|
commandSchema: NotificationPreferences$OrderingPlugin.commandSchema,
|
|
250
250
|
errorSchema: NotificationPreferences$OrderingPlugin.errorSchema,
|
|
251
|
-
eventSchema: NotificationPreferences$OrderingPlugin.eventSchema
|
|
251
|
+
eventSchema: NotificationPreferences$OrderingPlugin.eventSchema,
|
|
252
|
+
commandAuthorization: NotificationPreferences$OrderingPlugin.commandAuthorization
|
|
252
253
|
},
|
|
253
254
|
Behavior: {
|
|
254
255
|
Spec: {
|
|
@@ -256,7 +257,8 @@ let Conformance = Notification_Conformance$TraitNotification.Make({
|
|
|
256
257
|
consumedEventSchema: NotificationPreferences$OrderingPlugin.consumedEventSchema,
|
|
257
258
|
commandSchema: NotificationPreferences$OrderingPlugin.commandSchema,
|
|
258
259
|
errorSchema: NotificationPreferences$OrderingPlugin.errorSchema,
|
|
259
|
-
eventSchema: NotificationPreferences$OrderingPlugin.eventSchema
|
|
260
|
+
eventSchema: NotificationPreferences$OrderingPlugin.eventSchema,
|
|
261
|
+
commandAuthorization: NotificationPreferences$OrderingPlugin.commandAuthorization
|
|
260
262
|
},
|
|
261
263
|
initialState: NotificationPreferences_Behavior$OrderingPlugin.initialState,
|
|
262
264
|
evolve: NotificationPreferences_Behavior$OrderingPlugin.evolve,
|
|
@@ -10,7 +10,8 @@ let include = Behavior_GWT$ReventlessGwt.Make({
|
|
|
10
10
|
consumedEventSchema: NotificationPreferences$OrderingPlugin.consumedEventSchema,
|
|
11
11
|
commandSchema: NotificationPreferences$OrderingPlugin.commandSchema,
|
|
12
12
|
errorSchema: NotificationPreferences$OrderingPlugin.errorSchema,
|
|
13
|
-
eventSchema: NotificationPreferences$OrderingPlugin.eventSchema
|
|
13
|
+
eventSchema: NotificationPreferences$OrderingPlugin.eventSchema,
|
|
14
|
+
commandAuthorization: NotificationPreferences$OrderingPlugin.commandAuthorization
|
|
14
15
|
})({
|
|
15
16
|
initialState: NotificationPreferences_Behavior$OrderingPlugin.initialState,
|
|
16
17
|
evolve: NotificationPreferences_Behavior$OrderingPlugin.evolve,
|
|
@@ -10,7 +10,8 @@ let include = Behavior_GWT$ReventlessGwt.Make({
|
|
|
10
10
|
consumedEventSchema: NotificationSourceClaims$OrderingPlugin.consumedEventSchema,
|
|
11
11
|
commandSchema: NotificationSourceClaims$OrderingPlugin.commandSchema,
|
|
12
12
|
errorSchema: NotificationSourceClaims$OrderingPlugin.errorSchema,
|
|
13
|
-
eventSchema: NotificationSourceClaims$OrderingPlugin.eventSchema
|
|
13
|
+
eventSchema: NotificationSourceClaims$OrderingPlugin.eventSchema,
|
|
14
|
+
commandAuthorization: NotificationSourceClaims$OrderingPlugin.commandAuthorization
|
|
14
15
|
})({
|
|
15
16
|
initialState: NotificationSourceClaims_Behavior$OrderingPlugin.initialState,
|
|
16
17
|
evolve: NotificationSourceClaims_Behavior$OrderingPlugin.evolve,
|
|
@@ -10,7 +10,8 @@ let include = Behavior_GWT$ReventlessGwt.Make({
|
|
|
10
10
|
consumedEventSchema: CancelOrder$OrderingPlugin.consumedEventSchema,
|
|
11
11
|
commandSchema: CancelOrder$OrderingPlugin.commandSchema,
|
|
12
12
|
errorSchema: CancelOrder$OrderingPlugin.errorSchema,
|
|
13
|
-
eventSchema: CancelOrder$OrderingPlugin.eventSchema
|
|
13
|
+
eventSchema: CancelOrder$OrderingPlugin.eventSchema,
|
|
14
|
+
commandAuthorization: CancelOrder$OrderingPlugin.commandAuthorization
|
|
14
15
|
})({
|
|
15
16
|
initialState: CancelOrder_Behavior$OrderingPlugin.initialState,
|
|
16
17
|
evolve: CancelOrder_Behavior$OrderingPlugin.evolve,
|
|
@@ -123,7 +124,7 @@ describe("CancelOrder StateChangeSlice", () => {
|
|
|
123
124
|
TAG: "OrderPlaced",
|
|
124
125
|
productIds: [Ordering_Examples$OrderingPlugin.p1],
|
|
125
126
|
customerId: Ordering_Examples$OrderingPlugin.c1
|
|
126
|
-
}]), Caller.owner(Ordering_Examples$OrderingPlugin.c1)), {
|
|
127
|
+
}]), Caller.owner(Ordering_Examples$OrderingPlugin.c1, undefined)), {
|
|
127
128
|
TAG: "CancelOrder",
|
|
128
129
|
orderId: Ordering_Examples$OrderingPlugin.o1
|
|
129
130
|
}), {
|
|
@@ -135,7 +136,7 @@ describe("CancelOrder StateChangeSlice", () => {
|
|
|
135
136
|
TAG: "OrderPlaced",
|
|
136
137
|
productIds: [Ordering_Examples$OrderingPlugin.p1],
|
|
137
138
|
customerId: Ordering_Examples$OrderingPlugin.c1
|
|
138
|
-
}]), Caller.owner(Ordering_Examples$OrderingPlugin.c2)), {
|
|
139
|
+
}]), Caller.owner(Ordering_Examples$OrderingPlugin.c2, undefined)), {
|
|
139
140
|
TAG: "CancelOrder",
|
|
140
141
|
orderId: Ordering_Examples$OrderingPlugin.o1
|
|
141
142
|
})));
|
|
@@ -14,7 +14,8 @@ let include = Behavior_GWT$ReventlessGwt.Make({
|
|
|
14
14
|
consumedEventSchema: PlaceOrder$OrderingPlugin.consumedEventSchema,
|
|
15
15
|
commandSchema: PlaceOrder$OrderingPlugin.commandSchema,
|
|
16
16
|
errorSchema: PlaceOrder$OrderingPlugin.errorSchema,
|
|
17
|
-
eventSchema: PlaceOrder$OrderingPlugin.eventSchema
|
|
17
|
+
eventSchema: PlaceOrder$OrderingPlugin.eventSchema,
|
|
18
|
+
commandAuthorization: PlaceOrder$OrderingPlugin.commandAuthorization
|
|
18
19
|
})({
|
|
19
20
|
initialState: PlaceOrder_Behavior$OrderingPlugin.initialState,
|
|
20
21
|
evolve: PlaceOrder_Behavior$OrderingPlugin.evolve,
|
|
@@ -43,3 +43,37 @@ describe("ShipOrder StateChangeSlice", () => {
|
|
|
43
43
|
->thenEvent(OrderShipped({orderId: o1, customerId: c1}))
|
|
44
44
|
)
|
|
45
45
|
})
|
|
46
|
+
|
|
47
|
+
describe("Who may ShipOrder", () => {
|
|
48
|
+
// scenario-id: a0ce6e35-29df-48c8-81d8-5af12a0f48d1
|
|
49
|
+
test("a Fulfilment may ship an order", () =>
|
|
50
|
+
givenEvents([OrderPlaced({productIds: [p1], customerId: c1})])
|
|
51
|
+
->asCaller(Caller.inRoles([Fulfilment]))
|
|
52
|
+
->whenCmd(ShipOrder({orderId: o1}))
|
|
53
|
+
->thenEvent(OrderShipped({orderId: o1, customerId: c1}))
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
// scenario-id: 6af9d686-1310-43e5-946e-90ed1ec14d18
|
|
57
|
+
test("an Admin may ship an order", () =>
|
|
58
|
+
givenEvents([OrderPlaced({productIds: [p1], customerId: c1})])
|
|
59
|
+
->asCaller(Caller.inRoles([Admin]))
|
|
60
|
+
->whenCmd(ShipOrder({orderId: o1}))
|
|
61
|
+
->thenEvent(OrderShipped({orderId: o1, customerId: c1}))
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
// scenario-id: 5b4f7a52-ec5e-4282-a7c8-a74432af13da
|
|
65
|
+
test("a shopper may not ship an order", () =>
|
|
66
|
+
givenEvents([OrderPlaced({productIds: [p1], customerId: c1})])
|
|
67
|
+
->asCaller(Caller.owner(c1))
|
|
68
|
+
->whenCmd(ShipOrder({orderId: o1}))
|
|
69
|
+
->thenRefused
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
// scenario-id: 020c3695-3e3d-4343-8d38-d9d33ccf22f0
|
|
73
|
+
test("an anonymous caller may not ship an order", () =>
|
|
74
|
+
givenEvents([OrderPlaced({productIds: [p1], customerId: c1})])
|
|
75
|
+
->asCaller(Caller.anonymous)
|
|
76
|
+
->whenCmd(ShipOrder({orderId: o1}))
|
|
77
|
+
->thenRefused
|
|
78
|
+
)
|
|
79
|
+
})
|
|
@@ -10,7 +10,8 @@ let include = Behavior_GWT$ReventlessGwt.Make({
|
|
|
10
10
|
consumedEventSchema: ShipOrder$OrderingPlugin.consumedEventSchema,
|
|
11
11
|
commandSchema: ShipOrder$OrderingPlugin.commandSchema,
|
|
12
12
|
errorSchema: ShipOrder$OrderingPlugin.errorSchema,
|
|
13
|
-
eventSchema: ShipOrder$OrderingPlugin.eventSchema
|
|
13
|
+
eventSchema: ShipOrder$OrderingPlugin.eventSchema,
|
|
14
|
+
commandAuthorization: ShipOrder$OrderingPlugin.commandAuthorization
|
|
14
15
|
})({
|
|
15
16
|
initialState: ShipOrder_Behavior$OrderingPlugin.initialState,
|
|
16
17
|
evolve: ShipOrder_Behavior$OrderingPlugin.evolve,
|
|
@@ -23,6 +24,10 @@ let test = include.test;
|
|
|
23
24
|
|
|
24
25
|
let givenEvents = include.givenEvents;
|
|
25
26
|
|
|
27
|
+
let Caller = include.Caller;
|
|
28
|
+
|
|
29
|
+
let asCaller = include.asCaller;
|
|
30
|
+
|
|
26
31
|
let whenCmd = include.whenCmd;
|
|
27
32
|
|
|
28
33
|
let thenEvent = include.thenEvent;
|
|
@@ -31,6 +36,8 @@ let thenNoEvent = include.thenNoEvent;
|
|
|
31
36
|
|
|
32
37
|
let thenError = include.thenError;
|
|
33
38
|
|
|
39
|
+
let thenRefused = include.thenRefused;
|
|
40
|
+
|
|
34
41
|
describe("ShipOrder StateChangeSlice", () => {
|
|
35
42
|
test("non-existent order returns OrderNotFound", () => thenError(whenCmd(givenEvents([]), {
|
|
36
43
|
TAG: "ShipOrder",
|
|
@@ -88,22 +95,59 @@ describe("ShipOrder StateChangeSlice", () => {
|
|
|
88
95
|
}));
|
|
89
96
|
});
|
|
90
97
|
|
|
98
|
+
describe("Who may ShipOrder", () => {
|
|
99
|
+
test("a Fulfilment may ship an order", () => thenEvent(whenCmd(asCaller(givenEvents([{
|
|
100
|
+
TAG: "OrderPlaced",
|
|
101
|
+
productIds: [Ordering_Examples$OrderingPlugin.p1],
|
|
102
|
+
customerId: Ordering_Examples$OrderingPlugin.c1
|
|
103
|
+
}]), Caller.inRoles(["Fulfilment"])), {
|
|
104
|
+
TAG: "ShipOrder",
|
|
105
|
+
orderId: Ordering_Examples$OrderingPlugin.o1
|
|
106
|
+
}), {
|
|
107
|
+
TAG: "OrderShipped",
|
|
108
|
+
orderId: Ordering_Examples$OrderingPlugin.o1,
|
|
109
|
+
customerId: Ordering_Examples$OrderingPlugin.c1
|
|
110
|
+
}));
|
|
111
|
+
test("an Admin may ship an order", () => thenEvent(whenCmd(asCaller(givenEvents([{
|
|
112
|
+
TAG: "OrderPlaced",
|
|
113
|
+
productIds: [Ordering_Examples$OrderingPlugin.p1],
|
|
114
|
+
customerId: Ordering_Examples$OrderingPlugin.c1
|
|
115
|
+
}]), Caller.inRoles(["Admin"])), {
|
|
116
|
+
TAG: "ShipOrder",
|
|
117
|
+
orderId: Ordering_Examples$OrderingPlugin.o1
|
|
118
|
+
}), {
|
|
119
|
+
TAG: "OrderShipped",
|
|
120
|
+
orderId: Ordering_Examples$OrderingPlugin.o1,
|
|
121
|
+
customerId: Ordering_Examples$OrderingPlugin.c1
|
|
122
|
+
}));
|
|
123
|
+
test("a shopper may not ship an order", () => thenRefused(whenCmd(asCaller(givenEvents([{
|
|
124
|
+
TAG: "OrderPlaced",
|
|
125
|
+
productIds: [Ordering_Examples$OrderingPlugin.p1],
|
|
126
|
+
customerId: Ordering_Examples$OrderingPlugin.c1
|
|
127
|
+
}]), Caller.owner(Ordering_Examples$OrderingPlugin.c1, undefined)), {
|
|
128
|
+
TAG: "ShipOrder",
|
|
129
|
+
orderId: Ordering_Examples$OrderingPlugin.o1
|
|
130
|
+
})));
|
|
131
|
+
test("an anonymous caller may not ship an order", () => thenRefused(whenCmd(asCaller(givenEvents([{
|
|
132
|
+
TAG: "OrderPlaced",
|
|
133
|
+
productIds: [Ordering_Examples$OrderingPlugin.p1],
|
|
134
|
+
customerId: Ordering_Examples$OrderingPlugin.c1
|
|
135
|
+
}]), Caller.anonymous), {
|
|
136
|
+
TAG: "ShipOrder",
|
|
137
|
+
orderId: Ordering_Examples$OrderingPlugin.o1
|
|
138
|
+
})));
|
|
139
|
+
});
|
|
140
|
+
|
|
91
141
|
let Spec = include.Spec;
|
|
92
142
|
|
|
93
143
|
let todo = include.todo;
|
|
94
144
|
|
|
95
|
-
let Caller = include.Caller;
|
|
96
|
-
|
|
97
|
-
let asCaller = include.asCaller;
|
|
98
|
-
|
|
99
145
|
let thenEvents = include.thenEvents;
|
|
100
146
|
|
|
101
147
|
let thenEventWithError = include.thenEventWithError;
|
|
102
148
|
|
|
103
149
|
let thenEventsWithError = include.thenEventsWithError;
|
|
104
150
|
|
|
105
|
-
let thenRefused = include.thenRefused;
|
|
106
|
-
|
|
107
151
|
let thenAppendsConditionedOn = include.thenAppendsConditionedOn;
|
|
108
152
|
|
|
109
153
|
let thenAppendsConditionedOnExactly = include.thenAppendsConditionedOnExactly;
|