@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
|
@@ -15,6 +15,7 @@ import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/component
|
|
|
15
15
|
import * as Message$Reventless from "@reventlessdev/reventless-spec/src/types/Message.res.mjs";
|
|
16
16
|
import * as Schedule$Reventless from "@reventlessdev/reventless-spec/src/types/Schedule.res.mjs";
|
|
17
17
|
import * as Semantic$Reventless from "@reventlessdev/reventless-spec/src/semantic/Semantic.res.mjs";
|
|
18
|
+
import * as Admission$Reventless from "@reventlessdev/reventless-spec/src/types/Admission.res.mjs";
|
|
18
19
|
import * as Lifecycle$Reventless from "@reventlessdev/reventless-spec/src/types/Lifecycle.res.mjs";
|
|
19
20
|
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
20
21
|
import * as Reference$Reventless from "@reventlessdev/reventless-spec/src/components/Reference.res.mjs";
|
|
@@ -480,7 +481,6 @@ function identityReference(identityViews, fieldName, fieldSchema, declared) {
|
|
|
480
481
|
fieldName,
|
|
481
482
|
{
|
|
482
483
|
entity: view,
|
|
483
|
-
plugin: undefined,
|
|
484
484
|
identity: key
|
|
485
485
|
}
|
|
486
486
|
]];
|
|
@@ -494,7 +494,6 @@ function identityReference(identityViews, fieldName, fieldSchema, declared) {
|
|
|
494
494
|
fieldName,
|
|
495
495
|
{
|
|
496
496
|
entity: view$1,
|
|
497
|
-
plugin: undefined,
|
|
498
497
|
identity: key
|
|
499
498
|
}
|
|
500
499
|
]];
|
|
@@ -579,7 +578,65 @@ function isCreateCommandName(name) {
|
|
|
579
578
|
].some(p => name.startsWith(p));
|
|
580
579
|
}
|
|
581
580
|
|
|
582
|
-
function
|
|
581
|
+
function tagKeysByVariant(schema) {
|
|
582
|
+
let ofVariant = v => {
|
|
583
|
+
switch (v.type) {
|
|
584
|
+
case "string" :
|
|
585
|
+
let name = v.const;
|
|
586
|
+
if (name !== undefined) {
|
|
587
|
+
return [
|
|
588
|
+
name,
|
|
589
|
+
[]
|
|
590
|
+
];
|
|
591
|
+
} else {
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
case "object" :
|
|
595
|
+
let properties = v.properties;
|
|
596
|
+
let match = properties["TAG"];
|
|
597
|
+
if (match === undefined) {
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
if (match.type !== "string") {
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
let name$1 = match.const;
|
|
604
|
+
if (name$1 !== undefined) {
|
|
605
|
+
return [
|
|
606
|
+
name$1,
|
|
607
|
+
DcbTag$Reventless.tagKeysOfProperties(properties)
|
|
608
|
+
];
|
|
609
|
+
} else {
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
default:
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
if (schema.type === "anyOf") {
|
|
617
|
+
return Stdlib_Array.filterMap(schema.anyOf, ofVariant);
|
|
618
|
+
} else {
|
|
619
|
+
return Stdlib_Option.mapOr(ofVariant(schema), [], x => [x]);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
function createsBy(produced, consumed) {
|
|
624
|
+
let own = tagKeysByVariant(produced).map(param => param[0]);
|
|
625
|
+
let read = tagKeysByVariant(consumed);
|
|
626
|
+
let readsOwn = read.some(param => own.includes(param[0]));
|
|
627
|
+
let foreign = read.filter(param => !own.includes(param[0]));
|
|
628
|
+
let untold = foreign.some(param => Primitive_object.equal(param[1], []));
|
|
629
|
+
let foreignKeys = foreign.flatMap(param => param[1]);
|
|
630
|
+
return key => {
|
|
631
|
+
if (readsOwn && !untold) {
|
|
632
|
+
return !foreignKeys.includes(key);
|
|
633
|
+
} else {
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
function commandLevelAndId(isAggregate, partitionKey, createsFor, variantName, properties) {
|
|
583
640
|
if (isAggregate) {
|
|
584
641
|
if (isCreateCommandName(variantName)) {
|
|
585
642
|
return [
|
|
@@ -622,7 +679,8 @@ function commandLevelAndId(isAggregate, partitionKey, variantName, properties) {
|
|
|
622
679
|
];
|
|
623
680
|
}
|
|
624
681
|
let fieldName = taggedField[0];
|
|
625
|
-
|
|
682
|
+
let creates = Stdlib_Option.mapOr(createsFor, false, f => f(keyOf(taggedField)));
|
|
683
|
+
if (creates || isCreateCommandName(variantName)) {
|
|
626
684
|
return [
|
|
627
685
|
"Collection",
|
|
628
686
|
fieldName
|
|
@@ -684,9 +742,9 @@ function annotateArgTypes(schema, argTypes) {
|
|
|
684
742
|
return schema;
|
|
685
743
|
}
|
|
686
744
|
|
|
687
|
-
function toCommandDef(identityViews, isAggregate, partitionKey, mutationFieldFor, parentSchema, authorizationOf, commandTransition, derivedEdgeFor, v) {
|
|
745
|
+
function toCommandDef(identityViews, isAggregate, partitionKey, createsFor, mutationFieldFor, parentSchema, authorizationOf, commandTransition, derivedEdgeFor, v) {
|
|
688
746
|
let mkDef = (variantName, properties) => {
|
|
689
|
-
let match = commandLevelAndId(isAggregate, partitionKey, variantName, properties);
|
|
747
|
+
let match = commandLevelAndId(isAggregate, partitionKey, createsFor, variantName, properties);
|
|
690
748
|
let aggregateIdField = match[1];
|
|
691
749
|
let syntheticCommand$1 = syntheticCommand(parentSchema, variantName);
|
|
692
750
|
let declared = commandTransition(syntheticCommand$1);
|
|
@@ -771,12 +829,12 @@ function toCommandDef(identityViews, isAggregate, partitionKey, mutationFieldFor
|
|
|
771
829
|
}
|
|
772
830
|
}
|
|
773
831
|
|
|
774
|
-
function extractCommandDefs(identityViews, isAggregate, partitionKey, mutationFieldFor, authorizationOf, commandTransition, derivedEdgeForOpt, commandSchema) {
|
|
832
|
+
function extractCommandDefs(identityViews, isAggregate, partitionKey, createsFor, mutationFieldFor, authorizationOf, commandTransition, derivedEdgeForOpt, commandSchema) {
|
|
775
833
|
let derivedEdgeFor = derivedEdgeForOpt !== undefined ? derivedEdgeForOpt : param => {};
|
|
776
834
|
if (commandSchema.type === "anyOf") {
|
|
777
|
-
return Stdlib_Array.filterMap(commandSchema.anyOf, v => toCommandDef(identityViews, isAggregate, partitionKey, mutationFieldFor, commandSchema, authorizationOf, commandTransition, derivedEdgeFor, v));
|
|
835
|
+
return Stdlib_Array.filterMap(commandSchema.anyOf, v => toCommandDef(identityViews, isAggregate, partitionKey, createsFor, mutationFieldFor, commandSchema, authorizationOf, commandTransition, derivedEdgeFor, v));
|
|
778
836
|
} else {
|
|
779
|
-
return Stdlib_Option.mapOr(toCommandDef(identityViews, isAggregate, partitionKey, mutationFieldFor, commandSchema, authorizationOf, commandTransition, derivedEdgeFor, commandSchema), [], def => [def]);
|
|
837
|
+
return Stdlib_Option.mapOr(toCommandDef(identityViews, isAggregate, partitionKey, createsFor, mutationFieldFor, commandSchema, authorizationOf, commandTransition, derivedEdgeFor, commandSchema), [], def => [def]);
|
|
780
838
|
}
|
|
781
839
|
}
|
|
782
840
|
|
|
@@ -819,7 +877,7 @@ function readSideDefFromSpec(plugin, name, stateSchema, authorization, visibilit
|
|
|
819
877
|
};
|
|
820
878
|
}
|
|
821
879
|
|
|
822
|
-
function make(name, aggregatesOpt, readModelsOpt, stateViewSlicesOpt, stateChangeSlicesOpt, automationSlicesOpt, outboundTranslationSlicesOpt, inboundTranslationSlicesOpt, extensionsOpt, extensionPointsOpt, componentChaptersOpt, lifecycleModelOpt, identitiesOpt) {
|
|
880
|
+
function make(name, aggregatesOpt, readModelsOpt, stateViewSlicesOpt, stateChangeSlicesOpt, automationSlicesOpt, outboundTranslationSlicesOpt, inboundTranslationSlicesOpt, extensionsOpt, extensionPointsOpt, componentChaptersOpt, lifecycleModelOpt, identitiesOpt, admission, admissionDoorsOpt) {
|
|
823
881
|
let aggregates = aggregatesOpt !== undefined ? aggregatesOpt : [];
|
|
824
882
|
let readModels = readModelsOpt !== undefined ? readModelsOpt : [];
|
|
825
883
|
let stateViewSlices = stateViewSlicesOpt !== undefined ? stateViewSlicesOpt : [];
|
|
@@ -832,6 +890,7 @@ function make(name, aggregatesOpt, readModelsOpt, stateViewSlicesOpt, stateChang
|
|
|
832
890
|
let componentChapters = componentChaptersOpt !== undefined ? componentChaptersOpt : ({});
|
|
833
891
|
let lifecycleModel = lifecycleModelOpt !== undefined ? lifecycleModelOpt : [];
|
|
834
892
|
let identities = identitiesOpt !== undefined ? identitiesOpt : [];
|
|
893
|
+
let admissionDoors = admissionDoorsOpt !== undefined ? admissionDoorsOpt : [];
|
|
835
894
|
let chapterOf = compName => componentChapters[compName];
|
|
836
895
|
let model = declaredTransitionsOnly ? [] : lifecycleModel;
|
|
837
896
|
let derivedEdgeFor = (component, command) => model.find(e => {
|
|
@@ -1022,10 +1081,11 @@ function make(name, aggregatesOpt, readModelsOpt, stateViewSlicesOpt, stateChang
|
|
|
1022
1081
|
if (found.length !== 0) {
|
|
1023
1082
|
Stdlib_JsError.throwWithMessage(name + `: two declared object stores look like one store misspelled.\n` + found.map(Capability_Inference$ReventlessCore.collisionMessage).join("\n"));
|
|
1024
1083
|
}
|
|
1025
|
-
let
|
|
1084
|
+
let declarationsOf = (component, needs) => needs.map(need => ({
|
|
1026
1085
|
capability: CapabilityNeed$Reventless.toString(need),
|
|
1027
|
-
component:
|
|
1028
|
-
}))
|
|
1086
|
+
component: component
|
|
1087
|
+
}));
|
|
1088
|
+
let requiredCapabilities = Stdlib_Array.reduce(outboundTranslationSlices.flatMap(OTS => declarationsOf(OTS.Spec.name, OTS.Spec.capabilityNeeds)).concat(inboundTranslationSlices.flatMap(ITS => declarationsOf(ITS.Spec.name, ITS.Spec.capabilityNeeds))).toSorted((a, b) => {
|
|
1029
1089
|
if (a.capability === b.capability) {
|
|
1030
1090
|
return Primitive_string.compare(a.component, b.component);
|
|
1031
1091
|
} else {
|
|
@@ -1252,7 +1312,7 @@ function make(name, aggregatesOpt, readModelsOpt, stateViewSlicesOpt, stateChang
|
|
|
1252
1312
|
let consumed = match$1[1];
|
|
1253
1313
|
return {
|
|
1254
1314
|
name: SCS.Spec.name,
|
|
1255
|
-
commands: extractCommandDefs(identityViewsOf(SCS.Spec.name), false, partitionBySlice[SCS.Spec.name], variantName => Api_Naming$ReventlessCore.sliceMutationFieldFor(name, SCS.Spec.name, SCS.Spec.commandSchema, variantName), name => Authorization$Reventless.named(SCS.Spec.authorizationOf(name)), SCS.Spec.commandTransition, extra => derivedEdgeFor(SCS.Spec.name, extra), SCS.Spec.commandSchema),
|
|
1315
|
+
commands: extractCommandDefs(identityViewsOf(SCS.Spec.name), false, partitionBySlice[SCS.Spec.name], createsBy(SCS.Spec.eventSchema, SCS.Spec.consumedEventSchema), variantName => Api_Naming$ReventlessCore.sliceMutationFieldFor(name, SCS.Spec.name, SCS.Spec.commandSchema, variantName), name => Authorization$Reventless.named(SCS.Spec.authorizationOf(name)), SCS.Spec.commandTransition, extra => derivedEdgeFor(SCS.Spec.name, extra), SCS.Spec.commandSchema),
|
|
1256
1316
|
producedEventTypes: produced,
|
|
1257
1317
|
consumedEventTypes: consumed,
|
|
1258
1318
|
linkedViews: linkedSvsFor(produced),
|
|
@@ -1267,11 +1327,10 @@ function make(name, aggregatesOpt, readModelsOpt, stateViewSlicesOpt, stateChang
|
|
|
1267
1327
|
let produced = match[1];
|
|
1268
1328
|
return {
|
|
1269
1329
|
name: A.Spec.name,
|
|
1270
|
-
commands: extractCommandDefs(identityViewsOf(A.Spec.name), true, undefined, variantName => Api_Naming$ReventlessCore.aggregateMutationField(name, A.Spec.name, variantName), name => Authorization$Reventless.named(A.Spec.authorizationOf(name)), A.Spec.commandTransition, extra => derivedEdgeFor(A.Spec.name, extra), A.Spec.commandSchema),
|
|
1330
|
+
commands: extractCommandDefs(identityViewsOf(A.Spec.name), true, undefined, undefined, variantName => Api_Naming$ReventlessCore.aggregateMutationField(name, A.Spec.name, variantName), name => Authorization$Reventless.named(A.Spec.authorizationOf(name)), A.Spec.commandTransition, extra => derivedEdgeFor(A.Spec.name, extra), A.Spec.commandSchema),
|
|
1271
1331
|
producedEventTypes: produced,
|
|
1272
1332
|
consumedEventTypes: [],
|
|
1273
1333
|
linkedViews: linkedSvsFor(produced).concat(linkedReadModelsFor(A.Spec.name)),
|
|
1274
|
-
consistencyRead: undefined,
|
|
1275
1334
|
events: extractEventDefs(identityViewsOf(A.Spec.name), A.Spec.eventSchema),
|
|
1276
1335
|
errors: extractErrorDefs(A.Spec.errorSchema),
|
|
1277
1336
|
chapter: componentChapters[A.Spec.name]
|
|
@@ -1563,7 +1622,12 @@ function make(name, aggregatesOpt, readModelsOpt, stateViewSlicesOpt, stateChang
|
|
|
1563
1622
|
requiredStores: requiredStores,
|
|
1564
1623
|
requiredStoreDeclarations: requiredStoreDeclarations,
|
|
1565
1624
|
requiredCapabilities: requiredCapabilities,
|
|
1566
|
-
traitDeclarations: traitDeclarations
|
|
1625
|
+
traitDeclarations: traitDeclarations,
|
|
1626
|
+
admission: Stdlib_Option.map(admission, Admission$Reventless.toDefs),
|
|
1627
|
+
admissionDoors: admissionDoors.length !== 0 ? admissionDoors.map(param => ({
|
|
1628
|
+
component: param[0],
|
|
1629
|
+
part: Admission$Reventless.doorName(param[1])
|
|
1630
|
+
})) : undefined
|
|
1567
1631
|
};
|
|
1568
1632
|
}
|
|
1569
1633
|
|
|
@@ -1604,6 +1668,8 @@ export {
|
|
|
1604
1668
|
extractEventDefs,
|
|
1605
1669
|
extractErrorDefs,
|
|
1606
1670
|
isCreateCommandName,
|
|
1671
|
+
tagKeysByVariant,
|
|
1672
|
+
createsBy,
|
|
1607
1673
|
commandLevelAndId,
|
|
1608
1674
|
accessKeysFor,
|
|
1609
1675
|
nonEmpty,
|
|
@@ -61,17 +61,21 @@ let displayState = (
|
|
|
61
61
|
// write path marshals the raw ReScript value, so a variant would land in DynamoDB
|
|
62
62
|
// as `{TAG, _0}`. The ComponentDefinitions Lambda then reads structure back and
|
|
63
63
|
// resolves the sentinel.
|
|
64
|
-
apiSchemaFragment:
|
|
65
|
-
|
|
64
|
+
apiSchemaFragment: ?(
|
|
65
|
+
def.apiSchemaFragment->Option.map(
|
|
66
|
+
Reventless.Offload.toJson(Reventless.Plugin.apiSchemaFragmentSchema, _),
|
|
67
|
+
)
|
|
66
68
|
),
|
|
67
|
-
structure:
|
|
68
|
-
|
|
69
|
+
structure: ?(
|
|
70
|
+
def.structure->Option.map(
|
|
71
|
+
Reventless.Offload.toJson(Reventless.Plugin.pluginStructureSchema, _),
|
|
72
|
+
)
|
|
69
73
|
),
|
|
70
|
-
dcbEventLog: def.dcbEventLog,
|
|
74
|
+
dcbEventLog: ?def.dcbEventLog,
|
|
71
75
|
// A freshly projected row always knows its kind (the definition carries it as a
|
|
72
76
|
// mandatory field). `option` here is purely for rows persisted before `kind`
|
|
73
77
|
// existed — see PluginsReadModelSpec.state.kind.
|
|
74
|
-
kind:
|
|
78
|
+
kind: def.kind,
|
|
75
79
|
// The current version is never listed among the "other" connected versions.
|
|
76
80
|
otherConnectedVersions: otherConnectedVersions->Util.without(def.version),
|
|
77
81
|
}
|
|
@@ -55,7 +55,7 @@ type state = {
|
|
|
55
55
|
// it through a dedicated resolver path. What it must not be is a column in a
|
|
56
56
|
// generated list view — it is a multi-kilobyte JSON blob, and a query that names
|
|
57
57
|
// it drags one per row over the wire to render a cell nobody reads.
|
|
58
|
-
@hidden apiSchemaFragment
|
|
58
|
+
@hidden apiSchemaFragment?: JSON.t,
|
|
59
59
|
// API target for split-API schema routing. Absent/None means "Domain" (backward compat).
|
|
60
60
|
// "Platform" → excluded from DomainApi runtime schema stitching in updateApiSchema.
|
|
61
61
|
apiTarget?: string,
|
|
@@ -66,12 +66,12 @@ type state = {
|
|
|
66
66
|
//
|
|
67
67
|
// `@hidden` for the same reason, and more so: this is the larger of the two
|
|
68
68
|
// blobs.
|
|
69
|
-
@hidden structure
|
|
69
|
+
@hidden structure?: JSON.t,
|
|
70
70
|
// DCB EventLog definition for plugins that bundle a DcbEventLog component.
|
|
71
71
|
// Admin's manageSubscriptions uses this to wire cross-plugin SNS subscriptions
|
|
72
72
|
// from this plugin's DCB topic → peer EventCollectors (and vice-versa). None
|
|
73
73
|
// for pure-aggregate plugins or for plugins persisted before Phase 4.
|
|
74
|
-
dcbEventLog
|
|
74
|
+
dcbEventLog?: Reventless.Plugin.dcbEventLogDefinition,
|
|
75
75
|
// Business role of the plugin (from pluginDefinition.kind). Lets the admin Plugins
|
|
76
76
|
// view segregate PlatformInfrastructure / Commercial / Marketplace from Domain.
|
|
77
77
|
// @scan opts the field into server-side equality filtering so the connection gains
|
|
@@ -88,7 +88,7 @@ type state = {
|
|
|
88
88
|
// bookkeeping row). Optional here → nullable `Platform_PluginKind` in the SDL, so a
|
|
89
89
|
// blank kind degrades to a missing group (AutoListView's trailing group) instead of
|
|
90
90
|
// taking down the whole list. Backfill then upgrades blanks to real kinds.
|
|
91
|
-
@scan @groupBy kind
|
|
91
|
+
@scan @groupBy kind?: Reventless.Plugin.pluginKind,
|
|
92
92
|
// Other versions of this name that are currently **Connected** — excludes this
|
|
93
93
|
// row's own `version` (whose status is the `status` field above). Lets the
|
|
94
94
|
// projection recompute which version is current (highest Connected) during a
|
|
@@ -108,9 +108,9 @@ type queryResult = {
|
|
|
108
108
|
extensionNames: array<string>,
|
|
109
109
|
extensions: array<Reventless.Plugin.extensionDefinition>,
|
|
110
110
|
status: status,
|
|
111
|
-
apiSchemaFragment
|
|
111
|
+
apiSchemaFragment?: JSON.t,
|
|
112
112
|
apiTarget?: string,
|
|
113
|
-
structure
|
|
114
|
-
dcbEventLog
|
|
115
|
-
kind
|
|
113
|
+
structure?: JSON.t,
|
|
114
|
+
dcbEventLog?: Reventless.Plugin.dcbEventLogDefinition,
|
|
115
|
+
kind?: Reventless.Plugin.pluginKind,
|
|
116
116
|
}
|
package/src/util/FTPHandler.res
CHANGED
|
@@ -7,11 +7,11 @@ type secret = Password(password) | Key(privateKey, passphrase)
|
|
|
7
7
|
|
|
8
8
|
type connectionParams = {
|
|
9
9
|
host: string,
|
|
10
|
-
port
|
|
10
|
+
port?: int,
|
|
11
11
|
path: string,
|
|
12
12
|
userName: string,
|
|
13
13
|
secret: secret,
|
|
14
|
-
readyTimeout
|
|
14
|
+
readyTimeout?: int,
|
|
15
15
|
retryCount: int,
|
|
16
16
|
retryInterval: int,
|
|
17
17
|
}
|
|
@@ -37,7 +37,7 @@ type ftpAction =
|
|
|
37
37
|
| Upload(NodeStreams.Readable.t, /* filename on ftp */ string)
|
|
38
38
|
|
|
39
39
|
let ftp = (~connectionParams: connectionParams, ~ftpAction: ftpAction) => {
|
|
40
|
-
let {host, port, userName, secret, path, readyTimeout} = connectionParams
|
|
40
|
+
let {host, ?port, userName, secret, path, ?readyTimeout} = connectionParams
|
|
41
41
|
let (promise, resolve, _reject) = Util.Promise.make()
|
|
42
42
|
let result: ref<result<bool, string>> = ref(Error("Stream ended before action handling!"))
|
|
43
43
|
let client = FTP.Client.make()
|
|
@@ -208,8 +208,8 @@ let nextFiring = (time, ~after) =>
|
|
|
208
208
|
/** What EventBridge Scheduler is given for a time. */
|
|
209
209
|
type awsSchedule = {
|
|
210
210
|
expression: string,
|
|
211
|
-
timezone
|
|
212
|
-
startDate
|
|
211
|
+
timezone?: string,
|
|
212
|
+
startDate?: float,
|
|
213
213
|
deleteAfterCompletion: bool,
|
|
214
214
|
}
|
|
215
215
|
|
|
@@ -246,20 +246,17 @@ let toAws = (time, ~setAt) =>
|
|
|
246
246
|
| Days(n) => rateOf(n, "day")
|
|
247
247
|
| Weeks(n) => rateOf(n * 7, "day")
|
|
248
248
|
},
|
|
249
|
-
|
|
250
|
-
startDate: Some(setAt +. interval->intervalMs),
|
|
249
|
+
startDate: setAt +. interval->intervalMs,
|
|
251
250
|
deleteAfterCompletion: false,
|
|
252
251
|
}
|
|
253
252
|
| Calendar({calendar, ?zone}) => {
|
|
254
253
|
expression: calendar->cronExpressionOf,
|
|
255
|
-
timezone:
|
|
256
|
-
startDate: None,
|
|
254
|
+
timezone: zone->zoneName,
|
|
257
255
|
deleteAfterCompletion: false,
|
|
258
256
|
}
|
|
259
257
|
| Once({moment: At({year, month, day, hour, minute}), ?zone}) => {
|
|
260
258
|
expression: `at(${year->Int.toString}-${month->pad2}-${day->pad2}T${hour->pad2}:${minute->pad2}:00)`,
|
|
261
|
-
timezone:
|
|
262
|
-
startDate: None,
|
|
259
|
+
timezone: zone->zoneName,
|
|
263
260
|
deleteAfterCompletion: true,
|
|
264
261
|
}
|
|
265
262
|
| Once({moment: After(_)}) => throw(InvalidTime("unresolved once-only time"))
|
|
@@ -391,7 +391,6 @@ function toAws(time, setAt) {
|
|
|
391
391
|
}
|
|
392
392
|
return {
|
|
393
393
|
expression: tmp,
|
|
394
|
-
timezone: undefined,
|
|
395
394
|
startDate: setAt + intervalMs(interval$1),
|
|
396
395
|
deleteAfterCompletion: false
|
|
397
396
|
};
|
|
@@ -399,7 +398,6 @@ function toAws(time, setAt) {
|
|
|
399
398
|
return {
|
|
400
399
|
expression: cronExpressionOf(interval.calendar),
|
|
401
400
|
timezone: Stdlib_Option.getOr(interval.zone, utc),
|
|
402
|
-
startDate: undefined,
|
|
403
401
|
deleteAfterCompletion: false
|
|
404
402
|
};
|
|
405
403
|
case "Once" :
|
|
@@ -409,7 +407,6 @@ function toAws(time, setAt) {
|
|
|
409
407
|
return {
|
|
410
408
|
expression: `at(` + match$1.year.toString() + `-` + pad2(match$1.month) + `-` + pad2(match$1.day) + `T` + pad2(match$1.hour) + `:` + pad2(match$1.minute) + `:00)`,
|
|
411
409
|
timezone: Stdlib_Option.getOr(interval.zone, utc),
|
|
412
|
-
startDate: undefined,
|
|
413
410
|
deleteAfterCompletion: true
|
|
414
411
|
};
|
|
415
412
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
open JestGlobals
|
|
2
|
+
|
|
3
|
+
// The limit on doors open to anonymous callers: counted per door and source, in
|
|
4
|
+
// fixed windows, and parsed from one setting that refuses rather than guesses.
|
|
5
|
+
|
|
6
|
+
let clock = () => {
|
|
7
|
+
let at = ref(1_000_000.)
|
|
8
|
+
(() => at.contents, seconds => at := at.contents +. seconds *. 1000.)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let limit: Reventless.AnonymousRequestLimit.t = {requests: 2, windowSeconds: 60}
|
|
12
|
+
|
|
13
|
+
describe("AnonymousLimiter", () => {
|
|
14
|
+
testSync("admits up to the limit, then refuses", () => {
|
|
15
|
+
let (now, _) = clock()
|
|
16
|
+
let l = AnonymousLimiter.make(~limit, ~now)
|
|
17
|
+
let admitted = [
|
|
18
|
+
l.admit(~door="SignUp", ~source="1.2.3.4"),
|
|
19
|
+
l.admit(~door="SignUp", ~source="1.2.3.4"),
|
|
20
|
+
l.admit(~door="SignUp", ~source="1.2.3.4"),
|
|
21
|
+
]
|
|
22
|
+
expect(admitted)->toEqual([true, true, false])
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
testSync("a new window starts the count again", () => {
|
|
26
|
+
let (now, advance) = clock()
|
|
27
|
+
let l = AnonymousLimiter.make(~limit, ~now)
|
|
28
|
+
let _ = l.admit(~door="SignUp", ~source="1.2.3.4")
|
|
29
|
+
let _ = l.admit(~door="SignUp", ~source="1.2.3.4")
|
|
30
|
+
advance(60.)
|
|
31
|
+
expect(l.admit(~door="SignUp", ~source="1.2.3.4"))->toBe(true)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
testSync("sources and doors are counted apart", () => {
|
|
35
|
+
let (now, _) = clock()
|
|
36
|
+
let l = AnonymousLimiter.make(~limit, ~now)
|
|
37
|
+
let _ = l.admit(~door="SignUp", ~source="1.2.3.4")
|
|
38
|
+
let _ = l.admit(~door="SignUp", ~source="1.2.3.4")
|
|
39
|
+
expect((
|
|
40
|
+
l.admit(~door="SignUp", ~source="5.6.7.8"),
|
|
41
|
+
l.admit(~door="CompleteRegistration", ~source="1.2.3.4"),
|
|
42
|
+
))->toEqual((true, true))
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
describe("AnonymousRequestLimit.parse", () => {
|
|
47
|
+
testSync("reads requests per seconds", () =>
|
|
48
|
+
expect(Reventless.AnonymousRequestLimit.parse(" 5 / 600 "))->toEqual(
|
|
49
|
+
Ok({Reventless.AnonymousRequestLimit.requests: 5, windowSeconds: 600}),
|
|
50
|
+
)
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
testSync("refuses anything else rather than defaulting", () => {
|
|
54
|
+
expect(Reventless.AnonymousRequestLimit.parse("5")->Result.isError)->toBe(true)
|
|
55
|
+
expect(Reventless.AnonymousRequestLimit.parse("0/60")->Result.isError)->toBe(true)
|
|
56
|
+
expect(Reventless.AnonymousRequestLimit.parse("lots/hour")->Result.isError)->toBe(true)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
testSync("the default round-trips through its spelling", () =>
|
|
60
|
+
expect(
|
|
61
|
+
Reventless.AnonymousRequestLimit.parse(
|
|
62
|
+
Reventless.AnonymousRequestLimit.default->Reventless.AnonymousRequestLimit.toString,
|
|
63
|
+
),
|
|
64
|
+
)->toEqual(Ok(Reventless.AnonymousRequestLimit.default))
|
|
65
|
+
)
|
|
66
|
+
})
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Stdlib_Result from "@rescript/runtime/lib/es6/Stdlib_Result.js";
|
|
4
|
+
import * as AnonymousLimiter$ReventlessCore from "../src/adapter/Throttle/AnonymousLimiter.res.mjs";
|
|
5
|
+
import * as AnonymousRequestLimit$Reventless from "@reventlessdev/reventless-spec/src/types/AnonymousRequestLimit.res.mjs";
|
|
6
|
+
|
|
7
|
+
function clock() {
|
|
8
|
+
let at = {
|
|
9
|
+
contents: 1000000
|
|
10
|
+
};
|
|
11
|
+
return [
|
|
12
|
+
() => at.contents,
|
|
13
|
+
seconds => {
|
|
14
|
+
at.contents = at.contents + seconds * 1000;
|
|
15
|
+
}
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let limit = {
|
|
20
|
+
requests: 2,
|
|
21
|
+
windowSeconds: 60
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
globalThis.describe("AnonymousLimiter", () => {
|
|
25
|
+
globalThis.test("admits up to the limit, then refuses", () => {
|
|
26
|
+
let match = clock();
|
|
27
|
+
let l = AnonymousLimiter$ReventlessCore.make(limit, match[0]);
|
|
28
|
+
let admitted = [
|
|
29
|
+
l.admit("SignUp", "1.2.3.4"),
|
|
30
|
+
l.admit("SignUp", "1.2.3.4"),
|
|
31
|
+
l.admit("SignUp", "1.2.3.4")
|
|
32
|
+
];
|
|
33
|
+
globalThis.expect(admitted).toEqual([
|
|
34
|
+
true,
|
|
35
|
+
true,
|
|
36
|
+
false
|
|
37
|
+
]);
|
|
38
|
+
});
|
|
39
|
+
globalThis.test("a new window starts the count again", () => {
|
|
40
|
+
let match = clock();
|
|
41
|
+
let l = AnonymousLimiter$ReventlessCore.make(limit, match[0]);
|
|
42
|
+
l.admit("SignUp", "1.2.3.4");
|
|
43
|
+
l.admit("SignUp", "1.2.3.4");
|
|
44
|
+
match[1](60);
|
|
45
|
+
globalThis.expect(l.admit("SignUp", "1.2.3.4")).toBe(true);
|
|
46
|
+
});
|
|
47
|
+
globalThis.test("sources and doors are counted apart", () => {
|
|
48
|
+
let match = clock();
|
|
49
|
+
let l = AnonymousLimiter$ReventlessCore.make(limit, match[0]);
|
|
50
|
+
l.admit("SignUp", "1.2.3.4");
|
|
51
|
+
l.admit("SignUp", "1.2.3.4");
|
|
52
|
+
globalThis.expect([
|
|
53
|
+
l.admit("SignUp", "5.6.7.8"),
|
|
54
|
+
l.admit("CompleteRegistration", "1.2.3.4")
|
|
55
|
+
]).toEqual([
|
|
56
|
+
true,
|
|
57
|
+
true
|
|
58
|
+
]);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
globalThis.describe("AnonymousRequestLimit.parse", () => {
|
|
63
|
+
globalThis.test("reads requests per seconds", () => {
|
|
64
|
+
globalThis.expect(AnonymousRequestLimit$Reventless.parse(" 5 / 600 ")).toEqual({
|
|
65
|
+
TAG: "Ok",
|
|
66
|
+
_0: {
|
|
67
|
+
requests: 5,
|
|
68
|
+
windowSeconds: 600
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
globalThis.test("refuses anything else rather than defaulting", () => {
|
|
73
|
+
globalThis.expect(Stdlib_Result.isError(AnonymousRequestLimit$Reventless.parse("5"))).toBe(true);
|
|
74
|
+
globalThis.expect(Stdlib_Result.isError(AnonymousRequestLimit$Reventless.parse("0/60"))).toBe(true);
|
|
75
|
+
globalThis.expect(Stdlib_Result.isError(AnonymousRequestLimit$Reventless.parse("lots/hour"))).toBe(true);
|
|
76
|
+
});
|
|
77
|
+
globalThis.test("the default round-trips through its spelling", () => {
|
|
78
|
+
globalThis.expect(AnonymousRequestLimit$Reventless.parse(AnonymousRequestLimit$Reventless.toString(AnonymousRequestLimit$Reventless.default))).toEqual({
|
|
79
|
+
TAG: "Ok",
|
|
80
|
+
_0: AnonymousRequestLimit$Reventless.default
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export {
|
|
86
|
+
clock,
|
|
87
|
+
limit,
|
|
88
|
+
}
|
|
89
|
+
/* Not a pure module */
|
|
@@ -153,7 +153,7 @@ describe("ResourceAttribution — carrying the context into deferred work", () =
|
|
|
153
153
|
|
|
154
154
|
testSync("enterCaptured can express the empty context, which enter cannot", () => {
|
|
155
155
|
let previous = Attribution.enter(~platform="online-shop", ~plugin="Catalog")
|
|
156
|
-
let restoredToEmpty = Attribution.enterCaptured({
|
|
156
|
+
let restoredToEmpty = Attribution.enterCaptured({})
|
|
157
157
|
expect(Attribution.current.contents.plugin)->toEqual(None)
|
|
158
158
|
expect(restoredToEmpty.plugin)->toEqual(Some("Catalog"))
|
|
159
159
|
Attribution.restore(previous)
|
|
@@ -142,10 +142,7 @@ globalThis.describe("ResourceAttribution — carrying the context into deferred
|
|
|
142
142
|
});
|
|
143
143
|
globalThis.test("enterCaptured can express the empty context, which enter cannot", () => {
|
|
144
144
|
let previous = ResourceAttribution$ReventlessCore.enter("online-shop", "Catalog");
|
|
145
|
-
let restoredToEmpty = ResourceAttribution$ReventlessCore.enterCaptured({
|
|
146
|
-
platform: undefined,
|
|
147
|
-
plugin: undefined
|
|
148
|
-
});
|
|
145
|
+
let restoredToEmpty = ResourceAttribution$ReventlessCore.enterCaptured({});
|
|
149
146
|
globalThis.expect(ResourceAttribution$ReventlessCore.current.contents.plugin).toEqual(undefined);
|
|
150
147
|
globalThis.expect(restoredToEmpty.plugin).toEqual("Catalog");
|
|
151
148
|
ResourceAttribution$ReventlessCore.restore(previous);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
open JestGlobals
|
|
2
|
+
|
|
3
|
+
// The local stash's two promises: a value is handed over once, and a value
|
|
4
|
+
// nobody takes is gone after its time. Time is moved, not waited for.
|
|
5
|
+
|
|
6
|
+
let clock = () => {
|
|
7
|
+
let at = ref(1_000_000.)
|
|
8
|
+
(() => at.contents, seconds => at := at.contents +. seconds *. 1000.)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe("Stash_Memory_Backend", () => {
|
|
12
|
+
testPromise("hands a value over once", async () => {
|
|
13
|
+
let (now, _) = clock()
|
|
14
|
+
let stash = Stash_Memory_Backend.make(~now)
|
|
15
|
+
expect(await stash.put(~key="k", ~value="secret", ~ttl=60))->toEqual(Ok())
|
|
16
|
+
expect(await stash.take(~key="k"))->toEqual(Ok(Some("secret")))
|
|
17
|
+
expect(await stash.take(~key="k"))->toEqual(Ok(None))
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
testPromise("a value past its time is gone", async () => {
|
|
21
|
+
let (now, advance) = clock()
|
|
22
|
+
let stash = Stash_Memory_Backend.make(~now)
|
|
23
|
+
let _ = await stash.put(~key="k", ~value="secret", ~ttl=60)
|
|
24
|
+
advance(61.)
|
|
25
|
+
expect(await stash.take(~key="k"))->toEqual(Ok(None))
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
testPromise("a value within its time is still there", async () => {
|
|
29
|
+
let (now, advance) = clock()
|
|
30
|
+
let stash = Stash_Memory_Backend.make(~now)
|
|
31
|
+
let _ = await stash.put(~key="k", ~value="secret", ~ttl=60)
|
|
32
|
+
advance(59.)
|
|
33
|
+
expect(await stash.take(~key="k"))->toEqual(Ok(Some("secret")))
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
// The newer request is the one in flight: a person who submits the form twice
|
|
37
|
+
// means the second password.
|
|
38
|
+
testPromise("a second put under one key replaces the first", async () => {
|
|
39
|
+
let (now, _) = clock()
|
|
40
|
+
let stash = Stash_Memory_Backend.make(~now)
|
|
41
|
+
let _ = await stash.put(~key="k", ~value="first", ~ttl=60)
|
|
42
|
+
let _ = await stash.put(~key="k", ~value="second", ~ttl=60)
|
|
43
|
+
expect(await stash.take(~key="k"))->toEqual(Ok(Some("second")))
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
testPromise("two stashes share nothing", async () => {
|
|
47
|
+
let (now, _) = clock()
|
|
48
|
+
let a = Stash_Memory_Backend.make(~now)
|
|
49
|
+
let b = Stash_Memory_Backend.make(~now)
|
|
50
|
+
let _ = await a.put(~key="k", ~value="secret", ~ttl=60)
|
|
51
|
+
expect(await b.take(~key="k"))->toEqual(Ok(None))
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
testPromise("a platform with none refuses both operations", async () => {
|
|
55
|
+
let none = Reventless.Capabilities.none.stash
|
|
56
|
+
expect(await none.put(~key="k", ~value="v", ~ttl=60))->toEqual(
|
|
57
|
+
Error(Reventless.Stash.Unavailable("no stash is configured for this platform")),
|
|
58
|
+
)
|
|
59
|
+
expect(await none.take(~key="k"))->toEqual(
|
|
60
|
+
Error(Reventless.Stash.Unavailable("no stash is configured for this platform")),
|
|
61
|
+
)
|
|
62
|
+
})
|
|
63
|
+
})
|