UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

37 lines (36 loc) 942 B
import { getEntity as i } from "../../synapse-client/SynapseClient.js"; import { isLink as s } from "../types/IsType.js"; import { useQuery as a } from "@tanstack/react-query"; import { useSynapseContext as u } from "../context/SynapseContext.js"; async function c(e, r, n) { const o = /* @__PURE__ */ new Set(); try { let t = await i(n, e, r); for (; s(t); ) { if (o.has(t.id)) throw new Error("Link forms a cycle."); o.add(t.id), t = await i( n, t.linksTo.targetId, t.linksTo.targetVersionNumber ); } return t; } catch (t) { throw new Error(`${e} could not be resolved. ${t.message}`); } } function w(e, r, n) { const { accessToken: o } = u(); return a({ queryKey: ["resolveLinkEntity", e, r], queryFn: () => c(e, r, o), ...n }); } export { c as resolveLinkEntity, w as useResolveLinkEntity }; //# sourceMappingURL=ResolveLinkEntity.js.map