@singi-labs/sifa-sdk 0.19.96 → 0.19.98

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 (44) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +1 -1
  3. package/dist/jev/index.cjs +20 -0
  4. package/dist/jev/index.cjs.map +1 -1
  5. package/dist/jev/index.d.cts +29 -1
  6. package/dist/jev/index.d.ts +29 -1
  7. package/dist/jev/index.js +20 -0
  8. package/dist/jev/index.js.map +1 -1
  9. package/dist/jev/issue.cjs.map +1 -1
  10. package/dist/query/fetchers/admin-review-queues.js +3 -1
  11. package/dist/query/fetchers/admin-review-queues.js.map +1 -1
  12. package/dist/query/fetchers/index.cjs +25 -2
  13. package/dist/query/fetchers/index.cjs.map +1 -1
  14. package/dist/query/fetchers/index.d.cts +1 -1
  15. package/dist/query/fetchers/index.d.ts +1 -1
  16. package/dist/query/fetchers/index.js +4 -0
  17. package/dist/query/fetchers/index.js.map +1 -1
  18. package/dist/query/fetchers/profile-completeness.js +21 -2
  19. package/dist/query/fetchers/profile-completeness.js.map +1 -1
  20. package/dist/query/fetchers/profile-emails.js +66 -0
  21. package/dist/query/fetchers/profile-emails.js.map +1 -0
  22. package/dist/query/hooks/index.cjs +164 -2
  23. package/dist/query/hooks/index.cjs.map +1 -1
  24. package/dist/query/hooks/index.d.cts +2 -2
  25. package/dist/query/hooks/index.d.ts +2 -2
  26. package/dist/query/hooks/index.js +17 -1
  27. package/dist/query/hooks/index.js.map +1 -1
  28. package/dist/query/hooks/use-profile-completeness.js +43 -1
  29. package/dist/query/hooks/use-profile-completeness.js.map +1 -1
  30. package/dist/query/hooks/use-profile-emails.js +73 -0
  31. package/dist/query/hooks/use-profile-emails.js.map +1 -0
  32. package/dist/query/index.cjs +169 -2
  33. package/dist/query/index.cjs.map +1 -1
  34. package/dist/query/index.d.cts +3 -3
  35. package/dist/query/index.d.ts +3 -3
  36. package/dist/query/index.js +33 -1
  37. package/dist/query/index.js.map +1 -1
  38. package/dist/query/keys.js +5 -0
  39. package/dist/query/keys.js.map +1 -1
  40. package/dist/{use-user-settings-CFhaGcAq.d.ts → use-user-settings-CrzlFn2d.d.ts} +100 -2
  41. package/dist/{use-user-settings-CBH1CeDP.d.cts → use-user-settings-DppxALpF.d.cts} +100 -2
  42. package/dist/{user-settings-D1zKOWa2.d.ts → user-settings-Bgm2xbpb.d.ts} +25 -1
  43. package/dist/{user-settings-ChPm0BFN.d.cts → user-settings-C-eXWC6X.d.cts} +25 -1
  44. package/package.json +1 -1
@@ -685,6 +685,57 @@ async function fetchVerificationLog(config, did, positionRkey, options = {}) {
685
685
  return { events: [] };
686
686
  }
687
687
  }
