@rebasepro/app 0.10.1-canary.ed8caed → 0.10.1-canary.g4db1bb1
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/dist/index.es.js +18 -10
- package/dist/index.es.js.map +1 -1
- package/package.json +7 -7
- package/src/collections/title-property.ts +26 -16
package/dist/index.es.js
CHANGED
|
@@ -17565,21 +17565,29 @@ function isStorageProperty(property) {
|
|
|
17565
17565
|
function getForeignKeyColumns(collection) {
|
|
17566
17566
|
const keys = /* @__PURE__ */ new Set();
|
|
17567
17567
|
const addRelationKeys = (relation) => {
|
|
17568
|
-
|
|
17569
|
-
|
|
17570
|
-
|
|
17571
|
-
|
|
17572
|
-
|
|
17573
|
-
|
|
17568
|
+
switch (relation.kind) {
|
|
17569
|
+
case "belongsTo":
|
|
17570
|
+
keys.add(relation.localKey ?? generateForeignKeyName(relation.relationName ?? ""));
|
|
17571
|
+
break;
|
|
17572
|
+
case "manyToMany":
|
|
17573
|
+
if (relation.through?.sourceColumn) keys.add(relation.through.sourceColumn);
|
|
17574
|
+
break;
|
|
17575
|
+
case "via": {
|
|
17576
|
+
const from = relation.joinPath?.[0]?.on?.from;
|
|
17577
|
+
for (const column of Array.isArray(from) ? from : [from]) if (column) keys.add(column);
|
|
17578
|
+
break;
|
|
17579
|
+
}
|
|
17580
|
+
default: break;
|
|
17574
17581
|
}
|
|
17575
17582
|
};
|
|
17576
17583
|
for (const relation of collection.relations ?? []) addRelationKeys(relation);
|
|
17577
17584
|
for (const [key, propertyRaw] of Object.entries(collection.properties ?? {})) {
|
|
17578
17585
|
const property = propertyRaw;
|
|
17579
17586
|
if (!property || isPropertyBuilder(property) || property.type !== "relation") continue;
|
|
17580
|
-
|
|
17581
|
-
|
|
17582
|
-
|
|
17587
|
+
if (property.relation) addRelationKeys({
|
|
17588
|
+
...property.relation,
|
|
17589
|
+
relationName: property.relation.relationName ?? key
|
|
17590
|
+
});
|
|
17583
17591
|
}
|
|
17584
17592
|
return keys;
|
|
17585
17593
|
}
|
|
@@ -17600,7 +17608,7 @@ function scoreTitleCandidate(property, key, idKeys, foreignKeys) {
|
|
|
17600
17608
|
if (isHidden$1(property)) return SCORE.DISQUALIFIED;
|
|
17601
17609
|
if (isIdentifierProperty(property, key, idKeys, foreignKeys)) return SCORE.DISQUALIFIED;
|
|
17602
17610
|
if (isStorageProperty(property)) return SCORE.DISQUALIFIED;
|
|
17603
|
-
if (property.type === "relation") return property.cardinality === "many" || property.relation?.
|
|
17611
|
+
if (property.type === "relation") return (property.resolvedRelation ? property.resolvedRelation.cardinality === "many" : property.relation?.kind === "hasMany" || property.relation?.kind === "manyToMany") ? SCORE.DISQUALIFIED : SCORE.RELATION;
|
|
17604
17612
|
if (property.type === "reference") return SCORE.REFERENCE;
|
|
17605
17613
|
if (property.type !== "string") return SCORE.DISQUALIFIED;
|
|
17606
17614
|
if (property.userSelect) return SCORE.USER;
|