@synap-core/react 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +144 -31
  2. package/api/editor.d.ts +178 -0
  3. package/api/whiteboard.d.ts +104 -0
  4. package/dist/editor.cjs +38733 -0
  5. package/dist/editor.css +9953 -0
  6. package/dist/editor.d.cts +178 -0
  7. package/dist/editor.d.ts +178 -0
  8. package/dist/editor.js +38974 -0
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +26 -4
  11. package/dist/index.d.ts +26 -4
  12. package/dist/index.js.map +1 -1
  13. package/dist/whiteboard.cjs +4540 -0
  14. package/dist/whiteboard.css +7913 -0
  15. package/dist/whiteboard.d.cts +104 -0
  16. package/dist/whiteboard.d.ts +104 -0
  17. package/dist/whiteboard.js +4568 -0
  18. package/package.json +198 -14
  19. package/src/SynapProvider.tsx +1 -1
  20. package/src/editor/SynapEditor.tsx +288 -0
  21. package/src/editor/SynapMarkdown.tsx +11 -0
  22. package/src/editor/adapter-source.ts +97 -0
  23. package/src/editor/api.ts +30 -0
  24. package/src/editor/copy.ts +18 -0
  25. package/src/editor/drag.ts +14 -0
  26. package/src/editor/editor-base.css +28 -0
  27. package/src/editor/http-adapter.ts +87 -0
  28. package/src/editor/index.ts +22 -0
  29. package/src/editor/no-default-source.ts +7 -0
  30. package/src/editor/provider.tsx +79 -0
  31. package/src/editor/types.ts +162 -0
  32. package/src/index.ts +3 -3
  33. package/src/shared/read-cache.ts +76 -0
  34. package/src/trpc.ts +3 -2
  35. package/src/whiteboard/SynapBoard.tsx +139 -0
  36. package/src/whiteboard/adapter-source.ts +138 -0
  37. package/src/whiteboard/api.ts +22 -0
  38. package/src/whiteboard/copy.ts +24 -0
  39. package/src/whiteboard/http-adapter.ts +57 -0
  40. package/src/whiteboard/index.ts +17 -0
  41. package/src/whiteboard/no-default-source.ts +7 -0
  42. package/src/whiteboard/provider.tsx +14 -0
  43. package/src/whiteboard/shapes.tsx +157 -0
  44. package/src/whiteboard/types.ts +99 -0
  45. package/src/whiteboard/whiteboard-base.css +87 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/SynapProvider.tsx","../src/trpc.ts","../src/hooks.ts"],"sourcesContent":["/**\n * @synap-core/react — React hooks and provider for Synap data pods.\n *\n * Quick start:\n * ```tsx\n * import { SynapProvider, useSynap } from \"@synap-core/react\";\n *\n * // 1. Wrap your app\n * <SynapProvider podUrl=\"...\" apiKey=\"...\" workspaceId=\"...\">\n * <App />\n * </SynapProvider>\n *\n * // 2. Use hooks anywhere inside\n * function MyComponent() {\n * const { entities } = useSynap();\n * const { data } = entities.list.useQuery({ limit: 20 });\n * }\n * ```\n */\n\nexport { SynapProvider, useSynapContext } from \"./SynapProvider\";\nexport type { SynapProviderProps } from \"./SynapProvider\";\n\n// Expose the raw tRPC hooks for advanced use (useSynap().entities.list.useQuery etc.)\nexport { trpc as useSynap } from \"./trpc\";\n\n// Thin ergonomic data hooks over the SDK + TanStack Query.\nexport {\n useEntity,\n useEntities,\n useLinks,\n useView,\n} from \"./hooks\";\nexport type {\n UseEntityData,\n UseEntitiesData,\n UseLinksData,\n UseViewData,\n} from \"./hooks\";\n\n// Re-export type helpers\nexport type { AppRouter } from \"@synap-core/api-types\";\nexport type { RouterInputs, RouterOutputs } from \"./types\";\n","/**\n * SynapProvider — wraps your React app with tRPC + TanStack Query\n * configured for a Synap data pod.\n *\n * Usage:\n * ```tsx\n * import { SynapProvider } from \"@synap-core/react\";\n *\n * function App() {\n * return (\n * <SynapProvider\n * podUrl=\"https://pod.example.com\"\n * apiKey=\"sk_live_...\"\n * workspaceId=\"ws_...\"\n * >\n * <YourApp />\n * </SynapProvider>\n * );\n * }\n * ```\n */\n\nimport React, { useState, createContext, useContext, useMemo } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport { createSynapClient, type SynapClientOptions } from \"@synap-core/sdk\";\nimport { trpc } from \"./trpc\";\n\nexport interface SynapProviderProps extends SynapClientOptions {\n children: React.ReactNode;\n /**\n * Provide your own QueryClient to share it with an existing TanStack Query setup.\n */\n queryClient?: QueryClient;\n}\n\nconst SynapContext = createContext<{\n podUrl: string;\n workspaceId: string;\n} | null>(null);\n\n/**\n * Returns the current pod context. Must be called inside <SynapProvider>.\n */\nexport function useSynapContext() {\n const ctx = useContext(SynapContext);\n if (!ctx)\n throw new Error(\"useSynapContext must be called inside <SynapProvider>\");\n return ctx;\n}\n\nexport function SynapProvider({\n children,\n queryClient: externalQueryClient,\n ...clientOptions\n}: SynapProviderProps) {\n const { podUrl, sessionToken, apiKey, workspaceId } = clientOptions;\n\n const [queryClient] = useState(\n () =>\n externalQueryClient ??\n new QueryClient({\n defaultOptions: {\n queries: { staleTime: 30_000, retry: 1 },\n },\n })\n );\n\n // Delegate to the SDK so every option (sessionToken, onAuthError,\n // extraHeaders) is honoured — the provider owns no transport of its own.\n // Deps are deliberately the credential fields, not `clientOptions` itself:\n // that object is rebuilt on every render, so depending on it would recreate\n // the client (and drop all in-flight query state) on every render.\n const trpcClient = useMemo(\n () => createSynapClient(clientOptions),\n [podUrl, sessionToken, apiKey, workspaceId]\n );\n\n const ctx = useMemo(() => ({ podUrl, workspaceId }), [podUrl, workspaceId]);\n\n return (\n <SynapContext.Provider value={ctx}>\n <trpc.Provider client={trpcClient} queryClient={queryClient}>\n <QueryClientProvider client={queryClient}>\n {children}\n </QueryClientProvider>\n </trpc.Provider>\n </SynapContext.Provider>\n );\n}\n","import { createTRPCReact, type CreateTRPCReact } from \"@trpc/react-query\";\nimport type { AppRouter } from \"@synap-core/api-types\";\n\n/**\n * tRPC React hooks — use via `useSynap()` from the provider context.\n * Exported for advanced use cases (e.g. calling `trpc.useUtils()`).\n */\nexport const trpc: CreateTRPCReact<AppRouter, unknown> =\n createTRPCReact<AppRouter>();\n","/**\n * Thin, self-contained data hooks over the published Synap SDK + TanStack Query.\n *\n * These wrap the `trpc` react-query client (the same instance exposed as\n * `useSynap`) — they do NOT import the monorepo `@synap-core/hooks` (which\n * couples Zustand stores, Yjs, notifications and is unpublishable). Each hook is\n * a thin pass-through to a single tRPC procedure so an external React app gets\n * ergonomic entity/relation/view access with zero hand-written query code.\n *\n * Procedure paths and input shapes mirror the canonical pod router:\n * - entities.get { id, includeProfile? }\n * - entities.list { profileSlug?, workspaceId?, projectId?, limit? }\n * - relations.get { entityId, direction? }\n * - views.get { id }\n *\n * Each hook's `opts` is the *exact* TanStack-Query options type of its\n * underlying procedure (derived via `Parameters<...useQuery>[1]`), so passthrough\n * options like `enabled` / `staleTime` keep full type-safety against that\n * procedure's data + error shapes.\n */\n\nimport { trpc } from \"./trpc\";\nimport type { RouterInputs, RouterOutputs } from \"./types\";\n\n/** The TanStack-Query options accepted by a given `useQuery` procedure. */\ntype QueryOptionsOf<P extends { useQuery: (...args: never[]) => unknown }> =\n NonNullable<Parameters<P[\"useQuery\"]>[1]>;\n\n/** The result type returned by a given `useQuery` procedure. */\ntype QueryResultOf<P extends { useQuery: (...args: never[]) => unknown }> =\n ReturnType<P[\"useQuery\"]>;\n\n/** The `useMutation` options accepted by a given mutation procedure. */\ntype MutationOptionsOf<\n P extends { useMutation: (...args: never[]) => unknown },\n> = NonNullable<Parameters<P[\"useMutation\"]>[0]>;\n\n/** The result type returned by a given `useMutation` procedure. */\ntype MutationResultOf<\n P extends { useMutation: (...args: never[]) => unknown },\n> = ReturnType<P[\"useMutation\"]>;\n\n/**\n * Fetch a single entity by id.\n *\n * @param id - Entity id.\n * @param opts - `{ includeProfile?, ...tanstackQueryOptions }`.\n */\nexport function useEntity(\n id: string,\n opts: { includeProfile?: boolean } & QueryOptionsOf<\n typeof trpc.entities.get\n > = {},\n): QueryResultOf<typeof trpc.entities.get> {\n const { includeProfile, ...queryOptions } = opts;\n const input: RouterInputs[\"entities\"][\"get\"] = { id, includeProfile };\n return trpc.entities.get.useQuery(input, {\n enabled: !!id,\n ...queryOptions,\n });\n}\n\n/**\n * List entities, optionally filtered by profile / workspace / project.\n *\n * @param profileSlug - Restrict to a single profile (e.g. \"person\", \"note\"). Omit for all.\n * @param opts - `{ workspaceId?, projectId?, limit?, ...tanstackQueryOptions }`.\n */\nexport function useEntities(\n profileSlug?: string,\n opts: {\n workspaceId?: string;\n projectId?: string;\n limit?: number;\n } & QueryOptionsOf<typeof trpc.entities.list> = {},\n): QueryResultOf<typeof trpc.entities.list> {\n const { workspaceId, projectId, limit, ...queryOptions } = opts;\n const input: RouterInputs[\"entities\"][\"list\"] = {\n profileSlug,\n workspaceId,\n projectId,\n limit,\n };\n return trpc.entities.list.useQuery(input, queryOptions);\n}\n\n/**\n * Fetch the relations/graph edges for an entity (both directions by default).\n *\n * @param entityId - The entity whose links to fetch.\n * @param opts - `{ direction?, ...tanstackQueryOptions }`.\n */\nexport function useLinks(\n entityId: string,\n opts: {\n direction?: RouterInputs[\"relations\"][\"get\"][\"direction\"];\n } & QueryOptionsOf<typeof trpc.relations.get> = {},\n): QueryResultOf<typeof trpc.relations.get> {\n const { direction = \"both\", ...queryOptions } = opts;\n const input: RouterInputs[\"relations\"][\"get\"] = { entityId, direction };\n return trpc.relations.get.useQuery(input, {\n enabled: !!entityId,\n ...queryOptions,\n });\n}\n\n/**\n * Fetch a view definition (config + query) by id.\n *\n * @param viewId - The view id.\n * @param opts - Passthrough TanStack Query options.\n */\nexport function useView(\n viewId: string,\n opts: QueryOptionsOf<typeof trpc.views.get> = {},\n): QueryResultOf<typeof trpc.views.get> {\n const input: RouterInputs[\"views\"][\"get\"] = { id: viewId };\n return trpc.views.get.useQuery(input, {\n enabled: !!viewId,\n ...opts,\n });\n}\n\n// NOTE: useTemplateCatalog / useInstallTemplate were removed — they referenced\n// tRPC procedures (workspaces.listInstallableTemplates / installFromCatalog) that\n// no longer exist in @synap-core/api-types, so they broke the dts build and could\n// never work. Re-add them here only once those procedures are back in api-types.\n\n/** Output type helpers for consumers that want to type derived state. */\nexport type UseEntityData = RouterOutputs[\"entities\"][\"get\"];\nexport type UseEntitiesData = RouterOutputs[\"entities\"][\"list\"];\nexport type UseLinksData = RouterOutputs[\"relations\"][\"get\"];\nexport type UseViewData = RouterOutputs[\"views\"][\"get\"];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACsBA,mBAAoE;AACpE,IAAAA,sBAAiD;AACjD,iBAA2D;;;ACxB3D,yBAAsD;AAO/C,IAAM,WACX,oCAA2B;;;AD0ErB;AA/CR,IAAM,mBAAe,4BAGX,IAAI;AAKP,SAAS,kBAAkB;AAChC,QAAM,UAAM,yBAAW,YAAY;AACnC,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,uDAAuD;AACzE,SAAO;AACT;AAEO,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA,aAAa;AAAA,EACb,GAAG;AACL,GAAuB;AACrB,QAAM,EAAE,QAAQ,cAAc,QAAQ,YAAY,IAAI;AAEtD,QAAM,CAAC,WAAW,QAAI;AAAA,IACpB,MACE,uBACA,IAAI,gCAAY;AAAA,MACd,gBAAgB;AAAA,QACd,SAAS,EAAE,WAAW,KAAQ,OAAO,EAAE;AAAA,MACzC;AAAA,IACF,CAAC;AAAA,EACL;AAOA,QAAM,iBAAa;AAAA,IACjB,UAAM,8BAAkB,aAAa;AAAA,IACrC,CAAC,QAAQ,cAAc,QAAQ,WAAW;AAAA,EAC5C;AAEA,QAAM,UAAM,sBAAQ,OAAO,EAAE,QAAQ,YAAY,IAAI,CAAC,QAAQ,WAAW,CAAC;AAE1E,SACE,4CAAC,aAAa,UAAb,EAAsB,OAAO,KAC5B,sDAAC,KAAK,UAAL,EAAc,QAAQ,YAAY,aACjC,sDAAC,2CAAoB,QAAQ,aAC1B,UACH,GACF,GACF;AAEJ;;;AExCO,SAAS,UACd,IACA,OAEI,CAAC,GACoC;AACzC,QAAM,EAAE,gBAAgB,GAAG,aAAa,IAAI;AAC5C,QAAM,QAAyC,EAAE,IAAI,eAAe;AACpE,SAAO,KAAK,SAAS,IAAI,SAAS,OAAO;AAAA,IACvC,SAAS,CAAC,CAAC;AAAA,IACX,GAAG;AAAA,EACL,CAAC;AACH;AAQO,SAAS,YACd,aACA,OAIgD,CAAC,GACP;AAC1C,QAAM,EAAE,aAAa,WAAW,OAAO,GAAG,aAAa,IAAI;AAC3D,QAAM,QAA0C;AAAA,IAC9C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,SAAO,KAAK,SAAS,KAAK,SAAS,OAAO,YAAY;AACxD;AAQO,SAAS,SACd,UACA,OAEgD,CAAC,GACP;AAC1C,QAAM,EAAE,YAAY,QAAQ,GAAG,aAAa,IAAI;AAChD,QAAM,QAA0C,EAAE,UAAU,UAAU;AACtE,SAAO,KAAK,UAAU,IAAI,SAAS,OAAO;AAAA,IACxC,SAAS,CAAC,CAAC;AAAA,IACX,GAAG;AAAA,EACL,CAAC;AACH;AAQO,SAAS,QACd,QACA,OAA8C,CAAC,GACT;AACtC,QAAM,QAAsC,EAAE,IAAI,OAAO;AACzD,SAAO,KAAK,MAAM,IAAI,SAAS,OAAO;AAAA,IACpC,SAAS,CAAC,CAAC;AAAA,IACX,GAAG;AAAA,EACL,CAAC;AACH;","names":["import_react_query"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/SynapProvider.tsx","../src/trpc.ts","../src/hooks.ts"],"sourcesContent":["/**\n * @synap-core/react — React hooks and provider for Synap data pods.\n *\n * Quick start:\n * ```tsx\n * import { SynapProvider, useSynap } from \"@synap-core/react\";\n *\n * // 1. Wrap your app\n * <SynapProvider podUrl=\"...\" apiKey=\"...\" workspaceId=\"...\">\n * <App />\n * </SynapProvider>\n *\n * // 2. Use hooks anywhere inside\n * function MyComponent() {\n * // `useSynap` is the tRPC hook tree itself, not a function to call.\n * const { data } = useSynap.entities.list.useQuery({ limit: 20 });\n * }\n * ```\n */\n\nexport { SynapProvider, useSynapContext } from \"./SynapProvider\";\nexport type { SynapProviderProps } from \"./SynapProvider\";\n\n// Expose the raw tRPC hooks for advanced use (useSynap.entities.list.useQuery etc.)\nexport { trpc as useSynap } from \"./trpc\";\n\n// Thin ergonomic data hooks over the SDK + TanStack Query.\nexport {\n useEntity,\n useEntities,\n useLinks,\n useView,\n} from \"./hooks\";\nexport type {\n UseEntityData,\n UseEntitiesData,\n UseLinksData,\n UseViewData,\n} from \"./hooks\";\n\n// Re-export type helpers\nexport type { AppRouter } from \"@synap-core/api-types\";\nexport type { RouterInputs, RouterOutputs } from \"./types\";\n","/**\n * SynapProvider — wraps your React app with tRPC + TanStack Query\n * configured for a Synap data pod.\n *\n * Usage:\n * ```tsx\n * import { SynapProvider } from \"@synap-core/react\";\n *\n * function App() {\n * return (\n * <SynapProvider\n * podUrl=\"https://pod.example.com\"\n * sessionToken=\"...\"\n * workspaceId=\"ws_...\"\n * >\n * <YourApp />\n * </SynapProvider>\n * );\n * }\n * ```\n */\n\nimport React, { useState, createContext, useContext, useMemo } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport { createSynapClient, type SynapClientOptions } from \"@synap-core/sdk\";\nimport { trpc } from \"./trpc\";\n\nexport interface SynapProviderProps extends SynapClientOptions {\n children: React.ReactNode;\n /**\n * Provide your own QueryClient to share it with an existing TanStack Query setup.\n */\n queryClient?: QueryClient;\n}\n\nconst SynapContext = createContext<{\n podUrl: string;\n workspaceId: string;\n} | null>(null);\n\n/**\n * Returns the current pod context. Must be called inside <SynapProvider>.\n */\nexport function useSynapContext() {\n const ctx = useContext(SynapContext);\n if (!ctx)\n throw new Error(\"useSynapContext must be called inside <SynapProvider>\");\n return ctx;\n}\n\nexport function SynapProvider({\n children,\n queryClient: externalQueryClient,\n ...clientOptions\n}: SynapProviderProps) {\n const { podUrl, sessionToken, apiKey, workspaceId } = clientOptions;\n\n const [queryClient] = useState(\n () =>\n externalQueryClient ??\n new QueryClient({\n defaultOptions: {\n queries: { staleTime: 30_000, retry: 1 },\n },\n })\n );\n\n // Delegate to the SDK so every option (sessionToken, onAuthError,\n // extraHeaders) is honoured — the provider owns no transport of its own.\n // Deps are deliberately the credential fields, not `clientOptions` itself:\n // that object is rebuilt on every render, so depending on it would recreate\n // the client (and drop all in-flight query state) on every render.\n const trpcClient = useMemo(\n () => createSynapClient(clientOptions),\n [podUrl, sessionToken, apiKey, workspaceId]\n );\n\n const ctx = useMemo(() => ({ podUrl, workspaceId }), [podUrl, workspaceId]);\n\n return (\n <SynapContext.Provider value={ctx}>\n <trpc.Provider client={trpcClient} queryClient={queryClient}>\n <QueryClientProvider client={queryClient}>\n {children}\n </QueryClientProvider>\n </trpc.Provider>\n </SynapContext.Provider>\n );\n}\n","import { createTRPCReact, type CreateTRPCReact } from \"@trpc/react-query\";\nimport type { AppRouter } from \"@synap-core/api-types\";\n\n/**\n * tRPC React hooks, exported publicly as `useSynap`. Call hooks on the tree\n * directly (`useSynap.entities.list.useQuery(...)`, `useSynap.useUtils()`)\n * inside `<SynapProvider>`. Calling `useSynap()` itself returns undefined.\n */\nexport const trpc: CreateTRPCReact<AppRouter, unknown> =\n createTRPCReact<AppRouter>();\n","/**\n * Thin, self-contained data hooks over the published Synap SDK + TanStack Query.\n *\n * These wrap the `trpc` react-query client (the same instance exposed as\n * `useSynap`) — they do NOT import the monorepo `@synap-core/hooks` (which\n * couples Zustand stores, Yjs, notifications and is unpublishable). Each hook is\n * a thin pass-through to a single tRPC procedure so an external React app gets\n * ergonomic entity/relation/view access with zero hand-written query code.\n *\n * Procedure paths and input shapes mirror the canonical pod router:\n * - entities.get { id, includeProfile? }\n * - entities.list { profileSlug?, workspaceId?, projectId?, limit? }\n * - relations.get { entityId, direction? }\n * - views.get { id }\n *\n * Each hook's `opts` is the *exact* TanStack-Query options type of its\n * underlying procedure (derived via `Parameters<...useQuery>[1]`), so passthrough\n * options like `enabled` / `staleTime` keep full type-safety against that\n * procedure's data + error shapes.\n */\n\nimport { trpc } from \"./trpc\";\nimport type { RouterInputs, RouterOutputs } from \"./types\";\n\n/** The TanStack-Query options accepted by a given `useQuery` procedure. */\ntype QueryOptionsOf<P extends { useQuery: (...args: never[]) => unknown }> =\n NonNullable<Parameters<P[\"useQuery\"]>[1]>;\n\n/** The result type returned by a given `useQuery` procedure. */\ntype QueryResultOf<P extends { useQuery: (...args: never[]) => unknown }> =\n ReturnType<P[\"useQuery\"]>;\n\n/** The `useMutation` options accepted by a given mutation procedure. */\ntype MutationOptionsOf<\n P extends { useMutation: (...args: never[]) => unknown },\n> = NonNullable<Parameters<P[\"useMutation\"]>[0]>;\n\n/** The result type returned by a given `useMutation` procedure. */\ntype MutationResultOf<\n P extends { useMutation: (...args: never[]) => unknown },\n> = ReturnType<P[\"useMutation\"]>;\n\n/**\n * Fetch a single entity by id.\n *\n * @param id - Entity id.\n * @param opts - `{ includeProfile?, ...tanstackQueryOptions }`.\n */\nexport function useEntity(\n id: string,\n opts: { includeProfile?: boolean } & QueryOptionsOf<\n typeof trpc.entities.get\n > = {},\n): QueryResultOf<typeof trpc.entities.get> {\n const { includeProfile, ...queryOptions } = opts;\n const input: RouterInputs[\"entities\"][\"get\"] = { id, includeProfile };\n return trpc.entities.get.useQuery(input, {\n enabled: !!id,\n ...queryOptions,\n });\n}\n\n/**\n * List entities, optionally filtered by profile / workspace / project.\n *\n * @param profileSlug - Restrict to a single profile (e.g. \"person\", \"note\"). Omit for all.\n * @param opts - `{ workspaceId?, projectId?, limit?, ...tanstackQueryOptions }`.\n */\nexport function useEntities(\n profileSlug?: string,\n opts: {\n workspaceId?: string;\n projectId?: string;\n limit?: number;\n } & QueryOptionsOf<typeof trpc.entities.list> = {},\n): QueryResultOf<typeof trpc.entities.list> {\n const { workspaceId, projectId, limit, ...queryOptions } = opts;\n const input: RouterInputs[\"entities\"][\"list\"] = {\n profileSlug,\n workspaceId,\n projectId,\n limit,\n };\n return trpc.entities.list.useQuery(input, queryOptions);\n}\n\n/**\n * Fetch the relations/graph edges for an entity (both directions by default).\n *\n * @param entityId - The entity whose links to fetch.\n * @param opts - `{ direction?, ...tanstackQueryOptions }`.\n */\nexport function useLinks(\n entityId: string,\n opts: {\n direction?: RouterInputs[\"relations\"][\"get\"][\"direction\"];\n } & QueryOptionsOf<typeof trpc.relations.get> = {},\n): QueryResultOf<typeof trpc.relations.get> {\n const { direction = \"both\", ...queryOptions } = opts;\n const input: RouterInputs[\"relations\"][\"get\"] = { entityId, direction };\n return trpc.relations.get.useQuery(input, {\n enabled: !!entityId,\n ...queryOptions,\n });\n}\n\n/**\n * Fetch a view definition (config + query) by id.\n *\n * @param viewId - The view id.\n * @param opts - Passthrough TanStack Query options.\n */\nexport function useView(\n viewId: string,\n opts: QueryOptionsOf<typeof trpc.views.get> = {},\n): QueryResultOf<typeof trpc.views.get> {\n const input: RouterInputs[\"views\"][\"get\"] = { id: viewId };\n return trpc.views.get.useQuery(input, {\n enabled: !!viewId,\n ...opts,\n });\n}\n\n// NOTE: useTemplateCatalog / useInstallTemplate were removed — they referenced\n// tRPC procedures (workspaces.listInstallableTemplates / installFromCatalog) that\n// no longer exist in @synap-core/api-types, so they broke the dts build and could\n// never work. Re-add them here only once those procedures are back in api-types.\n\n/** Output type helpers for consumers that want to type derived state. */\nexport type UseEntityData = RouterOutputs[\"entities\"][\"get\"];\nexport type UseEntitiesData = RouterOutputs[\"entities\"][\"list\"];\nexport type UseLinksData = RouterOutputs[\"relations\"][\"get\"];\nexport type UseViewData = RouterOutputs[\"views\"][\"get\"];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACsBA,mBAAoE;AACpE,IAAAA,sBAAiD;AACjD,iBAA2D;;;ACxB3D,yBAAsD;AAQ/C,IAAM,WACX,oCAA2B;;;ADyErB;AA/CR,IAAM,mBAAe,4BAGX,IAAI;AAKP,SAAS,kBAAkB;AAChC,QAAM,UAAM,yBAAW,YAAY;AACnC,MAAI,CAAC;AACH,U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AI;AAChD,QAAM,QAA0C,EAAE,UAAU,UAAU;AACtE,SAAO,KAAK,UAAU,IAAI,SAAS,OAAO;AAAA,IACxC,SAAS,CAAC,CAAC;AAAA,IACX,GAAG;AAAA,EACL,CAAC;AACH;AAQO,SAAS,QACd,QACA,OAA8C,CAAC,GACT;AACtC,QAAM,QAAsC,EAAE,IAAI,OAAO;AACzD,SAAO,KAAK,MAAM,IAAI,SAAS,OAAO;AAAA,IACpC,SAAS,CAAC,CAAC;AAAA,IACX,GAAG;AAAA,EACL,CAAC;AACH;","names":["import_react_query"]}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,3 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
