import { Observable } from '@apollo/client/index.js';
import { IApolloClient } from '@deep-foundation/hasura/client.js';
import React from "react";
import { Link, MinilinksResult } from './minilinks.js';
import { BoolExpCan, BoolExpHandler, QueryLink, BoolExpSelector, BoolExpTree, BoolExpValue, MutationInputLink, MutationInputLinkPlain, MutationInputValue } from './client_types.js';
import { Traveler as NativeTraveler } from './traveler.js';
import { DeepClientOptions, DeepClientResult, DeepClientStartItem, DeepClientPathItem } from './client.js';
export interface DeepClientInstance<L extends Link<number> = Link<number>> {
    linkId?: number;
    token?: string;
    handleAuth?: (linkId?: number, token?: string) => any;
    deep: DeepClientInstance<L>;
    apolloClient: IApolloClient<any>;
    minilinks: MinilinksResult<L>;
    table?: string;
    returning?: string;
    selectReturning?: string;
    linksSelectReturning?: string;
    valuesSelectReturning?: string;
    selectorsSelectReturning?: string;
    filesSelectReturning?: string;
    insertReturning?: string;
    updateReturning?: string;
    deleteReturning?: string;
    defaultSelectName?: string;
    defaultInsertName?: string;
    defaultUpdateName?: string;
    defaultDeleteName?: string;
    unsafe?: any;
    stringify(any?: any): string;
    select<TTable extends 'links' | 'numbers' | 'strings' | 'objects' | 'can' | 'selectors' | 'tree' | 'handlers', LL = L>(exp: Exp<TTable>, options?: ReadOptions<TTable>): Promise<DeepClientResult<LL[] | number>>;
    subscribe<TTable extends 'links' | 'numbers' | 'strings' | 'objects' | 'can' | 'selectors' | 'tree' | 'handlers', LL = L>(exp: Exp<TTable>, options?: ReadOptions<TTable>): Observable<LL[] | number>;
    insert<TTable extends 'links' | 'numbers' | 'strings' | 'objects', LL = L>(objects: InsertObjects<TTable>, options?: WriteOptions<TTable>): Promise<DeepClientResult<{
        id: any;
    }[]>>;
    update<TTable extends 'links' | 'numbers' | 'strings' | 'objects'>(exp: Exp<TTable>, value: UpdateValue<TTable>, options?: WriteOptions<TTable>): Promise<DeepClientResult<{
        id: any;
    }[]>>;
    delete<TTable extends 'links' | 'numbers' | 'strings' | 'objects'>(exp: Exp<TTable>, options?: WriteOptions<TTable>): Promise<DeepClientResult<{
        id: any;
    }[]>>;
    serial(options: AsyncSerialParams): Promise<DeepClientResult<{
        id: any;
    }[]>>;
    reserve<LL = L>(count: number): Promise<number[]>;
    await(id: number): Promise<boolean>;
    serializeWhere(exp: any, env?: string): any;
    serializeQuery(exp: any, env?: string): any;
    id(start: DeepClientStartItem | QueryLink, ...path: DeepClientPathItem[]): Promise<number>;
    idLocal(start: DeepClientStartItem, ...path: DeepClientPathItem[]): number;
    guest(options: DeepClientGuestOptions): Promise<DeepClientAuthResult>;
    jwt(options: DeepClientJWTOptions): Promise<DeepClientAuthResult>;
    login(options: DeepClientJWTOptions): Promise<DeepClientAuthResult>;
    logout(): Promise<DeepClientAuthResult>;
    can(objectIds: number[], subjectIds: number[], actionIds: number[]): Promise<boolean>;
    useDeepSubscription: typeof useDeepSubscription;
    useDeepQuery: typeof useDeepQuery;
    useMinilinksQuery: (query: QueryLink) => L[];
    useMinilinksSubscription: (query: QueryLink) => L[];
    useDeep: typeof useDeep;
    DeepProvider: typeof DeepProvider;
    DeepContext: typeof DeepContext;
    Traveler(links: Link<number>[]): NativeTraveler;
}
export interface DeepClientAuthResult {
    linkId?: number;
    token?: string;
    error?: any;
}
export interface DeepClientGuestOptions {
    relogin?: boolean;
}
export interface DeepClientJWTOptions {
    linkId?: number;
    token?: string;
    relogin?: boolean;
}
export type SelectTable = 'links' | 'numbers' | 'strings' | 'objects' | 'can' | 'selectors' | 'tree' | 'handlers';
export type InsertTable = 'links' | 'numbers' | 'strings' | 'objects';
export type UpdateTable = 'links' | 'numbers' | 'strings' | 'objects' | 'can' | 'selectors' | 'tree' | 'handlers';
export type DeleteTable = 'links' | 'numbers' | 'strings' | 'objects' | 'can' | 'selectors' | 'tree' | 'handlers';
export type OperationType = 'select' | 'insert' | 'update' | 'delete';
export type SerialOperationType = 'insert' | 'update' | 'delete';
export type Table<TOperationType extends OperationType = OperationType> = TOperationType extends 'select' ? SelectTable : TOperationType extends 'insert' ? InsertTable : TOperationType extends 'update' ? UpdateTable : TOperationType extends 'delete' ? DeleteTable : never;
export type ValueForTable<TTable extends Table> = TTable extends 'numbers' ? MutationInputValue<number> : TTable extends 'strings' ? MutationInputValue<string> : TTable extends 'objects' ? MutationInputValue<any> : MutationInputLink;
export type ExpForTable<TTable extends Table> = TTable extends 'numbers' ? BoolExpValue<number> : TTable extends 'strings' ? BoolExpValue<string> : TTable extends 'objects' ? BoolExpValue<object> : TTable extends 'can' ? BoolExpCan : TTable extends 'selectors' ? BoolExpSelector : TTable extends 'tree' ? BoolExpTree : TTable extends 'handlers' ? BoolExpHandler : QueryLink;
export type SerialOperationDetails<TSerialOperationType extends SerialOperationType, TTable extends Table<TSerialOperationType>> = TSerialOperationType extends 'insert' ? {
    objects: ValueForTable<TTable> | ValueForTable<TTable>[];
} : TSerialOperationType extends 'update' ? {
    exp: ExpForTable<TTable> | number | number[];
    value: ValueForTable<TTable>;
} : TSerialOperationType extends 'delete' ? {
    exp: ExpForTable<TTable> | number | number[];
} : never;
export type SerialOperation<TSerialOperationType extends SerialOperationType = SerialOperationType, TTable extends Table<TSerialOperationType> = Table<TSerialOperationType>> = {
    type: TSerialOperationType;
    table: TTable;
} & SerialOperationDetails<TSerialOperationType, TTable>;
export type DeepSerialOperation = SerialOperation<SerialOperationType, Table<SerialOperationType>>;
export type AsyncSerialParams = {
    operations: Array<DeepSerialOperation>;
    name?: string;
    returning?: string;
    silent?: boolean;
};
export declare function checkAndFillShorts(obj: any): void;
export declare class DeepClient<L extends Link<number> = Link<number>> implements DeepClientInstance<L> {
    static resolveDependency?: (path: string) => Promise<any>;
    useDeepSubscription: typeof useDeepSubscription;
    useDeepQuery: typeof useDeepQuery;
    useMinilinksQuery: (query: QueryLink) => any;
    useMinilinksSubscription: (query: QueryLink) => any;
    useDeep: typeof useDeep;
    DeepProvider: typeof DeepProvider;
    DeepContext: React.Context<DeepClient<Link<number>>>;
    linkId?: number;
    token?: string;
    handleAuth?: (linkId?: number, token?: string) => any;
    deep: DeepClientInstance<L>;
    client: IApolloClient<any>;
    apolloClient: IApolloClient<any>;
    minilinks: MinilinksResult<L>;
    table?: string;
    returning?: string;
    selectReturning?: string;
    linksSelectReturning?: string;
    valuesSelectReturning?: string;
    selectorsSelectReturning?: string;
    filesSelectReturning?: string;
    insertReturning?: string;
    updateReturning?: string;
    deleteReturning?: string;
    defaultSelectName?: string;
    defaultInsertName?: string;
    defaultUpdateName?: string;
    defaultDeleteName?: string;
    silent: boolean;
    unsafe?: any;
    _silent(options?: Partial<{
        silent?: boolean;
    }>): boolean;
    constructor(options: DeepClientOptions<L>);
    stringify(any?: any): string;
    serializeQuery: (exp: any, env?: string) => any;
    serializeWhere: (exp: any, env?: string) => any;
    select<TTable extends 'links' | 'numbers' | 'strings' | 'objects' | 'can' | 'selectors' | 'tree' | 'handlers', LL = L>(exp: Exp<TTable>, options?: ReadOptions<TTable>): Promise<DeepClientResult<LL[]>>;
    subscribe<TTable extends 'links' | 'numbers' | 'strings' | 'objects' | 'can' | 'selectors' | 'tree' | 'handlers', LL = L>(exp: Exp<TTable>, options?: ReadOptions<TTable>): Observable<LL[]>;
    insert<TTable extends 'links' | 'numbers' | 'strings' | 'objects', LL = L>(objects: InsertObjects<TTable>, options?: WriteOptions<TTable>): Promise<DeepClientResult<{
        id: any;
    }[]>>;
    update<TTable extends 'links' | 'numbers' | 'strings' | 'objects'>(exp: Exp<TTable>, value: UpdateValue<TTable>, options?: WriteOptions<TTable>): Promise<DeepClientResult<{
        id: any;
    }[]>>;
    delete<TTable extends 'links' | 'numbers' | 'strings' | 'objects'>(exp: Exp<TTable>, options?: WriteOptions<TTable>): Promise<DeepClientResult<{
        id: any;
    }[]>>;
    serial({ name, operations, returning, silent }: AsyncSerialParams): Promise<DeepClientResult<{
        id: number;
    }[]>>;
    reserve<LL = L>(count: number): Promise<number[]>;
    await(id: number, options?: {
        results: boolean;
    }): Promise<any>;
    id(start: DeepClientStartItem | QueryLink, ...path: DeepClientPathItem[]): Promise<number>;
    ids(...paths: Array<[DeepClientStartItem, ...DeepClientPathItem[]]>): Promise<any>;
    idLocal(start: DeepClientStartItem, ...path: DeepClientPathItem[]): number;
    guest(options?: DeepClientGuestOptions): Promise<DeepClientAuthResult>;
    jwt(options: DeepClientJWTOptions): Promise<DeepClientAuthResult>;
    whoami(): Promise<number | undefined>;
    login(options: DeepClientJWTOptions): Promise<DeepClientAuthResult>;
    logout(): Promise<DeepClientAuthResult>;
    can(objectIds: null | number | number[], subjectIds: null | number | number[], actionIds: null | number | number[], userIds?: number | number[]): Promise<boolean>;
    name(input: Link<number> | number): Promise<string | undefined>;
    nameLocal(input: Link<number> | number): string | undefined;
    import(path: string): Promise<any>;
    Traveler(links: Link<number>[]): NativeTraveler;
}
export declare const JWT: import("graphql/language/ast.js").DocumentNode;
export declare const WHOISME: import("graphql/language/ast.js").DocumentNode;
export declare const GUEST: import("graphql/language/ast.js").DocumentNode;
export declare function useAuthNode(): [number, (value: number | import("@deep-foundation/store/store.js").IUseStoreSetHandler<number>) => any, () => any, boolean];
export declare const DeepContext: React.Context<DeepClient<Link<number>>>;
export declare function useDeepGenerator(apolloClientProps?: IApolloClient<any>): DeepClient<Link<number>>;
export declare function DeepProvider({ apolloClient: apolloClientProps, children, }: {
    apolloClient?: IApolloClient<any>;
    children: any;
}): React.JSX.Element;
export declare function useDeep(): DeepClient<Link<number>>;
export declare function useDeepQuery<Table extends 'links' | 'numbers' | 'strings' | 'objects' | 'can' | 'selectors' | 'tree' | 'handlers', LL = Link<number>>(query: QueryLink, options?: {
    table?: Table;
    tableNamePostfix?: string;
    returning?: string;
    variables?: any;
    name?: string;
    mini?: string;
}): {
    data?: LL[];
    error?: any;
    loading: boolean;
};
export declare function useDeepSubscription<Table extends 'links' | 'numbers' | 'strings' | 'objects' | 'can' | 'selectors' | 'tree' | 'handlers', LL = Link<number>>(query: QueryLink, options?: {
    table?: Table;
    tableNamePostfix?: string;
    returning?: string;
    variables?: any;
    name?: string;
    mini?: string;
}): UseDeepSubscriptionResult<LL>;
export interface UseDeepSubscriptionResult<LL = Link<number>> {
    data?: LL[];
    error?: any;
    loading: boolean;
}
export declare function useDeepId(start: DeepClientStartItem | QueryLink, ...path: DeepClientPathItem[]): {
    data: number;
    loading: boolean;
    error?: any;
};
export type Exp<TTable extends Table> = (TTable extends 'numbers' ? BoolExpValue<number> : TTable extends 'strings' ? BoolExpValue<string> : TTable extends 'objects' ? BoolExpValue<object> : TTable extends 'can' ? BoolExpCan : TTable extends 'selectors' ? BoolExpSelector : TTable extends 'tree' ? BoolExpTree : TTable extends 'handlers' ? BoolExpHandler : QueryLink) | number | number[];
export type UpdateValue<TTable extends Table> = (TTable extends 'numbers' ? MutationInputValue<number> : TTable extends 'strings' ? MutationInputValue<string> : TTable extends 'objects' ? MutationInputValue<any> : MutationInputLinkPlain);
export type InsertObjects<TTable extends Table> = (TTable extends 'numbers' ? MutationInputValue<number> : TTable extends 'strings' ? MutationInputValue<string> : TTable extends 'objects' ? MutationInputValue<any> : MutationInputLink) | (TTable extends 'numbers' ? MutationInputValue<number> : TTable extends 'strings' ? MutationInputValue<string> : TTable extends 'objects' ? MutationInputValue<any> : MutationInputLink)[];
export type Options<TTable extends Table> = {
    table?: TTable;
    tableNamePostfix?: string;
    returning?: string;
    variables?: any;
    name?: string;
    aggregate?: 'count' | 'sum' | 'avg' | 'min' | 'max';
};
export type ReadOptions<TTable extends Table> = Options<TTable>;
export type WriteOptions<TTable extends Table> = Options<TTable> & {
    silent?: boolean;
};
