@singi-labs/sifa-sdk 0.11.26 → 0.11.27

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.cjs CHANGED
@@ -1538,6 +1538,82 @@ function formatCompanyName(name) {
1538
1538
  }).join("");
1539
1539
  }
1540
1540
 
1541
+ // src/format/normalize-legal-form.ts
1542
+ var CANONICAL_LEGAL_FORMS = {
1543
+ llc: "LLC",
1544
+ inc: "Inc",
1545
+ ltd: "Ltd",
1546
+ ltda: "Ltda",
1547
+ corp: "Corp",
1548
+ co: "Co",
1549
+ plc: "PLC",
1550
+ llp: "LLP",
1551
+ lp: "LP",
1552
+ gmbh: "GmbH",
1553
+ ag: "AG",
1554
+ ab: "AB",
1555
+ as: "AS",
1556
+ aps: "ApS",
1557
+ oy: "Oy",
1558
+ oyj: "Oyj",
1559
+ nv: "NV",
1560
+ bv: "BV",
1561
+ sa: "SA",
1562
+ sas: "SAS",
1563
+ sarl: "SARL",
1564
+ kk: "KK",
1565
+ sl: "SL",
1566
+ pty: "Pty"
1567
+ };
1568
+ var AMBIGUOUS_WHEN_LEADING = /* @__PURE__ */ new Set(["as"]);
1569
+ function recase(token, canonical) {
1570
+ let li = 0;
1571
+ let out = "";
1572
+ for (const ch of token) {
1573
+ if (/[A-Za-z]/.test(ch)) {
1574
+ out += canonical.charAt(li);
1575
+ li += 1;
1576
+ } else {
1577
+ out += ch;
1578
+ }
1579
+ }
1580
+ return out;
1581
+ }
1582
+ function normalizeToken(token, isLeading) {
1583
+ const letters = token.replace(/\./g, "");
1584
+ if (!/^[A-Za-z]+$/.test(letters)) return token;
1585
+ const key = letters.toLowerCase();
1586
+ const canonical = CANONICAL_LEGAL_FORMS[key];
1587
+ if (!canonical) return token;
1588
+ if (isLeading && AMBIGUOUS_WHEN_LEADING.has(key)) return token;
1589
+ return recase(token, canonical);
1590
+ }
1591
+ function normalizeLegalForm(name) {
1592
+ if (!name || hasNonAsciiLetter(name)) return name;
1593
+ const parts = name.split(/(\s+)/);
1594
+ const wordIndices = [];
1595
+ for (let i = 0; i < parts.length; i += 1) {
1596
+ const part = parts[i];
1597
+ if (part !== void 0 && part.length > 0 && !/^\s+$/.test(part)) wordIndices.push(i);
1598
+ }
1599
+ if (wordIndices.length === 0) return name;
1600
+ const firstIdx = wordIndices[0];
1601
+ const lastIdx = wordIndices[wordIndices.length - 1];
1602
+ if (firstIdx === void 0 || lastIdx === void 0) return name;
1603
+ const candidateIndices = firstIdx === lastIdx ? [firstIdx] : [firstIdx, lastIdx];
1604
+ let changed = false;
1605
+ for (const idx of candidateIndices) {
1606
+ const original = parts[idx];
1607
+ if (original === void 0) continue;
1608
+ const rewritten = normalizeToken(original, idx === firstIdx);
1609
+ if (rewritten !== original) {
1610
+ parts[idx] = rewritten;
1611
+ changed = true;
1612
+ }
1613
+ }
1614
+ return changed ? parts.join("") : name;
1615
+ }
1616
+
1541
1617
  // src/format/normalize-company-key.ts
1542
1618
  var COMBINING_MARKS = /[\u0300-\u036f]/g;
1543
1619
  function normalizeCompanyKey(name) {
@@ -3039,7 +3115,7 @@ var ProfileVolunteeringRecordSchema = zod.z.object({
3039
3115
  });
3040
3116
 
3041
3117
  // src/index.ts
3042
- var SIFA_SDK_VERSION = "0.11.26";
3118
+ var SIFA_SDK_VERSION = "0.11.27";
3043
3119
 
3044
3120
  exports.ACTIVITY_TIERS = ACTIVITY_TIERS;
3045
3121
  exports.ACTIVITY_VISIBILITY_RULES = ACTIVITY_VISIBILITY_RULES;
@@ -3197,6 +3273,7 @@ exports.makeGraphFollowRecordSchema = makeGraphFollowRecordSchema;
3197
3273
  exports.maxGraphemes = maxGraphemes;
3198
3274
  exports.meetsContrastAA = meetsContrastAA;
3199
3275
  exports.normalizeCompanyKey = normalizeCompanyKey;
3276
+ exports.normalizeLegalForm = normalizeLegalForm;
3200
3277
  exports.normalizeOpenTo = normalizeOpenTo;
3201
3278
  exports.normalizePlatformId = normalizePlatformId;
3202
3279
  exports.normalizePresentationMode = normalizePresentationMode;