@reventlessdev/reventless-core 3.0.0-alpha.307 → 3.0.0-alpha.309
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 +39 -0
- package/package.json +7 -7
- package/src/Projection.res +4 -4
- package/src/Projection.res.mjs +11 -9
- package/src/ResourceAttribution.res +3 -3
- package/src/ResourceAttribution.res.mjs +1 -4
- package/src/adapter/Auth/Auth_ActiveRole.res +13 -18
- package/src/adapter/Auth/Auth_ActiveRole.res.mjs +4 -9
- package/src/adapter/EventLogProvisioning/EventLogProvisioning.res +1 -1
- package/src/adapter/Monitoring/Monitoring.res +5 -5
- package/src/adapter/Stash/Stash_Memory_Backend.res +35 -0
- package/src/adapter/Stash/Stash_Memory_Backend.res.mjs +44 -0
- package/src/adapter/Throttle/AnonymousLimiter.res +37 -0
- package/src/adapter/Throttle/AnonymousLimiter.res.mjs +43 -0
- package/src/admin/Platform_Admin.res +2 -2
- package/src/admin/Platform_Admin_Structure.res +0 -9
- package/src/admin/Platform_Admin_Structure.res.mjs +3 -12
- package/src/admin/Platform_BakedManifest.res +6 -6
- package/src/admin/Platform_BakedManifest.res.mjs +11 -26
- package/src/admin/Platform_PluginStructuresApi.res +36 -2
- package/src/admin/Platform_PluginStructuresApi.res.mjs +43 -1
- package/src/admin/Platform_SelfRegistration.res +79 -0
- package/src/admin/Platform_SelfRegistration.res.mjs +95 -0
- package/src/components/Api/GraphQL_SchemaInspector.res +3 -3
- package/src/components/Api/SuryToJsonSchema.res +3 -3
- package/src/components/Dcb/Dcb_Builder.res +6 -9
- package/src/components/Dcb/Dcb_Builder.res.mjs +0 -3
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Builder.res +14 -1
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Builder.res.mjs +3 -3
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res +73 -8
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res.mjs +60 -12
- package/src/plugin/component/Plugin.res +2 -0
- package/src/plugin/component/Plugin_Builder.res +9 -8
- package/src/plugin/component/Plugin_Builder.res.mjs +6 -10
- package/src/plugin/component/Plugin_Helpers.res +4 -4
- package/src/plugin/component/Plugin_Structure.res +179 -115
- package/src/plugin/component/Plugin_Structure.res.mjs +83 -17
- package/src/plugin/lifecycle/PluginsProjection.res +10 -6
- package/src/plugin/lifecycle/PluginsReadModelSpec.res +8 -8
- package/src/util/FTPHandler.res +3 -3
- package/src/util/ScheduleTime.res +5 -8
- package/src/util/ScheduleTime.res.mjs +0 -3
- package/src/util/Util_Promise.res +1 -1
- package/tests/AnonymousLimiterTest.res +66 -0
- package/tests/AnonymousLimiterTest.res.mjs +89 -0
- package/tests/ResourceAttributionTest.res +1 -1
- package/tests/ResourceAttributionTest.res.mjs +1 -4
- package/tests/Stash_Memory_BackendTest.res +63 -0
- package/tests/Stash_Memory_BackendTest.res.mjs +98 -0
- package/tests/admin/AdminApiSchemaDriftTest.res +72 -44
- package/tests/admin/AdminApiSchemaDriftTest.res.mjs +41 -3
- package/tests/admin/Platform_Admin_StructureTest.res +1 -1
- package/tests/admin/Platform_Admin_StructureTest.res.mjs +4 -22
- package/tests/admin/Platform_BakedManifestTest.res +11 -29
- package/tests/admin/Platform_BakedManifestTest.res.mjs +8 -39
- package/tests/admin/Platform_ComponentDefinitionsApiTest.res +24 -84
- package/tests/admin/Platform_ComponentDefinitionsApiTest.res.mjs +36 -169
- package/tests/admin/Platform_PluginStructuresApiTest.res +46 -31
- package/tests/admin/Platform_PluginStructuresApiTest.res.mjs +37 -34
- package/tests/admin/Platform_SelfRegistrationTest.res +91 -0
- package/tests/admin/Platform_SelfRegistrationTest.res.mjs +112 -0
- package/tests/admin/Platform_UIFragmentsApiTest.res +1 -4
- package/tests/admin/Platform_UIFragmentsApiTest.res.mjs +1 -4
- package/tests/api/GeocodingTest.res +1 -1
- package/tests/logger/LogFormatTest.res +0 -2
- package/tests/logger/LogFormatTest.res.mjs +0 -2
- package/tests/message/MessageTest.res +0 -13
- package/tests/message/MessageTest.res.mjs +2 -15
- package/tests/plugin/ManifestVisibilityTest.res.mjs +1 -1
- package/tests/plugin/PluginStructureAccessTest.res +6 -1
- package/tests/plugin/PluginStructureAccessTest.res.mjs +9 -5
- package/tests/plugin/PluginStructureTest.res +99 -23
- package/tests/plugin/PluginStructureTest.res.mjs +123 -79
- package/tests/plugin/pluginDefinitionRequiredScalars.txt +10 -0
|
@@ -102,17 +102,11 @@ function referencedEntities(pluginName, kept) {
|
|
|
102
102
|
function curateStructure(pluginId, def, sel) {
|
|
103
103
|
return Stdlib_Result.map(validate(def, sel), () => {
|
|
104
104
|
let pluginName = Plugin$ReventlessCore.name(pluginId);
|
|
105
|
-
let keepCommands = ws => ws.map(w =>
|
|
106
|
-
|
|
107
|
-
commands
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
linkedViews: w.linkedViews,
|
|
111
|
-
consistencyRead: w.consistencyRead,
|
|
112
|
-
events: w.events,
|
|
113
|
-
errors: w.errors,
|
|
114
|
-
chapter: w.chapter
|
|
115
|
-
})).filter(w => w.commands.length !== 0);
|
|
105
|
+
let keepCommands = ws => ws.map(w => {
|
|
106
|
+
let newrecord = {...w};
|
|
107
|
+
newrecord.commands = w.commands.filter(c => isSelected(sel.commands, c.name));
|
|
108
|
+
return newrecord;
|
|
109
|
+
}).filter(w => w.commands.length !== 0);
|
|
116
110
|
let stateChangeSlices = keepCommands(def.stateChangeSlices);
|
|
117
111
|
let aggregates = keepCommands(def.aggregates);
|
|
118
112
|
let referenced = referencedEntities(pluginName, stateChangeSlices.concat(aggregates));
|
|
@@ -123,21 +117,12 @@ function curateStructure(pluginId, def, sel) {
|
|
|
123
117
|
return referenced.includes(q.name);
|
|
124
118
|
}
|
|
125
119
|
});
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
outboundTranslationSlices: def.outboundTranslationSlices,
|
|
133
|
-
inboundTranslationSlices: def.inboundTranslationSlices,
|
|
134
|
-
extensions: def.extensions,
|
|
135
|
-
extensionPoints: def.extensionPoints,
|
|
136
|
-
requiredStores: def.requiredStores,
|
|
137
|
-
requiredStoreDeclarations: def.requiredStoreDeclarations,
|
|
138
|
-
requiredCapabilities: def.requiredCapabilities,
|
|
139
|
-
traitDeclarations: def.traitDeclarations
|
|
140
|
-
};
|
|
120
|
+
let newrecord = {...def};
|
|
121
|
+
newrecord.aggregates = aggregates;
|
|
122
|
+
newrecord.stateChangeSlices = stateChangeSlices;
|
|
123
|
+
newrecord.stateViewSlices = keepViews(def.stateViewSlices);
|
|
124
|
+
newrecord.readModels = keepViews(def.readModels);
|
|
125
|
+
return newrecord;
|
|
141
126
|
});
|
|
142
127
|
}
|
|
143
128
|
|
|
@@ -46,13 +46,19 @@ let sdlTypes: array<string> = [
|
|
|
46
46
|
// It records ORIGIN, never behavior — a grafted file is the host's to edit
|
|
47
47
|
// afterwards — so a reader must not paint a declared graft as a verified one.
|
|
48
48
|
`type Platform_TraitDeclaration {\n trait: String!\n version: String!\n posture: String!\n component: String!\n}`,
|
|
49
|
+
// How a person comes to hold a role, per role the plugin declares. `strategy` is a
|
|
50
|
+
// String for the reason `posture` is; `invitedBy` is null unless it is `Invitation`.
|
|
51
|
+
`type Platform_AdmissionDef {\n role: String!\n strategy: String!\n invitedBy: [String!]\n}`,
|
|
52
|
+
// A door into the admission flow, and which part of it the door serves.
|
|
53
|
+
`type Platform_AdmissionDoorDef {\n component: String!\n part: String!\n}`,
|
|
49
54
|
// `extensionPoints` / `requiredStores` / `requiredStoreDeclarations` /
|
|
50
|
-
// `requiredCapabilities` / `traitDeclarations`
|
|
55
|
+
// `requiredCapabilities` / `traitDeclarations` / `admission` / `admissionDoors` are
|
|
56
|
+
// nullable lists, not `[T!]!`: all seven are optional on
|
|
51
57
|
// `pluginStructure` so that plugin definitions persisted before the field existed
|
|
52
58
|
// still decode. A structure written by an older deploy sends null, and null is the
|
|
53
59
|
// honest answer — an empty list would claim the plugin has no extension points when
|
|
54
60
|
// the truth is that the deployment cannot say.
|
|
55
|
-
`type Platform_PluginStructureEntry {\n pluginId: String!\n readModels: [Platform_ReadSideDef!]!\n stateViewSlices: [Platform_ReadSideDef!]!\n stateChangeSlices: [Platform_WriteSideDef!]!\n aggregates: [Platform_WriteSideDef!]!\n automationSlices: [Platform_AutomationSliceDef!]!\n outboundTranslationSlices: [Platform_OutboundTranslationSliceDef!]!\n inboundTranslationSlices: [Platform_InboundTranslationSliceDef!]!\n extensions: [Platform_ExtensionDef!]!\n extensionPoints: [Platform_ExtensionPointDef!]\n requiredStores: [String!]\n requiredStoreDeclarations: [Platform_RequiredStoreDeclaration!]\n requiredCapabilities: [Platform_RequiredCapabilityDeclaration!]\n traitDeclarations: [Platform_TraitDeclaration!]\n}`,
|
|
61
|
+
`type Platform_PluginStructureEntry {\n pluginId: String!\n readModels: [Platform_ReadSideDef!]!\n stateViewSlices: [Platform_ReadSideDef!]!\n stateChangeSlices: [Platform_WriteSideDef!]!\n aggregates: [Platform_WriteSideDef!]!\n automationSlices: [Platform_AutomationSliceDef!]!\n outboundTranslationSlices: [Platform_OutboundTranslationSliceDef!]!\n inboundTranslationSlices: [Platform_InboundTranslationSliceDef!]!\n extensions: [Platform_ExtensionDef!]!\n extensionPoints: [Platform_ExtensionPointDef!]\n requiredStores: [String!]\n requiredStoreDeclarations: [Platform_RequiredStoreDeclaration!]\n requiredCapabilities: [Platform_RequiredCapabilityDeclaration!]\n traitDeclarations: [Platform_TraitDeclaration!]\n admission: [Platform_AdmissionDef!]\n admissionDoors: [Platform_AdmissionDoorDef!]\n}`,
|
|
56
62
|
]
|
|
57
63
|
|
|
58
64
|
let sdlQueryField: string = ` Platform_PluginStructures: [Platform_PluginStructureEntry!]!`
|
|
@@ -65,6 +71,22 @@ let encodeTraitDeclaration = (d: traitDeclaration): JSON.t =>
|
|
|
65
71
|
("component", JSON.Encode.string(d.component)),
|
|
66
72
|
])->JSON.Encode.object
|
|
67
73
|
|
|
74
|
+
let encodeAdmissionDef = (d: Reventless.Admission.def): JSON.t =>
|
|
75
|
+
Dict.fromArray([
|
|
76
|
+
("role", JSON.Encode.string(d.role)),
|
|
77
|
+
("strategy", JSON.Encode.string(d.strategy)),
|
|
78
|
+
(
|
|
79
|
+
"invitedBy",
|
|
80
|
+
d.invitedBy->Option.mapOr(JSON.Encode.null, Platform_ComponentDefinitionsApi.encodeStrings),
|
|
81
|
+
),
|
|
82
|
+
])->JSON.Encode.object
|
|
83
|
+
|
|
84
|
+
let encodeAdmissionDoorDef = (d: Reventless.Admission.doorDef): JSON.t =>
|
|
85
|
+
Dict.fromArray([
|
|
86
|
+
("component", JSON.Encode.string(d.component)),
|
|
87
|
+
("part", JSON.Encode.string(d.part)),
|
|
88
|
+
])->JSON.Encode.object
|
|
89
|
+
|
|
68
90
|
let encodeExtensionPointDef = (e: extensionPointDef): JSON.t =>
|
|
69
91
|
Dict.fromArray([
|
|
70
92
|
("name", JSON.Encode.string(e.name)),
|
|
@@ -204,4 +226,16 @@ let encodePluginStructureEntry = (~pluginId: string, def: pluginStructure): JSON
|
|
|
204
226
|
ds->Array.map(encodeTraitDeclaration)->JSON.Encode.array
|
|
205
227
|
),
|
|
206
228
|
),
|
|
229
|
+
(
|
|
230
|
+
"admission",
|
|
231
|
+
def.admission->Option.mapOr(JSON.Encode.null, ds =>
|
|
232
|
+
ds->Array.map(encodeAdmissionDef)->JSON.Encode.array
|
|
233
|
+
),
|
|
234
|
+
),
|
|
235
|
+
(
|
|
236
|
+
"admissionDoors",
|
|
237
|
+
def.admissionDoors->Option.mapOr(JSON.Encode.null, ds =>
|
|
238
|
+
ds->Array.map(encodeAdmissionDoorDef)->JSON.Encode.array
|
|
239
|
+
),
|
|
240
|
+
),
|
|
207
241
|
])->JSON.Encode.object
|
|
@@ -11,7 +11,9 @@ let sdlTypes = [
|
|
|
11
11
|
`type Platform_RequiredStoreDeclaration {\n store: String!\n component: String!\n field: String!\n annotation: String\n}`,
|
|
12
12
|
`type Platform_RequiredCapabilityDeclaration {\n capability: String!\n component: String!\n}`,
|
|
13
13
|
`type Platform_TraitDeclaration {\n trait: String!\n version: String!\n posture: String!\n component: String!\n}`,
|
|
14
|
-
`type
|
|
14
|
+
`type Platform_AdmissionDef {\n role: String!\n strategy: String!\n invitedBy: [String!]\n}`,
|
|
15
|
+
`type Platform_AdmissionDoorDef {\n component: String!\n part: String!\n}`,
|
|
16
|
+
`type Platform_PluginStructureEntry {\n pluginId: String!\n readModels: [Platform_ReadSideDef!]!\n stateViewSlices: [Platform_ReadSideDef!]!\n stateChangeSlices: [Platform_WriteSideDef!]!\n aggregates: [Platform_WriteSideDef!]!\n automationSlices: [Platform_AutomationSliceDef!]!\n outboundTranslationSlices: [Platform_OutboundTranslationSliceDef!]!\n inboundTranslationSlices: [Platform_InboundTranslationSliceDef!]!\n extensions: [Platform_ExtensionDef!]!\n extensionPoints: [Platform_ExtensionPointDef!]\n requiredStores: [String!]\n requiredStoreDeclarations: [Platform_RequiredStoreDeclaration!]\n requiredCapabilities: [Platform_RequiredCapabilityDeclaration!]\n traitDeclarations: [Platform_TraitDeclaration!]\n admission: [Platform_AdmissionDef!]\n admissionDoors: [Platform_AdmissionDoorDef!]\n}`
|
|
15
17
|
];
|
|
16
18
|
|
|
17
19
|
function encodeTraitDeclaration(d) {
|
|
@@ -35,6 +37,36 @@ function encodeTraitDeclaration(d) {
|
|
|
35
37
|
]);
|
|
36
38
|
}
|
|
37
39
|
|
|
40
|
+
function encodeAdmissionDef(d) {
|
|
41
|
+
return Object.fromEntries([
|
|
42
|
+
[
|
|
43
|
+
"role",
|
|
44
|
+
d.role
|
|
45
|
+
],
|
|
46
|
+
[
|
|
47
|
+
"strategy",
|
|
48
|
+
d.strategy
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
"invitedBy",
|
|
52
|
+
Stdlib_Option.mapOr(d.invitedBy, null, Platform_ComponentDefinitionsApi$ReventlessCore.encodeStrings)
|
|
53
|
+
]
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function encodeAdmissionDoorDef(d) {
|
|
58
|
+
return Object.fromEntries([
|
|
59
|
+
[
|
|
60
|
+
"component",
|
|
61
|
+
d.component
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
"part",
|
|
65
|
+
d.part
|
|
66
|
+
]
|
|
67
|
+
]);
|
|
68
|
+
}
|
|
69
|
+
|
|
38
70
|
function encodeExtensionPointDef(e) {
|
|
39
71
|
return Object.fromEntries([
|
|
40
72
|
[
|
|
@@ -173,6 +205,14 @@ function encodePluginStructureEntry(pluginId, def) {
|
|
|
173
205
|
[
|
|
174
206
|
"traitDeclarations",
|
|
175
207
|
Stdlib_Option.mapOr(def.traitDeclarations, null, ds => ds.map(encodeTraitDeclaration))
|
|
208
|
+
],
|
|
209
|
+
[
|
|
210
|
+
"admission",
|
|
211
|
+
Stdlib_Option.mapOr(def.admission, null, ds => ds.map(encodeAdmissionDef))
|
|
212
|
+
],
|
|
213
|
+
[
|
|
214
|
+
"admissionDoors",
|
|
215
|
+
Stdlib_Option.mapOr(def.admissionDoors, null, ds => ds.map(encodeAdmissionDoorDef))
|
|
176
216
|
]
|
|
177
217
|
]);
|
|
178
218
|
}
|
|
@@ -183,6 +223,8 @@ export {
|
|
|
183
223
|
sdlTypes,
|
|
184
224
|
sdlQueryField,
|
|
185
225
|
encodeTraitDeclaration,
|
|
226
|
+
encodeAdmissionDef,
|
|
227
|
+
encodeAdmissionDoorDef,
|
|
186
228
|
encodeExtensionPointDef,
|
|
187
229
|
encodeRequiredStoreDeclaration,
|
|
188
230
|
encodeRequiredCapabilityDeclaration,
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// What the host shell needs to let a visitor create an account, read off the
|
|
2
|
+
// plugin structures rather than written by hand: the mutation that starts a
|
|
3
|
+
// registration, the one that completes it, the groups a visitor may sign up
|
|
4
|
+
// for, and the query that says which of them are open right now. Absent when no
|
|
5
|
+
// plugin marks both doors, so a deployment without self-registration writes the
|
|
6
|
+
// same `config.json` it always did.
|
|
7
|
+
|
|
8
|
+
let configKey = "selfRegistration"
|
|
9
|
+
|
|
10
|
+
type config = {
|
|
11
|
+
start: string,
|
|
12
|
+
complete: string,
|
|
13
|
+
/** The groups of the roles declared self-service, as the deployment maps them. */
|
|
14
|
+
roles: array<string>,
|
|
15
|
+
/** The list query of the view saying which roles are open, where a plugin marks one. */
|
|
16
|
+
openRoles?: string,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let marked = (
|
|
20
|
+
structures: array<(string, Reventless.Plugin.pluginStructure)>,
|
|
21
|
+
part: Reventless.Admission.door,
|
|
22
|
+
): option<(string, Reventless.Admission.doorDef)> =>
|
|
23
|
+
structures->Array.findMap(((plugin, s)) =>
|
|
24
|
+
s.admissionDoors
|
|
25
|
+
->Option.getOr([])
|
|
26
|
+
->Array.find(d => d.part == Reventless.Admission.doorName(part))
|
|
27
|
+
->Option.map(d => (plugin, d))
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
let doorField = (
|
|
31
|
+
structures: array<(string, Reventless.Plugin.pluginStructure)>,
|
|
32
|
+
part: Reventless.Admission.door,
|
|
33
|
+
): option<string> =>
|
|
34
|
+
marked(structures, part)->Option.map(((plugin, d)) =>
|
|
35
|
+
Api_Naming.sliceMutationField(~plugin, ~slice=d.component)
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
let openRolesField = (structures: array<(string, Reventless.Plugin.pluginStructure)>): option<
|
|
39
|
+
string,
|
|
40
|
+
> =>
|
|
41
|
+
marked(structures, OpenRoles)->Option.map(((plugin, d)) =>
|
|
42
|
+
Api_Naming.queryFieldNamesForStateView(~plugin, ~viewName=d.component).listFieldName
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
let selfServiceGroups = (structures: array<(string, Reventless.Plugin.pluginStructure)>) =>
|
|
46
|
+
structures->Array.flatMap(((_, s)) =>
|
|
47
|
+
switch s.admission->Option.map(Reventless.Admission.fromDefs) {
|
|
48
|
+
| Some(Ok(table)) => table->Reventless.Admission.selfService->Array.map(Reventless.Role.groupOf)
|
|
49
|
+
| Some(Error(_)) | None => []
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
/** The configuration, where a deployment has a door that starts and one that
|
|
54
|
+
completes a registration. */
|
|
55
|
+
let fromStructures = (structures: array<(string, Reventless.Plugin.pluginStructure)>): option<
|
|
56
|
+
config,
|
|
57
|
+
> =>
|
|
58
|
+
switch (doorField(structures, Start), doorField(structures, Complete)) {
|
|
59
|
+
| (Some(start), Some(complete)) =>
|
|
60
|
+
Some({
|
|
61
|
+
start,
|
|
62
|
+
complete,
|
|
63
|
+
roles: selfServiceGroups(structures),
|
|
64
|
+
openRoles: ?openRolesField(structures),
|
|
65
|
+
})
|
|
66
|
+
| _ => None
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let toJson = (c: config): JSON.t => {
|
|
70
|
+
let entries = Dict.fromArray([
|
|
71
|
+
("start", JSON.Encode.string(c.start)),
|
|
72
|
+
("complete", JSON.Encode.string(c.complete)),
|
|
73
|
+
("roles", c.roles->Array.map(JSON.Encode.string)->JSON.Encode.array),
|
|
74
|
+
])
|
|
75
|
+
c.openRoles->Option.forEach(q => entries->Dict.set("openRoles", JSON.Encode.string(q)))
|
|
76
|
+
JSON.Encode.object(entries)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let configEntry = (c: config): (string, JSON.t) => (configKey, toJson(c))
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
|
|
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";
|
|
6
|
+
import * as Admission$Reventless from "@reventlessdev/reventless-spec/src/types/Admission.res.mjs";
|
|
7
|
+
import * as Api_Naming$ReventlessCore from "../components/Api/Api_Naming.res.mjs";
|
|
8
|
+
|
|
9
|
+
let configKey = "selfRegistration";
|
|
10
|
+
|
|
11
|
+
function marked(structures, part) {
|
|
12
|
+
return Stdlib_Array.findMap(structures, param => {
|
|
13
|
+
let plugin = param[0];
|
|
14
|
+
return Stdlib_Option.map(Stdlib_Option.getOr(param[1].admissionDoors, []).find(d => d.part === Admission$Reventless.doorName(part)), d => [
|
|
15
|
+
plugin,
|
|
16
|
+
d
|
|
17
|
+
]);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function doorField(structures, part) {
|
|
22
|
+
return Stdlib_Option.map(marked(structures, part), param => Api_Naming$ReventlessCore.sliceMutationField(param[0], param[1].component));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function openRolesField(structures) {
|
|
26
|
+
return Stdlib_Option.map(marked(structures, "OpenRoles"), param => Api_Naming$ReventlessCore.queryFieldNamesForStateView(param[0], param[1].component, undefined).listFieldName);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function selfServiceGroups(structures) {
|
|
30
|
+
return structures.flatMap(param => {
|
|
31
|
+
let match = Stdlib_Option.map(param[1].admission, Admission$Reventless.fromDefs);
|
|
32
|
+
if (match !== undefined) {
|
|
33
|
+
if (match.TAG === "Ok") {
|
|
34
|
+
return Admission$Reventless.selfService(match._0).map(Role$Reventless.groupOf);
|
|
35
|
+
} else {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function fromStructures(structures) {
|
|
45
|
+
let match = doorField(structures, "Start");
|
|
46
|
+
let match$1 = doorField(structures, "Complete");
|
|
47
|
+
if (match !== undefined && match$1 !== undefined) {
|
|
48
|
+
return {
|
|
49
|
+
start: match,
|
|
50
|
+
complete: match$1,
|
|
51
|
+
roles: selfServiceGroups(structures),
|
|
52
|
+
openRoles: openRolesField(structures)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function toJson(c) {
|
|
58
|
+
let entries = Object.fromEntries([
|
|
59
|
+
[
|
|
60
|
+
"start",
|
|
61
|
+
c.start
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
"complete",
|
|
65
|
+
c.complete
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
"roles",
|
|
69
|
+
c.roles.map(prim => prim)
|
|
70
|
+
]
|
|
71
|
+
]);
|
|
72
|
+
Stdlib_Option.forEach(c.openRoles, q => {
|
|
73
|
+
entries["openRoles"] = q;
|
|
74
|
+
});
|
|
75
|
+
return entries;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function configEntry(c) {
|
|
79
|
+
return [
|
|
80
|
+
configKey,
|
|
81
|
+
toJson(c)
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export {
|
|
86
|
+
configKey,
|
|
87
|
+
marked,
|
|
88
|
+
doorField,
|
|
89
|
+
openRolesField,
|
|
90
|
+
selfServiceGroups,
|
|
91
|
+
fromStructures,
|
|
92
|
+
toJson,
|
|
93
|
+
configEntry,
|
|
94
|
+
}
|
|
95
|
+
/* Role-Reventless Not a pure module */
|
|
@@ -59,9 +59,9 @@ let inspectMutationFields = (~fieldPrefix: string, commandSchema: S.t<'a>): arra
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
type queryFieldInspection = {
|
|
62
|
-
typeDef
|
|
62
|
+
typeDef?: string,
|
|
63
63
|
singleQuery: string,
|
|
64
|
-
listQuery
|
|
64
|
+
listQuery?: string,
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
let inspectQueryFields = (
|
|
@@ -83,7 +83,7 @@ let inspectQueryFields = (
|
|
|
83
83
|
~pluralTypeName=pluralName,
|
|
84
84
|
),
|
|
85
85
|
)
|
|
86
|
-
{typeDef, singleQuery, listQuery}
|
|
86
|
+
{?typeDef, singleQuery, ?listQuery}
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
// ── Plugin Level — Fragment Inspector ───────────────────────────────────────
|
|
@@ -312,7 +312,7 @@ and withSemantic = (fieldSchema: JSON.t, sem: Reventless.Semantic.t): JSON.t =>
|
|
|
312
312
|
obj->Dict.set("x-reventless-semantic-source", str("type"))
|
|
313
313
|
switch sem.payload {
|
|
314
314
|
| Plain => ()
|
|
315
|
-
| ReferenceTo({entity, plugin, ?identity}) =>
|
|
315
|
+
| ReferenceTo({entity, ?plugin, ?identity}) =>
|
|
316
316
|
let pairs = withOptionalPlugin([("entity", str(entity))], plugin)
|
|
317
317
|
let pairs = switch identity {
|
|
318
318
|
| Some(key) => Array.concat(pairs, [("identity", str(key))])
|
|
@@ -321,14 +321,14 @@ and withSemantic = (fieldSchema: JSON.t, sem: Reventless.Semantic.t): JSON.t =>
|
|
|
321
321
|
obj->Dict.set("x-reventless-semantic-target", jsonObject(pairs))
|
|
322
322
|
| IdentityOf({key}) =>
|
|
323
323
|
obj->Dict.set("x-reventless-semantic-target", jsonObject([("key", str(key))]))
|
|
324
|
-
| StoredIn({plugin, store}) =>
|
|
324
|
+
| StoredIn({?plugin, store}) =>
|
|
325
325
|
// An absent plugin means "this plugin's own store" — omit the key rather
|
|
326
326
|
// than writing an empty string, so a reader never has to tell those apart.
|
|
327
327
|
obj->Dict.set(
|
|
328
328
|
"x-reventless-semantic-target",
|
|
329
329
|
jsonObject(withOptionalPlugin([("store", str(store))], plugin)),
|
|
330
330
|
)
|
|
331
|
-
| MemberOf({plugin, view, field, content}) =>
|
|
331
|
+
| MemberOf({?plugin, ?view, field, ?content}) =>
|
|
332
332
|
// Same channel as the two above, and `view` and `content` are omitted on
|
|
333
333
|
// the same terms as `plugin`: absent means the collection is on the row
|
|
334
334
|
// this field is already part of, and that the member's kind is the
|
|
@@ -47,17 +47,17 @@ let mergedEventSchema = (schemas: array<S.t<unknown>>) =>
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
type dcbResult = {
|
|
50
|
-
dcbEventLogOutputs
|
|
50
|
+
dcbEventLogOutputs?: DcbEventLog.outputs,
|
|
51
51
|
stateChangeSlicesOutputs: dict<StateChangeSlice.outputs>,
|
|
52
52
|
stateViewSlicesOutputs: dict<StateViewSlice.outputs>,
|
|
53
53
|
automationSlicesOutputs: dict<AutomationSlice.outputs>,
|
|
54
54
|
outboundTranslationSlicesOutputs: dict<OutboundTranslationSlice.outputs>,
|
|
55
55
|
inboundTranslationSlicesOutputs: dict<InboundTranslationSlice.outputs>,
|
|
56
|
-
dcbRuntimeSetup
|
|
56
|
+
dcbRuntimeSetup?: unit => unit,
|
|
57
57
|
// Shared publishJsons for all DCB StateChangeSlices in this plugin (same command topic).
|
|
58
58
|
// Used by Plugin_Builder to register slice names in publishToAggregates so extensions
|
|
59
59
|
// can dispatch commands to DCB slices via the same mechanism as regular aggregates.
|
|
60
|
-
dcbPublishJsons
|
|
60
|
+
dcbPublishJsons?: Pulumi.Output.t<CommandTopic.publishJsons>,
|
|
61
61
|
// SQS URL of the DCB command topic — shared by all StateChangeSlices in this
|
|
62
62
|
// plugin. Surfaced so the bundled Plugin EventCollector Lambda can dispatch
|
|
63
63
|
// PublishStateChangeSliceCommand actions from user extensions to the right
|
|
@@ -75,14 +75,11 @@ type dcbResult = {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
let emptyResult: dcbResult = {
|
|
78
|
-
dcbEventLogOutputs: None,
|
|
79
78
|
stateChangeSlicesOutputs: Dict.make(),
|
|
80
79
|
stateViewSlicesOutputs: Dict.make(),
|
|
81
80
|
automationSlicesOutputs: Dict.make(),
|
|
82
81
|
outboundTranslationSlicesOutputs: Dict.make(),
|
|
83
82
|
inboundTranslationSlicesOutputs: Dict.make(),
|
|
84
|
-
dcbRuntimeSetup: None,
|
|
85
|
-
dcbPublishJsons: None,
|
|
86
83
|
dcbCommandTopicQueueUrl: Pulumi.Output.make(""),
|
|
87
84
|
mutationEntries: [],
|
|
88
85
|
queryEntries: [],
|
|
@@ -1267,7 +1264,7 @@ module Make = (
|
|
|
1267
1264
|
}
|
|
1268
1265
|
})
|
|
1269
1266
|
{
|
|
1270
|
-
dcbEventLogOutputs:
|
|
1267
|
+
dcbEventLogOutputs: dcbEventLog->Component.outputs,
|
|
1271
1268
|
stateChangeSlicesOutputs: Dict.fromArray(
|
|
1272
1269
|
Array.concat(
|
|
1273
1270
|
stateChangeSlicesOutputs->Dict.toArray,
|
|
@@ -1278,8 +1275,8 @@ module Make = (
|
|
|
1278
1275
|
automationSlicesOutputs,
|
|
1279
1276
|
outboundTranslationSlicesOutputs,
|
|
1280
1277
|
inboundTranslationSlicesOutputs,
|
|
1281
|
-
dcbRuntimeSetup
|
|
1282
|
-
dcbPublishJsons:
|
|
1278
|
+
dcbRuntimeSetup,
|
|
1279
|
+
dcbPublishJsons: publishJsons,
|
|
1283
1280
|
dcbCommandTopicQueueUrl,
|
|
1284
1281
|
mutationEntries: Array.concat(mutationEntriesFromSlices, mutationEntriesFromInboundSlices),
|
|
1285
1282
|
queryEntries: stateViewEntries
|
|
@@ -107,14 +107,11 @@ let emptyResult_queryEntries = [];
|
|
|
107
107
|
let emptyResult_eventLogEntries = [];
|
|
108
108
|
|
|
109
109
|
let emptyResult = {
|
|
110
|
-
dcbEventLogOutputs: undefined,
|
|
111
110
|
stateChangeSlicesOutputs: emptyResult_stateChangeSlicesOutputs,
|
|
112
111
|
stateViewSlicesOutputs: emptyResult_stateViewSlicesOutputs,
|
|
113
112
|
automationSlicesOutputs: emptyResult_automationSlicesOutputs,
|
|
114
113
|
outboundTranslationSlicesOutputs: emptyResult_outboundTranslationSlicesOutputs,
|
|
115
114
|
inboundTranslationSlicesOutputs: emptyResult_inboundTranslationSlicesOutputs,
|
|
116
|
-
dcbRuntimeSetup: undefined,
|
|
117
|
-
dcbPublishJsons: undefined,
|
|
118
115
|
dcbCommandTopicQueueUrl: emptyResult_dcbCommandTopicQueueUrl,
|
|
119
116
|
mutationEntries: emptyResult_mutationEntries,
|
|
120
117
|
queryEntries: emptyResult_queryEntries,
|
|
@@ -13,6 +13,13 @@ module Make = (
|
|
|
13
13
|
let api: unit => QueryDbStorage.api
|
|
14
14
|
let apiRole: unit => QueryDbStorage.role
|
|
15
15
|
},
|
|
16
|
+
// What the platform provisioned, for `translate` to reach — the outbound
|
|
17
|
+
// builder's parameter, for the same reason: a platform that omits it does not
|
|
18
|
+
// compile. Read per request, so a provider registered after this functor is
|
|
19
|
+
// applied is still the one a request meets.
|
|
20
|
+
Capabilities: {
|
|
21
|
+
let capabilities: unit => Reventless.Capabilities.t
|
|
22
|
+
},
|
|
16
23
|
) => {
|
|
17
24
|
module Make = (
|
|
18
25
|
Spec: Reventless.InboundTranslationSlice.Spec,
|
|
@@ -82,7 +89,13 @@ module Make = (
|
|
|
82
89
|
->Pulumi.Output.apply(((queryDbOps, publishJsonsFn)) => {
|
|
83
90
|
let ops: InboundTranslationSlice.operations = {
|
|
84
91
|
receive: async (inputJson, ~caller=?, ~door=?) => {
|
|
85
|
-
let result = await Callback.receive(
|
|
92
|
+
let result = await Callback.receive(
|
|
93
|
+
publishJsonsFn,
|
|
94
|
+
inputJson,
|
|
95
|
+
~capabilities=Capabilities.capabilities(),
|
|
96
|
+
~caller?,
|
|
97
|
+
~door?,
|
|
98
|
+
)
|
|
86
99
|
await syncToQueryDb(queryDbOps, result->InboundTranslationSlice_Callback.requestIdOf)
|
|
87
100
|
result
|
|
88
101
|
},
|
|
@@ -11,7 +11,7 @@ import * as InboundTranslationSlice$ReventlessCore from "./InboundTranslationSli
|
|
|
11
11
|
import * as InboundTranslationSlice_Callback$ReventlessCore from "./InboundTranslationSlice_Callback.res.mjs";
|
|
12
12
|
|
|
13
13
|
function Make(QueryDbStorage) {
|
|
14
|
-
return QueryDbResolvers => (Api => {
|
|
14
|
+
return QueryDbResolvers => (Api => (Capabilities => {
|
|
15
15
|
let Make = Spec => (Translation => {
|
|
16
16
|
let Callback = InboundTranslationSlice_Callback$ReventlessCore.Make(Spec)(Translation);
|
|
17
17
|
let queryDbName = Spec.name + "Audit";
|
|
@@ -58,7 +58,7 @@ function Make(QueryDbStorage) {
|
|
|
58
58
|
let queryDbOps = param[0];
|
|
59
59
|
return {
|
|
60
60
|
receive: async (inputJson, caller, door) => {
|
|
61
|
-
let result = await Callback.receive(publishJsonsFn, inputJson, caller, door);
|
|
61
|
+
let result = await Callback.receive(publishJsonsFn, inputJson, Capabilities.capabilities(), caller, door);
|
|
62
62
|
await syncToQueryDb(queryDbOps, InboundTranslationSlice_Callback$ReventlessCore.requestIdOf(result));
|
|
63
63
|
return result;
|
|
64
64
|
},
|
|
@@ -87,7 +87,7 @@ function Make(QueryDbStorage) {
|
|
|
87
87
|
return {
|
|
88
88
|
Make: Make
|
|
89
89
|
};
|
|
90
|
-
});
|
|
90
|
+
}));
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
export {
|