UNPKG

@better-auth-ui/core

Version:

Authentication components and data utilities for [Better Auth](https://better-auth.com), available for React and Solid.

51 lines (50 loc) 3.71 kB
import { QueryClient, QueryOptions, skipToken } from '@tanstack/query-core'; import { InferData } from '../../lib/auth-client'; import { OrganizationAuthClient } from './organization-auth-client'; export type ListOrganizationMembersData<TAuthClient extends OrganizationAuthClient = OrganizationAuthClient> = InferData<TAuthClient["organization"]["listMembers"]>; export type ListOrganizationMembersParams<TAuthClient extends OrganizationAuthClient = OrganizationAuthClient> = Parameters<TAuthClient["organization"]["listMembers"]>[0]; export type ListOrganizationMembersOptions<TAuthClient extends OrganizationAuthClient = OrganizationAuthClient> = Omit<QueryOptions<ListOrganizationMembersData<TAuthClient>>, "queryKey"> & ListOrganizationMembersParams<TAuthClient>; /** * Query options factory for organization members visible to the current user. * * @param authClient - The Better Auth organization client. * @param userId - The current signed-in user's ID. Used for cache partitioning. * @param params - Parameters forwarded to `authClient.organization.listMembers`. */ export declare function listOrganizationMembersOptions<TAuthClient extends OrganizationAuthClient>(authClient: TAuthClient, userId?: string, params?: ListOrganizationMembersParams<TAuthClient>): { queryKey: readonly ["auth", "user", string | undefined, "organization", "members", "list", { limit?: string | number | undefined; offset?: string | number | undefined; sortBy?: string | undefined; sortDirection?: "asc" | "desc" | undefined; filterField?: string | undefined; filterValue?: string | number | boolean | string[] | number[] | undefined; filterOperator?: "in" | "contains" | "starts_with" | "ends_with" | "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "not_in" | undefined; organizationId?: string | undefined; organizationSlug?: string | undefined; } | null]; queryFn: typeof skipToken | (({ signal }: { client: QueryClient; queryKey: readonly unknown[]; signal: AbortSignal; meta: import('@tanstack/query-core').QueryMeta | undefined; pageParam?: unknown; direction?: unknown; }) => Promise<InferData<TAuthClient["organization"]["listMembers"]>>); }; /** * Get organization members from the cache, fetching if needed. */ export declare const ensureListOrganizationMembers: <TAuthClient extends OrganizationAuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, options?: ListOrganizationMembersOptions<TAuthClient>) => Promise<InferData<TAuthClient["organization"]["listMembers"]>>; /** * Prefetch organization members into the query cache. */ export declare const prefetchListOrganizationMembers: <TAuthClient extends OrganizationAuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, options?: ListOrganizationMembersOptions<TAuthClient>) => Promise<void>; /** * Fetch and cache organization members, resolving with data or throwing on error. */ export declare const fetchListOrganizationMembers: <TAuthClient extends OrganizationAuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, options?: ListOrganizationMembersOptions<TAuthClient>) => Promise<InferData<TAuthClient["organization"]["listMembers"]>>; /** * Read organization members synchronously from the query cache without fetching. */ export declare const getListOrganizationMembers: <TAuthClient extends OrganizationAuthClient = OrganizationAuthClient>(queryClient: QueryClient, _authClient?: TAuthClient, userId?: string, params?: ListOrganizationMembersParams<TAuthClient>) => InferData<TAuthClient["organization"]["listMembers"]> | undefined;