@singi-labs/sifa-sdk 0.7.1 → 0.7.3

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.
@@ -73,6 +73,34 @@ async function apiFetchOrNull(config, path, options = {}) {
73
73
  throw e;
74
74
  }
75
75
  }
76
+ function extractWriteError(data, status) {
77
+ const body = data ?? {};
78
+ return {
79
+ error: body.message ?? `Request failed (${status})`,
80
+ ...body.pdsHost ? { pdsHost: body.pdsHost } : {}
81
+ };
82
+ }
83
+ async function apiWrite(config, path, method, options = {}) {
84
+ try {
85
+ const data = await apiFetch(config, path, {
86
+ method,
87
+ credentials: "include",
88
+ ...options
89
+ });
90
+ return { success: true, ...data ?? {} };
91
+ } catch (e) {
92
+ if (e instanceof ApiError) {
93
+ return { success: false, ...extractWriteError(e.body, e.status) };
94
+ }
95
+ return { success: false, error: "Network error" };
96
+ }
97
+ }
98
+ function apiWriteCreate(config, path, body, options = {}) {
99
+ return apiWrite(config, path, "POST", {
100
+ body,
101
+ ...options
102
+ });
103
+ }
76
104
  var SifaConfigContext = createContext(null);
77
105
  function SifaProvider({ config, children }) {
78
106
  return /* @__PURE__ */ jsx(SifaConfigContext.Provider, { value: config, children });
@@ -109,15 +137,303 @@ async function fetchAtFundLink(config, did, options = {}) {
109
137
  }
110
138
  }
111
139
 
140
+ // src/query/fetchers/profile-mutations.ts
141
+ function updateProfileSelf(config, data, options = {}) {
142
+ return apiWrite(config, "/api/profile/self", "PUT", { body: data, ...options });
143
+ }
144
+ function updateProfileOverride(config, data, options = {}) {
145
+ return apiWrite(config, "/api/profile/override", "PUT", { body: data, ...options });
146
+ }
147
+ function refreshPds(config, options = {}) {
148
+ return apiWrite(
149
+ config,
150
+ "/api/profile/refresh-pds",
151
+ "POST",
152
+ options
153
+ );
154
+ }
155
+ async function uploadAvatar(config, file, options = {}) {
156
+ const fetchFn = config.fetch ?? globalThis.fetch;
157
+ const url = `${config.baseUrl}/api/profile/avatar`;
158
+ const formData = new FormData();
159
+ formData.append("file", file);
160
+ try {
161
+ const res = await fetchFn(url, {
162
+ method: "POST",
163
+ credentials: options.credentials ?? "include",
164
+ body: formData,
165
+ signal: options.signal ?? AbortSignal.timeout(options.timeoutMs ?? 3e4),
166
+ headers: options.headers
167
+ });
168
+ if (!res.ok) {
169
+ const errBody = await res.json().catch(() => ({}));
170
+ const msg = errBody.message ?? `Request failed (${res.status})`;
171
+ const pdsHost = errBody.pdsHost;
172
+ return { success: false, error: msg, ...pdsHost ? { pdsHost } : {} };
173
+ }
174
+ const data = await res.json();
175
+ return { success: true, url: data.url };
176
+ } catch {
177
+ return { success: false, error: "Network error" };
178
+ }
179
+ }
180
+ function deleteAvatarOverride(config, options = {}) {
181
+ return apiWrite(config, "/api/profile/avatar", "DELETE", options);
182
+ }
183
+
112
184
  // src/query/fetchers/positions.ts
