import { Zero as ZeroClient } from '@rocicorp/zero'; import { type Context, type ReactNode } from 'react'; import { type QueryControlMode, type UseQueryHook } from './createUseQuery'; import { type Emitter } from './helpers/emitter'; import { type RecoveryGuardStorage, type ScheduleReloadContext, type ZeroLogPattern } from './helpers/recoverZeroClient'; import { resolveQuery, type PlainQueryFn } from './resolveQuery'; import type { AuthData, GenericModels, GetZeroMutators, ZeroEventsEmitter } from './types'; import type { AnyQueryRegistry, Query, Row, ZeroOptions, Schema as ZeroSchema } from '@rocicorp/zero'; import type { AggregateSet } from 'orez-lite/aggregate'; import type { HttpPullTransport } from 'orez-lite/client'; type PreloadOptions = { ttl?: 'always' | 'never' | number | undefined; }; export type GroupedQueries = Record any>>; export type PermissionStrategy = 'optimistic' | 'optimistic-deny' | 'optimistic-allow'; export type ZeroProviderTransport = { install(serverURL: string): Pick | undefined; logClassifications?: { benign?: readonly ZeroLogPattern[]; }; }; export type ZeroProviderGeneration = { isCurrent: () => boolean; }; export type WaitForZeroOptions = { signal?: AbortSignal; }; export type CreateZeroClientOptions = { schema: Schema; models: Models; groupedQueries: GroupedQueries; aggregates?: AggregateSet; permissionStrategy?: PermissionStrategy; serverAckTimeoutRecoveryThreshold?: number; instanceName?: string; }; export type DirectQueryAdapter = (props: { DisabledContext: Context; customQueries: AnyQueryRegistry; getZero: () => any; zeroVersion: Emitter; }) => UseQueryHook; export declare function createZeroClient(options: CreateZeroClientOptions): { instanceName: string; zeroEvents: ZeroEventsEmitter; reloadPage: () => boolean; ProvideZero: ({ children, authData: authDataIn }: Omit>, "schema" | "mutators"> & { children: ReactNode; authData?: {} | null | undefined; disable?: boolean; transport?: ZeroProviderTransport; beforeReload?: (() => Promise) | undefined; scheduleReload?: ((ctx: ScheduleReloadContext) => void) | undefined; guardStorage?: RecoveryGuardStorage; benignLogPatterns?: readonly ZeroLogPattern[]; refreshAuth?: (() => Promise) | undefined; connectionDataset?: boolean; }) => import("react").JSX.Element; connectHeadless: (props: Omit>, "schema" | "mutators"> & { authData?: {} | null | undefined; transport?: ZeroProviderTransport; beforeReload?: (() => Promise) | undefined; scheduleReload?: ((ctx: ScheduleReloadContext) => void) | undefined; guardStorage?: RecoveryGuardStorage; benignLogPatterns?: readonly ZeroLogPattern[]; refreshAuth?: (() => Promise) | undefined; }) => { zero: ZeroClient, unknown>; close: () => Promise; }; ControlQueries: ({ children, action, whenDisabled, }: { children: ReactNode; action?: "enable" | "disable"; whenDisabled?: "empty" | "last-value"; }) => import("react").JSX.Element; useQuery: UseQueryHook; useQueryDirect: UseQueryHook; usePermission: (table: (string & {}) | (keyof Schema["tables"] & string), objOrId: string | Partial> | undefined, enabled?: boolean, debug?: boolean) => boolean | null; usePermissionDirect: (table: (string & {}) | (keyof Schema["tables"] & string), objOrId: string | Partial> | undefined, enabled?: boolean, debug?: boolean) => boolean | null; useZeroProviderGeneration: () => ZeroProviderGeneration | null; zero: ZeroClient, unknown>; preload: { (fn: PlainQueryFn>, params: TArg, options?: PreloadOptions): { cleanup: () => void; complete: Promise; }; (fn: PlainQueryFn>, options?: PreloadOptions): { cleanup: () => void; complete: Promise; }; }; getQuery: { (fn: PlainQueryFn>, params: TArg): ReturnType>; (fn: PlainQueryFn>): ReturnType>; }; waitForZero: ({ signal }?: WaitForZeroOptions) => Promise, unknown>>; remint: (opts?: { dropLocalState?: boolean; }) => Promise; retire: () => Promise; mutationLifecycle: import(".").MutationLifecycle; drainBackgroundMutations: (options?: { timeoutMs?: number; }) => Promise; enqueueBackgroundMutation: (label: string, create: () => unknown, options?: import(".").BackgroundMutationOptions) => Promise; awaitMutationClient: (mutation: import(".").MutationLike, label: string, timeoutMs?: number) => Promise; awaitMutationServer: (mutation: import(".").MutationLike, label: string, timeoutMs?: number) => Promise; }; export declare function createZeroClientInternal({ schema, models, groupedQueries, aggregates, permissionStrategy, instanceName, serverAckTimeoutRecoveryThreshold, createDirectUseQuery, }: CreateZeroClientOptions & { createDirectUseQuery?: DirectQueryAdapter; }): { instanceName: string; zeroEvents: ZeroEventsEmitter; reloadPage: () => boolean; ProvideZero: ({ children, authData: authDataIn }: Omit>, "schema" | "mutators"> & { children: ReactNode; authData?: AuthData | null; disable?: boolean; transport?: ZeroProviderTransport; beforeReload?: () => Promise; scheduleReload?: (ctx: ScheduleReloadContext) => void; guardStorage?: RecoveryGuardStorage; benignLogPatterns?: readonly ZeroLogPattern[]; refreshAuth?: () => Promise; connectionDataset?: boolean; }) => import("react").JSX.Element; connectHeadless: (props: Omit>, "schema" | "mutators"> & { authData?: AuthData | null; transport?: ZeroProviderTransport; beforeReload?: () => Promise; scheduleReload?: (ctx: ScheduleReloadContext) => void; guardStorage?: RecoveryGuardStorage; benignLogPatterns?: readonly ZeroLogPattern[]; refreshAuth?: () => Promise; }) => { zero: ZeroClient, unknown>; close: () => Promise; }; ControlQueries: ({ children, action, whenDisabled, }: { children: ReactNode; action?: "enable" | "disable"; whenDisabled?: "empty" | "last-value"; }) => import("react").JSX.Element; useQuery: UseQueryHook; useQueryDirect: UseQueryHook; usePermission: (table: (keyof Schema["tables"] & string) | (string & {}), objOrId: string | Partial> | undefined, enabled?: boolean, debug?: boolean) => boolean | null; usePermissionDirect: (table: (keyof Schema["tables"] & string) | (string & {}), objOrId: string | Partial> | undefined, enabled?: boolean, debug?: boolean) => boolean | null; useZeroProviderGeneration: () => ZeroProviderGeneration | null; zero: ZeroClient, unknown>; preload: { (fn: PlainQueryFn>, params: TArg, options?: PreloadOptions): { cleanup: () => void; complete: Promise; }; (fn: PlainQueryFn>, options?: PreloadOptions): { cleanup: () => void; complete: Promise; }; }; getQuery: { (fn: PlainQueryFn>, params: TArg): ReturnType>; (fn: PlainQueryFn>): ReturnType>; }; waitForZero: ({ signal }?: WaitForZeroOptions) => Promise, unknown>>; remint: (opts?: { dropLocalState?: boolean; }) => Promise; retire: () => Promise; mutationLifecycle: import(".").MutationLifecycle; drainBackgroundMutations: (options?: { timeoutMs?: number; }) => Promise; enqueueBackgroundMutation: (label: string, create: () => unknown, options?: import(".").BackgroundMutationOptions) => Promise; awaitMutationClient: (mutation: import(".").MutationLike, label: string, timeoutMs?: number) => Promise; awaitMutationServer: (mutation: import(".").MutationLike, label: string, timeoutMs?: number) => Promise; }; export {}; //# sourceMappingURL=createZeroClient.d.ts.map