@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
package/dist/query/index.cjs
CHANGED
|
@@ -1033,8 +1033,36 @@ async function fetchMyRoadmapVotes(config, options = {}) {
|
|
|
1033
1033
|
return [];
|
|
1034
1034
|
}
|
|
1035
1035
|
}
|
|
1036
|
-
function castRoadmapVote(config, key, options = {}) {
|
|
1037
|
-
|
|
1036
|
+
async function castRoadmapVote(config, key, options = {}) {
|
|
1037
|
+
const fetchFn = config.fetch ?? globalThis.fetch;
|
|
1038
|
+
const url = `${config.baseUrl}/api/roadmap/votes/${encodeURIComponent(key)}`;
|
|
1039
|
+
try {
|
|
1040
|
+
const res = await fetchFn(url, {
|
|
1041
|
+
method: "POST",
|
|
1042
|
+
headers: { "Content-Type": "application/json", ...options.headers ?? {} },
|
|
1043
|
+
credentials: options.credentials ?? "include",
|
|
1044
|
+
signal: options.signal ?? AbortSignal.timeout(options.timeoutMs ?? 1e4)
|
|
1045
|
+
});
|
|
1046
|
+
if (!res.ok) {
|
|
1047
|
+
if (res.status === 403) {
|
|
1048
|
+
try {
|
|
1049
|
+
const body = await res.json();
|
|
1050
|
+
if (body.error === "ScopeInsufficient") {
|
|
1051
|
+
return {
|
|
1052
|
+
ok: false,
|
|
1053
|
+
error: { type: "scope_insufficient", requiredScope: body.requiredScope }
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
} catch {
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
return { ok: false, error: { type: "error" } };
|
|
1060
|
+
}
|
|
1061
|
+
const data = await res.json();
|
|
1062
|
+
return { ok: true, data };
|
|
1063
|
+
} catch {
|
|
1064
|
+
return { ok: false, error: { type: "error" } };
|
|
1065
|
+
}
|
|
1038
1066
|
}
|
|
1039
1067
|
function retractRoadmapVote(config, key, options = {}) {
|
|
1040
1068
|
return apiWrite(config, `/api/roadmap/votes/${encodeURIComponent(key)}`, "DELETE", options);
|
|
@@ -2219,7 +2247,7 @@ function useCastRoadmapVote(options) {
|
|
|
2219
2247
|
return reactQuery.useMutation({
|
|
2220
2248
|
mutationFn: (key) => castRoadmapVote(config, key),
|
|
2221
2249
|
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
2222
|
-
if (result.
|
|
2250
|
+
if (result.ok) {
|
|
2223
2251
|
await invalidateRoadmap(queryClient);
|
|
2224
2252
|
}
|
|
2225
2253
|
await options?.onSuccess?.(result, variables, onMutateResult, context);
|