@reventlessdev/reventless-core 3.0.0-alpha.307 → 3.0.0-alpha.308
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 +32 -0
- package/package.json +6 -6
- 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 +54 -0
- package/src/admin/Platform_SelfRegistration.res.mjs +77 -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 +70 -0
- package/tests/admin/Platform_SelfRegistrationTest.res.mjs +98 -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
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,38 @@
|
|
|
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.308 (2026-10-25)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **core:** the plugin-structures query carries a plugin's admission and its doors ([c881564](https://github.com/ReventlessDev/reventless-core/commit/c881564eefe9d9d67fd14a792ca4788a89cf40df))
|
|
11
|
+
* refactor!: internal results and tool records whose parts may be absent are optional fields ([7009ddf](https://github.com/ReventlessDev/reventless-core/commit/7009ddf5d522f39ec9946a3b5cd062ceae889bbf))
|
|
12
|
+
* refactor(aws)!: deploy and runtime configuration a function may lack are optional fields ([de80a54](https://github.com/ReventlessDev/reventless-core/commit/de80a546501a97b39cbe71200120f062bb260da4))
|
|
13
|
+
* refactor(spec)!: the plugin structure's optional parts are optional fields ([130bad5](https://github.com/ReventlessDev/reventless-core/commit/130bad581caf725a9d61b5a3df3d012e4f8ba402))
|
|
14
|
+
* feat!: an inbound translation is async and handed the platform's capabilities, and its audit row withholds sensitive fields ([dae6049](https://github.com/ReventlessDev/reventless-core/commit/dae6049e084f81408a494a2cd2011ec564dda65c))
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* a door open to anonymous callers is limited per source address, and answers Throttled past the limit ([259a671](https://github.com/ReventlessDev/reventless-core/commit/259a671969dd25579d26227a8fe80cba3194f0aa))
|
|
18
|
+
* a plugin declares per role how a person is admitted, and the local platform honors the self-service and provisioned halves ([9c37bf5](https://github.com/ReventlessDev/reventless-core/commit/9c37bf50f15cac1703bf2c351713518121a56211))
|
|
19
|
+
* a stash capability holds a value for minutes outside the log and hands it over once ([627f285](https://github.com/ReventlessDev/reventless-core/commit/627f28529ead2d2d31bdd091c9f42e7faca40f6f))
|
|
20
|
+
* **core:** a slice that reads no earlier event about its own identity creates its row ([21d8efe](https://github.com/ReventlessDev/reventless-core/commit/21d8efe646894689f7afe076244198b25643a15a))
|
|
21
|
+
|
|
22
|
+
### BREAKING CHANGES
|
|
23
|
+
|
|
24
|
+
* code that builds these records drops `name: None` and
|
|
25
|
+
writes `name: x` for `name: Some(x)`; a destructure of one of them binds a
|
|
26
|
+
field that may be absent with `?name`.
|
|
27
|
+
* code that builds these records drops `name: None` and
|
|
28
|
+
writes `name: x` for `name: Some(x)`.
|
|
29
|
+
* code that builds these records drops `name: None`, writes
|
|
30
|
+
`name: x` for `name: Some(x)`, and `name: ?x` for a value already of type
|
|
31
|
+
option.
|
|
32
|
+
* an inbound translation's translate takes ~capabilities and
|
|
33
|
+
returns a promise, and its spec must declare capabilityNeeds ([] for one that
|
|
34
|
+
only maps input). FromSlice steps return promises.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
# 3.0.0-alpha.307 (2026-10-23)
|
|
7
39
|
|
|
8
40
|
### Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reventlessdev/reventless-core",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.308",
|
|
4
4
|
"description": "Core package for Reventless framework",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"jest": {
|
|
@@ -29,16 +29,16 @@
|
|
|
29
29
|
"sury": "11.0.0",
|
|
30
30
|
"uuid": "^13.0.0",
|
|
31
31
|
"@reventlessdev/rescript-effect": "1.0.0-alpha.1",
|
|
32
|
-
"@reventlessdev/rescript-fast-csv": "2.0.0-alpha.23",
|
|
33
32
|
"@reventlessdev/rescript-hash-object": "1.2.0-alpha.15",
|
|
34
|
-
"@reventlessdev/rescript-jest": "1.0.0-alpha.13",
|
|
35
33
|
"@reventlessdev/rescript-node": "2.0.0-alpha.23",
|
|
36
|
-
"@reventlessdev/rescript-
|
|
34
|
+
"@reventlessdev/rescript-fast-csv": "2.0.0-alpha.23",
|
|
35
|
+
"@reventlessdev/rescript-jest": "1.0.0-alpha.13",
|
|
37
36
|
"@reventlessdev/rescript-pulumi-pulumi": "3.0.0-alpha.0",
|
|
37
|
+
"@reventlessdev/rescript-ssh2": "2.0.0-alpha.24",
|
|
38
38
|
"@reventlessdev/rescript-uuid": "2.0.0-alpha.1",
|
|
39
|
+
"@reventlessdev/reventless-infra": "3.0.0-alpha.205",
|
|
39
40
|
"@reventlessdev/reventless-interop": "3.0.0-alpha.42",
|
|
40
|
-
"@reventlessdev/reventless-
|
|
41
|
-
"@reventlessdev/reventless-spec": "3.0.0-alpha.175"
|
|
41
|
+
"@reventlessdev/reventless-spec": "3.0.0-alpha.176"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"rescript": "12.3.1",
|
package/src/Projection.res
CHANGED
|
@@ -18,7 +18,7 @@ let logAction = makeStr => log.debugLazy(~comp="Projection", makeStr)
|
|
|
18
18
|
// schema and applied to one JSON round trip per written state.
|
|
19
19
|
|
|
20
20
|
type overlays = {
|
|
21
|
-
displayName
|
|
21
|
+
displayName?: Reventless.DisplayName.displayNameSpec,
|
|
22
22
|
// (trail field, lifecycle field). A trail with no lifecycle field to follow
|
|
23
23
|
// records nothing — there is no value to append.
|
|
24
24
|
trail: option<(string, string)>,
|
|
@@ -33,7 +33,7 @@ let overlaysFor = (stateSchema: S.t<unknown>): option<overlays> => {
|
|
|
33
33
|
| (Some(trailField), Some(lifecycleField)) => Some((trailField, lifecycleField))
|
|
34
34
|
| _ => None
|
|
35
35
|
}
|
|
36
|
-
displayName->Option.isNone && trail->Option.isNone ? None : Some({displayName, trail})
|
|
36
|
+
displayName->Option.isNone && trail->Option.isNone ? None : Some({?displayName, trail})
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// `priorLifecycle` is what the row's lifecycle field held before the action.
|
|
@@ -42,7 +42,7 @@ let overlaysFor = (stateSchema: S.t<unknown>): option<overlays> => {
|
|
|
42
42
|
// read one would produce a different trail on every replay.
|
|
43
43
|
let applyOverlays = (
|
|
44
44
|
stateDict: dict<JSON.t>,
|
|
45
|
-
{displayName, trail}: overlays,
|
|
45
|
+
{?displayName, trail}: overlays,
|
|
46
46
|
~priorLifecycle: option<JSON.t>,
|
|
47
47
|
~at: string,
|
|
48
48
|
): unit => {
|
|
@@ -135,7 +135,7 @@ let rewriteAction = (action: action<'id, 'state>, ~at: string, stateSchema: S.t<
|
|
|
135
135
|
// The trail alone, for the two callers that must not compose `displayName`.
|
|
136
136
|
let trailOverlays = (stateSchema: option<S.t<unknown>>): option<overlays> =>
|
|
137
137
|
switch stateSchema->Option.flatMap(overlaysFor) {
|
|
138
|
-
| Some({trail: Some(_)} as overlays) => Some({...overlays, displayName: None})
|
|
138
|
+
| Some({trail: Some(_)} as overlays) => Some({...overlays, displayName: ?None})
|
|
139
139
|
| _ => None
|
|
140
140
|
}
|
|
141
141
|
|
package/src/Projection.res.mjs
CHANGED
|
@@ -74,10 +74,10 @@ function rewriteActionWith(action, overlays, toDict, fromDict, at) {
|
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
let updated = (fn, state) => apply(fn(state), overlays, priorLifecycleOf(state));
|
|
77
|
-
let labelled = state =>
|
|
78
|
-
|
|
79
|
-
trail
|
|
80
|
-
}
|
|
77
|
+
let labelled = state => {
|
|
78
|
+
let newrecord = {...overlays};
|
|
79
|
+
return apply(state, (newrecord.trail = undefined, newrecord), undefined);
|
|
80
|
+
};
|
|
81
81
|
if (typeof action !== "object") {
|
|
82
82
|
return action;
|
|
83
83
|
}
|
|
@@ -176,12 +176,14 @@ function rewriteAction(action, at, stateSchema) {
|
|
|
176
176
|
|
|
177
177
|
function trailOverlays(stateSchema) {
|
|
178
178
|
let overlays = Stdlib_Option.flatMap(stateSchema, overlaysFor);
|
|
179
|
-
if (overlays
|
|
180
|
-
return
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
179
|
+
if (overlays === undefined) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (overlays.trail === undefined) {
|
|
183
|
+
return;
|
|
184
184
|
}
|
|
185
|
+
let newrecord = {...overlays};
|
|
186
|
+
return newrecord.displayName = undefined, newrecord;
|
|
185
187
|
}
|
|
186
188
|
|
|
187
189
|
function rewriteTrail(action, at, stateSchema) {
|
|
@@ -150,14 +150,14 @@ importable from code that ends up in a Lambda bundle.
|
|
|
150
150
|
Outside any plugin construct both are `None` — the correct answer for
|
|
151
151
|
platform-scope substrate.
|
|
152
152
|
*/
|
|
153
|
-
type context = {platform
|
|
153
|
+
type context = {platform?: string, plugin?: string}
|
|
154
154
|
|
|
155
|
-
let current: ref<context> = ref({
|
|
155
|
+
let current: ref<context> = ref(({}: context))
|
|
156
156
|
|
|
157
157
|
/** Publish the plugin being constructed; returns the previous context to restore. */
|
|
158
158
|
let enter = (~platform: string, ~plugin: string) => {
|
|
159
159
|
let previous = current.contents
|
|
160
|
-
current := {platform
|
|
160
|
+
current := {platform, plugin}
|
|
161
161
|
previous
|
|
162
162
|
}
|
|
163
163
|
|
|
@@ -77,57 +77,52 @@ stored state) resolves `None` by minting `membership` and marking
|
|
|
77
77
|
type conformanceCase = {
|
|
78
78
|
label: string,
|
|
79
79
|
membership: array<string>,
|
|
80
|
-
requested
|
|
81
|
-
expected
|
|
80
|
+
requested?: string,
|
|
81
|
+
expected?: array<string>,
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
let conformanceCases: array<conformanceCase> = [
|
|
85
85
|
{
|
|
86
86
|
label: "no role requested mints exactly what it always minted",
|
|
87
87
|
membership: ["Fulfilment", "Shopper"],
|
|
88
|
-
|
|
89
|
-
expected: Some(["Fulfilment", "Shopper"]),
|
|
88
|
+
expected: ["Fulfilment", "Shopper"],
|
|
90
89
|
},
|
|
91
90
|
{
|
|
92
91
|
label: "a held role narrows to that role alone",
|
|
93
92
|
membership: ["Fulfilment", "Shopper"],
|
|
94
|
-
requested:
|
|
95
|
-
expected:
|
|
93
|
+
requested: "Shopper",
|
|
94
|
+
expected: ["Shopper"],
|
|
96
95
|
},
|
|
97
96
|
{
|
|
98
97
|
label: "the other held role narrows just as well",
|
|
99
98
|
membership: ["Fulfilment", "Shopper"],
|
|
100
|
-
requested:
|
|
101
|
-
expected:
|
|
99
|
+
requested: "Fulfilment",
|
|
100
|
+
expected: ["Fulfilment"],
|
|
102
101
|
},
|
|
103
102
|
{
|
|
104
103
|
label: "a role the caller does not hold is refused, never widened into",
|
|
105
104
|
membership: ["Fulfilment", "Shopper"],
|
|
106
|
-
requested:
|
|
107
|
-
expected: None,
|
|
105
|
+
requested: "Admin",
|
|
108
106
|
},
|
|
109
107
|
{
|
|
110
108
|
label: "a sole role narrows to itself rather than being a special case",
|
|
111
109
|
membership: ["Shopper"],
|
|
112
|
-
requested:
|
|
113
|
-
expected:
|
|
110
|
+
requested: "Shopper",
|
|
111
|
+
expected: ["Shopper"],
|
|
114
112
|
},
|
|
115
113
|
{
|
|
116
114
|
label: "a caller holding nothing can request nothing",
|
|
117
115
|
membership: [],
|
|
118
|
-
requested:
|
|
119
|
-
expected: None,
|
|
116
|
+
requested: "Shopper",
|
|
120
117
|
},
|
|
121
118
|
{
|
|
122
119
|
label: "the empty string is a request, and one no caller can hold",
|
|
123
120
|
membership: ["Shopper"],
|
|
124
|
-
requested:
|
|
125
|
-
expected: None,
|
|
121
|
+
requested: "",
|
|
126
122
|
},
|
|
127
123
|
{
|
|
128
124
|
label: "group names are matched exactly, not case-insensitively",
|
|
129
125
|
membership: ["Shopper"],
|
|
130
|
-
requested:
|
|
131
|
-
expected: None,
|
|
126
|
+
requested: "shopper",
|
|
132
127
|
},
|
|
133
128
|
]
|
|
@@ -8,7 +8,6 @@ let conformanceCases = [
|
|
|
8
8
|
"Fulfilment",
|
|
9
9
|
"Shopper"
|
|
10
10
|
],
|
|
11
|
-
requested: undefined,
|
|
12
11
|
expected: [
|
|
13
12
|
"Fulfilment",
|
|
14
13
|
"Shopper"
|
|
@@ -38,8 +37,7 @@ let conformanceCases = [
|
|
|
38
37
|
"Fulfilment",
|
|
39
38
|
"Shopper"
|
|
40
39
|
],
|
|
41
|
-
requested: "Admin"
|
|
42
|
-
expected: undefined
|
|
40
|
+
requested: "Admin"
|
|
43
41
|
},
|
|
44
42
|
{
|
|
45
43
|
label: "a sole role narrows to itself rather than being a special case",
|
|
@@ -50,20 +48,17 @@ let conformanceCases = [
|
|
|
50
48
|
{
|
|
51
49
|
label: "a caller holding nothing can request nothing",
|
|
52
50
|
membership: [],
|
|
53
|
-
requested: "Shopper"
|
|
54
|
-
expected: undefined
|
|
51
|
+
requested: "Shopper"
|
|
55
52
|
},
|
|
56
53
|
{
|
|
57
54
|
label: "the empty string is a request, and one no caller can hold",
|
|
58
55
|
membership: ["Shopper"],
|
|
59
|
-
requested: ""
|
|
60
|
-
expected: undefined
|
|
56
|
+
requested: ""
|
|
61
57
|
},
|
|
62
58
|
{
|
|
63
59
|
label: "group names are matched exactly, not case-insensitively",
|
|
64
60
|
membership: ["Shopper"],
|
|
65
|
-
requested: "shopper"
|
|
66
|
-
expected: undefined
|
|
61
|
+
requested: "shopper"
|
|
67
62
|
}
|
|
68
63
|
];
|
|
69
64
|
|
|
@@ -160,6 +160,6 @@ let notify = (
|
|
|
160
160
|
// The owning plugin/platform come from the ambient context the plugin builder publishes
|
|
161
161
|
// (ResourceAttribution.enter) — populated exactly when this fires, so the call sites need not
|
|
162
162
|
// thread the names. `None` outside a plugin construct.
|
|
163
|
-
let {ResourceAttribution.plugin: plugin, platform} = ResourceAttribution.current.contents
|
|
163
|
+
let {ResourceAttribution.plugin: ?plugin, ?platform} = ResourceAttribution.current.contents
|
|
164
164
|
B.onProvisioned(~logStyle, ~name, ~owner, ~plugin, ~platform, ~resources, ~opts)
|
|
165
165
|
}
|
|
@@ -123,9 +123,9 @@ type announcement = {
|
|
|
123
123
|
kind: unitKind,
|
|
124
124
|
name: string,
|
|
125
125
|
component: ReventlessInfra.Adapter.resource,
|
|
126
|
-
plugin
|
|
127
|
-
platform
|
|
128
|
-
logLocator
|
|
126
|
+
plugin?: string,
|
|
127
|
+
platform?: string,
|
|
128
|
+
logLocator?: Pulumi.Output.t<string>,
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
let pending: ref<array<announcement>> = ref([])
|
|
@@ -190,11 +190,11 @@ let notify = (
|
|
|
190
190
|
// Read here rather than at delivery, because a buffered announcement is replayed from a deploy
|
|
191
191
|
// program's body, where the ambient context is whatever the *next* construct left behind. The
|
|
192
192
|
// owner belongs to the moment the unit was provisioned.
|
|
193
|
-
let {ResourceAttribution.plugin: plugin, platform} = ResourceAttribution.current.contents
|
|
193
|
+
let {ResourceAttribution.plugin: ?plugin, ?platform} = ResourceAttribution.current.contents
|
|
194
194
|
// `~logLocator`, unlike the owner, is NOT ambient: only the provisioning site knows where it
|
|
195
195
|
// pointed the unit's logs. So it is passed, and optional — a call site with nothing to say omits
|
|
196
196
|
// it rather than being forced to invent an address.
|
|
197
|
-
let announcement = {kind, name, component, plugin, platform, logLocator}
|
|
197
|
+
let announcement = {kind, name, component, ?plugin, ?platform, ?logLocator}
|
|
198
198
|
if registered.contents {
|
|
199
199
|
deliver(backend.contents, announcement)
|
|
200
200
|
} else {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// A stash in this process's memory: what the local platform provisions, since
|
|
2
|
+
// the door that puts and the slice that takes run in one process there.
|
|
3
|
+
//
|
|
4
|
+
// Lost on a restart, which is the right failure for what it holds: a restart
|
|
5
|
+
// between a person submitting a form and the slice acting on it leaves them to
|
|
6
|
+
// submit it again, and leaves no secret on disk.
|
|
7
|
+
|
|
8
|
+
type entry = {value: string, expiresAt: float}
|
|
9
|
+
|
|
10
|
+
/** A fresh, empty stash. `now` is injected so a test can move time instead of
|
|
11
|
+
waiting for it. */
|
|
12
|
+
let make = (~now: unit => float=Date.now): Reventless.Stash.t => {
|
|
13
|
+
let held: dict<entry> = Dict.make()
|
|
14
|
+
// Expired entries are dropped on every call, so nothing a person abandoned
|
|
15
|
+
// outlives its time by more than the next request.
|
|
16
|
+
let sweep = () => {
|
|
17
|
+
let at = now()
|
|
18
|
+
held
|
|
19
|
+
->Dict.toArray
|
|
20
|
+
->Array.forEach(((key, {expiresAt})) => expiresAt <= at ? held->Dict.delete(key) : ())
|
|
21
|
+
}
|
|
22
|
+
{
|
|
23
|
+
put: async (~key, ~value, ~ttl) => {
|
|
24
|
+
sweep()
|
|
25
|
+
held->Dict.set(key, {value, expiresAt: now() +. Int.toFloat(ttl) *. 1000.})
|
|
26
|
+
Ok()
|
|
27
|
+
},
|
|
28
|
+
take: async (~key) => {
|
|
29
|
+
sweep()
|
|
30
|
+
let found = held->Dict.get(key)->Option.map(e => e.value)
|
|
31
|
+
held->Dict.delete(key)
|
|
32
|
+
Ok(found)
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Stdlib_Dict from "@rescript/runtime/lib/es6/Stdlib_Dict.js";
|
|
4
|
+
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
5
|
+
|
|
6
|
+
function make(nowOpt) {
|
|
7
|
+
let now = nowOpt !== undefined ? nowOpt : prim => Date.now();
|
|
8
|
+
let held = {};
|
|
9
|
+
let sweep = () => {
|
|
10
|
+
let at = now();
|
|
11
|
+
Object.entries(held).forEach(param => {
|
|
12
|
+
if (param[1].expiresAt <= at) {
|
|
13
|
+
return Stdlib_Dict.$$delete(held, param[0]);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
put: async (key, value, ttl) => {
|
|
19
|
+
sweep();
|
|
20
|
+
held[key] = {
|
|
21
|
+
value: value,
|
|
22
|
+
expiresAt: now() + ttl * 1000
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
TAG: "Ok",
|
|
26
|
+
_0: undefined
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
take: async key => {
|
|
30
|
+
sweep();
|
|
31
|
+
let found = Stdlib_Option.map(held[key], e => e.value);
|
|
32
|
+
Stdlib_Dict.$$delete(held, key);
|
|
33
|
+
return {
|
|
34
|
+
TAG: "Ok",
|
|
35
|
+
_0: found
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
make,
|
|
43
|
+
}
|
|
44
|
+
/* No side effect */
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Counts requests per door and source in fixed windows, and says whether one
|
|
2
|
+
// more is admitted. In memory: what a single process serving the doors needs.
|
|
3
|
+
//
|
|
4
|
+
// Fixed windows rather than sliding ones. A burst straddling a boundary can
|
|
5
|
+
// reach twice the limit, which bounds the abuse by a constant and keeps the
|
|
6
|
+
// state one counter per key.
|
|
7
|
+
|
|
8
|
+
type window = {startedAt: float, count: int}
|
|
9
|
+
|
|
10
|
+
type t = {admit: (~door: string, ~source: string) => bool}
|
|
11
|
+
|
|
12
|
+
/** A limiter for `limit`. `now` is injected so a test moves time instead of
|
|
13
|
+
waiting for it. */
|
|
14
|
+
let make = (~limit: Reventless.AnonymousRequestLimit.t, ~now: unit => float=Date.now): t => {
|
|
15
|
+
let windows: dict<window> = Dict.make()
|
|
16
|
+
let length = Int.toFloat(limit.windowSeconds) *. 1000.
|
|
17
|
+
{
|
|
18
|
+
admit: (~door, ~source) => {
|
|
19
|
+
let key = `${door}\u0000${source}`
|
|
20
|
+
let at = now()
|
|
21
|
+
// Expired windows are dropped as they are met, so the map holds only the
|
|
22
|
+
// sources seen within the last window.
|
|
23
|
+
windows
|
|
24
|
+
->Dict.toArray
|
|
25
|
+
->Array.forEach(((k, w)) => at -. w.startedAt >= length ? windows->Dict.delete(k) : ())
|
|
26
|
+
switch windows->Dict.get(key) {
|
|
27
|
+
| Some(w) if w.count >= limit.requests => false
|
|
28
|
+
| Some(w) =>
|
|
29
|
+
windows->Dict.set(key, {...w, count: w.count + 1})
|
|
30
|
+
true
|
|
31
|
+
| None =>
|
|
32
|
+
windows->Dict.set(key, {startedAt: at, count: 1})
|
|
33
|
+
true
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Stdlib_Dict from "@rescript/runtime/lib/es6/Stdlib_Dict.js";
|
|
4
|
+
|
|
5
|
+
function make(limit, nowOpt) {
|
|
6
|
+
let now = nowOpt !== undefined ? nowOpt : prim => Date.now();
|
|
7
|
+
let windows = {};
|
|
8
|
+
let length = limit.windowSeconds * 1000;
|
|
9
|
+
return {
|
|
10
|
+
admit: (door, source) => {
|
|
11
|
+
let key = door + `\u0000` + source;
|
|
12
|
+
let at = now();
|
|
13
|
+
Object.entries(windows).forEach(param => {
|
|
14
|
+
if (at - param[1].startedAt >= length) {
|
|
15
|
+
return Stdlib_Dict.$$delete(windows, param[0]);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
let w = windows[key];
|
|
19
|
+
if (w !== undefined) {
|
|
20
|
+
if (w.count >= limit.requests) {
|
|
21
|
+
return false;
|
|
22
|
+
} else {
|
|
23
|
+
windows[key] = {
|
|
24
|
+
startedAt: w.startedAt,
|
|
25
|
+
count: w.count + 1 | 0
|
|
26
|
+
};
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
windows[key] = {
|
|
31
|
+
startedAt: at,
|
|
32
|
+
count: 1
|
|
33
|
+
};
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
make,
|
|
42
|
+
}
|
|
43
|
+
/* No side effect */
|
|
@@ -13,7 +13,7 @@ type outputs = {
|
|
|
13
13
|
extensionPointsOutputs: Pulumi.Output.t<array<ExtensionPoint.outputs>>,
|
|
14
14
|
aggregatesOutputs: dict<Aggregate.outputs>,
|
|
15
15
|
readModelsOutputs: dict<ReadModel.outputs>,
|
|
16
|
-
dcbEventLogOutputs
|
|
16
|
+
dcbEventLogOutputs?: DcbEventLog.outputs,
|
|
17
17
|
stateChangeSlicesOutputs: dict<StateChangeSlice.outputs>,
|
|
18
18
|
stateViewSlicesOutputs: dict<StateViewSlice.outputs>,
|
|
19
19
|
automationSlicesOutputs: dict<AutomationSlice.outputs>,
|
|
@@ -449,7 +449,7 @@ module Make = (
|
|
|
449
449
|
extensionPointsOutputs,
|
|
450
450
|
aggregatesOutputs: aggregatesWithoutEventMappers,
|
|
451
451
|
readModelsOutputs,
|
|
452
|
-
dcbEventLogOutputs: dcbResult.dcbEventLogOutputs,
|
|
452
|
+
dcbEventLogOutputs: ?dcbResult.dcbEventLogOutputs,
|
|
453
453
|
stateChangeSlicesOutputs: dcbResult.stateChangeSlicesOutputs,
|
|
454
454
|
stateViewSlicesOutputs: dcbResult.stateViewSlicesOutputs,
|
|
455
455
|
automationSlicesOutputs: dcbResult.automationSlicesOutputs,
|
|
@@ -48,13 +48,11 @@ let pluginAggregate: writeSideDef = {
|
|
|
48
48
|
producedEventTypes: [],
|
|
49
49
|
consumedEventTypes: [],
|
|
50
50
|
linkedViews: ["Plugins"],
|
|
51
|
-
consistencyRead: None,
|
|
52
51
|
events: [],
|
|
53
52
|
// Derived rather than left empty like `events` above: the two admin commands can
|
|
54
53
|
// be refused, and `[]` here would read as "this aggregate never rejects". Uses
|
|
55
54
|
// the same walk `Plugin_Structure` applies to every other write side.
|
|
56
55
|
errors: Plugin_Structure.extractErrorDefs(PluginSpec.errorSchema->S.castToUnknown),
|
|
57
|
-
chapter: None,
|
|
58
56
|
}
|
|
59
57
|
|
|
60
58
|
// Functions, not values: the view's access keys are the group the platform maps
|
|
@@ -77,11 +75,6 @@ let structure = (): pluginStructure => {
|
|
|
77
75
|
outboundTranslationSlices: [],
|
|
78
76
|
inboundTranslationSlices: [],
|
|
79
77
|
extensions: [],
|
|
80
|
-
extensionPoints: None,
|
|
81
|
-
requiredStores: None,
|
|
82
|
-
requiredStoreDeclarations: None,
|
|
83
|
-
requiredCapabilities: None,
|
|
84
|
-
traitDeclarations: None,
|
|
85
78
|
}
|
|
86
79
|
|
|
87
80
|
/** The definition the platform's own EventCollector ships as its
|
|
@@ -103,8 +96,6 @@ let internalPluginDefinition: pluginDefinition = {
|
|
|
103
96
|
eventCollector: "NOT-SET",
|
|
104
97
|
extensionProtocols: [],
|
|
105
98
|
apiSchemaFragment: None,
|
|
106
|
-
apiTarget: None,
|
|
107
99
|
structure: None,
|
|
108
|
-
dcbEventLog: None,
|
|
109
100
|
kind: Domain,
|
|
110
101
|
}
|
|
@@ -8,7 +8,7 @@ import * as PluginsReadModelSpec$ReventlessCore from "../plugin/lifecycle/Plugin
|
|
|
8
8
|
|
|
9
9
|
let pluginId = "Platform";
|
|
10
10
|
|
|
11
|
-
let pluginCommands = Plugin_Structure$ReventlessCore.extractCommandDefs(undefined, true, undefined, variantName => Api_Naming$ReventlessCore.adminField(PluginSpec$ReventlessCore.name + "_" + variantName), name => Authorization$Reventless.named(PluginSpec$ReventlessCore.authorizationOf(name)), PluginSpec$ReventlessCore.commandTransition, undefined, PluginSpec$ReventlessCore.commandSchema);
|
|
11
|
+
let pluginCommands = Plugin_Structure$ReventlessCore.extractCommandDefs(undefined, true, undefined, undefined, variantName => Api_Naming$ReventlessCore.adminField(PluginSpec$ReventlessCore.name + "_" + variantName), name => Authorization$Reventless.named(PluginSpec$ReventlessCore.authorizationOf(name)), PluginSpec$ReventlessCore.commandTransition, undefined, PluginSpec$ReventlessCore.commandSchema);
|
|
12
12
|
|
|
13
13
|
let pluginAggregate_producedEventTypes = [];
|
|
14
14
|
|
|
@@ -26,10 +26,8 @@ let pluginAggregate = {
|
|
|
26
26
|
producedEventTypes: pluginAggregate_producedEventTypes,
|
|
27
27
|
consumedEventTypes: pluginAggregate_consumedEventTypes,
|
|
28
28
|
linkedViews: pluginAggregate_linkedViews,
|
|
29
|
-
consistencyRead: undefined,
|
|
30
29
|
events: pluginAggregate_events,
|
|
31
|
-
errors: pluginAggregate_errors
|
|
32
|
-
chapter: undefined
|
|
30
|
+
errors: pluginAggregate_errors
|
|
33
31
|
};
|
|
34
32
|
|
|
35
33
|
function pluginReadModel() {
|
|
@@ -45,12 +43,7 @@ function structure() {
|
|
|
45
43
|
automationSlices: [],
|
|
46
44
|
outboundTranslationSlices: [],
|
|
47
45
|
inboundTranslationSlices: [],
|
|
48
|
-
extensions: []
|
|
49
|
-
extensionPoints: undefined,
|
|
50
|
-
requiredStores: undefined,
|
|
51
|
-
requiredStoreDeclarations: undefined,
|
|
52
|
-
requiredCapabilities: undefined,
|
|
53
|
-
traitDeclarations: undefined
|
|
46
|
+
extensions: []
|
|
54
47
|
};
|
|
55
48
|
}
|
|
56
49
|
|
|
@@ -63,9 +56,7 @@ let internalPluginDefinition = {
|
|
|
63
56
|
eventCollector: "NOT-SET",
|
|
64
57
|
extensionProtocols: [],
|
|
65
58
|
apiSchemaFragment: undefined,
|
|
66
|
-
apiTarget: undefined,
|
|
67
59
|
structure: undefined,
|
|
68
|
-
dcbEventLog: undefined,
|
|
69
60
|
kind: "Domain"
|
|
70
61
|
};
|
|
71
62
|
|
|
@@ -60,9 +60,9 @@ let describe = (e: error): string =>
|
|
|
60
60
|
// that can honor it.
|
|
61
61
|
type selection = {
|
|
62
62
|
plugin: string,
|
|
63
|
-
views
|
|
64
|
-
commands
|
|
65
|
-
derived
|
|
63
|
+
views?: array<string>,
|
|
64
|
+
commands?: array<string>,
|
|
65
|
+
derived?: array<string>,
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
let publicViews = (def: pluginStructure): array<readSideDef> =>
|
|
@@ -204,9 +204,9 @@ let journeyKey = (~group: string): string => {
|
|
|
204
204
|
|
|
205
205
|
let toSelection = (s: ReventlessInfra.Platform.bakedManifestSelection): selection => {
|
|
206
206
|
plugin: s.plugin,
|
|
207
|
-
views: s.views,
|
|
208
|
-
commands: s.commands,
|
|
209
|
-
derived: s.derived,
|
|
207
|
+
views: ?s.views,
|
|
208
|
+
commands: ?s.commands,
|
|
209
|
+
derived: ?s.derived,
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
/** One declared journey, with everything a platform needs to serve it: the group
|
|
@@ -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
|
|