@singi-labs/sifa-sdk 0.7.2 → 0.7.4

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,44 @@ 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
+ }
413
780
 
414
781
  // src/query/fetchers/quoted-posts.ts
415
782
  var QUOTED_POSTS_BATCH_MAX = 20;
@@ -471,6 +838,26 @@ async function fetchMyRoadmapVotes(config, options = {}) {
471
838
  return [];
472
839
  }
473
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
+ }
474
861
 
475
862
  // src/query/keys.ts
476
863
  var sifaQueryKeys = {
@@ -478,7 +865,8 @@ var sifaQueryKeys = {
478
865
  profile: {
479
866
  all: () => ["sifa", "profile"],
480
867
  byHandle: (handleOrDid) => ["sifa", "profile", handleOrDid],
481
- 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]
482
870
  },
483
871
  position: {
484
872
  all: () => ["sifa", "position"],
@@ -488,6 +876,7 @@ var sifaQueryKeys = {
488
876
  all: () => ["sifa", "search"],
489
877
  profiles: (filters) => ["sifa", "search", "profiles", filters],
490
878
  skills: (query) => ["sifa", "search", "skills", query],
879
+ canonicalSkills: (query, limit) => ["sifa", "search", "canonical-skills", query, limit],
491
880
  filters: () => ["sifa", "search", "filters"]
492
881
  },
493
882
  discovery: {
@@ -555,93 +944,669 @@ function useAtFundLink(did, options) {
555
944
  ...options
556
945
  });
557
946
  }
558
- 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) {
559
953
  const config = useSifaConfig();
560
954
  const queryClient = useQueryClient();
561
955
  return useMutation({
562
- mutationFn: (data) => createPosition(config, data),
956
+ mutationFn: (data) => updateProfileSelf(config, data),
563
957
  onSuccess: async (result, variables, onMutateResult, context) => {
564
958
  if (result.success) {
565
- await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.profile.byHandle(ownerDid) });
566
- await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.position.byOwner(ownerDid) });
959
+ await invalidateProfile(queryClient, ownerHandleOrDid);
567
960
  }
568
961
  await options?.onSuccess?.(result, variables, onMutateResult, context);
569
962
  },
570
963
  ...options
571
964
  });
572
965
  }
573
- function useStats(options) {
966
+ function useUpdateProfileOverride(ownerHandleOrDid, options) {
574
967
  const config = useSifaConfig();
575
- return useQuery({
576
- queryKey: sifaQueryKeys.stats.homepage(),
577
- 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
+ },
578
977
  ...options
579
978
  });
580
979
  }
581
- function useAppsRegistry(options) {
980
+ function useRefreshPds(ownerHandleOrDid, options) {
582
981
  const config = useSifaConfig();
583
- return useQuery({
584
- queryKey: sifaQueryKeys.apps.registry(),
585
- 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
+ },
586
991
  ...options
587
992
  });
588
993
  }
589
- function useHiddenApps(options) {
994
+ function useUploadAvatar(ownerHandleOrDid, options) {
590
995
  const config = useSifaConfig();
591
- return useQuery({
592
- queryKey: sifaQueryKeys.apps.hidden(),
593
- 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
+ },
594
1005
  ...options
595
1006
  });
596
1007
  }
597
- function useSearchProfiles(filters, options) {
1008
+ function useDeleteAvatarOverride(ownerHandleOrDid, options) {
598
1009
  const config = useSifaConfig();
599
- return useQuery({
600
- queryKey: sifaQueryKeys.search.profiles(filters),
601
- 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
+ },
602
1019
  ...options
603
1020
  });
604
1021
  }
605
- function useSkillSuggestions(query, options) {
1022
+ function useCreatePosition(ownerDid, options) {
606
1023
  const config = useSifaConfig();
607
- return useQuery({
608
- queryKey: sifaQueryKeys.search.skills(query),
609
- queryFn: () => fetchSkillSuggestions(config, query),
610
- 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
+ },
611
1034
  ...options
612
1035
  });
613
1036
  }
614
- function useSearchFilters(options) {
615
- const config = useSifaConfig();
616
- return useQuery({
617
- queryKey: sifaQueryKeys.search.filters(),
618
- queryFn: () => fetchSearchFilters(config),
619
- ...options
1037
+ async function invalidatePositionCaches(queryClient, ownerHandleOrDid) {
1038
+ await queryClient.invalidateQueries({
1039
+ queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
1040
+ });
1041
+ await queryClient.invalidateQueries({
1042
+ queryKey: sifaQueryKeys.position.byOwner(ownerHandleOrDid)
620
1043
  });
621
1044
  }
622
- function useSimilarProfiles(did, opts = {}, options) {
1045
+ function useUpdatePosition(ownerHandleOrDid, options) {
623
1046
  const config = useSifaConfig();
624
- const limit = opts.limit ?? 5;
625
- return useQuery({
626
- queryKey: sifaQueryKeys.discovery.similar(did ?? "", limit),
627
- queryFn: () => fetchSimilarProfiles(config, did ?? "", { limit }),
628
- enabled: Boolean(did) && (options?.enabled ?? true),
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
+ },
629
1056
  ...options
630
1057
  });
631
1058
  }
632
- function useSuggestions(opts = {}, options) {
1059
+ function useDeletePosition(ownerHandleOrDid, options) {
633
1060
  const config = useSifaConfig();
634
- return useQuery({
635
- queryKey: sifaQueryKeys.discovery.suggestions(opts),
636
- queryFn: () => fetchSuggestions(config, opts),
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
+ },
637
1070
  ...options
638
1071
  });
639
1072
  }
640
- function useSuggestionCount(since, options) {
1073
+ function useSetPositionPrimary(ownerHandleOrDid, options) {
641
1074
  const config = useSifaConfig();
642
- return useQuery({
643
- queryKey: sifaQueryKeys.discovery.suggestionCount(since),
644
- queryFn: () => fetchSuggestionCount(config, since),
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
+ },
1084
+ ...options
1085
+ });
1086
+ }
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),
645
1610
  ...options
646
1611
  });
647
1612
  }
@@ -723,6 +1688,34 @@ function useAppAccountCheck(appId, options) {
723
1688
  ...options
724
1689
  });
725
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
+ }
726
1719
  function useRoadmapVotes(options) {
727
1720
  const config = useSifaConfig();
728
1721
  return useQuery({
@@ -739,7 +1732,66 @@ function useMyRoadmapVotes(options) {
739
1732
  ...options
740
1733
  });
741
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
+ }
742
1794
 
743
- export { ApiError, QUOTED_POSTS_BATCH_MAX, 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, resolveQuotedPosts, 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 };
744
1796
  //# sourceMappingURL=index.js.map
745
1797
  //# sourceMappingURL=index.js.map