@singi-labs/sifa-sdk 0.18.11 → 0.18.13

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.
Files changed (47) hide show
  1. package/dist/index.cjs +29 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +28 -3
  4. package/dist/index.d.ts +28 -3
  5. package/dist/index.js +28 -2
  6. package/dist/index.js.map +1 -1
  7. package/dist/{network-map-CMod-9od.d.ts → network-map-5WbfyFed.d.ts} +12 -3
  8. package/dist/{network-map-CH37aj_Q.d.cts → network-map-Cwv7SsL0.d.cts} +12 -3
  9. package/dist/{org-3gFPQ_pC.d.cts → org-BHz9ymjp.d.cts} +122 -4
  10. package/dist/{org-CTSJ5zTZ.d.ts → org-Bgz5parA.d.ts} +122 -4
  11. package/dist/{profile-investment-CmiQxk5C.d.cts → profile-investment-CIG7Hy8g.d.cts} +16 -1
  12. package/dist/{profile-investment-CmiQxk5C.d.ts → profile-investment-CIG7Hy8g.d.ts} +16 -1
  13. package/dist/publishing/index.cjs +5 -0
  14. package/dist/publishing/index.cjs.map +1 -1
  15. package/dist/publishing/index.js +5 -0
  16. package/dist/publishing/index.js.map +1 -1
  17. package/dist/query/fetchers/index.cjs +121 -5
  18. package/dist/query/fetchers/index.cjs.map +1 -1
  19. package/dist/query/fetchers/index.d.cts +3 -3
  20. package/dist/query/fetchers/index.d.ts +3 -3
  21. package/dist/query/fetchers/index.js +118 -6
  22. package/dist/query/fetchers/index.js.map +1 -1
  23. package/dist/query/hooks/index.cjs +157 -4
  24. package/dist/query/hooks/index.cjs.map +1 -1
  25. package/dist/query/hooks/index.d.cts +3 -3
  26. package/dist/query/hooks/index.d.ts +3 -3
  27. package/dist/query/hooks/index.js +155 -5
  28. package/dist/query/hooks/index.js.map +1 -1
  29. package/dist/query/index.cjs +161 -5
  30. package/dist/query/index.cjs.map +1 -1
  31. package/dist/query/index.d.cts +5 -5
  32. package/dist/query/index.d.ts +5 -5
  33. package/dist/query/index.js +155 -6
  34. package/dist/query/index.js.map +1 -1
  35. package/dist/schemas/index.cjs +6 -0
  36. package/dist/schemas/index.cjs.map +1 -1
  37. package/dist/schemas/index.d.cts +1 -1
  38. package/dist/schemas/index.d.ts +1 -1
  39. package/dist/schemas/index.js +6 -1
  40. package/dist/schemas/index.js.map +1 -1
  41. package/dist/schemas/write/index.cjs +7 -2
  42. package/dist/schemas/write/index.cjs.map +1 -1
  43. package/dist/schemas/write/index.js +7 -2
  44. package/dist/schemas/write/index.js.map +1 -1
  45. package/dist/{use-org-notification-emails-J29DcsSu.d.ts → use-org-notification-emails-C9CWyhSC.d.ts} +24 -2
  46. package/dist/{use-org-notification-emails-CdRgTAj4.d.cts → use-org-notification-emails-vNekuQKF.d.cts} +24 -2
  47. package/package.json +1 -1
