import { DataTag, QueryClient } from '@tanstack/react-query'; import { APIError } from 'better-auth'; import { OrganizationAuthServer } from '../../../lib/auth-server'; import { FullOrganizationParams } from './full-organization-query'; import { ListOrganization } from './list-organizations-query'; /** * Cache shape for the active organization. Intentionally narrowed to * {@link ListOrganization} (basic fields only) so the cache stays * compatible with `setActive`'s optimistic update, which can only produce * list-shaped data. Use {@link FullOrganizationData} (via * `fullOrganizationOptions`) when you need members / invitations. */ export type ActiveOrganizationData = ListOrganization; /** * Same shape as {@link FullOrganizationParams} so server-side prefetches * can target a specific organization (e.g. by `query.organizationSlug` for * slug-driven routes) and produce a cache key that matches the client's * `useActiveOrganization({ query: { organizationSlug } })` on hydration. */ export type ActiveOrganizationParams = FullOrganizationParams; /** * Query options factory for the active organization. Shares its cache key * with the client-side `activeOrganizationOptions` (including any * `params.query` partition such as `{ organizationSlug }`) so SSR-prefetched * data hydrates without a refetch — even on slug-prefixed routes. * * @param auth - The Better Auth server instance. * @param userId - The signed-in user's ID. Used for cache partitioning so * the key matches the client-side `activeOrganizationOptions` for SSR hydration. * @param params - Parameters forwarded to `auth.api.getFullOrganization`. Pass * `{ query: { organizationSlug } }` for slug-driven prefetches. */ export declare function activeOrganizationOptions(auth: TAuth, userId: string, params: ActiveOrganizationParams): (import('@tanstack/query-core').OmitKeyof, APIError, ActiveOrganizationData, readonly ["auth", "user", string | undefined, "organization", "active", { organizationId?: string | undefined; organizationSlug?: string | undefined; membersLimit?: string | number | undefined; } | null]>, "queryFn"> & { queryFn?: import('@tanstack/query-core').QueryFunction, readonly ["auth", "user", string | undefined, "organization", "active", { organizationId?: string | undefined; organizationSlug?: string | undefined; membersLimit?: string | number | undefined; } | null], never> | undefined; } & { queryKey: readonly ["auth", "user", string | undefined, "organization", "active", { organizationId?: string | undefined; organizationSlug?: string | undefined; membersLimit?: string | number | undefined; } | null] & { [dataTagSymbol]: ActiveOrganizationData; [dataTagErrorSymbol]: APIError; }; }) & { queryKey: DataTag, APIError>; }; export declare const ensureActiveOrganization: (queryClient: QueryClient, auth: TAuth, userId: string, params: ActiveOrganizationParams) => Promise>; export declare const prefetchActiveOrganization: (queryClient: QueryClient, auth: TAuth, userId: string, params: ActiveOrganizationParams) => Promise; export declare const fetchActiveOrganization: (queryClient: QueryClient, auth: TAuth, userId: string, params: ActiveOrganizationParams) => Promise>;