@famgia/omnify-laravel 0.0.49 → 0.0.51

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
@@ -22,7 +22,7 @@ import {
22
22
  schemaToBlueprint,
23
23
  toColumnName,
24
24
  toTableName
25
- } from "./chunk-RP2B7BTK.js";
25
+ } from "./chunk-FSVH5TYU.js";
26
26
  export {
27
27
  formatColumnMethod,
28
28
  formatForeignKey,
package/dist/plugin.cjs CHANGED
@@ -106,7 +106,7 @@ function propertyToColumnMethod(propertyName, property, options = {}) {
106
106
  }
107
107
  }
108
108
  const baseProp = property;
109
- if (baseProp.primaryKey) {
109
+ if (baseProp.primary) {
110
110
  modifiers.push({ method: "primary" });
111
111
  }
112
112
  if (baseProp.nullable) {
@@ -480,7 +480,7 @@ function schemaToBlueprint(schema, allSchemas, options = {}) {
480
480
  } else if (schema.properties) {
481
481
  const pkColumns = [];
482
482
  for (const [propName, property] of Object.entries(schema.properties)) {
483
- if (property.primaryKey) {
483
+ if (property.primary) {
484
484
  pkColumns.push(toColumnName(propName));
485
485
  }
486
486
  }
@@ -1330,10 +1330,28 @@ function generateEntityBaseModel(schema, schemas, options, stubContent, authStub
1330
1330
  const className = toPascalCase(schema.name);
1331
1331
  const tableName = schema.options?.tableName ?? pluralize(toSnakeCase(schema.name));
1332
1332
  const isAuth = schema.options?.authenticatable ?? false;
1333
- const primaryKey = "id";
1334
- const idType = schema.options?.idType ?? "BigInt";
1335
- const isUuid = idType === "Uuid";
1336
- const isStringKey = idType === "Uuid" || idType === "String";
1333
+ const hasAutoId2 = schema.options?.id !== false;
1334
+ let primaryKey = "id";
1335
+ let isStringKey = false;
1336
+ let isUuid = false;
1337
+ let isNonIncrementing = false;
1338
+ if (hasAutoId2) {
1339
+ const idType = schema.options?.idType ?? "BigInt";
1340
+ isUuid = idType === "Uuid";
1341
+ isStringKey = idType === "Uuid" || idType === "String";
1342
+ isNonIncrementing = isUuid;
1343
+ } else {
1344
+ const properties2 = schema.properties ?? {};
1345
+ for (const [propName, propDef] of Object.entries(properties2)) {
1346
+ if (propDef.primary === true) {
1347
+ primaryKey = toSnakeCase(propName);
1348
+ const propType = propDef.type;
1349
+ isStringKey = propType === "String" || propType === "Text" || propType === "Email";
1350
+ isNonIncrementing = true;
1351
+ break;
1352
+ }
1353
+ }
1354
+ }
1337
1355
  const imports = [];
1338
1356
  const traits = [];
1339
1357
  const fillable = [];
@@ -1454,7 +1472,7 @@ ${docProperties.join("\n")}
1454
1472
  protected $keyType = 'string';
1455
1473
 
1456
1474
  ` : "";
1457
- const incrementing = isUuid ? ` /**
1475
+ const incrementing = isNonIncrementing ? ` /**
1458
1476
  * Indicates if the IDs are auto-incrementing.
1459
1477
  */
1460
1478
  public $incrementing = false;