@danielhritcu/zenstack-custom 1.2.1 → 1.2.2
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/cli.cjs +37 -8
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +6 -2
- package/dist/cli.d.ts +6 -2
- package/dist/cli.js +37 -8
- package/dist/cli.js.map +1 -1
- package/dist/codegen/index.cjs +14 -2
- package/dist/codegen/index.cjs.map +1 -1
- package/dist/codegen/index.d.cts +3 -1
- package/dist/codegen/index.d.ts +3 -1
- package/dist/codegen/index.js +14 -2
- package/dist/codegen/index.js.map +1 -1
- package/dist/index.cjs +14 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/codegen/index.d.cts
CHANGED
|
@@ -206,7 +206,9 @@ declare function discoverViews(allViews: Record<string, unknown>): ViewInfo[];
|
|
|
206
206
|
declare function extractFKs(table: PgTable): FKInfo[];
|
|
207
207
|
|
|
208
208
|
type RelationTargets = Record<string, Record<string, string>>;
|
|
209
|
-
declare function buildRelations(tables: TableInfo[], relationTargets?: RelationTargets, filteredRelations?: FilteredRelationsConfig, throughRelations?: ThroughRelationsConfig, fkRelations?: Record<string, Record<string, FKRelationInfo$1
|
|
209
|
+
declare function buildRelations(tables: TableInfo[], relationTargets?: RelationTargets, filteredRelations?: FilteredRelationsConfig, throughRelations?: ThroughRelationsConfig, fkRelations?: Record<string, Record<string, FKRelationInfo$1>>, options?: {
|
|
210
|
+
ignoreCompositeFkColumns?: string[];
|
|
211
|
+
}): {
|
|
210
212
|
modelRelations: Map<string, RelationField[]>;
|
|
211
213
|
inverseRelations: Map<string, RelationField[]>;
|
|
212
214
|
};
|
package/dist/codegen/index.d.ts
CHANGED
|
@@ -206,7 +206,9 @@ declare function discoverViews(allViews: Record<string, unknown>): ViewInfo[];
|
|
|
206
206
|
declare function extractFKs(table: PgTable): FKInfo[];
|
|
207
207
|
|
|
208
208
|
type RelationTargets = Record<string, Record<string, string>>;
|
|
209
|
-
declare function buildRelations(tables: TableInfo[], relationTargets?: RelationTargets, filteredRelations?: FilteredRelationsConfig, throughRelations?: ThroughRelationsConfig, fkRelations?: Record<string, Record<string, FKRelationInfo$1
|
|
209
|
+
declare function buildRelations(tables: TableInfo[], relationTargets?: RelationTargets, filteredRelations?: FilteredRelationsConfig, throughRelations?: ThroughRelationsConfig, fkRelations?: Record<string, Record<string, FKRelationInfo$1>>, options?: {
|
|
210
|
+
ignoreCompositeFkColumns?: string[];
|
|
211
|
+
}): {
|
|
210
212
|
modelRelations: Map<string, RelationField[]>;
|
|
211
213
|
inverseRelations: Map<string, RelationField[]>;
|
|
212
214
|
};
|
package/dist/codegen/index.js
CHANGED
|
@@ -924,7 +924,7 @@ function unfoldRelationSelector(relation) {
|
|
|
924
924
|
return relationName;
|
|
925
925
|
}
|
|
926
926
|
__name(unfoldRelationSelector, "unfoldRelationSelector");
|
|
927
|
-
function buildRelations(tables, relationTargets = {}, filteredRelations = {}, throughRelations = {}, fkRelations = {}) {
|
|
927
|
+
function buildRelations(tables, relationTargets = {}, filteredRelations = {}, throughRelations = {}, fkRelations = {}, options = {}) {
|
|
928
928
|
const baseTables = tables.filter((table) => !table.derivedFrom);
|
|
929
929
|
const sqlToBaseTable = /* @__PURE__ */ new Map();
|
|
930
930
|
const modelToTable = /* @__PURE__ */ new Map();
|
|
@@ -1013,7 +1013,19 @@ function buildRelations(tables, relationTargets = {}, filteredRelations = {}, th
|
|
|
1013
1013
|
if (!targetTable) continue;
|
|
1014
1014
|
const signature = makePhysicalFKSignature(table, targetTable, fk);
|
|
1015
1015
|
if (declaredFKRelations.has(signature)) continue;
|
|
1016
|
-
|
|
1016
|
+
const ignoreCols = options.ignoreCompositeFkColumns ?? [];
|
|
1017
|
+
if (ignoreCols.length > 0 && fk.localColumns.length > 1) {
|
|
1018
|
+
const strippedFk = {
|
|
1019
|
+
...fk,
|
|
1020
|
+
localColumns: fk.localColumns.filter((c) => !ignoreCols.includes(c)),
|
|
1021
|
+
foreignColumns: fk.foreignColumns.filter((_, i) => !ignoreCols.includes(fk.localColumns[i]))
|
|
1022
|
+
};
|
|
1023
|
+
if (strippedFk.localColumns.length > 0) {
|
|
1024
|
+
const strippedSig = makePhysicalFKSignature(table, targetTable, strippedFk);
|
|
1025
|
+
if (declaredFKRelations.has(strippedSig)) continue;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
console.warn(`Warning: undeclared FK "${table.exportName}": [${fk.localColumns.join(", ")}] -> ${targetTable.exportName}([${fk.foreignColumns.join(", ")}]). Add a relation in orm.config.ts or it will be auto-generated.`);
|
|
1017
1029
|
}
|
|
1018
1030
|
}
|
|
1019
1031
|
const forwardByTarget = /* @__PURE__ */ new Map();
|