@ng-forge/openapi-generator 1.2.0-next.1 → 1.2.0-next.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.
@@ -307,7 +307,7 @@ function mapSchemaToValidators(schema, required) {
307
307
 
308
308
  // packages/openapi-generator/src/utils/naming.ts
309
309
  function toLabel(name) {
310
- return name.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()).trim();
310
+ return name.replace(/(\p{Ll})(\p{Lu})/gu, "$1 $2").replace(/[_-]/g, " ").replace(/(^|\s)(\p{L})/gu, (_, separator, letter) => separator + letter.toUpperCase()).trim();
311
311
  }
312
312
  var KNOWN_ACRONYMS = /* @__PURE__ */ new Set([
313
313
  "id",
@@ -355,14 +355,14 @@ var KNOWN_ACRONYMS = /* @__PURE__ */ new Set([
355
355
  "cd"
356
356
  ]);
357
357
  function toEnumLabel(value) {
358
- if (/^[A-Z][A-Z0-9_-]*$/.test(value)) {
358
+ if (/^\p{Lu}[\p{Lu}\p{N}_-]*$/u.test(value)) {
359
359
  if (value.length <= 3 && !/[_-]/.test(value)) {
360
360
  return value;
361
361
  }
362
362
  value = value.toLowerCase();
363
363
  }
364
364
  const label = toLabel(value);
365
- return label.replace(/\b\w+\b/g, (word) => {
365
+ return label.replace(/[\p{L}\p{N}]+/gu, (word) => {
366
366
  if (KNOWN_ACRONYMS.has(word.toLowerCase())) {
367
367
  return word.toUpperCase();
368
368
  }
@@ -370,14 +370,14 @@ function toEnumLabel(value) {
370
370
  });
371
371
  }
372
372
  function toPascalCase(str) {
373
- return str.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[^a-zA-Z0-9]/g, " ").split(/\s+/).filter(Boolean).map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join("");
373
+ return str.replace(/([\p{Ll}\p{N}])(\p{Lu})/gu, "$1 $2").replace(/[^\p{L}\p{N}]/gu, " ").split(/\s+/).filter(Boolean).map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join("");
374
374
  }
375
375
  function toCamelCase(str) {
376
376
  const pascal = toPascalCase(str);
377
377
  return pascal.charAt(0).toLowerCase() + pascal.slice(1);
378
378
  }
379
379
  function toKebabCase(str) {
380
- return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[^a-zA-Z0-9]/g, "-").replace(/-+/g, "-").toLowerCase().replace(/^-|-$/g, "");
380
+ return str.replace(/(\p{Ll})(\p{Lu})/gu, "$1-$2").replace(/[^\p{L}\p{N}]/gu, "-").replace(/-+/g, "-").toLowerCase().replace(/^-|-$/g, "");
381
381
  }
382
382
  function cleanPathParams(path, prefix) {
383
383
  let result = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-forge/openapi-generator",
3
- "version": "1.2.0-next.1",
3
+ "version": "1.2.0-next.2",
4
4
  "description": "Generate @ng-forge/dynamic-forms configurations from OpenAPI specs",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/index.js CHANGED
@@ -299,7 +299,7 @@ function mapSchemaToValidators(schema, required) {
299
299
 
300
300
  // packages/openapi-generator/src/utils/naming.ts
301
301
  function toLabel(name) {
302
- return name.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()).trim();
302
+ return name.replace(/(\p{Ll})(\p{Lu})/gu, "$1 $2").replace(/[_-]/g, " ").replace(/(^|\s)(\p{L})/gu, (_, separator, letter) => separator + letter.toUpperCase()).trim();
303
303
  }
304
304
  var KNOWN_ACRONYMS = /* @__PURE__ */ new Set([
305
305
  "id",
@@ -347,14 +347,14 @@ var KNOWN_ACRONYMS = /* @__PURE__ */ new Set([
347
347
  "cd"
348
348
  ]);
349
349
  function toEnumLabel(value) {
350
- if (/^[A-Z][A-Z0-9_-]*$/.test(value)) {
350
+ if (/^\p{Lu}[\p{Lu}\p{N}_-]*$/u.test(value)) {
351
351
  if (value.length <= 3 && !/[_-]/.test(value)) {
352
352
  return value;
353
353
  }
354
354
  value = value.toLowerCase();
355
355
  }
356
356
  const label = toLabel(value);
357
- return label.replace(/\b\w+\b/g, (word) => {
357
+ return label.replace(/[\p{L}\p{N}]+/gu, (word) => {
358
358
  if (KNOWN_ACRONYMS.has(word.toLowerCase())) {
359
359
  return word.toUpperCase();
360
360
  }
@@ -362,14 +362,14 @@ function toEnumLabel(value) {
362
362
  });
363
363
  }
364
364
  function toPascalCase(str) {
365
- return str.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[^a-zA-Z0-9]/g, " ").split(/\s+/).filter(Boolean).map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join("");
365
+ return str.replace(/([\p{Ll}\p{N}])(\p{Lu})/gu, "$1 $2").replace(/[^\p{L}\p{N}]/gu, " ").split(/\s+/).filter(Boolean).map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join("");
366
366
  }
367
367
  function toCamelCase(str) {
368
368
  const pascal = toPascalCase(str);
369
369
  return pascal.charAt(0).toLowerCase() + pascal.slice(1);
370
370
  }
371
371
  function toKebabCase(str) {
372
- return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[^a-zA-Z0-9]/g, "-").replace(/-+/g, "-").toLowerCase().replace(/^-|-$/g, "");
372
+ return str.replace(/(\p{Ll})(\p{Lu})/gu, "$1-$2").replace(/[^\p{L}\p{N}]/gu, "-").replace(/-+/g, "-").toLowerCase().replace(/^-|-$/g, "");
373
373
  }
374
374
  function cleanPathParams(path, prefix) {
375
375
  let result = "";
@@ -11,7 +11,9 @@ export declare function toLabel(name: string): string;
11
11
  export declare function toEnumLabel(value: string): string;
12
12
  /**
13
13
  * Convert a string to PascalCase.
14
- * Examples: "create pet" → "CreatePet", "POST:/pets" → "PostPets"
14
+ * Letters outside ASCII are kept — they are valid in TypeScript identifiers, and
15
+ * dropping them would collapse names that differ only by a diacritic.
16
+ * Examples: "create pet" → "CreatePet", "POST:/pets" → "PostPets", "größe" → "Größe"
15
17
  */
16
18
  export declare function toPascalCase(str: string): string;
17
19
  /** Convert a string to camelCase. */
@@ -1 +1 @@
1
- {"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../../../../packages/openapi-generator/src/utils/naming.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM5C;AAiDD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAkBjD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQhD;AAED,qCAAqC;AACrC,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG/C;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO/C;AA0BD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAM3F;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAMzF;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAM1F"}
1
+ {"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../../../../packages/openapi-generator/src/utils/naming.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM5C;AAiDD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAkBjD;AAED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