@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/{chunk-4FPVRQVO.js → chunk-AF6XW6JU.js} +18 -9
- package/dist/chunk-AF6XW6JU.js.map +1 -0
- package/dist/index.cjs +17 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin.cjs +17 -8
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-4FPVRQVO.js.map +0 -1
package/dist/index.js
CHANGED
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
|
|
1336
|
-
|
|
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
|
|
1368
|
-
const
|
|
1369
|
-
if (
|
|
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
|
-
|
|
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 (
|
|
1397
|
-
for (const accessor of
|
|
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);
|