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