688
+ var ProfileEmailSchema = zod.z.object({
689
+ id: zod.z.number(),
690
+ email: zod.z.string(),
691
+ emailDomain: zod.z.string(),
692
+ status: zod.z.enum(["verified", "pending", "expired"]),
693
+ verifiedAt: zod.z.string().nullable(),
694
+ verificationSentAt: zod.z.string().nullable(),
695
+ createdAt: zod.z.string()
696
+ }).passthrough();
697
+ var ProfileEmailsSchema = zod.z.object({
698
+ emails: zod.z.array(ProfileEmailSchema).default([]),
699
+ /** False while Sifa does not send email; links are not sent then. */
700
+ sending: zod.z.boolean().default(false)
701
+ });
702
+ async function fetchProfileEmails(config, options = {}) {
703
+ const { cookieHeader, ...rest } = options;
704
+ const headers = { ...rest.headers ?? {} };
705
+ if (cookieHeader) headers.cookie = cookieHeader;
706
+ try {
707
+ const data = await apiFetch(config, "/api/profile-emails", {
708
+ cache: "no-store",
709
+ credentials: "include",
710
+ timeoutMs: 5e3,
711
+ ...rest,
712
+ headers
713
+ });
714
+ const parsed = ProfileEmailsSchema.safeParse(data);
715
+ return parsed.success ? parsed.data : { emails: [], sending: false };
716
+ } catch {
717
+ return { emails: [], sending: false };
718
+ }
719
+ }
720
+ function addProfileEmail(config, email, options = {}) {
721
+ return apiWriteCreate(
722
+ config,
723
+ "/api/profile-emails",
724
+ { email },
725
+ options
726
+ );
727
+ }
728
+ function resendProfileEmailVerification(config, id, options = {}) {
729
+ return apiWrite(
730
+ config,
731
+ `/api/profile-emails/${id}/resend`,
732
+ "POST",
733
+ options
734
+ );
735
+ }
736
+ function removeProfileEmail(config, id, options = {}) {
737
+ return apiWrite(config, `/api/profile-emails/${id}`, "DELETE", options);
738
+ }
688
739
  function createOrgAttestation(config, input, options = {}) {
689
740
  return apiWriteCreate(
690
741
  config,
@@ -843,6 +894,9 @@ var PROFILE_COMPLETENESS_SIGNALS = [
843
894
  "skill",
844
895
  "certification"
845
896
  ];
897
+ function isProfileCompletenessSignal(value) {
898
+ return PROFILE_COMPLETENESS_SIGNALS.some((signal) => signal === value);
899
+ }
846
900
  async function fetchProfileCompleteness(config, options = {}) {
847
901
  const { cookieHeader, ...rest } = options;
848
902
  const headers = { ...rest.headers ?? {} };
@@ -863,16 +917,27 @@ async function fetchProfileCompleteness(config, options = {}) {
863
917
  });
864
918
  if (!data) return empty;
865
919
  const missing = Array.isArray(data.missing) ? data.missing : [];
920
+ const dismissed = Array.isArray(data.dismissed) ? data.dismissed.filter(isProfileCompletenessSignal) : void 0;
866
921
  return {
867
922
  complete: data.complete ?? missing.length === 0,
868
923
  score: data.score ?? PROFILE_COMPLETENESS_SIGNALS.length - missing.length,
869
924
  total: data.total ?? PROFILE_COMPLETENESS_SIGNALS.length,
870
- missing
925
+ missing,
926
+ ...dismissed ? { dismissed } : {}
871
927
  };
872
928
  } catch {
873
929
  return empty;
874
930
  }
875
931
  }
932
+ function dismissCompletenessSignal(config, data, options = {}) {
933
+ return apiWrite(config, "/api/profile/completeness/dismiss", "POST", { body: data, ...options });
934
+ }
935
+ function clearCompletenessDismissals(config, options = {}) {
936
+ return apiWrite(config, "/api/profile/completeness/dismissals/clear", "POST", {
937
+ body: {},
938
+ ...options
939
+ });
940
+ }
876
941
 
877
942
  // src/query/fetchers/actor.ts
878
943
  async function fetchResolveActor(config, handleOrDid, options = {}) {
@@ -1605,14 +1670,16 @@ async function getAdminReviewQueues(config, opts = {}) {
1605
1670
  const nameCorrections = res.nameCorrections ?? 0;
1606
1671
  const pendingCompanies = res.pendingCompanies ?? 0;
1607
1672
  const duplicateOrgs = res.duplicateOrgs ?? 0;
1673
+ const inferredFactReports = res.inferredFactReports ?? 0;
1608
1674
  return {
1609
1675
  ideas,
1610
1676
  nameCorrections,
1611
1677
  pendingCompanies,
1612
1678
  duplicateOrgs,
1679
+ inferredFactReports,
1613
1680
  // Derived rather than trusted so an API that predates the field still
1614
1681
  // yields a usable pill count.
1615
- total: res.total ?? ideas + nameCorrections + pendingCompanies + duplicateOrgs,
1682
+ total: res.total ?? ideas + nameCorrections + pendingCompanies + duplicateOrgs + inferredFactReports,
1616
1683
  generatedAt: res.generatedAt ?? ""
1617
1684
  };
1618
1685
  }
@@ -2179,6 +2246,11 @@ var sifaQueryKeys = {
2179
2246
  /** Pending confirmation requests addressed to the signed-in organization. */
2180
2247
  attestationRequests: () => ["sifa", "org", "attestation-requests"]
2181
2248
  },
2249
+ profileEmails: {
2250
+ all: () => ["sifa", "profile-emails"],
2251
+ /** The signed-in account's email addresses (#158). */
2252
+ list: () => ["sifa", "profile-emails", "list"]
2253
+ },
2182
2254
  verification: {
2183
2255
  all: () => ["sifa", "verification"],
2184
2256
  /** The append-only verification log of one position. */
@@ -3069,6 +3141,55 @@ function useVerificationLog(did, positionRkey, options) {
3069
3141
  ...options
3070
3142
  });
3071
3143
  }
