@famgia/omnify-laravel 2.0.34 → 2.0.36
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/{chunk-XEXTOJRM.js → chunk-FE7YXEZW.js} +28 -4
- package/dist/chunk-FE7YXEZW.js.map +1 -0
- package/dist/index.cjs +27 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin.cjs +27 -3
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-XEXTOJRM.js.map +0 -1
|
@@ -288,6 +288,11 @@ function generateForeignKey(propertyName, property, allSchemas, options = {}) {
|
|
|
288
288
|
const columnName = toColumnName(propertyName) + "_id";
|
|
289
289
|
const targetSchema = assocProp.target ? allSchemas[assocProp.target] : void 0;
|
|
290
290
|
const targetTable = assocProp.target ? toTableName(assocProp.target) : "unknown";
|
|
291
|
+
if (assocProp.target && !targetSchema && !assocProp.targetNamespace && !assocProp.idType) {
|
|
292
|
+
throw new Error(
|
|
293
|
+
`Association "${propertyName}" references target "${assocProp.target}" which was not found in loaded schemas. Available schemas: [${Object.keys(allSchemas).join(", ")}]. If this is an external package reference, add "targetNamespace" and "idType" to the association.`
|
|
294
|
+
);
|
|
295
|
+
}
|
|
291
296
|
const targetPkType = assocProp.idType ?? (targetSchema ? getIdType(targetSchema) : "BigInt");
|
|
292
297
|
let method = "unsignedBigInteger";
|
|
293
298
|
if (targetPkType === "Int") {
|
|
@@ -444,8 +449,13 @@ function schemaToBlueprint(schema, allSchemas, options = {}) {
|
|
|
444
449
|
for (const targetSchemaName of pivotFor) {
|
|
445
450
|
const targetSchema = allSchemas[targetSchemaName];
|
|
446
451
|
const fkColumnName = `${toColumnName(targetSchemaName)}_id`;
|
|
452
|
+
if (!targetSchema) {
|
|
453
|
+
throw new Error(
|
|
454
|
+
`Pivot schema "${schema.name}" references target "${targetSchemaName}" in pivotFor which was not found in loaded schemas. Available schemas: [${Object.keys(allSchemas).join(", ")}]. Make sure the target schema is defined and loaded.`
|
|
455
|
+
);
|
|
456
|
+
}
|
|
447
457
|
if (!explicitColumnNames.has(fkColumnName)) {
|
|
448
|
-
const targetIdType = targetSchema
|
|
458
|
+
const targetIdType = targetSchema.options?.idType ?? "BigInt";
|
|
449
459
|
const columnType = targetIdType === "Uuid" ? "uuid" : targetIdType === "String" ? "string" : "unsignedBigInteger";
|
|
450
460
|
columns.push({
|
|
451
461
|
name: fkColumnName,
|
|
@@ -690,7 +700,12 @@ function extractManyToManyRelations(schema, allSchemas) {
|
|
|
690
700
|
}
|
|
691
701
|
const targetSchema = allSchemas[targetName];
|
|
692
702
|
const targetTable = toTableName(targetName);
|
|
693
|
-
|
|
703
|
+
if (!targetSchema && !assocProp.targetNamespace && !assocProp.idType) {
|
|
704
|
+
throw new Error(
|
|
705
|
+
`ManyToMany association in "${schema.name}" references target "${targetName}" which was not found in loaded schemas. Available schemas: [${Object.keys(allSchemas).join(", ")}]. If this is an external package reference, add "targetNamespace" and "idType" to the association.`
|
|
706
|
+
);
|
|
707
|
+
}
|
|
708
|
+
const targetPkType = assocProp.idType ?? (targetSchema ? getIdType(targetSchema) : "BigInt");
|
|
694
709
|
let isOwningSide;
|
|
695
710
|
if (assocProp.owning !== void 0) {
|
|
696
711
|
isOwningSide = assocProp.owning;
|
|
@@ -1013,9 +1028,18 @@ function renderForeignKeys(blueprint) {
|
|
|
1013
1028
|
return "\n" + lines.join("\n");
|
|
1014
1029
|
}
|
|
1015
1030
|
function renderIndexes(blueprint) {
|
|
1031
|
+
const columnsWithUniqueModifier = /* @__PURE__ */ new Set();
|
|
1032
|
+
for (const column of blueprint.columns) {
|
|
1033
|
+
if (column.modifiers.some((mod) => mod.method === "unique")) {
|
|
1034
|
+
columnsWithUniqueModifier.add(column.name);
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1016
1037
|
const customIndexes = blueprint.indexes.filter((idx) => {
|
|
1017
1038
|
if (idx.unique && idx.columns.length === 1) {
|
|
1018
|
-
|
|
1039
|
+
const columnName = idx.columns[0];
|
|
1040
|
+
if (columnName && columnsWithUniqueModifier.has(columnName)) {
|
|
1041
|
+
return false;
|
|
1042
|
+
}
|
|
1019
1043
|
}
|
|
1020
1044
|
return true;
|
|
1021
1045
|
});
|
|
@@ -5666,4 +5690,4 @@ export {
|
|
|
5666
5690
|
getFactoryPath,
|
|
5667
5691
|
laravelPlugin
|
|
5668
5692
|
};
|
|
5669
|
-
//# sourceMappingURL=chunk-
|
|
5693
|
+
//# sourceMappingURL=chunk-FE7YXEZW.js.map
|