@singi-labs/sifa-sdk 0.12.38 → 0.12.39
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/badge/index.cjs +3 -0
- package/dist/badge/index.cjs.map +1 -1
- package/dist/badge/index.js +3 -0
- package/dist/badge/index.js.map +1 -1
- package/dist/{index-G5HiA-nk.d.cts → index-BPImvVQq.d.cts} +44 -2
- package/dist/{index-N0-ctbY1.d.ts → index-C1szgnQc.d.ts} +44 -2
- package/dist/{index-C-TwdQWh.d.cts → index-CO3z2uAZ.d.cts} +1 -1
- package/dist/{index-DzjbfKwZ.d.ts → index-DyffAaPT.d.ts} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{org-OPyzh-oe.d.cts → org-DPfmXSYv.d.cts} +24 -2
- package/dist/{org-BFi9g37U.d.ts → org-dEe3TbBJ.d.ts} +24 -2
- package/dist/query/fetchers/index.cjs +32 -2
- package/dist/query/fetchers/index.cjs.map +1 -1
- package/dist/query/fetchers/index.d.cts +2 -2
- package/dist/query/fetchers/index.d.ts +2 -2
- package/dist/query/fetchers/index.js +30 -3
- package/dist/query/fetchers/index.js.map +1 -1
- package/dist/query/hooks/index.cjs +8 -2
- package/dist/query/hooks/index.cjs.map +1 -1
- package/dist/query/hooks/index.d.cts +2 -2
- package/dist/query/hooks/index.d.ts +2 -2
- package/dist/query/hooks/index.js +8 -2
- package/dist/query/hooks/index.js.map +1 -1
- package/dist/query/index.cjs +83 -2
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.d.cts +28 -6
- package/dist/query/index.d.ts +28 -6
- package/dist/query/index.js +78 -3
- package/dist/query/index.js.map +1 -1
- package/package.json +1 -1
package/dist/query/index.cjs
CHANGED
|
@@ -72,6 +72,9 @@ async function apiFetch(config, path, options = {}) {
|
|
|
72
72
|
}
|
|
73
73
|
throw new ApiError(`Sifa API ${res.status} on ${path}`, res.status, errBody);
|
|
74
74
|
}
|
|
75
|
+
if (res.status === 204 || res.status === 205) {
|
|
76
|
+
return void 0;
|
|
77
|
+
}
|
|
75
78
|
return await res.json();
|
|
76
79
|
}
|
|
77
80
|
throw new ApiError(`Sifa API exhausted retries on ${path}`, 429);
|
|
@@ -433,7 +436,28 @@ function verifyExternalAccount(config, rkey, options = {}) {
|
|
|
433
436
|
|
|
434
437
|
// src/query/fetchers/endorsements.ts
|
|
435
438
|
function createEndorsement(config, data, options = {}) {
|
|
436
|
-
return apiWriteCreate(config, "/api/
|
|
439
|
+
return apiWriteCreate(config, "/api/endorsement", data, options);
|
|
440
|
+
}
|
|
441
|
+
function confirmEndorsement(config, data, options = {}) {
|
|
442
|
+
return apiWriteCreate(config, "/api/endorsement/confirm", data, options);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// src/query/fetchers/endorsement-inbox.ts
|
|
446
|
+
async function fetchPendingEndorsements(config, options = {}) {
|
|
447
|
+
try {
|
|
448
|
+
const data = await apiFetch(config, "/api/endorsements/pending", {
|
|
449
|
+
cache: "no-store",
|
|
450
|
+
credentials: "include",
|
|
451
|
+
timeoutMs: 5e3,
|
|
452
|
+
...options
|
|
453
|
+
});
|
|
454
|
+
return { endorsements: data?.endorsements ?? [], cursor: data?.cursor };
|
|
455
|
+
} catch {
|
|
456
|
+
return { endorsements: [] };
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
function dismissEndorsement(config, data, options = {}) {
|
|
460
|
+
return apiWrite(config, "/api/endorsement/dismiss", "POST", { body: data, ...options });
|
|
437
461
|
}
|
|
438
462
|
|
|
439
463
|
// src/query/fetchers/actor.ts
|
|
@@ -1411,7 +1435,10 @@ var sifaQueryKeys = {
|
|
|
1411
1435
|
},
|
|
1412
1436
|
endorsement: {
|
|
1413
1437
|
all: () => ["sifa", "endorsement"],
|
|
1414
|
-
count: (did) => ["sifa", "endorsement", "count", did]
|
|
1438
|
+
count: (did) => ["sifa", "endorsement", "count", did],
|
|
1439
|
+
// Scoped to the session rather than a DID -- the AppView reads the subject
|
|
1440
|
+
// from the session cookie, so there is only ever one inbox per client.
|
|
1441
|
+
pending: () => ["sifa", "endorsement", "pending"]
|
|
1415
1442
|
},
|
|
1416
1443
|
stream: {
|
|
1417
1444
|
all: () => ["sifa", "stream"],
|
|
@@ -1973,6 +2000,54 @@ function useCreateEndorsement(endorsedHandleOrDid, options) {
|
|
|
1973
2000
|
...options
|
|
1974
2001
|
});
|
|
1975
2002
|
}
|
|
2003
|
+
function usePendingEndorsements(options) {
|
|
2004
|
+
const config = useSifaConfig();
|
|
2005
|
+
return reactQuery.useQuery({
|
|
2006
|
+
queryKey: sifaQueryKeys.endorsement.pending(),
|
|
2007
|
+
queryFn: () => fetchPendingEndorsements(config),
|
|
2008
|
+
...options
|
|
2009
|
+
});
|
|
2010
|
+
}
|
|
2011
|
+
function useConfirmEndorsement(subjectHandleOrDid, options) {
|
|
2012
|
+
const config = useSifaConfig();
|
|
2013
|
+
const queryClient = reactQuery.useQueryClient();
|
|
2014
|
+
return reactQuery.useMutation({
|
|
2015
|
+
mutationFn: (data) => confirmEndorsement(config, data),
|
|
2016
|
+
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
2017
|
+
if (result.success) {
|
|
2018
|
+
await queryClient.invalidateQueries({
|
|
2019
|
+
queryKey: sifaQueryKeys.endorsement.pending()
|
|
2020
|
+
});
|
|
2021
|
+
if (subjectHandleOrDid) {
|
|
2022
|
+
await queryClient.invalidateQueries({
|
|
2023
|
+
queryKey: sifaQueryKeys.profile.byHandle(subjectHandleOrDid)
|
|
2024
|
+
});
|
|
2025
|
+
await queryClient.invalidateQueries({
|
|
2026
|
+
queryKey: sifaQueryKeys.endorsement.count(subjectHandleOrDid)
|
|
2027
|
+
});
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
2031
|
+
},
|
|
2032
|
+
...options
|
|
2033
|
+
});
|
|
2034
|
+
}
|
|
2035
|
+
function useDismissEndorsement(options) {
|
|
2036
|
+
const config = useSifaConfig();
|
|
2037
|
+
const queryClient = reactQuery.useQueryClient();
|
|
2038
|
+
return reactQuery.useMutation({
|
|
2039
|
+
mutationFn: (data) => dismissEndorsement(config, data),
|
|
2040
|
+
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
2041
|
+
if (result.success) {
|
|
2042
|
+
await queryClient.invalidateQueries({
|
|
2043
|
+
queryKey: sifaQueryKeys.endorsement.pending()
|
|
2044
|
+
});
|
|
2045
|
+
}
|
|
2046
|
+
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
2047
|
+
},
|
|
2048
|
+
...options
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
1976
2051
|
async function invalidateProfile6(queryClient, ownerHandleOrDid) {
|
|
1977
2052
|
await queryClient.invalidateQueries({
|
|
1978
2053
|
queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
|
|
@@ -2841,6 +2916,7 @@ exports.bulkUnhideStandardPublications = bulkUnhideStandardPublications;
|
|
|
2841
2916
|
exports.castRoadmapVote = castRoadmapVote;
|
|
2842
2917
|
exports.checkAppAccount = checkAppAccount;
|
|
2843
2918
|
exports.checkNetworkMapJobStatus = checkNetworkMapJobStatus;
|
|
2919
|
+
exports.confirmEndorsement = confirmEndorsement;
|
|
2844
2920
|
exports.createEducation = createEducation;
|
|
2845
2921
|
exports.createEndorsement = createEndorsement;
|
|
2846
2922
|
exports.createExternalAccount = createExternalAccount;
|
|
@@ -2858,6 +2934,7 @@ exports.deleteProfileLocation = deleteProfileLocation;
|
|
|
2858
2934
|
exports.deleteReaction = deleteReaction;
|
|
2859
2935
|
exports.deleteRecord = deleteRecord;
|
|
2860
2936
|
exports.deleteSkill = deleteSkill;
|
|
2937
|
+
exports.dismissEndorsement = dismissEndorsement;
|
|
2861
2938
|
exports.effectiveContentVisibility = effectiveContentVisibility;
|
|
2862
2939
|
exports.fetchActivityFeed = fetchActivityFeed;
|
|
2863
2940
|
exports.fetchActivityTeaser = fetchActivityTeaser;
|
|
@@ -2876,6 +2953,7 @@ exports.fetchMyGithubPullRequests = fetchMyGithubPullRequests;
|
|
|
2876
2953
|
exports.fetchMyRoadmapVotes = fetchMyRoadmapVotes;
|
|
2877
2954
|
exports.fetchNetworkMap = fetchNetworkMap;
|
|
2878
2955
|
exports.fetchNetworkStreamCount = fetchNetworkStreamCount;
|
|
2956
|
+
exports.fetchPendingEndorsements = fetchPendingEndorsements;
|
|
2879
2957
|
exports.fetchProfile = fetchProfile;
|
|
2880
2958
|
exports.fetchProfileSummary = fetchProfileSummary;
|
|
2881
2959
|
exports.fetchReactionStatus = fetchReactionStatus;
|
|
@@ -2960,6 +3038,7 @@ exports.useBulkUnhideProfileItems = useBulkUnhideProfileItems;
|
|
|
2960
3038
|
exports.useBulkUnhideStandardPublications = useBulkUnhideStandardPublications;
|
|
2961
3039
|
exports.useCanonicalSkillSearch = useCanonicalSkillSearch;
|
|
2962
3040
|
exports.useCastRoadmapVote = useCastRoadmapVote;
|
|
3041
|
+
exports.useConfirmEndorsement = useConfirmEndorsement;
|
|
2963
3042
|
exports.useCreateEducation = useCreateEducation;
|
|
2964
3043
|
exports.useCreateEndorsement = useCreateEndorsement;
|
|
2965
3044
|
exports.useCreateExternalAccount = useCreateExternalAccount;
|
|
@@ -2978,6 +3057,7 @@ exports.useDeleteProfileLocation = useDeleteProfileLocation;
|
|
|
2978
3057
|
exports.useDeleteReaction = useDeleteReaction;
|
|
2979
3058
|
exports.useDeleteRecord = useDeleteRecord;
|
|
2980
3059
|
exports.useDeleteSkill = useDeleteSkill;
|
|
3060
|
+
exports.useDismissEndorsement = useDismissEndorsement;
|
|
2981
3061
|
exports.useEndorsementCount = useEndorsementCount;
|
|
2982
3062
|
exports.useEntitySearch = useEntitySearch;
|
|
2983
3063
|
exports.useExternalAccounts = useExternalAccounts;
|
|
@@ -3007,6 +3087,7 @@ exports.useOrgClaim = useOrgClaim;
|
|
|
3007
3087
|
exports.useOrgDomainChallenge = useOrgDomainChallenge;
|
|
3008
3088
|
exports.useOrgDomainVerify = useOrgDomainVerify;
|
|
3009
3089
|
exports.useOrgProfile = useOrgProfile;
|
|
3090
|
+
exports.usePendingEndorsements = usePendingEndorsements;
|
|
3010
3091
|
exports.useProfile = useProfile;
|
|
3011
3092
|
exports.useReactionStatus = useReactionStatus;
|
|
3012
3093
|
exports.useRefreshOrcidPublications = useRefreshOrcidPublications;
|