@singi-labs/sifa-sdk 0.10.18 → 0.11.1
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 +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- 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
|
@@ -986,8 +986,46 @@ interface FetchMyRoadmapVotesOptions extends ApiFetchOptions {
|
|
|
986
986
|
* error or when the response payload is shaped unexpectedly.
|
|
987
987
|
*/
|
|
988
988
|
declare function fetchMyRoadmapVotes(config: SifaApiConfig, options?: FetchMyRoadmapVotesOptions): Promise<string[]>;
|
|
989
|
-
/**
|
|
990
|
-
|
|
989
|
+
/** Result of a successful {@link castRoadmapVote} -- the created upvote record. */
|
|
990
|
+
interface RoadmapVoteResult {
|
|
991
|
+
uri: string;
|
|
992
|
+
rkey: string;
|
|
993
|
+
}
|
|
994
|
+
/** Structured error returned by {@link castRoadmapVote} on failure. */
|
|
995
|
+
interface RoadmapVoteError {
|
|
996
|
+
type: 'scope_insufficient' | 'error';
|
|
997
|
+
/**
|
|
998
|
+
* When `type === 'scope_insufficient'`, the lexicon collection the user must
|
|
999
|
+
* re-authorize for (e.g. `app.userinput.upvote`). sifa-web maps this to an
|
|
1000
|
+
* OAuth scope-upgrade flow (`/oauth/reauth?scope=repo:<collection>`).
|
|
1001
|
+
*/
|
|
1002
|
+
requiredScope?: string;
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Discriminated-union result of {@link castRoadmapVote}. Exported so the
|
|
1006
|
+
* `useCastRoadmapVote` hook and SDK consumers can type mutation handlers
|
|
1007
|
+
* against a single source of truth.
|
|
1008
|
+
*/
|
|
1009
|
+
type CastRoadmapVoteResult = {
|
|
1010
|
+
ok: true;
|
|
1011
|
+
data: RoadmapVoteResult;
|
|
1012
|
+
} | {
|
|
1013
|
+
ok: false;
|
|
1014
|
+
error: RoadmapVoteError;
|
|
1015
|
+
};
|
|
1016
|
+
/**
|
|
1017
|
+
* Cast a vote on a roadmap item by its key.
|
|
1018
|
+
*
|
|
1019
|
+
* Writes an `app.userinput.upvote` record into the viewer's PDS (server-side,
|
|
1020
|
+
* via their OAuth session). Returns a discriminated-union result rather than
|
|
1021
|
+
* the generic {@link WriteResult} because a first-time voter's PDS grant may
|
|
1022
|
+
* not yet include the `app.userinput.upvote` collection: the AppView responds
|
|
1023
|
+
* 403 `ScopeInsufficient`, which the caller handles by triggering an OAuth
|
|
1024
|
+
* scope upgrade rather than showing an error. Mirrors {@link createReaction}.
|
|
1025
|
+
*
|
|
1026
|
+
* Never throws.
|
|
1027
|
+
*/
|
|
1028
|
+
declare function castRoadmapVote(config: SifaApiConfig, key: string, options?: ApiFetchOptions): Promise<CastRoadmapVoteResult>;
|
|
991
1029
|
/** Retract a previously-cast roadmap vote. */
|
|
992
1030
|
declare function retractRoadmapVote(config: SifaApiConfig, key: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
993
1031
|
|
|
@@ -1110,4 +1148,4 @@ declare const sifaQueryKeys: {
|
|
|
1110
1148
|
};
|
|
1111
1149
|
type SifaQueryKey = ReturnType<typeof sifaQueryKeys.all> | ReturnType<typeof sifaQueryKeys.profile.all> | ReturnType<typeof sifaQueryKeys.profile.byHandle> | ReturnType<typeof sifaQueryKeys.profile.atFundLink> | ReturnType<typeof sifaQueryKeys.profile.externalAccounts> | ReturnType<typeof sifaQueryKeys.position.all> | ReturnType<typeof sifaQueryKeys.position.byOwner> | ReturnType<typeof sifaQueryKeys.search.all> | ReturnType<typeof sifaQueryKeys.search.profiles> | ReturnType<typeof sifaQueryKeys.search.canonicalSkills> | ReturnType<typeof sifaQueryKeys.search.skills> | ReturnType<typeof sifaQueryKeys.search.filters> | ReturnType<typeof sifaQueryKeys.discovery.all> | ReturnType<typeof sifaQueryKeys.discovery.similar> | ReturnType<typeof sifaQueryKeys.discovery.suggestions> | ReturnType<typeof sifaQueryKeys.discovery.suggestionCount> | ReturnType<typeof sifaQueryKeys.discovery.featured> | ReturnType<typeof sifaQueryKeys.follow.all> | ReturnType<typeof sifaQueryKeys.follow.following> | ReturnType<typeof sifaQueryKeys.follow.followers> | ReturnType<typeof sifaQueryKeys.follow.followingOf> | ReturnType<typeof sifaQueryKeys.follow.feed> | ReturnType<typeof sifaQueryKeys.follow.mutuals> | ReturnType<typeof sifaQueryKeys.follow.blueskySuggestions> | ReturnType<typeof sifaQueryKeys.admin.all> | ReturnType<typeof sifaQueryKeys.admin.featureAllowlist> | ReturnType<typeof sifaQueryKeys.stats.all> | ReturnType<typeof sifaQueryKeys.stats.homepage> | ReturnType<typeof sifaQueryKeys.apps.all> | ReturnType<typeof sifaQueryKeys.apps.registry> | ReturnType<typeof sifaQueryKeys.apps.hidden> | ReturnType<typeof sifaQueryKeys.activity.all> | ReturnType<typeof sifaQueryKeys.activity.heatmap> | ReturnType<typeof sifaQueryKeys.activity.teaser> | ReturnType<typeof sifaQueryKeys.activity.feed> | ReturnType<typeof sifaQueryKeys.endorsement.all> | ReturnType<typeof sifaQueryKeys.endorsement.count> | ReturnType<typeof sifaQueryKeys.stream.all> | ReturnType<typeof sifaQueryKeys.stream.networkCount> | ReturnType<typeof sifaQueryKeys.reactions.all> | ReturnType<typeof sifaQueryKeys.reactions.status> | ReturnType<typeof sifaQueryKeys.reactions.accountCheck> | ReturnType<typeof sifaQueryKeys.roadmap.all> | ReturnType<typeof sifaQueryKeys.roadmap.votes> | ReturnType<typeof sifaQueryKeys.roadmap.myVotes> | ReturnType<typeof sifaQueryKeys.bskyPreferences.all> | ReturnType<typeof sifaQueryKeys.bskyPreferences.contentLabels>;
|
|
1112
1150
|
|
|
1113
|
-
export { type
|
|
1151
|
+
export { type QuotedPostResult as $, type ApiFetchOptions as A, type BulkHideProfileItemInput as B, type CastRoadmapVoteResult as C, type DeleteAccountResult as D, type EndorsementInput as E, type FeatureAllowlistResponse as F, type FollowUserResult as G, type FollowingResponse as H, HIDDEN_ITEM_SOURCES as I, HIDDEN_ITEM_TYPES as J, type HeatmapDay as K, type HeatmapResponse as L, type HiddenApp as M, type HiddenItemSource as N, type HiddenItemType as O, type HideProfileItemInput as P, type ListFeatureAllowlistOptions as Q, type ProfileIndustryInput as R, type SifaApiConfig as S, type ProfileLocationAddress as T, type ProfileLocationInput as U, type ProfileSearchResult as V, type WriteResult as W, type ProfileSelfLocation as X, QUOTED_POSTS_BATCH_MAX as Y, type QuotedPostAuthor as Z, type QuotedPostImage as _, type AccountCheckResult as a, getFollowers as a$, type QuotedPostView as a0, type ReactionError as a1, type ReactionResult as a2, type ReactionStatus as a3, type RefreshOrcidPublicationsResult as a4, type RefreshPdsResult as a5, type ResolveQuotedPostsOptions as a6, type RoadmapVoteError as a7, type RoadmapVoteResult as a8, type RoadmapVoter as a9, createProfileLocation as aA, createReaction as aB, deleteAccount as aC, deleteAvatarOverride as aD, deleteExternalAccount as aE, deleteProfileLocation as aF, deleteReaction as aG, fetchActivityFeed as aH, fetchActivityTeaser as aI, fetchAppsRegistry as aJ, fetchExternalAccounts as aK, fetchFeaturedProfile as aL, fetchFollowing as aM, fetchHeatmapData as aN, fetchHiddenApps as aO, fetchMyRoadmapVotes as aP, fetchReactionStatus as aQ, fetchRoadmapVotes as aR, fetchSearchFilters as aS, fetchSearchProfiles as aT, fetchSimilarProfiles as aU, fetchSkillSuggestions as aV, fetchStats as aW, fetchSuggestionCount as aX, fetchSuggestions as aY, followUser as aZ, getBlueskySuggestions as a_, type RoadmapVotesResponse as aa, type SearchFilters as ab, type SearchResponse as ac, type SifaQueryKey as ad, type SimilarProfile as ae, type SkillSearchResult as af, type StatsResponse as ag, type SuggestionProfile as ah, type SuggestionsResponse as ai, type UpdateProfileOverrideInput as aj, type UpdateProfileSelfInput as ak, type UploadAvatarResult as al, type VerifyExternalAccountResult as am, addFeatureAllowlist as an, apiFetch as ao, apiFetchOrNull as ap, apiWrite as aq, apiWriteCreate as ar, bulkHideProfileItems as as, bulkHideStandardPublications as at, bulkUnhideProfileItems as au, bulkUnhideStandardPublications as av, castRoadmapVote as aw, checkAppAccount as ax, createEndorsement as ay, createExternalAccount as az, type ActivityFeedResponse as b, getFollowing as b0, getFollowingFeed as b1, getMutuals as b2, hideOrcidPublication as b3, hideProfileItem as b4, hideSifaPublication as b5, hideStandardPublication as b6, listFeatureAllowlist as b7, refreshOrcidPublications as b8, refreshPds as b9, removeFeatureAllowlist as ba, resetProfile as bb, resolveQuotedPosts as bc, retractRoadmapVote as bd, searchSkills as be, setExternalAccountPrimary as bf, unfollowUser as bg, unhideOrcidPublication as bh, unhideProfileItem as bi, unhideSifaPublication as bj, unhideStandardPublication as bk, unsetExternalAccountPrimary as bl, updateExternalAccount as bm, updateProfileLocation as bn, updateProfileOverride as bo, updateProfileSelf as bp, uploadAvatar as bq, verifyExternalAccount as br, type ActivityItem as c, type ActivityItemLinkHealth as d, type ActivityTeaserResponse as e, ApiError as f, type AppRegistryEntry as g, type CheckAppAccountOptions as h, type CreateExternalAccountResult as i, type CreateResult as j, type ExternalAccountInput as k, type FeaturedProfile as l, type FetchActivityFeedOptions as m, type FetchActivityTeaserOptions as n, type FetchFollowListOptions as o, type FetchFollowProfilePageOptions as p, type FetchFollowingFeedOptions as q, type FetchHiddenAppsOptions as r, sifaQueryKeys as s, type FetchMyRoadmapVotesOptions as t, type FetchReactionStatusOptions as u, type FetchSuggestionsOptions as v, type FilterOptions as w, type FollowListPage as x, type FollowProfile as y, type FollowProfilePageResponse as z };
|
|
@@ -986,8 +986,46 @@ interface FetchMyRoadmapVotesOptions extends ApiFetchOptions {
|
|
|
986
986
|
* error or when the response payload is shaped unexpectedly.
|
|
987
987
|
*/
|
|
988
988
|
declare function fetchMyRoadmapVotes(config: SifaApiConfig, options?: FetchMyRoadmapVotesOptions): Promise<string[]>;
|
|
989
|
-
/**
|
|
990
|
-
|
|
989
|
+
/** Result of a successful {@link castRoadmapVote} -- the created upvote record. */
|
|
990
|
+
interface RoadmapVoteResult {
|
|
991
|
+
uri: string;
|
|
992
|
+
rkey: string;
|
|
993
|
+
}
|
|
994
|
+
/** Structured error returned by {@link castRoadmapVote} on failure. */
|
|
995
|
+
interface RoadmapVoteError {
|
|
996
|
+
type: 'scope_insufficient' | 'error';
|
|
997
|
+
/**
|
|
998
|
+
* When `type === 'scope_insufficient'`, the lexicon collection the user must
|
|
999
|
+
* re-authorize for (e.g. `app.userinput.upvote`). sifa-web maps this to an
|
|
1000
|
+
* OAuth scope-upgrade flow (`/oauth/reauth?scope=repo:<collection>`).
|
|
1001
|
+
*/
|
|
1002
|
+
requiredScope?: string;
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Discriminated-union result of {@link castRoadmapVote}. Exported so the
|
|
1006
|
+
* `useCastRoadmapVote` hook and SDK consumers can type mutation handlers
|
|
1007
|
+
* against a single source of truth.
|
|
1008
|
+
*/
|
|
1009
|
+
type CastRoadmapVoteResult = {
|
|
1010
|
+
ok: true;
|
|
1011
|
+
data: RoadmapVoteResult;
|
|
1012
|
+
} | {
|
|
1013
|
+
ok: false;
|
|
1014
|
+
error: RoadmapVoteError;
|
|
1015
|
+
};
|
|
1016
|
+
/**
|
|
1017
|
+
* Cast a vote on a roadmap item by its key.
|
|
1018
|
+
*
|
|
1019
|
+
* Writes an `app.userinput.upvote` record into the viewer's PDS (server-side,
|
|
1020
|
+
* via their OAuth session). Returns a discriminated-union result rather than
|
|
1021
|
+
* the generic {@link WriteResult} because a first-time voter's PDS grant may
|
|
1022
|
+
* not yet include the `app.userinput.upvote` collection: the AppView responds
|
|
1023
|
+
* 403 `ScopeInsufficient`, which the caller handles by triggering an OAuth
|
|
1024
|
+
* scope upgrade rather than showing an error. Mirrors {@link createReaction}.
|
|
1025
|
+
*
|
|
1026
|
+
* Never throws.
|
|
1027
|
+
*/
|
|
1028
|
+
declare function castRoadmapVote(config: SifaApiConfig, key: string, options?: ApiFetchOptions): Promise<CastRoadmapVoteResult>;
|
|
991
1029
|
/** Retract a previously-cast roadmap vote. */
|
|
992
1030
|
declare function retractRoadmapVote(config: SifaApiConfig, key: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
993
1031
|
|
|
@@ -1110,4 +1148,4 @@ declare const sifaQueryKeys: {
|
|
|
1110
1148
|
};
|
|
1111
1149
|
type SifaQueryKey = ReturnType<typeof sifaQueryKeys.all> | ReturnType<typeof sifaQueryKeys.profile.all> | ReturnType<typeof sifaQueryKeys.profile.byHandle> | ReturnType<typeof sifaQueryKeys.profile.atFundLink> | ReturnType<typeof sifaQueryKeys.profile.externalAccounts> | ReturnType<typeof sifaQueryKeys.position.all> | ReturnType<typeof sifaQueryKeys.position.byOwner> | ReturnType<typeof sifaQueryKeys.search.all> | ReturnType<typeof sifaQueryKeys.search.profiles> | ReturnType<typeof sifaQueryKeys.search.canonicalSkills> | ReturnType<typeof sifaQueryKeys.search.skills> | ReturnType<typeof sifaQueryKeys.search.filters> | ReturnType<typeof sifaQueryKeys.discovery.all> | ReturnType<typeof sifaQueryKeys.discovery.similar> | ReturnType<typeof sifaQueryKeys.discovery.suggestions> | ReturnType<typeof sifaQueryKeys.discovery.suggestionCount> | ReturnType<typeof sifaQueryKeys.discovery.featured> | ReturnType<typeof sifaQueryKeys.follow.all> | ReturnType<typeof sifaQueryKeys.follow.following> | ReturnType<typeof sifaQueryKeys.follow.followers> | ReturnType<typeof sifaQueryKeys.follow.followingOf> | ReturnType<typeof sifaQueryKeys.follow.feed> | ReturnType<typeof sifaQueryKeys.follow.mutuals> | ReturnType<typeof sifaQueryKeys.follow.blueskySuggestions> | ReturnType<typeof sifaQueryKeys.admin.all> | ReturnType<typeof sifaQueryKeys.admin.featureAllowlist> | ReturnType<typeof sifaQueryKeys.stats.all> | ReturnType<typeof sifaQueryKeys.stats.homepage> | ReturnType<typeof sifaQueryKeys.apps.all> | ReturnType<typeof sifaQueryKeys.apps.registry> | ReturnType<typeof sifaQueryKeys.apps.hidden> | ReturnType<typeof sifaQueryKeys.activity.all> | ReturnType<typeof sifaQueryKeys.activity.heatmap> | ReturnType<typeof sifaQueryKeys.activity.teaser> | ReturnType<typeof sifaQueryKeys.activity.feed> | ReturnType<typeof sifaQueryKeys.endorsement.all> | ReturnType<typeof sifaQueryKeys.endorsement.count> | ReturnType<typeof sifaQueryKeys.stream.all> | ReturnType<typeof sifaQueryKeys.stream.networkCount> | ReturnType<typeof sifaQueryKeys.reactions.all> | ReturnType<typeof sifaQueryKeys.reactions.status> | ReturnType<typeof sifaQueryKeys.reactions.accountCheck> | ReturnType<typeof sifaQueryKeys.roadmap.all> | ReturnType<typeof sifaQueryKeys.roadmap.votes> | ReturnType<typeof sifaQueryKeys.roadmap.myVotes> | ReturnType<typeof sifaQueryKeys.bskyPreferences.all> | ReturnType<typeof sifaQueryKeys.bskyPreferences.contentLabels>;
|
|
1112
1150
|
|
|
1113
|
-
export { type
|
|
1151
|
+
export { type QuotedPostResult as $, type ApiFetchOptions as A, type BulkHideProfileItemInput as B, type CastRoadmapVoteResult as C, type DeleteAccountResult as D, type EndorsementInput as E, type FeatureAllowlistResponse as F, type FollowUserResult as G, type FollowingResponse as H, HIDDEN_ITEM_SOURCES as I, HIDDEN_ITEM_TYPES as J, type HeatmapDay as K, type HeatmapResponse as L, type HiddenApp as M, type HiddenItemSource as N, type HiddenItemType as O, type HideProfileItemInput as P, type ListFeatureAllowlistOptions as Q, type ProfileIndustryInput as R, type SifaApiConfig as S, type ProfileLocationAddress as T, type ProfileLocationInput as U, type ProfileSearchResult as V, type WriteResult as W, type ProfileSelfLocation as X, QUOTED_POSTS_BATCH_MAX as Y, type QuotedPostAuthor as Z, type QuotedPostImage as _, type AccountCheckResult as a, getFollowers as a$, type QuotedPostView as a0, type ReactionError as a1, type ReactionResult as a2, type ReactionStatus as a3, type RefreshOrcidPublicationsResult as a4, type RefreshPdsResult as a5, type ResolveQuotedPostsOptions as a6, type RoadmapVoteError as a7, type RoadmapVoteResult as a8, type RoadmapVoter as a9, createProfileLocation as aA, createReaction as aB, deleteAccount as aC, deleteAvatarOverride as aD, deleteExternalAccount as aE, deleteProfileLocation as aF, deleteReaction as aG, fetchActivityFeed as aH, fetchActivityTeaser as aI, fetchAppsRegistry as aJ, fetchExternalAccounts as aK, fetchFeaturedProfile as aL, fetchFollowing as aM, fetchHeatmapData as aN, fetchHiddenApps as aO, fetchMyRoadmapVotes as aP, fetchReactionStatus as aQ, fetchRoadmapVotes as aR, fetchSearchFilters as aS, fetchSearchProfiles as aT, fetchSimilarProfiles as aU, fetchSkillSuggestions as aV, fetchStats as aW, fetchSuggestionCount as aX, fetchSuggestions as aY, followUser as aZ, getBlueskySuggestions as a_, type RoadmapVotesResponse as aa, type SearchFilters as ab, type SearchResponse as ac, type SifaQueryKey as ad, type SimilarProfile as ae, type SkillSearchResult as af, type StatsResponse as ag, type SuggestionProfile as ah, type SuggestionsResponse as ai, type UpdateProfileOverrideInput as aj, type UpdateProfileSelfInput as ak, type UploadAvatarResult as al, type VerifyExternalAccountResult as am, addFeatureAllowlist as an, apiFetch as ao, apiFetchOrNull as ap, apiWrite as aq, apiWriteCreate as ar, bulkHideProfileItems as as, bulkHideStandardPublications as at, bulkUnhideProfileItems as au, bulkUnhideStandardPublications as av, castRoadmapVote as aw, checkAppAccount as ax, createEndorsement as ay, createExternalAccount as az, type ActivityFeedResponse as b, getFollowing as b0, getFollowingFeed as b1, getMutuals as b2, hideOrcidPublication as b3, hideProfileItem as b4, hideSifaPublication as b5, hideStandardPublication as b6, listFeatureAllowlist as b7, refreshOrcidPublications as b8, refreshPds as b9, removeFeatureAllowlist as ba, resetProfile as bb, resolveQuotedPosts as bc, retractRoadmapVote as bd, searchSkills as be, setExternalAccountPrimary as bf, unfollowUser as bg, unhideOrcidPublication as bh, unhideProfileItem as bi, unhideSifaPublication as bj, unhideStandardPublication as bk, unsetExternalAccountPrimary as bl, updateExternalAccount as bm, updateProfileLocation as bn, updateProfileOverride as bo, updateProfileSelf as bp, uploadAvatar as bq, verifyExternalAccount as br, type ActivityItem as c, type ActivityItemLinkHealth as d, type ActivityTeaserResponse as e, ApiError as f, type AppRegistryEntry as g, type CheckAppAccountOptions as h, type CreateExternalAccountResult as i, type CreateResult as j, type ExternalAccountInput as k, type FeaturedProfile as l, type FetchActivityFeedOptions as m, type FetchActivityTeaserOptions as n, type FetchFollowListOptions as o, type FetchFollowProfilePageOptions as p, type FetchFollowingFeedOptions as q, type FetchHiddenAppsOptions as r, sifaQueryKeys as s, type FetchMyRoadmapVotesOptions as t, type FetchReactionStatusOptions as u, type FetchSuggestionsOptions as v, type FilterOptions as w, type FollowListPage as x, type FollowProfile as y, type FollowProfilePageResponse as z };
|
|
@@ -1016,8 +1016,36 @@ async function fetchMyRoadmapVotes(config, options = {}) {
|
|
|
1016
1016
|
return [];
|
|
1017
1017
|
}
|
|
1018
1018
|
}
|
|
1019
|
-
function castRoadmapVote(config, key, options = {}) {
|
|
1020
|
-
|
|
1019
|
+
async function castRoadmapVote(config, key, options = {}) {
|
|
1020
|
+
const fetchFn = config.fetch ?? globalThis.fetch;
|
|
1021
|
+
const url = `${config.baseUrl}/api/roadmap/votes/${encodeURIComponent(key)}`;
|
|
1022
|
+
try {
|
|
1023
|
+
const res = await fetchFn(url, {
|
|
1024
|
+
method: "POST",
|
|
1025
|
+
headers: { "Content-Type": "application/json", ...options.headers ?? {} },
|
|
1026
|
+
credentials: options.credentials ?? "include",
|
|
1027
|
+
signal: options.signal ?? AbortSignal.timeout(options.timeoutMs ?? 1e4)
|
|
1028
|
+
});
|
|
1029
|
+
if (!res.ok) {
|
|
1030
|
+
if (res.status === 403) {
|
|
1031
|
+
try {
|
|
1032
|
+
const body = await res.json();
|
|
1033
|
+
if (body.error === "ScopeInsufficient") {
|
|
1034
|
+
return {
|
|
1035
|
+
ok: false,
|
|
1036
|
+
error: { type: "scope_insufficient", requiredScope: body.requiredScope }
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
} catch {
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
return { ok: false, error: { type: "error" } };
|
|
1043
|
+
}
|
|
1044
|
+
const data = await res.json();
|
|
1045
|
+
return { ok: true, data };
|
|
1046
|
+
} catch {
|
|
1047
|
+
return { ok: false, error: { type: "error" } };
|
|
1048
|
+
}
|
|
1021
1049
|
}
|
|
1022
1050
|
function retractRoadmapVote(config, key, options = {}) {
|
|
1023
1051
|
return apiWrite(config, `/api/roadmap/votes/${encodeURIComponent(key)}`, "DELETE", options);
|