@reventlessdev/reventless-core 3.0.0-alpha.267 → 3.0.0-alpha.269
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 +15 -0
- package/README.md +1 -1
- package/package.json +16 -16
- package/src/components/AutomationSlice/AutomationSlice_Callback.res.mjs +4 -4
- package/src/components/CommandGenerator/CommandGenerator_Callback.res.mjs +90 -92
- package/src/components/Counter/Counter_Callback.res.mjs +1 -1
- package/src/components/Counter/Counter_Operations.res.mjs +1 -1
- package/src/components/EventCollector/EventCollector_Builder.res.mjs +3 -3
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res.mjs +2 -3
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res.mjs +4 -4
- package/src/plugin/component/Plugin_Builder.res.mjs +3 -3
- package/src/plugin/component/Plugin_Helpers.res.mjs +2 -2
- package/src/plugin/component/Plugin_Structure.res +11 -3
- package/src/plugin/component/Plugin_Structure.res.mjs +6 -5
- package/src/plugin/lifecycle/PluginBehavior.res.mjs +1 -1
- package/src/util/Interstack.res.mjs +4 -4
- package/tests/aggregate/AggregateCacheTest.res.mjs +1 -1
- package/tests/api/BrandedMarkerCompositionTest.res.mjs +2 -3
- package/tests/api/GeolocationSemanticTest.res.mjs +1 -2
- package/tests/api/GraphQL_FragmentGeneratorTest.res.mjs +2 -2
- package/tests/api/SuryToJsonSchemaTest.res +8 -8
- package/tests/api/SuryToJsonSchemaTest.res.mjs +24 -24
- package/tests/dcb/DcbFixtures.res.mjs +6 -6
- package/tests/dcb/DcbValidationTest.res.mjs +3 -3
- package/tests/eventmapper/EventMapperFixtures.res.mjs +5 -5
- package/tests/plugin/IdentityReferenceTest.res +21 -2
- package/tests/plugin/IdentityReferenceTest.res.mjs +43 -8
- package/tests/plugin/PluginSpecExperiment.res +2 -2
- package/tests/plugin/PluginSpecExperiment.res.mjs +3 -3
- package/tests/plugin/PluginStructureTest.res +1 -1
- package/tests/plugin/PluginStructureTest.res.mjs +5 -5
- package/tests/plugin/SchemaWalkerTest.res.mjs +2 -2
- package/tests/plugin/StateChange/PsReserveStock.res.mjs +1 -1
- package/tests/plugin/StateView/PsAnnotatedView.res +1 -1
- package/tests/plugin/StateView/PsAnnotatedView.res.mjs +4 -4
- package/tests/querydb/QueryDbFixtures.res.mjs +1 -1
- package/tests/util/CommandPublisherTest.res.mjs +1 -1
|
@@ -234,7 +234,7 @@ globalThis.describe("deriveServerCapability — inferred keys reach the SDL surf
|
|
|
234
234
|
globalThis.test("an inferred key yields an eq filter and a sort field", () => {
|
|
235
235
|
let schema = Sury.$schema(s => ({
|
|
236
236
|
orderId: s.m(Sury.string),
|
|
237
|
-
total: s.m(Sury.
|
|
237
|
+
total: s.m(Sury.number)
|
|
238
238
|
}));
|
|
239
239
|
let c = GraphQL_FragmentGenerator$ReventlessCore.deriveServerCapability("Orders", schema);
|
|
240
240
|
globalThis.expect(c.filterFields.map(f => f.name)).toEqual(["orderId"]);
|
|
@@ -387,7 +387,7 @@ let schema = Sury.$schema(s => ({
|
|
|
387
387
|
shippingMethod: s.m(shippingMethodSchema),
|
|
388
388
|
total: s.m(Money$Reventless.schema),
|
|
389
389
|
tip: s.m(Sury.$option(Money$Reventless.schema)),
|
|
390
|
-
itemCount: s.m(Sury.
|
|
390
|
+
itemCount: s.m(Sury.int32)
|
|
391
391
|
}));
|
|
392
392
|
|
|
393
393
|
let PlaceOrder = {
|
|
@@ -1012,10 +1012,10 @@ describe("SuryToJsonSchema:", () => {
|
|
|
1012
1012
|
)
|
|
1013
1013
|
})
|
|
1014
1014
|
|
|
1015
|
-
// Parity sanity-check: deriveObjectSchema and the legacy S.
|
|
1015
|
+
// Parity sanity-check: deriveObjectSchema and the legacy S.toInputJSONSchemaOrThrow must
|
|
1016
1016
|
// agree on `properties` keyset and `required` array for unannotated objects,
|
|
1017
1017
|
// so swapping the encoder at Plugin_Structure.res:261/280 doesn't drop fields.
|
|
1018
|
-
describe("parity with S.
|
|
1018
|
+
describe("parity with S.toInputJSONSchemaOrThrow for unannotated objects:", () => {
|
|
1019
1019
|
let getKeys = (schema: JSON.t): array<string> =>
|
|
1020
1020
|
switch getProperty(schema, "properties")->Option.flatMap(JSON.Decode.object) {
|
|
1021
1021
|
| Some(obj) => obj->Dict.keysToArray
|
|
@@ -1031,7 +1031,7 @@ describe("SuryToJsonSchema:", () => {
|
|
|
1031
1031
|
let sortStrings = (xs: array<string>): array<string> => xs->Array.toSorted(String.compare)
|
|
1032
1032
|
|
|
1033
1033
|
testSync(
|
|
1034
|
-
"properties keyset matches between deriveObjectSchema and S.
|
|
1034
|
+
"properties keyset matches between deriveObjectSchema and S.toInputJSONSchemaOrThrow",
|
|
1035
1035
|
() => {
|
|
1036
1036
|
let schema = S.schema(
|
|
1037
1037
|
s =>
|
|
@@ -1042,13 +1042,13 @@ describe("SuryToJsonSchema:", () => {
|
|
|
1042
1042
|
},
|
|
1043
1043
|
)->S.castToUnknown
|
|
1044
1044
|
let derived = SuryToJsonSchema.deriveObjectSchema(schema)
|
|
1045
|
-
let native = (schema->S.
|
|
1045
|
+
let native = (schema->S.toInputJSONSchemaOrThrow->Obj.magic: JSON.t)
|
|
1046
1046
|
expect(derived->getKeys->sortStrings)->toEqual(native->getKeys->sortStrings)
|
|
1047
1047
|
},
|
|
1048
1048
|
)
|
|
1049
1049
|
|
|
1050
1050
|
testSync(
|
|
1051
|
-
"required array matches between deriveObjectSchema and S.
|
|
1051
|
+
"required array matches between deriveObjectSchema and S.toInputJSONSchemaOrThrow",
|
|
1052
1052
|
() => {
|
|
1053
1053
|
let schema = S.schema(
|
|
1054
1054
|
s =>
|
|
@@ -1058,13 +1058,13 @@ describe("SuryToJsonSchema:", () => {
|
|
|
1058
1058
|
},
|
|
1059
1059
|
)->S.castToUnknown
|
|
1060
1060
|
let derived = SuryToJsonSchema.deriveObjectSchema(schema)
|
|
1061
|
-
let native = (schema->S.
|
|
1061
|
+
let native = (schema->S.toInputJSONSchemaOrThrow->Obj.magic: JSON.t)
|
|
1062
1062
|
expect(derived->getRequired->sortStrings)->toEqual(native->getRequired->sortStrings)
|
|
1063
1063
|
},
|
|
1064
1064
|
)
|
|
1065
1065
|
|
|
1066
1066
|
testSync(
|
|
1067
|
-
"S.
|
|
1067
|
+
"S.toInputJSONSchemaOrThrow does NOT emit x-reventless-* keys even when metadata is set",
|
|
1068
1068
|
() => {
|
|
1069
1069
|
let withSpec = (schema, spec) =>
|
|
1070
1070
|
schema->S.Metadata.set(~id=Reventless.StateAnnotations.stateAnnotationsId, spec)
|
|
@@ -1076,7 +1076,7 @@ describe("SuryToJsonSchema:", () => {
|
|
|
1076
1076
|
},
|
|
1077
1077
|
)->S.castToUnknown
|
|
1078
1078
|
let schema' = schema->withSpec({...emptySpec, ids: ["entityId"]})
|
|
1079
|
-
let native = (schema'->S.
|
|
1079
|
+
let native = (schema'->S.toInputJSONSchemaOrThrow->Obj.magic: JSON.t)
|
|
1080
1080
|
let entityIdSchema = getPropertyOf(native, "entityId")
|
|
1081
1081
|
expect(entityIdSchema->Option.flatMap(s => getProperty(s, "x-reventless-id")))->toBe(None)
|
|
1082
1082
|
},
|
|
@@ -471,7 +471,7 @@ globalThis.describe("SuryToJsonSchema:", () => {
|
|
|
471
471
|
globalThis.test("emits x-reventless-semantic on the field listed in semantic", () => {
|
|
472
472
|
let schema = Sury.$schema(s => ({
|
|
473
473
|
id: s.m(Sury.string),
|
|
474
|
-
total: s.m(Sury.
|
|
474
|
+
total: s.m(Sury.number)
|
|
475
475
|
}));
|
|
476
476
|
let newrecord = {...emptySpec};
|
|
477
477
|
newrecord.semantic = [[
|
|
@@ -494,7 +494,7 @@ globalThis.describe("SuryToJsonSchema:", () => {
|
|
|
494
494
|
globalThis.test("emits x-reventless-metric {aggregate,label} on the field listed in metric", () => {
|
|
495
495
|
let schema = Sury.$schema(s => ({
|
|
496
496
|
id: s.m(Sury.string),
|
|
497
|
-
total: s.m(Sury.
|
|
497
|
+
total: s.m(Sury.number)
|
|
498
498
|
}));
|
|
499
499
|
let newrecord = {...emptySpec};
|
|
500
500
|
newrecord.metric = [[
|
|
@@ -518,7 +518,7 @@ globalThis.describe("SuryToJsonSchema:", () => {
|
|
|
518
518
|
});
|
|
519
519
|
globalThis.test("omits the metric label when empty (UI derives one from the field name)", () => {
|
|
520
520
|
let schema = Sury.$schema(s => ({
|
|
521
|
-
total: s.m(Sury.
|
|
521
|
+
total: s.m(Sury.number)
|
|
522
522
|
}));
|
|
523
523
|
let newrecord = {...emptySpec};
|
|
524
524
|
newrecord.metric = [[
|
|
@@ -543,7 +543,7 @@ globalThis.describe("SuryToJsonSchema:", () => {
|
|
|
543
543
|
globalThis.test("emits x-reventless-retired {label,showWhenFalse} on the retired field", () => {
|
|
544
544
|
let schema = Sury.$schema(s => ({
|
|
545
545
|
id: s.m(Sury.string),
|
|
546
|
-
archived: s.m(Sury.
|
|
546
|
+
archived: s.m(Sury.boolean)
|
|
547
547
|
}));
|
|
548
548
|
let newrecord = {...emptySpec};
|
|
549
549
|
newrecord.retired = {
|
|
@@ -612,7 +612,7 @@ globalThis.describe("SuryToJsonSchema:", () => {
|
|
|
612
612
|
});
|
|
613
613
|
globalThis.test("omits both value and values entirely on the boolean form", () => {
|
|
614
614
|
let schema = Sury.$schema(s => ({
|
|
615
|
-
archived: s.m(Sury.
|
|
615
|
+
archived: s.m(Sury.boolean)
|
|
616
616
|
}));
|
|
617
617
|
let newrecord = {...emptySpec};
|
|
618
618
|
newrecord.retired = {
|
|
@@ -637,7 +637,7 @@ globalThis.describe("SuryToJsonSchema:", () => {
|
|
|
637
637
|
globalThis.test("carries namedWhenRetired only when the record opted in", () => {
|
|
638
638
|
let build = named => {
|
|
639
639
|
let schema = Sury.$schema(s => ({
|
|
640
|
-
archived: s.m(Sury.
|
|
640
|
+
archived: s.m(Sury.boolean)
|
|
641
641
|
}));
|
|
642
642
|
let newrecord = {...emptySpec};
|
|
643
643
|
newrecord.retired = {
|
|
@@ -660,7 +660,7 @@ globalThis.describe("SuryToJsonSchema:", () => {
|
|
|
660
660
|
});
|
|
661
661
|
globalThis.test("omits the retired label when empty but always states showWhenFalse", () => {
|
|
662
662
|
let schema = Sury.$schema(s => ({
|
|
663
|
-
deactivated: s.m(Sury.
|
|
663
|
+
deactivated: s.m(Sury.boolean)
|
|
664
664
|
}));
|
|
665
665
|
let newrecord = {...emptySpec};
|
|
666
666
|
newrecord.retired = {
|
|
@@ -684,7 +684,7 @@ globalThis.describe("SuryToJsonSchema:", () => {
|
|
|
684
684
|
});
|
|
685
685
|
globalThis.test("emits nothing for a schema with no retired annotation", () => {
|
|
686
686
|
let schema = Sury.$schema(s => ({
|
|
687
|
-
archived: s.m(Sury.
|
|
687
|
+
archived: s.m(Sury.boolean)
|
|
688
688
|
}));
|
|
689
689
|
let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(undefined, undefined, Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, emptySpec));
|
|
690
690
|
globalThis.expect(Stdlib_Option.flatMap(getPropertyOf(json, "archived"), s => getProperty(s, "x-reventless-retired"))).toBe(undefined);
|
|
@@ -801,7 +801,7 @@ globalThis.describe("SuryToJsonSchema:", () => {
|
|
|
801
801
|
]);
|
|
802
802
|
});
|
|
803
803
|
});
|
|
804
|
-
globalThis.describe("parity with S.
|
|
804
|
+
globalThis.describe("parity with S.toInputJSONSchemaOrThrow for unannotated objects:", () => {
|
|
805
805
|
let getKeys = schema => {
|
|
806
806
|
let obj = Stdlib_Option.flatMap(getProperty(schema, "properties"), Stdlib_JSON.Decode.object);
|
|
807
807
|
if (obj !== undefined) {
|
|
@@ -819,26 +819,26 @@ globalThis.describe("SuryToJsonSchema:", () => {
|
|
|
819
819
|
}
|
|
820
820
|
};
|
|
821
821
|
let sortStrings = xs => xs.toSorted(Primitive_string.compare);
|
|
822
|
-
globalThis.test("properties keyset matches between deriveObjectSchema and S.
|
|
822
|
+
globalThis.test("properties keyset matches between deriveObjectSchema and S.toInputJSONSchemaOrThrow", () => {
|
|
823
823
|
let schema = Sury.$schema(s => ({
|
|
824
824
|
id: s.m(Sury.string),
|
|
825
825
|
name: s.m(Sury.string),
|
|
826
|
-
count: s.m(Sury.
|
|
826
|
+
count: s.m(Sury.int32)
|
|
827
827
|
}));
|
|
828
828
|
let derived = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(undefined, undefined, schema);
|
|
829
|
-
let native = Sury.
|
|
829
|
+
let native = Sury.toInputJSONSchemaOrThrow(schema);
|
|
830
830
|
globalThis.expect(sortStrings(getKeys(derived))).toEqual(sortStrings(getKeys(native)));
|
|
831
831
|
});
|
|
832
|
-
globalThis.test("required array matches between deriveObjectSchema and S.
|
|
832
|
+
globalThis.test("required array matches between deriveObjectSchema and S.toInputJSONSchemaOrThrow", () => {
|
|
833
833
|
let schema = Sury.$schema(s => ({
|
|
834
834
|
id: s.m(Sury.string),
|
|
835
835
|
name: s.m(Sury.string)
|
|
836
836
|
}));
|
|
837
837
|
let derived = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(undefined, undefined, schema);
|
|
838
|
-
let native = Sury.
|
|
838
|
+
let native = Sury.toInputJSONSchemaOrThrow(schema);
|
|
839
839
|
globalThis.expect(sortStrings(getRequired(derived))).toEqual(sortStrings(getRequired(native)));
|
|
840
840
|
});
|
|
841
|
-
globalThis.test("S.
|
|
841
|
+
globalThis.test("S.toInputJSONSchemaOrThrow does NOT emit x-reventless-* keys even when metadata is set", () => {
|
|
842
842
|
let schema = Sury.$schema(s => ({
|
|
843
843
|
entityId: s.m(Sury.string),
|
|
844
844
|
name: s.m(Sury.string)
|
|
@@ -847,7 +847,7 @@ globalThis.describe("SuryToJsonSchema:", () => {
|
|
|
847
847
|
newrecord.ids = ["entityId"];
|
|
848
848
|
let spec = newrecord;
|
|
849
849
|
let schema$p = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
|
|
850
|
-
let native = Sury.
|
|
850
|
+
let native = Sury.toInputJSONSchemaOrThrow(schema$p);
|
|
851
851
|
let entityIdSchema = getPropertyOf(native, "entityId");
|
|
852
852
|
globalThis.expect(Stdlib_Option.flatMap(entityIdSchema, s => getProperty(s, "x-reventless-id"))).toBe(undefined);
|
|
853
853
|
});
|
|
@@ -932,15 +932,15 @@ globalThis.describe("SuryToJsonSchema:", () => {
|
|
|
932
932
|
globalThis.expect(Stdlib_Option.isSome(Stdlib_Option.flatMap(getPropertyOf(json, "imageUrl"), s => getProperty(s, "oneOf")))).toBe(true);
|
|
933
933
|
});
|
|
934
934
|
globalThis.test("a type-carried semantic beats an annotation naming the same field", () => {
|
|
935
|
+
let schema = Sury.$schema(s => ({
|
|
936
|
+
imageUrl: s.m(StorageRef$Reventless.forStore(undefined, "productImages"))
|
|
937
|
+
}));
|
|
935
938
|
let newrecord = {...emptySpec};
|
|
936
939
|
newrecord.semantic = [[
|
|
937
940
|
"imageUrl",
|
|
938
941
|
"image"
|
|
939
942
|
]];
|
|
940
943
|
let spec = newrecord;
|
|
941
|
-
let schema = Sury.$schema(s => ({
|
|
942
|
-
imageUrl: s.m(StorageRef$Reventless.forStore(undefined, "productImages"))
|
|
943
|
-
}));
|
|
944
944
|
let schema$1 = Sury.$Metadata_set(schema, StateAnnotations$Reventless.stateAnnotationsId, spec);
|
|
945
945
|
let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(undefined, undefined, schema$1);
|
|
946
946
|
globalThis.expect(semanticOf(json, "imageUrl")).toEqual("storageRef");
|
|
@@ -1022,7 +1022,7 @@ globalThis.describe("SuryToJsonSchema:", () => {
|
|
|
1022
1022
|
globalThis.describe("Money changes the field's shape, and says so:", () => {
|
|
1023
1023
|
let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(undefined, undefined, Sury.$schema(s => ({
|
|
1024
1024
|
price: s.m(Money$Reventless.schema),
|
|
1025
|
-
quantity: s.m(Sury.
|
|
1025
|
+
quantity: s.m(Sury.number)
|
|
1026
1026
|
})));
|
|
1027
1027
|
let keyOf = (name, key) => Stdlib_Option.flatMap(getPropertyOf(json, name), s => getProperty(s, key));
|
|
1028
1028
|
globalThis.test("the field is an object, not a number", () => {
|
|
@@ -1112,7 +1112,7 @@ globalThis.describe("SuryToJsonSchema:", () => {
|
|
|
1112
1112
|
globalThis.describe("GeoPoint is an object carrying the geoPoint marker:", () => {
|
|
1113
1113
|
let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(undefined, undefined, Sury.$schema(s => ({
|
|
1114
1114
|
location: s.m(GeoPoint$Reventless.schema),
|
|
1115
|
-
lat: s.m(Sury.
|
|
1115
|
+
lat: s.m(Sury.number)
|
|
1116
1116
|
})));
|
|
1117
1117
|
let keyOf = (name, key) => Stdlib_Option.flatMap(getPropertyOf(json, name), s => getProperty(s, key));
|
|
1118
1118
|
globalThis.test("the field is an object, not a pair of numbers", () => {
|
|
@@ -1167,9 +1167,9 @@ globalThis.describe("SuryToJsonSchema:", () => {
|
|
|
1167
1167
|
globalThis.describe("a field declaring a default:", () => {
|
|
1168
1168
|
let defaultOf = (json, field) => Stdlib_Option.flatMap(getPropertyOf(json, field), s => getProperty(s, "default"));
|
|
1169
1169
|
let json = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(undefined, undefined, Sury.$schema(s => ({
|
|
1170
|
-
quantity: s.m(FieldDefault$Reventless.int(Sury.
|
|
1170
|
+
quantity: s.m(FieldDefault$Reventless.int(Sury.int32, 1)),
|
|
1171
1171
|
shippingMethod: s.m(FieldDefault$Reventless.string(Sury.string, "Standard")),
|
|
1172
|
-
plain: s.m(Sury.
|
|
1172
|
+
plain: s.m(Sury.int32)
|
|
1173
1173
|
})));
|
|
1174
1174
|
globalThis.test("carries it as `default`", () => {
|
|
1175
1175
|
globalThis.expect(defaultOf(json, "quantity")).toEqual(1);
|
|
@@ -1186,7 +1186,7 @@ globalThis.describe("SuryToJsonSchema:", () => {
|
|
|
1186
1186
|
globalThis.test("and reaches a field of a nested record", () => {
|
|
1187
1187
|
let lineItem = Sury.$schema(s => ({
|
|
1188
1188
|
productId: s.m(Sury.string),
|
|
1189
|
-
quantity: s.m(FieldDefault$Reventless.int(Sury.
|
|
1189
|
+
quantity: s.m(FieldDefault$Reventless.int(Sury.int32, 1))
|
|
1190
1190
|
}));
|
|
1191
1191
|
let nested = SuryToJsonSchema$ReventlessCore.deriveObjectSchema(undefined, undefined, Sury.$schema(s => ({
|
|
1192
1192
|
lineItems: s.m(Sury.array(lineItem))
|
|
@@ -38,7 +38,7 @@ let eventSchema$1 = Sury.union([
|
|
|
38
38
|
Sury.$schema(s => ({
|
|
39
39
|
TAG: "PlainEvent",
|
|
40
40
|
name: s.m(Sury.string),
|
|
41
|
-
value: s.m(Sury.
|
|
41
|
+
value: s.m(Sury.int32)
|
|
42
42
|
})),
|
|
43
43
|
Sury.literal("EmptyEvent")
|
|
44
44
|
]);
|
|
@@ -325,7 +325,7 @@ function makeMockStorage() {
|
|
|
325
325
|
|
|
326
326
|
let plainRecordSchema = Sury.$schema(s => ({
|
|
327
327
|
name: s.m(Sury.string),
|
|
328
|
-
value: s.m(Sury.
|
|
328
|
+
value: s.m(Sury.int32)
|
|
329
329
|
}));
|
|
330
330
|
|
|
331
331
|
let multiTagRecordSchema = Sury.$schema(s => ({
|
|
@@ -350,7 +350,7 @@ let mixedEventSchema = Sury.union([
|
|
|
350
350
|
Sury.$schema(s => ({
|
|
351
351
|
TAG: "EventB",
|
|
352
352
|
id: s.m(DcbTag$Reventless.string),
|
|
353
|
-
count: s.m(Sury.
|
|
353
|
+
count: s.m(Sury.int32)
|
|
354
354
|
})),
|
|
355
355
|
Sury.$schema(s => ({
|
|
356
356
|
TAG: "EventC",
|
|
@@ -373,7 +373,7 @@ let complexEventSchema = Sury.union([
|
|
|
373
373
|
TAG: "OrderPlaced",
|
|
374
374
|
orderId: s.m(DcbTag$Reventless.string),
|
|
375
375
|
userId: s.m(DcbTag$Reventless.string),
|
|
376
|
-
amount: s.m(Sury.
|
|
376
|
+
amount: s.m(Sury.number)
|
|
377
377
|
})),
|
|
378
378
|
Sury.$schema(s => ({
|
|
379
379
|
TAG: "OrderShipped",
|
|
@@ -383,7 +383,7 @@ let complexEventSchema = Sury.union([
|
|
|
383
383
|
Sury.$schema(s => ({
|
|
384
384
|
TAG: "PaymentProcessed",
|
|
385
385
|
paymentId: s.m(DcbTag$Reventless.string),
|
|
386
|
-
amount: s.m(Sury.
|
|
386
|
+
amount: s.m(Sury.number)
|
|
387
387
|
}))
|
|
388
388
|
]);
|
|
389
389
|
|
|
@@ -463,7 +463,7 @@ let compositeMultiVariantSchema = Sury.union([
|
|
|
463
463
|
TAG: "VariantB",
|
|
464
464
|
env: s.m(DcbTag$Reventless.compositePartitionMember(0, undefined)),
|
|
465
465
|
name: s.m(DcbTag$Reventless.compositePartitionMember(1, undefined)),
|
|
466
|
-
count: s.m(Sury.
|
|
466
|
+
count: s.m(Sury.int32)
|
|
467
467
|
}))
|
|
468
468
|
]);
|
|
469
469
|
|
|
@@ -43,7 +43,7 @@ let producedAMismatchTagsSchema = Sury.$schema(s => ({
|
|
|
43
43
|
let producedAMismatchTypeSchema = Sury.$schema(s => ({
|
|
44
44
|
TAG: "ItemCreated",
|
|
45
45
|
itemId: s.m(DcbTag$Reventless.string),
|
|
46
|
-
name: s.m(Sury.
|
|
46
|
+
name: s.m(Sury.number)
|
|
47
47
|
}));
|
|
48
48
|
|
|
49
49
|
let consumedFullSchema = Sury.union([
|
|
@@ -77,13 +77,13 @@ let consumedDanglingSchema = Sury.$schema(s => ({
|
|
|
77
77
|
let consumedBadFieldSchema = Sury.$schema(s => ({
|
|
78
78
|
TAG: "ItemCreated",
|
|
79
79
|
itemId: s.m(Sury.string),
|
|
80
|
-
rating: s.m(Sury.
|
|
80
|
+
rating: s.m(Sury.number)
|
|
81
81
|
}));
|
|
82
82
|
|
|
83
83
|
let consumedBadTypeSchema = Sury.$schema(s => ({
|
|
84
84
|
TAG: "ItemCreated",
|
|
85
85
|
itemId: s.m(Sury.string),
|
|
86
|
-
name: s.m(Sury.
|
|
86
|
+
name: s.m(Sury.number)
|
|
87
87
|
}));
|
|
88
88
|
|
|
89
89
|
let recordDemandCommandSchema = Sury.$schema(s => ({
|
|
@@ -14,11 +14,11 @@ let eventSchema = Sury.union([
|
|
|
14
14
|
Sury.$schema(s => ({
|
|
15
15
|
TAG: "ItemCreated",
|
|
16
16
|
name: s.m(Sury.string),
|
|
17
|
-
price: s.m(Sury.
|
|
17
|
+
price: s.m(Sury.number)
|
|
18
18
|
})),
|
|
19
19
|
Sury.$schema(s => ({
|
|
20
20
|
TAG: "ItemPriceUpdated",
|
|
21
|
-
newPrice: s.m(Sury.
|
|
21
|
+
newPrice: s.m(Sury.number)
|
|
22
22
|
})),
|
|
23
23
|
Sury.literal("ItemRemoved")
|
|
24
24
|
]);
|
|
@@ -36,7 +36,7 @@ let name$1 = "ItemCatalog";
|
|
|
36
36
|
|
|
37
37
|
let stateSchema = Sury.$schema(s => ({
|
|
38
38
|
name: s.m(Sury.string),
|
|
39
|
-
price: s.m(Sury.
|
|
39
|
+
price: s.m(Sury.number)
|
|
40
40
|
}));
|
|
41
41
|
|
|
42
42
|
let config = ReadModel$Reventless.config(undefined, undefined, undefined);
|
|
@@ -128,7 +128,7 @@ let eventSchema$1 = Sury.union([
|
|
|
128
128
|
Sury.$schema(s => ({
|
|
129
129
|
TAG: "OrderPlaced",
|
|
130
130
|
orderId: s.m(Sury.string),
|
|
131
|
-
amount: s.m(Sury.
|
|
131
|
+
amount: s.m(Sury.number)
|
|
132
132
|
})),
|
|
133
133
|
Sury.$schema(s => ({
|
|
134
134
|
TAG: "OrderShipped",
|
|
@@ -151,7 +151,7 @@ let commandSchema = Sury.union([
|
|
|
151
151
|
Sury.$schema(s => ({
|
|
152
152
|
TAG: "ProcessOrder",
|
|
153
153
|
orderId: s.m(Sury.string),
|
|
154
|
-
amount: s.m(Sury.
|
|
154
|
+
amount: s.m(Sury.number)
|
|
155
155
|
})),
|
|
156
156
|
Sury.$schema(s => ({
|
|
157
157
|
TAG: "ShipOrder",
|
|
@@ -11,7 +11,7 @@ module CustomerId = Reventless.Id.Make({
|
|
|
11
11
|
let key = "customerId"
|
|
12
12
|
})
|
|
13
13
|
|
|
14
|
-
let refsOf = (~viewsByKey, schema: S.t<'a>) => {
|
|
14
|
+
let refsOf = (~viewsByKey, ~minted=?, schema: S.t<'a>) => {
|
|
15
15
|
let reports = []
|
|
16
16
|
let identityViews: Plugin_Structure.identityViews = {
|
|
17
17
|
viewsByKey: Dict.fromArray(viewsByKey),
|
|
@@ -23,7 +23,7 @@ let refsOf = (~viewsByKey, schema: S.t<'a>) => {
|
|
|
23
23
|
| _ => Dict.make()
|
|
24
24
|
}
|
|
25
25
|
let refs =
|
|
26
|
-
Plugin_Structure.extractReferences(~identityViews, properties)->Array.map(r => (
|
|
26
|
+
Plugin_Structure.extractReferences(~identityViews, ~minted?, properties)->Array.map(r => (
|
|
27
27
|
r.fieldName,
|
|
28
28
|
r.entity,
|
|
29
29
|
))
|
|
@@ -63,6 +63,17 @@ describe("a reference derived from the type", () => {
|
|
|
63
63
|
expect(reports->Array.some(r => r->String.includes("no view in this plugin")))->toBe(true)
|
|
64
64
|
})
|
|
65
65
|
|
|
66
|
+
// A create form mints this id; a list of the rows that already exist is the
|
|
67
|
+
// wrong control for it.
|
|
68
|
+
testSync("the id a creating command mints references nothing", () => {
|
|
69
|
+
let (refs, reports) = refsOf(
|
|
70
|
+
~viewsByKey=[("customerId", ["Customers"]), ("productId", ["AvailableProducts"])],
|
|
71
|
+
~minted="buyer",
|
|
72
|
+
order,
|
|
73
|
+
)
|
|
74
|
+
expect((refs, reports))->toEqual(([("productIds", "AvailableProducts")], []))
|
|
75
|
+
})
|
|
76
|
+
|
|
66
77
|
testSync("an untyped field is left to its name, as before", () => {
|
|
67
78
|
let (refs, reports) = refsOf(
|
|
68
79
|
~viewsByKey=[("customerId", ["Customers"])],
|
|
@@ -96,4 +107,12 @@ describe("a declared @ref on a typed id", () => {
|
|
|
96
107
|
)
|
|
97
108
|
expect((refs, reports))->toEqual(([("buyer", "Customers")], []))
|
|
98
109
|
})
|
|
110
|
+
|
|
111
|
+
testSync("stands on a minted id: only the derived one steps aside", () => {
|
|
112
|
+
let chosen = S.schema(
|
|
113
|
+
s => {"buyer": s.matches(CustomerId.schema->Reventless.Reference.mark("Customers"))},
|
|
114
|
+
)
|
|
115
|
+
let (refs, _) = refsOf(~viewsByKey=[("customerId", ["Customers"])], ~minted="buyer", chosen)
|
|
116
|
+
expect(refs)->toEqual([("buyer", "Customers")])
|
|
117
|
+
})
|
|
99
118
|
})
|
|
@@ -13,7 +13,7 @@ let CustomerId = Id$Reventless.Make({
|
|
|
13
13
|
key: "customerId"
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
function refsOf(viewsByKey, schema) {
|
|
16
|
+
function refsOf(viewsByKey, minted, schema) {
|
|
17
17
|
let reports = [];
|
|
18
18
|
let identityViews_viewsByKey = Object.fromEntries(viewsByKey);
|
|
19
19
|
let identityViews_viewNames = viewsByKey.flatMap(param => param[1]);
|
|
@@ -27,7 +27,7 @@ function refsOf(viewsByKey, schema) {
|
|
|
27
27
|
};
|
|
28
28
|
let properties;
|
|
29
29
|
properties = schema.type === "object" ? schema.properties : ({});
|
|
30
|
-
let refs = Plugin_Structure$ReventlessCore.extractReferences(identityViews, properties).map(r => [
|
|
30
|
+
let refs = Plugin_Structure$ReventlessCore.extractReferences(identityViews, minted, properties).map(r => [
|
|
31
31
|
r.fieldName,
|
|
32
32
|
r.entity
|
|
33
33
|
]);
|
|
@@ -54,7 +54,7 @@ globalThis.describe("a reference derived from the type", () => {
|
|
|
54
54
|
"productId",
|
|
55
55
|
["AvailableProducts"]
|
|
56
56
|
]
|
|
57
|
-
], order);
|
|
57
|
+
], undefined, order);
|
|
58
58
|
globalThis.expect(match[0]).toEqual([
|
|
59
59
|
[
|
|
60
60
|
"buyer",
|
|
@@ -80,7 +80,7 @@ globalThis.describe("a reference derived from the type", () => {
|
|
|
80
80
|
"ProductDemand"
|
|
81
81
|
]
|
|
82
82
|
]
|
|
83
|
-
], order);
|
|
83
|
+
], undefined, order);
|
|
84
84
|
globalThis.expect(match[0]).toEqual([[
|
|
85
85
|
"buyer",
|
|
86
86
|
"Customers"
|
|
@@ -91,18 +91,40 @@ globalThis.describe("a reference derived from the type", () => {
|
|
|
91
91
|
let match = refsOf([[
|
|
92
92
|
"productId",
|
|
93
93
|
["AvailableProducts"]
|
|
94
|
-
]], order);
|
|
94
|
+
]], undefined, order);
|
|
95
95
|
globalThis.expect(match[0]).toEqual([[
|
|
96
96
|
"productIds",
|
|
97
97
|
"AvailableProducts"
|
|
98
98
|
]]);
|
|
99
99
|
globalThis.expect(match[1].some(r => r.includes("no view in this plugin"))).toBe(true);
|
|
100
100
|
});
|
|
101
|
+
globalThis.test("the id a creating command mints references nothing", () => {
|
|
102
|
+
let match = refsOf([
|
|
103
|
+
[
|
|
104
|
+
"customerId",
|
|
105
|
+
["Customers"]
|
|
106
|
+
],
|
|
107
|
+
[
|
|
108
|
+
"productId",
|
|
109
|
+
["AvailableProducts"]
|
|
110
|
+
]
|
|
111
|
+
], "buyer", order);
|
|
112
|
+
globalThis.expect([
|
|
113
|
+
match[0],
|
|
114
|
+
match[1]
|
|
115
|
+
]).toEqual([
|
|
116
|
+
[[
|
|
117
|
+
"productIds",
|
|
118
|
+
"AvailableProducts"
|
|
119
|
+
]],
|
|
120
|
+
[]
|
|
121
|
+
]);
|
|
122
|
+
});
|
|
101
123
|
globalThis.test("an untyped field is left to its name, as before", () => {
|
|
102
124
|
let match = refsOf([[
|
|
103
125
|
"customerId",
|
|
104
126
|
["Customers"]
|
|
105
|
-
]], Sury.$schema(s => ({
|
|
127
|
+
]], undefined, Sury.$schema(s => ({
|
|
106
128
|
customerId: s.m(Sury.string)
|
|
107
129
|
})));
|
|
108
130
|
globalThis.expect([
|
|
@@ -129,7 +151,7 @@ globalThis.describe("a declared @ref on a typed id", () => {
|
|
|
129
151
|
"productId",
|
|
130
152
|
["Products"]
|
|
131
153
|
]
|
|
132
|
-
], referenced);
|
|
154
|
+
], undefined, referenced);
|
|
133
155
|
globalThis.expect(match[0]).toEqual([[
|
|
134
156
|
"buyer",
|
|
135
157
|
"Products"
|
|
@@ -146,7 +168,7 @@ globalThis.describe("a declared @ref on a typed id", () => {
|
|
|
146
168
|
"Customers",
|
|
147
169
|
"VipCustomers"
|
|
148
170
|
]
|
|
149
|
-
]], chosen);
|
|
171
|
+
]], undefined, chosen);
|
|
150
172
|
globalThis.expect([
|
|
151
173
|
match[0],
|
|
152
174
|
match[1]
|
|
@@ -158,6 +180,19 @@ globalThis.describe("a declared @ref on a typed id", () => {
|
|
|
158
180
|
[]
|
|
159
181
|
]);
|
|
160
182
|
});
|
|
183
|
+
globalThis.test("stands on a minted id: only the derived one steps aside", () => {
|
|
184
|
+
let chosen = Sury.$schema(s => ({
|
|
185
|
+
buyer: s.m(Reference$Reventless.mark(CustomerId.schema, undefined, undefined, "Customers"))
|
|
186
|
+
}));
|
|
187
|
+
let match = refsOf([[
|
|
188
|
+
"customerId",
|
|
189
|
+
["Customers"]
|
|
190
|
+
]], "buyer", chosen);
|
|
191
|
+
globalThis.expect(match[0]).toEqual([[
|
|
192
|
+
"buyer",
|
|
193
|
+
"Customers"
|
|
194
|
+
]]);
|
|
195
|
+
});
|
|
161
196
|
});
|
|
162
197
|
|
|
163
198
|
export {
|
|
@@ -7,5 +7,5 @@ type record = {
|
|
|
7
7
|
@schema
|
|
8
8
|
type variant = | @s.meta({description: "QQQ"}) Q(int) | @s.meta({description: "XXX"}) X | Y
|
|
9
9
|
|
|
10
|
-
Console.log2("Record:", recordSchema->S.
|
|
11
|
-
Console.log2("Variant:", variantSchema->S.
|
|
10
|
+
Console.log2("Record:", recordSchema->S.toInputJSONSchemaOrThrow->JSON.stringifyAny(~space=2))
|
|
11
|
+
Console.log2("Variant:", variantSchema->S.toInputJSONSchemaOrThrow->JSON.stringifyAny(~space=2))
|
|
@@ -12,15 +12,15 @@ let recordSchema = Sury.$schema(s => ({
|
|
|
12
12
|
let variantSchema = Sury.union([
|
|
13
13
|
Sury.$schema(s => ({
|
|
14
14
|
TAG: "Q",
|
|
15
|
-
_0: s.m(Sury.
|
|
15
|
+
_0: s.m(Sury.int32)
|
|
16
16
|
})),
|
|
17
17
|
Sury.literal("X"),
|
|
18
18
|
Sury.literal("Y")
|
|
19
19
|
]);
|
|
20
20
|
|
|
21
|
-
console.log("Record:", JSON.stringify(Sury.
|
|
21
|
+
console.log("Record:", JSON.stringify(Sury.toInputJSONSchemaOrThrow(recordSchema), undefined, 2));
|
|
22
22
|
|
|
23
|
-
console.log("Variant:", JSON.stringify(Sury.
|
|
23
|
+
console.log("Variant:", JSON.stringify(Sury.toInputJSONSchemaOrThrow(variantSchema), undefined, 2));
|
|
24
24
|
|
|
25
25
|
export {
|
|
26
26
|
recordSchema,
|
|
@@ -1740,7 +1740,7 @@ describe("Plugin_Structure.make — Phase 2 graph fields", () => {
|
|
|
1740
1740
|
|
|
1741
1741
|
// Phase 4: queryableDef.schema must carry x-reventless-* extension keys for
|
|
1742
1742
|
// annotated state types. Plugin_Structure now uses SuryToJsonSchema.deriveObjectSchema
|
|
1743
|
-
// (annotation-aware) instead of S.
|
|
1743
|
+
// (annotation-aware) instead of S.toInputJSONSchemaOrThrow (metadata-blind).
|
|
1744
1744
|
describe("queryableDef.schema propagates x-reventless-* annotations", () => {
|
|
1745
1745
|
let parseSchema = (svs: Reventless.Plugin.queryableDef): JSON.t => svs.schema->JSON.parseOrThrow
|
|
1746
1746
|
|
|
@@ -1417,20 +1417,20 @@ globalThis.describe("Plugin_Structure.make — Phase 2 graph fields", () => {
|
|
|
1417
1417
|
});
|
|
1418
1418
|
globalThis.test("publishes no states on the boolean form", () => {
|
|
1419
1419
|
let schema = Sury.$schema(s => ({
|
|
1420
|
-
archived: s.m(Sury.
|
|
1420
|
+
archived: s.m(Sury.boolean)
|
|
1421
1421
|
}));
|
|
1422
1422
|
globalThis.expect(Plugin_Structure$ReventlessCore.retiredValuesFromStateSchema(withRetired(schema, "archived"))).toEqual(undefined);
|
|
1423
1423
|
});
|
|
1424
1424
|
globalThis.test("names the annotated field", () => {
|
|
1425
1425
|
let schema = Sury.$schema(s => ({
|
|
1426
|
-
archived: s.m(Sury.
|
|
1426
|
+
archived: s.m(Sury.boolean)
|
|
1427
1427
|
}));
|
|
1428
1428
|
globalThis.expect(Plugin_Structure$ReventlessCore.retiredFieldFromStateSchema(withRetired(schema, "archived"))).toEqual("archived");
|
|
1429
1429
|
});
|
|
1430
1430
|
globalThis.test("declines a conventionally-named boolean nobody annotated", () => {
|
|
1431
1431
|
let schema = Sury.$schema(s => ({
|
|
1432
|
-
archived: s.m(Sury.
|
|
1433
|
-
deactivated: s.m(Sury.
|
|
1432
|
+
archived: s.m(Sury.boolean),
|
|
1433
|
+
deactivated: s.m(Sury.boolean)
|
|
1434
1434
|
}));
|
|
1435
1435
|
globalThis.expect(Plugin_Structure$ReventlessCore.retiredFieldFromStateSchema(schema)).toEqual(undefined);
|
|
1436
1436
|
});
|
|
@@ -1530,7 +1530,7 @@ globalThis.describe("Plugin_Structure.make — Phase 2 graph fields", () => {
|
|
|
1530
1530
|
});
|
|
1531
1531
|
globalThis.test("the boolean form is not a skip", () => {
|
|
1532
1532
|
let schema = withRetiredStates(Sury.$schema(s => ({
|
|
1533
|
-
archived: s.m(Sury.
|
|
1533
|
+
archived: s.m(Sury.boolean)
|
|
1534
1534
|
})), "archived", undefined, undefined);
|
|
1535
1535
|
globalThis.expect(Plugin_Structure$ReventlessCore.checkRetiredValue("Products", schema)).toEqual("NotDeclared");
|
|
1536
1536
|
});
|
|
@@ -7,8 +7,8 @@ import * as SchemaWalker$ReventlessCore from "../../src/plugin/component/SchemaW
|
|
|
7
7
|
|
|
8
8
|
let simpleRecordSchema = Sury.$schema(s => ({
|
|
9
9
|
label: s.m(Sury.string),
|
|
10
|
-
count: s.m(Sury.
|
|
11
|
-
rating: s.m(Sury.$option(Sury.
|
|
10
|
+
count: s.m(Sury.int32),
|
|
11
|
+
rating: s.m(Sury.$option(Sury.number))
|
|
12
12
|
}));
|
|
13
13
|
|
|
14
14
|
let simpleVariantSchema = Sury.union([
|
|
@@ -15,7 +15,7 @@ function evolve(_state, _event) {
|
|
|
15
15
|
|
|
16
16
|
let lineItemSchema = Sury.$schema(s => ({
|
|
17
17
|
productId: s.m(Reference$Reventless.to_(undefined, undefined, "AvailableProducts")),
|
|
18
|
-
quantity: s.m(Sury.
|
|
18
|
+
quantity: s.m(Sury.int32)
|
|
19
19
|
}));
|
|
20
20
|
|
|
21
21
|
let commandSchema = Sury.$schema(s => ({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Phase 4 fixture: state-view slice with structural annotations.
|
|
2
2
|
// Used to verify Plugin_Structure.make ships x-reventless-* extension
|
|
3
|
-
// properties through queryableDef.schema after swapping S.
|
|
3
|
+
// properties through queryableDef.schema after swapping S.toInputJSONSchemaOrThrow
|
|
4
4
|
// for SuryToJsonSchema.deriveObjectSchema.
|
|
5
5
|
|
|
6
6
|
@@reventless.spec("AnnotatedView")
|