113
185
  function createPosition(config, data, options = {}) {
114
- return apiFetch(config, "/api/positions", {
115
- method: "POST",
186
+ return apiWriteCreate(config, "/api/profile/position", data, options);
187
+ }
188
+ function updatePosition(config, rkey, data, options = {}) {
189
+ return apiWrite(config, `/api/profile/position/${encodeURIComponent(rkey)}`, "PUT", {
190
+ body: data,
191
+ ...options
192
+ });
193
+ }
194
+ function deletePosition(config, rkey, options = {}) {
195
+ return apiWrite(config, `/api/profile/position/${encodeURIComponent(rkey)}`, "DELETE", options);
196
+ }
197
+ function setPositionPrimary(config, rkey, options = {}) {
198
+ return apiWrite(
199
+ config,
200
+ `/api/profile/position/${encodeURIComponent(rkey)}/primary`,
201
+ "PUT",
202
+ options
203
+ );
204
+ }
205
+ function unsetPositionPrimary(config, rkey, options = {}) {
206
+ return apiWrite(
207
+ config,
208
+ `/api/profile/position/${encodeURIComponent(rkey)}/primary`,
209
+ "DELETE",
210
+ options
211
+ );
212
+ }
213
+ function buildPositionPayload(position, skills) {
214
+ return {
215
+ company: position.company,
216
+ title: position.title,
217
+ description: position.description,
218
+ startedAt: position.startedAt,
219
+ endedAt: position.endedAt,
220
+ location: position.location ?? void 0,
221
+ skills
222
+ };
223
+ }
224
+ function linkSkillToPosition(config, position, skillRef, options = {}) {
225
+ const currentSkills = position.skills ?? [];
226
+ if (currentSkills.some((s) => s.uri === skillRef.uri)) {
227
+ return Promise.resolve({ success: true });
228
+ }
229
+ return updatePosition(
230
+ config,
231
+ position.rkey,
232
+ buildPositionPayload(position, [...currentSkills, skillRef]),
233
+ options
234
+ );
235
+ }
236
+ function unlinkSkillFromPosition(config, position, skillRef, options = {}) {
237
+ const remaining = (position.skills ?? []).filter((s) => s.uri !== skillRef.uri);
238
+ return updatePosition(config, position.rkey, buildPositionPayload(position, remaining), options);
239
+ }
240
+
241
+ // src/query/fetchers/education.ts
242
+ function createEducation(config, data, options = {}) {
243
+ return apiWriteCreate(config, "/api/profile/education", data, options);
244
+ }
245
+ function updateEducation(config, rkey, data, options = {}) {
246
+ return apiWrite(config, `/api/profile/education/${encodeURIComponent(rkey)}`, "PUT", {
247
+ body: data,
248
+ ...options
249
+ });
250
+ }
251
+ function deleteEducation(config, rkey, options = {}) {
252
+ return apiWrite(config, `/api/profile/education/${encodeURIComponent(rkey)}`, "DELETE", options);
253
+ }
254
+
255
+ // src/query/fetchers/skills.ts
256
+ function createSkill(config, data, options = {}) {
257
+ return apiWriteCreate(config, "/api/profile/skill", data, options);
258
+ }
259
+ function updateSkill(config, rkey, data, options = {}) {
260
+ return apiWrite(config, `/api/profile/skill/${encodeURIComponent(rkey)}`, "PUT", {
261
+ body: data,
262
+ ...options
263
+ });
264
+ }
265
+ function deleteSkill(config, rkey, options = {}) {
266
+ return apiWrite(config, `/api/profile/skill/${encodeURIComponent(rkey)}`, "DELETE", options);
267
+ }
268
+
269
+ // src/query/fetchers/records.ts
270
+ function createRecord(config, collection, data, options = {}) {
271
+ return apiWriteCreate(
272
+ config,
273
+ `/api/profile/records/${encodeURIComponent(collection)}`,
274
+ data,
275
+ options
276
+ );
277
+ }
278
+ function updateRecord(config, collection, rkey, data, options = {}) {
279
+ const path = `/api/profile/records/${encodeURIComponent(collection)}/${encodeURIComponent(rkey)}`;
280
+ return apiWrite(config, path, "PUT", { body: data, ...options });
281
+ }
282
+ function deleteRecord(config, collection, rkey, options = {}) {
283
+ const path = `/api/profile/records/${encodeURIComponent(collection)}/${encodeURIComponent(rkey)}`;
284
+ return apiWrite(config, path, "DELETE", options);
285
+ }
286
+
287
+ // src/query/fetchers/profile-locations.ts
288
+ function createProfileLocation(config, data, options = {}) {
289
+ return apiWriteCreate(config, "/api/profile/location", data, options);
290
+ }
291
+ function updateProfileLocation(config, rkey, data, options = {}) {
292
+ return apiWrite(config, `/api/profile/location/${encodeURIComponent(rkey)}`, "PUT", {
293
+ body: data,
294
+ ...options
295
+ });
296
+ }
297
+ function deleteProfileLocation(config, rkey, options = {}) {
298
+ return apiWrite(config, `/api/profile/location/${encodeURIComponent(rkey)}`, "DELETE", options);
299
+ }
300
+
301
+ // src/query/fetchers/external-accounts.ts
302
+ async function fetchExternalAccounts(config, handleOrDid, options = {}) {
303
+ const path = `/api/profile/${encodeURIComponent(handleOrDid)}/external-accounts`;
304
+ try {
305
+ const data = await apiFetch(config, path, {
306
+ credentials: "include",
307
+ ...options
308
+ });
309
+ return data.accounts ?? [];
310
+ } catch {
311
+ return [];
312
+ }
313
+ }
314
+ function createExternalAccount(config, data, options = {}) {
315
+ return apiWrite(
316
+ config,
317
+ "/api/profile/external-accounts",
318
+ "POST",
319
+ { body: data, ...options }
320
+ );
321
+ }
322
+ function updateExternalAccount(config, rkey, data, options = {}) {
323
+ return apiWrite(config, `/api/profile/external-accounts/${encodeURIComponent(rkey)}`, "PUT", {
116
324
  body: data,
117
- credentials: "include",
118
325
  ...options
119
326
  });
120
327
  }
328
+ function deleteExternalAccount(config, rkey, options = {}) {
329
+ return apiWrite(
330
+ config,
331
+ `/api/profile/external-accounts/${encodeURIComponent(rkey)}`,
332
+ "DELETE",
333
+ options
334
+ );
335
+ }
336
+ function setExternalAccountPrimary(config, rkey, options = {}) {
337
+ return apiWrite(
338
+ config,
339
+ `/api/profile/external-accounts/${encodeURIComponent(rkey)}/primary`,
340
+ "PUT",
341
+ options
342
+ );
343
+ }
344
+ function unsetExternalAccountPrimary(config, rkey, options = {}) {
345
+ return apiWrite(
346
+ config,
347
+ `/api/profile/external-accounts/${encodeURIComponent(rkey)}/primary`,
348
+ "DELETE",
349
+ options
350
+ );
351
+ }
352
+ function verifyExternalAccount(config, rkey, options = {}) {
353
+ return apiWrite(
354
+ config,
355
+ `/api/profile/external-accounts/${encodeURIComponent(rkey)}/verify`,
356
+ "POST",
357
+ { body: {}, ...options }
358
+ );
359
+ }
360
+
361
+ // src/query/fetchers/endorsements.ts
362
+ function createEndorsement(config, data, options = {}) {
363
+ return apiWriteCreate(config, "/api/endorsements", data, options);
364
+ }
365
+
366
+ // src/query/fetchers/keytrace-claims.ts
367
+ function hideKeytraceClaim(config, rkey, options = {}) {
368
+ return apiWrite(
369
+ config,
370
+ `/api/profile/keytrace-claims/${encodeURIComponent(rkey)}/hide`,
371
+ "POST",
372
+ options
373
+ );
374
+ }
375
+ function unhideKeytraceClaim(config, rkey, options = {}) {
376
+ return apiWrite(
377
+ config,
378
+ `/api/profile/keytrace-claims/${encodeURIComponent(rkey)}/hide`,
379
+ "DELETE",
380
+ options
381
+ );
382
+ }
383
+
384
+ // src/query/fetchers/publications.ts
385
+ function hideOrcidPublication(config, putCode, options = {}) {
386
+ return apiWrite(config, `/api/profile/orcid-publications/${putCode}/hide`, "POST", options);
387
+ }
388
+ function unhideOrcidPublication(config, putCode, options = {}) {
389
+ return apiWrite(config, `/api/profile/orcid-publications/${putCode}/hide`, "DELETE", options);
390
+ }
391
+ function hideStandardPublication(config, uri, options = {}) {
392
+ return apiWrite(
393
+ config,
394
+ `/api/profile/standard-publications/${encodeURIComponent(uri)}/hide`,
395
+ "POST",
396
+ options
397
+ );
398
+ }
399
+ function unhideStandardPublication(config, uri, options = {}) {
400
+ return apiWrite(
401
+ config,
402
+ `/api/profile/standard-publications/${encodeURIComponent(uri)}/hide`,
403
+ "DELETE",
404
+ options
405
+ );
406
+ }
407
+ function bulkHideStandardPublications(config, uris, options = {}) {
408
+ return apiWrite(config, "/api/profile/standard-publications/bulk-hide", "POST", {
409
+ body: { uris },
410
+ ...options
411
+ });
412
+ }
413
+ function bulkUnhideStandardPublications(config, uris, options = {}) {
414
+ return apiWrite(config, "/api/profile/standard-publications/bulk-hide", "DELETE", {
415
+ body: { uris },
416
+ ...options
417
+ });
418
+ }
419
+ function hideSifaPublication(config, rkey, options = {}) {
420
+ return apiWrite(config, `/api/profile/publications/${rkey}/hide`, "POST", options);
421
+ }
422
+ function unhideSifaPublication(config, rkey, options = {}) {
423
+ return apiWrite(config, `/api/profile/publications/${rkey}/hide`, "DELETE", options);
424
+ }
425
+ async function refreshOrcidPublications(config, options = {}) {
426
+ const result = await apiWrite(
427
+ config,
428
+ "/api/profile/orcid-publications/refresh",
429
+ "POST",
430
+ { body: {}, ...options }
431
+ );
432
+ if (result.success && result.error) {
433
+ return { success: false, error: result.error };
434
+ }
435
+ return result;
436
+ }
121
437
 
122
438
  // src/query/fetchers/stats.ts
123
439
  async function fetchStats(config, options = {}) {
@@ -195,6 +511,19 @@ async function fetchSearchFilters(config, options = {}) {
195
511
  return EMPTY_FILTERS;
196
512
  }
197
513
  }
514
+ async function searchSkills(config, query, limit = 10, options = {}) {
515
+ if (!query.trim()) return [];
516
+ const path = `/api/skills/search?q=${encodeURIComponent(query)}&limit=${limit}`;
517
+ try {
518
+ const data = await apiFetch(config, path, {
519
+ cache: "no-store",
520
+ ...options
521
+ });
522
+ return data.skills ?? [];
523
+ } catch {
524
+ return [];
525
+ }
526
+ }
198
527
 
199
528
  // src/query/fetchers/discovery.ts
200
529
  async function fetchSimilarProfiles(config, did, opts = {}) {
@@ -410,6 +739,79 @@ async function checkAppAccount(config, appId, options = {}) {
410
739
  return null;
411
740
  }
412
741
  }
742
+ async function createReaction(config, targetUri, appId, targetCid, options = {}) {
743
+ const fetchFn = config.fetch ?? globalThis.fetch;
744
+ const url = `${config.baseUrl}/api/reactions`;
745
+ try {
746
+ const res = await fetchFn(url, {
747
+ method: "POST",
748
+ headers: { "Content-Type": "application/json", ...options.headers ?? {} },
749
+ credentials: options.credentials ?? "include",
750
+ body: JSON.stringify({ targetUri, appId, targetCid }),
751
+ signal: options.signal ?? AbortSignal.timeout(options.timeoutMs ?? 1e4)
752
+ });
753
+ if (!res.ok) {
754
+ if (res.status === 403) {
755
+ try {
756
+ const body = await res.json();
757
+ if (body.error === "ScopeInsufficient") {
758
+ return {
759
+ ok: false,
760
+ error: { type: "scope_insufficient", requiredScope: body.requiredScope }
761
+ };
762
+ }
763
+ } catch {
764
+ }
765
+ }
766
+ return { ok: false, error: { type: "error" } };
767
+ }
768
+ const data = await res.json();
769
+ return { ok: true, data };
770
+ } catch {
771
+ return { ok: false, error: { type: "error" } };
772
+ }
773
+ }
774
+ function deleteReaction(config, targetUri, appId, options = {}) {
775
+ return apiWrite(config, "/api/reactions", "DELETE", {
776
+ body: { targetUri, appId },
777
+ ...options
778
+ });
779
+ }
780
+
781
+ // src/query/fetchers/quoted-posts.ts
782
+ var QUOTED_POSTS_BATCH_MAX = 20;
783
+ async function resolveQuotedPosts(config, uris, options = {}) {
784
+ if (uris.length === 0) return {};
785
+ const unique = [...new Set(uris)];
786
+ const batches = [];
787
+ for (let i = 0; i < unique.length; i += QUOTED_POSTS_BATCH_MAX) {
788
+ batches.push(unique.slice(i, i + QUOTED_POSTS_BATCH_MAX));
789
+ }
790
+ const headers = { ...options.headers ?? {} };
791
+ if (options.cookieHeader) headers.cookie = options.cookieHeader;
792
+ const results = {};
793
+ await Promise.all(
794
+ batches.map(async (batch) => {
795
+ try {
796
+ const data = await apiFetch(
797
+ config,
798
+ "/api/quoted-posts/resolve",
799
+ {
800
+ method: "POST",
801
+ body: { uris: batch },
802
+ credentials: "include",
803
+ timeoutMs: 8e3,
804
+ ...options,
805
+ headers
806
+ }
807
+ );
808
+ Object.assign(results, data);
809
+ } catch {
810
+ }
811
+ })
812
+ );
813
+ return results;
814
+ }
413
815
 
414
816
  // src/query/fetchers/roadmap.ts
415
817
  async function fetchRoadmapVotes(config, options = {}) {
@@ -436,6 +838,26 @@ async function fetchMyRoadmapVotes(config, options = {}) {
436
838
  return [];
437
839
  }
438
840
  }
841
+ function castRoadmapVote(config, key, options = {}) {
842
+ return apiWrite(config, `/api/roadmap/votes/${encodeURIComponent(key)}`, "POST", options);
843
+ }
844
+ function retractRoadmapVote(config, key, options = {}) {
845
+ return apiWrite(config, `/api/roadmap/votes/${encodeURIComponent(key)}`, "DELETE", options);
846
+ }
847
+
848
+ // src/query/fetchers/destructive.ts
849
+ function resetProfile(config, deletePdsData, options = {}) {
850
+ return apiWrite(config, "/api/profile/reset", "DELETE", {
851
+ body: { deletePdsData },
852
+ ...options
853
+ });
854
+ }
855
+ function deleteAccount(config, deletePdsData, options = {}) {
856
+ return apiWrite(config, "/api/profile/account", "DELETE", {
857
+ body: { deletePdsData },
858
+ ...options
859
+ });
860
+ }
439
861
 
440
862
  // src/query/keys.ts
441
863
  var sifaQueryKeys = {
@@ -443,7 +865,8 @@ var sifaQueryKeys = {
443
865
  profile: {
444
866
  all: () => ["sifa", "profile"],
445
867
  byHandle: (handleOrDid) => ["sifa", "profile", handleOrDid],
446
- atFundLink: (did) => ["sifa", "profile", "at-fund-link", did]
868
+ atFundLink: (did) => ["sifa", "profile", "at-fund-link", did],
869
+ externalAccounts: (handleOrDid) => ["sifa", "profile", "external-accounts", handleOrDid]
447
870
  },
448
871
  position: {
449
872
  all: () => ["sifa", "position"],
@@ -453,6 +876,7 @@ var sifaQueryKeys = {
453
876
  all: () => ["sifa", "search"],
454
877
  profiles: (filters) => ["sifa", "search", "profiles", filters],
455
878
  skills: (query) => ["sifa", "search", "skills", query],
879
+ canonicalSkills: (query, limit) => ["sifa", "search", "canonical-skills", query, limit],
456
880
  filters: () => ["sifa", "search", "filters"]
457
881
  },
458
882
  discovery: {
@@ -520,105 +944,681 @@ function useAtFundLink(did, options) {
520
944
  ...options
521
945
  });
522
946
  }
523
- function useCreatePosition(ownerDid, options) {
947
+ async function invalidateProfile(queryClient, ownerHandleOrDid) {
948
+ await queryClient.invalidateQueries({
949
+ queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
950
+ });
951
+ }
952
+ function useUpdateProfileSelf(ownerHandleOrDid, options) {
524
953
  const config = useSifaConfig();
525
954
  const queryClient = useQueryClient();
526
955
  return useMutation({
527
- mutationFn: (data) => createPosition(config, data),
956
+ mutationFn: (data) => updateProfileSelf(config, data),
528
957
  onSuccess: async (result, variables, onMutateResult, context) => {
529
958
  if (result.success) {
530
- await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.profile.byHandle(ownerDid) });
531
- await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.position.byOwner(ownerDid) });
959
+ await invalidateProfile(queryClient, ownerHandleOrDid);
532
960
  }
533
961
  await options?.onSuccess?.(result, variables, onMutateResult, context);
534
962
  },
535
963
  ...options
536
964
  });
537
965
  }
538
- function useStats(options) {
966
+ function useUpdateProfileOverride(ownerHandleOrDid, options) {
539
967
  const config = useSifaConfig();
540
- return useQuery({
541
- queryKey: sifaQueryKeys.stats.homepage(),
542
- queryFn: () => fetchStats(config),
968
+ const queryClient = useQueryClient();
969
+ return useMutation({
970
+ mutationFn: (data) => updateProfileOverride(config, data),
971
+ onSuccess: async (result, variables, onMutateResult, context) => {
972
+ if (result.success) {
973
+ await invalidateProfile(queryClient, ownerHandleOrDid);
974
+ }
975
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
976
+ },
543
977
  ...options
544
978
  });
545
979
  }
546
- function useAppsRegistry(options) {
980
+ function useRefreshPds(ownerHandleOrDid, options) {
547
981
  const config = useSifaConfig();
548
- return useQuery({
549
- queryKey: sifaQueryKeys.apps.registry(),
550
- queryFn: () => fetchAppsRegistry(config),
982
+ const queryClient = useQueryClient();
983
+ return useMutation({
984
+ mutationFn: () => refreshPds(config),
985
+ onSuccess: async (result, variables, onMutateResult, context) => {
986
+ if (result.success) {
987
+ await invalidateProfile(queryClient, ownerHandleOrDid);
988
+ }
989
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
990
+ },
551
991
  ...options
552
992
  });
553
993
  }
554
- function useHiddenApps(options) {
994
+ function useUploadAvatar(ownerHandleOrDid, options) {
555
995
  const config = useSifaConfig();
556
- return useQuery({
557
- queryKey: sifaQueryKeys.apps.hidden(),
558
- queryFn: () => fetchHiddenApps(config),
996
+ const queryClient = useQueryClient();
997
+ return useMutation({
998
+ mutationFn: (file) => uploadAvatar(config, file),
999
+ onSuccess: async (result, variables, onMutateResult, context) => {
1000
+ if (result.success) {
1001
+ await invalidateProfile(queryClient, ownerHandleOrDid);
1002
+ }
1003
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1004
+ },
559
1005
  ...options
560
1006
  });
561
1007
  }
562
- function useSearchProfiles(filters, options) {
1008
+ function useDeleteAvatarOverride(ownerHandleOrDid, options) {
563
1009
  const config = useSifaConfig();
564
- return useQuery({
565
- queryKey: sifaQueryKeys.search.profiles(filters),
566
- queryFn: () => fetchSearchProfiles(config, filters),
1010
+ const queryClient = useQueryClient();
1011
+ return useMutation({
1012
+ mutationFn: () => deleteAvatarOverride(config),
1013
+ onSuccess: async (result, variables, onMutateResult, context) => {
1014
+ if (result.success) {
1015
+ await invalidateProfile(queryClient, ownerHandleOrDid);
1016
+ }
1017
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1018
+ },
567
1019
  ...options
568
1020
  });
569
1021
  }
570
- function useSkillSuggestions(query, options) {
1022
+ function useCreatePosition(ownerDid, options) {
571
1023
  const config = useSifaConfig();
572
- return useQuery({
573
- queryKey: sifaQueryKeys.search.skills(query),
574
- queryFn: () => fetchSkillSuggestions(config, query),
575
- enabled: query.trim().length > 0 && (options?.enabled ?? true),
1024
+ const queryClient = useQueryClient();
1025
+ return useMutation({
1026
+ mutationFn: (data) => createPosition(config, data),
1027
+ onSuccess: async (result, variables, onMutateResult, context) => {
1028
+ if (result.success) {
1029
+ await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.profile.byHandle(ownerDid) });
1030
+ await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.position.byOwner(ownerDid) });
1031
+ }
1032
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1033
+ },
576
1034
  ...options
577
1035
  });
578
1036
  }
579
- function useSearchFilters(options) {
580
- const config = useSifaConfig();
581
- return useQuery({
582
- queryKey: sifaQueryKeys.search.filters(),
583
- queryFn: () => fetchSearchFilters(config),
584
- ...options
1037
+ async function invalidatePositionCaches(queryClient, ownerHandleOrDid) {
1038
+ await queryClient.invalidateQueries({
1039
+ queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
585
1040
  });
586
- }
587
- function useSimilarProfiles(did, opts = {}, options) {
588
- const config = useSifaConfig();
589
- const limit = opts.limit ?? 5;
590
- return useQuery({
591
- queryKey: sifaQueryKeys.discovery.similar(did ?? "", limit),
592
- queryFn: () => fetchSimilarProfiles(config, did ?? "", { limit }),
593
- enabled: Boolean(did) && (options?.enabled ?? true),
594
- ...options
1041
+ await queryClient.invalidateQueries({
1042
+ queryKey: sifaQueryKeys.position.byOwner(ownerHandleOrDid)
595
1043
  });
596
1044
  }
597
- function useSuggestions(opts = {}, options) {
1045
+ function useUpdatePosition(ownerHandleOrDid, options) {
598
1046
  const config = useSifaConfig();
599
- return useQuery({
600
- queryKey: sifaQueryKeys.discovery.suggestions(opts),
601
- queryFn: () => fetchSuggestions(config, opts),
1047
+ const queryClient = useQueryClient();
1048
+ return useMutation({
1049
+ mutationFn: ({ rkey, data }) => updatePosition(config, rkey, data),
1050
+ onSuccess: async (result, variables, onMutateResult, context) => {
1051
+ if (result.success) {
1052
+ await invalidatePositionCaches(queryClient, ownerHandleOrDid);
1053
+ }
1054
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1055
+ },
602
1056
  ...options
603
1057
  });
604
1058
  }
605
- function useSuggestionCount(since, options) {
1059
+ function useDeletePosition(ownerHandleOrDid, options) {
606
1060
  const config = useSifaConfig();
607
- return useQuery({
608
- queryKey: sifaQueryKeys.discovery.suggestionCount(since),
609
- queryFn: () => fetchSuggestionCount(config, since),
1061
+ const queryClient = useQueryClient();
1062
+ return useMutation({
1063
+ mutationFn: (rkey) => deletePosition(config, rkey),
1064
+ onSuccess: async (result, variables, onMutateResult, context) => {
1065
+ if (result.success) {
1066
+ await invalidatePositionCaches(queryClient, ownerHandleOrDid);
1067
+ }
1068
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1069
+ },
610
1070
  ...options
611
1071
  });
612
1072
  }
613
- function useFeaturedProfile(options) {
1073
+ function useSetPositionPrimary(ownerHandleOrDid, options) {
614
1074
  const config = useSifaConfig();
615
- return useQuery({
616
- queryKey: sifaQueryKeys.discovery.featured(),
617
- queryFn: () => fetchFeaturedProfile(config),
1075
+ const queryClient = useQueryClient();
1076
+ return useMutation({
1077
+ mutationFn: (rkey) => setPositionPrimary(config, rkey),
1078
+ onSuccess: async (result, variables, onMutateResult, context) => {
1079
+ if (result.success) {
1080
+ await invalidatePositionCaches(queryClient, ownerHandleOrDid);
1081
+ }
1082
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1083
+ },
618
1084
  ...options
619
1085
  });
620
1086
  }
621
- function useFollowing(opts = {}, options) {
1087
+ function useUnsetPositionPrimary(ownerHandleOrDid, options) {
1088
+ const config = useSifaConfig();
1089
+ const queryClient = useQueryClient();
1090
+ return useMutation({
1091
+ mutationFn: (rkey) => unsetPositionPrimary(config, rkey),
1092
+ onSuccess: async (result, variables, onMutateResult, context) => {
1093
+ if (result.success) {
1094
+ await invalidatePositionCaches(queryClient, ownerHandleOrDid);
1095
+ }
1096
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1097
+ },
1098
+ ...options
1099
+ });
1100
+ }
1101
+ function useLinkSkillToPosition(ownerHandleOrDid, options) {
1102
+ const config = useSifaConfig();
1103
+ const queryClient = useQueryClient();
1104
+ return useMutation({
1105
+ mutationFn: ({ position, skillRef }) => linkSkillToPosition(config, position, skillRef),
1106
+ onSuccess: async (result, variables, onMutateResult, context) => {
1107
+ if (result.success) {
1108
+ await invalidatePositionCaches(queryClient, ownerHandleOrDid);
1109
+ }
1110
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1111
+ },
1112
+ ...options
1113
+ });
1114
+ }
1115
+ function useUnlinkSkillFromPosition(ownerHandleOrDid, options) {
1116
+ const config = useSifaConfig();
1117
+ const queryClient = useQueryClient();
1118
+ return useMutation({
1119
+ mutationFn: ({ position, skillRef }) => unlinkSkillFromPosition(config, position, skillRef),
1120
+ onSuccess: async (result, variables, onMutateResult, context) => {
1121
+ if (result.success) {
1122
+ await invalidatePositionCaches(queryClient, ownerHandleOrDid);
1123
+ }
1124
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1125
+ },
1126
+ ...options
1127
+ });
1128
+ }
1129
+ async function invalidateProfile2(queryClient, ownerHandleOrDid) {
1130
+ await queryClient.invalidateQueries({
1131
+ queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
1132
+ });
1133
+ }
1134
+ function useCreateEducation(ownerHandleOrDid, options) {
1135
+ const config = useSifaConfig();
1136
+ const queryClient = useQueryClient();
1137
+ return useMutation({
1138
+ mutationFn: (data) => createEducation(config, data),
1139
+ onSuccess: async (result, variables, onMutateResult, context) => {
1140
+ if (result.success) {
1141
+ await invalidateProfile2(queryClient, ownerHandleOrDid);
1142
+ }
1143
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1144
+ },
1145
+ ...options
1146
+ });
1147
+ }
1148
+ function useUpdateEducation(ownerHandleOrDid, options) {
1149
+ const config = useSifaConfig();
1150
+ const queryClient = useQueryClient();
1151
+ return useMutation({
1152
+ mutationFn: ({ rkey, data }) => updateEducation(config, rkey, data),
1153
+ onSuccess: async (result, variables, onMutateResult, context) => {
1154
+ if (result.success) {
1155
+ await invalidateProfile2(queryClient, ownerHandleOrDid);
1156
+ }
1157
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1158
+ },
1159
+ ...options
1160
+ });
1161
+ }
1162
+ function useDeleteEducation(ownerHandleOrDid, options) {
1163
+ const config = useSifaConfig();
1164
+ const queryClient = useQueryClient();
1165
+ return useMutation({
1166
+ mutationFn: (rkey) => deleteEducation(config, rkey),
1167
+ onSuccess: async (result, variables, onMutateResult, context) => {
1168
+ if (result.success) {
1169
+ await invalidateProfile2(queryClient, ownerHandleOrDid);
1170
+ }
1171
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1172
+ },
1173
+ ...options
1174
+ });
1175
+ }
1176
+ async function invalidateProfile3(queryClient, ownerHandleOrDid) {
1177
+ await queryClient.invalidateQueries({
1178
+ queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
1179
+ });
1180
+ }
1181
+ function useCreateSkill(ownerHandleOrDid, options) {
1182
+ const config = useSifaConfig();
1183
+ const queryClient = useQueryClient();
1184
+ return useMutation({
1185
+ mutationFn: (data) => createSkill(config, data),
1186
+ onSuccess: async (result, variables, onMutateResult, context) => {
1187
+ if (result.success) {
1188
+ await invalidateProfile3(queryClient, ownerHandleOrDid);
1189
+ }
1190
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1191
+ },
1192
+ ...options
1193
+ });
1194
+ }
1195
+ function useUpdateSkill(ownerHandleOrDid, options) {
1196
+ const config = useSifaConfig();
1197
+ const queryClient = useQueryClient();
1198
+ return useMutation({
1199
+ mutationFn: ({ rkey, data }) => updateSkill(config, rkey, data),
1200
+ onSuccess: async (result, variables, onMutateResult, context) => {
1201
+ if (result.success) {
1202
+ await invalidateProfile3(queryClient, ownerHandleOrDid);
1203
+ }
1204
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1205
+ },
1206
+ ...options
1207
+ });
1208
+ }
1209
+ function useDeleteSkill(ownerHandleOrDid, options) {
1210
+ const config = useSifaConfig();
1211
+ const queryClient = useQueryClient();
1212
+ return useMutation({
1213
+ mutationFn: (rkey) => deleteSkill(config, rkey),
1214
+ onSuccess: async (result, variables, onMutateResult, context) => {
1215
+ if (result.success) {
1216
+ await invalidateProfile3(queryClient, ownerHandleOrDid);
1217
+ }
1218
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1219
+ },
1220
+ ...options
1221
+ });
1222
+ }
1223
+ async function invalidateProfile4(queryClient, ownerHandleOrDid) {
1224
+ await queryClient.invalidateQueries({
1225
+ queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
1226
+ });
1227
+ }
1228
+ function useCreateRecord(ownerHandleOrDid, options) {
1229
+ const config = useSifaConfig();
1230
+ const queryClient = useQueryClient();
1231
+ return useMutation({
1232
+ mutationFn: ({ collection, data }) => createRecord(config, collection, data),
1233
+ onSuccess: async (result, variables, onMutateResult, context) => {
1234
+ if (result.success) {
1235
+ await invalidateProfile4(queryClient, ownerHandleOrDid);
1236
+ }
1237
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1238
+ },
1239
+ ...options
1240
+ });
1241
+ }
1242
+ function useUpdateRecord(ownerHandleOrDid, options) {
1243
+ const config = useSifaConfig();
1244
+ const queryClient = useQueryClient();
1245
+ return useMutation({
1246
+ mutationFn: ({ collection, rkey, data }) => updateRecord(config, collection, rkey, data),
1247
+ onSuccess: async (result, variables, onMutateResult, context) => {
1248
+ if (result.success) {
1249
+ await invalidateProfile4(queryClient, ownerHandleOrDid);
1250
+ }
1251
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1252
+ },
1253
+ ...options
1254
+ });
1255
+ }
1256
+ function useDeleteRecord(ownerHandleOrDid, options) {
1257
+ const config = useSifaConfig();
1258
+ const queryClient = useQueryClient();
1259
+ return useMutation({
1260
+ mutationFn: ({ collection, rkey }) => deleteRecord(config, collection, rkey),
1261
+ onSuccess: async (result, variables, onMutateResult, context) => {
1262
+ if (result.success) {
1263
+ await invalidateProfile4(queryClient, ownerHandleOrDid);
1264
+ }
1265
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1266
+ },
1267
+ ...options
1268
+ });
1269
+ }
1270
+ async function invalidateProfile5(queryClient, ownerHandleOrDid) {
1271
+ await queryClient.invalidateQueries({
1272
+ queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
1273
+ });
1274
+ }
1275
+ function useCreateProfileLocation(ownerHandleOrDid, options) {
1276
+ const config = useSifaConfig();
1277
+ const queryClient = useQueryClient();
1278
+ return useMutation({
1279
+ mutationFn: (data) => createProfileLocation(config, data),
1280
+ onSuccess: async (result, variables, onMutateResult, context) => {
1281
+ if (result.success) {
1282
+ await invalidateProfile5(queryClient, ownerHandleOrDid);
1283
+ }
1284
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1285
+ },
1286
+ ...options
1287
+ });
1288
+ }
1289
+ function useUpdateProfileLocation(ownerHandleOrDid, options) {
1290
+ const config = useSifaConfig();
1291
+ const queryClient = useQueryClient();
1292
+ return useMutation({
1293
+ mutationFn: ({ rkey, data }) => updateProfileLocation(config, rkey, data),
1294
+ onSuccess: async (result, variables, onMutateResult, context) => {
1295
+ if (result.success) {
1296
+ await invalidateProfile5(queryClient, ownerHandleOrDid);
1297
+ }
1298
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1299
+ },
1300
+ ...options
1301
+ });
1302
+ }
1303
+ function useDeleteProfileLocation(ownerHandleOrDid, options) {
1304
+ const config = useSifaConfig();
1305
+ const queryClient = useQueryClient();
1306
+ return useMutation({
1307
+ mutationFn: (rkey) => deleteProfileLocation(config, rkey),
1308
+ onSuccess: async (result, variables, onMutateResult, context) => {
1309
+ if (result.success) {
1310
+ await invalidateProfile5(queryClient, ownerHandleOrDid);
1311
+ }
1312
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1313
+ },
1314
+ ...options
1315
+ });
1316
+ }
1317
+ async function invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid) {
1318
+ await queryClient.invalidateQueries({
1319
+ queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
1320
+ });
1321
+ await queryClient.invalidateQueries({
1322
+ queryKey: sifaQueryKeys.profile.externalAccounts(ownerHandleOrDid)
1323
+ });
1324
+ }
1325
+ function useExternalAccounts(handleOrDid, options) {
1326
+ const config = useSifaConfig();
1327
+ return useQuery({
1328
+ queryKey: sifaQueryKeys.profile.externalAccounts(handleOrDid ?? ""),
1329
+ queryFn: () => fetchExternalAccounts(config, handleOrDid ?? ""),
1330
+ enabled: Boolean(handleOrDid) && (options?.enabled ?? true),
1331
+ ...options
1332
+ });
1333
+ }
1334
+ function useCreateExternalAccount(ownerHandleOrDid, options) {
1335
+ const config = useSifaConfig();
1336
+ const queryClient = useQueryClient();
1337
+ return useMutation({
1338
+ mutationFn: (data) => createExternalAccount(config, data),
1339
+ onSuccess: async (result, variables, onMutateResult, context) => {
1340
+ if (result.success) {
1341
+ await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);
1342
+ }
1343
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1344
+ },
1345
+ ...options
1346
+ });
1347
+ }
1348
+ function useUpdateExternalAccount(ownerHandleOrDid, options) {
1349
+ const config = useSifaConfig();
1350
+ const queryClient = useQueryClient();
1351
+ return useMutation({
1352
+ mutationFn: ({ rkey, data }) => updateExternalAccount(config, rkey, data),
1353
+ onSuccess: async (result, variables, onMutateResult, context) => {
1354
+ if (result.success) {
1355
+ await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);
1356
+ }
1357
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1358
+ },
1359
+ ...options
1360
+ });
1361
+ }
1362
+ function useDeleteExternalAccount(ownerHandleOrDid, options) {
1363
+ const config = useSifaConfig();
1364
+ const queryClient = useQueryClient();
1365
+ return useMutation({
1366
+ mutationFn: (rkey) => deleteExternalAccount(config, rkey),
1367
+ onSuccess: async (result, variables, onMutateResult, context) => {
1368
+ if (result.success) {
1369
+ await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);
1370
+ }
1371
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1372
+ },
1373
+ ...options
1374
+ });
1375
+ }
1376
+ function useSetExternalAccountPrimary(ownerHandleOrDid, options) {
1377
+ const config = useSifaConfig();
1378
+ const queryClient = useQueryClient();
1379
+ return useMutation({
1380
+ mutationFn: (rkey) => setExternalAccountPrimary(config, rkey),
1381
+ onSuccess: async (result, variables, onMutateResult, context) => {
1382
+ if (result.success) {
1383
+ await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);
1384
+ }
1385
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1386
+ },
1387
+ ...options
1388
+ });
1389
+ }
1390
+ function useUnsetExternalAccountPrimary(ownerHandleOrDid, options) {
1391
+ const config = useSifaConfig();
1392
+ const queryClient = useQueryClient();
1393
+ return useMutation({
1394
+ mutationFn: (rkey) => unsetExternalAccountPrimary(config, rkey),
1395
+ onSuccess: async (result, variables, onMutateResult, context) => {
1396
+ if (result.success) {
1397
+ await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);
1398
+ }
1399
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1400
+ },
1401
+ ...options
1402
+ });
1403
+ }
1404
+ function useVerifyExternalAccount(ownerHandleOrDid, options) {
1405
+ const config = useSifaConfig();
1406
+ const queryClient = useQueryClient();
1407
+ return useMutation({
1408
+ mutationFn: (rkey) => verifyExternalAccount(config, rkey),
1409
+ onSuccess: async (result, variables, onMutateResult, context) => {
1410
+ if (result.success) {
1411
+ await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);
1412
+ }
1413
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1414
+ },
1415
+ ...options
1416
+ });
1417
+ }
1418
+ function useCreateEndorsement(endorsedHandleOrDid, options) {
1419
+ const config = useSifaConfig();
1420
+ const queryClient = useQueryClient();
1421
+ return useMutation({
1422
+ mutationFn: (data) => createEndorsement(config, data),
1423
+ onSuccess: async (result, variables, onMutateResult, context) => {
1424
+ if (result.success && endorsedHandleOrDid) {
1425
+ await queryClient.invalidateQueries({
1426
+ queryKey: sifaQueryKeys.profile.byHandle(endorsedHandleOrDid)
1427
+ });
1428
+ await queryClient.invalidateQueries({
1429
+ queryKey: sifaQueryKeys.endorsement.count(endorsedHandleOrDid)
1430
+ });
1431
+ }
1432
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1433
+ },
1434
+ ...options
1435
+ });
1436
+ }
1437
+ async function invalidateProfile6(queryClient, ownerHandleOrDid) {
1438
+ await queryClient.invalidateQueries({
1439
+ queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
1440
+ });
1441
+ }
1442
+ function useHideKeytraceClaim(ownerHandleOrDid, options) {
1443
+ const config = useSifaConfig();
1444
+ const queryClient = useQueryClient();
1445
+ return useMutation({
1446
+ mutationFn: (rkey) => hideKeytraceClaim(config, rkey),
1447
+ onSuccess: async (result, variables, onMutateResult, context) => {
1448
+ if (result.success) {
1449
+ await invalidateProfile6(queryClient, ownerHandleOrDid);
1450
+ }
1451
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1452
+ },
1453
+ ...options
1454
+ });
1455
+ }
1456
+ function useUnhideKeytraceClaim(ownerHandleOrDid, options) {
1457
+ const config = useSifaConfig();
1458
+ const queryClient = useQueryClient();
1459
+ return useMutation({
1460
+ mutationFn: (rkey) => unhideKeytraceClaim(config, rkey),
1461
+ onSuccess: async (result, variables, onMutateResult, context) => {
1462
+ if (result.success) {
1463
+ await invalidateProfile6(queryClient, ownerHandleOrDid);
1464
+ }
1465
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1466
+ },
1467
+ ...options
1468
+ });
1469
+ }
1470
+ async function invalidateProfile7(queryClient, ownerHandleOrDid) {
1471
+ await queryClient.invalidateQueries({
1472
+ queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
1473
+ });
1474
+ }
1475
+ function makeWriteHook(fetcher) {
1476
+ return function useHook(ownerHandleOrDid, options) {
1477
+ const config = useSifaConfig();
1478
+ const queryClient = useQueryClient();
1479
+ return useMutation({
1480
+ mutationFn: (v) => fetcher(config, v),
1481
+ onSuccess: async (result, variables, onMutateResult, context) => {
1482
+ if (result.success) {
1483
+ await invalidateProfile7(queryClient, ownerHandleOrDid);
1484
+ }
1485
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1486
+ },
1487
+ ...options
1488
+ });
1489
+ };
1490
+ }
1491
+ var useHideOrcidPublication = makeWriteHook(
1492
+ (config, putCode) => hideOrcidPublication(config, putCode)
1493
+ );
1494
+ var useUnhideOrcidPublication = makeWriteHook(
1495
+ (config, putCode) => unhideOrcidPublication(config, putCode)
1496
+ );
1497
+ var useHideStandardPublication = makeWriteHook(
1498
+ (config, uri) => hideStandardPublication(config, uri)
1499
+ );
1500
+ var useUnhideStandardPublication = makeWriteHook(
1501
+ (config, uri) => unhideStandardPublication(config, uri)
1502
+ );
1503
+ var useBulkHideStandardPublications = makeWriteHook(
1504
+ (config, uris) => bulkHideStandardPublications(config, uris)
1505
+ );
1506
+ var useBulkUnhideStandardPublications = makeWriteHook(
1507
+ (config, uris) => bulkUnhideStandardPublications(config, uris)
1508
+ );
1509
+ var useHideSifaPublication = makeWriteHook(
1510
+ (config, rkey) => hideSifaPublication(config, rkey)
1511
+ );
1512
+ var useUnhideSifaPublication = makeWriteHook(
1513
+ (config, rkey) => unhideSifaPublication(config, rkey)
1514
+ );
1515
+ function useRefreshOrcidPublications(ownerHandleOrDid, options) {
1516
+ const config = useSifaConfig();
1517
+ const queryClient = useQueryClient();
1518
+ return useMutation({
1519
+ mutationFn: () => refreshOrcidPublications(config),
1520
+ onSuccess: async (result, variables, onMutateResult, context) => {
1521
+ if (result.success) {
1522
+ await invalidateProfile7(queryClient, ownerHandleOrDid);
1523
+ }
1524
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1525
+ },
1526
+ ...options
1527
+ });
1528
+ }
1529
+ function useStats(options) {
1530
+ const config = useSifaConfig();
1531
+ return useQuery({
1532
+ queryKey: sifaQueryKeys.stats.homepage(),
1533
+ queryFn: () => fetchStats(config),
1534
+ ...options
1535
+ });
1536
+ }
1537
+ function useAppsRegistry(options) {
1538
+ const config = useSifaConfig();
1539
+ return useQuery({
1540
+ queryKey: sifaQueryKeys.apps.registry(),
1541
+ queryFn: () => fetchAppsRegistry(config),
1542
+ ...options
1543
+ });
1544
+ }
1545
+ function useHiddenApps(options) {
1546
+ const config = useSifaConfig();
1547
+ return useQuery({
1548
+ queryKey: sifaQueryKeys.apps.hidden(),
1549
+ queryFn: () => fetchHiddenApps(config),
1550
+ ...options
1551
+ });
1552
+ }
1553
+ function useSearchProfiles(filters, options) {
1554
+ const config = useSifaConfig();
1555
+ return useQuery({
1556
+ queryKey: sifaQueryKeys.search.profiles(filters),
1557
+ queryFn: () => fetchSearchProfiles(config, filters),
1558
+ ...options
1559
+ });
1560
+ }
1561
+ function useSkillSuggestions(query, options) {
1562
+ const config = useSifaConfig();
1563
+ return useQuery({
1564
+ queryKey: sifaQueryKeys.search.skills(query),
1565
+ queryFn: () => fetchSkillSuggestions(config, query),
1566
+ enabled: query.trim().length > 0 && (options?.enabled ?? true),
1567
+ ...options
1568
+ });
1569
+ }
1570
+ function useCanonicalSkillSearch(query, limit = 10, options) {
1571
+ const config = useSifaConfig();
1572
+ return useQuery({
1573
+ queryKey: sifaQueryKeys.search.canonicalSkills(query, limit),
1574
+ queryFn: () => searchSkills(config, query, limit),
1575
+ enabled: query.trim().length > 0 && (options?.enabled ?? true),
1576
+ ...options
1577
+ });
1578
+ }
1579
+ function useSearchFilters(options) {
1580
+ const config = useSifaConfig();
1581
+ return useQuery({
1582
+ queryKey: sifaQueryKeys.search.filters(),
1583
+ queryFn: () => fetchSearchFilters(config),
1584
+ ...options
1585
+ });
1586
+ }
1587
+ function useSimilarProfiles(did, opts = {}, options) {
1588
+ const config = useSifaConfig();
1589
+ const limit = opts.limit ?? 5;
1590
+ return useQuery({
1591
+ queryKey: sifaQueryKeys.discovery.similar(did ?? "", limit),
1592
+ queryFn: () => fetchSimilarProfiles(config, did ?? "", { limit }),
1593
+ enabled: Boolean(did) && (options?.enabled ?? true),
1594
+ ...options
1595
+ });
1596
+ }
1597
+ function useSuggestions(opts = {}, options) {
1598
+ const config = useSifaConfig();
1599
+ return useQuery({
1600
+ queryKey: sifaQueryKeys.discovery.suggestions(opts),
1601
+ queryFn: () => fetchSuggestions(config, opts),
1602
+ ...options
1603
+ });
1604
+ }
1605
+ function useSuggestionCount(since, options) {
1606
+ const config = useSifaConfig();
1607
+ return useQuery({
1608
+ queryKey: sifaQueryKeys.discovery.suggestionCount(since),
1609
+ queryFn: () => fetchSuggestionCount(config, since),
1610
+ ...options
1611
+ });
1612
+ }
1613
+ function useFeaturedProfile(options) {
1614
+ const config = useSifaConfig();
1615
+ return useQuery({
1616
+ queryKey: sifaQueryKeys.discovery.featured(),
1617
+ queryFn: () => fetchFeaturedProfile(config),
1618
+ ...options
1619
+ });
1620
+ }
1621
+ function useFollowing(opts = {}, options) {
622
1622
  const config = useSifaConfig();
623
1623
  return useQuery({
624
1624
  queryKey: sifaQueryKeys.follow.following(opts),
@@ -688,6 +1688,34 @@ function useAppAccountCheck(appId, options) {
688
1688
  ...options
689
1689
  });
690
1690
  }
1691
+ function useCreateReaction(options) {
1692
+ const config = useSifaConfig();
1693
+ const queryClient = useQueryClient();
1694
+ return useMutation({
1695
+ mutationFn: ({ targetUri, appId, targetCid }) => createReaction(config, targetUri, appId, targetCid),
1696
+ onSuccess: async (result, variables, onMutateResult, context) => {
1697
+ if (result.ok) {
1698
+ await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.reactions.all() });
1699
+ }
1700
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1701
+ },
1702
+ ...options
1703
+ });
1704
+ }
1705
+ function useDeleteReaction(options) {
1706
+ const config = useSifaConfig();
1707
+ const queryClient = useQueryClient();
1708
+ return useMutation({
1709
+ mutationFn: ({ targetUri, appId }) => deleteReaction(config, targetUri, appId),
1710
+ onSuccess: async (result, variables, onMutateResult, context) => {
1711
+ if (result.success) {
1712
+ await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.reactions.all() });
1713
+ }
1714
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1715
+ },
1716
+ ...options
1717
+ });
1718
+ }
691
1719
  function useRoadmapVotes(options) {
692
1720
  const config = useSifaConfig();
693
1721
  return useQuery({
@@ -704,7 +1732,66 @@ function useMyRoadmapVotes(options) {
704
1732
  ...options
705
1733
  });
706
1734
  }
1735
+ async function invalidateRoadmap(queryClient) {
1736
+ await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.roadmap.all() });
1737
+ }
1738
+ function useCastRoadmapVote(options) {
1739
+ const config = useSifaConfig();
1740
+ const queryClient = useQueryClient();
1741
+ return useMutation({
1742
+ mutationFn: (key) => castRoadmapVote(config, key),
1743
+ onSuccess: async (result, variables, onMutateResult, context) => {
1744
+ if (result.success) {
1745
+ await invalidateRoadmap(queryClient);
1746
+ }
1747
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1748
+ },
1749
+ ...options
1750
+ });
1751
+ }
1752
+ function useRetractRoadmapVote(options) {
1753
+ const config = useSifaConfig();
1754
+ const queryClient = useQueryClient();
1755
+ return useMutation({
1756
+ mutationFn: (key) => retractRoadmapVote(config, key),
1757
+ onSuccess: async (result, variables, onMutateResult, context) => {
1758
+ if (result.success) {
1759
+ await invalidateRoadmap(queryClient);
1760
+ }
1761
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1762
+ },
1763
+ ...options
1764
+ });
1765
+ }
1766
+ function useResetProfile(options) {
1767
+ const config = useSifaConfig();
1768
+ const queryClient = useQueryClient();
1769
+ return useMutation({
1770
+ mutationFn: (deletePdsData) => resetProfile(config, deletePdsData),
1771
+ onSuccess: async (result, variables, onMutateResult, context) => {
1772
+ if (result.success) {
1773
+ await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.all() });
1774
+ }
1775
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1776
+ },
1777
+ ...options
1778
+ });
1779
+ }
1780
+ function useDeleteAccount(options) {
1781
+ const config = useSifaConfig();
1782
+ const queryClient = useQueryClient();
1783
+ return useMutation({
1784
+ mutationFn: (deletePdsData) => deleteAccount(config, deletePdsData),
1785
+ onSuccess: async (result, variables, onMutateResult, context) => {
1786
+ if (result.success) {
1787
+ queryClient.clear();
1788
+ }
1789
+ await options?.onSuccess?.(result, variables, onMutateResult, context);
1790
+ },
1791
+ ...options
1792
+ });
1793
+ }
707
1794
 
708
- export { ApiError, SifaProvider, apiFetch, apiFetchOrNull, checkAppAccount, createPosition, fetchActivityFeed, fetchActivityTeaser, fetchAppsRegistry, fetchAtFundLink, fetchEndorsementCount, fetchFeaturedProfile, fetchFollowing, fetchHeatmapData, fetchHiddenApps, fetchMyRoadmapVotes, fetchNetworkStreamCount, fetchProfile, fetchReactionStatus, fetchRoadmapVotes, fetchSearchFilters, fetchSearchProfiles, fetchSimilarProfiles, fetchSkillSuggestions, fetchStats, fetchSuggestionCount, fetchSuggestions, sifaQueryKeys, useActivityFeed, useActivityTeaser, useAppAccountCheck, useAppsRegistry, useAtFundLink, useCreatePosition, useEndorsementCount, useFeaturedProfile, useFollowing, useHeatmapData, useHiddenApps, useMyRoadmapVotes, useNetworkStreamCount, useProfile, useReactionStatus, useRoadmapVotes, useSearchFilters, useSearchProfiles, useSifaConfig, useSimilarProfiles, useSkillSuggestions, useStats, useSuggestionCount, useSuggestions };
1795
+ export { ApiError, QUOTED_POSTS_BATCH_MAX, SifaProvider, apiFetch, apiFetchOrNull, apiWrite, apiWriteCreate, bulkHideStandardPublications, bulkUnhideStandardPublications, castRoadmapVote, checkAppAccount, createEducation, createEndorsement, createExternalAccount, createPosition, createProfileLocation, createReaction, createRecord, createSkill, deleteAccount, deleteAvatarOverride, deleteEducation, deleteExternalAccount, deletePosition, deleteProfileLocation, deleteReaction, deleteRecord, deleteSkill, fetchActivityFeed, fetchActivityTeaser, fetchAppsRegistry, fetchAtFundLink, fetchEndorsementCount, fetchExternalAccounts, fetchFeaturedProfile, fetchFollowing, fetchHeatmapData, fetchHiddenApps, fetchMyRoadmapVotes, fetchNetworkStreamCount, fetchProfile, fetchReactionStatus, fetchRoadmapVotes, fetchSearchFilters, fetchSearchProfiles, fetchSimilarProfiles, fetchSkillSuggestions, fetchStats, fetchSuggestionCount, fetchSuggestions, hideKeytraceClaim, hideOrcidPublication, hideSifaPublication, hideStandardPublication, linkSkillToPosition, refreshOrcidPublications, refreshPds, resetProfile, resolveQuotedPosts, retractRoadmapVote, searchSkills, setExternalAccountPrimary, setPositionPrimary, sifaQueryKeys, unhideKeytraceClaim, unhideOrcidPublication, unhideSifaPublication, unhideStandardPublication, unlinkSkillFromPosition, unsetExternalAccountPrimary, unsetPositionPrimary, updateEducation, updateExternalAccount, updatePosition, updateProfileLocation, updateProfileOverride, updateProfileSelf, updateRecord, updateSkill, uploadAvatar, useActivityFeed, useActivityTeaser, useAppAccountCheck, useAppsRegistry, useAtFundLink, useBulkHideStandardPublications, useBulkUnhideStandardPublications, useCanonicalSkillSearch, useCastRoadmapVote, useCreateEducation, useCreateEndorsement, useCreateExternalAccount, useCreatePosition, useCreateProfileLocation, useCreateReaction, useCreateRecord, useCreateSkill, useDeleteAccount, useDeleteAvatarOverride, useDeleteEducation, useDeleteExternalAccount, useDeletePosition, useDeleteProfileLocation, useDeleteReaction, useDeleteRecord, useDeleteSkill, useEndorsementCount, useExternalAccounts, useFeaturedProfile, useFollowing, useHeatmapData, useHiddenApps, useHideKeytraceClaim, useHideOrcidPublication, useHideSifaPublication, useHideStandardPublication, useLinkSkillToPosition, useMyRoadmapVotes, useNetworkStreamCount, useProfile, useReactionStatus, useRefreshOrcidPublications, useRefreshPds, useResetProfile, useRetractRoadmapVote, useRoadmapVotes, useSearchFilters, useSearchProfiles, useSetExternalAccountPrimary, useSetPositionPrimary, useSifaConfig, useSimilarProfiles, useSkillSuggestions, useStats, useSuggestionCount, useSuggestions, useUnhideKeytraceClaim, useUnhideOrcidPublication, useUnhideSifaPublication, useUnhideStandardPublication, useUnlinkSkillFromPosition, useUnsetExternalAccountPrimary, useUnsetPositionPrimary, useUpdateEducation, useUpdateExternalAccount, useUpdatePosition, useUpdateProfileLocation, useUpdateProfileOverride, useUpdateProfileSelf, useUpdateRecord, useUpdateSkill, useUploadAvatar, useVerifyExternalAccount, verifyExternalAccount };
709
1796
  //# sourceMappingURL=index.js.map
710
1797
  //# sourceMappingURL=index.js.map