@mastra/react 1.11.1-alpha.6 → 1.12.0-alpha.11
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.
- package/dist/{accumulator-C8kIc450.js → accumulator-BfvVnXJr.js} +1 -2
- package/dist/{accumulator-C8kIc450.js.map → accumulator-BfvVnXJr.js.map} +1 -1
- package/dist/{accumulator-BQGsraqS.cjs → accumulator-CgLQ_3q3.cjs} +1 -2
- package/dist/{accumulator-BQGsraqS.cjs.map → accumulator-CgLQ_3q3.cjs.map} +1 -1
- package/dist/agent/hooks.d.ts +9 -0
- package/dist/agent/hooks.d.ts.map +1 -1
- package/dist/chat/index.cjs +1 -1
- package/dist/chat/index.js +1 -2
- package/dist/combine-by-ids-D_lp6Dvq.cjs.map +1 -1
- package/dist/hooks/agents/index.cjs +2 -2
- package/dist/hooks/agents/index.cjs.map +1 -1
- package/dist/hooks/agents/index.js +2 -2
- package/dist/hooks/agents/index.js.map +1 -1
- package/dist/hooks/auth/index.cjs +2 -2
- package/dist/hooks/auth/index.cjs.map +1 -1
- package/dist/hooks/auth/index.js +2 -2
- package/dist/hooks/auth/index.js.map +1 -1
- package/dist/hooks/capabilities/index.cjs +1 -1
- package/dist/hooks/capabilities/index.cjs.map +1 -1
- package/dist/hooks/capabilities/index.js +1 -1
- package/dist/hooks/capabilities/index.js.map +1 -1
- package/dist/hooks/configuration/index.cjs.map +1 -1
- package/dist/hooks/datasets/index.cjs +1 -1
- package/dist/hooks/datasets/index.cjs.map +1 -1
- package/dist/hooks/datasets/index.js +1 -1
- package/dist/hooks/datasets/index.js.map +1 -1
- package/dist/hooks/embedders/index.cjs.map +1 -1
- package/dist/hooks/experiments/index.cjs.map +1 -1
- package/dist/hooks/feedback/index.cjs.map +1 -1
- package/dist/hooks/feedback/use-feedback.d.ts +3 -3
- package/dist/hooks/llm/index.cjs.map +1 -1
- package/dist/hooks/logs/index.cjs.map +1 -1
- package/dist/hooks/logs/use-logs.d.ts +3 -3
- package/dist/hooks/mcps/index.cjs.map +1 -1
- package/dist/hooks/memory/index.cjs +10 -10
- package/dist/hooks/memory/index.cjs.map +1 -1
- package/dist/hooks/memory/index.js +10 -10
- package/dist/hooks/memory/index.js.map +1 -1
- package/dist/hooks/metrics/index.cjs +13 -11
- package/dist/hooks/metrics/index.cjs.map +1 -1
- package/dist/hooks/metrics/index.js +13 -11
- package/dist/hooks/metrics/index.js.map +1 -1
- package/dist/hooks/processors/index.cjs.map +1 -1
- package/dist/hooks/prompt-blocks/index.cjs.map +1 -1
- package/dist/hooks/query/index.cjs.map +1 -1
- package/dist/hooks/review/index.cjs.map +1 -1
- package/dist/hooks/schedules/index.cjs.map +1 -1
- package/dist/hooks/scores/index.cjs.map +1 -1
- package/dist/hooks/templates/index.cjs +20 -18
- package/dist/hooks/templates/index.cjs.map +1 -1
- package/dist/hooks/templates/index.js +20 -18
- package/dist/hooks/templates/index.js.map +1 -1
- package/dist/hooks/tool-providers/index.cjs +1 -1
- package/dist/hooks/tool-providers/index.cjs.map +1 -1
- package/dist/hooks/tool-providers/index.js +1 -1
- package/dist/hooks/tool-providers/index.js.map +1 -1
- package/dist/hooks/tools/index.cjs.map +1 -1
- package/dist/hooks/traces/index.cjs +6 -5
- package/dist/hooks/traces/index.cjs.map +1 -1
- package/dist/hooks/traces/index.js +6 -5
- package/dist/hooks/traces/index.js.map +1 -1
- package/dist/hooks/traces/types.d.ts +1 -0
- package/dist/hooks/traces/types.d.ts.map +1 -1
- package/dist/hooks/traces/use-traces.d.ts +4 -4
- package/dist/hooks/vectors/index.cjs.map +1 -1
- package/dist/hooks/voice/index.cjs.map +1 -1
- package/dist/hooks/workflows/index.cjs +1 -1
- package/dist/hooks/workflows/index.cjs.map +1 -1
- package/dist/hooks/workflows/index.js +1 -1
- package/dist/hooks/workspace/index.cjs +1 -1
- package/dist/hooks/workspace/index.cjs.map +1 -1
- package/dist/hooks/workspace/index.js +1 -1
- package/dist/hooks/workspace/index.js.map +1 -1
- package/dist/{hooks-CIwCEruG.cjs → hooks-B1i-oHae.cjs} +27 -5
- package/dist/hooks-B1i-oHae.cjs.map +1 -0
- package/dist/{hooks-CbX7Q4A3.js → hooks-CLfMO5cH.js} +27 -5
- package/dist/hooks-CLfMO5cH.js.map +1 -0
- package/dist/{hooks-_YevKidX.cjs → hooks-D8nOYPUd.cjs} +2 -2
- package/dist/hooks-D8nOYPUd.cjs.map +1 -0
- package/dist/{hooks-0L0RNfau.js → hooks-NaZLZreZ.js} +2 -2
- package/dist/{hooks-0L0RNfau.js.map → hooks-NaZLZreZ.js.map} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/mastra-client-context-DzX3f0RF.cjs.map +1 -1
- package/dist/ui/index.cjs +4 -4
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +3 -3
- package/dist/ui/index.js.map +1 -1
- package/dist/use-in-view-B6eJO9Zi.cjs.map +1 -1
- package/dist/voice-BOtUdMi8.cjs.map +1 -1
- package/package.json +4 -4
- package/dist/hooks-CIwCEruG.cjs.map +0 -1
- package/dist/hooks-CbX7Q4A3.js.map +0 -1
- package/dist/hooks-_YevKidX.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/auth/types.ts","../../../src/hooks/auth/fetch-with-refresh.ts","../../../src/hooks/auth/get-client-query-key.ts","../../../src/hooks/auth/sso-login.ts","../../../src/hooks/auth/use-auth-capabilities.ts","../../../src/hooks/auth/use-current-user.ts","../../../src/hooks/auth/use-permission-patterns.ts","../../../src/hooks/auth/use-credentials-login.ts","../../../src/hooks/auth/use-credentials-signup.ts","../../../src/hooks/auth/use-auth-actions.ts"],"sourcesContent":["/**\n * Auth types for EE authentication in playground-ui.\n *\n * These types mirror the server schemas from @mastra/server.\n */\n\n/**\n * SSO configuration for login\n */\nexport type SSOConfig = {\n provider: string;\n text: string;\n icon?: string;\n description?: string;\n url: string;\n};\n\n/**\n * Login configuration\n */\nexport type LoginConfig = {\n type: 'sso' | 'credentials' | 'both';\n /** Whether sign-up is enabled (defaults to true) */\n signUpEnabled?: boolean;\n /** Optional description explaining the auth requirement and what credentials to use */\n description?: string;\n sso?: SSOConfig;\n} | null;\n\n/**\n * Public capabilities (unauthenticated)\n */\nexport type PublicAuthCapabilities = {\n enabled: boolean;\n login: LoginConfig;\n};\n\n/**\n * Authenticated user information\n */\nexport type AuthenticatedUser = {\n id: string;\n email?: string;\n name?: string;\n avatarUrl?: string;\n};\n\n/**\n * Capability flags\n */\nexport type CapabilityFlags = {\n user: boolean;\n session: boolean;\n sso: boolean;\n rbac: boolean;\n acl: boolean;\n};\n\n/**\n * User access information\n */\nexport type UserAccess = {\n roles: string[];\n permissions: string[];\n} | null;\n\n/**\n * Authenticated capabilities (extends public)\n */\nexport type AuthenticatedCapabilities = PublicAuthCapabilities & {\n user: AuthenticatedUser;\n capabilities: CapabilityFlags;\n access: UserAccess;\n /** Available roles in the system (only present for admin users) */\n availableRoles?: { id: string; name: string }[];\n};\n\n/**\n * Auth capabilities response (union of public and authenticated)\n */\nexport type AuthCapabilities = PublicAuthCapabilities | AuthenticatedCapabilities;\n\n/**\n * Current user response (may be null if not authenticated)\n */\nexport type CurrentUser = {\n id: string;\n email?: string;\n name?: string;\n avatarUrl?: string;\n roles?: string[];\n permissions?: string[];\n} | null;\n\n/**\n * SSO callback response\n */\nexport type SSOCallbackResponse = {\n success: boolean;\n user?: AuthenticatedUser;\n redirectTo?: string;\n};\n\n/**\n * Logout response\n */\nexport type LogoutResponse = {\n success: boolean;\n redirectTo?: string;\n};\n\n/**\n * Type guard to check if capabilities include authenticated user\n */\nexport function isAuthenticated(capabilities: AuthCapabilities): capabilities is AuthenticatedCapabilities {\n return 'user' in capabilities && capabilities.user !== undefined;\n}\n","/**\n * Fetch wrapper for the Mastra server API.\n *\n * ⚠️ MIRRORS: `platform/frontend/src/shared/lib/fetch-with-refresh.ts`\n *\n * Both files must stay behaviourally in lockstep — the platform dashboard and\n * the embedded playground both talk to WorkOS-backed auth and both would be\n * vulnerable to the same 429 lockout loop if either regressed. If you change\n * one, change the other in the same PR (or extract to a shared package —\n * currently blocked by the platform/mastra-ai monorepo boundary).\n *\n * ---\n *\n * The server middleware already refreshes the WorkOS session transparently\n * on every protected request. There is no scenario where the client can\n * succeed by calling /auth/refresh after a 401 — that endpoint hits the\n * same broken WorkOS with the same session and would only amplify transient\n * failures into forced logout (PLTFRM-1270).\n *\n * These are pass-throughs today. The names and signatures are preserved for\n * compatibility with existing call sites (`App.tsx`, `use-current-user.ts`).\n * Transient-failure retry belongs one level up — in React Query's `retry`\n * config on individual queries — not in a fetch wrapper that would compound\n * with the query-level retry.\n */\n\nexport async function fetchWithRefresh(\n _baseUrl: string,\n input: RequestInfo | URL,\n init?: RequestInit,\n): Promise<Response> {\n return fetch(input, init);\n}\n\nexport function createFetchWithRefresh(_baseUrl?: string, _apiPrefix?: string): typeof fetch {\n return (input, init) => fetch(input, init);\n}\n","import type { MastraClient } from '@mastra/client-js';\n\nconst clientQueryKeys = new WeakMap<MastraClient, number>();\nlet nextClientQueryKey = 0;\n\n/**\n * Returns a stable, non-sensitive query key for a Mastra client instance.\n * A new client is created whenever its connection options change.\n */\nexport function getClientQueryKey(client: MastraClient) {\n const existingKey = clientQueryKeys.get(client);\n if (existingKey !== undefined) return existingKey;\n\n const queryKey = nextClientQueryKey++;\n clientQueryKeys.set(client, queryKey);\n return queryKey;\n}\n","import type { MastraClient } from '@mastra/client-js';\n\nexport type SSOLoginResponse = {\n url: string;\n};\n\nexport async function makeSSOLoginRequest(\n client: Pick<MastraClient, 'options'>,\n { redirectUri }: { redirectUri?: string },\n): Promise<SSOLoginResponse> {\n const { baseUrl = '', apiPrefix, headers: clientHeaders = {} } = client.options;\n const raw = (apiPrefix || '/api').trim();\n const prefix = (raw.startsWith('/') ? raw : `/${raw}`).replace(/\\/$/, '');\n\n const params = new URLSearchParams();\n if (redirectUri) {\n params.set('redirect_uri', redirectUri);\n }\n\n const url = `${baseUrl}${prefix}/auth/sso/login${params.toString() ? `?${params}` : ''}`;\n\n const response = await fetch(url, {\n credentials: 'include',\n headers: {\n ...clientHeaders,\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw new Error(`Failed to initiate SSO login: ${response.status}`);\n }\n\n return response.json();\n}\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nimport { getClientQueryKey } from './get-client-query-key';\nimport type { AuthCapabilities } from './types';\n\n/**\n * Makes a request to the auth capabilities endpoint.\n * Exported for testing purposes.\n *\n * @internal\n */\nexport async function makeAuthCapabilitiesRequest(client: MastraClient): Promise<AuthCapabilities> {\n const { baseUrl = '', headers: clientHeaders = {}, apiPrefix } = client.options;\n const raw = (apiPrefix || '/api').trim();\n const prefix = (raw.startsWith('/') ? raw : `/${raw}`).replace(/\\/$/, '');\n\n const response = await fetch(`${baseUrl}${prefix}/auth/capabilities`, {\n credentials: 'include',\n headers: {\n ...clientHeaders,\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw new Error(`Failed to fetch auth capabilities: ${response.status}`);\n }\n\n return response.json();\n}\n\n/**\n * Hook to fetch authentication capabilities.\n *\n * Returns server-authoritative capability detection including:\n * - Whether auth is enabled\n * - Login configuration (SSO, credentials, or both)\n * - Current user (if authenticated)\n * - Available capabilities (user awareness, session, SSO, RBAC, ACL, audit)\n * - User access (roles and permissions)\n *\n * @example\n * ```tsx\n * import { useAuthCapabilities } from '@mastra/react/hooks/auth';\n *\n * function AuthStatus() {\n * const { data: capabilities, isLoading } = useAuthCapabilities();\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (!capabilities?.enabled) return <div>Auth not enabled</div>;\n *\n * if (isAuthenticated(capabilities)) {\n * return <div>Welcome, {capabilities.user.name}</div>;\n * }\n *\n * return <LoginButton config={capabilities.login} />;\n * }\n * ```\n */\nexport function useAuthCapabilities<TData = AuthCapabilities>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<AuthCapabilities, TData> } = {}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n\n return useQuery<AuthCapabilities, Error, TData>({\n queryKey: ['auth', 'capabilities', getClientQueryKey(client)],\n queryFn: () => makeAuthCapabilitiesRequest(client),\n staleTime: 60 * 1000, // Cache for 1 minute\n retry: false, // Don't retry auth requests\n ...queryOptions,\n });\n}\n","import type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nimport { fetchWithRefresh } from './fetch-with-refresh';\nimport type { CurrentUser } from './types';\n\nconst AUTH_TRANSIENT_MAX_RETRIES = 3;\nconst AUTH_TRANSIENT_MAX_BACKOFF_MS = 8_000;\n\nexport class CurrentUserError extends Error {\n constructor(public readonly status: number) {\n super(`Failed to fetch current user: ${status}`);\n this.name = 'CurrentUserError';\n }\n}\n\nexport function isUnauthenticatedError(error: unknown): boolean {\n return error instanceof CurrentUserError && error.status === 401;\n}\n\n/**\n * Hook to fetch the current authenticated user.\n *\n * Returns the current user if authenticated, null otherwise.\n * Includes roles and permissions if RBAC is available.\n *\n * Uses fetchWithRefresh to automatically refresh the session on 401 errors,\n * preventing users from being logged out when the access token expires.\n *\n * @example\n * ```tsx\n * import { useCurrentUser } from '@mastra/react/hooks/auth';\n *\n * function UserMenu() {\n * const { data: user, isLoading } = useCurrentUser();\n *\n * if (isLoading) return <Skeleton />;\n * if (!user) return <LoginButton />;\n *\n * return (\n * <Menu>\n * <Avatar src={user.avatarUrl} />\n * <span>{user.name || user.email}</span>\n * </Menu>\n * );\n * }\n * ```\n */\nexport function useCurrentUser<TData = CurrentUser>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<CurrentUser, TData> } = {}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n const baseUrl = client.options?.baseUrl || '';\n\n return useQuery<CurrentUser, Error, TData>({\n queryKey: ['auth', 'me'],\n queryFn: async () => {\n const response = await fetchWithRefresh(baseUrl, `${baseUrl}/api/auth/me`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw new CurrentUserError(response.status);\n }\n\n return response.json();\n },\n staleTime: 60 * 1000, // Cache for 1 minute\n // Retry the /api/auth/me query on transient auth-provider failures (HTTP 503)\n // so the UI stays in `isLoading` instead of flipping to `isError` and\n // triggering login — that redirect is what fed the WorkOS 429 lockout loop\n // (PLTFRM-1270). 401 (terminal) still fails fast.\n retry: (failureCount, error) => {\n if (!(error instanceof CurrentUserError)) return false;\n if (error.status !== 503) return false;\n return failureCount < AUTH_TRANSIENT_MAX_RETRIES;\n },\n retryDelay: attemptIndex => Math.min(AUTH_TRANSIENT_MAX_BACKOFF_MS, 500 * 2 ** attemptIndex),\n ...queryOptions,\n });\n}\n","import type { MastraClient, PermissionPattern } from '@mastra/client-js';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMemo } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nimport { getClientQueryKey } from './get-client-query-key';\nimport { isAuthenticated } from './types';\nimport { useAuthCapabilities } from './use-auth-capabilities';\n\n/**\n * Fetches the authoritative set of permission patterns from the server\n * (`GET /auth/permission-patterns`).\n *\n * The server owns the permission source of truth (generated from the route\n * registry), so the browser never imports the server-only `@mastra/core/auth/ee`\n * code just to validate hardcoded route-permission literals.\n *\n * The request only fires when RBAC is actually enabled — when auth is off or\n * RBAC isn't configured, route gating is a no-op so the pattern vocabulary is\n * not needed, and we avoid an unnecessary (and potentially 403/401) call.\n */\ntype PermissionPatternsResponse = Awaited<ReturnType<MastraClient['getPermissionPatterns']>>;\n\nexport const usePermissionPatterns = ({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<PermissionPatternsResponse> } = {}) => {\n const client = useMastraClient();\n const { data: capabilities, isLoading: capabilitiesLoading, error: capabilitiesError } = useAuthCapabilities();\n\n const rbacEnabled = !!(capabilities && isAuthenticated(capabilities) && capabilities.capabilities.rbac);\n\n const { data, isLoading, error } = useQuery({\n queryKey: ['permission-patterns', getClientQueryKey(client)],\n queryFn: () => client.getPermissionPatterns(),\n // Only fetch the pattern vocabulary when RBAC gating is in effect.\n enabled: rbacEnabled,\n // The endpoint requires auth; on 403/401 we don't want React Query to\n // thrash with retries (which toggles isLoading and re-triggers redirect\n // guards). One attempt is enough — gating falls back to the user's\n // permissions if the pattern set is empty.\n retry: false,\n staleTime: Infinity,\n ...queryOptions,\n });\n\n const patterns = useMemo(() => new Set<PermissionPattern>(data?.patterns ?? []), [data]);\n\n // While capabilities are resolving we don't yet know whether RBAC applies, so\n // report loading. Once RBAC is ruled out, this hook is never \"loading\".\n return { patterns, isLoading: capabilitiesLoading || (rbacEnabled && isLoading), error: capabilitiesError || error };\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\nexport type CredentialsLoginRequest = {\n email: string;\n password: string;\n};\n\nexport type CredentialsLoginResponse = {\n user?: {\n id: string;\n email: string;\n name?: string;\n };\n error?: string;\n};\n\n/**\n * Hook to login with email/password credentials.\n *\n * Uses Better Auth's email sign-in endpoint.\n *\n * @example\n * ```tsx\n * import { useCredentialsLogin } from '@mastra/react/hooks/auth';\n *\n * function LoginForm() {\n * const { mutate: login, isPending, error } = useCredentialsLogin();\n *\n * const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {\n * e.preventDefault();\n * const formData = new FormData(e.currentTarget);\n * login({\n * email: formData.get('email') as string,\n * password: formData.get('password') as string,\n * }, {\n * onSuccess: () => {\n * window.location.href = '/';\n * },\n * });\n * };\n *\n * return (\n * <form onSubmit={handleSubmit}>\n * <input name=\"email\" type=\"email\" required />\n * <input name=\"password\" type=\"password\" required />\n * <button type=\"submit\" disabled={isPending}>\n * Sign in\n * </button>\n * {error && <p>{error.message}</p>}\n * </form>\n * );\n * }\n * ```\n */\n/**\n * Makes a credentials sign-in request.\n * Exported for testing purposes.\n *\n * @internal\n */\nexport async function makeCredentialsLoginRequest(\n client: MastraClient,\n { email, password }: CredentialsLoginRequest,\n): Promise<CredentialsLoginResponse> {\n const { baseUrl = '', apiPrefix, headers: clientHeaders = {} } = client.options || {};\n const raw = (apiPrefix ?? '/api').trim();\n const normalized = raw === '' ? '' : raw.startsWith('/') ? raw : `/${raw}`;\n const prefix = normalized.replace(/\\/+$/, '');\n\n // Generic Mastra auth endpoint - works with any credentials provider\n const response = await fetch(`${baseUrl}${prefix}/auth/credentials/sign-in`, {\n method: 'POST',\n credentials: 'include',\n headers: {\n ...clientHeaders,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ email, password }),\n });\n\n const data = await response.json();\n\n if (!response.ok) {\n throw new Error(data.message || data.error || 'Invalid email or password');\n }\n\n return data;\n}\n\nexport function useCredentialsLogin({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<CredentialsLoginResponse, CredentialsLoginRequest> } = {}) {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<CredentialsLoginResponse, Error, CredentialsLoginRequest>({\n mutationFn: ({ email, password }) => makeCredentialsLoginRequest(client, { email, password }),\n onSuccess: () => {\n // Invalidate auth queries to refetch user state\n void queryClient.invalidateQueries({ queryKey: ['auth'] });\n },\n ...queryOptions,\n });\n}\n","import type { MastraClient } from '@mastra/client-js';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\nexport type CredentialsSignUpRequest = {\n email: string;\n password: string;\n name?: string;\n};\n\nexport type CredentialsSignUpResponse = {\n user?: {\n id: string;\n email: string;\n name?: string;\n };\n error?: string;\n};\n\n/**\n * Hook to sign up with email/password credentials.\n *\n * Uses Better Auth's email sign-up endpoint.\n *\n * @example\n * ```tsx\n * import { useCredentialsSignUp } from '@mastra/react/hooks/auth';\n *\n * function SignUpForm() {\n * const { mutate: signUp, isPending, error } = useCredentialsSignUp();\n *\n * const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {\n * e.preventDefault();\n * const formData = new FormData(e.currentTarget);\n * signUp({\n * email: formData.get('email') as string,\n * password: formData.get('password') as string,\n * name: formData.get('name') as string,\n * }, {\n * onSuccess: () => {\n * window.location.href = '/';\n * },\n * });\n * };\n *\n * return (\n * <form onSubmit={handleSubmit}>\n * <input name=\"name\" type=\"text\" />\n * <input name=\"email\" type=\"email\" required />\n * <input name=\"password\" type=\"password\" required />\n * <button type=\"submit\" disabled={isPending}>\n * Sign up\n * </button>\n * {error && <p>{error.message}</p>}\n * </form>\n * );\n * }\n * ```\n */\n/**\n * Makes a credentials sign-up request.\n * Exported for testing purposes.\n *\n * @internal\n */\nexport async function makeCredentialsSignUpRequest(\n client: MastraClient,\n { email, password, name }: CredentialsSignUpRequest,\n): Promise<CredentialsSignUpResponse> {\n const { baseUrl = '', apiPrefix, headers: clientHeaders = {} } = client.options || {};\n const raw = (apiPrefix ?? '/api').trim();\n const normalized = raw === '' ? '' : raw.startsWith('/') ? raw : `/${raw}`;\n const prefix = normalized.replace(/\\/+$/, '');\n\n // Generic Mastra auth endpoint - works with any credentials provider\n const response = await fetch(`${baseUrl}${prefix}/auth/credentials/sign-up`, {\n method: 'POST',\n credentials: 'include',\n headers: {\n ...clientHeaders,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ email, password, name }),\n });\n\n const data = await response.json();\n\n if (!response.ok) {\n throw new Error(data.message || data.error || 'Failed to create account');\n }\n\n return data;\n}\n\nexport function useCredentialsSignUp({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<CredentialsSignUpResponse, CredentialsSignUpRequest> } = {}) {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<CredentialsSignUpResponse, Error, CredentialsSignUpRequest>({\n mutationFn: ({ email, password, name }) => makeCredentialsSignUpRequest(client, { email, password, name }),\n onSuccess: () => {\n // Invalidate auth queries to refetch user state\n void queryClient.invalidateQueries({ queryKey: ['auth'] });\n },\n ...queryOptions,\n });\n}\n","import type { MastraClient } from '@mastra/client-js';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\nimport { makeSSOLoginRequest } from './sso-login';\nimport type { LogoutResponse } from './types';\n\n/**\n * Hook to initiate SSO login.\n *\n * Returns mutation to get the SSO login URL and redirect.\n *\n * @example\n * ```tsx\n * import { useSSOLogin } from '@mastra/react/hooks/auth';\n *\n * function SSOLoginButton() {\n * const { mutate: login, isPending } = useSSOLogin();\n *\n * const handleClick = () => {\n * login({ redirectUri: window.location.href }, {\n * onSuccess: (data) => {\n * window.location.href = data.url;\n * },\n * });\n * };\n *\n * return (\n * <button onClick={handleClick} disabled={isPending}>\n * Sign in with SSO\n * </button>\n * );\n * }\n * ```\n */\ntype SSOLoginResponse = Awaited<ReturnType<typeof makeSSOLoginRequest>>;\n\nexport function useSSOLogin({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<SSOLoginResponse, { redirectUri?: string }> } = {}) {\n const client = useMastraClient();\n\n return useMutation({\n mutationFn: ({ redirectUri }: { redirectUri?: string }) => makeSSOLoginRequest(client, { redirectUri }),\n ...queryOptions,\n });\n}\n\n/**\n * Hook to logout the current user.\n *\n * Destroys the current session and optionally redirects to\n * the SSO logout URL if available.\n *\n * @example\n * ```tsx\n * import { useLogout } from '@mastra/react/hooks/auth';\n *\n * function LogoutButton({ userId }: { userId: string }) {\n * const { mutate: logout, isPending } = useLogout();\n * const queryClient = useQueryClient();\n *\n * const handleLogout = () => {\n * logout({ userId }, {\n * onSuccess: (data) => {\n * queryClient.invalidateQueries({ queryKey: ['auth'] });\n * if (data.redirectTo) {\n * window.location.href = data.redirectTo;\n * } else {\n * window.location.reload();\n * }\n * },\n * });\n * };\n *\n * return (\n * <button onClick={handleLogout} disabled={isPending}>\n * Sign out\n * </button>\n * );\n * }\n * ```\n */\n/**\n * Makes a logout request.\n * Exported for testing purposes.\n *\n * @internal\n */\nexport async function makeLogoutRequest(client: Pick<MastraClient, 'options'>): Promise<LogoutResponse> {\n const { baseUrl = '', apiPrefix, headers: clientHeaders = {} } = client.options;\n const raw = (apiPrefix || '/api').trim();\n const prefix = (raw.startsWith('/') ? raw : `/${raw}`).replace(/\\/$/, '');\n\n const response = await fetch(`${baseUrl}${prefix}/auth/logout`, {\n method: 'POST',\n credentials: 'include',\n headers: {\n ...clientHeaders,\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw new Error(`Failed to logout: ${response.status}`);\n }\n\n return response.json();\n}\n\nexport interface UseLogoutOptions {\n /**\n * Runs once the server has ended the session, before the mutation resolves.\n * Failures are ignored so cleanup never turns a completed sign-out into an error.\n */\n onLoggedOut?: (variables: { userId: string }) => Promise<void>;\n queryOptions?: MastraMutationOptions<LogoutResponse, { userId: string }>;\n}\n\nexport function useLogout({ onLoggedOut, queryOptions }: UseLogoutOptions = {}) {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<LogoutResponse, Error, { userId: string }>({\n mutationFn: async variables => {\n const response = await makeLogoutRequest(client);\n await onLoggedOut?.(variables).catch(() => {});\n return response;\n },\n onSuccess: () => {\n // Invalidate all auth-related queries\n void queryClient.invalidateQueries({ queryKey: ['auth'] });\n },\n ...queryOptions,\n });\n}\n"],"mappings":";;;;;;;AAkHA,SAAgB,gBAAgB,cAA2E;CACzG,OAAO,UAAU,gBAAgB,aAAa,SAAS,KAAA;AACzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC1FA,eAAsB,iBACpB,UACA,OACA,MACmB;CACnB,OAAO,MAAM,OAAO,IAAI;AAC1B;AAEA,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ooks/auth/get-client-query-key.ts","../../../src/hooks/auth/sso-login.ts","../../../src/hooks/auth/use-auth-capabilities.ts","../../../src/hooks/auth/use-current-user.ts","../../../src/hooks/auth/use-permission-patterns.ts","../../../src/hooks/auth/use-credentials-login.ts","../../../src/hooks/auth/use-credentials-signup.ts","../../../src/hooks/auth/use-auth-actions.ts"],"sourcesContent":["/**\n * Auth types for EE authentication in playground-ui.\n *\n * These types mirror the server schemas from @mastra/server.\n */\n\n/**\n * SSO configuration for login\n */\nexport type SSOConfig = {\n provider: string;\n text: string;\n icon?: string;\n description?: string;\n url: string;\n};\n\n/**\n * Login configuration\n */\nexport type LoginConfig = {\n type: 'sso' | 'credentials' | 'both';\n /** Whether sign-up is enabled (defaults to true) */\n signUpEnabled?: boolean;\n /** Optional description explaining the auth requirement and what credentials to use */\n description?: string;\n sso?: SSOConfig;\n} | null;\n\n/**\n * Public capabilities (unauthenticated)\n */\nexport type PublicAuthCapabilities = {\n enabled: boolean;\n login: LoginConfig;\n};\n\n/**\n * Authenticated user information\n */\nexport type AuthenticatedUser = {\n id: string;\n email?: string;\n name?: string;\n avatarUrl?: string;\n};\n\n/**\n * Capability flags\n */\nexport type CapabilityFlags = {\n user: boolean;\n session: boolean;\n sso: boolean;\n rbac: boolean;\n acl: boolean;\n};\n\n/**\n * User access information\n */\nexport type UserAccess = {\n roles: string[];\n permissions: string[];\n} | null;\n\n/**\n * Authenticated capabilities (extends public)\n */\nexport type AuthenticatedCapabilities = PublicAuthCapabilities & {\n user: AuthenticatedUser;\n capabilities: CapabilityFlags;\n access: UserAccess;\n /** Available roles in the system (only present for admin users) */\n availableRoles?: { id: string; name: string }[];\n};\n\n/**\n * Auth capabilities response (union of public and authenticated)\n */\nexport type AuthCapabilities = PublicAuthCapabilities | AuthenticatedCapabilities;\n\n/**\n * Current user response (may be null if not authenticated)\n */\nexport type CurrentUser = {\n id: string;\n email?: string;\n name?: string;\n avatarUrl?: string;\n roles?: string[];\n permissions?: string[];\n} | null;\n\n/**\n * SSO callback response\n */\nexport type SSOCallbackResponse = {\n success: boolean;\n user?: AuthenticatedUser;\n redirectTo?: string;\n};\n\n/**\n * Logout response\n */\nexport type LogoutResponse = {\n success: boolean;\n redirectTo?: string;\n};\n\n/**\n * Type guard to check if capabilities include authenticated user\n */\nexport function isAuthenticated(capabilities: AuthCapabilities): capabilities is AuthenticatedCapabilities {\n return 'user' in capabilities && capabilities.user !== undefined;\n}\n","/**\n * Fetch wrapper for the Mastra server API.\n *\n * ⚠️ MIRRORS: `platform/frontend/src/shared/lib/fetch-with-refresh.ts`\n *\n * Both files must stay behaviourally in lockstep — the platform dashboard and\n * the embedded playground both talk to WorkOS-backed auth and both would be\n * vulnerable to the same 429 lockout loop if either regressed. If you change\n * one, change the other in the same PR (or extract to a shared package —\n * currently blocked by the platform/mastra-ai monorepo boundary).\n *\n * ---\n *\n * The server middleware already refreshes the WorkOS session transparently\n * on every protected request. There is no scenario where the client can\n * succeed by calling /auth/refresh after a 401 — that endpoint hits the\n * same broken WorkOS with the same session and would only amplify transient\n * failures into forced logout (PLTFRM-1270).\n *\n * These are pass-throughs today. The names and signatures are preserved for\n * compatibility with existing call sites (`App.tsx`, `use-current-user.ts`).\n * Transient-failure retry belongs one level up — in React Query's `retry`\n * config on individual queries — not in a fetch wrapper that would compound\n * with the query-level retry.\n */\n\nexport async function fetchWithRefresh(\n _baseUrl: string,\n input: RequestInfo | URL,\n init?: RequestInit,\n): Promise<Response> {\n return fetch(input, init);\n}\n\nexport function createFetchWithRefresh(_baseUrl?: string, _apiPrefix?: string): typeof fetch {\n return (input, init) => fetch(input, init);\n}\n","import type { MastraClient } from '@mastra/client-js';\n\nconst clientQueryKeys = new WeakMap<MastraClient, number>();\nlet nextClientQueryKey = 0;\n\n/**\n * Returns a stable, non-sensitive query key for a Mastra client instance.\n * A new client is created whenever its connection options change.\n */\nexport function getClientQueryKey(client: MastraClient) {\n const existingKey = clientQueryKeys.get(client);\n if (existingKey !== undefined) return existingKey;\n\n const queryKey = nextClientQueryKey++;\n clientQueryKeys.set(client, queryKey);\n return queryKey;\n}\n","import type { MastraClient } from '@mastra/client-js';\n\nexport type SSOLoginResponse = {\n url: string;\n};\n\nexport async function makeSSOLoginRequest(\n client: Pick<MastraClient, 'options'>,\n { redirectUri }: { redirectUri?: string },\n): Promise<SSOLoginResponse> {\n const { baseUrl = '', apiPrefix, headers: clientHeaders = {} } = client.options;\n const raw = (apiPrefix || '/api').trim();\n const prefix = (raw.startsWith('/') ? raw : `/${raw}`).replace(/\\/$/, '');\n\n const params = new URLSearchParams();\n if (redirectUri) {\n params.set('redirect_uri', redirectUri);\n }\n\n const url = `${baseUrl}${prefix}/auth/sso/login${params.toString() ? `?${params}` : ''}`;\n\n const response = await fetch(url, {\n credentials: 'include',\n headers: {\n ...clientHeaders,\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw new Error(`Failed to initiate SSO login: ${response.status}`);\n }\n\n return response.json();\n}\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nimport { getClientQueryKey } from './get-client-query-key';\nimport type { AuthCapabilities } from './types';\n\n/**\n * Makes a request to the auth capabilities endpoint.\n * Exported for testing purposes.\n *\n * @internal\n */\nexport async function makeAuthCapabilitiesRequest(client: MastraClient): Promise<AuthCapabilities> {\n const { baseUrl = '', headers: clientHeaders = {}, apiPrefix } = client.options;\n const raw = (apiPrefix || '/api').trim();\n const prefix = (raw.startsWith('/') ? raw : `/${raw}`).replace(/\\/$/, '');\n\n const response = await fetch(`${baseUrl}${prefix}/auth/capabilities`, {\n credentials: 'include',\n headers: {\n ...clientHeaders,\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw new Error(`Failed to fetch auth capabilities: ${response.status}`);\n }\n\n return response.json();\n}\n\n/**\n * Hook to fetch authentication capabilities.\n *\n * Returns server-authoritative capability detection including:\n * - Whether auth is enabled\n * - Login configuration (SSO, credentials, or both)\n * - Current user (if authenticated)\n * - Available capabilities (user awareness, session, SSO, RBAC, ACL, audit)\n * - User access (roles and permissions)\n *\n * @example\n * ```tsx\n * import { useAuthCapabilities } from '@mastra/react/hooks/auth';\n *\n * function AuthStatus() {\n * const { data: capabilities, isLoading } = useAuthCapabilities();\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (!capabilities?.enabled) return <div>Auth not enabled</div>;\n *\n * if (isAuthenticated(capabilities)) {\n * return <div>Welcome, {capabilities.user.name}</div>;\n * }\n *\n * return <LoginButton config={capabilities.login} />;\n * }\n * ```\n */\nexport function useAuthCapabilities<TData = AuthCapabilities>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<AuthCapabilities, TData> } = {}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n\n return useQuery<AuthCapabilities, Error, TData>({\n queryKey: ['auth', 'capabilities', getClientQueryKey(client)],\n queryFn: () => makeAuthCapabilitiesRequest(client),\n staleTime: 60 * 1000, // Cache for 1 minute\n retry: false, // Don't retry auth requests\n ...queryOptions,\n });\n}\n","import type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nimport { fetchWithRefresh } from './fetch-with-refresh';\nimport type { CurrentUser } from './types';\n\nconst AUTH_TRANSIENT_MAX_RETRIES = 3;\nconst AUTH_TRANSIENT_MAX_BACKOFF_MS = 8_000;\n\nexport class CurrentUserError extends Error {\n constructor(public readonly status: number) {\n super(`Failed to fetch current user: ${status}`);\n this.name = 'CurrentUserError';\n }\n}\n\nexport function isUnauthenticatedError(error: unknown): boolean {\n return error instanceof CurrentUserError && error.status === 401;\n}\n\n/**\n * Hook to fetch the current authenticated user.\n *\n * Returns the current user if authenticated, null otherwise.\n * Includes roles and permissions if RBAC is available.\n *\n * Uses fetchWithRefresh to automatically refresh the session on 401 errors,\n * preventing users from being logged out when the access token expires.\n *\n * @example\n * ```tsx\n * import { useCurrentUser } from '@mastra/react/hooks/auth';\n *\n * function UserMenu() {\n * const { data: user, isLoading } = useCurrentUser();\n *\n * if (isLoading) return <Skeleton />;\n * if (!user) return <LoginButton />;\n *\n * return (\n * <Menu>\n * <Avatar src={user.avatarUrl} />\n * <span>{user.name || user.email}</span>\n * </Menu>\n * );\n * }\n * ```\n */\nexport function useCurrentUser<TData = CurrentUser>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<CurrentUser, TData> } = {}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n const baseUrl = client.options?.baseUrl || '';\n\n return useQuery<CurrentUser, Error, TData>({\n queryKey: ['auth', 'me'],\n queryFn: async () => {\n const response = await fetchWithRefresh(baseUrl, `${baseUrl}/api/auth/me`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw new CurrentUserError(response.status);\n }\n\n return response.json();\n },\n staleTime: 60 * 1000, // Cache for 1 minute\n // Retry the /api/auth/me query on transient auth-provider failures (HTTP 503)\n // so the UI stays in `isLoading` instead of flipping to `isError` and\n // triggering login — that redirect is what fed the WorkOS 429 lockout loop\n // (PLTFRM-1270). 401 (terminal) still fails fast.\n retry: (failureCount, error) => {\n if (!(error instanceof CurrentUserError)) return false;\n if (error.status !== 503) return false;\n return failureCount < AUTH_TRANSIENT_MAX_RETRIES;\n },\n retryDelay: attemptIndex => Math.min(AUTH_TRANSIENT_MAX_BACKOFF_MS, 500 * 2 ** attemptIndex),\n ...queryOptions,\n });\n}\n","import type { MastraClient, PermissionPattern } from '@mastra/client-js';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMemo } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nimport { getClientQueryKey } from './get-client-query-key';\nimport { isAuthenticated } from './types';\nimport { useAuthCapabilities } from './use-auth-capabilities';\n\n/**\n * Fetches the authoritative set of permission patterns from the server\n * (`GET /auth/permission-patterns`).\n *\n * The server owns the permission source of truth (generated from the route\n * registry), so the browser never imports the server-only `@mastra/core/auth/ee`\n * code just to validate hardcoded route-permission literals.\n *\n * The request only fires when RBAC is actually enabled — when auth is off or\n * RBAC isn't configured, route gating is a no-op so the pattern vocabulary is\n * not needed, and we avoid an unnecessary (and potentially 403/401) call.\n */\ntype PermissionPatternsResponse = Awaited<ReturnType<MastraClient['getPermissionPatterns']>>;\n\nexport const usePermissionPatterns = ({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<PermissionPatternsResponse> } = {}) => {\n const client = useMastraClient();\n const { data: capabilities, isLoading: capabilitiesLoading, error: capabilitiesError } = useAuthCapabilities();\n\n const rbacEnabled = !!(capabilities && isAuthenticated(capabilities) && capabilities.capabilities.rbac);\n\n const { data, isLoading, error } = useQuery({\n queryKey: ['permission-patterns', getClientQueryKey(client)],\n queryFn: () => client.getPermissionPatterns(),\n // Only fetch the pattern vocabulary when RBAC gating is in effect.\n enabled: rbacEnabled,\n // The endpoint requires auth; on 403/401 we don't want React Query to\n // thrash with retries (which toggles isLoading and re-triggers redirect\n // guards). One attempt is enough — gating falls back to the user's\n // permissions if the pattern set is empty.\n retry: false,\n staleTime: Infinity,\n ...queryOptions,\n });\n\n const patterns = useMemo(() => new Set<PermissionPattern>(data?.patterns ?? []), [data]);\n\n // While capabilities are resolving we don't yet know whether RBAC applies, so\n // report loading. Once RBAC is ruled out, this hook is never \"loading\".\n return { patterns, isLoading: capabilitiesLoading || (rbacEnabled && isLoading), error: capabilitiesError || error };\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\nexport type CredentialsLoginRequest = {\n email: string;\n password: string;\n};\n\nexport type CredentialsLoginResponse = {\n user?: {\n id: string;\n email: string;\n name?: string;\n };\n error?: string;\n};\n\n/**\n * Hook to login with email/password credentials.\n *\n * Uses Better Auth's email sign-in endpoint.\n *\n * @example\n * ```tsx\n * import { useCredentialsLogin } from '@mastra/react/hooks/auth';\n *\n * function LoginForm() {\n * const { mutate: login, isPending, error } = useCredentialsLogin();\n *\n * const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {\n * e.preventDefault();\n * const formData = new FormData(e.currentTarget);\n * login({\n * email: formData.get('email') as string,\n * password: formData.get('password') as string,\n * }, {\n * onSuccess: () => {\n * window.location.href = '/';\n * },\n * });\n * };\n *\n * return (\n * <form onSubmit={handleSubmit}>\n * <input name=\"email\" type=\"email\" required />\n * <input name=\"password\" type=\"password\" required />\n * <button type=\"submit\" disabled={isPending}>\n * Sign in\n * </button>\n * {error && <p>{error.message}</p>}\n * </form>\n * );\n * }\n * ```\n */\n/**\n * Makes a credentials sign-in request.\n * Exported for testing purposes.\n *\n * @internal\n */\nexport async function makeCredentialsLoginRequest(\n client: MastraClient,\n { email, password }: CredentialsLoginRequest,\n): Promise<CredentialsLoginResponse> {\n const { baseUrl = '', apiPrefix, headers: clientHeaders = {} } = client.options || {};\n const raw = (apiPrefix ?? '/api').trim();\n const normalized = raw === '' ? '' : raw.startsWith('/') ? raw : `/${raw}`;\n const prefix = normalized.replace(/\\/+$/, '');\n\n // Generic Mastra auth endpoint - works with any credentials provider\n const response = await fetch(`${baseUrl}${prefix}/auth/credentials/sign-in`, {\n method: 'POST',\n credentials: 'include',\n headers: {\n ...clientHeaders,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ email, password }),\n });\n\n const data = await response.json();\n\n if (!response.ok) {\n throw new Error(data.message || data.error || 'Invalid email or password');\n }\n\n return data;\n}\n\nexport function useCredentialsLogin({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<CredentialsLoginResponse, CredentialsLoginRequest> } = {}) {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<CredentialsLoginResponse, Error, CredentialsLoginRequest>({\n mutationFn: ({ email, password }) => makeCredentialsLoginRequest(client, { email, password }),\n onSuccess: () => {\n // Invalidate auth queries to refetch user state\n void queryClient.invalidateQueries({ queryKey: ['auth'] });\n },\n ...queryOptions,\n });\n}\n","import type { MastraClient } from '@mastra/client-js';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\nexport type CredentialsSignUpRequest = {\n email: string;\n password: string;\n name?: string;\n};\n\nexport type CredentialsSignUpResponse = {\n user?: {\n id: string;\n email: string;\n name?: string;\n };\n error?: string;\n};\n\n/**\n * Hook to sign up with email/password credentials.\n *\n * Uses Better Auth's email sign-up endpoint.\n *\n * @example\n * ```tsx\n * import { useCredentialsSignUp } from '@mastra/react/hooks/auth';\n *\n * function SignUpForm() {\n * const { mutate: signUp, isPending, error } = useCredentialsSignUp();\n *\n * const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {\n * e.preventDefault();\n * const formData = new FormData(e.currentTarget);\n * signUp({\n * email: formData.get('email') as string,\n * password: formData.get('password') as string,\n * name: formData.get('name') as string,\n * }, {\n * onSuccess: () => {\n * window.location.href = '/';\n * },\n * });\n * };\n *\n * return (\n * <form onSubmit={handleSubmit}>\n * <input name=\"name\" type=\"text\" />\n * <input name=\"email\" type=\"email\" required />\n * <input name=\"password\" type=\"password\" required />\n * <button type=\"submit\" disabled={isPending}>\n * Sign up\n * </button>\n * {error && <p>{error.message}</p>}\n * </form>\n * );\n * }\n * ```\n */\n/**\n * Makes a credentials sign-up request.\n * Exported for testing purposes.\n *\n * @internal\n */\nexport async function makeCredentialsSignUpRequest(\n client: MastraClient,\n { email, password, name }: CredentialsSignUpRequest,\n): Promise<CredentialsSignUpResponse> {\n const { baseUrl = '', apiPrefix, headers: clientHeaders = {} } = client.options || {};\n const raw = (apiPrefix ?? '/api').trim();\n const normalized = raw === '' ? '' : raw.startsWith('/') ? raw : `/${raw}`;\n const prefix = normalized.replace(/\\/+$/, '');\n\n // Generic Mastra auth endpoint - works with any credentials provider\n const response = await fetch(`${baseUrl}${prefix}/auth/credentials/sign-up`, {\n method: 'POST',\n credentials: 'include',\n headers: {\n ...clientHeaders,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ email, password, name }),\n });\n\n const data = await response.json();\n\n if (!response.ok) {\n throw new Error(data.message || data.error || 'Failed to create account');\n }\n\n return data;\n}\n\nexport function useCredentialsSignUp({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<CredentialsSignUpResponse, CredentialsSignUpRequest> } = {}) {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<CredentialsSignUpResponse, Error, CredentialsSignUpRequest>({\n mutationFn: ({ email, password, name }) => makeCredentialsSignUpRequest(client, { email, password, name }),\n onSuccess: () => {\n // Invalidate auth queries to refetch user state\n void queryClient.invalidateQueries({ queryKey: ['auth'] });\n },\n ...queryOptions,\n });\n}\n","import type { MastraClient } from '@mastra/client-js';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\nimport { makeSSOLoginRequest } from './sso-login';\nimport type { LogoutResponse } from './types';\n\n/**\n * Hook to initiate SSO login.\n *\n * Returns mutation to get the SSO login URL and redirect.\n *\n * @example\n * ```tsx\n * import { useSSOLogin } from '@mastra/react/hooks/auth';\n *\n * function SSOLoginButton() {\n * const { mutate: login, isPending } = useSSOLogin();\n *\n * const handleClick = () => {\n * login({ redirectUri: window.location.href }, {\n * onSuccess: (data) => {\n * window.location.href = data.url;\n * },\n * });\n * };\n *\n * return (\n * <button onClick={handleClick} disabled={isPending}>\n * Sign in with SSO\n * </button>\n * );\n * }\n * ```\n */\ntype SSOLoginResponse = Awaited<ReturnType<typeof makeSSOLoginRequest>>;\n\nexport function useSSOLogin({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<SSOLoginResponse, { redirectUri?: string }> } = {}) {\n const client = useMastraClient();\n\n return useMutation({\n mutationFn: ({ redirectUri }: { redirectUri?: string }) => makeSSOLoginRequest(client, { redirectUri }),\n ...queryOptions,\n });\n}\n\n/**\n * Hook to logout the current user.\n *\n * Destroys the current session and optionally redirects to\n * the SSO logout URL if available.\n *\n * @example\n * ```tsx\n * import { useLogout } from '@mastra/react/hooks/auth';\n *\n * function LogoutButton({ userId }: { userId: string }) {\n * const { mutate: logout, isPending } = useLogout();\n * const queryClient = useQueryClient();\n *\n * const handleLogout = () => {\n * logout({ userId }, {\n * onSuccess: (data) => {\n * queryClient.invalidateQueries({ queryKey: ['auth'] });\n * if (data.redirectTo) {\n * window.location.href = data.redirectTo;\n * } else {\n * window.location.reload();\n * }\n * },\n * });\n * };\n *\n * return (\n * <button onClick={handleLogout} disabled={isPending}>\n * Sign out\n * </button>\n * );\n * }\n * ```\n */\n/**\n * Makes a logout request.\n * Exported for testing purposes.\n *\n * @internal\n */\nexport async function makeLogoutRequest(client: Pick<MastraClient, 'options'>): Promise<LogoutResponse> {\n const { baseUrl = '', apiPrefix, headers: clientHeaders = {} } = client.options;\n const raw = (apiPrefix || '/api').trim();\n const prefix = (raw.startsWith('/') ? raw : `/${raw}`).replace(/\\/$/, '');\n\n const response = await fetch(`${baseUrl}${prefix}/auth/logout`, {\n method: 'POST',\n credentials: 'include',\n headers: {\n ...clientHeaders,\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw new Error(`Failed to logout: ${response.status}`);\n }\n\n return response.json();\n}\n\nexport interface UseLogoutOptions {\n /**\n * Runs once the server has ended the session, before the mutation resolves.\n * Failures are ignored so cleanup never turns a completed sign-out into an error.\n */\n onLoggedOut?: (variables: { userId: string }) => Promise<void>;\n queryOptions?: MastraMutationOptions<LogoutResponse, { userId: string }>;\n}\n\nexport function useLogout({ onLoggedOut, queryOptions }: UseLogoutOptions = {}) {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<LogoutResponse, Error, { userId: string }>({\n mutationFn: async variables => {\n const response = await makeLogoutRequest(client);\n await onLoggedOut?.(variables).catch(() => {});\n return response;\n },\n onSuccess: () => {\n // Invalidate all auth-related queries\n void queryClient.invalidateQueries({ queryKey: ['auth'] });\n },\n ...queryOptions,\n });\n}\n"],"mappings":";;;;;;;AAkHA,SAAgB,gBAAgB,cAA2E;CACzG,OAAO,UAAU,gBAAgB,aAAa,SAAS,KAAA;AACzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC1FA,eAAsB,iBACpB,UACA,OACA,MACmB;CACnB,OAAO,MAAM,OAAO,IAAI;AAC1B;AAEA,SAAgB,uBAAuB,UAAmB,YAAmC;CAC3F,QAAQ,OAAO,SAAS,MAAM,OAAO,IAAI;AAC3C;;;AClCA,MAAM,kCAAkB,IAAI,QAA8B;AAC1D,IAAI,qBAAqB;;;;;AAMzB,SAAgB,kBAAkB,QAAsB;CACtD,MAAM,cAAc,gBAAgB,IAAI,MAAM;CAC9C,IAAI,gBAAgB,KAAA,GAAW,OAAO;CAEtC,MAAM,WAAW;CACjB,gBAAgB,IAAI,QAAQ,QAAQ;CACpC,OAAO;AACT;;;ACVA,eAAsB,oBACpB,QACA,EAAE,eACyB;CAC3B,MAAM,EAAE,UAAU,IAAI,WAAW,SAAS,gBAAgB,CAAC,MAAM,OAAO;CACxE,MAAM,OAAO,aAAa,OAAA,CAAQ,KAAK;CACvC,MAAM,UAAU,IAAI,WAAW,GAAG,IAAI,MAAM,IAAI,MAAA,CAAO,QAAQ,OAAO,EAAE;CAExE,MAAM,SAAS,IAAI,gBAAgB;CACnC,IAAI,aACF,OAAO,IAAI,gBAAgB,WAAW;CAGxC,MAAM,MAAM,GAAG,UAAU,OAAO,iBAAiB,OAAO,SAAS,IAAI,IAAI,WAAW;CAEpF,MAAM,WAAW,MAAM,MAAM,KAAK;EAChC,aAAa;EACb,SAAS;GACP,GAAG;GACH,gBAAgB;EAClB;CACF,CAAC;CAED,IAAI,CAAC,SAAS,IACZ,MAAM,IAAI,MAAM,iCAAiC,SAAS,Q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C5D,YAAY,OAAM,cAAa;GAC7B,MAAM,WAAW,MAAM,kBAAkB,MAAM;GAC/C,MAAM,cAAc,SAAS,CAAC,CAAC,YAAY,CAAC,CAAC;GAC7C,OAAO;EACT;EACA,iBAAiB;GAEf,YAAiB,kBAAkB,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC;EAC3D;EACA,GAAG;CACL,CAAC;AACH"}
|
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_mastra_client_context = require("../../mastra-client-context-DzX3f0RF.cjs");
|
|
3
3
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
4
4
|
//#region src/hooks/capabilities/use-observability-capabilities.ts
|
|
5
|
-
const OBSERVABILITY_CAPABILITIES_STALE_TIME =
|
|
5
|
+
const OBSERVABILITY_CAPABILITIES_STALE_TIME = 864e5;
|
|
6
6
|
const useObservabilityCapabilities = ({ queryOptions } = {}) => {
|
|
7
7
|
const client = require_mastra_client_context.useMastraClient();
|
|
8
8
|
return (0, _tanstack_react_query.useQuery)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useMastraClient"],"sources":["../../../src/hooks/capabilities/use-observability-capabilities.ts","../../../src/hooks/capabilities/use-trace-query-available.ts","../../../src/hooks/capabilities/use-trace-aggregate-available.ts","../../../src/hooks/capabilities/use-trace-query-discovery-available.ts","../../../src/hooks/capabilities/use-trace-query-root-duration-available.ts","../../../src/hooks/capabilities/use-feedback-available.ts"],"sourcesContent":["import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nconst OBSERVABILITY_CAPABILITIES_STALE_TIME = 24 * 60 * 60 * 1000;\n\ntype ObservabilityCapabilitiesResponse = Awaited<ReturnType<MastraClient['getObservabilityCapabilities']>>;\n\nexport const useObservabilityCapabilities = <TData = ObservabilityCapabilitiesResponse>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<ObservabilityCapabilitiesResponse, TData> } = {}): UseQueryResult<\n TData,\n Error\n> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['observability-capabilities'],\n queryFn: () => client.getObservabilityCapabilities(),\n retry: false,\n staleTime: OBSERVABILITY_CAPABILITIES_STALE_TIME,\n ...queryOptions,\n });\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * `enabled` stays false while capabilities load. Servers without the\n * capabilities endpoint fall back to `true` (trace query was the default before).\n */\nexport const useTraceQueryAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && (data?.capabilities.traceQuery ?? true),\n };\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * Whether the server can answer `aggregateTraces()`. `enabled` stays false while capabilities load.\n * Unlike trace query, a missing `traceAggregate` (an older server) or a missing capabilities endpoint\n * means aggregation is unavailable.\n */\nexport const useTraceAggregateAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && data?.capabilities.traceAggregate === true,\n };\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * Whether the store supports trace query field/value discovery. Callers combine it with\n * `useTraceQueryAvailable` when they also need the trace query API. `enabled` stays false\n * while capabilities load; servers without the capabilities endpoint fall back to `true`.\n */\nexport const useTraceQueryDiscoveryAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && (data?.capabilities.traceQueryDiscovery ?? true),\n };\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * Whether the store supports trace-level `durationMs` (root duration) predicates in trace queries.\n * `enabled` stays false while capabilities load, and also when the capability is missing: older\n * servers reject `durationMs` predicates, so this does not fall back to `true`.\n */\nexport const useTraceQueryRootDurationAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && (data?.capabilities.traceQueryRootDuration ?? false),\n };\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * `enabled` stays false while capabilities load. Servers without the\n * capabilities endpoint fall back to `true` (feedback was shown by default before).\n */\nexport const useFeedbackAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && (data?.capabilities.feedback ?? true),\n };\n};\n"],"mappings":";;;;AAMA,MAAM,wCAAwC
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useMastraClient","useQuery"],"sources":["../../../src/hooks/capabilities/use-observability-capabilities.ts","../../../src/hooks/capabilities/use-trace-query-available.ts","../../../src/hooks/capabilities/use-trace-aggregate-available.ts","../../../src/hooks/capabilities/use-trace-query-discovery-available.ts","../../../src/hooks/capabilities/use-trace-query-root-duration-available.ts","../../../src/hooks/capabilities/use-feedback-available.ts"],"sourcesContent":["import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nconst OBSERVABILITY_CAPABILITIES_STALE_TIME = 24 * 60 * 60 * 1000;\n\ntype ObservabilityCapabilitiesResponse = Awaited<ReturnType<MastraClient['getObservabilityCapabilities']>>;\n\nexport const useObservabilityCapabilities = <TData = ObservabilityCapabilitiesResponse>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<ObservabilityCapabilitiesResponse, TData> } = {}): UseQueryResult<\n TData,\n Error\n> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['observability-capabilities'],\n queryFn: () => client.getObservabilityCapabilities(),\n retry: false,\n staleTime: OBSERVABILITY_CAPABILITIES_STALE_TIME,\n ...queryOptions,\n });\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * `enabled` stays false while capabilities load. Servers without the\n * capabilities endpoint fall back to `true` (trace query was the default before).\n */\nexport const useTraceQueryAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && (data?.capabilities.traceQuery ?? true),\n };\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * Whether the server can answer `aggregateTraces()`. `enabled` stays false while capabilities load.\n * Unlike trace query, a missing `traceAggregate` (an older server) or a missing capabilities endpoint\n * means aggregation is unavailable.\n */\nexport const useTraceAggregateAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && data?.capabilities.traceAggregate === true,\n };\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * Whether the store supports trace query field/value discovery. Callers combine it with\n * `useTraceQueryAvailable` when they also need the trace query API. `enabled` stays false\n * while capabilities load; servers without the capabilities endpoint fall back to `true`.\n */\nexport const useTraceQueryDiscoveryAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && (data?.capabilities.traceQueryDiscovery ?? true),\n };\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * Whether the store supports trace-level `durationMs` (root duration) predicates in trace queries.\n * `enabled` stays false while capabilities load, and also when the capability is missing: older\n * servers reject `durationMs` predicates, so this does not fall back to `true`.\n */\nexport const useTraceQueryRootDurationAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && (data?.capabilities.traceQueryRootDuration ?? false),\n };\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * `enabled` stays false while capabilities load. Servers without the\n * capabilities endpoint fall back to `true` (feedback was shown by default before).\n */\nexport const useFeedbackAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && (data?.capabilities.feedback ?? true),\n };\n};\n"],"mappings":";;;;AAMA,MAAM,wCAAwC;AAI9C,MAAa,gCAA2E,EACtF,iBACmF,CAAC,MAGjF;CACH,MAAM,SAASA,8BAAAA,gBAAgB;CAE/B,QAAA,GAAOC,sBAAAA,SAAAA,CAAS;EACd,UAAU,CAAC,4BAA4B;EACvC,eAAe,OAAO,6BAA6B;EACnD,OAAO;EACP,WAAW;EACX,GAAG;CACL,CAAC;AACH;;;;;;;ACnBA,MAAa,+BAAyE;CACpF,MAAM,EAAE,MAAM,cAAc,6BAA6B;CAEzD,OAAO;EACL;EACA,SAAS,CAAC,cAAc,MAAM,aAAa,cAAc;CAC3D;AACF;;;;;;;;ACNA,MAAa,mCAA6E;CACxF,MAAM,EAAE,MAAM,cAAc,6BAA6B;CAEzD,OAAO;EACL;EACA,SAAS,CAAC,aAAa,MAAM,aAAa,mBAAmB;CAC/D;AACF;;;;;;;;ACPA,MAAa,wCAAkF;CAC7F,MAAM,EAAE,MAAM,cAAc,6BAA6B;CAEzD,OAAO;EACL;EACA,SAAS,CAAC,cAAc,MAAM,aAAa,uBAAuB;CACpE;AACF;;;;;;;;ACPA,MAAa,2CAAqF;CAChG,MAAM,EAAE,MAAM,cAAc,6BAA6B;CAEzD,OAAO;EACL;EACA,SAAS,CAAC,cAAc,MAAM,aAAa,0BAA0B;CACvE;AACF;;;;;;;ACRA,MAAa,6BAAuE;CAClF,MAAM,EAAE,MAAM,cAAc,6BAA6B;CAEzD,OAAO;EACL;EACA,SAAS,CAAC,cAAc,MAAM,aAAa,YAAY;CACzD;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as useMastraClient } from "../../mastra-client-context-Bx_g84YB.js";
|
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
|
3
3
|
//#region src/hooks/capabilities/use-observability-capabilities.ts
|
|
4
|
-
const OBSERVABILITY_CAPABILITIES_STALE_TIME =
|
|
4
|
+
const OBSERVABILITY_CAPABILITIES_STALE_TIME = 864e5;
|
|
5
5
|
const useObservabilityCapabilities = ({ queryOptions } = {}) => {
|
|
6
6
|
const client = useMastraClient();
|
|
7
7
|
return useQuery({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/capabilities/use-observability-capabilities.ts","../../../src/hooks/capabilities/use-trace-query-available.ts","../../../src/hooks/capabilities/use-trace-aggregate-available.ts","../../../src/hooks/capabilities/use-trace-query-discovery-available.ts","../../../src/hooks/capabilities/use-trace-query-root-duration-available.ts","../../../src/hooks/capabilities/use-feedback-available.ts"],"sourcesContent":["import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nconst OBSERVABILITY_CAPABILITIES_STALE_TIME = 24 * 60 * 60 * 1000;\n\ntype ObservabilityCapabilitiesResponse = Awaited<ReturnType<MastraClient['getObservabilityCapabilities']>>;\n\nexport const useObservabilityCapabilities = <TData = ObservabilityCapabilitiesResponse>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<ObservabilityCapabilitiesResponse, TData> } = {}): UseQueryResult<\n TData,\n Error\n> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['observability-capabilities'],\n queryFn: () => client.getObservabilityCapabilities(),\n retry: false,\n staleTime: OBSERVABILITY_CAPABILITIES_STALE_TIME,\n ...queryOptions,\n });\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * `enabled` stays false while capabilities load. Servers without the\n * capabilities endpoint fall back to `true` (trace query was the default before).\n */\nexport const useTraceQueryAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && (data?.capabilities.traceQuery ?? true),\n };\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * Whether the server can answer `aggregateTraces()`. `enabled` stays false while capabilities load.\n * Unlike trace query, a missing `traceAggregate` (an older server) or a missing capabilities endpoint\n * means aggregation is unavailable.\n */\nexport const useTraceAggregateAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && data?.capabilities.traceAggregate === true,\n };\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * Whether the store supports trace query field/value discovery. Callers combine it with\n * `useTraceQueryAvailable` when they also need the trace query API. `enabled` stays false\n * while capabilities load; servers without the capabilities endpoint fall back to `true`.\n */\nexport const useTraceQueryDiscoveryAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && (data?.capabilities.traceQueryDiscovery ?? true),\n };\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * Whether the store supports trace-level `durationMs` (root duration) predicates in trace queries.\n * `enabled` stays false while capabilities load, and also when the capability is missing: older\n * servers reject `durationMs` predicates, so this does not fall back to `true`.\n */\nexport const useTraceQueryRootDurationAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && (data?.capabilities.traceQueryRootDuration ?? false),\n };\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * `enabled` stays false while capabilities load. Servers without the\n * capabilities endpoint fall back to `true` (feedback was shown by default before).\n */\nexport const useFeedbackAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && (data?.capabilities.feedback ?? true),\n };\n};\n"],"mappings":";;;AAMA,MAAM,wCAAwC
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/capabilities/use-observability-capabilities.ts","../../../src/hooks/capabilities/use-trace-query-available.ts","../../../src/hooks/capabilities/use-trace-aggregate-available.ts","../../../src/hooks/capabilities/use-trace-query-discovery-available.ts","../../../src/hooks/capabilities/use-trace-query-root-duration-available.ts","../../../src/hooks/capabilities/use-feedback-available.ts"],"sourcesContent":["import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nconst OBSERVABILITY_CAPABILITIES_STALE_TIME = 24 * 60 * 60 * 1000;\n\ntype ObservabilityCapabilitiesResponse = Awaited<ReturnType<MastraClient['getObservabilityCapabilities']>>;\n\nexport const useObservabilityCapabilities = <TData = ObservabilityCapabilitiesResponse>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<ObservabilityCapabilitiesResponse, TData> } = {}): UseQueryResult<\n TData,\n Error\n> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['observability-capabilities'],\n queryFn: () => client.getObservabilityCapabilities(),\n retry: false,\n staleTime: OBSERVABILITY_CAPABILITIES_STALE_TIME,\n ...queryOptions,\n });\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * `enabled` stays false while capabilities load. Servers without the\n * capabilities endpoint fall back to `true` (trace query was the default before).\n */\nexport const useTraceQueryAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && (data?.capabilities.traceQuery ?? true),\n };\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * Whether the server can answer `aggregateTraces()`. `enabled` stays false while capabilities load.\n * Unlike trace query, a missing `traceAggregate` (an older server) or a missing capabilities endpoint\n * means aggregation is unavailable.\n */\nexport const useTraceAggregateAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && data?.capabilities.traceAggregate === true,\n };\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * Whether the store supports trace query field/value discovery. Callers combine it with\n * `useTraceQueryAvailable` when they also need the trace query API. `enabled` stays false\n * while capabilities load; servers without the capabilities endpoint fall back to `true`.\n */\nexport const useTraceQueryDiscoveryAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && (data?.capabilities.traceQueryDiscovery ?? true),\n };\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * Whether the store supports trace-level `durationMs` (root duration) predicates in trace queries.\n * `enabled` stays false while capabilities load, and also when the capability is missing: older\n * servers reject `durationMs` predicates, so this does not fall back to `true`.\n */\nexport const useTraceQueryRootDurationAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && (data?.capabilities.traceQueryRootDuration ?? false),\n };\n};\n","import { useObservabilityCapabilities } from './use-observability-capabilities';\n\n/**\n * `enabled` stays false while capabilities load. Servers without the\n * capabilities endpoint fall back to `true` (feedback was shown by default before).\n */\nexport const useFeedbackAvailable = (): { isLoading: boolean; enabled: boolean } => {\n const { data, isLoading } = useObservabilityCapabilities();\n\n return {\n isLoading,\n enabled: !isLoading && (data?.capabilities.feedback ?? true),\n };\n};\n"],"mappings":";;;AAMA,MAAM,wCAAwC;AAI9C,MAAa,gCAA2E,EACtF,iBACmF,CAAC,MAGjF;CACH,MAAM,SAAS,gBAAgB;CAE/B,OAAO,SAAS;EACd,UAAU,CAAC,4BAA4B;EACvC,eAAe,OAAO,6BAA6B;EACnD,OAAO;EACP,WAAW;EACX,GAAG;CACL,CAAC;AACH;;;;;;;ACnBA,MAAa,+BAAyE;CACpF,MAAM,EAAE,MAAM,cAAc,6BAA6B;CAEzD,OAAO;EACL;EACA,SAAS,CAAC,cAAc,MAAM,aAAa,cAAc;CAC3D;AACF;;;;;;;;ACNA,MAAa,mCAA6E;CACxF,MAAM,EAAE,MAAM,cAAc,6BAA6B;CAEzD,OAAO;EACL;EACA,SAAS,CAAC,aAAa,MAAM,aAAa,mBAAmB;CAC/D;AACF;;;;;;;;ACPA,MAAa,wCAAkF;CAC7F,MAAM,EAAE,MAAM,cAAc,6BAA6B;CAEzD,OAAO;EACL;EACA,SAAS,CAAC,cAAc,MAAM,aAAa,uBAAuB;CACpE;AACF;;;;;;;;ACPA,MAAa,2CAAqF;CAChG,MAAM,EAAE,MAAM,cAAc,6BAA6B;CAEzD,OAAO;EACL;EACA,SAAS,CAAC,cAAc,MAAM,aAAa,0BAA0B;CACvE;AACF;;;;;;;ACRA,MAAa,6BAAuE;CAClF,MAAM,EAAE,MAAM,cAAc,6BAA6B;CAEzD,OAAO;EACL;EACA,SAAS,CAAC,cAAc,MAAM,aAAa,YAAY;CACzD;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useMastraClient"],"sources":["../../../src/hooks/configuration/use-mastra-packages.ts"],"sourcesContent":["import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype SystemPackagesResponse = Awaited<ReturnType<MastraClient['getSystemPackages']>>;\n\nexport const useMastraPackages = <TData = SystemPackagesResponse>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<SystemPackagesResponse, TData> } = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['mastra-packages'],\n queryFn: () => {\n return client.getSystemPackages();\n },\n ...queryOptions,\n });\n};\n"],"mappings":";;;;AAQA,MAAa,qBAAqD,EAChE,iBACwE,CAAC,MAAoC;CAC7G,MAAM,SAASA,8BAAAA,gBAAgB;CAE/B,QAAA,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useMastraClient","useQuery"],"sources":["../../../src/hooks/configuration/use-mastra-packages.ts"],"sourcesContent":["import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype SystemPackagesResponse = Awaited<ReturnType<MastraClient['getSystemPackages']>>;\n\nexport const useMastraPackages = <TData = SystemPackagesResponse>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<SystemPackagesResponse, TData> } = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['mastra-packages'],\n queryFn: () => {\n return client.getSystemPackages();\n },\n ...queryOptions,\n });\n};\n"],"mappings":";;;;AAQA,MAAa,qBAAqD,EAChE,iBACwE,CAAC,MAAoC;CAC7G,MAAM,SAASA,8BAAAA,gBAAgB;CAE/B,QAAA,GAAOC,sBAAAA,SAAAA,CAAS;EACd,UAAU,CAAC,iBAAiB;EAC5B,eAAe;GACb,OAAO,OAAO,kBAAkB;EAClC;EACA,GAAG;CACL,CAAC;AACH"}
|
|
@@ -684,7 +684,7 @@ function useWorkflowSchema({ workflowId, queryOptions }) {
|
|
|
684
684
|
if (!workflowId) throw new Error("No workflow selected");
|
|
685
685
|
return client.getWorkflow(workflowId).getSchema();
|
|
686
686
|
},
|
|
687
|
-
staleTime:
|
|
687
|
+
staleTime: 3e5,
|
|
688
688
|
...queryOptions
|
|
689
689
|
});
|
|
690
690
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useMastraClient","PER_PAGE","useInView","useMastraClient","useMastraClient","useInView","useMastraClient","useMastraClient","useCombineByIds","useInView","useMastraClient","useMastraClient","useMastraClient","useMastraClient"],"sources":["../../../src/hooks/datasets/use-dataset-items.ts","../../../src/hooks/datasets/use-dataset-mutations.ts","../../../src/hooks/datasets/use-datasets.ts","../../../src/hooks/datasets/use-compare-experiments.ts","../../../src/hooks/datasets/use-dataset-experiments.ts","../../../src/hooks/datasets/use-dataset-item-versions.ts","../../../src/hooks/datasets/use-dataset-versions.ts","../../../src/hooks/datasets/use-experiments.ts","../../../src/hooks/datasets/use-workflow-schema.ts"],"sourcesContent":["import type { MastraClient } from '@mastra/client-js';\nimport { useQuery, useInfiniteQuery } from '@tanstack/react-query';\nimport type { InfiniteData, QueryKey, UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';\nimport { useEffect } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraInfiniteQueryOptions, MastraQueryOptions } from '../shared/query-options';\nimport { useInView } from '../shared/use-in-view';\n\n/**\n * Hook to fetch a single dataset item by ID\n */\ntype DatasetItemResponse = Awaited<ReturnType<MastraClient['getDatasetItem']>>;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useDatasetItem = <TData = DatasetItemResponse>({\n datasetId,\n itemId,\n queryOptions,\n}: {\n datasetId: string;\n itemId: string;\n queryOptions?: MastraQueryOptions<DatasetItemResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery({\n queryKey: ['dataset-item', datasetId, itemId],\n queryFn: () => client.getDatasetItem(datasetId, itemId),\n retry: false, // Don't retry 404s for deleted items\n ...queryOptions,\n });\n};\n\nconst PER_PAGE = 10;\n\ntype ListDatasetItemsResponse = Awaited<ReturnType<MastraClient['listDatasetItems']>>;\n\nexport type UseDatasetItemsResult = Omit<\n UseInfiniteQueryResult<InfiniteData<ListDatasetItemsResponse>, Error>,\n 'data'\n> & {\n data: ListDatasetItemsResponse['items'];\n total: number | undefined;\n setEndOfListElement: (element: HTMLDivElement | null) => void;\n};\n\n/**\n * Hook to list items in a dataset with infinite scroll pagination and optional search\n * @param version - Optional version timestamp to view historical snapshot\n */\nexport type DatasetItemsOrderBy = NonNullable<NonNullable<Parameters<MastraClient['listDatasetItems']>[1]>['orderBy']>;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useDatasetItems = ({\n datasetId,\n search,\n version,\n orderBy,\n queryOptions,\n}: {\n datasetId: string;\n search?: string;\n version?: number | null;\n orderBy?: DatasetItemsOrderBy;\n queryOptions?: MastraInfiniteQueryOptions<\n ListDatasetItemsResponse,\n InfiniteData<ListDatasetItemsResponse, number>,\n QueryKey,\n number\n >;\n}): UseDatasetItemsResult => {\n const client = useMastraClient();\n const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();\n\n const query = useInfiniteQuery({\n queryKey: ['dataset-items', datasetId, search, version, orderBy],\n queryFn: async ({ pageParam }) => {\n const res = await client.listDatasetItems(datasetId, {\n page: pageParam,\n perPage: PER_PAGE,\n search: search || undefined,\n version: version || undefined,\n orderBy,\n });\n return res;\n },\n initialPageParam: 0,\n getNextPageParam: (lastPage, _, lastPageParam) => {\n if (!lastPage?.items?.length) {\n return undefined;\n }\n const totalFetched = (lastPageParam + 1) * PER_PAGE;\n const total = lastPage?.pagination?.total ?? 0;\n if (totalFetched >= total) {\n return undefined;\n }\n return lastPageParam + 1;\n },\n retry: false,\n ...queryOptions,\n });\n\n const items = query.data?.pages.flatMap(page => page?.items ?? []) ?? [];\n const total = query.data?.pages[0]?.pagination?.total;\n\n useEffect(() => {\n if (isEndOfListInView && query.hasNextPage && !query.isFetchingNextPage) {\n void query.fetchNextPage();\n }\n }, [isEndOfListInView, query]);\n\n return { ...query, data: items, total, setEndOfListElement };\n};\n","import type {\n CreateDatasetParams,\n UpdateDatasetParams,\n AddDatasetItemParams,\n UpdateDatasetItemParams,\n TriggerDatasetExperimentParams,\n UpdateDatasetExperimentParams,\n UpdateExperimentResultParams,\n BatchInsertDatasetItemsParams,\n BatchDeleteDatasetItemsParams,\n MastraClient,\n} from '@mastra/client-js';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\ntype DatasetItemMutationVariables = {\n datasetId: string;\n itemId: string;\n};\n\ntype ClientResult<K extends keyof MastraClient> = MastraClient[K] extends (...args: any[]) => Promise<infer R>\n ? R\n : never;\n\nexport interface DatasetMutationsQueryOptions {\n createDataset?: MastraMutationOptions<ClientResult<'createDataset'>, CreateDatasetParams>;\n updateDataset?: MastraMutationOptions<ClientResult<'updateDataset'>, UpdateDatasetParams>;\n deleteDataset?: MastraMutationOptions<ClientResult<'deleteDataset'>, string>;\n addItem?: MastraMutationOptions<ClientResult<'addDatasetItem'>, AddDatasetItemParams>;\n updateItem?: MastraMutationOptions<ClientResult<'updateDatasetItem'>, UpdateDatasetItemParams>;\n deleteItem?: MastraMutationOptions<ClientResult<'deleteDatasetItem'>, DatasetItemMutationVariables>;\n purgeItem?: MastraMutationOptions<ClientResult<'purgeDatasetItem'>, DatasetItemMutationVariables>;\n deleteItems?: MastraMutationOptions<\n ClientResult<'batchDeleteDatasetItems'>,\n { datasetId: string; itemIds: string[] }\n >;\n batchInsertItems?: MastraMutationOptions<ClientResult<'batchInsertDatasetItems'>, BatchInsertDatasetItemsParams>;\n batchDeleteItems?: MastraMutationOptions<ClientResult<'batchDeleteDatasetItems'>, BatchDeleteDatasetItemsParams>;\n triggerExperiment?: MastraMutationOptions<ClientResult<'triggerDatasetExperiment'>, TriggerDatasetExperimentParams>;\n deleteExperiment?: MastraMutationOptions<ClientResult<'deleteExperiment'>, string>;\n updateExperiment?: MastraMutationOptions<ClientResult<'updateDatasetExperiment'>, UpdateDatasetExperimentParams>;\n updateExperimentResult?: MastraMutationOptions<\n ClientResult<'updateDatasetExperimentResult'>,\n UpdateExperimentResultParams\n >;\n}\n\n/**\n * Hook providing mutation functions for datasets, items, and runs\n * All mutations invalidate relevant query caches on success.\n * `queryOptions` is keyed by returned mutation name and spread last; a user `onSuccess` replaces the internal invalidation.\n */\nexport const useDatasetMutations = ({ queryOptions }: { queryOptions?: DatasetMutationsQueryOptions } = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n const createDataset = useMutation({\n mutationFn: (params: CreateDatasetParams) => client.createDataset(params),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['datasets'] });\n },\n ...queryOptions?.createDataset,\n });\n\n const updateDataset = useMutation({\n mutationFn: (params: UpdateDatasetParams) => client.updateDataset(params),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['datasets'] });\n void queryClient.invalidateQueries({ queryKey: ['dataset', variables.datasetId] });\n },\n ...queryOptions?.updateDataset,\n });\n\n const deleteDataset = useMutation({\n mutationFn: (datasetId: string) => client.deleteDataset(datasetId),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['datasets'] });\n },\n ...queryOptions?.deleteDataset,\n });\n\n const addItem = useMutation({\n mutationFn: (params: AddDatasetItemParams) => client.addDatasetItem(params),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['dataset-items', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-versions', variables.datasetId] });\n },\n ...queryOptions?.addItem,\n });\n\n const updateItem = useMutation({\n mutationFn: (params: UpdateDatasetItemParams) => client.updateDatasetItem(params),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['dataset-items', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-item', variables.datasetId, variables.itemId] });\n void queryClient.invalidateQueries({\n queryKey: ['dataset-item-versions', variables.datasetId, variables.itemId],\n });\n void queryClient.invalidateQueries({ queryKey: ['dataset-versions', variables.datasetId] });\n },\n ...queryOptions?.updateItem,\n });\n\n const deleteItem = useMutation({\n mutationFn: ({ datasetId, itemId }: DatasetItemMutationVariables) => client.deleteDatasetItem(datasetId, itemId),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['dataset-items', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-versions', variables.datasetId] });\n },\n ...queryOptions?.deleteItem,\n });\n\n const purgeItem = useMutation({\n mutationFn: ({ datasetId, itemId }: DatasetItemMutationVariables) => client.purgeDatasetItem(datasetId, itemId),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['dataset-items', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-item', variables.datasetId, variables.itemId] });\n void queryClient.invalidateQueries({\n queryKey: ['dataset-item-versions', variables.datasetId, variables.itemId],\n });\n void queryClient.invalidateQueries({ queryKey: ['dataset-experiment-results'] });\n void queryClient.invalidateQueries({ queryKey: ['experiment-results'] });\n void queryClient.invalidateQueries({ queryKey: ['review-items'] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-review-items'] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-completed-items'] });\n void queryClient.invalidateQueries({ queryKey: ['experiment-review-summary'] });\n },\n ...queryOptions?.purgeItem,\n });\n\n // Batch insert items using the batch endpoint\n const batchInsertItems = useMutation({\n mutationFn: (params: BatchInsertDatasetItemsParams) => client.batchInsertDatasetItems(params),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['dataset-items', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-versions', variables.datasetId] });\n },\n ...queryOptions?.batchInsertItems,\n });\n\n // Batch delete items using the batch endpoint\n const batchDeleteItems = useMutation({\n mutationFn: (params: BatchDeleteDatasetItemsParams) => client.batchDeleteDatasetItems(params),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['dataset-items', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-versions', variables.datasetId] });\n },\n ...queryOptions?.batchDeleteItems,\n });\n\n // @deprecated - use batchDeleteItems mutation instead\n const deleteItems = useMutation({\n mutationFn: async ({ datasetId, itemIds }: { datasetId: string; itemIds: string[] }) => {\n return client.batchDeleteDatasetItems({ datasetId, itemIds });\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['dataset-items', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-versions', variables.datasetId] });\n },\n ...queryOptions?.deleteItems,\n });\n\n const triggerExperiment = useMutation({\n mutationFn: (params: TriggerDatasetExperimentParams) => client.triggerDatasetExperiment(params),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['dataset-experiments', variables.datasetId] });\n },\n ...queryOptions?.triggerExperiment,\n });\n\n const deleteExperiment = useMutation({\n mutationFn: (experimentId: string) => client.deleteExperiment(experimentId),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['experiments'] });\n void queryClient.invalidateQueries({ queryKey: ['experiment'] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-experiments'] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-experiment'] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-experiment-results'] });\n void queryClient.invalidateQueries({ queryKey: ['review-items'] });\n void queryClient.invalidateQueries({ queryKey: ['completed-items'] });\n void queryClient.invalidateQueries({ queryKey: ['experiment-review-summary'] });\n },\n ...queryOptions?.deleteExperiment,\n });\n\n const updateExperiment = useMutation({\n mutationFn: (params: UpdateDatasetExperimentParams) => client.updateDatasetExperiment(params),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['experiments'] });\n void queryClient.invalidateQueries({ queryKey: ['experiment', variables.experimentId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-experiments', variables.datasetId] });\n void queryClient.invalidateQueries({\n queryKey: ['dataset-experiment', variables.datasetId, variables.experimentId],\n });\n },\n ...queryOptions?.updateExperiment,\n });\n\n const updateExperimentResult = useMutation({\n mutationFn: (params: UpdateExperimentResultParams) => client.updateDatasetExperimentResult(params),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['experiment-results', variables.experimentId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-experiment-results'] });\n void queryClient.invalidateQueries({ queryKey: ['review-items'] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-review-items'] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-completed-items'] });\n void queryClient.invalidateQueries({ queryKey: ['experiment-review-summary'] });\n },\n ...queryOptions?.updateExperimentResult,\n });\n\n return {\n createDataset,\n updateDataset,\n deleteDataset,\n addItem,\n updateItem,\n deleteItem,\n purgeItem,\n deleteItems,\n batchInsertItems,\n batchDeleteItems,\n triggerExperiment,\n deleteExperiment,\n updateExperiment,\n updateExperimentResult,\n };\n};\n","import type { ExperimentTargetType, ListDatasetsParams, MastraClient } from '@mastra/client-js';\nimport { useInfiniteQuery, useQuery } from '@tanstack/react-query';\nimport type { InfiniteData, QueryKey, UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';\nimport { useEffect } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraInfiniteQueryOptions, MastraQueryOptions } from '../shared/query-options';\nimport { useInView } from '../shared/use-in-view';\n\ntype ListDatasetsResponse = Awaited<ReturnType<MastraClient['listDatasets']>>;\ntype DatasetResponse = Awaited<ReturnType<MastraClient['getDataset']>>;\n\n/**\n * Hook to list all datasets with optional pagination\n */\nexport const useDatasets = <TData = ListDatasetsResponse>({\n pagination,\n queryOptions,\n}: {\n pagination?: { page?: number; perPage?: number };\n queryOptions?: MastraQueryOptions<ListDatasetsResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery({\n queryKey: ['datasets', pagination],\n queryFn: () => client.listDatasets(pagination),\n placeholderData: previousData => previousData,\n ...queryOptions,\n });\n};\n\nconst DATASETS_PER_PAGE = 20;\n\nexport interface DatasetTargetFilter {\n targetType?: ExperimentTargetType | '';\n targetId?: string;\n}\n\nexport type DatasetsOrderBy = NonNullable<ListDatasetsParams['orderBy']>;\n\ntype DatasetRecord = ListDatasetsResponse['datasets'][number];\n\nexport type UseInfiniteDatasetsResult<TData = DatasetRecord[]> = UseInfiniteQueryResult<TData, Error> & {\n setEndOfListElement: (element: HTMLDivElement | null) => void;\n};\n\n/**\n * Hook to list datasets with infinite scroll pagination, optionally scoped server-side to a target.\n * `data` defaults to the flattened dataset list; a user `select` replaces that flattening.\n */\nexport const useInfiniteDatasets = <TData = DatasetRecord[]>({\n filter,\n orderBy,\n queryOptions,\n}: {\n filter?: DatasetTargetFilter;\n orderBy?: DatasetsOrderBy;\n queryOptions?: MastraInfiniteQueryOptions<ListDatasetsResponse, TData, QueryKey, number>;\n} = {}): UseInfiniteDatasetsResult<TData> => {\n const client = useMastraClient();\n const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();\n const targetType = filter?.targetType || undefined;\n const targetIds = filter?.targetId ? [filter.targetId] : undefined;\n\n const query = useInfiniteQuery({\n queryKey: ['datasets', 'infinite', { targetType, targetIds, orderBy }],\n queryFn: ({ pageParam }) =>\n client.listDatasets({ page: pageParam, perPage: DATASETS_PER_PAGE, targetType, targetIds, orderBy }),\n initialPageParam: 0,\n getNextPageParam: (lastPage, _, lastPageParam) => {\n if (!lastPage?.datasets?.length || !lastPage.pagination?.hasMore) {\n return undefined;\n }\n return lastPageParam + 1;\n },\n select: (data: InfiniteData<ListDatasetsResponse, number>) =>\n data.pages.flatMap(page => page?.datasets ?? []) as TData,\n ...queryOptions,\n });\n\n useEffect(() => {\n if (isEndOfListInView && query.hasNextPage && !query.isFetchingNextPage) {\n void query.fetchNextPage();\n }\n }, [isEndOfListInView, query]);\n\n return { ...query, setEndOfListElement };\n};\n\n/**\n * Hook to fetch a single dataset by ID\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useDataset = <TData = DatasetResponse>({\n datasetId,\n queryOptions,\n}: {\n datasetId: string;\n queryOptions?: MastraQueryOptions<DatasetResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery({\n queryKey: ['dataset', datasetId],\n queryFn: () => client.getDataset(datasetId),\n ...queryOptions,\n });\n};\n","import type { CompareExperimentsResponse } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\n/**\n * Hook to compare two to ten dataset experiments item by item against a baseline.\n * @param datasetId - ID of the dataset\n * @param experimentIds - IDs of the experiments to compare\n * @param baselineId - ID of the baseline experiment; must be one of `experimentIds` (defaults to the first)\n * @param queryOptions - TanStack Query options, spread last to override defaults\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useCompareExperiments = <TData = CompareExperimentsResponse>({\n datasetId,\n experimentIds,\n baselineId,\n queryOptions,\n}: {\n datasetId: string;\n experimentIds: string[];\n baselineId?: string;\n queryOptions?: MastraQueryOptions<CompareExperimentsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery({\n queryKey: ['compare-experiments', datasetId, experimentIds, baselineId],\n queryFn: () => client.compareExperiments({ datasetId, experimentIds, baselineId }),\n ...queryOptions,\n });\n};\n","import type { ClientScoreRowData, DatasetExperimentResult, MastraClient } from '@mastra/client-js';\nimport type { ExperimentStatus } from '@mastra/core/storage';\nimport { queryOptions as tanstackQueryOptions, useInfiniteQuery, useQueries, useQuery } from '@tanstack/react-query';\nimport type {\n InfiniteData,\n QueryKey,\n UseInfiniteQueryResult,\n UseQueryOptions,\n UseQueryResult,\n} from '@tanstack/react-query';\nimport { useEffect } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport { useCombineByIds } from '../shared/combine-by-ids';\nimport type { ExperimentQueriesResult } from '../shared/combine-by-ids';\nimport type { MastraInfiniteQueryOptions, MastraQueryOptions } from '../shared/query-options';\n\nexport type { ExperimentQueriesResult } from '../shared/combine-by-ids';\nimport { useInView } from '../shared/use-in-view';\n\ntype DatasetExperimentResponse = Awaited<ReturnType<MastraClient['getDatasetExperiment']>>;\ntype ExperimentResultsPage = Awaited<ReturnType<MastraClient['listDatasetExperimentResults']>>;\ntype ExperimentScoresByEntity = Record<string, ClientScoreRowData[]>;\ntype DatasetExperimentQueryKey = string[];\ntype ExperimentStatusQueryKey = (string | undefined)[];\n\nconst POLL_INTERVAL_MS = 2000;\nconst RESULTS_PER_PAGE = 100;\nconst SCORES_PER_PAGE = 100;\n\nconst isInProgress = (status: string | undefined) => status === 'running' || status === 'pending';\n\n/**\n * Key, fetcher and polling policy of the `dataset-experiment` query, shared by the single and\n * multi-experiment hooks so they hit the same cache entry.\n * Polls every 2 seconds while the experiment is 'running' or 'pending'.\n */\nexport const datasetExperimentQueryOptions = (\n client: MastraClient,\n datasetId: string,\n experimentId: string,\n): UseQueryOptions<DatasetExperimentResponse, Error, DatasetExperimentResponse, DatasetExperimentQueryKey> =>\n tanstackQueryOptions({\n queryKey: ['dataset-experiment', datasetId, experimentId],\n queryFn: () => client.getDatasetExperiment(datasetId, experimentId),\n gcTime: 0,\n staleTime: 0,\n refetchInterval: query => (isInProgress(query.state.data?.status) ? POLL_INTERVAL_MS : false),\n });\n\n/**\n * Key and fetcher of the `dataset-experiment-scores` query: every score of an experiment, across all\n * pages, grouped by dataset item id. Polls every 2 seconds while `experimentStatus` is in progress.\n */\nexport const experimentScoresQueryOptions = (\n client: MastraClient,\n experimentId: string,\n experimentStatus: ExperimentStatus | undefined,\n): UseQueryOptions<ExperimentScoresByEntity, Error, ExperimentScoresByEntity, ExperimentStatusQueryKey> =>\n tanstackQueryOptions({\n queryKey: ['dataset-experiment-scores', experimentId, experimentStatus],\n queryFn: async (): Promise<ExperimentScoresByEntity> => {\n const allScores: ClientScoreRowData[] = [];\n let page = 0;\n\n while (true) {\n const response = await client.listScoresByRunId({ runId: experimentId, page, perPage: SCORES_PER_PAGE });\n allScores.push(...response.scores);\n if (!response.pagination.hasMore) break;\n page++;\n }\n\n const grouped: ExperimentScoresByEntity = {};\n for (const row of allScores) {\n (grouped[row.entityId] ??= []).push(row);\n }\n return grouped;\n },\n refetchInterval: isInProgress(experimentStatus) ? POLL_INTERVAL_MS : false,\n });\n\n/**\n * Key and fetcher of the `dataset-experiment-results-all` query: every result of an experiment, across\n * all pages. Polls every 2 seconds while `experimentStatus` is in progress.\n */\nexport const allDatasetExperimentResultsQueryOptions = (\n client: MastraClient,\n datasetId: string,\n experimentId: string,\n experimentStatus: ExperimentStatus | undefined,\n): UseQueryOptions<DatasetExperimentResult[], Error, DatasetExperimentResult[], ExperimentStatusQueryKey> =>\n tanstackQueryOptions({\n queryKey: ['dataset-experiment-results-all', datasetId, experimentId, experimentStatus],\n queryFn: async (): Promise<DatasetExperimentResult[]> => {\n const allResults: DatasetExperimentResult[] = [];\n let page = 0;\n\n while (true) {\n const response = await client.listDatasetExperimentResults(datasetId, experimentId, {\n page,\n perPage: RESULTS_PER_PAGE,\n });\n allResults.push(...response.results);\n if (!response.pagination.hasMore || response.results.length === 0) break;\n page++;\n }\n\n return allResults;\n },\n refetchInterval: isInProgress(experimentStatus) ? POLL_INTERVAL_MS : false,\n });\n\n/** An experiment id plus its status, which drives polling of its dependent queries. */\nexport interface ExperimentRef {\n id: string;\n status?: ExperimentStatus;\n}\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useDatasetExperiment = <TData = DatasetExperimentResponse>({\n datasetId,\n experimentId,\n queryOptions,\n}: {\n datasetId: string;\n experimentId: string;\n queryOptions?: MastraQueryOptions<DatasetExperimentResponse, TData, DatasetExperimentQueryKey>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n const { queryKey, queryFn, gcTime, staleTime, refetchInterval } = datasetExperimentQueryOptions(\n client,\n datasetId,\n experimentId,\n );\n return useQuery<DatasetExperimentResponse, Error, TData, DatasetExperimentQueryKey>({\n queryKey,\n queryFn,\n gcTime,\n staleTime,\n refetchInterval,\n ...queryOptions,\n });\n};\n\n/**\n * Fetches several experiments of one dataset in parallel, each polled while it runs.\n * The server 404s an experiment that does not belong to `datasetId`, which surfaces as `error`.\n */\nexport const useDatasetExperimentsQueries = ({\n datasetId,\n experimentIds,\n}: {\n datasetId: string;\n experimentIds: string[];\n}): ExperimentQueriesResult<DatasetExperimentResponse> => {\n const client = useMastraClient();\n const combine = useCombineByIds<DatasetExperimentResponse>(experimentIds);\n return useQueries({\n queries: experimentIds.map(id => datasetExperimentQueryOptions(client, datasetId, id)),\n combine,\n });\n};\n\nexport type ExperimentResultsOrderBy = NonNullable<\n NonNullable<Parameters<MastraClient['listDatasetExperimentResults']>[2]>['orderBy']\n>;\n\ninterface UseDatasetExperimentResultsParams<TData = DatasetExperimentResult[]> {\n datasetId: string;\n experimentId: string;\n experimentStatus?: ExperimentStatus;\n orderBy?: ExperimentResultsOrderBy;\n queryOptions?: MastraInfiniteQueryOptions<ExperimentResultsPage, TData, QueryKey, number>;\n}\n\n/**\n * Hook to list results for a dataset experiment with infinite scroll pagination.\n * Polls every 2 seconds while experiment status is 'pending' or 'running'.\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useDatasetExperimentResults = <TData = DatasetExperimentResult[]>({\n datasetId,\n experimentId,\n experimentStatus,\n orderBy,\n queryOptions,\n}: UseDatasetExperimentResultsParams<TData>): UseInfiniteQueryResult<TData, Error> & {\n setEndOfListElement: (element: HTMLDivElement | null) => void;\n} => {\n const client = useMastraClient();\n const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();\n\n const query = useInfiniteQuery({\n queryKey: ['dataset-experiment-results', datasetId, experimentId, experimentStatus, orderBy],\n queryFn: async ({ pageParam }) => {\n return client.listDatasetExperimentResults(datasetId, experimentId, {\n page: pageParam,\n perPage: RESULTS_PER_PAGE,\n orderBy,\n });\n },\n initialPageParam: 0,\n getNextPageParam: (lastPage, _, lastPageParam) => {\n if (!lastPage?.results?.length) {\n return undefined;\n }\n const totalFetched = (lastPageParam + 1) * RESULTS_PER_PAGE;\n const total = lastPage?.pagination?.total ?? 0;\n if (totalFetched >= total) {\n return undefined;\n }\n return lastPageParam + 1;\n },\n refetchInterval: isInProgress(experimentStatus) ? POLL_INTERVAL_MS : false,\n select: (data: InfiniteData<ExperimentResultsPage, number>) => {\n return data.pages.flatMap(page => page?.results ?? []) as TData;\n },\n ...queryOptions,\n });\n\n useEffect(() => {\n if (isEndOfListInView && query.hasNextPage && !query.isFetchingNextPage) {\n void query.fetchNextPage();\n }\n }, [isEndOfListInView, query]);\n\n return { ...query, setEndOfListElement };\n};\n\n/**\n * Fetches every result (all pages) of several experiments of one dataset in parallel.\n * Each experiment is polled while its `status` is in progress.\n */\nexport const useAllDatasetExperimentResultsQueries = ({\n datasetId,\n experiments,\n}: {\n datasetId: string;\n experiments: ExperimentRef[];\n}): ExperimentQueriesResult<DatasetExperimentResult[]> => {\n const client = useMastraClient();\n const combine = useCombineByIds<DatasetExperimentResult[]>(experiments.map(experiment => experiment.id));\n return useQueries({\n queries: experiments.map(experiment =>\n allDatasetExperimentResultsQueryOptions(client, datasetId, experiment.id, experiment.status),\n ),\n combine,\n });\n};\n\n/**\n * Hook to fetch all scores for an experiment, transformed to Record<entityId, ClientScoreRowData[]>\n * Paginates through all pages to ensure no scores are silently dropped.\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useScoresByExperimentId = <TData = ExperimentScoresByEntity>({\n experimentId,\n experimentStatus,\n queryOptions,\n}: {\n experimentId: string;\n experimentStatus?: ExperimentStatus;\n queryOptions?: MastraQueryOptions<ExperimentScoresByEntity, TData, ExperimentStatusQueryKey>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n const { queryKey, queryFn, refetchInterval } = experimentScoresQueryOptions(client, experimentId, experimentStatus);\n return useQuery<ExperimentScoresByEntity, Error, TData, ExperimentStatusQueryKey>({\n queryKey,\n queryFn,\n refetchInterval,\n ...queryOptions,\n });\n};\n\n/**\n * Fetches every score of several experiments in parallel, each grouped by dataset item id.\n * Each experiment is polled while its `status` is in progress.\n */\nexport const useScoresByExperimentIdsQueries = ({\n experiments,\n}: {\n experiments: ExperimentRef[];\n}): ExperimentQueriesResult<ExperimentScoresByEntity> => {\n const client = useMastraClient();\n const combine = useCombineByIds<ExperimentScoresByEntity>(experiments.map(experiment => experiment.id));\n return useQueries({\n queries: experiments.map(experiment => experimentScoresQueryOptions(client, experiment.id, experiment.status)),\n combine,\n });\n};\n","import type { DatasetItemVersionResponse } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nexport type DatasetItemVersion = DatasetItemVersionResponse & {\n validTo: number | null;\n isDeleted: boolean;\n isLatest: boolean;\n};\n\n/**\n * Hook to fetch full item history (SCD-2 rows).\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useDatasetItemVersions = <TData = DatasetItemVersion[]>({\n datasetId,\n itemId,\n queryOptions,\n}: {\n datasetId: string;\n itemId: string;\n queryOptions?: MastraQueryOptions<DatasetItemVersion[], TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['dataset-item-versions', datasetId, itemId],\n queryFn: async (): Promise<DatasetItemVersion[]> => {\n const res = await client.getItemHistory(datasetId, itemId);\n\n return (res?.history ?? []).map(\n (version, index): DatasetItemVersion => ({\n id: version.id,\n datasetId: version.datasetId,\n datasetVersion: version.datasetVersion,\n input: version.input,\n groundTruth: version.groundTruth,\n expectedTrajectory: version.expectedTrajectory,\n toolMocks: version.toolMocks ?? undefined,\n scorerIds: version.scorerIds ?? undefined,\n requestContext: version.requestContext ?? undefined,\n metadata: version.metadata ?? undefined,\n validTo: version.validTo,\n isDeleted: version.isDeleted,\n createdAt: version.createdAt,\n updatedAt: version.updatedAt,\n isLatest: index === 0,\n }),\n );\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to fetch a specific version of a dataset item.\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useDatasetItemVersion = <TData = DatasetItemVersion>({\n datasetId,\n itemId,\n datasetVersion,\n latestVersion,\n queryOptions,\n}: {\n datasetId: string;\n itemId: string;\n datasetVersion: number;\n latestVersion?: number;\n queryOptions?: MastraQueryOptions<DatasetItemVersion, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['dataset-item-version', datasetId, itemId, datasetVersion],\n queryFn: async (): Promise<DatasetItemVersion> => {\n const v = await client.getDatasetItemVersion(datasetId, itemId, datasetVersion);\n\n return {\n id: v.id,\n datasetId: v.datasetId,\n datasetVersion: v.datasetVersion,\n input: v.input,\n groundTruth: v.groundTruth,\n expectedTrajectory: v.expectedTrajectory,\n toolMocks: v.toolMocks ?? undefined,\n scorerIds: v.scorerIds ?? undefined,\n requestContext: v.requestContext ?? undefined,\n metadata: v.metadata ?? undefined,\n validTo: null,\n isDeleted: false,\n createdAt: v.createdAt,\n updatedAt: v.updatedAt,\n isLatest: latestVersion != null ? datasetVersion === latestVersion : false,\n };\n },\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport { useInfiniteQuery } from '@tanstack/react-query';\nimport type { InfiniteData, QueryKey } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraInfiniteQueryOptions } from '../shared/query-options';\n\nexport interface DatasetVersion {\n id?: string;\n datasetId?: string;\n version: number;\n createdAt?: Date | string;\n isCurrent: boolean;\n}\n\ntype DatasetVersionsPage = Awaited<ReturnType<MastraClient['listDatasetVersions']>>;\n\nconst PER_PAGE = 10;\n\n/**\n * Hook to fetch dataset versions from the API with infinite pagination.\n * `data` defaults to the flattened `DatasetVersion[]`; a user `select` replaces that.\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useDatasetVersions = <TData = DatasetVersion[]>({\n datasetId,\n queryOptions,\n}: {\n datasetId: string;\n queryOptions?: MastraInfiniteQueryOptions<DatasetVersionsPage, TData, QueryKey, number>;\n}) => {\n const client = useMastraClient();\n\n return useInfiniteQuery({\n queryKey: ['dataset-versions', datasetId],\n queryFn: async ({ pageParam }) => {\n return client.listDatasetVersions(datasetId, { page: pageParam, perPage: PER_PAGE });\n },\n initialPageParam: 0,\n getNextPageParam: (lastPage, _, lastPageParam) => {\n if (lastPage?.pagination?.hasMore) {\n return lastPageParam + 1;\n }\n return undefined;\n },\n select: (data: InfiniteData<DatasetVersionsPage, number>) => {\n return data.pages\n .flatMap(page => page?.versions ?? [])\n .map(\n (v, index): DatasetVersion => ({\n id: v.id,\n datasetId: v.datasetId,\n version: v.version,\n createdAt: v.createdAt,\n isCurrent: index === 0,\n }),\n ) as TData;\n },\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype ListExperimentsResponse = Awaited<ReturnType<MastraClient['listExperiments']>>;\ntype GetExperimentResponse = Awaited<ReturnType<MastraClient['getExperiment']>>;\n\n/**\n * Hook to list all experiments across all datasets with optional pagination\n */\nexport const useExperiments = <TData = ListExperimentsResponse>({\n pagination,\n queryOptions,\n}: {\n pagination?: { page?: number; perPage?: number };\n queryOptions?: MastraQueryOptions<ListExperimentsResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery({\n queryKey: ['experiments', pagination],\n queryFn: () => client.listExperiments(pagination),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to fetch a single experiment by ID without knowing its dataset\n */\nexport const useExperiment = <TData = GetExperimentResponse>({\n experimentId,\n queryOptions,\n}: {\n experimentId: string;\n queryOptions?: MastraQueryOptions<GetExperimentResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery({\n queryKey: ['experiment', experimentId],\n queryFn: () => client.getExperiment(experimentId),\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype WorkflowSchemaResponse = Awaited<ReturnType<ReturnType<MastraClient['getWorkflow']>['getSchema']>>;\n\n/**\n * Hook to fetch workflow input/output schema by workflow ID.\n * Returns { inputSchema, outputSchema } where each is Record<string, unknown> | null.\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport function useWorkflowSchema<TData = WorkflowSchemaResponse>({\n workflowId,\n queryOptions,\n}: {\n workflowId: string | null;\n queryOptions?: MastraQueryOptions<WorkflowSchemaResponse, TData>;\n}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['workflow-schema', workflowId],\n queryFn: async () => {\n if (!workflowId) throw new Error('No workflow selected');\n return client.getWorkflow(workflowId).getSchema();\n },\n staleTime: 5 * 60 * 1000, // Cache for 5 minutes\n ...queryOptions,\n });\n}\n"],"mappings":";;;;;;;;;;AAgBA,MAAa,kBAA+C,EAC1D,WACA,QACA,mBAKkC;CAClC,MAAM,SAASA,8BAAAA,gBAAgB;CAC/B,QAAA,GAAA,sBAAA,SAAA,CAAgB;EACd,UAAU;GAAC;GAAgB;GAAW;EAAM;EAC5C,eAAe,OAAO,eAAe,WAAW,MAAM;EACtD,OAAO;E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UAAU,YAAY,SACxB,OAAO,gBAAgB;EAG3B;EACA,SAAS,SAAoD;GAC3D,OAAO,KAAK,MACT,SAAQ,SAAQ,MAAM,YAAY,CAAC,CAAC,CAAC,CACrC,KACE,GAAG,WAA2B;IAC7B,IAAI,EAAE;IACN,WAAW,EAAE;IACb,SAAS,EAAE;IACX,WAAW,EAAE;IACb,WAAW,UAAU;GACvB,EACF;EACJ;EACA,GAAG;CACL,CAAC;AACH;;;;;;AChDA,MAAa,kBAAmD,EAC9D,YACA,iBAIE,CAAC,MAAoC;CACvC,MAAM,SAASC,8BAAAA,gBAAgB;CAC/B,QAAA,GAAA,sBAAA,SAAA,CAAgB;EACd,UAAU,CAAC,eAAe,UAAU;EACpC,eAAe,OAAO,gBAAgB,UAAU;EAChD,GAAG;CACL,CAAC;AACH;;;;AAKA,MAAa,iBAAgD,EAC3D,cACA,mBAIkC;CAClC,MAAM,SAASA,8BAAAA,gBAAgB;CAC/B,QAAA,GAAA,sBAAA,SAAA,CAAgB;EACd,UAAU,CAAC,cAAc,YAAY;EACrC,eAAe,OAAO,cAAc,YAAY;EAChD,GAAG;CACL,CAAC;AACH;;;;;;;;;AC7BA,SAAgB,kBAAkD,EAChE,YACA,gBAI+B;CAC/B,MAAM,SAASC,8BAAAA,gBAAgB;CAE/B,QAAA,GAAA,sBAAA,SAAA,CAAgB;EACd,UAAU,CAAC,mBAAmB,UAAU;EACxC,SAAS,YAAY;GACnB,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,sBAAsB;GACvD,OAAO,OAAO,YAAY,UAAU,CAAC,CAAC,UAAU;EAClD;EACA,WAAW,MAAS;EACpB,GAAG;CACL,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useMastraClient","useQuery","PER_PAGE","useInView","useInfiniteQuery","useMastraClient","useQueryClient","useMutation","useMastraClient","useQuery","useInView","useInfiniteQuery","useMastraClient","useQuery","tanstackQueryOptions","useMastraClient","useQuery","useCombineByIds","useQueries","useInView","useInfiniteQuery","useMastraClient","useQuery","useMastraClient","useInfiniteQuery","useMastraClient","useQuery","useMastraClient","useQuery"],"sources":["../../../src/hooks/datasets/use-dataset-items.ts","../../../src/hooks/datasets/use-dataset-mutations.ts","../../../src/hooks/datasets/use-datasets.ts","../../../src/hooks/datasets/use-compare-experiments.ts","../../../src/hooks/datasets/use-dataset-experiments.ts","../../../src/hooks/datasets/use-dataset-item-versions.ts","../../../src/hooks/datasets/use-dataset-versions.ts","../../../src/hooks/datasets/use-experiments.ts","../../../src/hooks/datasets/use-workflow-schema.ts"],"sourcesContent":["import type { MastraClient } from '@mastra/client-js';\nimport { useQuery, useInfiniteQuery } from '@tanstack/react-query';\nimport type { InfiniteData, QueryKey, UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';\nimport { useEffect } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraInfiniteQueryOptions, MastraQueryOptions } from '../shared/query-options';\nimport { useInView } from '../shared/use-in-view';\n\n/**\n * Hook to fetch a single dataset item by ID\n */\ntype DatasetItemResponse = Awaited<ReturnType<MastraClient['getDatasetItem']>>;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useDatasetItem = <TData = DatasetItemResponse>({\n datasetId,\n itemId,\n queryOptions,\n}: {\n datasetId: string;\n itemId: string;\n queryOptions?: MastraQueryOptions<DatasetItemResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery({\n queryKey: ['dataset-item', datasetId, itemId],\n queryFn: () => client.getDatasetItem(datasetId, itemId),\n retry: false, // Don't retry 404s for deleted items\n ...queryOptions,\n });\n};\n\nconst PER_PAGE = 10;\n\ntype ListDatasetItemsResponse = Awaited<ReturnType<MastraClient['listDatasetItems']>>;\n\nexport type UseDatasetItemsResult = Omit<\n UseInfiniteQueryResult<InfiniteData<ListDatasetItemsResponse>, Error>,\n 'data'\n> & {\n data: ListDatasetItemsResponse['items'];\n total: number | undefined;\n setEndOfListElement: (element: HTMLDivElement | null) => void;\n};\n\n/**\n * Hook to list items in a dataset with infinite scroll pagination and optional search\n * @param version - Optional version timestamp to view historical snapshot\n */\nexport type DatasetItemsOrderBy = NonNullable<NonNullable<Parameters<MastraClient['listDatasetItems']>[1]>['orderBy']>;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useDatasetItems = ({\n datasetId,\n search,\n version,\n orderBy,\n queryOptions,\n}: {\n datasetId: string;\n search?: string;\n version?: number | null;\n orderBy?: DatasetItemsOrderBy;\n queryOptions?: MastraInfiniteQueryOptions<\n ListDatasetItemsResponse,\n InfiniteData<ListDatasetItemsResponse, number>,\n QueryKey,\n number\n >;\n}): UseDatasetItemsResult => {\n const client = useMastraClient();\n const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();\n\n const query = useInfiniteQuery({\n queryKey: ['dataset-items', datasetId, search, version, orderBy],\n queryFn: async ({ pageParam }) => {\n const res = await client.listDatasetItems(datasetId, {\n page: pageParam,\n perPage: PER_PAGE,\n search: search || undefined,\n version: version || undefined,\n orderBy,\n });\n return res;\n },\n initialPageParam: 0,\n getNextPageParam: (lastPage, _, lastPageParam) => {\n if (!lastPage?.items?.length) {\n return undefined;\n }\n const totalFetched = (lastPageParam + 1) * PER_PAGE;\n const total = lastPage?.pagination?.total ?? 0;\n if (totalFetched >= total) {\n return undefined;\n }\n return lastPageParam + 1;\n },\n retry: false,\n ...queryOptions,\n });\n\n const items = query.data?.pages.flatMap(page => page?.items ?? []) ?? [];\n const total = query.data?.pages[0]?.pagination?.total;\n\n useEffect(() => {\n if (isEndOfListInView && query.hasNextPage && !query.isFetchingNextPage) {\n void query.fetchNextPage();\n }\n }, [isEndOfListInView, query]);\n\n return { ...query, data: items, total, setEndOfListElement };\n};\n","import type {\n CreateDatasetParams,\n UpdateDatasetParams,\n AddDatasetItemParams,\n UpdateDatasetItemParams,\n TriggerDatasetExperimentParams,\n UpdateDatasetExperimentParams,\n UpdateExperimentResultParams,\n BatchInsertDatasetItemsParams,\n BatchDeleteDatasetItemsParams,\n MastraClient,\n} from '@mastra/client-js';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\ntype DatasetItemMutationVariables = {\n datasetId: string;\n itemId: string;\n};\n\ntype ClientResult<K extends keyof MastraClient> = MastraClient[K] extends (...args: any[]) => Promise<infer R>\n ? R\n : never;\n\nexport interface DatasetMutationsQueryOptions {\n createDataset?: MastraMutationOptions<ClientResult<'createDataset'>, CreateDatasetParams>;\n updateDataset?: MastraMutationOptions<ClientResult<'updateDataset'>, UpdateDatasetParams>;\n deleteDataset?: MastraMutationOptions<ClientResult<'deleteDataset'>, string>;\n addItem?: MastraMutationOptions<ClientResult<'addDatasetItem'>, AddDatasetItemParams>;\n updateItem?: MastraMutationOptions<ClientResult<'updateDatasetItem'>, UpdateDatasetItemParams>;\n deleteItem?: MastraMutationOptions<ClientResult<'deleteDatasetItem'>, DatasetItemMutationVariables>;\n purgeItem?: MastraMutationOptions<ClientResult<'purgeDatasetItem'>, DatasetItemMutationVariables>;\n deleteItems?: MastraMutationOptions<\n ClientResult<'batchDeleteDatasetItems'>,\n { datasetId: string; itemIds: string[] }\n >;\n batchInsertItems?: MastraMutationOptions<ClientResult<'batchInsertDatasetItems'>, BatchInsertDatasetItemsParams>;\n batchDeleteItems?: MastraMutationOptions<ClientResult<'batchDeleteDatasetItems'>, BatchDeleteDatasetItemsParams>;\n triggerExperiment?: MastraMutationOptions<ClientResult<'triggerDatasetExperiment'>, TriggerDatasetExperimentParams>;\n deleteExperiment?: MastraMutationOptions<ClientResult<'deleteExperiment'>, string>;\n updateExperiment?: MastraMutationOptions<ClientResult<'updateDatasetExperiment'>, UpdateDatasetExperimentParams>;\n updateExperimentResult?: MastraMutationOptions<\n ClientResult<'updateDatasetExperimentResult'>,\n UpdateExperimentResultParams\n >;\n}\n\n/**\n * Hook providing mutation functions for datasets, items, and runs\n * All mutations invalidate relevant query caches on success.\n * `queryOptions` is keyed by returned mutation name and spread last; a user `onSuccess` replaces the internal invalidation.\n */\nexport const useDatasetMutations = ({ queryOptions }: { queryOptions?: DatasetMutationsQueryOptions } = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n const createDataset = useMutation({\n mutationFn: (params: CreateDatasetParams) => client.createDataset(params),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['datasets'] });\n },\n ...queryOptions?.createDataset,\n });\n\n const updateDataset = useMutation({\n mutationFn: (params: UpdateDatasetParams) => client.updateDataset(params),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['datasets'] });\n void queryClient.invalidateQueries({ queryKey: ['dataset', variables.datasetId] });\n },\n ...queryOptions?.updateDataset,\n });\n\n const deleteDataset = useMutation({\n mutationFn: (datasetId: string) => client.deleteDataset(datasetId),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['datasets'] });\n },\n ...queryOptions?.deleteDataset,\n });\n\n const addItem = useMutation({\n mutationFn: (params: AddDatasetItemParams) => client.addDatasetItem(params),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['dataset-items', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-versions', variables.datasetId] });\n },\n ...queryOptions?.addItem,\n });\n\n const updateItem = useMutation({\n mutationFn: (params: UpdateDatasetItemParams) => client.updateDatasetItem(params),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['dataset-items', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-item', variables.datasetId, variables.itemId] });\n void queryClient.invalidateQueries({\n queryKey: ['dataset-item-versions', variables.datasetId, variables.itemId],\n });\n void queryClient.invalidateQueries({ queryKey: ['dataset-versions', variables.datasetId] });\n },\n ...queryOptions?.updateItem,\n });\n\n const deleteItem = useMutation({\n mutationFn: ({ datasetId, itemId }: DatasetItemMutationVariables) => client.deleteDatasetItem(datasetId, itemId),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['dataset-items', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-versions', variables.datasetId] });\n },\n ...queryOptions?.deleteItem,\n });\n\n const purgeItem = useMutation({\n mutationFn: ({ datasetId, itemId }: DatasetItemMutationVariables) => client.purgeDatasetItem(datasetId, itemId),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['dataset-items', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-item', variables.datasetId, variables.itemId] });\n void queryClient.invalidateQueries({\n queryKey: ['dataset-item-versions', variables.datasetId, variables.itemId],\n });\n void queryClient.invalidateQueries({ queryKey: ['dataset-experiment-results'] });\n void queryClient.invalidateQueries({ queryKey: ['experiment-results'] });\n void queryClient.invalidateQueries({ queryKey: ['review-items'] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-review-items'] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-completed-items'] });\n void queryClient.invalidateQueries({ queryKey: ['experiment-review-summary'] });\n },\n ...queryOptions?.purgeItem,\n });\n\n // Batch insert items using the batch endpoint\n const batchInsertItems = useMutation({\n mutationFn: (params: BatchInsertDatasetItemsParams) => client.batchInsertDatasetItems(params),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['dataset-items', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-versions', variables.datasetId] });\n },\n ...queryOptions?.batchInsertItems,\n });\n\n // Batch delete items using the batch endpoint\n const batchDeleteItems = useMutation({\n mutationFn: (params: BatchDeleteDatasetItemsParams) => client.batchDeleteDatasetItems(params),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['dataset-items', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-versions', variables.datasetId] });\n },\n ...queryOptions?.batchDeleteItems,\n });\n\n // @deprecated - use batchDeleteItems mutation instead\n const deleteItems = useMutation({\n mutationFn: async ({ datasetId, itemIds }: { datasetId: string; itemIds: string[] }) => {\n return client.batchDeleteDatasetItems({ datasetId, itemIds });\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['dataset-items', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset', variables.datasetId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-versions', variables.datasetId] });\n },\n ...queryOptions?.deleteItems,\n });\n\n const triggerExperiment = useMutation({\n mutationFn: (params: TriggerDatasetExperimentParams) => client.triggerDatasetExperiment(params),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['dataset-experiments', variables.datasetId] });\n },\n ...queryOptions?.triggerExperiment,\n });\n\n const deleteExperiment = useMutation({\n mutationFn: (experimentId: string) => client.deleteExperiment(experimentId),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['experiments'] });\n void queryClient.invalidateQueries({ queryKey: ['experiment'] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-experiments'] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-experiment'] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-experiment-results'] });\n void queryClient.invalidateQueries({ queryKey: ['review-items'] });\n void queryClient.invalidateQueries({ queryKey: ['completed-items'] });\n void queryClient.invalidateQueries({ queryKey: ['experiment-review-summary'] });\n },\n ...queryOptions?.deleteExperiment,\n });\n\n const updateExperiment = useMutation({\n mutationFn: (params: UpdateDatasetExperimentParams) => client.updateDatasetExperiment(params),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['experiments'] });\n void queryClient.invalidateQueries({ queryKey: ['experiment', variables.experimentId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-experiments', variables.datasetId] });\n void queryClient.invalidateQueries({\n queryKey: ['dataset-experiment', variables.datasetId, variables.experimentId],\n });\n },\n ...queryOptions?.updateExperiment,\n });\n\n const updateExperimentResult = useMutation({\n mutationFn: (params: UpdateExperimentResultParams) => client.updateDatasetExperimentResult(params),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['experiment-results', variables.experimentId] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-experiment-results'] });\n void queryClient.invalidateQueries({ queryKey: ['review-items'] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-review-items'] });\n void queryClient.invalidateQueries({ queryKey: ['dataset-completed-items'] });\n void queryClient.invalidateQueries({ queryKey: ['experiment-review-summary'] });\n },\n ...queryOptions?.updateExperimentResult,\n });\n\n return {\n createDataset,\n updateDataset,\n deleteDataset,\n addItem,\n updateItem,\n deleteItem,\n purgeItem,\n deleteItems,\n batchInsertItems,\n batchDeleteItems,\n triggerExperiment,\n deleteExperiment,\n updateExperiment,\n updateExperimentResult,\n };\n};\n","import type { ExperimentTargetType, ListDatasetsParams, MastraClient } from '@mastra/client-js';\nimport { useInfiniteQuery, useQuery } from '@tanstack/react-query';\nimport type { InfiniteData, QueryKey, UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';\nimport { useEffect } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraInfiniteQueryOptions, MastraQueryOptions } from '../shared/query-options';\nimport { useInView } from '../shared/use-in-view';\n\ntype ListDatasetsResponse = Awaited<ReturnType<MastraClient['listDatasets']>>;\ntype DatasetResponse = Awaited<ReturnType<MastraClient['getDataset']>>;\n\n/**\n * Hook to list all datasets with optional pagination\n */\nexport const useDatasets = <TData = ListDatasetsResponse>({\n pagination,\n queryOptions,\n}: {\n pagination?: { page?: number; perPage?: number };\n queryOptions?: MastraQueryOptions<ListDatasetsResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery({\n queryKey: ['datasets', pagination],\n queryFn: () => client.listDatasets(pagination),\n placeholderData: previousData => previousData,\n ...queryOptions,\n });\n};\n\nconst DATASETS_PER_PAGE = 20;\n\nexport interface DatasetTargetFilter {\n targetType?: ExperimentTargetType | '';\n targetId?: string;\n}\n\nexport type DatasetsOrderBy = NonNullable<ListDatasetsParams['orderBy']>;\n\ntype DatasetRecord = ListDatasetsResponse['datasets'][number];\n\nexport type UseInfiniteDatasetsResult<TData = DatasetRecord[]> = UseInfiniteQueryResult<TData, Error> & {\n setEndOfListElement: (element: HTMLDivElement | null) => void;\n};\n\n/**\n * Hook to list datasets with infinite scroll pagination, optionally scoped server-side to a target.\n * `data` defaults to the flattened dataset list; a user `select` replaces that flattening.\n */\nexport const useInfiniteDatasets = <TData = DatasetRecord[]>({\n filter,\n orderBy,\n queryOptions,\n}: {\n filter?: DatasetTargetFilter;\n orderBy?: DatasetsOrderBy;\n queryOptions?: MastraInfiniteQueryOptions<ListDatasetsResponse, TData, QueryKey, number>;\n} = {}): UseInfiniteDatasetsResult<TData> => {\n const client = useMastraClient();\n const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();\n const targetType = filter?.targetType || undefined;\n const targetIds = filter?.targetId ? [filter.targetId] : undefined;\n\n const query = useInfiniteQuery({\n queryKey: ['datasets', 'infinite', { targetType, targetIds, orderBy }],\n queryFn: ({ pageParam }) =>\n client.listDatasets({ page: pageParam, perPage: DATASETS_PER_PAGE, targetType, targetIds, orderBy }),\n initialPageParam: 0,\n getNextPageParam: (lastPage, _, lastPageParam) => {\n if (!lastPage?.datasets?.length || !lastPage.pagination?.hasMore) {\n return undefined;\n }\n return lastPageParam + 1;\n },\n select: (data: InfiniteData<ListDatasetsResponse, number>) =>\n data.pages.flatMap(page => page?.datasets ?? []) as TData,\n ...queryOptions,\n });\n\n useEffect(() => {\n if (isEndOfListInView && query.hasNextPage && !query.isFetchingNextPage) {\n void query.fetchNextPage();\n }\n }, [isEndOfListInView, query]);\n\n return { ...query, setEndOfListElement };\n};\n\n/**\n * Hook to fetch a single dataset by ID\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useDataset = <TData = DatasetResponse>({\n datasetId,\n queryOptions,\n}: {\n datasetId: string;\n queryOptions?: MastraQueryOptions<DatasetResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery({\n queryKey: ['dataset', datasetId],\n queryFn: () => client.getDataset(datasetId),\n ...queryOptions,\n });\n};\n","import type { CompareExperimentsResponse } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\n/**\n * Hook to compare two to ten dataset experiments item by item against a baseline.\n * @param datasetId - ID of the dataset\n * @param experimentIds - IDs of the experiments to compare\n * @param baselineId - ID of the baseline experiment; must be one of `experimentIds` (defaults to the first)\n * @param queryOptions - TanStack Query options, spread last to override defaults\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useCompareExperiments = <TData = CompareExperimentsResponse>({\n datasetId,\n experimentIds,\n baselineId,\n queryOptions,\n}: {\n datasetId: string;\n experimentIds: string[];\n baselineId?: string;\n queryOptions?: MastraQueryOptions<CompareExperimentsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery({\n queryKey: ['compare-experiments', datasetId, experimentIds, baselineId],\n queryFn: () => client.compareExperiments({ datasetId, experimentIds, baselineId }),\n ...queryOptions,\n });\n};\n","import type { ClientScoreRowData, DatasetExperimentResult, MastraClient } from '@mastra/client-js';\nimport type { ExperimentStatus } from '@mastra/core/storage';\nimport { queryOptions as tanstackQueryOptions, useInfiniteQuery, useQueries, useQuery } from '@tanstack/react-query';\nimport type {\n InfiniteData,\n QueryKey,\n UseInfiniteQueryResult,\n UseQueryOptions,\n UseQueryResult,\n} from '@tanstack/react-query';\nimport { useEffect } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport { useCombineByIds } from '../shared/combine-by-ids';\nimport type { ExperimentQueriesResult } from '../shared/combine-by-ids';\nimport type { MastraInfiniteQueryOptions, MastraQueryOptions } from '../shared/query-options';\n\nexport type { ExperimentQueriesResult } from '../shared/combine-by-ids';\nimport { useInView } from '../shared/use-in-view';\n\ntype DatasetExperimentResponse = Awaited<ReturnType<MastraClient['getDatasetExperiment']>>;\ntype ExperimentResultsPage = Awaited<ReturnType<MastraClient['listDatasetExperimentResults']>>;\ntype ExperimentScoresByEntity = Record<string, ClientScoreRowData[]>;\ntype DatasetExperimentQueryKey = string[];\ntype ExperimentStatusQueryKey = (string | undefined)[];\n\nconst POLL_INTERVAL_MS = 2000;\nconst RESULTS_PER_PAGE = 100;\nconst SCORES_PER_PAGE = 100;\n\nconst isInProgress = (status: string | undefined) => status === 'running' || status === 'pending';\n\n/**\n * Key, fetcher and polling policy of the `dataset-experiment` query, shared by the single and\n * multi-experiment hooks so they hit the same cache entry.\n * Polls every 2 seconds while the experiment is 'running' or 'pending'.\n */\nexport const datasetExperimentQueryOptions = (\n client: MastraClient,\n datasetId: string,\n experimentId: string,\n): UseQueryOptions<DatasetExperimentResponse, Error, DatasetExperimentResponse, DatasetExperimentQueryKey> =>\n tanstackQueryOptions({\n queryKey: ['dataset-experiment', datasetId, experimentId],\n queryFn: () => client.getDatasetExperiment(datasetId, experimentId),\n gcTime: 0,\n staleTime: 0,\n refetchInterval: query => (isInProgress(query.state.data?.status) ? POLL_INTERVAL_MS : false),\n });\n\n/**\n * Key and fetcher of the `dataset-experiment-scores` query: every score of an experiment, across all\n * pages, grouped by dataset item id. Polls every 2 seconds while `experimentStatus` is in progress.\n */\nexport const experimentScoresQueryOptions = (\n client: MastraClient,\n experimentId: string,\n experimentStatus: ExperimentStatus | undefined,\n): UseQueryOptions<ExperimentScoresByEntity, Error, ExperimentScoresByEntity, ExperimentStatusQueryKey> =>\n tanstackQueryOptions({\n queryKey: ['dataset-experiment-scores', experimentId, experimentStatus],\n queryFn: async (): Promise<ExperimentScoresByEntity> => {\n const allScores: ClientScoreRowData[] = [];\n let page = 0;\n\n while (true) {\n const response = await client.listScoresByRunId({ runId: experimentId, page, perPage: SCORES_PER_PAGE });\n allScores.push(...response.scores);\n if (!response.pagination.hasMore) break;\n page++;\n }\n\n const grouped: ExperimentScoresByEntity = {};\n for (const row of allScores) {\n (grouped[row.entityId] ??= []).push(row);\n }\n return grouped;\n },\n refetchInterval: isInProgress(experimentStatus) ? POLL_INTERVAL_MS : false,\n });\n\n/**\n * Key and fetcher of the `dataset-experiment-results-all` query: every result of an experiment, across\n * all pages. Polls every 2 seconds while `experimentStatus` is in progress.\n */\nexport const allDatasetExperimentResultsQueryOptions = (\n client: MastraClient,\n datasetId: string,\n experimentId: string,\n experimentStatus: ExperimentStatus | undefined,\n): UseQueryOptions<DatasetExperimentResult[], Error, DatasetExperimentResult[], ExperimentStatusQueryKey> =>\n tanstackQueryOptions({\n queryKey: ['dataset-experiment-results-all', datasetId, experimentId, experimentStatus],\n queryFn: async (): Promise<DatasetExperimentResult[]> => {\n const allResults: DatasetExperimentResult[] = [];\n let page = 0;\n\n while (true) {\n const response = await client.listDatasetExperimentResults(datasetId, experimentId, {\n page,\n perPage: RESULTS_PER_PAGE,\n });\n allResults.push(...response.results);\n if (!response.pagination.hasMore || response.results.length === 0) break;\n page++;\n }\n\n return allResults;\n },\n refetchInterval: isInProgress(experimentStatus) ? POLL_INTERVAL_MS : false,\n });\n\n/** An experiment id plus its status, which drives polling of its dependent queries. */\nexport interface ExperimentRef {\n id: string;\n status?: ExperimentStatus;\n}\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useDatasetExperiment = <TData = DatasetExperimentResponse>({\n datasetId,\n experimentId,\n queryOptions,\n}: {\n datasetId: string;\n experimentId: string;\n queryOptions?: MastraQueryOptions<DatasetExperimentResponse, TData, DatasetExperimentQueryKey>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n const { queryKey, queryFn, gcTime, staleTime, refetchInterval } = datasetExperimentQueryOptions(\n client,\n datasetId,\n experimentId,\n );\n return useQuery<DatasetExperimentResponse, Error, TData, DatasetExperimentQueryKey>({\n queryKey,\n queryFn,\n gcTime,\n staleTime,\n refetchInterval,\n ...queryOptions,\n });\n};\n\n/**\n * Fetches several experiments of one dataset in parallel, each polled while it runs.\n * The server 404s an experiment that does not belong to `datasetId`, which surfaces as `error`.\n */\nexport const useDatasetExperimentsQueries = ({\n datasetId,\n experimentIds,\n}: {\n datasetId: string;\n experimentIds: string[];\n}): ExperimentQueriesResult<DatasetExperimentResponse> => {\n const client = useMastraClient();\n const combine = useCombineByIds<DatasetExperimentResponse>(experimentIds);\n return useQueries({\n queries: experimentIds.map(id => datasetExperimentQueryOptions(client, datasetId, id)),\n combine,\n });\n};\n\nexport type ExperimentResultsOrderBy = NonNullable<\n NonNullable<Parameters<MastraClient['listDatasetExperimentResults']>[2]>['orderBy']\n>;\n\ninterface UseDatasetExperimentResultsParams<TData = DatasetExperimentResult[]> {\n datasetId: string;\n experimentId: string;\n experimentStatus?: ExperimentStatus;\n orderBy?: ExperimentResultsOrderBy;\n queryOptions?: MastraInfiniteQueryOptions<ExperimentResultsPage, TData, QueryKey, number>;\n}\n\n/**\n * Hook to list results for a dataset experiment with infinite scroll pagination.\n * Polls every 2 seconds while experiment status is 'pending' or 'running'.\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useDatasetExperimentResults = <TData = DatasetExperimentResult[]>({\n datasetId,\n experimentId,\n experimentStatus,\n orderBy,\n queryOptions,\n}: UseDatasetExperimentResultsParams<TData>): UseInfiniteQueryResult<TData, Error> & {\n setEndOfListElement: (element: HTMLDivElement | null) => void;\n} => {\n const client = useMastraClient();\n const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();\n\n const query = useInfiniteQuery({\n queryKey: ['dataset-experiment-results', datasetId, experimentId, experimentStatus, orderBy],\n queryFn: async ({ pageParam }) => {\n return client.listDatasetExperimentResults(datasetId, experimentId, {\n page: pageParam,\n perPage: RESULTS_PER_PAGE,\n orderBy,\n });\n },\n initialPageParam: 0,\n getNextPageParam: (lastPage, _, lastPageParam) => {\n if (!lastPage?.results?.length) {\n return undefined;\n }\n const totalFetched = (lastPageParam + 1) * RESULTS_PER_PAGE;\n const total = lastPage?.pagination?.total ?? 0;\n if (totalFetched >= total) {\n return undefined;\n }\n return lastPageParam + 1;\n },\n refetchInterval: isInProgress(experimentStatus) ? POLL_INTERVAL_MS : false,\n select: (data: InfiniteData<ExperimentResultsPage, number>) => {\n return data.pages.flatMap(page => page?.results ?? []) as TData;\n },\n ...queryOptions,\n });\n\n useEffect(() => {\n if (isEndOfListInView && query.hasNextPage && !query.isFetchingNextPage) {\n void query.fetchNextPage();\n }\n }, [isEndOfListInView, query]);\n\n return { ...query, setEndOfListElement };\n};\n\n/**\n * Fetches every result (all pages) of several experiments of one dataset in parallel.\n * Each experiment is polled while its `status` is in progress.\n */\nexport const useAllDatasetExperimentResultsQueries = ({\n datasetId,\n experiments,\n}: {\n datasetId: string;\n experiments: ExperimentRef[];\n}): ExperimentQueriesResult<DatasetExperimentResult[]> => {\n const client = useMastraClient();\n const combine = useCombineByIds<DatasetExperimentResult[]>(experiments.map(experiment => experiment.id));\n return useQueries({\n queries: experiments.map(experiment =>\n allDatasetExperimentResultsQueryOptions(client, datasetId, experiment.id, experiment.status),\n ),\n combine,\n });\n};\n\n/**\n * Hook to fetch all scores for an experiment, transformed to Record<entityId, ClientScoreRowData[]>\n * Paginates through all pages to ensure no scores are silently dropped.\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useScoresByExperimentId = <TData = ExperimentScoresByEntity>({\n experimentId,\n experimentStatus,\n queryOptions,\n}: {\n experimentId: string;\n experimentStatus?: ExperimentStatus;\n queryOptions?: MastraQueryOptions<ExperimentScoresByEntity, TData, ExperimentStatusQueryKey>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n const { queryKey, queryFn, refetchInterval } = experimentScoresQueryOptions(client, experimentId, experimentStatus);\n return useQuery<ExperimentScoresByEntity, Error, TData, ExperimentStatusQueryKey>({\n queryKey,\n queryFn,\n refetchInterval,\n ...queryOptions,\n });\n};\n\n/**\n * Fetches every score of several experiments in parallel, each grouped by dataset item id.\n * Each experiment is polled while its `status` is in progress.\n */\nexport const useScoresByExperimentIdsQueries = ({\n experiments,\n}: {\n experiments: ExperimentRef[];\n}): ExperimentQueriesResult<ExperimentScoresByEntity> => {\n const client = useMastraClient();\n const combine = useCombineByIds<ExperimentScoresByEntity>(experiments.map(experiment => experiment.id));\n return useQueries({\n queries: experiments.map(experiment => experimentScoresQueryOptions(client, experiment.id, experiment.status)),\n combine,\n });\n};\n","import type { DatasetItemVersionResponse } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nexport type DatasetItemVersion = DatasetItemVersionResponse & {\n validTo: number | null;\n isDeleted: boolean;\n isLatest: boolean;\n};\n\n/**\n * Hook to fetch full item history (SCD-2 rows).\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useDatasetItemVersions = <TData = DatasetItemVersion[]>({\n datasetId,\n itemId,\n queryOptions,\n}: {\n datasetId: string;\n itemId: string;\n queryOptions?: MastraQueryOptions<DatasetItemVersion[], TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['dataset-item-versions', datasetId, itemId],\n queryFn: async (): Promise<DatasetItemVersion[]> => {\n const res = await client.getItemHistory(datasetId, itemId);\n\n return (res?.history ?? []).map(\n (version, index): DatasetItemVersion => ({\n id: version.id,\n datasetId: version.datasetId,\n datasetVersion: version.datasetVersion,\n input: version.input,\n groundTruth: version.groundTruth,\n expectedTrajectory: version.expectedTrajectory,\n toolMocks: version.toolMocks ?? undefined,\n scorerIds: version.scorerIds ?? undefined,\n requestContext: version.requestContext ?? undefined,\n metadata: version.metadata ?? undefined,\n validTo: version.validTo,\n isDeleted: version.isDeleted,\n createdAt: version.createdAt,\n updatedAt: version.updatedAt,\n isLatest: index === 0,\n }),\n );\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to fetch a specific version of a dataset item.\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useDatasetItemVersion = <TData = DatasetItemVersion>({\n datasetId,\n itemId,\n datasetVersion,\n latestVersion,\n queryOptions,\n}: {\n datasetId: string;\n itemId: string;\n datasetVersion: number;\n latestVersion?: number;\n queryOptions?: MastraQueryOptions<DatasetItemVersion, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['dataset-item-version', datasetId, itemId, datasetVersion],\n queryFn: async (): Promise<DatasetItemVersion> => {\n const v = await client.getDatasetItemVersion(datasetId, itemId, datasetVersion);\n\n return {\n id: v.id,\n datasetId: v.datasetId,\n datasetVersion: v.datasetVersion,\n input: v.input,\n groundTruth: v.groundTruth,\n expectedTrajectory: v.expectedTrajectory,\n toolMocks: v.toolMocks ?? undefined,\n scorerIds: v.scorerIds ?? undefined,\n requestContext: v.requestContext ?? undefined,\n metadata: v.metadata ?? undefined,\n validTo: null,\n isDeleted: false,\n createdAt: v.createdAt,\n updatedAt: v.updatedAt,\n isLatest: latestVersion != null ? datasetVersion === latestVersion : false,\n };\n },\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport { useInfiniteQuery } from '@tanstack/react-query';\nimport type { InfiniteData, QueryKey } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraInfiniteQueryOptions } from '../shared/query-options';\n\nexport interface DatasetVersion {\n id?: string;\n datasetId?: string;\n version: number;\n createdAt?: Date | string;\n isCurrent: boolean;\n}\n\ntype DatasetVersionsPage = Awaited<ReturnType<MastraClient['listDatasetVersions']>>;\n\nconst PER_PAGE = 10;\n\n/**\n * Hook to fetch dataset versions from the API with infinite pagination.\n * `data` defaults to the flattened `DatasetVersion[]`; a user `select` replaces that.\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useDatasetVersions = <TData = DatasetVersion[]>({\n datasetId,\n queryOptions,\n}: {\n datasetId: string;\n queryOptions?: MastraInfiniteQueryOptions<DatasetVersionsPage, TData, QueryKey, number>;\n}) => {\n const client = useMastraClient();\n\n return useInfiniteQuery({\n queryKey: ['dataset-versions', datasetId],\n queryFn: async ({ pageParam }) => {\n return client.listDatasetVersions(datasetId, { page: pageParam, perPage: PER_PAGE });\n },\n initialPageParam: 0,\n getNextPageParam: (lastPage, _, lastPageParam) => {\n if (lastPage?.pagination?.hasMore) {\n return lastPageParam + 1;\n }\n return undefined;\n },\n select: (data: InfiniteData<DatasetVersionsPage, number>) => {\n return data.pages\n .flatMap(page => page?.versions ?? [])\n .map(\n (v, index): DatasetVersion => ({\n id: v.id,\n datasetId: v.datasetId,\n version: v.version,\n createdAt: v.createdAt,\n isCurrent: index === 0,\n }),\n ) as TData;\n },\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype ListExperimentsResponse = Awaited<ReturnType<MastraClient['listExperiments']>>;\ntype GetExperimentResponse = Awaited<ReturnType<MastraClient['getExperiment']>>;\n\n/**\n * Hook to list all experiments across all datasets with optional pagination\n */\nexport const useExperiments = <TData = ListExperimentsResponse>({\n pagination,\n queryOptions,\n}: {\n pagination?: { page?: number; perPage?: number };\n queryOptions?: MastraQueryOptions<ListExperimentsResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery({\n queryKey: ['experiments', pagination],\n queryFn: () => client.listExperiments(pagination),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to fetch a single experiment by ID without knowing its dataset\n */\nexport const useExperiment = <TData = GetExperimentResponse>({\n experimentId,\n queryOptions,\n}: {\n experimentId: string;\n queryOptions?: MastraQueryOptions<GetExperimentResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery({\n queryKey: ['experiment', experimentId],\n queryFn: () => client.getExperiment(experimentId),\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype WorkflowSchemaResponse = Awaited<ReturnType<ReturnType<MastraClient['getWorkflow']>['getSchema']>>;\n\n/**\n * Hook to fetch workflow input/output schema by workflow ID.\n * Returns { inputSchema, outputSchema } where each is Record<string, unknown> | null.\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport function useWorkflowSchema<TData = WorkflowSchemaResponse>({\n workflowId,\n queryOptions,\n}: {\n workflowId: string | null;\n queryOptions?: MastraQueryOptions<WorkflowSchemaResponse, TData>;\n}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['workflow-schema', workflowId],\n queryFn: async () => {\n if (!workflowId) throw new Error('No workflow selected');\n return client.getWorkflow(workflowId).getSchema();\n },\n staleTime: 5 * 60 * 1000, // Cache for 5 minutes\n ...queryOptions,\n });\n}\n"],"mappings":";;;;;;;;;;AAgBA,MAAa,kBAA+C,EAC1D,WACA,QACA,mBAKkC;CAClC,MAAM,SAASA,8BAAAA,gBAAgB;CAC/B,QAAA,GAAOC,sBAAAA,SAAAA,CAAS;EACd,UAAU;GAAC;GAAgB;GAAW;EAAM;EAC5C,eAAe,OAAO,e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683
|
if (!workflowId) throw new Error("No workflow selected");
|
|
684
684
|
return client.getWorkflow(workflowId).getSchema();
|
|
685
685
|
},
|
|
686
|
-
staleTime:
|
|
686
|
+
staleTime: 3e5,
|
|
687
687
|
...queryOptions
|
|
688
688
|
});
|
|
689
689
|
}
|