@reventlessdev/reventless-core 3.0.0-alpha.284 → 3.0.0-alpha.286
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 +23 -0
- package/package.json +7 -7
- package/src/Message.res.mjs +3 -0
- package/src/Roles.res +3 -0
- package/src/Roles.res.mjs +2 -0
- package/src/admin/Platform_AdminGroup.res +12 -0
- package/src/admin/Platform_AdminGroup.res.mjs +23 -0
- package/src/admin/Platform_Admin_Structure.res +14 -10
- package/src/admin/Platform_Admin_Structure.res.mjs +22 -33
- package/src/components/Aggregate/Aggregate_Callback.res +116 -39
- package/src/components/Aggregate/Aggregate_Callback.res.mjs +96 -37
- package/src/components/AutomationSlice/AutomationSlice_Builder.res +2 -1
- package/src/components/CommandGenerator/CommandGenerator_Callback.res +9 -8
- package/src/components/CommandGenerator/CommandGenerator_Callback.res.mjs +10 -8
- package/src/components/CommandTopic/CommandTopic.res.mjs +3 -0
- package/src/components/CommandTopic/CommandTopic_Helpers.res +37 -1
- package/src/components/CommandTopic/CommandTopic_Helpers.res.mjs +29 -0
- package/src/components/Counter/Counter_Builder.res +4 -2
- package/src/components/Dcb/Dcb_Builder.res +9 -6
- package/src/components/Dcb/Dcb_Builder.res.mjs +6 -6
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Builder.res +2 -1
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Builder.res +2 -1
- package/src/components/QueryDb/QueryDb_Builder.res +1 -1
- package/src/components/QueryDb/QueryDb_Builder.res.mjs +3 -2
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res +191 -141
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res.mjs +66 -12
- package/src/components/StateViewSlice/StateViewSlice_Builder.res +1 -0
- package/src/plugin/api/PluginBaseFragment.res +1 -1
- package/src/plugin/api/PluginBaseFragment.res.mjs +2 -1
- package/src/plugin/component/Plugin_Builder.res +7 -3
- package/src/plugin/component/Plugin_Builder.res.mjs +6 -3
- package/src/plugin/component/Plugin_Helpers.res +35 -6
- package/src/plugin/component/Plugin_Helpers.res.mjs +47 -5
- package/src/plugin/component/Plugin_Structure.res +52 -19
- package/src/plugin/component/Plugin_Structure.res.mjs +40 -15
- package/src/plugin/lifecycle/PluginsReadModelSpec.res +1 -1
- package/src/plugin/lifecycle/PluginsReadModelSpec.res.mjs +1 -1
- package/tests/admin/AdminApiSchemaDriftTest.res +9 -3
- package/tests/admin/AdminApiSchemaDriftTest.res.mjs +3 -3
- package/tests/admin/Platform_Admin_StructureTest.res +17 -14
- package/tests/admin/Platform_Admin_StructureTest.res.mjs +31 -19
- package/tests/admin/Platform_ComponentDefinitionsApiTest.res.mjs +8 -72
- package/tests/admin/Platform_PluginStructuresApiTest.res.mjs +9 -39
- package/tests/api/GraphQL_FragmentGeneratorTest.res +1 -1
- package/tests/api/GraphQL_FragmentGeneratorTest.res.mjs +1 -1
- package/tests/commandgenerator/OwnerActingTest.res +601 -0
- package/tests/commandgenerator/OwnerActingTest.res.mjs +1018 -0
- package/tests/commandgenerator/OwnerStampingTest.res +90 -0
- package/tests/commandgenerator/OwnerStampingTest.res.mjs +87 -0
- package/tests/commandtopic/CommandOutcomeHookTest.res +1 -0
- package/tests/commandtopic/CommandOutcomeHookTest.res.mjs +11 -1
- package/tests/plugin/PluginStructureAccessTest.res +30 -1
- package/tests/plugin/PluginStructureAccessTest.res.mjs +28 -1
- package/tests/plugin/StateChange/PsGatedCommands.res +9 -1
- package/tests/plugin/StateChange/PsGatedCommands.res.mjs +4 -1
- package/tests/plugin/StateView/PsGatedView.res +1 -1
- package/tests/plugin/StateView/PsGatedView.res.mjs +1 -1
- package/tests/plugin/pluginDefinitionRequiredScalars.txt +5 -0
|
@@ -256,3 +256,93 @@ describe("the schema a generator is built with must answer for its commands:", (
|
|
|
256
256
|
},
|
|
257
257
|
)
|
|
258
258
|
})
|
|
259
|
+
|
|
260
|
+
// The claim a handler checks ownership against. It is written from the same
|
|
261
|
+
// classification the stamp uses, on every command, whether or not the command
|
|
262
|
+
// itself records an owner: the command that needs it most (`CancelOrder`) names
|
|
263
|
+
// no owner of its own.
|
|
264
|
+
describe("the caller claim on the envelope:", () => {
|
|
265
|
+
let claimOf = (cmd: Message.commandJson) => cmd.meta.callerClaim
|
|
266
|
+
|
|
267
|
+
let cancel = (~identity) =>
|
|
268
|
+
payload(
|
|
269
|
+
~command="ImportProducts",
|
|
270
|
+
~args=Dict.fromArray([("batchId", str("b-1")), ("source", str("acme"))]),
|
|
271
|
+
~identity,
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
testPromise("an owned caller is claimed as that owner", async () => {
|
|
275
|
+
let _ = await generate(
|
|
276
|
+
cancel(~identity=cognito(~userId="cust-A", ~groups=["User"])),
|
|
277
|
+
)->Effect.runPromise
|
|
278
|
+
expect(lastPublished()->claimOf)->toEqual(Some(Message.CallerClaim.Owned({userId: "cust-A"})))
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
testPromise("an elevated caller and a system caller are claimed exempt", async () => {
|
|
282
|
+
let _ = await generate(
|
|
283
|
+
cancel(~identity=cognito(~userId="ops-1", ~groups=["Admin"])),
|
|
284
|
+
)->Effect.runPromise
|
|
285
|
+
let elevated = lastPublished()->claimOf
|
|
286
|
+
let _ = await generate(cancel(~identity=iam))->Effect.runPromise
|
|
287
|
+
expect((elevated, lastPublished()->claimOf))->toEqual((
|
|
288
|
+
Some(Message.CallerClaim.Exempt),
|
|
289
|
+
Some(Message.CallerClaim.Exempt),
|
|
290
|
+
))
|
|
291
|
+
})
|
|
292
|
+
|
|
293
|
+
// Not refused here — the command records no owner, so `AllowAnonymous` still
|
|
294
|
+
// admits it. The claim is what lets the handler refuse it on an owned partition.
|
|
295
|
+
testPromise("an anonymous caller of an unowned command is claimed unidentified", async () => {
|
|
296
|
+
let _ = await generate(cancel(~identity=Reventless.Identity.anonymous))->Effect.runPromise
|
|
297
|
+
expect(lastPublished()->claimOf)->toEqual(Some(Message.CallerClaim.Unidentified))
|
|
298
|
+
})
|
|
299
|
+
|
|
300
|
+
// A client controls the arguments and nothing else. Naming the claim among them
|
|
301
|
+
// must neither reach the envelope nor survive into the command.
|
|
302
|
+
testPromise("a claim sent among the arguments is ignored", async () => {
|
|
303
|
+
let _ = await generate(
|
|
304
|
+
payload(
|
|
305
|
+
~command="ImportProducts",
|
|
306
|
+
~args=Dict.fromArray([
|
|
307
|
+
("batchId", str("b-1")),
|
|
308
|
+
("source", str("acme")),
|
|
309
|
+
("callerClaim", str("Exempt")),
|
|
310
|
+
("meta", JSON.Encode.object(Dict.fromArray([("callerClaim", str("Exempt"))]))),
|
|
311
|
+
]),
|
|
312
|
+
~identity=cognito(~userId="cust-A", ~groups=["User"]),
|
|
313
|
+
),
|
|
314
|
+
)->Effect.runPromise
|
|
315
|
+
expect(lastPublished()->claimOf)->toEqual(Some(Message.CallerClaim.Owned({userId: "cust-A"})))
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
// Unlike the stamp, the claim needs no schema: the permissive generator that
|
|
319
|
+
// stamps nothing still classifies the caller.
|
|
320
|
+
testPromise("a permissive-schema generator still writes the claim", async () => {
|
|
321
|
+
let permissive = CommandGenerator_Callback.makeGenerateCommand(
|
|
322
|
+
~publishJsons=async cmds => published := published.contents->Array.concat(cmds),
|
|
323
|
+
~serviceName="Ordering",
|
|
324
|
+
~commandSchema=S.json->S.castToUnknown,
|
|
325
|
+
~componentKind=CommandGenerator_Callback.StateChangeSlice,
|
|
326
|
+
~stripIdFromParams=false,
|
|
327
|
+
)
|
|
328
|
+
let _ = await permissive(
|
|
329
|
+
cancel(~identity=cognito(~userId="cust-A", ~groups=["User"])),
|
|
330
|
+
)->Effect.runPromise
|
|
331
|
+
expect(lastPublished()->claimOf)->toEqual(Some(Message.CallerClaim.Owned({userId: "cust-A"})))
|
|
332
|
+
})
|
|
333
|
+
|
|
334
|
+
// The claim belongs to the command alone. An event the command produces, and a
|
|
335
|
+
// command an automation issues in reaction to it, derive their envelope from
|
|
336
|
+
// it and must not inherit the caller.
|
|
337
|
+
testSync("a derived envelope does not inherit the claim", () => {
|
|
338
|
+
let parent: Message.meta = {
|
|
339
|
+
service: "Ordering",
|
|
340
|
+
time: "2024-01-01T00:00:00Z",
|
|
341
|
+
msgId: "m-1",
|
|
342
|
+
correlationId: "m-1",
|
|
343
|
+
user: "cust-A",
|
|
344
|
+
callerClaim: Message.CallerClaim.Owned({userId: "cust-A"}),
|
|
345
|
+
}
|
|
346
|
+
expect(Message.deriveMeta(~parent).callerClaim)->toEqual(None)
|
|
347
|
+
})
|
|
348
|
+
})
|
|
@@ -9,6 +9,7 @@ import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/component
|
|
|
9
9
|
import * as Identity$Reventless from "@reventlessdev/reventless-spec/src/types/Identity.res.mjs";
|
|
10
10
|
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
11
11
|
import * as OwnerScope$Reventless from "@reventlessdev/reventless-spec/src/types/OwnerScope.res.mjs";
|
|
12
|
+
import * as Message$ReventlessCore from "../../src/Message.res.mjs";
|
|
12
13
|
import * as Plugin_ResolverError$ReventlessCore from "../../src/plugin/component/Plugin_ResolverError.res.mjs";
|
|
13
14
|
import * as CommandGenerator_Callback$ReventlessCore from "../../src/components/CommandGenerator/CommandGenerator_Callback.res.mjs";
|
|
14
15
|
|
|
@@ -209,6 +210,92 @@ globalThis.describe("the schema a generator is built with must answer for its co
|
|
|
209
210
|
});
|
|
210
211
|
});
|
|
211
212
|
|
|
213
|
+
globalThis.describe("the caller claim on the envelope:", () => {
|
|
214
|
+
let cancel = identity => payload("ImportProducts", Object.fromEntries([
|
|
215
|
+
[
|
|
216
|
+
"batchId",
|
|
217
|
+
"b-1"
|
|
218
|
+
],
|
|
219
|
+
[
|
|
220
|
+
"source",
|
|
221
|
+
"acme"
|
|
222
|
+
]
|
|
223
|
+
]), identity);
|
|
224
|
+
globalThis.test("an owned caller is claimed as that owner", async () => {
|
|
225
|
+
await Effect.runPromise(generate(cancel(cognito("cust-A", ["User"]))));
|
|
226
|
+
globalThis.expect(published.contents[published.contents.length - 1 | 0].meta.callerClaim).toEqual({
|
|
227
|
+
TAG: "Owned",
|
|
228
|
+
userId: "cust-A"
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
globalThis.test("an elevated caller and a system caller are claimed exempt", async () => {
|
|
232
|
+
await Effect.runPromise(generate(cancel(cognito("ops-1", ["Admin"]))));
|
|
233
|
+
let elevated = published.contents[published.contents.length - 1 | 0].meta.callerClaim;
|
|
234
|
+
await Effect.runPromise(generate(cancel(iam)));
|
|
235
|
+
globalThis.expect([
|
|
236
|
+
elevated,
|
|
237
|
+
published.contents[published.contents.length - 1 | 0].meta.callerClaim
|
|
238
|
+
]).toEqual([
|
|
239
|
+
"Exempt",
|
|
240
|
+
"Exempt"
|
|
241
|
+
]);
|
|
242
|
+
});
|
|
243
|
+
globalThis.test("an anonymous caller of an unowned command is claimed unidentified", async () => {
|
|
244
|
+
await Effect.runPromise(generate(cancel(Identity$Reventless.anonymous)));
|
|
245
|
+
globalThis.expect(published.contents[published.contents.length - 1 | 0].meta.callerClaim).toEqual("Unidentified");
|
|
246
|
+
});
|
|
247
|
+
globalThis.test("a claim sent among the arguments is ignored", async () => {
|
|
248
|
+
await Effect.runPromise(generate(payload("ImportProducts", Object.fromEntries([
|
|
249
|
+
[
|
|
250
|
+
"batchId",
|
|
251
|
+
"b-1"
|
|
252
|
+
],
|
|
253
|
+
[
|
|
254
|
+
"source",
|
|
255
|
+
"acme"
|
|
256
|
+
],
|
|
257
|
+
[
|
|
258
|
+
"callerClaim",
|
|
259
|
+
"Exempt"
|
|
260
|
+
],
|
|
261
|
+
[
|
|
262
|
+
"meta",
|
|
263
|
+
Object.fromEntries([[
|
|
264
|
+
"callerClaim",
|
|
265
|
+
"Exempt"
|
|
266
|
+
]])
|
|
267
|
+
]
|
|
268
|
+
]), cognito("cust-A", ["User"]))));
|
|
269
|
+
globalThis.expect(published.contents[published.contents.length - 1 | 0].meta.callerClaim).toEqual({
|
|
270
|
+
TAG: "Owned",
|
|
271
|
+
userId: "cust-A"
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
globalThis.test("a permissive-schema generator still writes the claim", async () => {
|
|
275
|
+
let permissive = CommandGenerator_Callback$ReventlessCore.makeGenerateCommand(async cmds => {
|
|
276
|
+
published.contents = published.contents.concat(cmds);
|
|
277
|
+
}, undefined, "Ordering", Sury.json, "StateChangeSlice", false, undefined);
|
|
278
|
+
await Effect.runPromise(permissive(cancel(cognito("cust-A", ["User"]))));
|
|
279
|
+
globalThis.expect(published.contents[published.contents.length - 1 | 0].meta.callerClaim).toEqual({
|
|
280
|
+
TAG: "Owned",
|
|
281
|
+
userId: "cust-A"
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
globalThis.test("a derived envelope does not inherit the claim", () => {
|
|
285
|
+
globalThis.expect(Message$ReventlessCore.deriveMeta({
|
|
286
|
+
service: "Ordering",
|
|
287
|
+
time: "2024-01-01T00:00:00Z",
|
|
288
|
+
user: "cust-A",
|
|
289
|
+
msgId: "m-1",
|
|
290
|
+
correlationId: "m-1",
|
|
291
|
+
callerClaim: {
|
|
292
|
+
TAG: "Owned",
|
|
293
|
+
userId: "cust-A"
|
|
294
|
+
}
|
|
295
|
+
}, undefined).callerClaim).toEqual(undefined);
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
|
|
212
299
|
export {
|
|
213
300
|
commandSchema,
|
|
214
301
|
published,
|
|
@@ -106,7 +106,17 @@ function seen() {
|
|
|
106
106
|
];
|
|
107
107
|
}
|
|
108
108
|
let tmp;
|
|
109
|
-
|
|
109
|
+
switch (match.cause) {
|
|
110
|
+
case "DomainRejection" :
|
|
111
|
+
tmp = "rejected/domain";
|
|
112
|
+
break;
|
|
113
|
+
case "InfrastructureFailure" :
|
|
114
|
+
tmp = "rejected/infrastructure";
|
|
115
|
+
break;
|
|
116
|
+
case "AccessRefusal" :
|
|
117
|
+
tmp = "rejected/access";
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
110
120
|
return [
|
|
111
121
|
r.component,
|
|
112
122
|
r.reference,
|
|
@@ -76,7 +76,7 @@ let viewNamed = name =>
|
|
|
76
76
|
->Option.flatMap(q => q.requiredAccess)
|
|
77
77
|
|
|
78
78
|
describe("requiredAccess derived from the authorization rule", () => {
|
|
79
|
-
testSync("an
|
|
79
|
+
testSync("an AllowRoles command publishes its groups", () =>
|
|
80
80
|
expect(commandNamed("Restock"))->toEqual(Some(["Admin", "Ops"]))
|
|
81
81
|
)
|
|
82
82
|
|
|
@@ -108,4 +108,33 @@ describe("requiredAccess derived from the authorization rule", () => {
|
|
|
108
108
|
json->String.includes(`"requiredAccess":[]`),
|
|
109
109
|
))->toEqual((true, true, false))
|
|
110
110
|
})
|
|
111
|
+
|
|
112
|
+
// The access keys are compared with a token's groups, so they are the groups
|
|
113
|
+
// the roles map to; the roles themselves travel beside them for the deploy
|
|
114
|
+
// check.
|
|
115
|
+
testSync("a renamed role publishes its group as the key and its role as the role", () => {
|
|
116
|
+
Reventless.Role.clearGroups()
|
|
117
|
+
Reventless.Role.setGroups([(Reventless.Role.make("Ops"), "shop-ops")])
|
|
118
|
+
let renamed = Plugin_Structure.make(
|
|
119
|
+
~name="AccessPlugin",
|
|
120
|
+
~stateChangeSlices=[module(PsGatedCommandsSlice)],
|
|
121
|
+
)
|
|
122
|
+
Reventless.Role.clearGroups()
|
|
123
|
+
let restock =
|
|
124
|
+
renamed.stateChangeSlices
|
|
125
|
+
->Array.flatMap(w => w.commands)
|
|
126
|
+
->Array.find(c => c.name === "Restock")
|
|
127
|
+
expect(restock->Option.map(c => (c.requiredAccess, c.requiredRoles)))->toEqual(
|
|
128
|
+
Some((Some(["Admin", "shop-ops"]), Some(["Admin", "Ops"]))),
|
|
129
|
+
)
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
testSync("a command that names no role publishes no roles", () =>
|
|
133
|
+
expect(
|
|
134
|
+
structure.stateChangeSlices
|
|
135
|
+
->Array.flatMap(w => w.commands)
|
|
136
|
+
->Array.find(c => c.name === "RequestRestock")
|
|
137
|
+
->Option.flatMap(c => c.requiredRoles),
|
|
138
|
+
)->toEqual(None)
|
|
139
|
+
)
|
|
111
140
|
})
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as Id$Reventless from "@reventlessdev/reventless-spec/src/types/Id.res.mjs";
|
|
4
4
|
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
5
|
+
import * as Role$Reventless from "@reventlessdev/reventless-spec/src/types/Role.res.mjs";
|
|
5
6
|
import * as PsGatedView$ReventlessCore from "./StateView/PsGatedView.res.mjs";
|
|
6
7
|
import * as PsOrdersView$ReventlessCore from "./StateView/PsOrdersView.res.mjs";
|
|
7
8
|
import * as PsGatedCommands$ReventlessCore from "./StateChange/PsGatedCommands.res.mjs";
|
|
@@ -119,7 +120,7 @@ function viewNamed(name) {
|
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
globalThis.describe("requiredAccess derived from the authorization rule", () => {
|
|
122
|
-
globalThis.test("an
|
|
123
|
+
globalThis.test("an AllowRoles command publishes its groups", () => {
|
|
123
124
|
globalThis.expect(commandNamed("Restock")).toEqual([
|
|
124
125
|
"Admin",
|
|
125
126
|
"Ops"
|
|
@@ -146,6 +147,32 @@ globalThis.describe("requiredAccess derived from the authorization rule", () =>
|
|
|
146
147
|
false
|
|
147
148
|
]);
|
|
148
149
|
});
|
|
150
|
+
globalThis.test("a renamed role publishes its group as the key and its role as the role", () => {
|
|
151
|
+
Role$Reventless.clearGroups();
|
|
152
|
+
Role$Reventless.setGroups([[
|
|
153
|
+
"Ops",
|
|
154
|
+
"shop-ops"
|
|
155
|
+
]]);
|
|
156
|
+
let renamed = Plugin_Structure$ReventlessCore.make("AccessPlugin", undefined, undefined, undefined, [PsGatedCommandsSlice], undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
|
|
157
|
+
Role$Reventless.clearGroups();
|
|
158
|
+
let restock = renamed.stateChangeSlices.flatMap(w => w.commands).find(c => c.name === "Restock");
|
|
159
|
+
globalThis.expect(Stdlib_Option.map(restock, c => [
|
|
160
|
+
c.requiredAccess,
|
|
161
|
+
c.requiredRoles
|
|
162
|
+
])).toEqual([
|
|
163
|
+
[
|
|
164
|
+
"Admin",
|
|
165
|
+
"shop-ops"
|
|
166
|
+
],
|
|
167
|
+
[
|
|
168
|
+
"Admin",
|
|
169
|
+
"Ops"
|
|
170
|
+
]
|
|
171
|
+
]);
|
|
172
|
+
});
|
|
173
|
+
globalThis.test("a command that names no role publishes no roles", () => {
|
|
174
|
+
globalThis.expect(Stdlib_Option.flatMap(structure.stateChangeSlices.flatMap(w => w.commands).find(c => c.name === "RequestRestock"), c => c.requiredRoles)).toEqual(undefined);
|
|
175
|
+
});
|
|
149
176
|
});
|
|
150
177
|
|
|
151
178
|
export {
|
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
@@reventless.spec("GatedCommands")
|
|
6
6
|
|
|
7
|
+
// Declared here rather than in the package's `Roles.res`: the rule resolves
|
|
8
|
+
// `Roles` by ordinary scoping, so a spec can name roles its package does not.
|
|
9
|
+
module Roles = {
|
|
10
|
+
type t =
|
|
11
|
+
| Admin
|
|
12
|
+
| Ops
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
type state = bool
|
|
8
16
|
let initialState = false
|
|
9
17
|
|
|
@@ -14,7 +22,7 @@ let evolve = (_state, _event) => true
|
|
|
14
22
|
|
|
15
23
|
@schema
|
|
16
24
|
type command =
|
|
17
|
-
| @authorize(
|
|
25
|
+
| @authorize(AllowRoles([Admin, Ops])) Restock({productId: string})
|
|
18
26
|
| RequestRestock({productId: string})
|
|
19
27
|
|
|
20
28
|
@schema
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
import * as Sury from "sury";
|
|
4
4
|
import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
|
|
5
5
|
|
|
6
|
+
let Roles = {};
|
|
7
|
+
|
|
6
8
|
let consumedEventSchema = Sury.$schema(s => ({
|
|
7
9
|
TAG: "StockLow",
|
|
8
10
|
productId: s.m(DcbTag$Reventless.string)
|
|
@@ -46,7 +48,7 @@ function decide(_state, _command) {
|
|
|
46
48
|
function commandAuthorization(command) {
|
|
47
49
|
if (command.TAG === "Restock") {
|
|
48
50
|
return {
|
|
49
|
-
TAG: "
|
|
51
|
+
TAG: "AllowRoles",
|
|
50
52
|
_0: [
|
|
51
53
|
"Admin",
|
|
52
54
|
"Ops"
|
|
@@ -76,6 +78,7 @@ let readConsistency = "EscalateOnRetry";
|
|
|
76
78
|
export {
|
|
77
79
|
name,
|
|
78
80
|
Id,
|
|
81
|
+
Roles,
|
|
79
82
|
initialState,
|
|
80
83
|
consumedEventSchema,
|
|
81
84
|
evolve,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Test fixture spec: a view whose module-level rule restricts who may read it.
|
|
2
2
|
|
|
3
3
|
@@reventless.spec("GatedView")
|
|
4
|
-
@@reventless.authorize(
|
|
4
|
+
@@reventless.authorize(AllowRoles([Admin]))
|
|
5
5
|
|
|
6
6
|
@schema
|
|
7
7
|
type consumedEvent = OrderPlaced({orderId: string, customerName: string})
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
.structure.aggregates[].commands[].references[].entity: string
|
|
57
57
|
.structure.aggregates[].commands[].references[].fieldName: string
|
|
58
58
|
.structure.aggregates[].commands[].requiredAccess[]: string
|
|
59
|
+
.structure.aggregates[].commands[].requiredRoles[]: string
|
|
59
60
|
.structure.aggregates[].commands[].schema: string
|
|
60
61
|
.structure.aggregates[].consumedEventTypes[]: string
|
|
61
62
|
.structure.aggregates[].errors[].name: string
|
|
@@ -91,6 +92,7 @@
|
|
|
91
92
|
.structure.extensions[].name: string
|
|
92
93
|
.structure.inboundTranslationSlices[].commandTypes[]: string
|
|
93
94
|
.structure.inboundTranslationSlices[].name: string
|
|
95
|
+
.structure.inboundTranslationSlices[].requiredRoles[]: string
|
|
94
96
|
.structure.inboundTranslationSlices[].targetName: string
|
|
95
97
|
.structure.outboundTranslationSlices[].consumedEventTypes[]: string
|
|
96
98
|
# `consumedSources` is itself optional and is NEW, so no persisted payload
|
|
@@ -107,6 +109,7 @@
|
|
|
107
109
|
.structure.readModels[].name: string
|
|
108
110
|
.structure.readModels[].queryField: string
|
|
109
111
|
.structure.readModels[].requiredAccess[]: string
|
|
112
|
+
.structure.readModels[].requiredRoles[]: string
|
|
110
113
|
.structure.readModels[].retiredValues[]: string
|
|
111
114
|
.structure.readModels[].schema: string
|
|
112
115
|
.structure.readModels[].searchableFields[]: string
|
|
@@ -138,6 +141,7 @@
|
|
|
138
141
|
.structure.stateChangeSlices[].commands[].references[].entity: string
|
|
139
142
|
.structure.stateChangeSlices[].commands[].references[].fieldName: string
|
|
140
143
|
.structure.stateChangeSlices[].commands[].requiredAccess[]: string
|
|
144
|
+
.structure.stateChangeSlices[].commands[].requiredRoles[]: string
|
|
141
145
|
.structure.stateChangeSlices[].commands[].schema: string
|
|
142
146
|
.structure.stateChangeSlices[].consumedEventTypes[]: string
|
|
143
147
|
.structure.stateChangeSlices[].errors[].name: string
|
|
@@ -157,6 +161,7 @@
|
|
|
157
161
|
.structure.stateViewSlices[].name: string
|
|
158
162
|
.structure.stateViewSlices[].queryField: string
|
|
159
163
|
.structure.stateViewSlices[].requiredAccess[]: string
|
|
164
|
+
.structure.stateViewSlices[].requiredRoles[]: string
|
|
160
165
|
.structure.stateViewSlices[].retiredValues[]: string
|
|
161
166
|
.structure.stateViewSlices[].schema: string
|
|
162
167
|
.structure.stateViewSlices[].searchableFields[]: string
|