@@ -512,12 +512,16 @@ async function fetchReciprocityCandidate(config, options = {}) {
512
512
 
513
513
  // src/query/fetchers/endorsement-inbox.ts
514
514
  async function fetchPendingEndorsements(config, options = {}) {
515
+ const { cookieHeader, ...rest } = options;
516
+ const headers = { ...rest.headers ?? {} };
517
+ if (cookieHeader) headers.cookie = cookieHeader;
515
518
  try {
516
519
  const data = await apiFetch(config, "/api/endorsements/pending", {
517
520
  cache: "no-store",
518
521
  credentials: "include",
519
522
  timeoutMs: 5e3,
520
- ...options
523
+ ...rest,
524
+ headers
521
525
  });
522
526
  return { endorsements: data?.endorsements ?? [], cursor: data?.cursor };
523
527
  } catch {
@@ -530,12 +534,16 @@ function dismissEndorsement(config, data, options = {}) {
530
534
 
531
535
  // src/query/fetchers/confirmations.ts
532
536
  async function fetchPendingConfirmations(config, options = {}) {
537
+ const { cookieHeader, ...rest } = options;
538
+ const headers = { ...rest.headers ?? {} };
539
+ if (cookieHeader) headers.cookie = cookieHeader;
533
540
  try {
534
541
  const data = await apiFetch(config, "/api/confirmations/pending", {
535
542
  cache: "no-store",
536
543
  credentials: "include",
537
544
  timeoutMs: 5e3,
538
- ...options
545
+ ...rest,
546
+ headers
539
547
  });
540
548
  return { confirmations: data?.confirmations ?? [], cursor: data?.cursor };
541
549
  } catch {
@@ -543,11 +551,14 @@ async function fetchPendingConfirmations(config, options = {}) {
543
551
  }
544
552
  }
545
553
  async function fetchGivenConfirmations(config, options = {}) {
554
+ const { cookieHeader, ...rest } = options;
555
+ const headers = { ...rest.headers ?? {} };
556
+ if (cookieHeader) headers.cookie = cookieHeader;
546
557
  try {
547
558
  const data = await apiFetch(
548
559
  config,
549
560
  "/api/confirmations/mine",
550
- { cache: "no-store", credentials: "include", timeoutMs: 5e3, ...options }
561
+ { cache: "no-store", credentials: "include", timeoutMs: 5e3, ...rest, headers }
551
562
  );
552
563
  return { confirmations: data?.confirmations ?? [] };
553
564
  } catch {
@@ -564,6 +575,90 @@ function revokeConfirmation(config, data, options = {}) {
564
575
  return apiWrite(config, "/api/confirmation/revoke", "POST", { body: data, ...options });
565
576
  }
566
577
 
578
+ // src/query/fetchers/inbox.ts
579
+ function toCount(value) {
580
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.trunc(value) : 0;
581
+ }
582
+ async function fetchInboxCounts(config, options = {}) {
583
+ const { cookieHeader, ...rest } = options;
584
+ const headers = { ...rest.headers ?? {} };
585
+ if (cookieHeader) headers.cookie = cookieHeader;
586
+ try {
587
+ const data = await apiFetch(config, "/api/inbox/counts", {
588
+ cache: "no-store",
589
+ credentials: "include",
590
+ timeoutMs: 5e3,
591
+ ...rest,
592
+ headers
593
+ });
594
+ return {
595
+ tasks: toCount(data?.tasks),
596
+ unreadNotifications: toCount(data?.unreadNotifications)
597
+ };
598
+ } catch {
599
+ return { tasks: 0, unreadNotifications: 0 };
600
+ }
601
+ }
602
+
603
+ // src/query/fetchers/unlinked-positions.ts
604
+ async function fetchUnlinkedPositions(config, options = {}) {
605
+ const { cookieHeader, ...rest } = options;
606
+ const headers = { ...rest.headers ?? {} };
607
+ if (cookieHeader) headers.cookie = cookieHeader;
608
+ try {
609
+ const data = await apiFetch(config, "/api/positions/unlinked", {
610
+ cache: "no-store",
611
+ credentials: "include",
612
+ timeoutMs: 5e3,
613
+ ...rest,
614
+ headers
615
+ });
616
+ return { positions: Array.isArray(data?.positions) ? data.positions : [] };
617
+ } catch {
618
+ return { positions: [] };
619
+ }
620
+ }
621
+
622
+ // src/query/fetchers/profile-completeness.ts
623
+ var PROFILE_COMPLETENESS_SIGNALS = [
624
+ "headline",
625
+ "about",
626
+ "position",
627
+ "education",
628
+ "skill",
629
+ "certification"
630
+ ];
631
+ async function fetchProfileCompleteness(config, options = {}) {
632
+ const { cookieHeader, ...rest } = options;
633
+ const headers = { ...rest.headers ?? {} };
634
+ if (cookieHeader) headers.cookie = cookieHeader;
635
+ const empty = {
636
+ complete: true,
637
+ score: PROFILE_COMPLETENESS_SIGNALS.length,
638
+ total: PROFILE_COMPLETENESS_SIGNALS.length,
639
+ missing: []
640
+ };
641
+ try {
642
+ const data = await apiFetch(config, "/api/profile/completeness", {
643
+ cache: "no-store",
644
+ credentials: "include",
645
+ timeoutMs: 5e3,
646
+ ...rest,
647
+ headers
648
+ });
649
+ if (!data) return empty;
650
+ const missing = Array.isArray(data.missing) ? data.missing : [];
651
+ return {
652
+ complete: data.complete ?? missing.length === 0,
653
+ score: data.score ?? PROFILE_COMPLETENESS_SIGNALS.length - missing.length,
654
+ total: data.total ?? PROFILE_COMPLETENESS_SIGNALS.length,
655
+ missing
656
+ };
657
+ } catch {
658
+ return empty;
659
+ }
660
+ }
661
+
567
662
  // src/query/fetchers/actor.ts
568
663
  async function fetchResolveActor(config, handleOrDid, options = {}) {
569
664
  const q = handleOrDid.trim().replace(/^@/, "");
@@ -1620,11 +1715,23 @@ var sifaQueryKeys = {
1620
1715
  byHandle: (handleOrDid) => ["sifa", "profile", handleOrDid],
1621
1716
  atFundLink: (did) => ["sifa", "profile", "at-fund-link", did],
1622
1717
  view: (actor) => ["sifa", "profile", "view", actor],
1623
- externalAccounts: (handleOrDid) => ["sifa", "profile", "external-accounts", handleOrDid]
1718
+ externalAccounts: (handleOrDid) => ["sifa", "profile", "external-accounts", handleOrDid],
1719
+ // Session-scoped: the AppView reads the owner from the session cookie, so
1720
+ // there is only ever one completeness result per client.
1721
+ completeness: () => ["sifa", "profile", "completeness"]
1624
1722
  },
1625
1723
  position: {
1626
1724
  all: () => ["sifa", "position"],
1627
- byOwner: (did) => ["sifa", "position", "by-owner", did]
1725
+ byOwner: (did) => ["sifa", "position", "by-owner", did],
1726
+ // Session-scoped: the AppView reads the owner from the session cookie.
1727
+ unlinked: () => ["sifa", "position", "unlinked"]
1728
+ },
1729
+ // Aggregate inbox counts for the header bell badge (session-scoped). The first
1730
+ // aggregate namespace: it fans in across confirmations, endorsements, drift,
1731
+ // unlinked positions and profile completeness on the server.
1732
+ inbox: {
1733
+ all: () => ["sifa", "inbox"],
1734
+ counts: () => ["sifa", "inbox", "counts"]
1628
1735
  },
1629
1736
  search: {
1630
1737
  all: () => ["sifa", "search"],
@@ -2404,6 +2511,9 @@ function useConfirmEndorsement(subjectHandleOrDid, options) {
2404
2511
  await queryClient.invalidateQueries({
2405
2512
  queryKey: sifaQueryKeys.endorsement.pending()
2406
2513
  });
2514
+ await queryClient.invalidateQueries({
2515
+ queryKey: sifaQueryKeys.inbox.counts()
2516
+ });
2407
2517
  if (subjectHandleOrDid) {
2408
2518
  await queryClient.invalidateQueries({
2409
2519
  queryKey: sifaQueryKeys.profile.byHandle(subjectHandleOrDid)
@@ -2430,6 +2540,9 @@ function useDismissEndorsement(options) {
2430
2540
  await queryClient.invalidateQueries({
2431
2541
  queryKey: sifaQueryKeys.endorsement.pending()
2432
2542
  });
2543
+ await queryClient.invalidateQueries({
2544
+ queryKey: sifaQueryKeys.inbox.counts()
2545
+ });
2433
2546
  }
2434
2547
  await options?.onSuccess?.(result, variables, onMutateResult, context);
2435
2548
  }
@@ -2467,6 +2580,9 @@ function useCreateConfirmation(claimerHandleOrDid, options) {
2467
2580
  await queryClient.invalidateQueries({
2468
2581
  queryKey: sifaQueryKeys.confirmation.given()
2469
2582
  });
2583
+ await queryClient.invalidateQueries({
2584
+ queryKey: sifaQueryKeys.inbox.counts()
2585
+ });
2470
2586
  if (claimerHandleOrDid) {
2471
2587
  await queryClient.invalidateQueries({
2472
2588
  queryKey: sifaQueryKeys.profile.byHandle(claimerHandleOrDid)
@@ -2490,6 +2606,9 @@ function useDismissConfirmation(options) {
2490
2606
  await queryClient.invalidateQueries({
2491
2607
  queryKey: sifaQueryKeys.confirmation.pending()
2492
2608
  });
2609
+ await queryClient.invalidateQueries({
2610
+ queryKey: sifaQueryKeys.inbox.counts()
2611
+ });
2493
2612
  }
2494
2613
  await options?.onSuccess?.(result, variables, onMutateResult, context);
2495
2614
  }
@@ -2508,6 +2627,12 @@ function useRevokeConfirmation(claimerHandleOrDid, options) {
2508
2627
  await queryClient.invalidateQueries({
2509
2628
  queryKey: sifaQueryKeys.confirmation.pending()
2510
2629
  });
2630
+ await queryClient.invalidateQueries({
2631
+ queryKey: sifaQueryKeys.confirmation.given()
2632
+ });
2633
+ await queryClient.invalidateQueries({
2634
+ queryKey: sifaQueryKeys.inbox.counts()
2635
+ });
2511
2636
  if (claimerHandleOrDid) {
2512
2637
  await queryClient.invalidateQueries({
2513
2638
  queryKey: sifaQueryKeys.profile.byHandle(claimerHandleOrDid)
@@ -2518,6 +2643,30 @@ function useRevokeConfirmation(claimerHandleOrDid, options) {
2518
2643
  }
2519
2644
  });
2520
2645
  }
2646
+ function useInboxCounts(options) {
2647
+ const config = useSifaConfig();
2648
+ return reactQuery.useQuery({
2649
+ queryKey: sifaQueryKeys.inbox.counts(),
2650
+ queryFn: () => fetchInboxCounts(config),
2651
+ ...options
2652
+ });
2653
+ }
2654
+ function useUnlinkedPositions(options) {
2655
+ const config = useSifaConfig();
2656
+ return reactQuery.useQuery({
2657
+ queryKey: sifaQueryKeys.position.unlinked(),
2658
+ queryFn: () => fetchUnlinkedPositions(config),
2659
+ ...options
2660
+ });
2661
+ }
2662
+ function useProfileCompleteness(options) {
2663
+ const config = useSifaConfig();
2664
+ return reactQuery.useQuery({
2665
+ queryKey: sifaQueryKeys.profile.completeness(),
2666
+ queryFn: () => fetchProfileCompleteness(config),
2667
+ ...options
2668
+ });
2669
+ }
2521
2670
  async function invalidateProfile6(queryClient, ownerHandleOrDid) {
2522
2671
  await queryClient.invalidateQueries({
2523
2672
  queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
@@ -3472,6 +3621,7 @@ function useRemoveOrgNotificationEmail(options) {
3472
3621
  exports.ApiError = ApiError;
3473
3622
  exports.HIDDEN_ITEM_SOURCES = HIDDEN_ITEM_SOURCES;
3474
3623
  exports.HIDDEN_ITEM_TYPES = HIDDEN_ITEM_TYPES;
3624
+ exports.PROFILE_COMPLETENESS_SIGNALS = PROFILE_COMPLETENESS_SIGNALS;
3475
3625
  exports.QUOTED_POSTS_BATCH_MAX = QUOTED_POSTS_BATCH_MAX;
3476
3626
  exports.SifaProvider = SifaProvider;
3477
3627
  exports.addFeatureAllowlist = addFeatureAllowlist;
@@ -3527,6 +3677,7 @@ exports.fetchGivenConfirmations = fetchGivenConfirmations;
3527
3677
  exports.fetchHeatmapData = fetchHeatmapData;
3528
3678
  exports.fetchHiddenActivityItems = fetchHiddenActivityItems;
3529
3679
  exports.fetchHiddenApps = fetchHiddenApps;
3680
+ exports.fetchInboxCounts = fetchInboxCounts;
3530
3681
  exports.fetchMyGithubPullRequests = fetchMyGithubPullRequests;
3531
3682
  exports.fetchMyRoadmapVotes = fetchMyRoadmapVotes;
3532
3683
  exports.fetchNetworkMap = fetchNetworkMap;
@@ -3534,6 +3685,7 @@ exports.fetchNetworkStreamCount = fetchNetworkStreamCount;
3534
3685
  exports.fetchPendingConfirmations = fetchPendingConfirmations;
3535
3686
  exports.fetchPendingEndorsements = fetchPendingEndorsements;
3536
3687
  exports.fetchProfile = fetchProfile;
3688
+ exports.fetchProfileCompleteness = fetchProfileCompleteness;
3537
3689
  exports.fetchProfileSummary = fetchProfileSummary;
3538
3690
  exports.fetchReactionStatus = fetchReactionStatus;
3539
3691
  exports.fetchReceivedEndorsements = fetchReceivedEndorsements;
@@ -3551,6 +3703,7 @@ exports.fetchSuggestionCount = fetchSuggestionCount;
3551
3703
  exports.fetchSuggestions = fetchSuggestions;
3552
3704
  exports.fetchTalks = fetchTalks;
3553
3705
  exports.fetchTypeaheadActors = fetchTypeaheadActors;
3706
+ exports.fetchUnlinkedPositions = fetchUnlinkedPositions;
3554
3707
  exports.fetchWipePreview = fetchWipePreview;
3555
3708
  exports.followUser = followUser;
3556
3709
  exports.getAdminReviewQueues = getAdminReviewQueues;
@@ -3678,6 +3831,7 @@ exports.useHideProfileItem = useHideProfileItem;
3678
3831
  exports.useHideSifaPublication = useHideSifaPublication;
3679
3832
  exports.useHideStandardPublication = useHideStandardPublication;
3680
3833
  exports.useImportSearchEntities = useImportSearchEntities;
3834
+ exports.useInboxCounts = useInboxCounts;
3681
3835
  exports.useLinkSkillToPosition = useLinkSkillToPosition;
3682
3836
  exports.useMintEntityDomain = useMintEntityDomain;
3683
3837
  exports.useMutuals = useMutuals;
@@ -3691,6 +3845,7 @@ exports.useOrgProfile = useOrgProfile;
3691
3845
  exports.usePendingConfirmations = usePendingConfirmations;
3692
3846
  exports.usePendingEndorsements = usePendingEndorsements;
3693
3847
  exports.useProfile = useProfile;
3848
+ exports.useProfileCompleteness = useProfileCompleteness;
3694
3849
  exports.useReactionStatus = useReactionStatus;
3695
3850
  exports.useReceivedEndorsements = useReceivedEndorsements;
3696
3851
  exports.useReciprocityCandidate = useReciprocityCandidate;
@@ -3724,6 +3879,7 @@ exports.useUnhideProfileItem = useUnhideProfileItem;
3724
3879
  exports.useUnhideSifaPublication = useUnhideSifaPublication;
3725
3880
  exports.useUnhideStandardPublication = useUnhideStandardPublication;
3726
3881
  exports.useUnlinkSkillFromPosition = useUnlinkSkillFromPosition;
3882
+ exports.useUnlinkedPositions = useUnlinkedPositions;
3727
3883
  exports.useUnrevealMarqueDomain = useUnrevealMarqueDomain;
3728
3884
  exports.useUnsetExternalAccountPrimary = useUnsetExternalAccountPrimary;
3729
3885
  exports.useUnsetPositionPrimary = useUnsetPositionPrimary;