synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
173 lines (172 loc) • 5.37 kB
JavaScript
import * as c from "../../synapse-client/SynapseClient.js";
import "@sage-bionetworks/synapse-client/generated/models/ErrorResponseCode";
import "@sage-bionetworks/synapse-client/generated/models/TwoFactorAuthErrorResponse";
import "@sage-bionetworks/synapse-client/util/SynapseClientError";
import "@sage-bionetworks/synapse-types";
import "../../utils/functions/EntityTypeUtils.js";
import "../../utils/SynapseConstants.js";
import "lodash-es";
import "@sage-bionetworks/synapse-client/util/synapseClientFetch";
import { useSynapseContext as r } from "../../utils/context/SynapseContext.js";
import { waitForAsyncResult as d } from "@sage-bionetworks/synapse-client";
import { useQuery as u, useInfiniteQuery as w, useQueryClient as y, useMutation as l } from "@tanstack/react-query";
function f(e, t) {
const { accessToken: n, keyFactory: s } = r();
return u({
...t,
queryKey: s.getDownloadListAvailableFilesQueryKey(e),
queryFn: () => c.getAvailableFilesToDownload(e, n)
});
}
function S(e, t, n) {
const { accessToken: s, keyFactory: o } = r(), a = {
concreteType: "org.sagebionetworks.repo.model.download.AvailableFilesRequest"
};
return e && (a.sort = [e]), t && (a.filter = t), w({
...n,
queryKey: o.getDownloadListAvailableFilesInfiniteQueryKey(a),
queryFn: async (i) => c.getAvailableFilesToDownload(
{ ...a, nextPageToken: i.pageParam },
s
),
initialPageParam: void 0,
getNextPageParam: (i) => i.nextPageToken
});
}
function K(e) {
const { accessToken: t, keyFactory: n } = r(), s = {
concreteType: "org.sagebionetworks.repo.model.download.ActionRequiredRequest"
};
return u({
...e,
queryKey: n.getDownloadListActionsRequiredQueryKey(),
queryFn: () => c.getAllDownloadListActionsRequired(s, t)
});
}
function R(e) {
const { accessToken: t, keyFactory: n } = r(), s = {
concreteType: "org.sagebionetworks.repo.model.download.ActionRequiredRequest"
};
return w({
...e,
queryKey: n.getDownloadListActionsRequiredInfiniteQueryKey(),
queryFn: async (o) => await c.getDownloadListActionsRequired(
{ ...s, nextPageToken: o.pageParam },
t
),
initialPageParam: void 0,
getNextPageParam: (o) => o.nextPageToken
});
}
function v(e) {
const { accessToken: t, keyFactory: n } = r();
return u({
...e,
queryKey: n.getDownloadListStatisticsQueryKey(),
queryFn: () => c.getDownloadListStatistics(t)
});
}
function Q(e) {
const { accessToken: t, keyFactory: n } = r(), s = y();
return l({
...e,
mutationFn: (o) => c.addFileToDownloadListV2(
o.entityId,
o.entityVersionNumber,
t
),
mutationKey: ["addFileToDownloadList"],
onSuccess: async (o, a, i) => {
if (await s.invalidateQueries({
queryKey: n.getDownloadListBaseQueryKey()
}), e?.onSuccess)
return e.onSuccess(o, a, i);
}
});
}
function P(e) {
const { accessToken: t, keyFactory: n } = r(), s = y();
return l({
...e,
mutationFn: (o) => c.addFileBatchToDownloadListV2(o, t),
mutationKey: ["addFileBatchToDownloadList"],
onSuccess: async (o, a, i) => {
if (await s.invalidateQueries({
queryKey: n.getDownloadListBaseQueryKey()
}), e?.onSuccess)
return e.onSuccess(o, a, i);
}
});
}
function C(e) {
const { synapseClient: t, keyFactory: n } = r(), s = y();
return l({
...e,
mutationFn: async (o) => {
const a = (await t.downloadListServicesClient.postRepoV1DownloadListAddAsyncStart(
{
addToDownloadListRequest: o
}
)).token;
return (await d(
() => t.asynchronousJobServicesClient.getRepoV1AsynchronousJobJobId(
{
jobId: a
}
)
)).responseBody;
},
mutationKey: ["addQueryToDownloadList"],
onSuccess: async (o, a, i) => {
if (await s.invalidateQueries({
queryKey: n.getDownloadListBaseQueryKey()
}), e?.onSuccess)
return e.onSuccess(o, a, i);
}
});
}
function I(e) {
const { accessToken: t, keyFactory: n } = r(), s = y();
return l({
...e,
mutationFn: (o) => c.removeItemsFromDownloadListV2(o, t),
onSuccess: async (o, a, i) => {
if (await s.invalidateQueries({
queryKey: n.getDownloadListBaseQueryKey()
}), e?.onSuccess)
return e.onSuccess(o, a, i);
}
});
}
function J(e, t) {
const { synapseClient: n, keyFactory: s } = r();
return u({
queryKey: s.getAddToDownloadListStatsQueryKey(
e
),
queryFn: async () => {
const o = (await n.downloadListServicesClient.postRepoV1DownloadListAddStatsAsyncStart(
{ addToDownloadListStatsRequest: e }
)).token;
return (await d(
() => n.asynchronousJobServicesClient.getRepoV1AsynchronousJobJobId(
{ jobId: o }
)
)).responseBody;
},
enabled: t?.enabled
});
}
export {
P as useAddFileBatchToDownloadList,
Q as useAddFileToDownloadList,
C as useAddToDownloadList,
J as useGetAddToDownloadListStats,
K as useGetAllDownloadListActionsRequired,
f as useGetAvailableFilesToDownload,
S as useGetAvailableFilesToDownloadInfinite,
R as useGetDownloadListActionsRequiredInfinite,
v as useGetDownloadListStatistics,
I as useRemoveFilesFromDownloadList
};
//# sourceMappingURL=useDownloadList.js.map