@famgia/omnify-laravel 2.0.23 → 2.0.25
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-RSC5ATSV.js → chunk-FQYGLKZY.js} +23 -11
- package/dist/chunk-FQYGLKZY.js.map +1 -0
- package/dist/index.cjs +22 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin.cjs +22 -10
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-RSC5ATSV.js.map +0 -1
|
@@ -288,7 +288,7 @@ 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
|
-
const targetPkType = targetSchema ? getIdType(targetSchema) : "BigInt";
|
|
291
|
+
const targetPkType = assocProp.idType ?? (targetSchema ? getIdType(targetSchema) : "BigInt");
|
|
292
292
|
let method = "unsignedBigInteger";
|
|
293
293
|
if (targetPkType === "Int") {
|
|
294
294
|
method = "unsignedInteger";
|
|
@@ -1496,7 +1496,12 @@ function formatAddColumn(columnName, prop) {
|
|
|
1496
1496
|
}
|
|
1497
1497
|
if (isAssociationWithFkColumn(prop)) {
|
|
1498
1498
|
const fkColumn = getAssociationFkColumnName(columnName);
|
|
1499
|
-
|
|
1499
|
+
const idType = prop.idType ?? "BigInt";
|
|
1500
|
+
let columnMethod = "unsignedBigInteger";
|
|
1501
|
+
if (idType === "Int") columnMethod = "unsignedInteger";
|
|
1502
|
+
else if (idType === "Uuid") columnMethod = "uuid";
|
|
1503
|
+
else if (idType === "String") columnMethod = "string";
|
|
1504
|
+
let code2 = `$table->${columnMethod}('${fkColumn}')`;
|
|
1500
1505
|
if (prop.nullable) code2 += "->nullable()";
|
|
1501
1506
|
lines.push(code2 + ";");
|
|
1502
1507
|
if (prop.target) {
|
|
@@ -1559,7 +1564,12 @@ function formatRenameColumn(oldName, newName, prop) {
|
|
|
1559
1564
|
function formatModifyColumn(columnName, _prevProp, currProp) {
|
|
1560
1565
|
if (isAssociationWithFkColumn(currProp)) {
|
|
1561
1566
|
const fkColumn = getAssociationFkColumnName(columnName);
|
|
1562
|
-
|
|
1567
|
+
const idType = currProp.idType ?? "BigInt";
|
|
1568
|
+
let columnMethod = "unsignedBigInteger";
|
|
1569
|
+
if (idType === "Int") columnMethod = "unsignedInteger";
|
|
1570
|
+
else if (idType === "Uuid") columnMethod = "uuid";
|
|
1571
|
+
else if (idType === "String") columnMethod = "string";
|
|
1572
|
+
let code2 = `$table->${columnMethod}('${fkColumn}')`;
|
|
1563
1573
|
if (currProp.nullable) code2 += "->nullable()";
|
|
1564
1574
|
return code2 + "->change();";
|
|
1565
1575
|
}
|
|
@@ -2095,7 +2105,8 @@ function generateEntityBaseModel(schema, schemas, options, stubContent, authStub
|
|
|
2095
2105
|
if (propDef.type === "Association") {
|
|
2096
2106
|
const assoc = propDef;
|
|
2097
2107
|
if (assoc.target) {
|
|
2098
|
-
|
|
2108
|
+
const targetNs = assoc.targetNamespace ?? options.modelNamespace;
|
|
2109
|
+
imports.push(`use ${targetNs}\\${toPascalCase(assoc.target)};`);
|
|
2099
2110
|
}
|
|
2100
2111
|
relations.push(generateRelation(propName, assoc, schema, schemas, options));
|
|
2101
2112
|
if (assoc.relation === "ManyToOne" || assoc.relation === "OneToOne") {
|
|
@@ -3467,15 +3478,16 @@ function generateAssociationFake(propertyName, property, schema, schemas, modelN
|
|
|
3467
3478
|
if (property.type !== "Association") {
|
|
3468
3479
|
return null;
|
|
3469
3480
|
}
|
|
3470
|
-
const
|
|
3471
|
-
|
|
3472
|
-
if (relation !== "ManyToOne" || !target) {
|
|
3481
|
+
const assoc = property;
|
|
3482
|
+
if (assoc.relation !== "ManyToOne" || !assoc.target) {
|
|
3473
3483
|
return null;
|
|
3474
3484
|
}
|
|
3485
|
+
const target = assoc.target;
|
|
3475
3486
|
const foreignKey = `${toSnakeCase(propertyName)}_id`;
|
|
3476
|
-
const isNullable2 =
|
|
3487
|
+
const isNullable2 = assoc.nullable ?? false;
|
|
3477
3488
|
const targetSchema = schemas[target];
|
|
3478
|
-
|
|
3489
|
+
const targetNs = assoc.targetNamespace ?? modelNamespace;
|
|
3490
|
+
if (!targetSchema && !assoc.targetNamespace) {
|
|
3479
3491
|
return null;
|
|
3480
3492
|
}
|
|
3481
3493
|
let fake;
|
|
@@ -3486,7 +3498,7 @@ function generateAssociationFake(propertyName, property, schema, schemas, modelN
|
|
|
3486
3498
|
}
|
|
3487
3499
|
let importStatement;
|
|
3488
3500
|
if (target !== schema.name) {
|
|
3489
|
-
importStatement = `use ${
|
|
3501
|
+
importStatement = `use ${targetNs}\\${target};`;
|
|
3490
3502
|
}
|
|
3491
3503
|
return { fake, import: importStatement };
|
|
3492
3504
|
}
|
|
@@ -5451,4 +5463,4 @@ export {
|
|
|
5451
5463
|
getFactoryPath,
|
|
5452
5464
|
laravelPlugin
|
|
5453
5465
|
};
|
|
5454
|
-
//# sourceMappingURL=chunk-
|
|
5466
|
+
//# sourceMappingURL=chunk-FQYGLKZY.js.map
|