@reventlessdev/reventless-local 3.0.0-alpha.282 → 3.0.0-alpha.283
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 +11 -0
- package/package.json +9 -9
- package/src/Platform.res +3 -3
- package/src/Platform.res.mjs +10 -10
- package/src/adapter/CommandGenerator/CommandGeneratorResolvers_GraphQL.res +6 -25
- package/src/adapter/CommandGenerator/CommandGeneratorResolvers_GraphQL.res.mjs +4 -20
- package/src/adapter/PlatformGraphQL_Server.res +1 -1
- package/tests/adapter/CommandAuthorizationTest.res +7 -8
- package/tests/adapter/CommandAuthorizationTest.res.mjs +5 -5
- package/tests/adapter/InboundTranslationMutationTest.res +1 -1
- package/tests/adapter/InboundTranslationMutationTest.res.mjs +3 -3
- package/tests/components/aggregate/AggregateFixtures.res.mjs +3 -3
- package/tests/components/aggregate/AggregateSelfMappingFixtures.res.mjs +3 -3
- package/tests/components/automationslice/AutomationSliceFixtures.res.mjs +4 -4
- package/tests/components/automationslice/AutomationSliceSelfDeadlockFixtures.res.mjs +8 -8
- package/tests/components/automationslice/MixedSourceAutomationSliceFixtures.res.mjs +2 -2
- package/tests/components/commandgenerator/CommandGeneratorFixtures.res.mjs +3 -3
- package/tests/components/commandtopic/CommandTopicFixtures.res.mjs +2 -2
- package/tests/components/commandtopic/CommandTopicStreamFixtures.res.mjs +2 -2
- package/tests/components/dcb/DcbCrossPartitionFixtures.res.mjs +3 -3
- package/tests/components/dcb/DcbFixtures.res.mjs +3 -3
- package/tests/components/extensionpoint/ExtensionPointFixtures.res.mjs +5 -5
- package/tests/components/inboundtranslationslice/InboundTranslationSliceCallbackTest.res +2 -2
- package/tests/components/inboundtranslationslice/InboundTranslationSliceCallbackTest.res.mjs +7 -7
- package/tests/components/inboundtranslationslice/InboundTranslationSliceFixtures.res +5 -4
- package/tests/components/inboundtranslationslice/InboundTranslationSliceFixtures.res.mjs +19 -16
- package/tests/components/outboundtranslationslice/OutboundTranslationSlicePlatformFixtures.res.mjs +3 -3
- package/tests/components/readmodel/DcbReadModelE2EFixtures.res.mjs +3 -3
- package/tests/plugin/PluginBehavior_GWT.res.mjs +2 -2
- package/tests/plugin/UiFragmentRegistry_GWT.res.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.283 (2026-10-10)
|
|
7
|
+
|
|
8
|
+
* feat!: a command's rule is looked up by its name, without a cast ([5f02c40](https://github.com/ReventlessDev/reventless-core/commit/5f02c4081d077bf4a6951d8c9b2b16553a8ca87b))
|
|
9
|
+
|
|
10
|
+
### BREAKING CHANGES
|
|
11
|
+
|
|
12
|
+
* a spec that writes `commandAuthorization` by hand writes
|
|
13
|
+
`authorizationOf = (name: string) => …` instead; the PPX refuses the old name.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# 3.0.0-alpha.282 (2026-10-10)
|
|
7
18
|
|
|
8
19
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reventlessdev/reventless-local",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.283",
|
|
4
4
|
"description": "Local platform for Reventless (in-memory or SQLite backend, for development and testing without AWS)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"bin": {
|
|
@@ -37,21 +37,21 @@
|
|
|
37
37
|
"@reventlessdev/rescript-effect": "0.1.0-alpha.34",
|
|
38
38
|
"@reventlessdev/rescript-graphql-yoga": "1.0.0-alpha.29",
|
|
39
39
|
"@reventlessdev/rescript-jest": "1.0.0-alpha.11",
|
|
40
|
-
"@reventlessdev/rescript-mcp-sdk": "1.0.0-alpha.23",
|
|
41
40
|
"@reventlessdev/rescript-node": "2.0.0-alpha.22",
|
|
41
|
+
"@reventlessdev/rescript-mcp-sdk": "1.0.0-alpha.23",
|
|
42
42
|
"@reventlessdev/rescript-pulumi-pulumi": "2.3.0-alpha.23",
|
|
43
|
-
"@reventlessdev/reventless-
|
|
44
|
-
"@reventlessdev/reventless-
|
|
45
|
-
"@reventlessdev/reventless-gwt": "1.0.0-alpha.
|
|
43
|
+
"@reventlessdev/reventless-graphql-server": "1.0.0-alpha.141",
|
|
44
|
+
"@reventlessdev/reventless-core": "3.0.0-alpha.293",
|
|
45
|
+
"@reventlessdev/reventless-gwt": "1.0.0-alpha.240",
|
|
46
|
+
"@reventlessdev/reventless-infra": "3.0.0-alpha.190",
|
|
46
47
|
"@reventlessdev/reventless-seed": "1.0.0-alpha.33",
|
|
47
|
-
"@reventlessdev/reventless-
|
|
48
|
-
"@reventlessdev/reventless-postgres": "3.0.0-alpha.
|
|
49
|
-
"@reventlessdev/reventless-spec": "3.0.0-alpha.161"
|
|
48
|
+
"@reventlessdev/reventless-spec": "3.0.0-alpha.162",
|
|
49
|
+
"@reventlessdev/reventless-postgres": "3.0.0-alpha.157"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"rescript": "12.3.1",
|
|
53
53
|
"sury-ppx": "11.0.0",
|
|
54
|
-
"@reventlessdev/reventless-ppx": "1.0.0-alpha.
|
|
54
|
+
"@reventlessdev/reventless-ppx": "1.0.0-alpha.99"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"rescript": "^12.3.1"
|
package/src/Platform.res
CHANGED
|
@@ -290,14 +290,14 @@ module MakeWithConfig = (
|
|
|
290
290
|
deployTarget: ref("Domain"),
|
|
291
291
|
// Phase 1: register SDL + resolver stub synchronously.
|
|
292
292
|
// Pass the resolved server so the correct target (domain or platform) receives the schema.
|
|
293
|
-
mutationResolverHook: (~kind, ~fields, ~commandSchema, ~
|
|
293
|
+
mutationResolverHook: (~kind, ~fields, ~commandSchema, ~authorizationOf) => {
|
|
294
294
|
let server = resolveTargetGraphQL()
|
|
295
295
|
switch kind {
|
|
296
296
|
| ReventlessCore.Plugin_Helpers.Aggregate =>
|
|
297
297
|
CommandGeneratorResolvers_GraphQL.register(
|
|
298
298
|
~fields,
|
|
299
299
|
~commandSchema,
|
|
300
|
-
~
|
|
300
|
+
~authorizationOf,
|
|
301
301
|
~server,
|
|
302
302
|
)
|
|
303
303
|
| Dcb =>
|
|
@@ -305,7 +305,7 @@ module MakeWithConfig = (
|
|
|
305
305
|
CommandGeneratorResolvers_GraphQL.registerDcb(
|
|
306
306
|
~fieldName=field,
|
|
307
307
|
~commandSchema,
|
|
308
|
-
~
|
|
308
|
+
~authorizationOf,
|
|
309
309
|
~server,
|
|
310
310
|
)
|
|
311
311
|
)
|
package/src/Platform.res.mjs
CHANGED
|
@@ -225,12 +225,12 @@ function MakeWithConfig(Config) {
|
|
|
225
225
|
}
|
|
226
226
|
};
|
|
227
227
|
let EventHistoryResolvers = EventHistoryResolvers_GraphQL$ReventlessLocal.Make(Bus);
|
|
228
|
-
let hooks_mutationResolverHook = (kind, fields, commandSchema,
|
|
228
|
+
let hooks_mutationResolverHook = (kind, fields, commandSchema, authorizationOf) => {
|
|
229
229
|
let server = resolveTargetGraphQL();
|
|
230
230
|
if (kind === "Aggregate") {
|
|
231
|
-
return CommandGeneratorResolvers_GraphQL$ReventlessLocal.register(fields, commandSchema,
|
|
231
|
+
return CommandGeneratorResolvers_GraphQL$ReventlessLocal.register(fields, commandSchema, authorizationOf, server);
|
|
232
232
|
}
|
|
233
|
-
fields.forEach(field => CommandGeneratorResolvers_GraphQL$ReventlessLocal.registerDcb(field, commandSchema,
|
|
233
|
+
fields.forEach(field => CommandGeneratorResolvers_GraphQL$ReventlessLocal.registerDcb(field, commandSchema, authorizationOf, server));
|
|
234
234
|
};
|
|
235
235
|
let hooks_mutationBindHook = CommandGeneratorResolvers_GraphQL$ReventlessLocal.bindHandler;
|
|
236
236
|
let hooks_inboundMutationResolverHook = (fieldName, externalInputSchema, permission) => InboundTranslationResolvers_GraphQL$ReventlessLocal.register(fieldName, externalInputSchema, permission, resolveTargetGraphQL());
|
|
@@ -649,7 +649,7 @@ function MakeWithConfig(Config) {
|
|
|
649
649
|
errorSchema: UiFragmentRegistry$ReventlessCore.errorSchema,
|
|
650
650
|
eventSchema: UiFragmentRegistry$ReventlessCore.eventSchema,
|
|
651
651
|
commandSchema: UiFragmentRegistry$ReventlessCore.commandSchema,
|
|
652
|
-
|
|
652
|
+
authorizationOf: UiFragmentRegistry$ReventlessCore.authorizationOf,
|
|
653
653
|
commandTransition: UiFragmentRegistry$ReventlessCore.commandTransition,
|
|
654
654
|
traits: UiFragmentRegistry$ReventlessCore.traits,
|
|
655
655
|
readConsistency: UiFragmentRegistry$ReventlessCore.readConsistency
|
|
@@ -761,7 +761,7 @@ function MakeWithConfig(Config) {
|
|
|
761
761
|
errorSchema: PluginSpec$ReventlessCore.errorSchema,
|
|
762
762
|
commandSchema: PluginSpec$ReventlessCore.commandSchema,
|
|
763
763
|
moduleUrl: PluginSpec$ReventlessCore.moduleUrl,
|
|
764
|
-
|
|
764
|
+
authorizationOf: PluginSpec$ReventlessCore.authorizationOf,
|
|
765
765
|
commandTransition: PluginSpec$ReventlessCore.commandTransition,
|
|
766
766
|
traits: PluginSpec$ReventlessCore.traits
|
|
767
767
|
})({
|
|
@@ -1985,12 +1985,12 @@ function Make($star) {
|
|
|
1985
1985
|
}
|
|
1986
1986
|
};
|
|
1987
1987
|
let EventHistoryResolvers = EventHistoryResolvers_GraphQL$ReventlessLocal.Make(Bus);
|
|
1988
|
-
let hooks_mutationResolverHook = (kind, fields, commandSchema,
|
|
1988
|
+
let hooks_mutationResolverHook = (kind, fields, commandSchema, authorizationOf) => {
|
|
1989
1989
|
let server = resolveTargetGraphQL();
|
|
1990
1990
|
if (kind === "Aggregate") {
|
|
1991
|
-
return CommandGeneratorResolvers_GraphQL$ReventlessLocal.register(fields, commandSchema,
|
|
1991
|
+
return CommandGeneratorResolvers_GraphQL$ReventlessLocal.register(fields, commandSchema, authorizationOf, server);
|
|
1992
1992
|
}
|
|
1993
|
-
fields.forEach(field => CommandGeneratorResolvers_GraphQL$ReventlessLocal.registerDcb(field, commandSchema,
|
|
1993
|
+
fields.forEach(field => CommandGeneratorResolvers_GraphQL$ReventlessLocal.registerDcb(field, commandSchema, authorizationOf, server));
|
|
1994
1994
|
};
|
|
1995
1995
|
let hooks_mutationBindHook = CommandGeneratorResolvers_GraphQL$ReventlessLocal.bindHandler;
|
|
1996
1996
|
let hooks_inboundMutationResolverHook = (fieldName, externalInputSchema, permission) => InboundTranslationResolvers_GraphQL$ReventlessLocal.register(fieldName, externalInputSchema, permission, resolveTargetGraphQL());
|
|
@@ -2409,7 +2409,7 @@ function Make($star) {
|
|
|
2409
2409
|
errorSchema: UiFragmentRegistry$ReventlessCore.errorSchema,
|
|
2410
2410
|
eventSchema: UiFragmentRegistry$ReventlessCore.eventSchema,
|
|
2411
2411
|
commandSchema: UiFragmentRegistry$ReventlessCore.commandSchema,
|
|
2412
|
-
|
|
2412
|
+
authorizationOf: UiFragmentRegistry$ReventlessCore.authorizationOf,
|
|
2413
2413
|
commandTransition: UiFragmentRegistry$ReventlessCore.commandTransition,
|
|
2414
2414
|
traits: UiFragmentRegistry$ReventlessCore.traits,
|
|
2415
2415
|
readConsistency: UiFragmentRegistry$ReventlessCore.readConsistency
|
|
@@ -2521,7 +2521,7 @@ function Make($star) {
|
|
|
2521
2521
|
errorSchema: PluginSpec$ReventlessCore.errorSchema,
|
|
2522
2522
|
commandSchema: PluginSpec$ReventlessCore.commandSchema,
|
|
2523
2523
|
moduleUrl: PluginSpec$ReventlessCore.moduleUrl,
|
|
2524
|
-
|
|
2524
|
+
authorizationOf: PluginSpec$ReventlessCore.authorizationOf,
|
|
2525
2525
|
commandTransition: PluginSpec$ReventlessCore.commandTransition,
|
|
2526
2526
|
traits: PluginSpec$ReventlessCore.traits
|
|
2527
2527
|
})({
|
|
@@ -83,17 +83,6 @@ let checkPluginStatus = (~field: string): option<JSON.t> =>
|
|
|
83
83
|
| None => None
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
// Build a synthetic command value sufficient for evaluating
|
|
87
|
-
// `commandAuthorization`. ReScript variants with record payloads compile to
|
|
88
|
-
// `{TAG: cname, ...payload}` and the PPX-generated switch matches `Ctor(_)`
|
|
89
|
-
// which only checks `command.TAG === cname`. Payload-less constructors
|
|
90
|
-
// compile to bare string literals and the switch matches them with
|
|
91
|
-
// `command === "Cname"`, so the synthetic value must be a bare string in
|
|
92
|
-
// that case — otherwise the wildcard branch (file-level default) wins
|
|
93
|
-
// instead of the per-constructor rule.
|
|
94
|
-
let syntheticCommand = (cname: string, ~hasPayload: bool): unknown =>
|
|
95
|
-
hasPayload ? {"TAG": cname}->Obj.magic : cname->Obj.magic
|
|
96
|
-
|
|
97
86
|
let capitalize = s => s->String.charAt(0)->String.toUpperCase ++ s->String.slice(~start=1)
|
|
98
87
|
|
|
99
88
|
// -- CommandResult SDL types --------------------------------------------------
|
|
@@ -139,7 +128,7 @@ let extractVariantSchema = (commandSchema: S.t<unknown>, ~index=0) =>
|
|
|
139
128
|
// stale `_0` payload arg into the SDL. Looking up by name avoids that.
|
|
140
129
|
let variantIndexForField = (commandSchema: S.t<unknown>, ~field: string): int => {
|
|
141
130
|
let cname = extractCommandName(field)
|
|
142
|
-
let allNames = Reventless.DcbTag.extractAllVariantNames(commandSchema
|
|
131
|
+
let allNames = Reventless.DcbTag.extractAllVariantNames(commandSchema)
|
|
143
132
|
allNames->Array.indexOf(cname)
|
|
144
133
|
}
|
|
145
134
|
|
|
@@ -188,7 +177,7 @@ let runCommand = async (
|
|
|
188
177
|
let register = (
|
|
189
178
|
~fields: array<string>,
|
|
190
179
|
~commandSchema: S.t<unknown>,
|
|
191
|
-
~
|
|
180
|
+
~authorizationOf: string => Reventless.Authorization.permission,
|
|
192
181
|
~server: ReventlessGraphqlServer.GraphQL_ServerInstance.t,
|
|
193
182
|
) => {
|
|
194
183
|
ensureCommandResultTypes(server)
|
|
@@ -210,13 +199,6 @@ let register = (
|
|
|
210
199
|
fields->Array.forEach(field => {
|
|
211
200
|
let handlerRef = ref(None)
|
|
212
201
|
handlerRefs->Dict.set(field, handlerRef)
|
|
213
|
-
// hasPayload is fixed per field — capture once at registration time so
|
|
214
|
-
// the resolver doesn't re-walk the schema per request.
|
|
215
|
-
let variantIndex = variantIndexForField(commandSchema, ~field)
|
|
216
|
-
let hasPayload = switch extractVariantSchema(commandSchema, ~index=variantIndex) {
|
|
217
|
-
| Object(_) => true
|
|
218
|
-
| _ => false
|
|
219
|
-
}
|
|
220
202
|
let commandName = extractCommandName(field)
|
|
221
203
|
let resolver: ReventlessGraphqlServer.GraphQL_ServerInstance.resolverFn = async (
|
|
222
204
|
_root,
|
|
@@ -229,7 +211,7 @@ let register = (
|
|
|
229
211
|
| Some(rejected) => rejected
|
|
230
212
|
| None =>
|
|
231
213
|
let identity = extractIdentity(ctx)
|
|
232
|
-
let rule =
|
|
214
|
+
let rule = authorizationOf(commandName)
|
|
233
215
|
if !Reventless.Authorization.isAllowed(rule, identity) {
|
|
234
216
|
rejectForbidden(~field)
|
|
235
217
|
} else {
|
|
@@ -262,7 +244,7 @@ let register = (
|
|
|
262
244
|
let registerDcb = (
|
|
263
245
|
~fieldName: string,
|
|
264
246
|
~commandSchema: S.t<unknown>,
|
|
265
|
-
~
|
|
247
|
+
~authorizationOf: string => Reventless.Authorization.permission,
|
|
266
248
|
~server: ReventlessGraphqlServer.GraphQL_ServerInstance.t,
|
|
267
249
|
) => {
|
|
268
250
|
ensureCommandResultTypes(server)
|
|
@@ -271,7 +253,7 @@ let registerDcb = (
|
|
|
271
253
|
// constructor (slice name == constructor); a multi-command slice's `Plugin_Ctor`
|
|
272
254
|
// resolves to `Ctor`. Position 0 was previously hardcoded, which dropped every
|
|
273
255
|
// non-first constructor of a multi-command slice.
|
|
274
|
-
let constructorNames = Reventless.DcbTag.extractAllVariantNames(commandSchema
|
|
256
|
+
let constructorNames = Reventless.DcbTag.extractAllVariantNames(commandSchema)
|
|
275
257
|
let variantIndex = variantIndexForField(commandSchema, ~field=fieldName)
|
|
276
258
|
let variantSchema = extractVariantSchema(
|
|
277
259
|
commandSchema,
|
|
@@ -284,7 +266,6 @@ let registerDcb = (
|
|
|
284
266
|
(
|
|
285
267
|
variantIndex >= 0 ? constructorNames->Array.get(variantIndex) : constructorNames->Array.get(0)
|
|
286
268
|
)->Option.getOr(fieldName)
|
|
287
|
-
let hasPayload = Reventless.DcbTag.isVariantPayloadBearing(commandSchema->Obj.magic, tag)
|
|
288
269
|
|
|
289
270
|
let handlerRef = ref(None)
|
|
290
271
|
handlerRefs->Dict.set(fieldName, handlerRef)
|
|
@@ -300,7 +281,7 @@ let registerDcb = (
|
|
|
300
281
|
| Some(rejected) => rejected
|
|
301
282
|
| None =>
|
|
302
283
|
let identity = extractIdentity(ctx)
|
|
303
|
-
let rule =
|
|
284
|
+
let rule = authorizationOf(tag)
|
|
304
285
|
if !Reventless.Authorization.isAllowed(rule, identity) {
|
|
305
286
|
rejectForbidden(~field=fieldName)
|
|
306
287
|
} else {
|
|
@@ -93,16 +93,6 @@ function checkPluginStatus(field) {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
function syntheticCommand(cname, hasPayload) {
|
|
97
|
-
if (hasPayload) {
|
|
98
|
-
return {
|
|
99
|
-
TAG: cname
|
|
100
|
-
};
|
|
101
|
-
} else {
|
|
102
|
-
return cname;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
96
|
function capitalize(s) {
|
|
107
97
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
108
98
|
}
|
|
@@ -156,7 +146,7 @@ async function runCommand(generateCommand, payload) {
|
|
|
156
146
|
}
|
|
157
147
|
}
|
|
158
148
|
|
|
159
|
-
function register(fields, commandSchema,
|
|
149
|
+
function register(fields, commandSchema, authorizationOf, server) {
|
|
160
150
|
server.registerTypes([commandResultSdl]);
|
|
161
151
|
let sdlFields = fields.map(field => {
|
|
162
152
|
let variantIndex = variantIndexForField(commandSchema, field);
|
|
@@ -173,10 +163,6 @@ function register(fields, commandSchema, commandAuthorization, server) {
|
|
|
173
163
|
contents: undefined
|
|
174
164
|
};
|
|
175
165
|
handlerRefs[field] = handlerRef;
|
|
176
|
-
let variantIndex = variantIndexForField(commandSchema, field);
|
|
177
|
-
let match = extractVariantSchema(commandSchema, variantIndex);
|
|
178
|
-
let hasPayload;
|
|
179
|
-
hasPayload = match.type === "object";
|
|
180
166
|
let commandName = extractCommandName(field);
|
|
181
167
|
let resolver = async (_root, args, ctx) => {
|
|
182
168
|
let generateCommand = handlerRef.contents;
|
|
@@ -188,7 +174,7 @@ function register(fields, commandSchema, commandAuthorization, server) {
|
|
|
188
174
|
return rejected;
|
|
189
175
|
}
|
|
190
176
|
let identity = extractIdentity(ctx);
|
|
191
|
-
let rule =
|
|
177
|
+
let rule = authorizationOf(commandName);
|
|
192
178
|
if (!Authorization$Reventless.isAllowed(rule, identity)) {
|
|
193
179
|
return rejectForbidden(field);
|
|
194
180
|
}
|
|
@@ -210,14 +196,13 @@ function register(fields, commandSchema, commandAuthorization, server) {
|
|
|
210
196
|
server.registerMutations(sdlFields, resolvers);
|
|
211
197
|
}
|
|
212
198
|
|
|
213
|
-
function registerDcb(fieldName, commandSchema,
|
|
199
|
+
function registerDcb(fieldName, commandSchema, authorizationOf, server) {
|
|
214
200
|
server.registerTypes([commandResultSdl]);
|
|
215
201
|
let constructorNames = DcbTag$Reventless.extractAllVariantNames(commandSchema);
|
|
216
202
|
let variantIndex = variantIndexForField(commandSchema, fieldName);
|
|
217
203
|
let variantSchema = extractVariantSchema(commandSchema, variantIndex >= 0 ? variantIndex : 0);
|
|
218
204
|
let sdlFields = [deriveSdlField(fieldName, variantSchema)];
|
|
219
205
|
let tag = Stdlib_Option.getOr(variantIndex >= 0 ? constructorNames[variantIndex] : constructorNames[0], fieldName);
|
|
220
|
-
let hasPayload = DcbTag$Reventless.isVariantPayloadBearing(commandSchema, tag);
|
|
221
206
|
let handlerRef = {
|
|
222
207
|
contents: undefined
|
|
223
208
|
};
|
|
@@ -232,7 +217,7 @@ function registerDcb(fieldName, commandSchema, commandAuthorization, server) {
|
|
|
232
217
|
return rejected;
|
|
233
218
|
}
|
|
234
219
|
let identity = extractIdentity(ctx);
|
|
235
|
-
let rule =
|
|
220
|
+
let rule = authorizationOf(tag);
|
|
236
221
|
if (!Authorization$Reventless.isAllowed(rule, identity)) {
|
|
237
222
|
return rejectForbidden(fieldName);
|
|
238
223
|
}
|
|
@@ -296,7 +281,6 @@ export {
|
|
|
296
281
|
resetPluginStatusGate,
|
|
297
282
|
rejectPluginStatus,
|
|
298
283
|
checkPluginStatus,
|
|
299
|
-
syntheticCommand,
|
|
300
284
|
capitalize,
|
|
301
285
|
commandResultSdl,
|
|
302
286
|
ensureCommandResultTypes,
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// failure, and cannot afford to read it as a session that has ended.
|
|
22
22
|
//
|
|
23
23
|
// Mutations are wrapped (in addition to their per-command
|
|
24
|
-
// `
|
|
24
|
+
// `authorizationOf` rule inside `CommandGeneratorResolvers_GraphQL.register`)
|
|
25
25
|
// because the per-command rule defaults to `AllowAuthenticated` and the
|
|
26
26
|
// in-memory adapter falls back to `defaultUser` on missing-bearer requests
|
|
27
27
|
// — without the wrapper, anonymous callers could trigger admin mutations
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// constructor `Add({name})` defaulting to AllowAuthenticated, plus a
|
|
4
4
|
// payload-less `Archive` constrained to AllowRoles([Admin]).
|
|
5
5
|
//
|
|
6
|
-
// The PPX emits
|
|
6
|
+
// The PPX emits an `authorizationOf` switch at compile time (see
|
|
7
7
|
// examples/online-shop-hybrid/catalog/.../Category.res.mjs). This test hand-
|
|
8
8
|
// writes an equivalent switch and feeds it through the live resolver path
|
|
9
9
|
// (CommandGeneratorResolvers_GraphQL.register), so the test covers the same
|
|
@@ -25,11 +25,10 @@ type command =
|
|
|
25
25
|
|
|
26
26
|
// Matches the shape the PPX emits for `@authorize(AllowRoles([Admin]))` on
|
|
27
27
|
// the payload-less `Archive` constructor with a file-level default.
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
AllowAuthenticated
|
|
28
|
+
let authorizationOf = (name: string): Reventless.Authorization.permission =>
|
|
29
|
+
switch name {
|
|
30
|
+
| "Archive" => AllowRoles([Reventless.Role.make("Admin")])
|
|
31
|
+
| _ => AllowAuthenticated
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
// ── Identity fixtures ────────────────────────────────────────────────────────
|
|
@@ -84,7 +83,7 @@ let buildFixture = (~namespace: string) => {
|
|
|
84
83
|
CommandGeneratorResolvers_GraphQL.register(
|
|
85
84
|
~fields=[addField, renameField, archiveField],
|
|
86
85
|
~commandSchema=commandSchema->S.castToUnknown,
|
|
87
|
-
~
|
|
86
|
+
~authorizationOf,
|
|
88
87
|
~server,
|
|
89
88
|
)
|
|
90
89
|
|
|
@@ -242,7 +241,7 @@ let failingFixture = (~namespace: string, ~failWith: unit => unit) => {
|
|
|
242
241
|
CommandGeneratorResolvers_GraphQL.register(
|
|
243
242
|
~fields=[field],
|
|
244
243
|
~commandSchema=commandSchema->S.castToUnknown,
|
|
245
|
-
~
|
|
244
|
+
~authorizationOf,
|
|
246
245
|
~server,
|
|
247
246
|
)
|
|
248
247
|
let generateCommand: ReventlessCore.CommandGenerator.commandGenerator = _payload =>
|
|
@@ -28,8 +28,8 @@ let commandSchema = Sury.union([
|
|
|
28
28
|
Sury.literal("Archive")
|
|
29
29
|
]);
|
|
30
30
|
|
|
31
|
-
function
|
|
32
|
-
if (
|
|
31
|
+
function authorizationOf(name) {
|
|
32
|
+
if (name === "Archive") {
|
|
33
33
|
return {
|
|
34
34
|
TAG: "AllowRoles",
|
|
35
35
|
_0: ["Admin"]
|
|
@@ -91,7 +91,7 @@ function buildFixture(namespace) {
|
|
|
91
91
|
addField,
|
|
92
92
|
renameField,
|
|
93
93
|
archiveField
|
|
94
|
-
], commandSchema,
|
|
94
|
+
], commandSchema, authorizationOf, DomainGraphQL_Server$ReventlessLocal.asInterface);
|
|
95
95
|
let stubGenerateCommand = payload => Effect.promise(() => {
|
|
96
96
|
calls.contents.push(payload.command);
|
|
97
97
|
return Promise.resolve({
|
|
@@ -203,7 +203,7 @@ globalThis.describe("CommandGeneratorResolvers_GraphQL — per-constructor autho
|
|
|
203
203
|
|
|
204
204
|
function failingFixture(namespace, failWith) {
|
|
205
205
|
let field = namespace + `_Add`;
|
|
206
|
-
CommandGeneratorResolvers_GraphQL$ReventlessLocal.register([field], commandSchema,
|
|
206
|
+
CommandGeneratorResolvers_GraphQL$ReventlessLocal.register([field], commandSchema, authorizationOf, DomainGraphQL_Server$ReventlessLocal.asInterface);
|
|
207
207
|
let generateCommand = _payload => Effect.promise(() => {
|
|
208
208
|
failWith();
|
|
209
209
|
return Promise.resolve({
|
|
@@ -260,7 +260,7 @@ globalThis.describe("CommandGeneratorResolvers_GraphQL — a failure the caller
|
|
|
260
260
|
|
|
261
261
|
export {
|
|
262
262
|
commandSchema,
|
|
263
|
-
|
|
263
|
+
authorizationOf,
|
|
264
264
|
adminIdentity,
|
|
265
265
|
userIdentity,
|
|
266
266
|
ctxFor,
|
|
@@ -190,7 +190,7 @@ describe("InboundTranslationSlice mutation — the door", () => {
|
|
|
190
190
|
~externalInputSchema=CatalogFeedSpec.externalInputSchema->S.castToUnknown,
|
|
191
191
|
~permission=?ReventlessCore.Dcb_Builder.inboundDoorPermission(
|
|
192
192
|
CatalogFeedSpec.commandSchema,
|
|
193
|
-
CatalogFeedSpec.
|
|
193
|
+
CatalogFeedSpec.authorizationOf,
|
|
194
194
|
),
|
|
195
195
|
~server=DomainGraphQL_Server.asInterface,
|
|
196
196
|
)
|
|
@@ -29,7 +29,7 @@ let Callback = InboundTranslationSlice_Callback$ReventlessCore.Make({
|
|
|
29
29
|
commandSchema: InboundTranslationSliceFixtures$ReventlessLocal.PaymentWebhookSpec.commandSchema,
|
|
30
30
|
targetName: InboundTranslationSliceFixtures$ReventlessLocal.PaymentWebhookSpec.targetName,
|
|
31
31
|
externalSystem: InboundTranslationSliceFixtures$ReventlessLocal.PaymentWebhookSpec.externalSystem,
|
|
32
|
-
|
|
32
|
+
authorizationOf: InboundTranslationSliceFixtures$ReventlessLocal.PaymentWebhookSpec.authorizationOf
|
|
33
33
|
})(PaymentWebhookTranslation);
|
|
34
34
|
|
|
35
35
|
let scope = "Payments";
|
|
@@ -157,7 +157,7 @@ let CatalogFeedCallback = InboundTranslationSlice_Callback$ReventlessCore.Make({
|
|
|
157
157
|
commandSchema: InboundTranslationSliceFixtures$ReventlessLocal.CatalogFeedSpec.commandSchema,
|
|
158
158
|
targetName: InboundTranslationSliceFixtures$ReventlessLocal.CatalogFeedSpec.targetName,
|
|
159
159
|
externalSystem: InboundTranslationSliceFixtures$ReventlessLocal.CatalogFeedSpec.externalSystem,
|
|
160
|
-
|
|
160
|
+
authorizationOf: InboundTranslationSliceFixtures$ReventlessLocal.CatalogFeedSpec.authorizationOf
|
|
161
161
|
})(CatalogFeedTranslation);
|
|
162
162
|
|
|
163
163
|
let feedField = "Catalog_CatalogFeed";
|
|
@@ -171,7 +171,7 @@ globalThis.describe("InboundTranslationSlice mutation — the door", () => {
|
|
|
171
171
|
DomainGraphQL_Server$ReventlessLocal.asInterface.reset();
|
|
172
172
|
published.contents = [];
|
|
173
173
|
DomainGraphQL_Server$ReventlessLocal.setScope("Catalog");
|
|
174
|
-
InboundTranslationResolvers_GraphQL$ReventlessLocal.register(feedField, InboundTranslationSliceFixtures$ReventlessLocal.CatalogFeedSpec.externalInputSchema, Dcb_Builder$ReventlessCore.inboundDoorPermission(InboundTranslationSliceFixtures$ReventlessLocal.CatalogFeedSpec.commandSchema, InboundTranslationSliceFixtures$ReventlessLocal.CatalogFeedSpec.
|
|
174
|
+
InboundTranslationResolvers_GraphQL$ReventlessLocal.register(feedField, InboundTranslationSliceFixtures$ReventlessLocal.CatalogFeedSpec.externalInputSchema, Dcb_Builder$ReventlessCore.inboundDoorPermission(InboundTranslationSliceFixtures$ReventlessLocal.CatalogFeedSpec.commandSchema, InboundTranslationSliceFixtures$ReventlessLocal.CatalogFeedSpec.authorizationOf), DomainGraphQL_Server$ReventlessLocal.asInterface);
|
|
175
175
|
DomainGraphQL_Server$ReventlessLocal.resetScope();
|
|
176
176
|
InboundTranslationResolvers_GraphQL$ReventlessLocal.bindReceive(feedField, (inputJson, caller) => CatalogFeedCallback.receive(publishJsons, inputJson, caller));
|
|
177
177
|
});
|
|
@@ -23,7 +23,7 @@ let errorSchema = Sury.literal("AlreadyExists");
|
|
|
23
23
|
|
|
24
24
|
let moduleUrl = import.meta.url;
|
|
25
25
|
|
|
26
|
-
function
|
|
26
|
+
function authorizationOf(param) {
|
|
27
27
|
return "AllowAuthenticated";
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -40,7 +40,7 @@ let ItemSpec = {
|
|
|
40
40
|
eventSchema: eventSchema,
|
|
41
41
|
errorSchema: errorSchema,
|
|
42
42
|
moduleUrl: moduleUrl,
|
|
43
|
-
|
|
43
|
+
authorizationOf: authorizationOf,
|
|
44
44
|
commandTransition: commandTransition,
|
|
45
45
|
traits: traits
|
|
46
46
|
};
|
|
@@ -97,7 +97,7 @@ let ItemAgg = ItemAggregateMaker.Make({
|
|
|
97
97
|
errorSchema: errorSchema,
|
|
98
98
|
commandSchema: commandSchema,
|
|
99
99
|
moduleUrl: moduleUrl,
|
|
100
|
-
|
|
100
|
+
authorizationOf: authorizationOf,
|
|
101
101
|
commandTransition: commandTransition,
|
|
102
102
|
traits: traits
|
|
103
103
|
})(ItemBehavior)(NoEventMappings$ReventlessInfra.Make({
|
|
@@ -25,7 +25,7 @@ let errorSchema = Sury.$unit;
|
|
|
25
25
|
|
|
26
26
|
let moduleUrl = import.meta.url;
|
|
27
27
|
|
|
28
|
-
function
|
|
28
|
+
function authorizationOf(param) {
|
|
29
29
|
return "AllowAuthenticated";
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -42,7 +42,7 @@ let ShipmentSpec = {
|
|
|
42
42
|
eventSchema: eventSchema,
|
|
43
43
|
errorSchema: errorSchema,
|
|
44
44
|
moduleUrl: moduleUrl,
|
|
45
|
-
|
|
45
|
+
authorizationOf: authorizationOf,
|
|
46
46
|
commandTransition: commandTransition,
|
|
47
47
|
traits: traits
|
|
48
48
|
};
|
|
@@ -155,7 +155,7 @@ let ShipmentAgg = ShipmentAggregateMaker.Make({
|
|
|
155
155
|
errorSchema: errorSchema,
|
|
156
156
|
commandSchema: commandSchema,
|
|
157
157
|
moduleUrl: moduleUrl,
|
|
158
|
-
|
|
158
|
+
authorizationOf: authorizationOf,
|
|
159
159
|
commandTransition: commandTransition,
|
|
160
160
|
traits: traits
|
|
161
161
|
})(ShipmentBehavior)({
|
|
@@ -59,7 +59,7 @@ let commandSchema = Sury.$schema(s => ({
|
|
|
59
59
|
orderId: s.m(DcbTag$Reventless.string)
|
|
60
60
|
}));
|
|
61
61
|
|
|
62
|
-
function
|
|
62
|
+
function authorizationOf(param) {
|
|
63
63
|
return "AllowAuthenticated";
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -77,7 +77,7 @@ let ShipOrderSpec = {
|
|
|
77
77
|
maxRetries: 3,
|
|
78
78
|
heartbeatInterval: 60,
|
|
79
79
|
targetName: "CreateShipment",
|
|
80
|
-
|
|
80
|
+
authorizationOf: authorizationOf,
|
|
81
81
|
commandTransition: commandTransition,
|
|
82
82
|
traits: traits
|
|
83
83
|
};
|
|
@@ -90,7 +90,7 @@ let todoItemSchema$1 = Sury.$schema(s => ({
|
|
|
90
90
|
|
|
91
91
|
let commandSchema$1 = Sury.literal("Noop");
|
|
92
92
|
|
|
93
|
-
function
|
|
93
|
+
function authorizationOf$1(param) {
|
|
94
94
|
return "AllowAuthenticated";
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -108,7 +108,7 @@ let SkipProcessSpec = {
|
|
|
108
108
|
maxRetries: 0,
|
|
109
109
|
heartbeatInterval: 60,
|
|
110
110
|
targetName: "Noop",
|
|
111
|
-
|
|
111
|
+
authorizationOf: authorizationOf$1,
|
|
112
112
|
commandTransition: commandTransition$1,
|
|
113
113
|
traits: traits$1
|
|
114
114
|
};
|
|
@@ -37,7 +37,7 @@ let commandSchema = Sury.$schema(s => ({
|
|
|
37
37
|
|
|
38
38
|
let errorSchema = Sury.literal("AlreadyPlaced");
|
|
39
39
|
|
|
40
|
-
function
|
|
40
|
+
function authorizationOf(param) {
|
|
41
41
|
return "AllowAuthenticated";
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -55,7 +55,7 @@ let PlaceSpec = {
|
|
|
55
55
|
consumedEventSchema: consumedEventSchema,
|
|
56
56
|
errorSchema: errorSchema,
|
|
57
57
|
commandSchema: commandSchema,
|
|
58
|
-
|
|
58
|
+
authorizationOf: authorizationOf,
|
|
59
59
|
commandTransition: commandTransition,
|
|
60
60
|
traits: traits,
|
|
61
61
|
readConsistency: "EscalateOnRetry"
|
|
@@ -116,7 +116,7 @@ let commandSchema$1 = Sury.$schema(s => ({
|
|
|
116
116
|
|
|
117
117
|
let errorSchema$1 = Sury.literal("NotPlaced");
|
|
118
118
|
|
|
119
|
-
function
|
|
119
|
+
function authorizationOf$1(param) {
|
|
120
120
|
return "AllowAuthenticated";
|
|
121
121
|
}
|
|
122
122
|
|
|
@@ -134,7 +134,7 @@ let ShipSpec = {
|
|
|
134
134
|
consumedEventSchema: consumedEventSchema$1,
|
|
135
135
|
errorSchema: errorSchema$1,
|
|
136
136
|
commandSchema: commandSchema$1,
|
|
137
|
-
|
|
137
|
+
authorizationOf: authorizationOf$1,
|
|
138
138
|
commandTransition: commandTransition$1,
|
|
139
139
|
traits: traits$1,
|
|
140
140
|
readConsistency: "EscalateOnRetry"
|
|
@@ -225,7 +225,7 @@ let commandSchema$2 = Sury.$schema(s => ({
|
|
|
225
225
|
orderId: s.m(DcbTag$Reventless.string)
|
|
226
226
|
}));
|
|
227
227
|
|
|
228
|
-
function
|
|
228
|
+
function authorizationOf$2(param) {
|
|
229
229
|
return "AllowAuthenticated";
|
|
230
230
|
}
|
|
231
231
|
|
|
@@ -243,7 +243,7 @@ let AutoShipSpec = {
|
|
|
243
243
|
maxRetries: 3,
|
|
244
244
|
heartbeatInterval: 60,
|
|
245
245
|
targetName: "Ship",
|
|
246
|
-
|
|
246
|
+
authorizationOf: authorizationOf$2,
|
|
247
247
|
commandTransition: commandTransition$2,
|
|
248
248
|
traits: traits$2
|
|
249
249
|
};
|
|
@@ -362,7 +362,7 @@ let PlaceMaker = StateChangeSlice_Builder$ReventlessLocal.Make({
|
|
|
362
362
|
errorSchema: errorSchema,
|
|
363
363
|
eventSchema: eventSchema,
|
|
364
364
|
commandSchema: commandSchema,
|
|
365
|
-
|
|
365
|
+
authorizationOf: authorizationOf,
|
|
366
366
|
commandTransition: commandTransition,
|
|
367
367
|
traits: traits,
|
|
368
368
|
readConsistency: "EscalateOnRetry"
|
|
@@ -382,7 +382,7 @@ let ShipMaker = StateChangeSlice_Builder$ReventlessLocal.Make({
|
|
|
382
382
|
errorSchema: errorSchema$1,
|
|
383
383
|
eventSchema: eventSchema$1,
|
|
384
384
|
commandSchema: commandSchema$1,
|
|
385
|
-
|
|
385
|
+
authorizationOf: authorizationOf$1,
|
|
386
386
|
commandTransition: commandTransition$1,
|
|
387
387
|
traits: traits$1,
|
|
388
388
|
readConsistency: "EscalateOnRetry"
|
|
@@ -64,7 +64,7 @@ let commandSchema = Sury.$schema(s => ({
|
|
|
64
64
|
productId: s.m(DcbTag$Reventless.string)
|
|
65
65
|
}));
|
|
66
66
|
|
|
67
|
-
function
|
|
67
|
+
function authorizationOf(param) {
|
|
68
68
|
return "AllowAuthenticated";
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -82,7 +82,7 @@ let AutoFulfillSpec = {
|
|
|
82
82
|
maxRetries: 3,
|
|
83
83
|
heartbeatInterval: 60,
|
|
84
84
|
targetName: "MarkFulfilled",
|
|
85
|
-
|
|
85
|
+
authorizationOf: authorizationOf,
|
|
86
86
|
commandTransition: commandTransition,
|
|
87
87
|
traits: traits
|
|
88
88
|
};
|
|
@@ -24,7 +24,7 @@ let errorSchema = Sury.literal("CGAlreadyExists");
|
|
|
24
24
|
|
|
25
25
|
let moduleUrl = import.meta.url;
|
|
26
26
|
|
|
27
|
-
function
|
|
27
|
+
function authorizationOf(param) {
|
|
28
28
|
return "AllowAuthenticated";
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -41,7 +41,7 @@ let CGSpec = {
|
|
|
41
41
|
eventSchema: eventSchema,
|
|
42
42
|
errorSchema: errorSchema,
|
|
43
43
|
moduleUrl: moduleUrl,
|
|
44
|
-
|
|
44
|
+
authorizationOf: authorizationOf,
|
|
45
45
|
commandTransition: commandTransition,
|
|
46
46
|
traits: traits
|
|
47
47
|
};
|
|
@@ -89,7 +89,7 @@ let CGMaker = CommandGenerator_Builder$ReventlessCore.Make({
|
|
|
89
89
|
errorSchema: errorSchema,
|
|
90
90
|
commandSchema: commandSchema,
|
|
91
91
|
moduleUrl: moduleUrl,
|
|
92
|
-
|
|
92
|
+
authorizationOf: authorizationOf,
|
|
93
93
|
commandTransition: commandTransition,
|
|
94
94
|
traits: traits
|
|
95
95
|
})(LocalCommandGeneratorResolvers$ReventlessLocal);
|
|
@@ -29,7 +29,7 @@ let errorSchema = Sury.literal("AlreadyExists");
|
|
|
29
29
|
|
|
30
30
|
let moduleUrl = import.meta.url;
|
|
31
31
|
|
|
32
|
-
function
|
|
32
|
+
function authorizationOf(param) {
|
|
33
33
|
return "AllowAuthenticated";
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -46,7 +46,7 @@ let ItemSpec = {
|
|
|
46
46
|
eventSchema: eventSchema,
|
|
47
47
|
errorSchema: errorSchema,
|
|
48
48
|
moduleUrl: moduleUrl,
|
|
49
|
-
|
|
49
|
+
authorizationOf: authorizationOf,
|
|
50
50
|
commandTransition: commandTransition,
|
|
51
51
|
traits: traits
|
|
52
52
|
};
|
|
@@ -31,7 +31,7 @@ let errorSchema = Sury.literal("AlreadyExists");
|
|
|
31
31
|
|
|
32
32
|
let moduleUrl = import.meta.url;
|
|
33
33
|
|
|
34
|
-
function
|
|
34
|
+
function authorizationOf(param) {
|
|
35
35
|
return "AllowAuthenticated";
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -48,7 +48,7 @@ let ItemSpec = {
|
|
|
48
48
|
eventSchema: eventSchema,
|
|
49
49
|
errorSchema: errorSchema,
|
|
50
50
|
moduleUrl: moduleUrl,
|
|
51
|
-
|
|
51
|
+
authorizationOf: authorizationOf,
|
|
52
52
|
commandTransition: commandTransition,
|
|
53
53
|
traits: traits
|
|
54
54
|
};
|
|
@@ -68,7 +68,7 @@ let errorSchema = Sury.union([
|
|
|
68
68
|
Sury.literal("CategoryNotFound")
|
|
69
69
|
]);
|
|
70
70
|
|
|
71
|
-
function
|
|
71
|
+
function authorizationOf(param) {
|
|
72
72
|
return "AllowAuthenticated";
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -86,7 +86,7 @@ let AddProductSpec = {
|
|
|
86
86
|
consumedEventSchema: consumedEventSchema,
|
|
87
87
|
errorSchema: errorSchema,
|
|
88
88
|
commandSchema: commandSchema,
|
|
89
|
-
|
|
89
|
+
authorizationOf: authorizationOf,
|
|
90
90
|
commandTransition: commandTransition,
|
|
91
91
|
traits: traits,
|
|
92
92
|
readConsistency: "EscalateOnRetry"
|
|
@@ -177,7 +177,7 @@ let AddProductMaker = StateChangeSlice_Builder$ReventlessLocal.Make({
|
|
|
177
177
|
errorSchema: errorSchema,
|
|
178
178
|
eventSchema: eventSchema$1,
|
|
179
179
|
commandSchema: commandSchema,
|
|
180
|
-
|
|
180
|
+
authorizationOf: authorizationOf,
|
|
181
181
|
commandTransition: commandTransition,
|
|
182
182
|
traits: traits,
|
|
183
183
|
readConsistency: "EscalateOnRetry"
|
|
@@ -45,7 +45,7 @@ let commandSchema = Sury.$schema(s => ({
|
|
|
45
45
|
|
|
46
46
|
let errorSchema = Sury.literal("ItemAlreadyExists");
|
|
47
47
|
|
|
48
|
-
function
|
|
48
|
+
function authorizationOf(param) {
|
|
49
49
|
return "AllowAuthenticated";
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -63,7 +63,7 @@ let AddItemSpec = {
|
|
|
63
63
|
consumedEventSchema: consumedEventSchema,
|
|
64
64
|
errorSchema: errorSchema,
|
|
65
65
|
commandSchema: commandSchema,
|
|
66
|
-
|
|
66
|
+
authorizationOf: authorizationOf,
|
|
67
67
|
commandTransition: commandTransition,
|
|
68
68
|
traits: traits,
|
|
69
69
|
readConsistency: "EscalateOnRetry"
|
|
@@ -129,7 +129,7 @@ let AddItemMaker = StateChangeSlice_Builder$ReventlessLocal.Make({
|
|
|
129
129
|
errorSchema: errorSchema,
|
|
130
130
|
eventSchema: eventSchema$1,
|
|
131
131
|
commandSchema: commandSchema,
|
|
132
|
-
|
|
132
|
+
authorizationOf: authorizationOf,
|
|
133
133
|
commandTransition: commandTransition,
|
|
134
134
|
traits: traits,
|
|
135
135
|
readConsistency: "EscalateOnRetry"
|
|
@@ -25,7 +25,7 @@ let directiveSchema = Sury.literal("TEPNoDirective");
|
|
|
25
25
|
|
|
26
26
|
let moduleUrl = import.meta.url;
|
|
27
27
|
|
|
28
|
-
function
|
|
28
|
+
function authorizationOf(param) {
|
|
29
29
|
return "AllowAuthenticated";
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -41,7 +41,7 @@ let TestEPSpec = {
|
|
|
41
41
|
eventSchema: eventSchema,
|
|
42
42
|
directiveSchema: directiveSchema,
|
|
43
43
|
moduleUrl: moduleUrl,
|
|
44
|
-
|
|
44
|
+
authorizationOf: authorizationOf,
|
|
45
45
|
commandTransition: commandTransition,
|
|
46
46
|
traits: traits
|
|
47
47
|
};
|
|
@@ -62,7 +62,7 @@ let errorSchema = Sury.literal("TEAggNoError");
|
|
|
62
62
|
|
|
63
63
|
let moduleUrl$1 = import.meta.url;
|
|
64
64
|
|
|
65
|
-
function
|
|
65
|
+
function authorizationOf$1(param) {
|
|
66
66
|
return "AllowAuthenticated";
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -79,7 +79,7 @@ let DelegateAggSpec = {
|
|
|
79
79
|
eventSchema: eventSchema$1,
|
|
80
80
|
errorSchema: errorSchema,
|
|
81
81
|
moduleUrl: moduleUrl$1,
|
|
82
|
-
|
|
82
|
+
authorizationOf: authorizationOf$1,
|
|
83
83
|
commandTransition: commandTransition$1,
|
|
84
84
|
traits: traits$1
|
|
85
85
|
};
|
|
@@ -137,7 +137,7 @@ let TestEPMapping1 = ExtensionPointMapping$ReventlessInfra.Make({
|
|
|
137
137
|
errorSchema: errorSchema,
|
|
138
138
|
commandSchema: commandSchema$1,
|
|
139
139
|
moduleUrl: moduleUrl$1,
|
|
140
|
-
|
|
140
|
+
authorizationOf: authorizationOf$1,
|
|
141
141
|
commandTransition: commandTransition$1,
|
|
142
142
|
traits: traits$1
|
|
143
143
|
},
|
|
@@ -224,7 +224,7 @@ describe("InboundTranslationSlice Callback", () => {
|
|
|
224
224
|
|
|
225
225
|
type role = Reventless.Role.name
|
|
226
226
|
|
|
227
|
-
let
|
|
227
|
+
let authorizationOf = (_: string): Reventless.Authorization.rule<role> =>
|
|
228
228
|
AllowAuthenticated
|
|
229
229
|
}
|
|
230
230
|
|
|
@@ -290,7 +290,7 @@ describe("InboundTranslationSlice Callback", () => {
|
|
|
290
290
|
|
|
291
291
|
type role = Reventless.Role.name
|
|
292
292
|
|
|
293
|
-
let
|
|
293
|
+
let authorizationOf = (_: string): Reventless.Authorization.rule<role> =>
|
|
294
294
|
AllowAuthenticated
|
|
295
295
|
}
|
|
296
296
|
|
package/tests/components/inboundtranslationslice/InboundTranslationSliceCallbackTest.res.mjs
CHANGED
|
@@ -26,7 +26,7 @@ let Callback = InboundTranslationSlice_Callback$ReventlessCore.Make({
|
|
|
26
26
|
commandSchema: InboundTranslationSliceFixtures$ReventlessLocal.PaymentWebhookSpec.commandSchema,
|
|
27
27
|
targetName: InboundTranslationSliceFixtures$ReventlessLocal.PaymentWebhookSpec.targetName,
|
|
28
28
|
externalSystem: InboundTranslationSliceFixtures$ReventlessLocal.PaymentWebhookSpec.externalSystem,
|
|
29
|
-
|
|
29
|
+
authorizationOf: InboundTranslationSliceFixtures$ReventlessLocal.PaymentWebhookSpec.authorizationOf
|
|
30
30
|
})(PaymentWebhookTranslation);
|
|
31
31
|
|
|
32
32
|
globalThis.describe("InboundTranslationSlice Callback", () => {
|
|
@@ -186,7 +186,7 @@ globalThis.describe("InboundTranslationSlice Callback", () => {
|
|
|
186
186
|
}
|
|
187
187
|
])
|
|
188
188
|
});
|
|
189
|
-
let
|
|
189
|
+
let authorizationOf = param => "AllowAuthenticated";
|
|
190
190
|
let MultiTranslation = {
|
|
191
191
|
translate: translate,
|
|
192
192
|
moduleUrl: moduleUrl
|
|
@@ -198,7 +198,7 @@ globalThis.describe("InboundTranslationSlice Callback", () => {
|
|
|
198
198
|
commandSchema: commandSchema,
|
|
199
199
|
targetName: "ConfirmPayment",
|
|
200
200
|
externalSystem: undefined,
|
|
201
|
-
|
|
201
|
+
authorizationOf: authorizationOf
|
|
202
202
|
})(MultiTranslation);
|
|
203
203
|
let publishedCommands = {
|
|
204
204
|
contents: []
|
|
@@ -248,7 +248,7 @@ globalThis.describe("InboundTranslationSlice Callback", () => {
|
|
|
248
248
|
TAG: "Ok",
|
|
249
249
|
_0: []
|
|
250
250
|
});
|
|
251
|
-
let
|
|
251
|
+
let authorizationOf = param => "AllowAuthenticated";
|
|
252
252
|
let EmptyTranslation = {
|
|
253
253
|
translate: translate,
|
|
254
254
|
moduleUrl: moduleUrl
|
|
@@ -260,7 +260,7 @@ globalThis.describe("InboundTranslationSlice Callback", () => {
|
|
|
260
260
|
commandSchema: commandSchema,
|
|
261
261
|
targetName: "ConfirmPayment",
|
|
262
262
|
externalSystem: undefined,
|
|
263
|
-
|
|
263
|
+
authorizationOf: authorizationOf
|
|
264
264
|
})(EmptyTranslation);
|
|
265
265
|
let publishedCommands = {
|
|
266
266
|
contents: []
|
|
@@ -300,7 +300,7 @@ let CatalogFeedCallback = InboundTranslationSlice_Callback$ReventlessCore.Make({
|
|
|
300
300
|
commandSchema: InboundTranslationSliceFixtures$ReventlessLocal.CatalogFeedSpec.commandSchema,
|
|
301
301
|
targetName: InboundTranslationSliceFixtures$ReventlessLocal.CatalogFeedSpec.targetName,
|
|
302
302
|
externalSystem: InboundTranslationSliceFixtures$ReventlessLocal.CatalogFeedSpec.externalSystem,
|
|
303
|
-
|
|
303
|
+
authorizationOf: InboundTranslationSliceFixtures$ReventlessLocal.CatalogFeedSpec.authorizationOf
|
|
304
304
|
})(CatalogFeedTranslation);
|
|
305
305
|
|
|
306
306
|
function caller(groups) {
|
|
@@ -396,7 +396,7 @@ let NoteFeedCallback = InboundTranslationSlice_Callback$ReventlessCore.Make({
|
|
|
396
396
|
commandSchema: InboundTranslationSliceFixtures$ReventlessLocal.NoteFeedSpec.commandSchema,
|
|
397
397
|
targetName: InboundTranslationSliceFixtures$ReventlessLocal.NoteFeedSpec.targetName,
|
|
398
398
|
externalSystem: InboundTranslationSliceFixtures$ReventlessLocal.NoteFeedSpec.externalSystem,
|
|
399
|
-
|
|
399
|
+
authorizationOf: InboundTranslationSliceFixtures$ReventlessLocal.NoteFeedSpec.authorizationOf
|
|
400
400
|
})(NoteFeedTranslation);
|
|
401
401
|
|
|
402
402
|
globalThis.describe("receive encodes commands with their schema", () => {
|
|
@@ -56,10 +56,11 @@ module CatalogFeedSpec = {
|
|
|
56
56
|
type role = Reventless.Role.name
|
|
57
57
|
let merchandiser = Reventless.Role.make("Merchandiser")
|
|
58
58
|
let admin = Reventless.Role.make("Admin")
|
|
59
|
-
let
|
|
60
|
-
switch
|
|
61
|
-
| AddProduct
|
|
62
|
-
| AddCategory
|
|
59
|
+
let authorizationOf = (name: string): Reventless.Authorization.rule<role> =>
|
|
60
|
+
switch name {
|
|
61
|
+
| "AddProduct" => AllowRoles([merchandiser])
|
|
62
|
+
| "AddCategory" => AllowRoles([admin])
|
|
63
|
+
| _ => DenyAll
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
let translate = (input: externalInput) =>
|
|
@@ -52,7 +52,7 @@ function translate(input) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
function
|
|
55
|
+
function authorizationOf(param) {
|
|
56
56
|
return "AllowAuthenticated";
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -66,7 +66,7 @@ let PaymentWebhookSpec = {
|
|
|
66
66
|
targetName: "ConfirmPayment",
|
|
67
67
|
externalSystem: undefined,
|
|
68
68
|
translate: translate,
|
|
69
|
-
|
|
69
|
+
authorizationOf: authorizationOf,
|
|
70
70
|
traits: traits
|
|
71
71
|
};
|
|
72
72
|
|
|
@@ -92,17 +92,20 @@ let merchandiser = "Merchandiser";
|
|
|
92
92
|
|
|
93
93
|
let admin = "Admin";
|
|
94
94
|
|
|
95
|
-
function
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
95
|
+
function authorizationOf$1(name) {
|
|
96
|
+
switch (name) {
|
|
97
|
+
case "AddCategory" :
|
|
98
|
+
return {
|
|
99
|
+
TAG: "AllowRoles",
|
|
100
|
+
_0: [admin]
|
|
101
|
+
};
|
|
102
|
+
case "AddProduct" :
|
|
103
|
+
return {
|
|
104
|
+
TAG: "AllowRoles",
|
|
105
|
+
_0: [merchandiser]
|
|
106
|
+
};
|
|
107
|
+
default:
|
|
108
|
+
return "DenyAll";
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
|
|
@@ -159,7 +162,7 @@ let CatalogFeedSpec = {
|
|
|
159
162
|
externalSystem: undefined,
|
|
160
163
|
merchandiser: merchandiser,
|
|
161
164
|
admin: admin,
|
|
162
|
-
|
|
165
|
+
authorizationOf: authorizationOf$1,
|
|
163
166
|
translate: translate$1,
|
|
164
167
|
traits: traits$1
|
|
165
168
|
};
|
|
@@ -190,7 +193,7 @@ function translate$2(input) {
|
|
|
190
193
|
};
|
|
191
194
|
}
|
|
192
195
|
|
|
193
|
-
function
|
|
196
|
+
function authorizationOf$2(param) {
|
|
194
197
|
return "AllowAuthenticated";
|
|
195
198
|
}
|
|
196
199
|
|
|
@@ -204,7 +207,7 @@ let NoteFeedSpec = {
|
|
|
204
207
|
targetName: "Annotate",
|
|
205
208
|
externalSystem: undefined,
|
|
206
209
|
translate: translate$2,
|
|
207
|
-
|
|
210
|
+
authorizationOf: authorizationOf$2,
|
|
208
211
|
traits: traits$2
|
|
209
212
|
};
|
|
210
213
|
|
package/tests/components/outboundtranslationslice/OutboundTranslationSlicePlatformFixtures.res.mjs
CHANGED
|
@@ -37,7 +37,7 @@ let commandSchema = Sury.$schema(s => ({
|
|
|
37
37
|
|
|
38
38
|
let errorSchema = Sury.literal("AlreadyPlaced");
|
|
39
39
|
|
|
40
|
-
function
|
|
40
|
+
function authorizationOf(param) {
|
|
41
41
|
return "AllowAuthenticated";
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -55,7 +55,7 @@ let PlaceSpec = {
|
|
|
55
55
|
consumedEventSchema: consumedEventSchema,
|
|
56
56
|
errorSchema: errorSchema,
|
|
57
57
|
commandSchema: commandSchema,
|
|
58
|
-
|
|
58
|
+
authorizationOf: authorizationOf,
|
|
59
59
|
commandTransition: commandTransition,
|
|
60
60
|
traits: traits,
|
|
61
61
|
readConsistency: "EscalateOnRetry"
|
|
@@ -222,7 +222,7 @@ let PlaceMaker = StateChangeSlice_Builder$ReventlessLocal.Make({
|
|
|
222
222
|
errorSchema: errorSchema,
|
|
223
223
|
eventSchema: eventSchema,
|
|
224
224
|
commandSchema: commandSchema,
|
|
225
|
-
|
|
225
|
+
authorizationOf: authorizationOf,
|
|
226
226
|
commandTransition: commandTransition,
|
|
227
227
|
traits: traits,
|
|
228
228
|
readConsistency: "EscalateOnRetry"
|
|
@@ -41,7 +41,7 @@ let commandSchema = Sury.$schema(s => ({
|
|
|
41
41
|
|
|
42
42
|
let errorSchema = Sury.literal("ProductAlreadyExists");
|
|
43
43
|
|
|
44
|
-
function
|
|
44
|
+
function authorizationOf(param) {
|
|
45
45
|
return "AllowAuthenticated";
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -59,7 +59,7 @@ let AddProductSpec = {
|
|
|
59
59
|
consumedEventSchema: consumedEventSchema,
|
|
60
60
|
errorSchema: errorSchema,
|
|
61
61
|
commandSchema: commandSchema,
|
|
62
|
-
|
|
62
|
+
authorizationOf: authorizationOf,
|
|
63
63
|
commandTransition: commandTransition,
|
|
64
64
|
traits: traits,
|
|
65
65
|
readConsistency: "EscalateOnRetry"
|
|
@@ -195,7 +195,7 @@ let AddProductMaker = StateChangeSlice_Builder$ReventlessLocal.Make({
|
|
|
195
195
|
errorSchema: errorSchema,
|
|
196
196
|
eventSchema: eventSchema,
|
|
197
197
|
commandSchema: commandSchema,
|
|
198
|
-
|
|
198
|
+
authorizationOf: authorizationOf,
|
|
199
199
|
commandTransition: commandTransition,
|
|
200
200
|
traits: traits,
|
|
201
201
|
readConsistency: "EscalateOnRetry"
|
|
@@ -10,14 +10,14 @@ let PluginTest = Behavior_GWT$ReventlessGwt.MakeFromAggregate({
|
|
|
10
10
|
commandSchema: PluginSpec$ReventlessCore.commandSchema,
|
|
11
11
|
eventSchema: PluginSpec$ReventlessCore.eventSchema,
|
|
12
12
|
errorSchema: PluginSpec$ReventlessCore.errorSchema,
|
|
13
|
-
|
|
13
|
+
authorizationOf: PluginSpec$ReventlessCore.authorizationOf
|
|
14
14
|
})({
|
|
15
15
|
Spec: {
|
|
16
16
|
name: PluginSpec$ReventlessCore.name,
|
|
17
17
|
commandSchema: PluginSpec$ReventlessCore.commandSchema,
|
|
18
18
|
eventSchema: PluginSpec$ReventlessCore.eventSchema,
|
|
19
19
|
errorSchema: PluginSpec$ReventlessCore.errorSchema,
|
|
20
|
-
|
|
20
|
+
authorizationOf: PluginSpec$ReventlessCore.authorizationOf
|
|
21
21
|
},
|
|
22
22
|
initialState: PluginBehavior$ReventlessCore.initialState,
|
|
23
23
|
evolve: PluginBehavior$ReventlessCore.evolve,
|
|
@@ -11,7 +11,7 @@ let Test = Behavior_GWT$ReventlessGwt.Make({
|
|
|
11
11
|
commandSchema: UiFragmentRegistry$ReventlessCore.commandSchema,
|
|
12
12
|
errorSchema: UiFragmentRegistry$ReventlessCore.errorSchema,
|
|
13
13
|
eventSchema: UiFragmentRegistry$ReventlessCore.eventSchema,
|
|
14
|
-
|
|
14
|
+
authorizationOf: UiFragmentRegistry$ReventlessCore.authorizationOf
|
|
15
15
|
})({
|
|
16
16
|
initialState: undefined,
|
|
17
17
|
evolve: UiFragmentRegistry_Behavior$ReventlessCore.evolve,
|