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

55 lines (54 loc) 1.69 kB
import { useCreateGridReplica as u, useCreateGridSession as l } from "../../synapse-queries/grid/useGridSession.js"; import { useSynapseContext as p } from "../../utils/context/SynapseContext.js"; import { useMutation as a } from "@tanstack/react-query"; function g() { const { mutateAsync: i } = l(), { synapseClient: n } = p(); return a({ mutationFn: async ({ createGridRequest: s, sessionId: e }) => { if (!(s || e)) throw new Error( "Must provide either a CreateGridRequest or sessionId to create or get a grid session." ); if (s) { const t = await i(s); return console.log("Grid session started:", t), t.gridSession; } return console.log(`Joining existing session ID: ${e}`), await n.gridServicesClient.getRepoV1GridSessionSessionId( { sessionId: e } ); } }); } function f(i) { const { mutateAsync: n } = g(), { mutateAsync: s } = u(); return a({ ...i, mutationFn: async ({ createGridRequest: e, sessionId: t }) => { if (!(e || t)) throw new Error( "Must provide either a SQL query, recordSetId, or sessionId to initialize grid connection." ); const r = await n({ createGridRequest: e, sessionId: t }), c = r.sessionId; try { const o = await s(c); console.log("Replica created:", o); const d = o.replica; return { session: r, replica: d }; } catch (o) { throw new Error("Error starting session:", { cause: o }); } } }); } export { f as default }; //# sourceMappingURL=useInitializeGridConnection.js.map