@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/index.js CHANGED
@@ -1084,7 +1084,7 @@ function unfoldRelationSelector(relation) {
1084
1084
  return relationName;
1085
1085
  }
1086
1086
  __name(unfoldRelationSelector, "unfoldRelationSelector");
1087
- function buildRelations(tables, relationTargets = {}, filteredRelations = {}, throughRelations = {}, fkRelations = {}) {
1087
+ function buildRelations(tables, relationTargets = {}, filteredRelations = {}, throughRelations = {}, fkRelations = {}, options = {}) {
1088
1088
  const baseTables = tables.filter((table) => !table.derivedFrom);
1089
1089
  const sqlToBaseTable = /* @__PURE__ */ new Map();
1090
1090
  const modelToTable = /* @__PURE__ */ new Map();
@@ -1173,7 +1173,19 @@ function buildRelations(tables, relationTargets = {}, filteredRelations = {}, th
1173
1173
  if (!targetTable) continue;
1174
1174
  const signature = makePhysicalFKSignature(table, targetTable, fk);
1175
1175
  if (declaredFKRelations.has(signature)) continue;
1176
- throw new Error(`Missing explicit relation in supabase/schema/relations.ts for "${table.exportName}": [${fk.localColumns.join(", ")}] -> ${targetTable.exportName}([${fk.foreignColumns.join(", ")}]).`);
1176
+ const ignoreCols = options.ignoreCompositeFkColumns ?? [];
1177
+ if (ignoreCols.length > 0 && fk.localColumns.length > 1) {
1178
+ const strippedFk = {
1179
+ ...fk,
1180
+ localColumns: fk.localColumns.filter((c) => !ignoreCols.includes(c)),
1181
+ foreignColumns: fk.foreignColumns.filter((_, i) => !ignoreCols.includes(fk.localColumns[i]))
1182
+ };
1183
+ if (strippedFk.localColumns.length > 0) {
1184
+ const strippedSig = makePhysicalFKSignature(table, targetTable, strippedFk);
1185
+ if (declaredFKRelations.has(strippedSig)) continue;
1186
+ }
1187
+ }
1188
+ 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.`);
1177
1189
  }
1178
1190
  }
1179
1191
  const forwardByTarget = /* @__PURE__ */ new Map();