synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
64 lines (63 loc) • 1.69 kB
JavaScript
import { allowNotFoundError as y } from "../../synapse-client/SynapseClientUtils.js";
import { useSynapseContext as i } from "../../utils/context/SynapseContext.js";
import { waitForAsyncResult as a } from "@sage-bionetworks/synapse-client";
import { useQuery as u, useQueryClient as p, useMutation as d } from "@tanstack/react-query";
function m(e, n) {
const { synapseClient: t, keyFactory: s } = i();
return u({
...n,
queryKey: s.getDOIAssociationQueryKey(e),
queryFn: () => y(
() => t.doiServicesClient.getRepoV1DoiAssociation(e)
)
});
}
function D(e, n) {
const { synapseClient: t, keyFactory: s } = i();
return u({
...n,
queryKey: s.getDOIQueryKey(e),
queryFn: () => y(
() => t.doiServicesClient.getRepoV1Doi(e)
)
});
}
function f(e) {
const n = p(), { synapseClient: t, keyFactory: s } = i();
return d({
...e,
mutationFn: async (r) => {
const o = await t.doiServicesClient.postRepoV1DoiAsyncStart({
doiRequest: r
});
return (await a(
() => t.asynchronousJobServicesClient.getRepoV1AsynchronousJobJobId(
{
jobId: o.token
}
)
)).responseBody;
},
onSuccess(...r) {
e?.onSuccess && e.onSuccess(...r);
const o = r[1].doi;
if (o) {
const c = {
id: o.objectId,
type: o.objectType,
portalId: o.portalId,
version: o.objectVersion
};
n.invalidateQueries({
queryKey: s.getDOIQueryKey(c)
});
}
}
});
}
export {
f as useCreateOrUpdateDOI,
D as useGetDOI,
m as useGetDOIAssociation
};
//# sourceMappingURL=useDOI.js.map