@singi-labs/sifa-sdk 0.18.11 → 0.18.12

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.
@@ -454,12 +454,16 @@ async function fetchReciprocityCandidate(config, options = {}) {
454
454
 
455
455
  // src/query/fetchers/endorsement-inbox.ts
456
456
  async function fetchPendingEndorsements(config, options = {}) {
457
+ const { cookieHeader, ...rest } = options;
458
+ const headers = { ...rest.headers ?? {} };
459
+ if (cookieHeader) headers.cookie = cookieHeader;
457
460
  try {
458
461
  const data = await apiFetch(config, "/api/endorsements/pending", {
459
462
  cache: "no-store",
460
463
  credentials: "include",
461
464
  timeoutMs: 5e3,
462
- ...options
465
+ ...rest,
466
+ headers
463
467
  });
464
468
  return { endorsements: data?.endorsements ?? [], cursor: data?.cursor };
465
469
  } catch {
@@ -472,12 +476,16 @@ function dismissEndorsement(config, data, options = {}) {
472
476
 
473
477
  // src/query/fetchers/confirmations.ts
474
478
  async function fetchPendingConfirmations(config, options = {}) {
479
+ const { cookieHeader, ...rest } = options;
480
+ const headers = { ...rest.headers ?? {} };
481
+ if (cookieHeader) headers.cookie = cookieHeader;
475
482
  try {
476
483
  const data = await apiFetch(config, "/api/confirmations/pending", {
477
484
  cache: "no-store",
478
485
  credentials: "include",
479
486
  timeoutMs: 5e3,
480
- ...options
487
+ ...rest,
488
+ headers
481
489
  });
482
490
  return { confirmations: data?.confirmations ?? [], cursor: data?.cursor };
483
491
  } catch {
@@ -485,11 +493,14 @@ async function fetchPendingConfirmations(config, options = {}) {
485
493
  }
486
494
  }
487
495
  async function fetchGivenConfirmations(config, options = {}) {
496
+ const { cookieHeader, ...rest } = options;
497
+ const headers = { ...rest.headers ?? {} };
498
+ if (cookieHeader) headers.cookie = cookieHeader;
488
499
  try {
489
500
  const data = await apiFetch(
490
501
  config,
491
502
  "/api/confirmations/mine",
492
- { cache: "no-store", credentials: "include", timeoutMs: 5e3, ...options }
503
+ { cache: "no-store", credentials: "include", timeoutMs: 5e3, ...rest, headers }
493
504
  );
494
505
  return { confirmations: data?.confirmations ?? [] };
495
506
  } catch {
@@ -506,6 +517,90 @@ function revokeConfirmation(config, data, options = {}) {
506
517
  return apiWrite(config, "/api/confirmation/revoke", "POST", { body: data, ...options });
507
518
  }
508
519
 
520
+ // src/query/fetchers/inbox.ts
521
+ function toCount(value) {
522
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.trunc(value) : 0;
523
+ }
524
+ async function fetchInboxCounts(config, options = {}) {
525
+ const { cookieHeader, ...rest } = options;
526
+ const headers = { ...rest.headers ?? {} };
527
+ if (cookieHeader) headers.cookie = cookieHeader;
528
+ try {
529
+ const data = await apiFetch(config, "/api/inbox/counts", {
530
+ cache: "no-store",
531
+ credentials: "include",
532
+ timeoutMs: 5e3,
533
+ ...rest,
534
+ headers
535
+ });
536
+ return {
537
+ tasks: toCount(data?.tasks),
538
+ unreadNotifications: toCount(data?.unreadNotifications)
539
+ };
540
+ } catch {
541
+ return { tasks: 0, unreadNotifications: 0 };
542
+ }
543
+ }
544
+
545
+ // src/query/fetchers/unlinked-positions.ts
546
+ async function fetchUnlinkedPositions(config, options = {}) {
547
+ const { cookieHeader, ...rest } = options;
548
+ const headers = { ...rest.headers ?? {} };
549
+ if (cookieHeader) headers.cookie = cookieHeader;
550
+ try {
551
+ const data = await apiFetch(config, "/api/positions/unlinked", {
552
+ cache: "no-store",
553
+ credentials: "include",
554
+ timeoutMs: 5e3,
555
+ ...rest,
556
+ headers
557
+ });
558
+ return { positions: Array.isArray(data?.positions) ? data.positions : [] };
559
+ } catch {
560
+ return { positions: [] };
561
+ }
562
+ }
563
+
564
+ // src/query/fetchers/profile-completeness.ts
565
+ var PROFILE_COMPLETENESS_SIGNALS = [
566
+ "headline",
567
+ "about",
568
+ "position",
569
+ "education",
570
+ "skill",
571
+ "certification"
572
+ ];
573
+ async function fetchProfileCompleteness(config, options = {}) {
574
+ const { cookieHeader, ...rest } = options;
575
+ const headers = { ...rest.headers ?? {} };
576
+ if (cookieHeader) headers.cookie = cookieHeader;
577
+ const empty = {
578
+ complete: true,
579
+ score: PROFILE_COMPLETENESS_SIGNALS.length,
580
+ total: PROFILE_COMPLETENESS_SIGNALS.length,
581
+ missing: []
582
+ };
583
+ try {
584
+ const data = await apiFetch(config, "/api/profile/completeness", {
585
+ cache: "no-store",
586
+ credentials: "include",
587
+ timeoutMs: 5e3,
588
+ ...rest,
589
+ headers
590
+ });
591
+ if (!data) return empty;
592
+ const missing = Array.isArray(data.missing) ? data.missing : [];
593
+ return {
594
+ complete: data.complete ?? missing.length === 0,
595
+ score: data.score ?? PROFILE_COMPLETENESS_SIGNALS.length - missing.length,
596
+ total: data.total ?? PROFILE_COMPLETENESS_SIGNALS.length,
597
+ missing
598
+ };
599
+ } catch {
600
+ return empty;
601
+ }
602
+ }
603
+
509
604
  // src/query/fetchers/keytrace-claims.ts
510
605
  function hideKeytraceClaim(config, rkey, options = {}) {
511
606
  return apiWrite(
@@ -1607,11 +1702,23 @@ var sifaQueryKeys = {
1607
1702
  byHandle: (handleOrDid) => ["sifa", "profile", handleOrDid],
1608
1703
  atFundLink: (did) => ["sifa", "profile", "at-fund-link", did],
1609
1704
  view: (actor) => ["sifa", "profile", "view", actor],
1610
- externalAccounts: (handleOrDid) => ["sifa", "profile", "external-accounts", handleOrDid]
1705
+ externalAccounts: (handleOrDid) => ["sifa", "profile", "external-accounts", handleOrDid],
1706
+ // Session-scoped: the AppView reads the owner from the session cookie, so
1707
+ // there is only ever one completeness result per client.
1708
+ completeness: () => ["sifa", "profile", "completeness"]
1611
1709
  },
1612
1710
  position: {
1613
1711
  all: () => ["sifa", "position"],
1614
- byOwner: (did) => ["sifa", "position", "by-owner", did]
1712
+ byOwner: (did) => ["sifa", "position", "by-owner", did],
1713
+ // Session-scoped: the AppView reads the owner from the session cookie.
1714
+ unlinked: () => ["sifa", "position", "unlinked"]
1715
+ },
1716
+ // Aggregate inbox counts for the header bell badge (session-scoped). The first
1717
+ // aggregate namespace: it fans in across confirmations, endorsements, drift,
1718
+ // unlinked positions and profile completeness on the server.
1719
+ inbox: {
1720
+ all: () => ["sifa", "inbox"],
1721
+ counts: () => ["sifa", "inbox", "counts"]
1615
1722
  },
1616
1723
  search: {
1617
1724
  all: () => ["sifa", "search"],
@@ -1860,6 +1967,7 @@ function deleteInvestment(config, rkey, options = {}) {
1860
1967
  exports.ApiError = ApiError;
1861
1968
  exports.HIDDEN_ITEM_SOURCES = HIDDEN_ITEM_SOURCES;
1862
1969
  exports.HIDDEN_ITEM_TYPES = HIDDEN_ITEM_TYPES;
1970
+ exports.PROFILE_COMPLETENESS_SIGNALS = PROFILE_COMPLETENESS_SIGNALS;
1863
1971
  exports.QUOTED_POSTS_BATCH_MAX = QUOTED_POSTS_BATCH_MAX;
1864
1972
  exports.addFeatureAllowlist = addFeatureAllowlist;
1865
1973
  exports.addOrgNotificationEmail = addOrgNotificationEmail;
@@ -1914,6 +2022,7 @@ exports.fetchGivenConfirmations = fetchGivenConfirmations;
1914
2022
  exports.fetchHeatmapData = fetchHeatmapData;
1915
2023
  exports.fetchHiddenActivityItems = fetchHiddenActivityItems;
1916
2024
  exports.fetchHiddenApps = fetchHiddenApps;
2025
+ exports.fetchInboxCounts = fetchInboxCounts;
1917
2026
  exports.fetchMyGithubPullRequests = fetchMyGithubPullRequests;
1918
2027
  exports.fetchMyRoadmapVotes = fetchMyRoadmapVotes;
1919
2028
  exports.fetchNetworkMap = fetchNetworkMap;
@@ -1921,6 +2030,7 @@ exports.fetchNetworkStreamCount = fetchNetworkStreamCount;
1921
2030
  exports.fetchPendingConfirmations = fetchPendingConfirmations;
1922
2031
  exports.fetchPendingEndorsements = fetchPendingEndorsements;
1923
2032
  exports.fetchProfile = fetchProfile;
2033
+ exports.fetchProfileCompleteness = fetchProfileCompleteness;
1924
2034
  exports.fetchProfileSummary = fetchProfileSummary;
1925
2035
  exports.fetchReactionStatus = fetchReactionStatus;
1926
2036
  exports.fetchReceivedEndorsements = fetchReceivedEndorsements;
@@ -1937,6 +2047,7 @@ exports.fetchStats = fetchStats;
1937
2047
  exports.fetchSuggestionCount = fetchSuggestionCount;
1938
2048
  exports.fetchSuggestions = fetchSuggestions;
1939
2049
  exports.fetchTalks = fetchTalks;
2050
+ exports.fetchUnlinkedPositions = fetchUnlinkedPositions;
1940
2051
  exports.fetchWipePreview = fetchWipePreview;
1941
2052
  exports.followUser = followUser;
1942
2053
  exports.getAdminReviewQueues = getAdminReviewQueues;