@reventlessdev/reventless-core 3.0.0-alpha.303 → 3.0.0-alpha.305
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
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
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.305 (2026-10-22)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @reventlessdev/reventless-core
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# 3.0.0-alpha.304 (2026-10-21)
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **core:** a typed id links to the view in its own chapter ([5420e30](https://github.com/ReventlessDev/reventless-core/commit/5420e302b835e11f6b85293239869776068120da))
|
|
19
|
+
|
|
20
|
+
|
|
6
21
|
# 3.0.0-alpha.303 (2026-10-21)
|
|
7
22
|
|
|
8
23
|
* feat!: a rejected command says whether the model, the access check or the platform said no ([6a8a6b0](https://github.com/ReventlessDev/reventless-core/commit/6a8a6b0f2f31e766ae26a944c23b0904e51a5865))
|
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.305",
|
|
4
4
|
"description": "Core package for Reventless framework",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"jest": {
|
|
@@ -28,22 +28,22 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"sury": "11.0.0",
|
|
30
30
|
"uuid": "^13.0.0",
|
|
31
|
-
"@reventlessdev/rescript-hash-object": "1.2.0-alpha.15",
|
|
32
31
|
"@reventlessdev/rescript-effect": "1.0.0-alpha.1",
|
|
33
|
-
"@reventlessdev/rescript-jest": "1.0.0-alpha.13",
|
|
34
32
|
"@reventlessdev/rescript-fast-csv": "2.0.0-alpha.23",
|
|
33
|
+
"@reventlessdev/rescript-jest": "1.0.0-alpha.13",
|
|
34
|
+
"@reventlessdev/rescript-hash-object": "1.2.0-alpha.15",
|
|
35
35
|
"@reventlessdev/rescript-node": "2.0.0-alpha.23",
|
|
36
36
|
"@reventlessdev/rescript-pulumi-pulumi": "3.0.0-alpha.0",
|
|
37
37
|
"@reventlessdev/rescript-uuid": "2.0.0-alpha.1",
|
|
38
|
-
"@reventlessdev/reventless-infra": "3.0.0-alpha.200",
|
|
39
38
|
"@reventlessdev/rescript-ssh2": "2.0.0-alpha.24",
|
|
40
|
-
"@reventlessdev/reventless-
|
|
41
|
-
"@reventlessdev/reventless-
|
|
39
|
+
"@reventlessdev/reventless-spec": "3.0.0-alpha.174",
|
|
40
|
+
"@reventlessdev/reventless-infra": "3.0.0-alpha.202",
|
|
41
|
+
"@reventlessdev/reventless-interop": "3.0.0-alpha.42"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"rescript": "12.3.1",
|
|
45
45
|
"sury-ppx": "11.0.0",
|
|
46
|
-
"@reventlessdev/reventless-ppx": "1.0.0-alpha.
|
|
46
|
+
"@reventlessdev/reventless-ppx": "1.0.0-alpha.107"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"rescript": "^12.3.1"
|
|
@@ -593,6 +593,8 @@ id find the view that lists it without an `@ref`. `report` says where the type
|
|
|
593
593
|
cannot decide: several views keyed by the identity, none, or an `@ref` naming a
|
|
594
594
|
view keyed by another. `inform` takes the one case that is not a fault: an
|
|
595
595
|
identity in `ownIdentities`, declared by this plugin, that no view lists yet.
|
|
596
|
+
Where several views are keyed by it, the one in `chapter` (the declaring
|
|
597
|
+
component's) is the reference, if exactly one is there.
|
|
596
598
|
*/
|
|
597
599
|
type identityViews = {
|
|
598
600
|
viewsByKey: dict<array<string>>,
|
|
@@ -600,6 +602,8 @@ type identityViews = {
|
|
|
600
602
|
ownIdentities: array<string>,
|
|
601
603
|
report: string => unit,
|
|
602
604
|
inform: string => unit,
|
|
605
|
+
chapter?: string,
|
|
606
|
+
viewChapter?: string => option<string>,
|
|
603
607
|
}
|
|
604
608
|
|
|
605
609
|
// The reference a typed id implies, and the check on one it declares.
|
|
@@ -627,12 +631,21 @@ let identityReference = (
|
|
|
627
631
|
)
|
|
628
632
|
[]
|
|
629
633
|
| several =>
|
|
630
|
-
identityViews.
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
634
|
+
let inChapter = switch (identityViews.chapter, identityViews.viewChapter) {
|
|
635
|
+
| (Some(chapter), Some(viewChapter)) =>
|
|
636
|
+
several->Array.filter(view => viewChapter(view) == Some(chapter))
|
|
637
|
+
| _ => []
|
|
638
|
+
}
|
|
639
|
+
switch inChapter {
|
|
640
|
+
| [view] => [(fieldName, {Reventless.Semantic.entity: view, plugin: None, identity: key})]
|
|
641
|
+
| _ =>
|
|
642
|
+
identityViews.report(
|
|
643
|
+
`${fieldName} is a ${key}, and ${several->Array.join(
|
|
644
|
+
" and ",
|
|
645
|
+
)} are all keyed by it, and no chapter singles one out. Say which it references with @ref.`,
|
|
646
|
+
)
|
|
647
|
+
[]
|
|
648
|
+
}
|
|
636
649
|
}
|
|
637
650
|
| _ =>
|
|
638
651
|
declared->Array.forEach(((_, target)) =>
|
|
@@ -1695,7 +1708,9 @@ let make = (
|
|
|
1695
1708
|
ownIdentities: identities,
|
|
1696
1709
|
report: message => once(log.warn, message),
|
|
1697
1710
|
inform: message => once(log.info, message),
|
|
1711
|
+
viewChapter: chapterOf,
|
|
1698
1712
|
}
|
|
1713
|
+
let identityViewsOf = component => {...identityViews, chapter: ?chapterOf(component)}
|
|
1699
1714
|
|
|
1700
1715
|
let stateChangeDefs =
|
|
1701
1716
|
stateChangeSlices->Array.mapWithIndex((module(SCS: ReventlessInfra.StateChangeSlice.T), i) => {
|
|
@@ -1706,7 +1721,7 @@ let make = (
|
|
|
1706
1721
|
{
|
|
1707
1722
|
Reventless.Plugin.name: SCS.Spec.name,
|
|
1708
1723
|
commands: extractCommandDefs(
|
|
1709
|
-
~identityViews,
|
|
1724
|
+
~identityViews=identityViewsOf(SCS.Spec.name),
|
|
1710
1725
|
~isAggregate=false,
|
|
1711
1726
|
~partitionKey=?partitionBySlice->Dict.get(SCS.Spec.name),
|
|
1712
1727
|
~mutationFieldFor=variantName =>
|
|
@@ -1725,7 +1740,10 @@ let make = (
|
|
|
1725
1740
|
consumedEventTypes: consumed,
|
|
1726
1741
|
linkedViews: linkedSvsFor(produced),
|
|
1727
1742
|
consistencyRead: consistencyReadFor(consumed),
|
|
1728
|
-
events: extractEventDefs(
|
|
1743
|
+
events: extractEventDefs(
|
|
1744
|
+
~identityViews=identityViewsOf(SCS.Spec.name),
|
|
1745
|
+
SCS.Spec.eventSchema->S.castToUnknown,
|
|
1746
|
+
),
|
|
1729
1747
|
errors: extractErrorDefs(SCS.Spec.errorSchema->S.castToUnknown),
|
|
1730
1748
|
chapter: chapterOf(SCS.Spec.name),
|
|
1731
1749
|
}: Reventless.Plugin.writeSideDef
|
|
@@ -1742,7 +1760,7 @@ let make = (
|
|
|
1742
1760
|
{
|
|
1743
1761
|
Reventless.Plugin.name: A.Spec.name,
|
|
1744
1762
|
commands: extractCommandDefs(
|
|
1745
|
-
~identityViews,
|
|
1763
|
+
~identityViews=identityViewsOf(A.Spec.name),
|
|
1746
1764
|
~isAggregate=true,
|
|
1747
1765
|
~mutationFieldFor=variantName =>
|
|
1748
1766
|
Api_Naming.aggregateMutationField(
|
|
@@ -1759,7 +1777,10 @@ let make = (
|
|
|
1759
1777
|
consumedEventTypes: [],
|
|
1760
1778
|
linkedViews: Array.concat(linkedSvsFor(produced), linkedReadModelsFor(A.Spec.name)),
|
|
1761
1779
|
consistencyRead: None,
|
|
1762
|
-
events: extractEventDefs(
|
|
1780
|
+
events: extractEventDefs(
|
|
1781
|
+
~identityViews=identityViewsOf(A.Spec.name),
|
|
1782
|
+
A.Spec.eventSchema->S.castToUnknown,
|
|
1783
|
+
),
|
|
1763
1784
|
errors: extractErrorDefs(A.Spec.errorSchema->S.castToUnknown),
|
|
1764
1785
|
chapter: chapterOf(A.Spec.name),
|
|
1765
1786
|
}: Reventless.Plugin.writeSideDef
|
|
@@ -466,18 +466,34 @@ function identityReference(identityViews, fieldName, fieldSchema, declared) {
|
|
|
466
466
|
let len = keyed.length;
|
|
467
467
|
if (len !== 1) {
|
|
468
468
|
if (len !== 0) {
|
|
469
|
-
|
|
470
|
-
|
|
469
|
+
let match = identityViews.chapter;
|
|
470
|
+
let match$1 = identityViews.viewChapter;
|
|
471
|
+
let inChapter = match !== undefined ? (
|
|
472
|
+
match$1 !== undefined ? keyed.filter(view => Primitive_object.equal(match$1(view), match)) : []
|
|
473
|
+
) : [];
|
|
474
|
+
if (inChapter.length !== 1) {
|
|
475
|
+
identityViews.report(fieldName + ` is a ` + key + `, and ` + keyed.join(" and ") + ` are all keyed by it, and no chapter singles one out. Say which it references with @ref.`);
|
|
476
|
+
return [];
|
|
477
|
+
}
|
|
478
|
+
let view = inChapter[0];
|
|
479
|
+
return [[
|
|
480
|
+
fieldName,
|
|
481
|
+
{
|
|
482
|
+
entity: view,
|
|
483
|
+
plugin: undefined,
|
|
484
|
+
identity: key
|
|
485
|
+
}
|
|
486
|
+
]];
|
|
471
487
|
}
|
|
472
488
|
let say = identityViews.ownIdentities.includes(key) ? identityViews.inform : identityViews.report;
|
|
473
489
|
say(fieldName + ` is a ` + key + `, and no view in this plugin is keyed by it, so it references nothing. List the identity in a view, or reference another plugin's with @ref("Plugin.View").`);
|
|
474
490
|
return [];
|
|
475
491
|
}
|
|
476
|
-
let view = keyed[0];
|
|
492
|
+
let view$1 = keyed[0];
|
|
477
493
|
return [[
|
|
478
494
|
fieldName,
|
|
479
495
|
{
|
|
480
|
-
entity: view,
|
|
496
|
+
entity: view$1,
|
|
481
497
|
plugin: undefined,
|
|
482
498
|
identity: key
|
|
483
499
|
}
|
|
@@ -816,6 +832,7 @@ function make(name, aggregatesOpt, readModelsOpt, stateViewSlicesOpt, stateChang
|
|
|
816
832
|
let componentChapters = componentChaptersOpt !== undefined ? componentChaptersOpt : ({});
|
|
817
833
|
let lifecycleModel = lifecycleModelOpt !== undefined ? lifecycleModelOpt : [];
|
|
818
834
|
let identities = identitiesOpt !== undefined ? identitiesOpt : [];
|
|
835
|
+
let chapterOf = compName => componentChapters[compName];
|
|
819
836
|
let model = declaredTransitionsOnly ? [] : lifecycleModel;
|
|
820
837
|
let derivedEdgeFor = (component, command) => model.find(e => {
|
|
821
838
|
if (e.component === component) {
|
|
@@ -1214,12 +1231,19 @@ function make(name, aggregatesOpt, readModelsOpt, stateViewSlicesOpt, stateChang
|
|
|
1214
1231
|
let identityViews_viewNames = viewKeys.map(param => param[0]);
|
|
1215
1232
|
let identityViews_report = message => once(log.warn, message);
|
|
1216
1233
|
let identityViews_inform = message => once(log.info, message);
|
|
1234
|
+
let identityViews_viewChapter = chapterOf;
|
|
1217
1235
|
let identityViews = {
|
|
1218
1236
|
viewsByKey: viewsByKey,
|
|
1219
1237
|
viewNames: identityViews_viewNames,
|
|
1220
1238
|
ownIdentities: identities,
|
|
1221
1239
|
report: identityViews_report,
|
|
1222
|
-
inform: identityViews_inform
|
|
1240
|
+
inform: identityViews_inform,
|
|
1241
|
+
viewChapter: identityViews_viewChapter
|
|
1242
|
+
};
|
|
1243
|
+
let identityViewsOf = component => {
|
|
1244
|
+
let newrecord = {...identityViews};
|
|
1245
|
+
newrecord.chapter = componentChapters[component];
|
|
1246
|
+
return newrecord;
|
|
1223
1247
|
};
|
|
1224
1248
|
let stateChangeDefs = stateChangeSlices.map((SCS, i) => {
|
|
1225
1249
|
let match = scsProduced[i];
|
|
@@ -1228,12 +1252,12 @@ function make(name, aggregatesOpt, readModelsOpt, stateViewSlicesOpt, stateChang
|
|
|
1228
1252
|
let consumed = match$1[1];
|
|
1229
1253
|
return {
|
|
1230
1254
|
name: SCS.Spec.name,
|
|
1231
|
-
commands: extractCommandDefs(
|
|
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),
|
|
1232
1256
|
producedEventTypes: produced,
|
|
1233
1257
|
consumedEventTypes: consumed,
|
|
1234
1258
|
linkedViews: linkedSvsFor(produced),
|
|
1235
1259
|
consistencyRead: consistencyReadFor(consumed),
|
|
1236
|
-
events: extractEventDefs(
|
|
1260
|
+
events: extractEventDefs(identityViewsOf(SCS.Spec.name), SCS.Spec.eventSchema),
|
|
1237
1261
|
errors: extractErrorDefs(SCS.Spec.errorSchema),
|
|
1238
1262
|
chapter: componentChapters[SCS.Spec.name]
|
|
1239
1263
|
};
|
|
@@ -1243,12 +1267,12 @@ function make(name, aggregatesOpt, readModelsOpt, stateViewSlicesOpt, stateChang
|
|
|
1243
1267
|
let produced = match[1];
|
|
1244
1268
|
return {
|
|
1245
1269
|
name: A.Spec.name,
|
|
1246
|
-
commands: extractCommandDefs(
|
|
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),
|
|
1247
1271
|
producedEventTypes: produced,
|
|
1248
1272
|
consumedEventTypes: [],
|
|
1249
1273
|
linkedViews: linkedSvsFor(produced).concat(linkedReadModelsFor(A.Spec.name)),
|
|
1250
1274
|
consistencyRead: undefined,
|
|
1251
|
-
events: extractEventDefs(
|
|
1275
|
+
events: extractEventDefs(identityViewsOf(A.Spec.name), A.Spec.eventSchema),
|
|
1252
1276
|
errors: extractErrorDefs(A.Spec.errorSchema),
|
|
1253
1277
|
chapter: componentChapters[A.Spec.name]
|
|
1254
1278
|
};
|
|
@@ -11,7 +11,14 @@ module CustomerId = Reventless.Id.Make({
|
|
|
11
11
|
let key = "customerId"
|
|
12
12
|
})
|
|
13
13
|
|
|
14
|
-
let refsOf = (
|
|
14
|
+
let refsOf = (
|
|
15
|
+
~viewsByKey,
|
|
16
|
+
~ownIdentities=[],
|
|
17
|
+
~minted=?,
|
|
18
|
+
~chapter=?,
|
|
19
|
+
~viewChapters=[],
|
|
20
|
+
schema: S.t<'a>,
|
|
21
|
+
) => {
|
|
15
22
|
let reports = []
|
|
16
23
|
let identityViews: Plugin_Structure.identityViews = {
|
|
17
24
|
viewsByKey: Dict.fromArray(viewsByKey),
|
|
@@ -19,6 +26,8 @@ let refsOf = (~viewsByKey, ~ownIdentities=[], ~minted=?, schema: S.t<'a>) => {
|
|
|
19
26
|
ownIdentities,
|
|
20
27
|
report: message => reports->Array.push(message),
|
|
21
28
|
inform: message => reports->Array.push(`info: ${message}`),
|
|
29
|
+
?chapter,
|
|
30
|
+
viewChapter: view => Dict.fromArray(viewChapters)->Dict.get(view),
|
|
22
31
|
}
|
|
23
32
|
let properties = switch schema->S.castToUnknown {
|
|
24
33
|
| Object({properties}) => properties
|
|
@@ -59,6 +68,38 @@ describe("a reference derived from the type", () => {
|
|
|
59
68
|
expect(reports->Array.some(r => r->String.includes("Products and ProductDemand")))->toBe(true)
|
|
60
69
|
})
|
|
61
70
|
|
|
71
|
+
// A counter keyed by the product beside the product list: each slice links to
|
|
72
|
+
// the view in its own chapter, so adding the counter leaves the rest untouched.
|
|
73
|
+
testSync("of several views keyed by it, the one in the field's chapter is the reference", () => {
|
|
74
|
+
let viewsByKey = [("customerId", ["Customers"]), ("productId", ["Products", "ProductDemand"])]
|
|
75
|
+
let viewChapters = [("Products", "Product"), ("ProductDemand", "ProductDemand")]
|
|
76
|
+
let (product, productReports) = refsOf(~viewsByKey, ~viewChapters, ~chapter="Product", order)
|
|
77
|
+
let (demand, _) = refsOf(~viewsByKey, ~viewChapters, ~chapter="ProductDemand", order)
|
|
78
|
+
expect((product, productReports, demand))->toEqual((
|
|
79
|
+
[("buyer", "Customers"), ("productIds", "Products")],
|
|
80
|
+
[],
|
|
81
|
+
[("buyer", "Customers"), ("productIds", "ProductDemand")],
|
|
82
|
+
))
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
testSync("a chapter holding none of them, or several, still asks for @ref", () => {
|
|
86
|
+
let viewsByKey = [("customerId", ["Customers"]), ("productId", ["Products", "ProductDemand"])]
|
|
87
|
+
let (elsewhere, _) = refsOf(
|
|
88
|
+
~viewsByKey,
|
|
89
|
+
~viewChapters=[("Products", "Product"), ("ProductDemand", "ProductDemand")],
|
|
90
|
+
~chapter="Order",
|
|
91
|
+
order,
|
|
92
|
+
)
|
|
93
|
+
let (both, reports) = refsOf(
|
|
94
|
+
~viewsByKey,
|
|
95
|
+
~viewChapters=[("Products", "Product"), ("ProductDemand", "Product")],
|
|
96
|
+
~chapter="Product",
|
|
97
|
+
order,
|
|
98
|
+
)
|
|
99
|
+
expect((elsewhere, both))->toEqual(([("buyer", "Customers")], [("buyer", "Customers")]))
|
|
100
|
+
expect(reports->Array.some(r => r->String.includes("no chapter singles one out")))->toBe(true)
|
|
101
|
+
})
|
|
102
|
+
|
|
62
103
|
testSync("no view keyed by it is reported", () => {
|
|
63
104
|
let (refs, reports) = refsOf(~viewsByKey=[("productId", ["AvailableProducts"])], order)
|
|
64
105
|
expect(refs)->toEqual([("productIds", "AvailableProducts")])
|
|
@@ -13,8 +13,9 @@ let CustomerId = Id$Reventless.Make({
|
|
|
13
13
|
key: "customerId"
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
function refsOf(viewsByKey, ownIdentitiesOpt, minted, schema) {
|
|
16
|
+
function refsOf(viewsByKey, ownIdentitiesOpt, minted, chapter, viewChaptersOpt, schema) {
|
|
17
17
|
let ownIdentities = ownIdentitiesOpt !== undefined ? ownIdentitiesOpt : [];
|
|
18
|
+
let viewChapters = viewChaptersOpt !== undefined ? viewChaptersOpt : [];
|
|
18
19
|
let reports = [];
|
|
19
20
|
let identityViews_viewsByKey = Object.fromEntries(viewsByKey);
|
|
20
21
|
let identityViews_viewNames = viewsByKey.flatMap(param => param[1]);
|
|
@@ -24,12 +25,15 @@ function refsOf(viewsByKey, ownIdentitiesOpt, minted, schema) {
|
|
|
24
25
|
let identityViews_inform = message => {
|
|
25
26
|
reports.push(`info: ` + message);
|
|
26
27
|
};
|
|
28
|
+
let identityViews_viewChapter = view => Object.fromEntries(viewChapters)[view];
|
|
27
29
|
let identityViews = {
|
|
28
30
|
viewsByKey: identityViews_viewsByKey,
|
|
29
31
|
viewNames: identityViews_viewNames,
|
|
30
32
|
ownIdentities: ownIdentities,
|
|
31
33
|
report: identityViews_report,
|
|
32
|
-
inform: identityViews_inform
|
|
34
|
+
inform: identityViews_inform,
|
|
35
|
+
chapter: chapter,
|
|
36
|
+
viewChapter: identityViews_viewChapter
|
|
33
37
|
};
|
|
34
38
|
let properties;
|
|
35
39
|
properties = schema.type === "object" ? schema.properties : ({});
|
|
@@ -60,7 +64,7 @@ globalThis.describe("a reference derived from the type", () => {
|
|
|
60
64
|
"productId",
|
|
61
65
|
["AvailableProducts"]
|
|
62
66
|
]
|
|
63
|
-
], undefined, undefined, order);
|
|
67
|
+
], undefined, undefined, undefined, undefined, order);
|
|
64
68
|
globalThis.expect(match[0]).toEqual([
|
|
65
69
|
[
|
|
66
70
|
"buyer",
|
|
@@ -86,18 +90,121 @@ globalThis.describe("a reference derived from the type", () => {
|
|
|
86
90
|
"ProductDemand"
|
|
87
91
|
]
|
|
88
92
|
]
|
|
89
|
-
], undefined, undefined, order);
|
|
93
|
+
], undefined, undefined, undefined, undefined, order);
|
|
90
94
|
globalThis.expect(match[0]).toEqual([[
|
|
91
95
|
"buyer",
|
|
92
96
|
"Customers"
|
|
93
97
|
]]);
|
|
94
98
|
globalThis.expect(match[1].some(r => r.includes("Products and ProductDemand"))).toBe(true);
|
|
95
99
|
});
|
|
100
|
+
globalThis.test("of several views keyed by it, the one in the field's chapter is the reference", () => {
|
|
101
|
+
let viewsByKey = [
|
|
102
|
+
[
|
|
103
|
+
"customerId",
|
|
104
|
+
["Customers"]
|
|
105
|
+
],
|
|
106
|
+
[
|
|
107
|
+
"productId",
|
|
108
|
+
[
|
|
109
|
+
"Products",
|
|
110
|
+
"ProductDemand"
|
|
111
|
+
]
|
|
112
|
+
]
|
|
113
|
+
];
|
|
114
|
+
let viewChapters = [
|
|
115
|
+
[
|
|
116
|
+
"Products",
|
|
117
|
+
"Product"
|
|
118
|
+
],
|
|
119
|
+
[
|
|
120
|
+
"ProductDemand",
|
|
121
|
+
"ProductDemand"
|
|
122
|
+
]
|
|
123
|
+
];
|
|
124
|
+
let match = refsOf(viewsByKey, undefined, undefined, "Product", viewChapters, order);
|
|
125
|
+
let match$1 = refsOf(viewsByKey, undefined, undefined, "ProductDemand", viewChapters, order);
|
|
126
|
+
globalThis.expect([
|
|
127
|
+
match[0],
|
|
128
|
+
match[1],
|
|
129
|
+
match$1[0]
|
|
130
|
+
]).toEqual([
|
|
131
|
+
[
|
|
132
|
+
[
|
|
133
|
+
"buyer",
|
|
134
|
+
"Customers"
|
|
135
|
+
],
|
|
136
|
+
[
|
|
137
|
+
"productIds",
|
|
138
|
+
"Products"
|
|
139
|
+
]
|
|
140
|
+
],
|
|
141
|
+
[],
|
|
142
|
+
[
|
|
143
|
+
[
|
|
144
|
+
"buyer",
|
|
145
|
+
"Customers"
|
|
146
|
+
],
|
|
147
|
+
[
|
|
148
|
+
"productIds",
|
|
149
|
+
"ProductDemand"
|
|
150
|
+
]
|
|
151
|
+
]
|
|
152
|
+
]);
|
|
153
|
+
});
|
|
154
|
+
globalThis.test("a chapter holding none of them, or several, still asks for @ref", () => {
|
|
155
|
+
let viewsByKey = [
|
|
156
|
+
[
|
|
157
|
+
"customerId",
|
|
158
|
+
["Customers"]
|
|
159
|
+
],
|
|
160
|
+
[
|
|
161
|
+
"productId",
|
|
162
|
+
[
|
|
163
|
+
"Products",
|
|
164
|
+
"ProductDemand"
|
|
165
|
+
]
|
|
166
|
+
]
|
|
167
|
+
];
|
|
168
|
+
let match = refsOf(viewsByKey, undefined, undefined, "Order", [
|
|
169
|
+
[
|
|
170
|
+
"Products",
|
|
171
|
+
"Product"
|
|
172
|
+
],
|
|
173
|
+
[
|
|
174
|
+
"ProductDemand",
|
|
175
|
+
"ProductDemand"
|
|
176
|
+
]
|
|
177
|
+
], order);
|
|
178
|
+
let match$1 = refsOf(viewsByKey, undefined, undefined, "Product", [
|
|
179
|
+
[
|
|
180
|
+
"Products",
|
|
181
|
+
"Product"
|
|
182
|
+
],
|
|
183
|
+
[
|
|
184
|
+
"ProductDemand",
|
|
185
|
+
"Product"
|
|
186
|
+
]
|
|
187
|
+
], order);
|
|
188
|
+
globalThis.expect([
|
|
189
|
+
match[0],
|
|
190
|
+
match$1[0]
|
|
191
|
+
]).toEqual([
|
|
192
|
+
[[
|
|
193
|
+
"buyer",
|
|
194
|
+
"Customers"
|
|
195
|
+
]],
|
|
196
|
+
[[
|
|
197
|
+
"buyer",
|
|
198
|
+
"Customers"
|
|
199
|
+
]]
|
|
200
|
+
]);
|
|
201
|
+
globalThis.expect(match$1[1].some(r => r.includes("no chapter singles one out"))).toBe(true);
|
|
202
|
+
});
|
|
96
203
|
globalThis.test("no view keyed by it is reported", () => {
|
|
97
204
|
let match = refsOf([[
|
|
98
205
|
"productId",
|
|
99
206
|
["AvailableProducts"]
|
|
100
|
-
]], undefined, undefined, order);
|
|
207
|
+
]], undefined, undefined, undefined, undefined, order);
|
|
101
208
|
globalThis.expect(match[0]).toEqual([[
|
|
102
209
|
"productIds",
|
|
103
210
|
"AvailableProducts"
|
|
@@ -108,14 +215,14 @@ globalThis.describe("a reference derived from the type", () => {
|
|
|
108
215
|
let match = refsOf([[
|
|
109
216
|
"productId",
|
|
110
217
|
["AvailableProducts"]
|
|
111
|
-
]], ["customerId"], undefined, order);
|
|
218
|
+
]], ["customerId"], undefined, undefined, undefined, order);
|
|
112
219
|
globalThis.expect(match[1]).toEqual([`info: buyer is a customerId, and no view in this plugin is keyed by it, so it references nothing. List the identity in a view, or reference another plugin's with @ref("Plugin.View").`]);
|
|
113
220
|
});
|
|
114
221
|
globalThis.test("one it does not declare still warns", () => {
|
|
115
222
|
let match = refsOf([[
|
|
116
223
|
"productId",
|
|
117
224
|
["AvailableProducts"]
|
|
118
|
-
]], ["orderId"], undefined, order);
|
|
225
|
+
]], ["orderId"], undefined, undefined, undefined, order);
|
|
119
226
|
globalThis.expect(match[1].some(r => r.startsWith("buyer is a customerId"))).toBe(true);
|
|
120
227
|
});
|
|
121
228
|
globalThis.test("the id a creating command mints references nothing", () => {
|
|
@@ -128,7 +235,7 @@ globalThis.describe("a reference derived from the type", () => {
|
|
|
128
235
|
"productId",
|
|
129
236
|
["AvailableProducts"]
|
|
130
237
|
]
|
|
131
|
-
], undefined, "buyer", order);
|
|
238
|
+
], undefined, "buyer", undefined, undefined, order);
|
|
132
239
|
globalThis.expect([
|
|
133
240
|
match[0],
|
|
134
241
|
match[1]
|
|
@@ -144,7 +251,7 @@ globalThis.describe("a reference derived from the type", () => {
|
|
|
144
251
|
let match = refsOf([[
|
|
145
252
|
"customerId",
|
|
146
253
|
["Customers"]
|
|
147
|
-
]], undefined, undefined, Sury.$schema(s => ({
|
|
254
|
+
]], undefined, undefined, undefined, undefined, Sury.$schema(s => ({
|
|
148
255
|
customerId: s.m(Sury.string)
|
|
149
256
|
})));
|
|
150
257
|
globalThis.expect([
|
|
@@ -171,7 +278,7 @@ globalThis.describe("a declared @ref on a typed id", () => {
|
|
|
171
278
|
"productId",
|
|
172
279
|
["Products"]
|
|
173
280
|
]
|
|
174
|
-
], undefined, undefined, referenced);
|
|
281
|
+
], undefined, undefined, undefined, undefined, referenced);
|
|
175
282
|
globalThis.expect(match[0]).toEqual([[
|
|
176
283
|
"buyer",
|
|
177
284
|
"Products"
|
|
@@ -188,7 +295,7 @@ globalThis.describe("a declared @ref on a typed id", () => {
|
|
|
188
295
|
"Customers",
|
|
189
296
|
"VipCustomers"
|
|
190
297
|
]
|
|
191
|
-
]], undefined, undefined, chosen);
|
|
298
|
+
]], undefined, undefined, undefined, undefined, chosen);
|
|
192
299
|
globalThis.expect([
|
|
193
300
|
match[0],
|
|
194
301
|
match[1]
|
|
@@ -207,7 +314,7 @@ globalThis.describe("a declared @ref on a typed id", () => {
|
|
|
207
314
|
let match = refsOf([[
|
|
208
315
|
"customerId",
|
|
209
316
|
["Customers"]
|
|
210
|
-
]], undefined, "buyer", chosen);
|
|
317
|
+
]], undefined, "buyer", undefined, undefined, chosen);
|
|
211
318
|
globalThis.expect(match[0]).toEqual([[
|
|
212
319
|
"buyer",
|
|
213
320
|
"Customers"
|