1
  import React from 'react';
3
2
  import { QueryClient } from '@tanstack/react-query';
4
3
  import { SynapClientOptions } from '@synap-core/sdk';
@@ -7,6 +6,28 @@ import { AppRouter } from '@synap-core/api-types';
7
6
  export { AppRouter } from '@synap-core/api-types';
8
7
  import { inferRouterInputs, inferRouterOutputs } from '@trpc/server';
9
8
 
9
+ /**
10
+ * SynapProvider — wraps your React app with tRPC + TanStack Query
11
+ * configured for a Synap data pod.
12
+ *
13
+ * Usage:
14
+ * ```tsx
15
+ * import { SynapProvider } from "@synap-core/react";
16
+ *
17
+ * function App() {
18
+ * return (
19
+ * <SynapProvider
20
+ * podUrl="https://pod.example.com"
21
+ * sessionToken="..."
22
+ * workspaceId="ws_..."
23
+ * >
24
+ * <YourApp />
25
+ * </SynapProvider>
26
+ * );
27
+ * }
28
+ * ```
29
+ */
30
+
10
31
  interface SynapProviderProps extends SynapClientOptions {
11
32
  children: React.ReactNode;
12
33
  /**
@@ -21,11 +42,12 @@ declare function useSynapContext(): {
21
42
  podUrl: string;
22
43
  workspaceId: string;
23
44
  };
24
- declare function SynapProvider({ children, queryClient: externalQueryClient, ...clientOptions }: SynapProviderProps): react_jsx_runtime.JSX.Element;
45
+ declare function SynapProvider({ children, queryClient: externalQueryClient, ...clientOptions }: SynapProviderProps): React.JSX.Element;
25
46
 
26
47
  /**
27
- * tRPC React hooks — use via `useSynap()` from the provider context.
28
- * Exported for advanced use cases (e.g. calling `trpc.useUtils()`).
48
+ * tRPC React hooks, exported publicly as `useSynap`. Call hooks on the tree
49
+ * directly (`useSynap.entities.list.useQuery(...)`, `useSynap.useUtils()`)
50
+ * inside `<SynapProvider>`. Calling `useSynap()` itself returns undefined.
29
51
  */
30
52
  declare const trpc: CreateTRPCReact<AppRouter, unknown>;
31
53
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
1
  import React from 'react';
3
2
  import { QueryClient } from '@tanstack/react-query';
4
3
  import { SynapClientOptions } from '@synap-core/sdk';
@@ -7,6 +6,28 @@ import { AppRouter } from '@synap-core/api-types';
7
6
  export { AppRouter } from '@synap-core/api-types';
8
7
  import { inferRouterInputs, inferRouterOutputs } from '@trpc/server';
9
8
 
9
+ /**
10
+ * SynapProvider — wraps your React app with tRPC + TanStack Query
11
+ * configured for a Synap data pod.
12
+ *
13
+ * Usage:
14
+ * ```tsx
15
+ * import { SynapProvider } from "@synap-core/react";
16
+ *
17
+ * function App() {
18
+ * return (
19
+ * <SynapProvider
20
+ * podUrl="https://pod.example.com"
21
+ * sessionToken="..."
22
+ * workspaceId="ws_..."
23
+ * >
24
+ * <YourApp />
25
+ * </SynapProvider>
26
+ * );
27
+ * }
28
+ * ```
29
+ */
30
+
10
31
  interface SynapProviderProps extends SynapClientOptions {
11
32
  children: React.ReactNode;
12
33
  /**
@@ -21,11 +42,12 @@ declare function useSynapContext(): {
21
42
  podUrl: string;
22
43
  workspaceId: string;
23
44
  };
24
- declare function SynapProvider({ children, queryClient: externalQueryClient, ...clientOptions }: SynapProviderProps): react_jsx_runtime.JSX.Element;
45
+ declare function SynapProvider({ children, queryClient: externalQueryClient, ...clientOptions }: SynapProviderProps): React.JSX.Element;
25
46
 
26
47
  /**
27
- * tRPC React hooks — use via `useSynap()` from the provider context.
28
- * Exported for advanced use cases (e.g. calling `trpc.useUtils()`).
48
+ * tRPC React hooks, exported publicly as `useSynap`. Call hooks on the tree
49
+ * directly (`useSynap.entities.list.useQuery(...)`, `useSynap.useUtils()`)
50
+ * inside `<SynapProvider>`. Calling `useSynap()` itself returns undefined.
29
51
  */
30
52
  declare const trpc: CreateTRPCReact<AppRouter, unknown>;
31
53
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/SynapProvider.tsx","../src/trpc.ts","../src/hooks.ts"],"sourcesContent":["/**\n * SynapProvider — wraps your React app with tRPC + TanStack Query\n * configured for a Synap data pod.\n *\n * Usage:\n * ```tsx\n * import { SynapProvider } from \"@synap-core/react\";\n *\n * function App() {\n * return (\n * <SynapProvider\n * podUrl=\"https://pod.example.com\"\n * apiKey=\"sk_live_...\"\n * workspaceId=\"ws_...\"\n * >\n * <YourApp />\n * </SynapProvider>\n * );\n * }\n * ```\n */\n\nimport React, { useState, createContext, useContext, useMemo } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport { createSynapClient, type SynapClientOptions } from \"@synap-core/sdk\";\nimport { trpc } from \"./trpc\";\n\nexport interface SynapProviderProps extends SynapClientOptions {\n children: React.ReactNode;\n /**\n * Provide your own QueryClient to share it with an existing TanStack Query setup.\n */\n queryClient?: QueryClient;\n}\n\nconst SynapContext = createContext<{\n podUrl: string;\n workspaceId: string;\n} | null>(null);\n\n/**\n * Returns the current pod context. Must be called inside <SynapProvider>.\n */\nexport function useSynapContext() {\n const ctx = useContext(SynapContext);\n if (!ctx)\n throw new Error(\"useSynapContext must be called inside <SynapProvider>\");\n return ctx;\n}\n\nexport function SynapProvider({\n children,\n queryClient: externalQueryClient,\n ...clientOptions\n}: SynapProviderProps) {\n const { podUrl, sessionToken, apiKey, workspaceId } = clientOptions;\n\n const [queryClient] = useState(\n () =>\n externalQueryClient ??\n new QueryClient({\n defaultOptions: {\n queries: { staleTime: 30_000, retry: 1 },\n },\n })\n );\n\n // Delegate to the SDK so every option (sessionToken, onAuthError,\n // extraHeaders) is honoured — the provider owns no transport of its own.\n // Deps are deliberately the credential fields, not `clientOptions` itself:\n // that object is rebuilt on every render, so depending on it would recreate\n // the client (and drop all in-flight query state) on every render.\n const trpcClient = useMemo(\n () => createSynapClient(clientOptions),\n [podUrl, sessionToken, apiKey, workspaceId]\n );\n\n const ctx = useMemo(() => ({ podUrl, workspaceId }), [podUrl, workspaceId]);\n\n return (\n <SynapContext.Provider value={ctx}>\n <trpc.Provider client={trpcClient} queryClient={queryClient}>\n <QueryClientProvider client={queryClient}>\n {children}\n </QueryClientProvider>\n </trpc.Provider>\n </SynapContext.Provider>\n );\n}\n","import { createTRPCReact, type CreateTRPCReact } from \"@trpc/react-query\";\nimport type { AppRouter } from \"@synap-core/api-types\";\n\n/**\n * tRPC React hooks — use via `useSynap()` from the provider context.\n * Exported for advanced use cases (e.g. calling `trpc.useUtils()`).\n */\nexport const trpc: CreateTRPCReact<AppRouter, unknown> =\n createTRPCReact<AppRouter>();\n","/**\n * Thin, self-contained data hooks over the published Synap SDK + TanStack Query.\n *\n * These wrap the `trpc` react-query client (the same instance exposed as\n * `useSynap`) — they do NOT import the monorepo `@synap-core/hooks` (which\n * couples Zustand stores, Yjs, notifications and is unpublishable). Each hook is\n * a thin pass-through to a single tRPC procedure so an external React app gets\n * ergonomic entity/relation/view access with zero hand-written query code.\n *\n * Procedure paths and input shapes mirror the canonical pod router:\n * - entities.get { id, includeProfile? }\n * - entities.list { profileSlug?, workspaceId?, projectId?, limit? }\n * - relations.get { entityId, direction? }\n * - views.get { id }\n *\n * Each hook's `opts` is the *exact* TanStack-Query options type of its\n * underlying procedure (derived via `Parameters<...useQuery>[1]`), so passthrough\n * options like `enabled` / `staleTime` keep full type-safety against that\n * procedure's data + error shapes.\n */\n\nimport { trpc } from \"./trpc\";\nimport type { RouterInputs, RouterOutputs } from \"./types\";\n\n/** The TanStack-Query options accepted by a given `useQuery` procedure. */\ntype QueryOptionsOf<P extends { useQuery: (...args: never[]) => unknown }> =\n NonNullable<Parameters<P[\"useQuery\"]>[1]>;\n\n/** The result type returned by a given `useQuery` procedure. */\ntype QueryResultOf<P extends { useQuery: (...args: never[]) => unknown }> =\n ReturnType<P[\"useQuery\"]>;\n\n/** The `useMutation` options accepted by a given mutation procedure. */\ntype MutationOptionsOf<\n P extends { useMutation: (...args: never[]) => unknown },\n> = NonNullable<Parameters<P[\"useMutation\"]>[0]>;\n\n/** The result type returned by a given `useMutation` procedure. */\ntype MutationResultOf<\n P extends { useMutation: (...args: never[]) => unknown },\n> = ReturnType<P[\"useMutation\"]>;\n\n/**\n * Fetch a single entity by id.\n *\n * @param id - Entity id.\n * @param opts - `{ includeProfile?, ...tanstackQueryOptions }`.\n */\nexport function useEntity(\n id: string,\n opts: { includeProfile?: boolean } & QueryOptionsOf<\n typeof trpc.entities.get\n > = {},\n): QueryResultOf<typeof trpc.entities.get> {\n const { includeProfile, ...queryOptions } = opts;\n const input: RouterInputs[\"entities\"][\"get\"] = { id, includeProfile };\n return trpc.entities.get.useQuery(input, {\n enabled: !!id,\n ...queryOptions,\n });\n}\n\n/**\n * List entities, optionally filtered by profile / workspace / project.\n *\n * @param profileSlug - Restrict to a single profile (e.g. \"person\", \"note\"). Omit for all.\n * @param opts - `{ workspaceId?, projectId?, limit?, ...tanstackQueryOptions }`.\n */\nexport function useEntities(\n profileSlug?: string,\n opts: {\n workspaceId?: string;\n projectId?: string;\n limit?: number;\n } & QueryOptionsOf<typeof trpc.entities.list> = {},\n): QueryResultOf<typeof trpc.entities.list> {\n const { workspaceId, projectId, limit, ...queryOptions } = opts;\n const input: RouterInputs[\"entities\"][\"list\"] = {\n profileSlug,\n workspaceId,\n projectId,\n limit,\n };\n return trpc.entities.list.useQuery(input, queryOptions);\n}\n\n/**\n * Fetch the relations/graph edges for an entity (both directions by default).\n *\n * @param entityId - The entity whose links to fetch.\n * @param opts - `{ direction?, ...tanstackQueryOptions }`.\n */\nexport function useLinks(\n entityId: string,\n opts: {\n direction?: RouterInputs[\"relations\"][\"get\"][\"direction\"];\n } & QueryOptionsOf<typeof trpc.relations.get> = {},\n): QueryResultOf<typeof trpc.relations.get> {\n const { direction = \"both\", ...queryOptions } = opts;\n const input: RouterInputs[\"relations\"][\"get\"] = { entityId, direction };\n return trpc.relations.get.useQuery(input, {\n enabled: !!entityId,\n ...queryOptions,\n });\n}\n\n/**\n * Fetch a view definition (config + query) by id.\n *\n * @param viewId - The view id.\n * @param opts - Passthrough TanStack Query options.\n */\nexport function useView(\n viewId: string,\n opts: QueryOptionsOf<typeof trpc.views.get> = {},\n): QueryResultOf<typeof trpc.views.get> {\n const input: RouterInputs[\"views\"][\"get\"] = { id: viewId };\n return trpc.views.get.useQuery(input, {\n enabled: !!viewId,\n ...opts,\n });\n}\n\n// NOTE: useTemplateCatalog / useInstallTemplate were removed — they referenced\n// tRPC procedures (workspaces.listInstallableTemplates / installFromCatalog) that\n// no longer exist in @synap-core/api-types, so they broke the dts build and could\n// never work. Re-add them here only once those procedures are back in api-types.\n\n/** Output type helpers for consumers that want to type derived state. */\nexport type UseEntityData = RouterOutputs[\"entities\"][\"get\"];\nexport type UseEntitiesData = RouterOutputs[\"entities\"][\"list\"];\nexport type UseLinksData = RouterOutputs[\"relations\"][\"get\"];\nexport type UseViewData = RouterOutputs[\"views\"][\"get\"];\n"],"mappings":";AAsBA,SAAgB,UAAU,eAAe,YAAY,eAAe;AACpE,SAAS,aAAa,2BAA2B;AACjD,SAAS,yBAAkD;;;ACxB3D,SAAS,uBAA6C;AAO/C,IAAM,OACX,gBAA2B;;;AD0ErB;AA/CR,IAAM,eAAe,cAGX,IAAI;AAKP,SAAS,kBAAkB;AAChC,QAAM,MAAM,WAAW,YAAY;AACnC,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,uDAAuD;AACzE,SAAO;AACT;AAEO,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA,aAAa;AAAA,EACb,GAAG;AACL,GAAuB;AACrB,QAA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AA,EACL,CAAC;AACH;AAQO,SAAS,QACd,QACA,OAA8C,CAAC,GACT;AACtC,QAAM,QAAsC,EAAE,IAAI,OAAO;AACzD,SAAO,KAAK,MAAM,IAAI,SAAS,OAAO;AAAA,IACpC,SAAS,CAAC,CAAC;AAAA,IACX,GAAG;AAAA,EACL,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../src/SynapProvider.tsx","../src/trpc.ts","../src/hooks.ts"],"sourcesContent":["/**\n * SynapProvider — wraps your React app with tRPC + TanStack Query\n * configured for a Synap data pod.\n *\n * Usage:\n * ```tsx\n * import { SynapProvider } from \"@synap-core/react\";\n *\n * function App() {\n * return (\n * <SynapProvider\n * podUrl=\"https://pod.example.com\"\n * sessionToken=\"...\"\n * workspaceId=\"ws_...\"\n * >\n * <YourApp />\n * </SynapProvider>\n * );\n * }\n * ```\n */\n\nimport React, { useState, createContext, useContext, useMemo } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport { createSynapClient, type SynapClientOptions } from \"@synap-core/sdk\";\nimport { trpc } from \"./trpc\";\n\nexport interface SynapProviderProps extends SynapClientOptions {\n children: React.ReactNode;\n /**\n * Provide your own QueryClient to share it with an existing TanStack Query setup.\n */\n queryClient?: QueryClient;\n}\n\nconst SynapContext = createContext<{\n podUrl: string;\n workspaceId: string;\n} | null>(null);\n\n/**\n * Returns the current pod context. Must be called inside <SynapProvider>.\n */\nexport function useSynapContext() {\n const ctx = useContext(SynapContext);\n if (!ctx)\n throw new Error(\"useSynapContext must be called inside <SynapProvider>\");\n return ctx;\n}\n\nexport function SynapProvider({\n children,\n queryClient: externalQueryClient,\n ...clientOptions\n}: SynapProviderProps) {\n const { podUrl, sessionToken, apiKey, workspaceId } = clientOptions;\n\n const [queryClient] = useState(\n () =>\n externalQueryClient ??\n new QueryClient({\n defaultOptions: {\n queries: { staleTime: 30_000, retry: 1 },\n },\n })\n );\n\n // Delegate to the SDK so every option (sessionToken, onAuthError,\n // extraHeaders) is honoured — the provider owns no transport of its own.\n // Deps are deliberately the credential fields, not `clientOptions` itself:\n // that object is rebuilt on every render, so depending on it would recreate\n // the client (and drop all in-flight query state) on every render.\n const trpcClient = useMemo(\n () => createSynapClient(clientOptions),\n [podUrl, sessionToken, apiKey, workspaceId]\n );\n\n const ctx = useMemo(() => ({ podUrl, workspaceId }), [podUrl, workspaceId]);\n\n return (\n <SynapContext.Provider value={ctx}>\n <trpc.Provider client={trpcClient} queryClient={queryClient}>\n <QueryClientProvider client={queryClient}>\n {children}\n </QueryClientProvider>\n </trpc.Provider>\n </SynapContext.Provider>\n );\n}\n","import { createTRPCReact, type CreateTRPCReact } from \"@trpc/react-query\";\nimport type { AppRouter } from \"@synap-core/api-types\";\n\n/**\n * tRPC React hooks, exported publicly as `useSynap`. Call hooks on the tree\n * directly (`useSynap.entities.list.useQuery(...)`, `useSynap.useUtils()`)\n * inside `<SynapProvider>`. Calling `useSynap()` itself returns undefined.\n */\nexport const trpc: CreateTRPCReact<AppRouter, unknown> =\n createTRPCReact<AppRouter>();\n","/**\n * Thin, self-contained data hooks over the published Synap SDK + TanStack Query.\n *\n * These wrap the `trpc` react-query client (the same instance exposed as\n * `useSynap`) — they do NOT import the monorepo `@synap-core/hooks` (which\n * couples Zustand stores, Yjs, notifications and is unpublishable). Each hook is\n * a thin pass-through to a single tRPC procedure so an external React app gets\n * ergonomic entity/relation/view access with zero hand-written query code.\n *\n * Procedure paths and input shapes mirror the canonical pod router:\n * - entities.get { id, includeProfile? }\n * - entities.list { profileSlug?, workspaceId?, projectId?, limit? }\n * - relations.get { entityId, direction? }\n * - views.get { id }\n *\n * Each hook's `opts` is the *exact* TanStack-Query options type of its\n * underlying procedure (derived via `Parameters<...useQuery>[1]`), so passthrough\n * options like `enabled` / `staleTime` keep full type-safety against that\n * procedure's data + error shapes.\n */\n\nimport { trpc } from \"./trpc\";\nimport type { RouterInputs, RouterOutputs } from \"./types\";\n\n/** The TanStack-Query options accepted by a given `useQuery` procedure. */\ntype QueryOptionsOf<P extends { useQuery: (...args: never[]) => unknown }> =\n NonNullable<Parameters<P[\"useQuery\"]>[1]>;\n\n/** The result type returned by a given `useQuery` procedure. */\ntype QueryResultOf<P extends { useQuery: (...args: never[]) => unknown }> =\n ReturnType<P[\"useQuery\"]>;\n\n/** The `useMutation` options accepted by a given mutation procedure. */\ntype MutationOptionsOf<\n P extends { useMutation: (...args: never[]) => unknown },\n> = NonNullable<Parameters<P[\"useMutation\"]>[0]>;\n\n/** The result type returned by a given `useMutation` procedure. */\ntype MutationResultOf<\n P extends { useMutation: (...args: never[]) => unknown },\n> = ReturnType<P[\"useMutation\"]>;\n\n/**\n * Fetch a single entity by id.\n *\n * @param id - Entity id.\n * @param opts - `{ includeProfile?, ...tanstackQueryOptions }`.\n */\nexport function useEntity(\n id: string,\n opts: { includeProfile?: boolean } & QueryOptionsOf<\n typeof trpc.entities.get\n > = {},\n): QueryResultOf<typeof trpc.entities.get> {\n const { includeProfile, ...queryOptions } = opts;\n const input: RouterInputs[\"entities\"][\"get\"] = { id, includeProfile };\n return trpc.entities.get.useQuery(input, {\n enabled: !!id,\n ...queryOptions,\n });\n}\n\n/**\n * List entities, optionally filtered by profile / workspace / project.\n *\n * @param profileSlug - Restrict to a single profile (e.g. \"person\", \"note\"). Omit for all.\n * @param opts - `{ workspaceId?, projectId?, limit?, ...tanstackQueryOptions }`.\n */\nexport function useEntities(\n profileSlug?: string,\n opts: {\n workspaceId?: string;\n projectId?: string;\n limit?: number;\n } & QueryOptionsOf<typeof trpc.entities.list> = {},\n): QueryResultOf<typeof trpc.entities.list> {\n const { workspaceId, projectId, limit, ...queryOptions } = opts;\n const input: RouterInputs[\"entities\"][\"list\"] = {\n profileSlug,\n workspaceId,\n projectId,\n limit,\n };\n return trpc.entities.list.useQuery(input, queryOptions);\n}\n\n/**\n * Fetch the relations/graph edges for an entity (both directions by default).\n *\n * @param entityId - The entity whose links to fetch.\n * @param opts - `{ direction?, ...tanstackQueryOptions }`.\n */\nexport function useLinks(\n entityId: string,\n opts: {\n direction?: RouterInputs[\"relations\"][\"get\"][\"direction\"];\n } & QueryOptionsOf<typeof trpc.relations.get> = {},\n): QueryResultOf<typeof trpc.relations.get> {\n const { direction = \"both\", ...queryOptions } = opts;\n const input: RouterInputs[\"relations\"][\"get\"] = { entityId, direction };\n return trpc.relations.get.useQuery(input, {\n enabled: !!entityId,\n ...queryOptions,\n });\n}\n\n/**\n * Fetch a view definition (config + query) by id.\n *\n * @param viewId - The view id.\n * @param opts - Passthrough TanStack Query options.\n */\nexport function useView(\n viewId: string,\n opts: QueryOptionsOf<typeof trpc.views.get> = {},\n): QueryResultOf<typeof trpc.views.get> {\n const input: RouterInputs[\"views\"][\"get\"] = { id: viewId };\n return trpc.views.get.useQuery(input, {\n enabled: !!viewId,\n ...opts,\n });\n}\n\n// NOTE: useTemplateCatalog / useInstallTemplate were removed — they referenced\n// tRPC procedures (workspaces.listInstallableTemplates / installFromCatalog) that\n// no longer exist in @synap-core/api-types, so they broke the dts build and could\n// never work. Re-add them here only once those procedures are back in api-types.\n\n/** Output type helpers for consumers that want to type derived state. */\nexport type UseEntityData = RouterOutputs[\"entities\"][\"get\"];\nexport type UseEntitiesData = RouterOutputs[\"entities\"][\"list\"];\nexport type UseLinksData = RouterOutputs[\"relations\"][\"get\"];\nexport type UseViewData = RouterOutputs[\"views\"][\"get\"];\n"],"mappings":";AAsBA,SAAgB,UAAU,eAAe,YAAY,eAAe;AACpE,SAAS,aAAa,2BAA2B;AACjD,SAAS,yBAAkD;;;ACxB3D,SAAS,uBAA6C;AAQ/C,IAAM,OACX,gBAA2B;;;ADyErB;AA/CR,IAAM,eAAe,cAGX,IAAI;AAKP,SAAS,kBAAkB;AAChC,QAAM,MAAM,WAAW,YAAY;AACnC,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,uDAAuD;AACzE,SAAO;AACT;AAEO,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA,aAAa;AAAA,EACb,GAAG;AACL,GAAuB;AACr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