@singi-labs/sifa-sdk 0.11.18 → 0.11.20

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
@@ -1461,6 +1461,13 @@ var SMALL_WORDS = /* @__PURE__ */ new Set([
1461
1461
  "le",
1462
1462
  "y"
1463
1463
  ]);
1464
+ function hasNonAsciiLetter(value) {
1465
+ for (const char of value) {
1466
+ const codePoint = char.codePointAt(0) ?? 0;
1467
+ if (codePoint > 127 && /\p{L}/u.test(char)) return true;
1468
+ }
1469
+ return false;
1470
+ }
1464
1471
  function capitalizeWord(word) {
1465
1472
  return word.replace(
1466
1473
  /^([^\p{L}\p{N}]*)(\p{L})/u,
@@ -1469,7 +1476,7 @@ function capitalizeWord(word) {
1469
1476
  }
1470
1477
  function formatCompanyName(name) {
1471
1478
  const trimmed = name.trim();
1472
- if (!trimmed || trimmed !== trimmed.toLowerCase()) return trimmed;
1479
+ if (!trimmed || hasNonAsciiLetter(trimmed) || trimmed !== trimmed.toLowerCase()) return trimmed;
1473
1480
  let seenWord = false;
1474
1481
  return trimmed.split(/(\s+)/).map((token) => {
1475
1482
  if (token.length === 0 || /^\s+$/.test(token)) return token;
@@ -1480,6 +1487,15 @@ function formatCompanyName(name) {
1480
1487
  }).join("");
1481
1488
  }
1482
1489
 
1490
+ // src/format/normalize-company-key.ts
1491
+ var COMBINING_MARKS = /[\u0300-\u036f]/g;
1492
+ function normalizeCompanyKey(name) {
1493
+ const trimmed = name.trim();
1494
+ if (!trimmed) return "";
1495
+ const caseFolded = trimmed.normalize("NFC").toLowerCase();
1496
+ return caseFolded.normalize("NFD").replace(COMBINING_MARKS, "").normalize("NFC");
1497
+ }
1498
+
1483
1499
  // src/format/format-time.ts
1484
1500
  function formatRelativeTime(dateString) {
1485
1501
  const date = new Date(dateString);
@@ -2504,6 +2520,34 @@ function searchResultDisambiguation(result) {
2504
2520
  function entityResultKey(result) {
2505
2521
  return result.source === "entity" ? `entity:${result.entityId}` : `pdl:${result.pdlId}`;
2506
2522
  }
2523
+
2524
+ // src/logic/entity-ref-anchor.ts
2525
+ var ENTITY_REF_ANCHORS = ["registry", "sifa", "unlinked"];
2526
+ var REGISTRY_HOSTS = /* @__PURE__ */ new Set([
2527
+ "wikidata.org",
2528
+ "www.wikidata.org",
2529
+ "ror.org",
2530
+ "gleif.org",
2531
+ "www.gleif.org"
2532
+ ]);
2533
+ var SIFA_HOST = "sifa.id";
2534
+ function classifyEntityRef(entityRef) {
2535
+ if (!entityRef || !entityRef.trim()) return "unlinked";
2536
+ let url;
2537
+ try {
2538
+ url = new URL(entityRef.trim());
2539
+ } catch {
2540
+ return "unlinked";
2541
+ }
2542
+ if (url.protocol !== "https:" && url.protocol !== "http:") return "unlinked";
2543
+ const host = url.hostname.toLowerCase();
2544
+ if (REGISTRY_HOSTS.has(host)) return "registry";
2545
+ if (host === SIFA_HOST) return "sifa";
2546
+ return "unlinked";
2547
+ }
2548
+ function isLinked(entityRef) {
2549
+ return classifyEntityRef(entityRef) !== "unlinked";
2550
+ }
2507
2551
  function maxGraphemes(max) {
2508
2552
  return (value) => {
2509
2553
  const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
@@ -2851,7 +2895,7 @@ var ProfileVolunteeringRecordSchema = zod.z.object({
2851
2895
  });
2852
2896
 
2853
2897
  // src/index.ts
2854
- var SIFA_SDK_VERSION = "0.11.18";
2898
+ var SIFA_SDK_VERSION = "0.11.20";
2855
2899
 
2856
2900
  exports.ACTIVITY_TIERS = ACTIVITY_TIERS;
2857
2901
  exports.ACTIVITY_VISIBILITY_RULES = ACTIVITY_VISIBILITY_RULES;
@@ -2873,6 +2917,7 @@ exports.COUNTRIES = COUNTRIES;
2873
2917
  exports.DIMENSIONS_MAX_SCORE = DIMENSIONS_MAX_SCORE;
2874
2918
  exports.EMPLOYMENT_TYPE_GROUPS = EMPLOYMENT_TYPE_GROUPS;
2875
2919
  exports.EMPLOYMENT_TYPE_LABELS = EMPLOYMENT_TYPE_LABELS;
2920
+ exports.ENTITY_REF_ANCHORS = ENTITY_REF_ANCHORS;
2876
2921
  exports.EndorsementConfirmationRecordSchema = EndorsementConfirmationRecordSchema;
2877
2922
  exports.EndorsementRecordSchema = EndorsementRecordSchema;
2878
2923
  exports.EntityImportSearchResponseSchema = EntityImportSearchResponseSchema;
@@ -2928,6 +2973,7 @@ exports.atUriSchema = atUriSchema;
2928
2973
  exports.categoryForApp = categoryForApp;
2929
2974
  exports.certDateExtractor = certDateExtractor;
2930
2975
  exports.cidSchema = cidSchema;
2976
+ exports.classifyEntityRef = classifyEntityRef;
2931
2977
  exports.completenessPercent = completenessPercent;
2932
2978
  exports.completenessScore = completenessScore;
2933
2979
  exports.contrastRatio = contrastRatio;
@@ -2981,6 +3027,7 @@ exports.isAppCategory = isAppCategory;
2981
3027
  exports.isCompanyRequired = isCompanyRequired;
2982
3028
  exports.isKnownAppId = isKnownAppId;
2983
3029
  exports.isKnownPlatform = isKnownPlatform;
3030
+ exports.isLinked = isLinked;
2984
3031
  exports.isPseudoEmployer = isPseudoEmployer;
2985
3032
  exports.isValidRgbColor = isValidRgbColor;
2986
3033
  exports.isVisibleActivityItem = isVisibleActivityItem;
@@ -2990,6 +3037,7 @@ exports.limitCombiningMarks = limitCombiningMarks;
2990
3037
  exports.makeGraphFollowRecordSchema = makeGraphFollowRecordSchema;
2991
3038
  exports.maxGraphemes = maxGraphemes;
2992
3039
  exports.meetsContrastAA = meetsContrastAA;
3040
+ exports.normalizeCompanyKey = normalizeCompanyKey;
2993
3041
  exports.normalizeOpenTo = normalizeOpenTo;
2994
3042
  exports.normalizePlatformId = normalizePlatformId;
2995
3043
  exports.normalizePresentationMode = normalizePresentationMode;