@singi-labs/sifa-sdk 0.12.48 → 0.12.50

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.
@@ -479,6 +479,18 @@ async function fetchPendingConfirmations(config, options = {}) {
479
479
  return { confirmations: [] };
480
480
  }
481
481
  }
482
+ async function fetchGivenConfirmations(config, options = {}) {
483
+ try {
484
+ const data = await apiFetch(
485
+ config,
486
+ "/api/confirmations/mine",
487
+ { cache: "no-store", credentials: "include", timeoutMs: 5e3, ...options }
488
+ );
489
+ return { confirmations: data?.confirmations ?? [] };
490
+ } catch {
491
+ return { confirmations: [] };
492
+ }
493
+ }
482
494
  function createConfirmation(config, data, options = {}) {
483
495
  return apiWriteCreate(config, "/api/confirmation", data, options);
484
496
  }
@@ -1035,6 +1047,30 @@ function removeFeatureAllowlist(config, flag, did, opts = {}) {
1035
1047
  );
1036
1048
  }
1037
1049
 
1050
+ // src/query/fetchers/admin-review-queues.ts
1051
+ async function getAdminReviewQueues(config, opts = {}) {
1052
+ const headers = { ...opts.headers ?? {} };
1053
+ if (opts.cookieHeader) headers.cookie = opts.cookieHeader;
1054
+ const res = await apiFetch(config, "/api/admin/stats/review-queues", {
1055
+ credentials: "include",
1056
+ cache: "no-store",
1057
+ ...opts,
1058
+ headers
1059
+ });
1060
+ const ideas = res.ideas ?? 0;
1061
+ const nameCorrections = res.nameCorrections ?? 0;
1062
+ const pendingCompanies = res.pendingCompanies ?? 0;
1063
+ return {
1064
+ ideas,
1065
+ nameCorrections,
1066
+ pendingCompanies,
1067
+ // Derived rather than trusted so an API that predates the field still
1068
+ // yields a usable pill count.
1069
+ total: res.total ?? ideas + nameCorrections + pendingCompanies,
1070
+ generatedAt: res.generatedAt ?? ""
1071
+ };
1072
+ }
1073
+
1038
1074
  // src/query/fetchers/activity.ts