3144
+ function useProfileEmails(options) {
3145
+ const config = useSifaConfig();
3146
+ return reactQuery.useQuery({
3147
+ queryKey: sifaQueryKeys.profileEmails.list(),
3148
+ queryFn: () => fetchProfileEmails(config),
3149
+ ...options
3150
+ });
3151
+ }
3152
+ function useInvalidate() {
3153
+ const queryClient = reactQuery.useQueryClient();
3154
+ return () => queryClient.invalidateQueries({ queryKey: sifaQueryKeys.profileEmails.all() });
3155
+ }
3156
+ function useAddProfileEmail(options) {
3157
+ const config = useSifaConfig();
3158
+ const invalidate = useInvalidate();
3159
+ return reactQuery.useMutation({
3160
+ // Spread first so a consumer handler cannot drop the invalidation.
3161
+ ...options,
3162
+ mutationFn: (email) => addProfileEmail(config, email),
3163
+ onSuccess: async (result, variables, onMutateResult, context) => {
3164
+ if (result.success) await invalidate();
3165
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
3166
+ }
3167
+ });
3168
+ }
3169
+ function useResendProfileEmailVerification(options) {
3170
+ const config = useSifaConfig();
3171
+ const invalidate = useInvalidate();
3172
+ return reactQuery.useMutation({
3173
+ ...options,
3174
+ mutationFn: (id) => resendProfileEmailVerification(config, id),
3175
+ onSuccess: async (result, variables, onMutateResult, context) => {
3176
+ if (result.success) await invalidate();
3177
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
3178
+ }
3179
+ });
3180
+ }
3181
+ function useRemoveProfileEmail(options) {
3182
+ const config = useSifaConfig();
3183
+ const invalidate = useInvalidate();
3184
+ return reactQuery.useMutation({
3185
+ ...options,
3186
+ mutationFn: (id) => removeProfileEmail(config, id),
3187
+ onSuccess: async (result, variables, onMutateResult, context) => {
3188
+ if (result.success) await invalidate();
3189
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
3190
+ }
3191
+ });
3192
+ }
3072
3193
  function useOrgAttestations(options) {
3073
3194
  const config = useSifaConfig();
3074
3195
  return reactQuery.useQuery({
@@ -3180,6 +3301,39 @@ function useProfileCompleteness(options) {
3180
3301
  ...options
3181
3302
  });
3182
3303
  }
3304
+ function useDismissCompletenessSignal(options) {
3305
+ const config = useSifaConfig();
3306
+ const queryClient = reactQuery.useQueryClient();
3307
+ return reactQuery.useMutation({
3308
+ // Spread first: a consumer-supplied handler would otherwise replace the
3309
+ // one below and silently drop cache invalidation (#453).
3310
+ ...options,
3311
+ mutationFn: (data) => dismissCompletenessSignal(config, data),
3312
+ onSuccess: async (result, variables, onMutateResult, context) => {
3313
+ if (result.success) {
3314
+ await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.profile.completeness() });
3315
+ await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.inbox.counts() });
3316
+ }
3317
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
3318
+ }
3319
+ });
3320
+ }
3321
+ function useClearCompletenessDismissals(options) {
3322
+ const config = useSifaConfig();
3323
+ const queryClient = reactQuery.useQueryClient();
3324
+ return reactQuery.useMutation({
3325
+ // Spread first, as above.
3326
+ ...options,
3327
+ mutationFn: () => clearCompletenessDismissals(config),
3328
+ onSuccess: async (result, variables, onMutateResult, context) => {
3329
+ if (result.success) {
3330
+ await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.profile.completeness() });
3331
+ await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.inbox.counts() });
3332
+ }
3333
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
3334
+ }
3335
+ });
3336
+ }
3183
3337
  function useRpgClaimable(options) {
3184
3338
  const config = useSifaConfig();
3185
3339
  return reactQuery.useQuery({
@@ -4260,6 +4414,7 @@ exports.HIDDEN_ITEM_SOURCES = HIDDEN_ITEM_SOURCES;
4260
4414
  exports.HIDDEN_ITEM_TYPES = HIDDEN_ITEM_TYPES;
4261
4415
  exports.OrgAttestationSchema = OrgAttestationSchema;
4262
4416
  exports.PROFILE_COMPLETENESS_SIGNALS = PROFILE_COMPLETENESS_SIGNALS;
4417
+ exports.ProfileEmailSchema = ProfileEmailSchema;
4263
4418
  exports.QUOTED_POSTS_BATCH_MAX = QUOTED_POSTS_BATCH_MAX;
4264
4419
  exports.RpgClaimableResponseSchema = RpgClaimableResponseSchema;
4265
4420
  exports.RpgItemStatusSchema = RpgItemStatusSchema;
@@ -4271,6 +4426,7 @@ exports.VerificationLogEntrySchema = VerificationLogEntrySchema;
4271
4426
  exports.VerificationLogSchema = VerificationLogSchema;
4272
4427
  exports.addFeatureAllowlist = addFeatureAllowlist;
4273
4428
  exports.addOrgNotificationEmail = addOrgNotificationEmail;
4429
+ exports.addProfileEmail = addProfileEmail;
4274
4430
  exports.apiFetch = apiFetch;
4275
4431
  exports.apiFetchOrNull = apiFetchOrNull;
4276
4432
  exports.apiWrite = apiWrite;
@@ -4282,6 +4438,7 @@ exports.bulkUnhideStandardPublications = bulkUnhideStandardPublications;
4282
4438
  exports.castRoadmapVote = castRoadmapVote;
4283
4439
  exports.checkAppAccount = checkAppAccount;
4284
4440
  exports.checkNetworkMapJobStatus = checkNetworkMapJobStatus;
4441
+ exports.clearCompletenessDismissals = clearCompletenessDismissals;
4285
4442
  exports.confirmEndorsement = confirmEndorsement;
4286
4443
  exports.createConfirmation = createConfirmation;
4287
4444
  exports.createEducation = createEducation;
@@ -4304,6 +4461,7 @@ exports.deleteReaction = deleteReaction;
4304
4461
  exports.deleteRecord = deleteRecord;
4305
4462
  exports.deleteRepoRecords = deleteRepoRecords;
4306
4463
  exports.deleteSkill = deleteSkill;
4464
+ exports.dismissCompletenessSignal = dismissCompletenessSignal;
4307
4465
  exports.dismissConfirmation = dismissConfirmation;
4308
4466
  exports.dismissEndorsement = dismissEndorsement;
4309
4467
  exports.dismissUnlinkedPosition = dismissUnlinkedPosition;
@@ -4338,6 +4496,7 @@ exports.fetchPendingConfirmations = fetchPendingConfirmations;
4338
4496
  exports.fetchPendingEndorsements = fetchPendingEndorsements;
4339
4497
  exports.fetchProfile = fetchProfile;
4340
4498
  exports.fetchProfileCompleteness = fetchProfileCompleteness;
4499
+ exports.fetchProfileEmails = fetchProfileEmails;
4341
4500
  exports.fetchProfileSummary = fetchProfileSummary;
4342
4501
  exports.fetchReactionStatus = fetchReactionStatus;
4343
4502
  exports.fetchReceivedEndorsements = fetchReceivedEndorsements;
@@ -4388,9 +4547,11 @@ exports.refreshPds = refreshPds;
4388
4547
  exports.rejectAttestationRequest = rejectAttestationRequest;
4389
4548
  exports.removeFeatureAllowlist = removeFeatureAllowlist;
4390
4549
  exports.removeOrgNotificationEmail = removeOrgNotificationEmail;
4550
+ exports.removeProfileEmail = removeProfileEmail;
4391
4551
  exports.repoExportUrl = repoExportUrl;
4392
4552
  exports.requestEmploymentConfirmation = requestEmploymentConfirmation;
4393
4553
  exports.requestOrgDomainChallenge = requestOrgDomainChallenge;
4554
+ exports.resendProfileEmailVerification = resendProfileEmailVerification;
4394
4555
  exports.resetProfile = resetProfile;
4395
4556
  exports.resolveEntityDomain = resolveEntityDomain;
4396
4557
  exports.resolveQuotedPosts = resolveQuotedPosts;
@@ -4440,6 +4601,7 @@ exports.useActivityPreferences = useActivityPreferences;
4440
4601
  exports.useActivityTeaser = useActivityTeaser;
4441
4602
  exports.useAddFeatureAllowlist = useAddFeatureAllowlist;
4442
4603
  exports.useAddOrgNotificationEmail = useAddOrgNotificationEmail;
4604
+ exports.useAddProfileEmail = useAddProfileEmail;
4443
4605
  exports.useAdminReviewQueues = useAdminReviewQueues;
4444
4606
  exports.useAppAccountCheck = useAppAccountCheck;
4445
4607
  exports.useAppsRegistry = useAppsRegistry;
@@ -4453,6 +4615,7 @@ exports.useBulkUnhideProfileItems = useBulkUnhideProfileItems;
4453
4615
  exports.useBulkUnhideStandardPublications = useBulkUnhideStandardPublications;
4454
4616
  exports.useCanonicalSkillSearch = useCanonicalSkillSearch;
4455
4617
  exports.useCastRoadmapVote = useCastRoadmapVote;
4618
+ exports.useClearCompletenessDismissals = useClearCompletenessDismissals;
4456
4619
  exports.useConfirmEndorsement = useConfirmEndorsement;
4457
4620
  exports.useCreateConfirmation = useCreateConfirmation;
4458
4621
  exports.useCreateEducation = useCreateEducation;
@@ -4476,6 +4639,7 @@ exports.useDeleteReaction = useDeleteReaction;
4476
4639
  exports.useDeleteRecord = useDeleteRecord;
4477
4640
  exports.useDeleteRepoRecords = useDeleteRepoRecords;
4478
4641
  exports.useDeleteSkill = useDeleteSkill;
4642
+ exports.useDismissCompletenessSignal = useDismissCompletenessSignal;
4479
4643
  exports.useDismissConfirmation = useDismissConfirmation;
4480
4644
  exports.useDismissEndorsement = useDismissEndorsement;
4481
4645
  exports.useDismissUnlinkedPosition = useDismissUnlinkedPosition;
@@ -4519,6 +4683,7 @@ exports.usePendingConfirmations = usePendingConfirmations;
4519
4683
  exports.usePendingEndorsements = usePendingEndorsements;
4520
4684
  exports.useProfile = useProfile;
4521
4685
  exports.useProfileCompleteness = useProfileCompleteness;
4686
+ exports.useProfileEmails = useProfileEmails;
4522
4687
  exports.useReactionStatus = useReactionStatus;
4523
4688
  exports.useReceivedEndorsements = useReceivedEndorsements;
4524
4689
  exports.useReciprocityCandidate = useReciprocityCandidate;
@@ -4527,8 +4692,10 @@ exports.useRefreshPds = useRefreshPds;
4527
4692
  exports.useRejectAttestationRequest = useRejectAttestationRequest;
4528
4693
  exports.useRemoveFeatureAllowlist = useRemoveFeatureAllowlist;
4529
4694
  exports.useRemoveOrgNotificationEmail = useRemoveOrgNotificationEmail;
4695
+ exports.useRemoveProfileEmail = useRemoveProfileEmail;
4530
4696
  exports.useRepoInventory = useRepoInventory;
4531
4697
  exports.useRequestEmploymentConfirmation = useRequestEmploymentConfirmation;
4698
+ exports.useResendProfileEmailVerification = useResendProfileEmailVerification;
4532
4699
  exports.useResetProfile = useResetProfile;
4533
4700
  exports.useResolveEntityDomain = useResolveEntityDomain;
4534
4701
  exports.useRetractRoadmapVote = useRetractRoadmapVote;