@famgia/omnify-laravel 2.0.0 → 2.0.2

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.
@@ -7,6 +7,17 @@ import { resolveLocalizedString } from "@famgia/omnify-types";
7
7
 
8
8
  // src/utils.ts
9
9
  import pluralizeLib from "pluralize";
10
+ function getEnumStringValues(enumArray) {
11
+ return enumArray.map((item) => {
12
+ if (typeof item === "string") {
13
+ return item;
14
+ }
15
+ if (typeof item === "object" && item !== null && "value" in item) {
16
+ return item.value;
17
+ }
18
+ return String(item);
19
+ });
20
+ }
10
21
  function toSnakeCase(str) {
11
22
  return str.replace(/([A-Z])/g, "_$1").replace(/^_/, "").toLowerCase();
12
23
  }
@@ -99,7 +110,8 @@ function propertyToColumnMethod(propertyName, property, options = {}) {
99
110
  if (property.type === "Enum") {
100
111
  const enumProp = property;
101
112
  if (enumProp.enum && enumProp.enum.length > 0) {
102
- args.push(enumProp.enum);
113
+ const enumValues = getEnumStringValues(enumProp.enum);
114
+ args.push(enumValues);
103
115
  }
104
116
  }
105
117
  const baseProp = property;
@@ -3444,7 +3456,8 @@ function formatRequestOpenApiProperty(prop, indent) {
3444
3456
  parts.push(`nullable: true`);
3445
3457
  }
3446
3458
  if (prop.enum) {
3447
- const enumStr = prop.enum.map((v) => `'${v}'`).join(", ");
3459
+ const enumValues = getEnumStringValues(prop.enum);
3460
+ const enumStr = enumValues.map((v) => `'${v}'`).join(", ");
3448
3461
  parts.push(`enum: [${enumStr}]`);
3449
3462
  }
3450
3463
  if (prop.example !== void 0) {
@@ -3549,7 +3562,8 @@ function generateStoreRules(propName, propDef, schema, schemas, options) {
3549
3562
  case "EnumRef":
3550
3563
  rules.push("'string'");
3551
3564
  if (prop.enum && Array.isArray(prop.enum)) {
3552
- const values = prop.enum.map((v) => `'${v}'`).join(", ");
3565
+ const enumValues = getEnumStringValues(prop.enum);
3566
+ const values = enumValues.map((v) => `'${v}'`).join(", ");
3553
3567
  rules.push(`Rule::in([${values}])`);
3554
3568
  }
3555
3569
  break;
@@ -3658,7 +3672,8 @@ function generateUpdateRules(propName, propDef, schema, schemas, options) {
3658
3672
  case "EnumRef":
3659
3673
  rules.push("'string'");
3660
3674
  if (prop.enum && Array.isArray(prop.enum)) {
3661
- const values = prop.enum.map((v) => `'${v}'`).join(", ");
3675
+ const enumValues = getEnumStringValues(prop.enum);
3676
+ const values = enumValues.map((v) => `'${v}'`).join(", ");
3662
3677
  rules.push(`Rule::in([${values}])`);
3663
3678
  }
3664
3679
  break;
@@ -5369,4 +5384,4 @@ export {
5369
5384
  shouldGenerateAIGuides,
5370
5385
  laravelPlugin
5371
5386
  };
5372
- //# sourceMappingURL=chunk-TSGLY4IZ.js.map
5387
+ //# sourceMappingURL=chunk-O7CQJR4A.js.map