import { type DefaultError, type InfiniteData, type QueryKey, type UseInfiniteQueryOptions, type UseInfiniteQueryReturnType, type UseMutationOptions, type UseMutationReturnType, type UseQueryOptions, type UseQueryReturnType } from '@tanstack/vue-query'; import { type InferExtQueryArgs, type InferExtResult, type InferOptions, type InferSchema } from '@zenstackhq/client-helpers'; import type { AggregateArgs, AggregateResult, BatchResult, ClientContract, CountArgs, CountResult, CreateArgs, CreateManyAndReturnArgs, CreateManyArgs, DeleteArgs, DeleteManyArgs, ExistsArgs, ExtQueryArgsBase, ExtResultBase, FindFirstArgs, FindManyArgs, FindUniqueArgs, GetProcedure, GetProcedureNames, GetSlicedModels, GetSlicedProcedures, GroupByArgs, GroupByResult, ProcedureEnvelope, QueryOptions, SelectSubset, SimplifiedPlainResult, SimplifiedResult, Subset, UpdateArgs, UpdateManyAndReturnArgs, UpdateManyArgs, UpsertArgs } from '@zenstackhq/orm'; import type { GetModels, SchemaDef } from '@zenstackhq/schema'; import { type MaybeRefOrGetter, type Ref, type UnwrapRef } from 'vue'; import type { ExtraMutationOptions, ExtraQueryOptions, ProcedureReturn, QueryContext, TransactionOperation, TransactionResults, TrimSlicedOperations, WithOptimistic } from './common/types.js'; export { AnyNull, DbNull, JsonNull } from '@zenstackhq/client-helpers'; export type { InferExtQueryArgs, InferExtResult, InferOptions, InferSchema } from '@zenstackhq/client-helpers'; export type { FetchFn } from '@zenstackhq/client-helpers/fetch'; export type { SchemaDef } from '@zenstackhq/schema'; export { getQueryKey } from './common/query-key.js'; export declare const VueQueryContextKey = "zenstack-vue-query-context"; type ProcedureHookFn, Options, Result, Input = ProcedureEnvelope> = { args: undefined; } extends Input ? (args?: MaybeRefOrGetter, options?: MaybeRefOrGetter) => Result : (args: MaybeRefOrGetter, options?: MaybeRefOrGetter) => Result; /** * Provide context for query settings. * * @deprecated Use {@link provideQuerySettingsContext} instead. */ export declare function provideHooksContext(context: QueryContext): void; /** * Provide context for query settings. */ export declare function provideQuerySettingsContext(context: QueryContext): void; export type ModelQueryOptions = MaybeRefOrGetter>, 'queryKey'> & ExtraQueryOptions>; export type ModelQueryResult = UseQueryReturnType, DefaultError> & { queryKey: Ref; }; export type ModelInfiniteQueryOptions = MaybeRefOrGetter, QueryKey, TPageParam>>, 'queryKey' | 'initialPageParam'> & QueryContext>; export type ModelInfiniteQueryResult = UseInfiniteQueryReturnType & { queryKey: Ref; }; export type ModelMutationOptions = MaybeRefOrGetter>, 'mutationFn'> & ExtraMutationOptions>; export type ModelMutationResult = UseMutationReturnType; export type ModelMutationModelResult, TArgs, Array extends boolean = false, Options extends QueryOptions = QueryOptions, ExtResult extends ExtResultBase = {}> = Omit, TArgs>, 'mutateAsync'> & { mutateAsync(args: T, options?: ModelMutationOptions, T>): Promise>; }; /** * Options accepted by `$transaction.useSequential()`. */ export type TransactionMutationOptions = QueryOptions, ExtQueryArgs extends ExtQueryArgsBase = {}, ExtResult extends ExtResultBase = {}> = MaybeRefOrGetter[]>>, 'mutationFn'> & Omit>; /** * The return type of `$transaction.useSequential()`. Overrides `mutateAsync` so the * resolved value is a tuple of per-operation results, narrowed to each operation's * model + op + args (mirrors the typing of the corresponding ORM CRUD method). */ export type TransactionMutationResult = QueryOptions, ExtQueryArgs extends ExtQueryArgsBase = {}, ExtResult extends ExtResultBase = {}> = Omit[], unknown>, 'mutateAsync'> & { mutateAsync[]>(operations: T, options?: Omit, DefaultError, T>, 'mutationFn'>): Promise>; }; /** * The full set of TanStack Query hooks returned by {@link useClientQueries}. */ export type ClientHooks = QueryOptions, ExtQueryArgs extends ExtQueryArgsBase = {}, ExtResult extends ExtResultBase = {}> = { [Model in GetSlicedModels as `${Uncapitalize}`]: ModelQueryHooks; } & ProcedureHooks & { $transaction: { useSequential(options?: TransactionMutationOptions): TransactionMutationResult; }; }; type ProcedureHookGroup> = { [Name in GetSlicedProcedures]: GetProcedure extends { mutation: true; } ? { useMutation(options?: MaybeRefOrGetter, DefaultError, ProcedureEnvelope>>, 'mutationFn'> & QueryContext>): UseMutationReturnType, DefaultError, ProcedureEnvelope, unknown>; } : { useQuery: ProcedureHookFn>, 'optimisticUpdate'>, UseQueryReturnType, DefaultError> & { queryKey: Ref; }>; }; }; export type ProcedureHooks> = Schema['procedures'] extends Record ? { /** * Custom procedures. */ $procs: ProcedureHookGroup; } : Record; export type ModelQueryHooks, Options extends QueryOptions = QueryOptions, ExtQueryArgs extends ExtQueryArgsBase = {}, ExtResult extends ExtResultBase = {}> = TrimSlicedOperations>(args: MaybeRefOrGetter>>, options?: MaybeRefOrGetter | null>>): ModelQueryResult | null>; useFindFirst>(args?: MaybeRefOrGetter>>, options?: MaybeRefOrGetter | null>>): ModelQueryResult | null>; useExists>(args?: MaybeRefOrGetter>>, options?: MaybeRefOrGetter>): ModelQueryResult; useFindMany>(args?: MaybeRefOrGetter>>, options?: MaybeRefOrGetter[]>>): ModelQueryResult[]>; useInfiniteFindMany, TPageParam = unknown>(args?: MaybeRefOrGetter>>, options?: MaybeRefOrGetter[], TPageParam>>): ModelInfiniteQueryResult[], TPageParam>>; useCreate>(options?: MaybeRefOrGetter, T>>): ModelMutationModelResult; useCreateMany>(options?: MaybeRefOrGetter>): ModelMutationResult; useCreateManyAndReturn>(options?: MaybeRefOrGetter[], T>>): ModelMutationModelResult; useUpdate>(options?: MaybeRefOrGetter, T>>): ModelMutationModelResult; useUpdateMany>(options?: MaybeRefOrGetter>): ModelMutationResult; useUpdateManyAndReturn>(options?: MaybeRefOrGetter[], T>>): ModelMutationModelResult; useUpsert>(options?: MaybeRefOrGetter, T>>): ModelMutationModelResult; useDelete>(options?: MaybeRefOrGetter, T>>): ModelMutationModelResult; useDeleteMany>(options?: MaybeRefOrGetter>): ModelMutationResult; useCount>(args?: MaybeRefOrGetter>>, options?: MaybeRefOrGetter>>): ModelQueryResult>; useAggregate>(args: MaybeRefOrGetter>>, options?: MaybeRefOrGetter>>): ModelQueryResult>; useGroupBy>(args: MaybeRefOrGetter>>, options?: MaybeRefOrGetter>>): ModelQueryResult>; }>; /** * Gets data query hooks for all models in the schema. * * Accepts either a raw `SchemaDef` or a `ClientContract` type (e.g. `typeof db`) as the generic parameter. * When a `ClientContract` type is provided, computed fields from plugins are reflected in the result types. * * @example * ```typescript * // Basic usage with schema * const client = useClientQueries(schema) * * // With server client type for computed field support * import type { DbType } from '~/server/db' * const client = useClientQueries(schema) * ``` */ export declare function useClientQueries>(schema: InferSchema, options?: MaybeRefOrGetter): ClientHooks, InferOptions>, InferExtQueryArgs extends ExtQueryArgsBase ? InferExtQueryArgs : {}, InferExtResult extends ExtResultBase> ? InferExtResult : {}>; /** * Gets data query hooks for a specific model in the schema. */ export declare function useModelQueries, Options extends QueryOptions, ExtQueryArgs extends ExtQueryArgsBase = {}, ExtResult extends ExtResultBase = {}>(schema: Schema, model: Model, rootOptions?: MaybeRefOrGetter): ModelQueryHooks; export declare function useInternalQuery(_schema: SchemaDef, model: string, operation: string, args?: MaybeRefOrGetter, options?: MaybeRefOrGetter>, 'queryKey'> & ExtraQueryOptions>): { data: Ref; error: Ref; isError: Ref; isPending: Ref; isLoading: Ref; isLoadingError: Ref; isRefetchError: Ref; isSuccess: Ref; isPlaceholderData: Ref; status: Ref<"error", "error">; dataUpdatedAt: Ref; errorUpdatedAt: Ref; failureCount: Ref; failureReason: Ref; errorUpdateCount: Ref; isFetched: Ref; isFetchedAfterMount: Ref; isFetching: Ref; isInitialLoading: Ref; isPaused: Ref; isRefetching: Ref; isStale: Ref; isEnabled: Ref; refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise>; fetchStatus: Ref; promise: Ref, Promise>; suspense: () => Promise>; queryKey: import("vue").ComputedRef; } | { data: Ref; error: Ref; isError: Ref; isPending: Ref; isLoading: Ref; isLoadingError: Ref; isRefetchError: Ref; isSuccess: Ref; isPlaceholderData: Ref; status: Ref<"success", "success">; dataUpdatedAt: Ref; errorUpdatedAt: Ref; failureCount: Ref; failureReason: Ref; errorUpdateCount: Ref; isFetched: Ref; isFetchedAfterMount: Ref; isFetching: Ref; isInitialLoading: Ref; isPaused: Ref; isRefetching: Ref; isStale: Ref; isEnabled: Ref; refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise>; fetchStatus: Ref; promise: Ref, Promise>; suspense: () => Promise>; queryKey: import("vue").ComputedRef; }; export declare function useInternalInfiniteQuery(_schema: SchemaDef, model: string, operation: string, args: MaybeRefOrGetter, options: MaybeRefOrGetter<(Omit, QueryKey, TPageParam>>, 'queryKey' | 'initialPageParam'> & QueryContext) | undefined>): { data: Ref, InfiniteData>; error: Ref; isError: Ref; isPending: Ref; isLoading: Ref; isLoadingError: Ref; isRefetchError: Ref; isSuccess: Ref; isPlaceholderData: Ref; status: Ref<"error", "error">; fetchNextPage: (options?: import("@tanstack/query-core").FetchNextPageOptions) => Promise, Error>>; fetchPreviousPage: (options?: import("@tanstack/query-core").FetchPreviousPageOptions) => Promise, Error>>; hasNextPage: Ref; hasPreviousPage: Ref; isFetchNextPageError: Ref; isFetchingNextPage: Ref; isFetchPreviousPageError: Ref; isFetchingPreviousPage: Ref; dataUpdatedAt: Ref; errorUpdatedAt: Ref; failureCount: Ref; failureReason: Ref; errorUpdateCount: Ref; isFetched: Ref; isFetchedAfterMount: Ref; isFetching: Ref; isInitialLoading: Ref; isPaused: Ref; isRefetching: Ref; isStale: Ref; isEnabled: Ref; refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise, Error>>; fetchStatus: Ref; promise: Ref>, Promise>>; suspense: () => Promise, Error>>; queryKey: import("vue").ComputedRef; } | { data: Ref, InfiniteData>; error: Ref; isError: Ref; isPending: Ref; isLoading: Ref; isLoadingError: Ref; isRefetchError: Ref; isFetchNextPageError: Ref; isFetchPreviousPageError: Ref; isSuccess: Ref; isPlaceholderData: Ref; status: Ref<"success", "success">; fetchNextPage: (options?: import("@tanstack/query-core").FetchNextPageOptions) => Promise, Error>>; fetchPreviousPage: (options?: import("@tanstack/query-core").FetchPreviousPageOptions) => Promise, Error>>; hasNextPage: Ref; hasPreviousPage: Ref; isFetchingNextPage: Ref; isFetchingPreviousPage: Ref; dataUpdatedAt: Ref; errorUpdatedAt: Ref; failureCount: Ref; failureReason: Ref; errorUpdateCount: Ref; isFetched: Ref; isFetchedAfterMount: Ref; isFetching: Ref; isInitialLoading: Ref; isPaused: Ref; isRefetching: Ref; isStale: Ref; isEnabled: Ref; refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise, Error>>; fetchStatus: Ref; promise: Ref>, Promise>>; suspense: () => Promise, Error>>; queryKey: import("vue").ComputedRef; } | { data: Ref; error: Ref; isError: Ref; isPending: Ref; isLoading: Ref; isLoadingError: Ref; isRefetchError: Ref; isFetchNextPageError: Ref; isFetchPreviousPageError: Ref; isSuccess: Ref; isPlaceholderData: Ref; status: Ref<"error", "error">; fetchNextPage: (options?: import("@tanstack/query-core").FetchNextPageOptions) => Promise, Error>>; fetchPreviousPage: (options?: import("@tanstack/query-core").FetchPreviousPageOptions) => Promise, Error>>; hasNextPage: Ref; hasPreviousPage: Ref; isFetchingNextPage: Ref; isFetchingPreviousPage: Ref; dataUpdatedAt: Ref; errorUpdatedAt: Ref; failureCount: Ref; failureReason: Ref; errorUpdateCount: Ref; isFetched: Ref; isFetchedAfterMount: Ref; isFetching: Ref; isInitialLoading: Ref; isPaused: Ref; isRefetching: Ref; isStale: Ref; isEnabled: Ref; refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise, Error>>; fetchStatus: Ref; promise: Ref>, Promise>>; suspense: () => Promise, Error>>; queryKey: import("vue").ComputedRef; } | { data: Ref; error: Ref; isError: Ref; isPending: Ref; isLoading: Ref; isLoadingError: Ref; isRefetchError: Ref; isFetchNextPageError: Ref; isFetchPreviousPageError: Ref; isSuccess: Ref; isPlaceholderData: Ref; status: Ref<"pending", "pending">; fetchNextPage: (options?: import("@tanstack/query-core").FetchNextPageOptions) => Promise, Error>>; fetchPreviousPage: (options?: import("@tanstack/query-core").FetchPreviousPageOptions) => Promise, Error>>; hasNextPage: Ref; hasPreviousPage: Ref; isFetchingNextPage: Ref; isFetchingPreviousPage: Ref; dataUpdatedAt: Ref; errorUpdatedAt: Ref; failureCount: Ref; failureReason: Ref; errorUpdateCount: Ref; isFetched: Ref; isFetchedAfterMount: Ref; isFetching: Ref; isInitialLoading: Ref; isPaused: Ref; isRefetching: Ref; isStale: Ref; isEnabled: Ref; refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise, Error>>; fetchStatus: Ref; promise: Ref>, Promise>>; suspense: () => Promise, Error>>; queryKey: import("vue").ComputedRef; } | { data: Ref; error: Ref; isError: Ref; isPending: Ref; isLoadingError: Ref; isRefetchError: Ref; isFetchNextPageError: Ref; isFetchPreviousPageError: Ref; isSuccess: Ref; isPlaceholderData: Ref; status: Ref<"pending", "pending">; fetchNextPage: (options?: import("@tanstack/query-core").FetchNextPageOptions) => Promise, Error>>; fetchPreviousPage: (options?: import("@tanstack/query-core").FetchPreviousPageOptions) => Promise, Error>>; hasNextPage: Ref; hasPreviousPage: Ref; isFetchingNextPage: Ref; isFetchingPreviousPage: Ref; dataUpdatedAt: Ref; errorUpdatedAt: Ref; failureCount: Ref; failureReason: Ref; errorUpdateCount: Ref; isFetched: Ref; isFetchedAfterMount: Ref; isFetching: Ref; isLoading: Ref; isInitialLoading: Ref; isPaused: Ref; isRefetching: Ref; isStale: Ref; isEnabled: Ref; refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise, Error>>; fetchStatus: Ref; promise: Ref>, Promise>>; suspense: () => Promise, Error>>; queryKey: import("vue").ComputedRef; } | { data: Ref, InfiniteData>; isError: Ref; error: Ref; isPending: Ref; isLoading: Ref; isLoadingError: Ref; isRefetchError: Ref; isSuccess: Ref; isPlaceholderData: Ref; isFetchNextPageError: Ref; isFetchPreviousPageError: Ref; status: Ref<"success", "success">; fetchNextPage: (options?: import("@tanstack/query-core").FetchNextPageOptions) => Promise, Error>>; fetchPreviousPage: (options?: import("@tanstack/query-core").FetchPreviousPageOptions) => Promise, Error>>; hasNextPage: Ref; hasPreviousPage: Ref; isFetchingNextPage: Ref; isFetchingPreviousPage: Ref; dataUpdatedAt: Ref; errorUpdatedAt: Ref; failureCount: Ref; failureReason: Ref; errorUpdateCount: Ref; isFetched: Ref; isFetchedAfterMount: Ref; isFetching: Ref; isInitialLoading: Ref; isPaused: Ref; isRefetching: Ref; isStale: Ref; isEnabled: Ref; refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise, Error>>; fetchStatus: Ref; promise: Ref>, Promise>>; suspense: () => Promise, Error>>; queryKey: import("vue").ComputedRef; }; /** * Creates a vue-query mutation * * @private * * @param model The name of the model under mutation. * @param method The HTTP method. * @param operation The mutation operation (e.g. `create`). * @param options The vue-query options. * @param checkReadBack Whether to check for read back errors and return undefined if found. */ export declare function useInternalMutation(schema: SchemaDef, model: string, method: 'POST' | 'PUT' | 'DELETE', operation: string, options?: MaybeRefOrGetter>, 'mutationFn'> & ExtraMutationOptions>): UseMutationReturnType, "mutate" | "reset"> | Omit, "mutate" | "reset"> | Omit, "mutate" | "reset"> | Omit, "mutate" | "reset">>; export declare function useInternalTransactionMutation = QueryOptions, ExtQueryArgs extends ExtQueryArgsBase = {}, ExtResult extends ExtResultBase = {}>(schema: Schema, options?: TransactionMutationOptions): TransactionMutationResult;