import { CancelToken } from "@iyio/common";
import { ZodType } from "zod";
import { PromiseResultType, PromiseResultTypeVoid } from "../result-type.js";
import { ConvoDb, ConvoDbCommand, ConvoDbCommandResult, ConvoDbDriver, ConvoNode, ConvoNodeEdge, ConvoNodeEdgeQuery, ConvoNodeEdgeQueryResult, ConvoNodeEdgeUpdate, ConvoNodeEmbedding, ConvoNodeEmbeddingQuery, ConvoNodeEmbeddingQueryResult, ConvoNodeEmbeddingUpdate, ConvoNodeKeySelection, ConvoNodePermissionType, ConvoNodeQuery, ConvoNodeQueryKeysToSelection, ConvoNodeQueryResult, ConvoNodeStreamItem, ConvoNodeUpdate, DeleteConvoNodeEdgeOptions, DeleteConvoNodeEmbeddingOptions, DeleteConvoNodeOptions, InsertConvoNodeEdgeOptions, InsertConvoNodeEmbeddingOptions, InsertConvoNodeOptions, UpdateConvoNodeEdgeOptions, UpdateConvoNodeEmbeddingOptions, UpdateConvoNodeOptions } from "./convo-db-types.js";
import { ConvoDbAuthManager } from "./ConvoDbAuthManager.js";
export interface ConvoDbPermissionBoundaryOptions {
    proxiedDb: ConvoDb;
    identityPath: string;
    auth: ConvoDbAuthManager;
}
/**
 * The ConvoDbPermissionBoundary class wraps an existing ConvoDb and ensures all calls to the wrapped
 * database use the provided `identityPath`. Permissions boundaries allow save access from external
 * callers ensuring that their access to the wrapped database is restricted to their identityPath.
 * The provided `identityPath` will be used to set the `permissionFrom` of all calls to the wrapped
 * database. The permissionFrom value supplied by external callers will always be overwritten.
 * External callers are not allowed to issue driver commands and will receive a 401 response
 * if they try.
 */
export declare class ConvoDbPermissionBoundary implements ConvoDb {
    readonly dbName: string;
    readonly auth: ConvoDbAuthManager;
    readonly proxiedDb: ConvoDb;
    readonly identityPath: string;
    readonly parentAuth: ConvoDbAuthManager;
    readonly _driver: ConvoDbDriver;
    lastUsed: number;
    constructor({ proxiedDb, identityPath, auth, }: ConvoDbPermissionBoundaryOptions);
    initAsync(): PromiseResultTypeVoid;
    get isDisposed(): boolean;
    dispose(): void;
    readBlobStringAsync(path: string, permissionFrom?: string): PromiseResultType<string | undefined>;
    openBlobAsync(path: string): PromiseResultType<ReadableStream>;
    writeBlobAsync(path: string, blob: string | Blob | ReadableStream): PromiseResultTypeVoid;
    hasBlobAsync(path: string): PromiseResultType<boolean>;
    callFunctionAsync<T extends Record<string, any> = Record<string, any>>(path: string, args: Record<string, any>, _permissionFrom?: string): PromiseResultType<T | undefined>;
    callFunctionWithSchemaAsync<TInput, TOutput>(inputSchema: ZodType<TInput>, outputSchema: ZodType<TOutput>, path: string, args: TInput, _permissionFrom?: string): PromiseResultType<TOutput>;
    callFunctionReturnValueAsync<T extends Record<string, any> = Record<string, any>>(path: string, args: Record<string, any>, _permissionFrom?: string): PromiseResultType<T>;
    callFunctionReturnNodeAsync(path: string, args: Record<string, any>, _permissionFrom?: string): PromiseResultType<ConvoNode | undefined>;
    queryNodesAsync<TKeys extends ConvoNodeKeySelection = undefined>(query: ConvoNodeQuery<TKeys>): PromiseResultType<ConvoNodeQueryResult<ConvoNodeQueryKeysToSelection<TKeys>>>;
    streamNodesAsync<TKeys extends ConvoNodeKeySelection = undefined>(query: ConvoNodeQuery<TKeys>, cancel?: CancelToken): AsyncIterableIterator<ConvoNodeStreamItem<ConvoNodeQueryKeysToSelection<TKeys>>>;
    getNodesByPathAsync(path: string, _permissionFrom?: string): PromiseResultType<ConvoNodeQueryResult<keyof ConvoNode>>;
    getNodeByPathAsync(path: string, _permissionFrom?: string): PromiseResultType<ConvoNode | undefined>;
    requireNodeByPathAsync(path: string, permissionFrom?: string): PromiseResultType<ConvoNode>;
    getNodePermissionAsync(_fromPath: string, toPath: string): PromiseResultType<ConvoNodePermissionType>;
    checkNodePermissionAsync(_fromPath: string, toPath: string, type: ConvoNodePermissionType, matchAny?: boolean): PromiseResultTypeVoid;
    insertNodeAsync(node: ConvoNode, options?: InsertConvoNodeOptions): PromiseResultType<ConvoNode>;
    updateNodeAsync(node: ConvoNodeUpdate, options?: UpdateConvoNodeOptions): PromiseResultTypeVoid;
    deleteNodeAsync(path: string, options?: DeleteConvoNodeOptions): PromiseResultTypeVoid;
    queryEdgesAsync(query: ConvoNodeEdgeQuery): PromiseResultType<ConvoNodeEdgeQueryResult>;
    getEdgeByIdAsync(id: string, _permissionFrom?: string): PromiseResultType<ConvoNodeEdge>;
    insertEdgeAsync(edge: Omit<ConvoNodeEdge, "id">, options?: InsertConvoNodeEdgeOptions): PromiseResultType<ConvoNodeEdge>;
    updateEdgeAsync(update: ConvoNodeEdgeUpdate, options?: UpdateConvoNodeEdgeOptions): PromiseResultTypeVoid;
    deleteEdgeAsync(id: string, options?: DeleteConvoNodeEdgeOptions): PromiseResultTypeVoid;
    queryEmbeddingsAsync(query: ConvoNodeEmbeddingQuery): PromiseResultType<ConvoNodeEmbeddingQueryResult>;
    getEmbeddingByIdAsync(id: string, _permissionFrom?: string): PromiseResultType<ConvoNodeEmbedding>;
    insertEmbeddingAsync(embedding: Omit<ConvoNodeEmbedding, "id">, options?: InsertConvoNodeEmbeddingOptions): PromiseResultType<ConvoNodeEmbedding>;
    updateEmbeddingAsync(update: ConvoNodeEmbeddingUpdate, options?: UpdateConvoNodeEmbeddingOptions): PromiseResultTypeVoid;
    deleteEmbeddingAsync(id: string, options?: DeleteConvoNodeEmbeddingOptions): PromiseResultTypeVoid;
    executeCommandAsync<TKeys extends ConvoNodeKeySelection = "*">(command: ConvoDbCommand<TKeys>): PromiseResultType<ConvoDbCommandResult<TKeys>>;
    executeCommandsAsync(commands: ConvoDbCommand<any>[]): PromiseResultType<ConvoDbCommandResult<any>[]>;
}