1039
1075
  async function fetchHeatmapData(config, handleOrDid, days, options = {}) {
1040
1076
  const path = `/api/activity/${encodeIdentifier(handleOrDid)}/heatmap?days=${days}`;
@@ -1441,7 +1477,8 @@ var sifaQueryKeys = {
1441
1477
  },
1442
1478
  admin: {
1443
1479
  all: () => ["sifa", "admin"],
1444
- featureAllowlist: (flag) => ["sifa", "admin", "feature-allowlist", flag]
1480
+ featureAllowlist: (flag) => ["sifa", "admin", "feature-allowlist", flag],
1481
+ reviewQueues: () => ["sifa", "admin", "review-queues"]
1445
1482
  },
1446
1483
  stats: {
1447
1484
  all: () => ["sifa", "stats"],
@@ -1474,7 +1511,9 @@ var sifaQueryKeys = {
1474
1511
  // Scoped to the session for the same reason as the endorsement inbox: the
1475
1512
  // AppView reads the subject from the session cookie, so there is only ever
1476
1513
  // one inbox per client.
1477
- pending: () => ["sifa", "confirmation", "pending"]
1514
+ pending: () => ["sifa", "confirmation", "pending"],
1515
+ /** Confirmations this session has given, for the withdraw surface. */
1516
+ given: () => ["sifa", "confirmation", "given"]
1478
1517
  },
1479
1518
  stream: {
1480
1519
  all: () => ["sifa", "stream"],
@@ -2092,6 +2131,14 @@ function usePendingConfirmations(options) {
2092
2131
  ...options
2093
2132
  });
2094
2133
  }
2134
+ function useGivenConfirmations(options) {
2135
+ const config = useSifaConfig();
2136
+ return reactQuery.useQuery({
2137
+ queryKey: sifaQueryKeys.confirmation.given(),
2138
+ queryFn: () => fetchGivenConfirmations(config),
2139
+ ...options
2140
+ });
2141
+ }
2095
2142
  function useCreateConfirmation(claimerHandleOrDid, options) {
2096
2143
  const config = useSifaConfig();
2097
2144
  const queryClient = reactQuery.useQueryClient();
@@ -2102,6 +2149,9 @@ function useCreateConfirmation(claimerHandleOrDid, options) {
2102
2149
  await queryClient.invalidateQueries({
2103
2150
  queryKey: sifaQueryKeys.confirmation.pending()
2104
2151
  });
2152
+ await queryClient.invalidateQueries({
2153
+ queryKey: sifaQueryKeys.confirmation.given()
2154
+ });
2105
2155
  if (claimerHandleOrDid) {
2106
2156
  await queryClient.invalidateQueries({
2107
2157
  queryKey: sifaQueryKeys.profile.byHandle(claimerHandleOrDid)
@@ -2630,6 +2680,16 @@ function useRemoveFeatureAllowlist(flag, options) {
2630
2680
  }
2631
2681
  );
2632
2682
  }
2683
+ var REVIEW_QUEUES_STALE_TIME_MS = 6e4;
2684
+ function useAdminReviewQueues(options) {
2685
+ const config = useSifaConfig();
2686
+ return reactQuery.useQuery({
2687
+ queryKey: sifaQueryKeys.admin.reviewQueues(),
2688
+ queryFn: () => getAdminReviewQueues(config),
2689
+ staleTime: REVIEW_QUEUES_STALE_TIME_MS,
2690
+ ...options
2691
+ });
2692
+ }
2633
2693
  function useHeatmapData(handleOrDid, days, options) {
2634
2694
  const config = useSifaConfig();
2635
2695
  return reactQuery.useQuery({
@@ -3051,6 +3111,7 @@ exports.fetchExternalAccounts = fetchExternalAccounts;
3051
3111
  exports.fetchFeaturedProfile = fetchFeaturedProfile;
3052
3112
  exports.fetchFollowing = fetchFollowing;
3053
3113
  exports.fetchGetProfileView = fetchGetProfileView;
3114
+ exports.fetchGivenConfirmations = fetchGivenConfirmations;
3054
3115
  exports.fetchHeatmapData = fetchHeatmapData;
3055
3116
  exports.fetchHiddenApps = fetchHiddenApps;
3056
3117
  exports.fetchMyGithubPullRequests = fetchMyGithubPullRequests;
@@ -3073,6 +3134,7 @@ exports.fetchSuggestionCount = fetchSuggestionCount;
3073
3134
  exports.fetchSuggestions = fetchSuggestions;
3074
3135
  exports.fetchWipePreview = fetchWipePreview;
3075
3136
  exports.followUser = followUser;
3137
+ exports.getAdminReviewQueues = getAdminReviewQueues;
3076
3138
  exports.getBlueskySuggestions = getBlueskySuggestions;
3077
3139
  exports.getFollowers = getFollowers;
3078
3140
  exports.getFollowing = getFollowing;
@@ -3133,6 +3195,7 @@ exports.useActivityFeed = useActivityFeed;
3133
3195
  exports.useActivityTeaser = useActivityTeaser;
3134
3196
  exports.useAddFeatureAllowlist = useAddFeatureAllowlist;
3135
3197
  exports.useAddOrgNotificationEmail = useAddOrgNotificationEmail;
3198
+ exports.useAdminReviewQueues = useAdminReviewQueues;
3136
3199
  exports.useAppAccountCheck = useAppAccountCheck;
3137
3200
  exports.useAppsRegistry = useAppsRegistry;
3138
3201
  exports.useAtFundLink = useAtFundLink;
@@ -3177,6 +3240,7 @@ exports.useFollowing = useFollowing;
3177
3240
  exports.useFollowingFeed = useFollowingFeed;
3178
3241
  exports.useFollowingList = useFollowingList;
3179
3242
  exports.useGetProfileView = useGetProfileView;
3243
+ exports.useGivenConfirmations = useGivenConfirmations;
3180
3244
  exports.useHeatmapData = useHeatmapData;
3181
3245
  exports.useHiddenApps = useHiddenApps;
3182
3246
  exports.useHideKeytraceClaim = useHideKeytraceClaim;