@singi-labs/sifa-sdk 0.10.17 → 0.11.0
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 +11 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/{keys-CMaEcp0g.d.cts → keys-BDzlCEo1.d.cts} +41 -3
- package/dist/{keys-B_Z735bY.d.ts → keys-D1qvOp5Q.d.ts} +41 -3
- package/dist/query/fetchers/index.cjs +30 -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 -2
- package/dist/query/fetchers/index.js.map +1 -1
- package/dist/query/hooks/index.cjs +31 -3
- package/dist/query/hooks/index.cjs.map +1 -1
- package/dist/query/hooks/index.d.cts +10 -4
- package/dist/query/hooks/index.d.ts +10 -4
- package/dist/query/hooks/index.js +31 -3
- package/dist/query/hooks/index.js.map +1 -1
- package/dist/query/index.cjs +31 -3
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.d.cts +2 -2
- package/dist/query/index.d.ts +2 -2
- package/dist/query/index.js +31 -3
- package/dist/query/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { S as SifaApiConfig, s as sifaQueryKeys, W as WriteResult,
|
|
4
|
-
export {
|
|
3
|
+
import { S as SifaApiConfig, s as sifaQueryKeys, W as WriteResult, a5 as RefreshPdsResult, aj as UpdateProfileOverrideInput, ak as UpdateProfileSelfInput, al as UploadAvatarResult, j as CreateResult, U as ProfileLocationInput, k as ExternalAccountInput, i as CreateExternalAccountResult, am as VerifyExternalAccountResult, E as EndorsementInput, a4 as RefreshOrcidPublicationsResult, B as BulkHideProfileItemInput, P as HideProfileItemInput, ag as StatsResponse, g as AppRegistryEntry, M as HiddenApp, w as FilterOptions, ab as SearchFilters, ac as SearchResponse, af as SkillSearchResult, l as FeaturedProfile, ae as SimilarProfile, v as FetchSuggestionsOptions, ai as SuggestionsResponse, G as FollowUserResult, o as FetchFollowListOptions, x as FollowListPage, H as FollowingResponse, q as FetchFollowingFeedOptions, p as FetchFollowProfilePageOptions, z as FollowProfilePageResponse, F as FeatureAllowlistResponse, m as FetchActivityFeedOptions, b as ActivityFeedResponse, e as ActivityTeaserResponse, L as HeatmapResponse, a as AccountCheckResult, a3 as ReactionStatus, a2 as ReactionResult, a1 as ReactionError, aa as RoadmapVotesResponse, C as CastRoadmapVoteResult, D as DeleteAccountResult } from '../../keys-BDzlCEo1.cjs';
|
|
4
|
+
export { ad as SifaQueryKey } from '../../keys-BDzlCEo1.cjs';
|
|
5
5
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
6
6
|
import { UseQueryOptions, UseMutationOptions, UseInfiniteQueryOptions, InfiniteData } from '@tanstack/react-query';
|
|
7
7
|
import { c as Profile, r as ProfilePosition, w as SkillRef, E as ExternalAccount, S as SkillSuggestion } from '../../adult-content-o0BxhFzc.cjs';
|
|
@@ -459,8 +459,14 @@ declare function useRoadmapVotes(options?: Omit<UseQueryOptions<RoadmapVotesResp
|
|
|
459
459
|
/** Roadmap items the authenticated viewer has voted on. Returns `[]` data on error. */
|
|
460
460
|
declare function useMyRoadmapVotes(options?: Omit<UseQueryOptions<string[], Error, string[], ReturnType<typeof sifaQueryKeys.roadmap.myVotes>>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<NoInfer<string[]>, Error>;
|
|
461
461
|
|
|
462
|
-
/**
|
|
463
|
-
|
|
462
|
+
/**
|
|
463
|
+
* React hook for casting a roadmap vote. Variable: the item key.
|
|
464
|
+
*
|
|
465
|
+
* Returns the discriminated-union result so callers can detect
|
|
466
|
+
* `scope_insufficient` and trigger an OAuth scope-upgrade flow
|
|
467
|
+
* (see {@link castRoadmapVote}).
|
|
468
|
+
*/
|
|
469
|
+
declare function useCastRoadmapVote(options?: Omit<UseMutationOptions<CastRoadmapVoteResult, Error, string>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<CastRoadmapVoteResult, Error, string, unknown>;
|
|
464
470
|
/** React hook for retracting a previously-cast roadmap vote. */
|
|
465
471
|
declare function useRetractRoadmapVote(options?: Omit<UseMutationOptions<WriteResult, Error, string>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<WriteResult, Error, string, unknown>;
|
|
466
472
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { S as SifaApiConfig, s as sifaQueryKeys, W as WriteResult,
|
|
4
|
-
export {
|
|
3
|
+
import { S as SifaApiConfig, s as sifaQueryKeys, W as WriteResult, a5 as RefreshPdsResult, aj as UpdateProfileOverrideInput, ak as UpdateProfileSelfInput, al as UploadAvatarResult, j as CreateResult, U as ProfileLocationInput, k as ExternalAccountInput, i as CreateExternalAccountResult, am as VerifyExternalAccountResult, E as EndorsementInput, a4 as RefreshOrcidPublicationsResult, B as BulkHideProfileItemInput, P as HideProfileItemInput, ag as StatsResponse, g as AppRegistryEntry, M as HiddenApp, w as FilterOptions, ab as SearchFilters, ac as SearchResponse, af as SkillSearchResult, l as FeaturedProfile, ae as SimilarProfile, v as FetchSuggestionsOptions, ai as SuggestionsResponse, G as FollowUserResult, o as FetchFollowListOptions, x as FollowListPage, H as FollowingResponse, q as FetchFollowingFeedOptions, p as FetchFollowProfilePageOptions, z as FollowProfilePageResponse, F as FeatureAllowlistResponse, m as FetchActivityFeedOptions, b as ActivityFeedResponse, e as ActivityTeaserResponse, L as HeatmapResponse, a as AccountCheckResult, a3 as ReactionStatus, a2 as ReactionResult, a1 as ReactionError, aa as RoadmapVotesResponse, C as CastRoadmapVoteResult, D as DeleteAccountResult } from '../../keys-D1qvOp5Q.js';
|
|
4
|
+
export { ad as SifaQueryKey } from '../../keys-D1qvOp5Q.js';
|
|
5
5
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
6
6
|
import { UseQueryOptions, UseMutationOptions, UseInfiniteQueryOptions, InfiniteData } from '@tanstack/react-query';
|
|
7
7
|
import { c as Profile, r as ProfilePosition, w as SkillRef, E as ExternalAccount, S as SkillSuggestion } from '../../adult-content-o0BxhFzc.js';
|
|
@@ -459,8 +459,14 @@ declare function useRoadmapVotes(options?: Omit<UseQueryOptions<RoadmapVotesResp
|
|
|
459
459
|
/** Roadmap items the authenticated viewer has voted on. Returns `[]` data on error. */
|
|
460
460
|
declare function useMyRoadmapVotes(options?: Omit<UseQueryOptions<string[], Error, string[], ReturnType<typeof sifaQueryKeys.roadmap.myVotes>>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<NoInfer<string[]>, Error>;
|
|
461
461
|
|
|
462
|
-
/**
|
|
463
|
-
|
|
462
|
+
/**
|
|
463
|
+
* React hook for casting a roadmap vote. Variable: the item key.
|
|
464
|
+
*
|
|
465
|
+
* Returns the discriminated-union result so callers can detect
|
|
466
|
+
* `scope_insufficient` and trigger an OAuth scope-upgrade flow
|
|
467
|
+
* (see {@link castRoadmapVote}).
|
|
468
|
+
*/
|
|
469
|
+
declare function useCastRoadmapVote(options?: Omit<UseMutationOptions<CastRoadmapVoteResult, Error, string>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<CastRoadmapVoteResult, Error, string, unknown>;
|
|
464
470
|
/** React hook for retracting a previously-cast roadmap vote. */
|
|
465
471
|
declare function useRetractRoadmapVote(options?: Omit<UseMutationOptions<WriteResult, Error, string>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<WriteResult, Error, string, unknown>;
|
|
466
472
|
|
|
@@ -2143,8 +2143,36 @@ async function fetchMyRoadmapVotes(config, options = {}) {
|
|
|
2143
2143
|
return [];
|
|
2144
2144
|
}
|
|
2145
2145
|
}
|
|
2146
|
-
function castRoadmapVote(config, key, options = {}) {
|
|
2147
|
-
|
|
2146
|
+
async function castRoadmapVote(config, key, options = {}) {
|
|
2147
|
+
const fetchFn = config.fetch ?? globalThis.fetch;
|
|
2148
|
+
const url = `${config.baseUrl}/api/roadmap/votes/${encodeURIComponent(key)}`;
|
|
2149
|
+
try {
|
|
2150
|
+
const res = await fetchFn(url, {
|
|
2151
|
+
method: "POST",
|
|
2152
|
+
headers: { "Content-Type": "application/json", ...options.headers ?? {} },
|
|
2153
|
+
credentials: options.credentials ?? "include",
|
|
2154
|
+
signal: options.signal ?? AbortSignal.timeout(options.timeoutMs ?? 1e4)
|
|
2155
|
+
});
|
|
2156
|
+
if (!res.ok) {
|
|
2157
|
+
if (res.status === 403) {
|
|
2158
|
+
try {
|
|
2159
|
+
const body = await res.json();
|
|
2160
|
+
if (body.error === "ScopeInsufficient") {
|
|
2161
|
+
return {
|
|
2162
|
+
ok: false,
|
|
2163
|
+
error: { type: "scope_insufficient", requiredScope: body.requiredScope }
|
|
2164
|
+
};
|
|
2165
|
+
}
|
|
2166
|
+
} catch {
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
return { ok: false, error: { type: "error" } };
|
|
2170
|
+
}
|
|
2171
|
+
const data = await res.json();
|
|
2172
|
+
return { ok: true, data };
|
|
2173
|
+
} catch {
|
|
2174
|
+
return { ok: false, error: { type: "error" } };
|
|
2175
|
+
}
|
|
2148
2176
|
}
|
|
2149
2177
|
function retractRoadmapVote(config, key, options = {}) {
|
|
2150
2178
|
return apiWrite(config, `/api/roadmap/votes/${encodeURIComponent(key)}`, "DELETE", options);
|
|
@@ -2176,7 +2204,7 @@ function useCastRoadmapVote(options) {
|
|
|
2176
2204
|
return useMutation({
|
|
2177
2205
|
mutationFn: (key) => castRoadmapVote(config, key),
|
|
2178
2206
|
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
2179
|
-
if (result.
|
|
2207
|
+
if (result.ok) {
|
|
2180
2208
|
await invalidateRoadmap(queryClient);
|
|
2181
2209
|
}
|
|
2182
2210
|
await options?.onSuccess?.(result, variables, onMutateResult, context);
|