@reventlessdev/reventless-core 3.0.0-alpha.291 → 3.0.0-alpha.293
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 +21 -0
- package/package.json +7 -7
- package/src/admin/Platform_Admin_Structure.res +1 -2
- package/src/admin/Platform_Admin_Structure.res.mjs +1 -1
- package/src/admin/UiFragmentRegistry/StateChange/UiFragmentRegistry.res.mjs +2 -2
- package/src/components/AutomationSlice/AutomationSlice_Callback.res +25 -46
- package/src/components/AutomationSlice/AutomationSlice_Callback.res.mjs +27 -46
- package/src/components/AutomationSlice/AutomationSlice_Route.res +50 -0
- package/src/components/AutomationSlice/AutomationSlice_Route.res.mjs +39 -0
- package/src/components/Dcb/Dcb_Builder.res +31 -56
- package/src/components/Dcb/Dcb_Builder.res.mjs +13 -29
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Builder.res +2 -2
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Builder.res.mjs +2 -2
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res +125 -164
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res.mjs +121 -130
- package/src/plugin/component/Plugin_Builder.res +8 -18
- package/src/plugin/component/Plugin_Builder.res.mjs +2 -8
- package/src/plugin/component/Plugin_Helpers.res +16 -9
- package/src/plugin/component/Plugin_Helpers.res.mjs +1 -1
- package/src/plugin/component/Plugin_Structure.res +35 -28
- package/src/plugin/component/Plugin_Structure.res.mjs +18 -8
- package/src/plugin/connect/PluginConnectExtension_Mapping.res.mjs +1 -1
- package/src/plugin/connect/PluginExtensionPoint_Plugin.res.mjs +1 -1
- package/src/plugin/connect/PluginExtensionPoint_UiFragment.res +1 -1
- package/src/plugin/connect/PluginExtensionPoint_UiFragment.res.mjs +1 -1
- package/src/plugin/lifecycle/PluginSpec.res.mjs +2 -2
- package/tests/aggregate/AggregateCacheTest.res.mjs +4 -4
- package/tests/aggregate/AggregateConflictTest.res.mjs +4 -4
- package/tests/aggregate/AggregateFixtures.res.mjs +4 -4
- package/tests/aggregate/AggregateSnapshotTest.res.mjs +6 -6
- package/tests/api/GraphQL_FragmentGeneratorTest.res.mjs +6 -6
- package/tests/commandgenerator/CommandGeneratorFixtures.res.mjs +3 -3
- package/tests/commandgenerator/OwnerActingTest.res.mjs +7 -7
- package/tests/commandtopic/CommandOutcomeHookTest.res.mjs +1 -1
- package/tests/commandtopic/CommandTopicCallbackFixtures.res.mjs +3 -3
- package/tests/dcb/DcbFixtures.res.mjs +2 -2
- package/tests/dcb/DcbStateChangeSliceTest.res.mjs +7 -7
- package/tests/eventmapper/EventMapperFixtures.res.mjs +4 -4
- package/tests/extensionpoint/ExtensionPointFixtures.res.mjs +2 -2
- package/tests/extensionpoint/ExtensionPointOperationsTest.res.mjs +2 -2
- package/tests/plugin/PluginStructureAccessTest.res +57 -0
- package/tests/plugin/PluginStructureAccessTest.res.mjs +91 -1
- package/tests/plugin/PluginStructureTest.res.mjs +10 -10
- package/tests/plugin/StateChange/PsAttachInvoice.res.mjs +2 -2
- package/tests/plugin/StateChange/PsChangePhoto.res.mjs +2 -2
- package/tests/plugin/StateChange/PsDispatchShipment.res.mjs +2 -2
- package/tests/plugin/StateChange/PsGatedCommands.res.mjs +3 -3
- package/tests/plugin/StateChange/PsPlaceOrder.res.mjs +2 -2
- package/tests/plugin/StateChange/PsReserveStock.res.mjs +2 -2
- package/tests/plugin/StateChange/PsShipOrder.res.mjs +2 -2
- package/tests/plugin/StateChange/PsTransitionSwitch.res.mjs +2 -2
- package/tests/plugin/StateChange/PsTypoStore.res.mjs +2 -2
- package/tests/plugin/StateChange/PsUploadAvatar.res.mjs +2 -2
- package/tests/plugin/StateChange/PsUploadImages.res.mjs +2 -2
- package/tests/util/CommandPublisherTest.res.mjs +2 -2
|
@@ -72,7 +72,7 @@ let errorSchema = Sury.union([
|
|
|
72
72
|
Sury.literal("OrderNotFound")
|
|
73
73
|
]);
|
|
74
74
|
|
|
75
|
-
function
|
|
75
|
+
function authorizationOf(param) {
|
|
76
76
|
return "AllowAuthenticated";
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -90,7 +90,7 @@ let OrderSlice = {
|
|
|
90
90
|
consumedEventSchema: consumedEventSchema,
|
|
91
91
|
commandSchema: commandSchema,
|
|
92
92
|
errorSchema: errorSchema,
|
|
93
|
-
|
|
93
|
+
authorizationOf: authorizationOf,
|
|
94
94
|
commandTransition: commandTransition,
|
|
95
95
|
traits: traits,
|
|
96
96
|
readConsistency: "EscalateOnRetry"
|
|
@@ -189,7 +189,7 @@ let OrderHandler = StateChangeSlice_Callback$ReventlessCore.Make({
|
|
|
189
189
|
errorSchema: errorSchema,
|
|
190
190
|
eventSchema: eventSchema,
|
|
191
191
|
commandSchema: commandSchema,
|
|
192
|
-
|
|
192
|
+
authorizationOf: authorizationOf,
|
|
193
193
|
commandTransition: commandTransition,
|
|
194
194
|
traits: traits,
|
|
195
195
|
readConsistency: "EscalateOnRetry"
|
|
@@ -270,7 +270,7 @@ let errorSchema$1 = Sury.union([
|
|
|
270
270
|
|
|
271
271
|
let moduleUrl$1 = import.meta.url;
|
|
272
272
|
|
|
273
|
-
function
|
|
273
|
+
function authorizationOf$1(param) {
|
|
274
274
|
return "AllowAuthenticated";
|
|
275
275
|
}
|
|
276
276
|
|
|
@@ -287,7 +287,7 @@ let AccountSpec = {
|
|
|
287
287
|
eventSchema: eventSchema$1,
|
|
288
288
|
errorSchema: errorSchema$1,
|
|
289
289
|
moduleUrl: moduleUrl$1,
|
|
290
|
-
|
|
290
|
+
authorizationOf: authorizationOf$1,
|
|
291
291
|
commandTransition: commandTransition$1,
|
|
292
292
|
traits: traits$1
|
|
293
293
|
};
|
|
@@ -453,7 +453,7 @@ let AccountHandler = Aggregate_Callback$ReventlessCore.Make({
|
|
|
453
453
|
errorSchema: errorSchema$1,
|
|
454
454
|
commandSchema: commandSchema$1,
|
|
455
455
|
moduleUrl: moduleUrl$1,
|
|
456
|
-
|
|
456
|
+
authorizationOf: authorizationOf$1,
|
|
457
457
|
commandTransition: commandTransition$1,
|
|
458
458
|
traits: traits$1
|
|
459
459
|
})({
|
|
@@ -476,7 +476,7 @@ let AccountHandler = Aggregate_Callback$ReventlessCore.Make({
|
|
|
476
476
|
errorSchema: errorSchema$1,
|
|
477
477
|
commandSchema: commandSchema$1,
|
|
478
478
|
moduleUrl: moduleUrl$1,
|
|
479
|
-
|
|
479
|
+
authorizationOf: authorizationOf$1,
|
|
480
480
|
commandTransition: commandTransition$1,
|
|
481
481
|
traits: traits$1
|
|
482
482
|
},
|
|
@@ -63,7 +63,7 @@ let SliceHandler = StateChangeSlice_Callback$ReventlessCore.Make({
|
|
|
63
63
|
errorSchema: DcbFixtures$ReventlessCore.TestCommandSpec.errorSchema,
|
|
64
64
|
eventSchema: DcbFixtures$ReventlessCore.TestCommandSpec.eventSchema,
|
|
65
65
|
commandSchema: DcbFixtures$ReventlessCore.TestCommandSpec.commandSchema,
|
|
66
|
-
|
|
66
|
+
authorizationOf: DcbFixtures$ReventlessCore.TestCommandSpec.authorizationOf,
|
|
67
67
|
commandTransition: DcbFixtures$ReventlessCore.TestCommandSpec.commandTransition,
|
|
68
68
|
traits: DcbFixtures$ReventlessCore.TestCommandSpec.traits,
|
|
69
69
|
readConsistency: DcbFixtures$ReventlessCore.TestCommandSpec.readConsistency
|
|
@@ -21,7 +21,7 @@ let commandSchema = Sury.union([
|
|
|
21
21
|
}))
|
|
22
22
|
]);
|
|
23
23
|
|
|
24
|
-
function
|
|
24
|
+
function authorizationOf(param) {
|
|
25
25
|
return "AllowAuthenticated";
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -35,7 +35,7 @@ let TestSpec = {
|
|
|
35
35
|
Id: undefined,
|
|
36
36
|
name: name,
|
|
37
37
|
commandSchema: commandSchema,
|
|
38
|
-
|
|
38
|
+
authorizationOf: authorizationOf,
|
|
39
39
|
commandTransition: commandTransition,
|
|
40
40
|
traits: traits
|
|
41
41
|
};
|
|
@@ -72,7 +72,7 @@ let TestOps_Spec = {
|
|
|
72
72
|
Id: Id$Reventless.StringPure,
|
|
73
73
|
name: name,
|
|
74
74
|
commandSchema: commandSchema,
|
|
75
|
-
|
|
75
|
+
authorizationOf: authorizationOf,
|
|
76
76
|
commandTransition: commandTransition,
|
|
77
77
|
traits: traits
|
|
78
78
|
};
|
|
@@ -152,7 +152,7 @@ function decide(state, command) {
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
function
|
|
155
|
+
function authorizationOf(param) {
|
|
156
156
|
return "AllowAuthenticated";
|
|
157
157
|
}
|
|
158
158
|
|
|
@@ -178,7 +178,7 @@ let TestCommandSpec = {
|
|
|
178
178
|
initialState: TestCommandSpec_initialState,
|
|
179
179
|
evolve: evolve,
|
|
180
180
|
decide: decide,
|
|
181
|
-
|
|
181
|
+
authorizationOf: authorizationOf,
|
|
182
182
|
commandTransition: commandTransition,
|
|
183
183
|
traits: traits,
|
|
184
184
|
readConsistency: "EscalateOnRetry"
|
|
@@ -59,7 +59,7 @@ let TestHandler = StateChangeSlice_Callback$ReventlessCore.Make({
|
|
|
59
59
|
errorSchema: DcbFixtures$ReventlessCore.TestCommandSpec.errorSchema,
|
|
60
60
|
eventSchema: DcbFixtures$ReventlessCore.TestCommandSpec.eventSchema,
|
|
61
61
|
commandSchema: DcbFixtures$ReventlessCore.TestCommandSpec.commandSchema,
|
|
62
|
-
|
|
62
|
+
authorizationOf: DcbFixtures$ReventlessCore.TestCommandSpec.authorizationOf,
|
|
63
63
|
commandTransition: DcbFixtures$ReventlessCore.TestCommandSpec.commandTransition,
|
|
64
64
|
traits: DcbFixtures$ReventlessCore.TestCommandSpec.traits,
|
|
65
65
|
readConsistency: DcbFixtures$ReventlessCore.TestCommandSpec.readConsistency
|
|
@@ -77,7 +77,7 @@ let commandSchema = DcbFixtures$ReventlessCore.TestCommandSpec.commandSchema;
|
|
|
77
77
|
|
|
78
78
|
let errorSchema = DcbFixtures$ReventlessCore.TestCommandSpec.errorSchema;
|
|
79
79
|
|
|
80
|
-
let
|
|
80
|
+
let authorizationOf = DcbFixtures$ReventlessCore.TestCommandSpec.authorizationOf;
|
|
81
81
|
|
|
82
82
|
let commandTransition = DcbFixtures$ReventlessCore.TestCommandSpec.commandTransition;
|
|
83
83
|
|
|
@@ -102,7 +102,7 @@ let StrongSpec = {
|
|
|
102
102
|
initialState: StrongSpec_initialState,
|
|
103
103
|
evolve: StrongSpec_evolve,
|
|
104
104
|
decide: StrongSpec_decide,
|
|
105
|
-
|
|
105
|
+
authorizationOf: authorizationOf,
|
|
106
106
|
commandTransition: commandTransition,
|
|
107
107
|
traits: traits,
|
|
108
108
|
readConsistency: "AlwaysStrong"
|
|
@@ -120,7 +120,7 @@ let commandSchema$1 = DcbFixtures$ReventlessCore.TestCommandSpec.commandSchema;
|
|
|
120
120
|
|
|
121
121
|
let errorSchema$1 = DcbFixtures$ReventlessCore.TestCommandSpec.errorSchema;
|
|
122
122
|
|
|
123
|
-
let
|
|
123
|
+
let authorizationOf$1 = DcbFixtures$ReventlessCore.TestCommandSpec.authorizationOf;
|
|
124
124
|
|
|
125
125
|
let commandTransition$1 = DcbFixtures$ReventlessCore.TestCommandSpec.commandTransition;
|
|
126
126
|
|
|
@@ -145,7 +145,7 @@ let EventualSpec = {
|
|
|
145
145
|
initialState: EventualSpec_initialState,
|
|
146
146
|
evolve: EventualSpec_evolve,
|
|
147
147
|
decide: EventualSpec_decide,
|
|
148
|
-
|
|
148
|
+
authorizationOf: authorizationOf$1,
|
|
149
149
|
commandTransition: commandTransition$1,
|
|
150
150
|
traits: traits$1,
|
|
151
151
|
readConsistency: "AlwaysEventual"
|
|
@@ -158,7 +158,7 @@ let StrongHandler = StateChangeSlice_Callback$ReventlessCore.Make({
|
|
|
158
158
|
errorSchema: errorSchema,
|
|
159
159
|
eventSchema: eventSchema,
|
|
160
160
|
commandSchema: commandSchema,
|
|
161
|
-
|
|
161
|
+
authorizationOf: authorizationOf,
|
|
162
162
|
commandTransition: commandTransition,
|
|
163
163
|
traits: traits,
|
|
164
164
|
readConsistency: "AlwaysStrong"
|
|
@@ -171,7 +171,7 @@ let EventualHandler = StateChangeSlice_Callback$ReventlessCore.Make({
|
|
|
171
171
|
errorSchema: errorSchema$1,
|
|
172
172
|
eventSchema: eventSchema$1,
|
|
173
173
|
commandSchema: commandSchema$1,
|
|
174
|
-
|
|
174
|
+
authorizationOf: authorizationOf$1,
|
|
175
175
|
commandTransition: commandTransition$1,
|
|
176
176
|
traits: traits$1,
|
|
177
177
|
readConsistency: "AlwaysEventual"
|
|
@@ -161,7 +161,7 @@ let commandSchema = Sury.union([
|
|
|
161
161
|
|
|
162
162
|
let moduleUrl$2 = import.meta.url;
|
|
163
163
|
|
|
164
|
-
function
|
|
164
|
+
function authorizationOf(param) {
|
|
165
165
|
return "AllowAuthenticated";
|
|
166
166
|
}
|
|
167
167
|
|
|
@@ -176,7 +176,7 @@ let CmdTargetSpec = {
|
|
|
176
176
|
name: name$3,
|
|
177
177
|
commandSchema: commandSchema,
|
|
178
178
|
moduleUrl: moduleUrl$2,
|
|
179
|
-
|
|
179
|
+
authorizationOf: authorizationOf,
|
|
180
180
|
commandTransition: commandTransition,
|
|
181
181
|
traits: traits
|
|
182
182
|
};
|
|
@@ -253,7 +253,7 @@ let OrderMappings_Target = {
|
|
|
253
253
|
name: name$3,
|
|
254
254
|
commandSchema: commandSchema,
|
|
255
255
|
moduleUrl: moduleUrl$2,
|
|
256
|
-
|
|
256
|
+
authorizationOf: authorizationOf,
|
|
257
257
|
commandTransition: commandTransition,
|
|
258
258
|
traits: traits
|
|
259
259
|
};
|
|
@@ -284,7 +284,7 @@ let CountOrderMappings_Target = {
|
|
|
284
284
|
name: name$3,
|
|
285
285
|
commandSchema: commandSchema,
|
|
286
286
|
moduleUrl: moduleUrl$2,
|
|
287
|
-
|
|
287
|
+
authorizationOf: authorizationOf,
|
|
288
288
|
commandTransition: commandTransition,
|
|
289
289
|
traits: traits
|
|
290
290
|
};
|
|
@@ -26,7 +26,7 @@ let directiveSchema = Sury.literal("DirectiveA");
|
|
|
26
26
|
|
|
27
27
|
let moduleUrl = import.meta.url;
|
|
28
28
|
|
|
29
|
-
function
|
|
29
|
+
function authorizationOf(param) {
|
|
30
30
|
return "AllowAuthenticated";
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -42,7 +42,7 @@ let TestEPSpec = {
|
|
|
42
42
|
eventSchema: eventSchema,
|
|
43
43
|
directiveSchema: directiveSchema,
|
|
44
44
|
moduleUrl: moduleUrl,
|
|
45
|
-
|
|
45
|
+
authorizationOf: authorizationOf,
|
|
46
46
|
commandTransition: commandTransition,
|
|
47
47
|
traits: traits
|
|
48
48
|
};
|
|
@@ -21,7 +21,7 @@ let directiveSchema = Sury.literal("OpsEPNoDirective");
|
|
|
21
21
|
|
|
22
22
|
let moduleUrl = import.meta.url;
|
|
23
23
|
|
|
24
|
-
function
|
|
24
|
+
function authorizationOf(param) {
|
|
25
25
|
return "AllowAuthenticated";
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -37,7 +37,7 @@ let OpsEPSpec = {
|
|
|
37
37
|
eventSchema: eventSchema,
|
|
38
38
|
directiveSchema: directiveSchema,
|
|
39
39
|
moduleUrl: moduleUrl,
|
|
40
|
-
|
|
40
|
+
authorizationOf: authorizationOf,
|
|
41
41
|
commandTransition: commandTransition,
|
|
42
42
|
traits: traits
|
|
43
43
|
};
|
|
@@ -138,3 +138,60 @@ describe("requiredAccess derived from the authorization rule", () => {
|
|
|
138
138
|
)->toEqual(None)
|
|
139
139
|
)
|
|
140
140
|
})
|
|
141
|
+
|
|
142
|
+
module PsTwoRuleFeed = {
|
|
143
|
+
let name = "PsTwoRuleFeed"
|
|
144
|
+
let moduleUrl = "ps-two-rule-feed://spec"
|
|
145
|
+
@schema type externalInput = {sku: string}
|
|
146
|
+
@schema type command = AddProduct({sku: string}) | AddCategory({sku: string})
|
|
147
|
+
let targetName = "AddProduct"
|
|
148
|
+
let externalSystem = None
|
|
149
|
+
type role = Reventless.Role.name
|
|
150
|
+
let authorizationOf = (name: string): Reventless.Authorization.rule<role> =>
|
|
151
|
+
switch name {
|
|
152
|
+
| "AddProduct" => AllowRoles([Reventless.Role.make("Merchandiser")])
|
|
153
|
+
| "AddCategory" => AllowRoles([Reventless.Role.make("Admin")])
|
|
154
|
+
| _ => DenyAll
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
module PsTwoRuleFeedSlice: ReventlessInfra.InboundTranslationSlice.T = {
|
|
159
|
+
module Spec = PsTwoRuleFeed
|
|
160
|
+
module Translation = {
|
|
161
|
+
let translate = (_: PsTwoRuleFeed.externalInput) => Ok([])
|
|
162
|
+
let moduleUrl = PsTwoRuleFeed.moduleUrl
|
|
163
|
+
}
|
|
164
|
+
type component = Component.t<
|
|
165
|
+
ReventlessInfra.InboundTranslationSlice.t,
|
|
166
|
+
ReventlessInfra.InboundTranslationSlice.outputs,
|
|
167
|
+
ReventlessInfra.InboundTranslationSlice.operations,
|
|
168
|
+
>
|
|
169
|
+
let queryDbName = "PsTwoRuleFeedAudit"
|
|
170
|
+
let make = (~publishJsons as _, ~runtime as _=?, ~opts as _=?): component => Obj.magic(0)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
describe("an inbound slice's roles", () => {
|
|
174
|
+
let door = Dcb_Builder.inboundDoorPermission(
|
|
175
|
+
PsTwoRuleFeed.commandSchema,
|
|
176
|
+
PsTwoRuleFeed.authorizationOf,
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
testSync("the door admits any constructor's roles", () =>
|
|
180
|
+
expect(door->Option.map(Reventless.Authorization.rolesOf))->toEqual(
|
|
181
|
+
Some([Reventless.Role.make("Merchandiser"), Reventless.Role.make("Admin")]),
|
|
182
|
+
)
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
testSync("requiredRoles are the door's roles", () => {
|
|
186
|
+
let inbound =
|
|
187
|
+
Plugin_Structure.make(
|
|
188
|
+
~name="AccessPlugin",
|
|
189
|
+
~inboundTranslationSlices=[module(PsTwoRuleFeedSlice)],
|
|
190
|
+
).inboundTranslationSlices->Array.get(0)
|
|
191
|
+
let doorRoles =
|
|
192
|
+
door->Option.map(
|
|
193
|
+
rule => rule->Reventless.Authorization.rolesOf->Array.map(r => (r :> string)),
|
|
194
|
+
)
|
|
195
|
+
expect(inbound->Option.flatMap(s => s.requiredRoles))->toEqual(doorRoles)
|
|
196
|
+
})
|
|
197
|
+
})
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
+
import * as Sury from "sury";
|
|
3
4
|
import * as Id$Reventless from "@reventlessdev/reventless-spec/src/types/Id.res.mjs";
|
|
4
5
|
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
5
6
|
import * as Role$Reventless from "@reventlessdev/reventless-spec/src/types/Role.res.mjs";
|
|
7
|
+
import * as Authorization$Reventless from "@reventlessdev/reventless-spec/src/types/Authorization.res.mjs";
|
|
8
|
+
import * as Dcb_Builder$ReventlessCore from "../../src/components/Dcb/Dcb_Builder.res.mjs";
|
|
6
9
|
import * as PsGatedView$ReventlessCore from "./StateView/PsGatedView.res.mjs";
|
|
7
10
|
import * as PsOrdersView$ReventlessCore from "./StateView/PsOrdersView.res.mjs";
|
|
8
11
|
import * as PsGatedCommands$ReventlessCore from "./StateChange/PsGatedCommands.res.mjs";
|
|
@@ -27,7 +30,7 @@ let PsGatedCommandsSlice_Spec = {
|
|
|
27
30
|
errorSchema: PsGatedCommands$ReventlessCore.errorSchema,
|
|
28
31
|
eventSchema: PsGatedCommands$ReventlessCore.eventSchema,
|
|
29
32
|
commandSchema: PsGatedCommands$ReventlessCore.commandSchema,
|
|
30
|
-
|
|
33
|
+
authorizationOf: PsGatedCommands$ReventlessCore.authorizationOf,
|
|
31
34
|
commandTransition: PsGatedCommands$ReventlessCore.commandTransition,
|
|
32
35
|
traits: PsGatedCommands$ReventlessCore.traits,
|
|
33
36
|
readConsistency: PsGatedCommands$ReventlessCore.readConsistency
|
|
@@ -175,6 +178,91 @@ globalThis.describe("requiredAccess derived from the authorization rule", () =>
|
|
|
175
178
|
});
|
|
176
179
|
});
|
|
177
180
|
|
|
181
|
+
let moduleUrl = "ps-two-rule-feed://spec";
|
|
182
|
+
|
|
183
|
+
let externalInputSchema = Sury.$schema(s => ({
|
|
184
|
+
sku: s.m(Sury.string)
|
|
185
|
+
}));
|
|
186
|
+
|
|
187
|
+
let commandSchema = Sury.union([
|
|
188
|
+
Sury.$schema(s => ({
|
|
189
|
+
TAG: "AddProduct",
|
|
190
|
+
sku: s.m(Sury.string)
|
|
191
|
+
})),
|
|
192
|
+
Sury.$schema(s => ({
|
|
193
|
+
TAG: "AddCategory",
|
|
194
|
+
sku: s.m(Sury.string)
|
|
195
|
+
}))
|
|
196
|
+
]);
|
|
197
|
+
|
|
198
|
+
function authorizationOf(name) {
|
|
199
|
+
switch (name) {
|
|
200
|
+
case "AddCategory" :
|
|
201
|
+
return {
|
|
202
|
+
TAG: "AllowRoles",
|
|
203
|
+
_0: ["Admin"]
|
|
204
|
+
};
|
|
205
|
+
case "AddProduct" :
|
|
206
|
+
return {
|
|
207
|
+
TAG: "AllowRoles",
|
|
208
|
+
_0: ["Merchandiser"]
|
|
209
|
+
};
|
|
210
|
+
default:
|
|
211
|
+
return "DenyAll";
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
let traits = [];
|
|
216
|
+
|
|
217
|
+
let PsTwoRuleFeed = {
|
|
218
|
+
name: "PsTwoRuleFeed",
|
|
219
|
+
moduleUrl: moduleUrl,
|
|
220
|
+
externalInputSchema: externalInputSchema,
|
|
221
|
+
commandSchema: commandSchema,
|
|
222
|
+
targetName: "AddProduct",
|
|
223
|
+
externalSystem: undefined,
|
|
224
|
+
authorizationOf: authorizationOf,
|
|
225
|
+
traits: traits
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
function translate(param) {
|
|
229
|
+
return {
|
|
230
|
+
TAG: "Ok",
|
|
231
|
+
_0: []
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
let Translation = {
|
|
236
|
+
translate: translate,
|
|
237
|
+
moduleUrl: moduleUrl
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
function make$3(param, param$1, param$2) {
|
|
241
|
+
return 0;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
let PsTwoRuleFeedSlice = {
|
|
245
|
+
Spec: PsTwoRuleFeed,
|
|
246
|
+
Translation: Translation,
|
|
247
|
+
queryDbName: "PsTwoRuleFeedAudit",
|
|
248
|
+
make: make$3
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
globalThis.describe("an inbound slice's roles", () => {
|
|
252
|
+
let door = Dcb_Builder$ReventlessCore.inboundDoorPermission(commandSchema, authorizationOf);
|
|
253
|
+
globalThis.test("the door admits any constructor's roles", () => {
|
|
254
|
+
globalThis.expect(Stdlib_Option.map(door, Authorization$Reventless.rolesOf)).toEqual([
|
|
255
|
+
"Merchandiser",
|
|
256
|
+
"Admin"
|
|
257
|
+
]);
|
|
258
|
+
});
|
|
259
|
+
globalThis.test("requiredRoles are the door's roles", () => {
|
|
260
|
+
let inbound = Plugin_Structure$ReventlessCore.make("AccessPlugin", undefined, undefined, undefined, undefined, undefined, undefined, [PsTwoRuleFeedSlice], undefined, undefined, undefined, undefined, undefined).inboundTranslationSlices[0];
|
|
261
|
+
let doorRoles = Stdlib_Option.map(door, rule => Authorization$Reventless.rolesOf(rule).map(r => r));
|
|
262
|
+
globalThis.expect(Stdlib_Option.flatMap(inbound, s => s.requiredRoles)).toEqual(doorRoles);
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
|
|
178
266
|
export {
|
|
179
267
|
PsGatedCommandsSlice,
|
|
180
268
|
PsGatedViewSlice,
|
|
@@ -182,5 +270,7 @@ export {
|
|
|
182
270
|
structure,
|
|
183
271
|
commandNamed,
|
|
184
272
|
viewNamed,
|
|
273
|
+
PsTwoRuleFeed,
|
|
274
|
+
PsTwoRuleFeedSlice,
|
|
185
275
|
}
|
|
186
276
|
/* structure Not a pure module */
|
|
@@ -53,7 +53,7 @@ let PsPlaceOrderSlice_Spec = {
|
|
|
53
53
|
errorSchema: PsPlaceOrder$ReventlessCore.errorSchema,
|
|
54
54
|
eventSchema: PsPlaceOrder$ReventlessCore.eventSchema,
|
|
55
55
|
commandSchema: PsPlaceOrder$ReventlessCore.commandSchema,
|
|
56
|
-
|
|
56
|
+
authorizationOf: PsPlaceOrder$ReventlessCore.authorizationOf,
|
|
57
57
|
commandTransition: PsPlaceOrder$ReventlessCore.commandTransition,
|
|
58
58
|
traits: PsPlaceOrder$ReventlessCore.traits,
|
|
59
59
|
readConsistency: PsPlaceOrder$ReventlessCore.readConsistency
|
|
@@ -84,7 +84,7 @@ let PsShipOrderSlice_Spec = {
|
|
|
84
84
|
errorSchema: PsShipOrder$ReventlessCore.errorSchema,
|
|
85
85
|
eventSchema: PsShipOrder$ReventlessCore.eventSchema,
|
|
86
86
|
commandSchema: PsShipOrder$ReventlessCore.commandSchema,
|
|
87
|
-
|
|
87
|
+
authorizationOf: PsShipOrder$ReventlessCore.authorizationOf,
|
|
88
88
|
commandTransition: PsShipOrder$ReventlessCore.commandTransition,
|
|
89
89
|
traits: PsShipOrder$ReventlessCore.traits,
|
|
90
90
|
readConsistency: PsShipOrder$ReventlessCore.readConsistency
|
|
@@ -280,7 +280,7 @@ let PsAttachInvoiceSlice_Spec = {
|
|
|
280
280
|
errorSchema: PsAttachInvoice$ReventlessCore.errorSchema,
|
|
281
281
|
eventSchema: PsAttachInvoice$ReventlessCore.eventSchema,
|
|
282
282
|
commandSchema: PsAttachInvoice$ReventlessCore.commandSchema,
|
|
283
|
-
|
|
283
|
+
authorizationOf: PsAttachInvoice$ReventlessCore.authorizationOf,
|
|
284
284
|
commandTransition: PsAttachInvoice$ReventlessCore.commandTransition,
|
|
285
285
|
traits: PsAttachInvoice$ReventlessCore.traits,
|
|
286
286
|
readConsistency: PsAttachInvoice$ReventlessCore.readConsistency
|
|
@@ -311,7 +311,7 @@ let PsUploadAvatarSlice_Spec = {
|
|
|
311
311
|
errorSchema: PsUploadAvatar$ReventlessCore.errorSchema,
|
|
312
312
|
eventSchema: PsUploadAvatar$ReventlessCore.eventSchema,
|
|
313
313
|
commandSchema: PsUploadAvatar$ReventlessCore.commandSchema,
|
|
314
|
-
|
|
314
|
+
authorizationOf: PsUploadAvatar$ReventlessCore.authorizationOf,
|
|
315
315
|
commandTransition: PsUploadAvatar$ReventlessCore.commandTransition,
|
|
316
316
|
traits: PsUploadAvatar$ReventlessCore.traits,
|
|
317
317
|
readConsistency: PsUploadAvatar$ReventlessCore.readConsistency
|
|
@@ -342,7 +342,7 @@ let PsUploadImagesSlice_Spec = {
|
|
|
342
342
|
errorSchema: PsUploadImages$ReventlessCore.errorSchema,
|
|
343
343
|
eventSchema: PsUploadImages$ReventlessCore.eventSchema,
|
|
344
344
|
commandSchema: PsUploadImages$ReventlessCore.commandSchema,
|
|
345
|
-
|
|
345
|
+
authorizationOf: PsUploadImages$ReventlessCore.authorizationOf,
|
|
346
346
|
commandTransition: PsUploadImages$ReventlessCore.commandTransition,
|
|
347
347
|
traits: PsUploadImages$ReventlessCore.traits,
|
|
348
348
|
readConsistency: PsUploadImages$ReventlessCore.readConsistency
|
|
@@ -373,7 +373,7 @@ let PsTypoStoreSlice_Spec = {
|
|
|
373
373
|
errorSchema: PsTypoStore$ReventlessCore.errorSchema,
|
|
374
374
|
eventSchema: PsTypoStore$ReventlessCore.eventSchema,
|
|
375
375
|
commandSchema: PsTypoStore$ReventlessCore.commandSchema,
|
|
376
|
-
|
|
376
|
+
authorizationOf: PsTypoStore$ReventlessCore.authorizationOf,
|
|
377
377
|
commandTransition: PsTypoStore$ReventlessCore.commandTransition,
|
|
378
378
|
traits: PsTypoStore$ReventlessCore.traits,
|
|
379
379
|
readConsistency: PsTypoStore$ReventlessCore.readConsistency
|
|
@@ -404,7 +404,7 @@ let PsChangePhotoSlice_Spec = {
|
|
|
404
404
|
errorSchema: PsChangePhoto$ReventlessCore.errorSchema,
|
|
405
405
|
eventSchema: PsChangePhoto$ReventlessCore.eventSchema,
|
|
406
406
|
commandSchema: PsChangePhoto$ReventlessCore.commandSchema,
|
|
407
|
-
|
|
407
|
+
authorizationOf: PsChangePhoto$ReventlessCore.authorizationOf,
|
|
408
408
|
commandTransition: PsChangePhoto$ReventlessCore.commandTransition,
|
|
409
409
|
traits: PsChangePhoto$ReventlessCore.traits,
|
|
410
410
|
readConsistency: PsChangePhoto$ReventlessCore.readConsistency
|
|
@@ -435,7 +435,7 @@ let PsReserveStockSlice_Spec = {
|
|
|
435
435
|
errorSchema: PsReserveStock$ReventlessCore.errorSchema,
|
|
436
436
|
eventSchema: PsReserveStock$ReventlessCore.eventSchema,
|
|
437
437
|
commandSchema: PsReserveStock$ReventlessCore.commandSchema,
|
|
438
|
-
|
|
438
|
+
authorizationOf: PsReserveStock$ReventlessCore.authorizationOf,
|
|
439
439
|
commandTransition: PsReserveStock$ReventlessCore.commandTransition,
|
|
440
440
|
traits: PsReserveStock$ReventlessCore.traits,
|
|
441
441
|
readConsistency: PsReserveStock$ReventlessCore.readConsistency
|
|
@@ -466,7 +466,7 @@ let PsDispatchShipmentSlice_Spec = {
|
|
|
466
466
|
errorSchema: PsDispatchShipment$ReventlessCore.errorSchema,
|
|
467
467
|
eventSchema: PsDispatchShipment$ReventlessCore.eventSchema,
|
|
468
468
|
commandSchema: PsDispatchShipment$ReventlessCore.commandSchema,
|
|
469
|
-
|
|
469
|
+
authorizationOf: PsDispatchShipment$ReventlessCore.authorizationOf,
|
|
470
470
|
commandTransition: PsDispatchShipment$ReventlessCore.commandTransition,
|
|
471
471
|
traits: PsDispatchShipment$ReventlessCore.traits,
|
|
472
472
|
readConsistency: PsDispatchShipment$ReventlessCore.readConsistency
|
|
@@ -497,7 +497,7 @@ let PsTransitionSwitchSlice_Spec = {
|
|
|
497
497
|
errorSchema: PsTransitionSwitch$ReventlessCore.errorSchema,
|
|
498
498
|
eventSchema: PsTransitionSwitch$ReventlessCore.eventSchema,
|
|
499
499
|
commandSchema: PsTransitionSwitch$ReventlessCore.commandSchema,
|
|
500
|
-
|
|
500
|
+
authorizationOf: PsTransitionSwitch$ReventlessCore.authorizationOf,
|
|
501
501
|
commandTransition: PsTransitionSwitch$ReventlessCore.commandTransition,
|
|
502
502
|
traits: PsTransitionSwitch$ReventlessCore.traits,
|
|
503
503
|
readConsistency: PsTransitionSwitch$ReventlessCore.readConsistency
|
|
@@ -32,7 +32,7 @@ function decide(_state, _command) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
function
|
|
35
|
+
function authorizationOf(param) {
|
|
36
36
|
return "AllowAuthenticated";
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -63,7 +63,7 @@ export {
|
|
|
63
63
|
eventSchema,
|
|
64
64
|
decide,
|
|
65
65
|
moduleUrl,
|
|
66
|
-
|
|
66
|
+
authorizationOf,
|
|
67
67
|
readConsistency,
|
|
68
68
|
commandTransition,
|
|
69
69
|
traits,
|
|
@@ -33,7 +33,7 @@ function decide(_state, _command) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
function
|
|
36
|
+
function authorizationOf(param) {
|
|
37
37
|
return "AllowAuthenticated";
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -64,7 +64,7 @@ export {
|
|
|
64
64
|
eventSchema,
|
|
65
65
|
decide,
|
|
66
66
|
moduleUrl,
|
|
67
|
-
|
|
67
|
+
authorizationOf,
|
|
68
68
|
readConsistency,
|
|
69
69
|
commandTransition,
|
|
70
70
|
traits,
|
|
@@ -39,7 +39,7 @@ function commandTransition(command) {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
function
|
|
42
|
+
function authorizationOf(param) {
|
|
43
43
|
return "AllowAuthenticated";
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -67,7 +67,7 @@ export {
|
|
|
67
67
|
decide,
|
|
68
68
|
commandTransition,
|
|
69
69
|
moduleUrl,
|
|
70
|
-
|
|
70
|
+
authorizationOf,
|
|
71
71
|
readConsistency,
|
|
72
72
|
traits,
|
|
73
73
|
}
|
|
@@ -45,8 +45,8 @@ function decide(_state, _command) {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
function
|
|
49
|
-
if (
|
|
48
|
+
function authorizationOf(name) {
|
|
49
|
+
if (name === "Restock") {
|
|
50
50
|
return {
|
|
51
51
|
TAG: "AllowRoles",
|
|
52
52
|
_0: [
|
|
@@ -87,7 +87,7 @@ export {
|
|
|
87
87
|
eventSchema,
|
|
88
88
|
decide,
|
|
89
89
|
moduleUrl,
|
|
90
|
-
|
|
90
|
+
authorizationOf,
|
|
91
91
|
readConsistency,
|
|
92
92
|
commandTransition,
|
|
93
93
|
traits,
|
|
@@ -31,7 +31,7 @@ function decide(_state, _command) {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
function
|
|
34
|
+
function authorizationOf(param) {
|
|
35
35
|
return "AllowAuthenticated";
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -62,7 +62,7 @@ export {
|
|
|
62
62
|
eventSchema,
|
|
63
63
|
decide,
|
|
64
64
|
moduleUrl,
|
|
65
|
-
|
|
65
|
+
authorizationOf,
|
|
66
66
|
readConsistency,
|
|
67
67
|
commandTransition,
|
|
68
68
|
traits,
|
|
@@ -42,7 +42,7 @@ function decide(_state, _command) {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
function
|
|
45
|
+
function authorizationOf(param) {
|
|
46
46
|
return "AllowAuthenticated";
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -74,7 +74,7 @@ export {
|
|
|
74
74
|
eventSchema,
|
|
75
75
|
decide,
|
|
76
76
|
moduleUrl,
|
|
77
|
-
|
|
77
|
+
authorizationOf,
|
|
78
78
|
readConsistency,
|
|
79
79
|
commandTransition,
|
|
80
80
|
traits,
|
|
@@ -59,7 +59,7 @@ function commandTransition(command) {
|
|
|
59
59
|
|
|
60
60
|
let commandSchema$1 = Api$ReventlessInfra.markNoApiVariants(commandSchema, ["CancelShipment"]);
|
|
61
61
|
|
|
62
|
-
function
|
|
62
|
+
function authorizationOf(param) {
|
|
63
63
|
return "AllowAuthenticated";
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -87,7 +87,7 @@ export {
|
|
|
87
87
|
commandTransition,
|
|
88
88
|
commandSchema$1 as commandSchema,
|
|
89
89
|
moduleUrl,
|
|
90
|
-
|
|
90
|
+
authorizationOf,
|
|
91
91
|
readConsistency,
|
|
92
92
|
traits,
|
|
93
93
|
}
|
|
@@ -71,7 +71,7 @@ let traits = [{
|
|
|
71
71
|
posture: "SelfContained"
|
|
72
72
|
}];
|
|
73
73
|
|
|
74
|
-
function
|
|
74
|
+
function authorizationOf(param) {
|
|
75
75
|
return "AllowAuthenticated";
|
|
76
76
|
}
|
|
77
77
|
|
|
@@ -98,7 +98,7 @@ export {
|
|
|
98
98
|
commandTransition,
|
|
99
99
|
traits,
|
|
100
100
|
moduleUrl,
|
|
101
|
-
|
|
101
|
+
authorizationOf,
|
|
102
102
|
readConsistency,
|
|
103
103
|
}
|
|
104
104
|
/* consumedEventSchema Not a pure module */
|