@singi-labs/sifa-sdk 0.10.18 → 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 +1 -1
- package/dist/index.js +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
|
@@ -2145,8 +2145,36 @@ async function fetchMyRoadmapVotes(config, options = {}) {
|
|
|
2145
2145
|
return [];
|
|
2146
2146
|
}
|
|
2147
2147
|
}
|
|
2148
|
-
function castRoadmapVote(config, key, options = {}) {
|
|
2149
|
-
|
|
2148
|
+
async function castRoadmapVote(config, key, options = {}) {
|
|
2149
|
+
const fetchFn = config.fetch ?? globalThis.fetch;
|
|
2150
|
+
const url = `${config.baseUrl}/api/roadmap/votes/${encodeURIComponent(key)}`;
|
|
2151
|
+
try {
|
|
2152
|
+
const res = await fetchFn(url, {
|
|
2153
|
+
method: "POST",
|
|
2154
|
+
headers: { "Content-Type": "application/json", ...options.headers ?? {} },
|
|
2155
|
+
credentials: options.credentials ?? "include",
|
|
2156
|
+
signal: options.signal ?? AbortSignal.timeout(options.timeoutMs ?? 1e4)
|
|
2157
|
+
});
|
|
2158
|
+
if (!res.ok) {
|
|
2159
|
+
if (res.status === 403) {
|
|
2160
|
+
try {
|
|
2161
|
+
const body = await res.json();
|
|
2162
|
+
if (body.error === "ScopeInsufficient") {
|
|
2163
|
+
return {
|
|
2164
|
+
ok: false,
|
|
2165
|
+
error: { type: "scope_insufficient", requiredScope: body.requiredScope }
|
|
2166
|
+
};
|
|
2167
|
+
}
|
|
2168
|
+
} catch {
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
return { ok: false, error: { type: "error" } };
|
|
2172
|
+
}
|
|
2173
|
+
const data = await res.json();
|
|
2174
|
+
return { ok: true, data };
|
|
2175
|
+
} catch {
|
|
2176
|
+
return { ok: false, error: { type: "error" } };
|
|
2177
|
+
}
|
|
2150
2178
|
}
|
|
2151
2179
|
function retractRoadmapVote(config, key, options = {}) {
|
|
2152
2180
|
return apiWrite(config, `/api/roadmap/votes/${encodeURIComponent(key)}`, "DELETE", options);
|
|
@@ -2178,7 +2206,7 @@ function useCastRoadmapVote(options) {
|
|
|
2178
2206
|
return reactQuery.useMutation({
|
|
2179
2207
|
mutationFn: (key) => castRoadmapVote(config, key),
|
|
2180
2208
|
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
2181
|
-
if (result.
|
|
2209
|
+
if (result.ok) {
|
|
2182
2210
|
await invalidateRoadmap(queryClient);
|
|
2183
2211
|
}
|
|
2184
2212
|
await options?.onSuccess?.(result, variables, onMutateResult, context);
|