@ai-matrx/content-ir 0.20.0 → 0.20.1

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
@@ -2409,9 +2409,20 @@ var IDENTIFIER_ACRONYMS = [
2409
2409
  ];
2410
2410
  var IDENTIFIER_ACRONYM_SET = new Set(IDENTIFIER_ACRONYMS.map((a) => a.toLowerCase()));
2411
2411
  function humanizeIdentifier(identifier) {
2412
- return identifier.replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(/[_\-.\s]+/).filter((part) => part.length > 0).map(
2413
- (part) => IDENTIFIER_ACRONYM_SET.has(part.toLowerCase()) ? part.toUpperCase() : part.charAt(0).toUpperCase() + part.slice(1).toLowerCase()
2414
- ).join(" ");
2412
+ const text = (identifier ?? "").trim();
2413
+ if (text === "") return "";
2414
+ if (!text.includes("_") && /\s/.test(text)) {
2415
+ return /^\p{Ll}/u.test(text) ? text.charAt(0).toUpperCase() + text.slice(1) : text;
2416
+ }
2417
+ return text.replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)(?![A-Z]s(?![a-z]))([A-Z][a-z])/g, "$1 $2").split(/[_\-.\s]+/).filter((part) => part.length > 0).map(identifierWord).join(" ");
2418
+ }
2419
+ function identifierWord(part) {
2420
+ const lower = part.toLowerCase();
2421
+ if (IDENTIFIER_ACRONYM_SET.has(lower)) return part.toUpperCase();
2422
+ if (lower.length > 1 && lower.endsWith("s") && IDENTIFIER_ACRONYM_SET.has(lower.slice(0, -1))) {
2423
+ return `${lower.slice(0, -1).toUpperCase()}s`;
2424
+ }
2425
+ return part.charAt(0).toUpperCase() + part.slice(1).toLowerCase();
2415
2426
  }
2416
2427
 
2417
2428
  // core/schema-structure.ts