synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
107 lines (106 loc) • 2.97 kB
JavaScript
import { useSynapseContext as r } from "../../utils/context/SynapseContext.js";
import u from "../../utils/functions/GridApiUtils.js";
import { waitForAsyncResult as d } from "@sage-bionetworks/synapse-client";
import { useMutation as a, useInfiniteQuery as S, useQueryClient as y, useQuery as p, queryOptions as l } from "@tanstack/react-query";
function m(e) {
const s = y(), { keyFactory: i, synapseClient: t } = r();
return a({
...e,
mutationFn: (n) => t.gridServicesClient.postRepoV1GridSessionSessionIdReplica({
sessionId: n,
createReplicaRequest: {
gridSessionId: n
}
}),
onSuccess: async (n, o, c) => {
await s.invalidateQueries({
queryKey: i.getGridSessionListKey()
}), e?.onSuccess && await e.onSuccess(n, o, c);
}
});
}
function q(e) {
const s = y(), { keyFactory: i, synapseClient: t } = r();
return a({
...e,
mutationFn: (n) => t.gridServicesClient.deleteRepoV1GridSessionSessionId({
sessionId: n
}),
onSuccess: async (n, o, c) => {
await s.invalidateQueries({
queryKey: i.getGridSessionListKey()
}), e?.onSuccess && await e.onSuccess(n, o, c);
}
});
}
const f = (e, s) => l({
queryKey: s.keyFactory.getGridSessionListKey(e),
queryFn: () => s.synapseClient.gridServicesClient.postRepoV1GridSessionList({
listGridSessionsRequest: e
})
});
function F(e, s) {
const { keyFactory: i, synapseClient: t } = r();
return S({
...s,
queryKey: i.getGridSessionListKey(e),
queryFn: async (n) => await t.gridServicesClient.postRepoV1GridSessionList({
listGridSessionsRequest: {
...e,
nextPageToken: n.pageParam
}
}),
initialPageParam: void 0,
getNextPageParam: (n) => n.nextPageToken
});
}
function v(e, s) {
const { keyFactory: i, synapseClient: t } = r();
return p({
...s,
queryKey: i.getGridSessionKey(e),
queryFn: () => t.gridServicesClient.getRepoV1GridSessionSessionId({
sessionId: e
})
});
}
const w = (e) => {
const { synapseClient: s } = r();
return a(
{
...e,
mutationFn: async (i) => await u(s, i)
}
);
};
function K(e) {
const { synapseClient: s } = r();
return a({
...e,
mutationFn: async (i) => {
const t = {
...i,
concreteType: "org.sagebionetworks.repo.model.grid.SynchronizeGridRequest"
}, n = await s.gridServicesClient.postRepoV1GridSynchronizeAsyncStart(
{ synchronizeGridRequest: t }
);
return (await d(
() => s.asynchronousJobServicesClient.getRepoV1AsynchronousJobJobId(
{
jobId: n.token
}
)
)).responseBody;
}
});
}
export {
f as getGridSessionsQuery,
m as useCreateGridReplica,
w as useCreateGridSession,
q as useDeleteGridSession,
v as useGetGridSession,
F as useGetGridSessionsInfinite,
K as useSynchronizeGridSession
};
//# sourceMappingURL=useGridSession.js.map