@famgia/omnify-laravel 0.0.42 → 0.0.44

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-4FPVRQVO.js";
25
+ } from "./chunk-AF6XW6JU.js";
26
26
  export {
27
27
  formatColumnMethod,
28
28
  formatForeignKey,
package/dist/plugin.cjs CHANGED
@@ -1332,8 +1332,12 @@ function generateEntityBaseModel(schema, schemas, options, stubContent, authStub
1332
1332
  const properties = schema.properties ?? {};
1333
1333
  for (const [propName, propDef] of Object.entries(properties)) {
1334
1334
  const snakeName = toSnakeCase(propName);
1335
- const phpType = getPhpDocType(propDef, schemas);
1336
- docProperties.push(` * @property ${phpType} $${snakeName}`);
1335
+ const typeDef = options.customTypes.get(propDef.type);
1336
+ const isCompoundType = typeDef?.compound && typeDef.expand;
1337
+ if (!isCompoundType) {
1338
+ const phpType = getPhpDocType(propDef, schemas);
1339
+ docProperties.push(` * @property ${phpType} $${snakeName}`);
1340
+ }
1337
1341
  if (propDef.type === "Association") {
1338
1342
  const assoc = propDef;
1339
1343
  if (assoc.target) {
@@ -1364,14 +1368,19 @@ function generateEntityBaseModel(schema, schemas, options, stubContent, authStub
1364
1368
  const propWithOptions = propDef;
1365
1369
  const isFillable = propWithOptions.fillable !== false;
1366
1370
  const isHidden = propWithOptions.hidden === true;
1367
- const typeDef = options.customTypes.get(propDef.type);
1368
- const isCompoundType = typeDef?.compound && typeDef.expand;
1369
- if (isCompoundType && typeDef.expand) {
1371
+ const typeDef2 = options.customTypes.get(propDef.type);
1372
+ const isCompoundType2 = typeDef2?.compound && typeDef2.expand;
1373
+ if (isCompoundType2 && typeDef2.expand) {
1370
1374
  const fieldOverrides = propWithOptions.fields ?? {};
1371
- for (const field of typeDef.expand) {
1375
+ const basePropWithNullable = propDef;
1376
+ for (const field of typeDef2.expand) {
1372
1377
  const suffixSnake = toSnakeCase(field.suffix);
1373
1378
  const fieldName = `${snakeName}_${suffixSnake}`;
1374
1379
  const override = fieldOverrides[field.suffix];
1380
+ const fieldNullable = override?.nullable ?? basePropWithNullable.nullable ?? false;
1381
+ const phpType = field.typescript?.type === "number" ? "int" : "string";
1382
+ const nullSuffix = fieldNullable ? "|null" : "";
1383
+ docProperties.push(` * @property ${phpType}${nullSuffix} $${fieldName}`);
1375
1384
  const fieldFillable = override?.fillable !== void 0 ? override.fillable : isFillable;
1376
1385
  if (fieldFillable) {
1377
1386
  fillable.push(` '${fieldName}',`);
@@ -1393,8 +1402,8 @@ function generateEntityBaseModel(schema, schemas, options, stubContent, authStub
1393
1402
  hidden.push(` '${snakeName}',`);
1394
1403
  }
1395
1404
  }
1396
- if (typeDef?.compound && typeDef.accessors) {
1397
- for (const accessor of typeDef.accessors) {
1405
+ if (typeDef2?.compound && typeDef2.accessors) {
1406
+ for (const accessor of typeDef2.accessors) {
1398
1407
  const accessorName = `${snakeName}_${toSnakeCase(accessor.name)}`;
1399
1408
  appends.push(` '${accessorName}',`);
1400
1409
  const methodName = toPascalCase(accessorName);