import { IBackendInfo, ContextListOptions, ContextListResult, IFile, IFileCreateOptions, AccessOperation, IUser, IAccessPatchInfo, IPatchInfo, IPatchRevision, IApplication, ListFileKind, IBulkOperationResult, ContextChangeRecord, ContextDeleteRecord, IProjectExecution, IProjectExecutionListOptions, ISpace, PermissionRole, ContextSpaceListOptions, IRevision, TrashEntry, TrashEntryCreate, ContextDeleteBulkEvent, FileAddOptions, FileBreadcrumb } from '@api-client/core/build/browser.js';
import { Patch } from '@api-client/json';
import { PlatformBindings } from './PlatformBindings.js';
import { IConfigEnvironment, IConfigInit } from '../../lib/config/Config.js';
import { ISessionInitInfo, HttpStore } from '../../store/HttpStore.js';
export interface EnvironmentSettings {
    /**
     * Initializes the store configuration from the init data.
     *
     * @param init The init data for the store environment.
     */
    init(init: IConfigInit): Promise<void>;
    /**
     * Reads the backend information about the store.
     *
     * @param baseUri Store's base URI.
     */
    readStoreInfo(baseUri: string): Promise<IBackendInfo>;
}
export interface StoreAuthenticationInit {
    /**
     * The environment to authenticate. Default to globally set environment.
     */
    env?: IConfigEnvironment;
    /**
     * Whether to update environment in application configuration after authentication.
     */
    updateEnvironment?: boolean;
    /**
     * Whether to force authentication even when the user is already authenticated.
     */
    force?: boolean;
}
interface StoreAuthentication {
    /**
     * Checks whether the user is authenticated in the store for the environment
     * @param env Optional environment if different than the global environment
     * @returns True if the user is authenticated in the store.
     */
    isAuthenticated(env?: IConfigEnvironment): Promise<boolean>;
    /**
     * Authenticates the global environment with the store.
     *
     * @param updateEnvironment When true it stores the environment data when the session was renewed.
     */
    authenticate(options?: StoreAuthenticationInit): Promise<ISessionInitInfo>;
    getToken(): Promise<string | undefined>;
}
/**
 * The base class for API store bindings.
 */
export declare abstract class StoreBindings extends PlatformBindings {
    /**
     * This is used by the client side (main thread or the renderer process)
     * to define the current space the app is using.
     * This space is used in some APIs instead of adding the space to the events system.
    */
    space: string;
    /**
     * The currently used environment for all store calls.
     * This can be changed via the `Events.Global.setEnv()`
     */
    globalEnvironment?: IConfigEnvironment;
    /**
     * Initialized with the `globalEnvironment`.
     * The store with initialized SDK for the global environment
     */
    store?: HttpStore;
    filesChannel: BroadcastChannel;
    mediaChannel: BroadcastChannel;
    spacesChannel: BroadcastChannel;
    trashChannel: BroadcastChannel;
    historyChannel: BroadcastChannel;
    projectExeChannel: BroadcastChannel;
    initialized: boolean;
    initializeStore(): Promise<void>;
    initialize(): Promise<void>;
    abstract environment: EnvironmentSettings;
    auth: StoreAuthentication;
    global: {
        /**
         * Sets the store environment to be used globally by the application.
         * This initializes the store with the configuration.
         *
         * Note, this won't initialize the session with the store.
         *
         * @param env The environment to set. Note, it must have the `location` set.
         */
        set: (env: IConfigEnvironment) => Promise<void>;
        get: () => Promise<IConfigEnvironment>;
    };
    protected handleInitializeEnvironment(input: Event): void;
    protected handleStoreInfo(input: Event): void;
    protected storeAuthHandler(input: Event): void;
    protected storeIsAuthenticatedHandler(input: Event): void;
    protected setGlobalEnvHandler(input: Event): void;
    protected getGlobalEnvHandler(input: Event): void;
    protected getTokenHandler(input: Event): void;
    protected handleFileList(event: CustomEvent<{
        kinds?: ListFileKind[];
        options?: ContextListOptions;
        result: Promise<ContextListResult<IFile>>;
    }>): void;
    protected handleSharedFileList(event: CustomEvent<{
        kinds?: ListFileKind[];
        options?: ContextListOptions;
        result: Promise<ContextListResult<IFile>>;
    }>): void;
    protected handleFileCreate(event: CustomEvent<{
        meta: IFile;
        media?: unknown;
        opts?: IFileCreateOptions;
        result: Promise<ContextChangeRecord<IFile>>;
    }>): void;
    protected fileCreateDefaultHandler(input: Event): void;
    protected handleFileRead(event: CustomEvent<{
        key: string;
        media: boolean;
        result: Promise<IFile | unknown>;
    }>): void;
    protected handleFilePatch(event: CustomEvent<{
        key: string;
        id: string;
        value: Patch.JsonPatch;
        app: IApplication;
        media?: boolean;
        result: Promise<IPatchRevision>;
    }>): void;
    protected handleFileDelete(event: CustomEvent<{
        key: string;
        result: Promise<string>;
    }>): void;
    protected handleFilePatchUser(event: CustomEvent<{
        key: string;
        id: string;
        value: AccessOperation[];
        app: IApplication;
        result: Promise<void>;
    }>): void;
    protected handleListFileUsers(event: CustomEvent<{
        key: string;
        result: Promise<ContextListResult<IUser>>;
    }>): void;
    protected handleFileBreadcrumbs(event: CustomEvent<{
        key: string;
        result: Promise<ContextListResult<FileBreadcrumb>>;
    }>): void;
    protected handlerMe(input: Event): void;
    protected handleUsersList(input: Event): void;
    protected handleUserRead(input: Event): void;
    protected handleHistoryCreate(input: Event): void;
    protected handleHistoryCreateBulk(input: Event): void;
    protected handleHistoryDelete(input: Event): void;
    protected handleHistoryList(input: Event): void;
    protected handleHistoryRead(input: Event): void;
    protected handleHistoryDeleteBulk(event: ContextDeleteBulkEvent): void;
    protected handleHistoryClearSpace(event: CustomEvent<{
        result: Promise<void>;
        space: string;
    }>): void;
    protected handleHistoryClearProject(event: CustomEvent<{
        result: Promise<void>;
        space: string;
        project: string;
    }>): void;
    protected handleHistoryClearRequest(event: CustomEvent<{
        result: Promise<void>;
        space: string;
        project: string;
        request: string;
    }>): void;
    deleteHistory(key: string): Promise<ContextDeleteRecord>;
    protected handleAddProjectExecution(event: CustomEvent<{
        item: IProjectExecution;
        result: Promise<ContextChangeRecord<IProjectExecution>>;
    }>): void;
    protected handleProjectExecutionRead(event: CustomEvent<{
        key: string;
        result: Promise<IProjectExecution>;
    }>): void;
    protected handleProjectExecutionList(event: CustomEvent<{
        options: IProjectExecutionListOptions;
        result: Promise<ContextListResult<IProjectExecution>>;
    }>): void;
    protected handleProjectExecutionDelete(event: CustomEvent<{
        key: string;
        result: Promise<void>;
    }>): void;
    protected handleProjectExecutionDeleteBulk(event: ContextDeleteBulkEvent): void;
    protected handleProjectExecutionClearSpace(event: CustomEvent<{
        space: string;
        result: Promise<void>;
    }>): void;
    protected handleProjectExecutionClearProject(event: CustomEvent<{
        space: string;
        project: string;
        result: Promise<void>;
    }>): void;
    protected handleProjectExecutionClearFolder(event: CustomEvent<{
        space: string;
        project: string;
        folder: string;
        result: Promise<void>;
    }>): void;
    /**
     * A logic that creates an empty (default) file from its name and the file kind.
     *
     * @param name The name of the file.
     * @param kind The kind of the file.
     * @param opts Optional create options
     * @returns The key of the created file.
     */
    createDefaultFile(space: string, name: string, kind: string, opts?: IFileCreateOptions): Promise<ContextChangeRecord<IFile>>;
    /**
     * Creates a default HttpProject from a name
     *
     * @param name The name of the project
     * @param opts Create options.
     * @returns The key of the created file.
     */
    createDefaultProject(space: string, name: string, opts?: IFileCreateOptions): Promise<ContextChangeRecord<IFile>>;
    /**
     * Creates a default DataNamespace from a name
     *
     * @param name The name of the DataNamespace
     * @param opts Create options.
     * @returns The key of the created file.
     */
    createDefaultDataNamespace(space: string, name: string, opts?: IFileCreateOptions): Promise<ContextChangeRecord<IFile>>;
    /**
     * Creates a default Folder from a name
     *
     * @param name The name of the space
     * @param opts Create options.
     * @returns The key of the created file.
     */
    createDefaultFolder(space: string, name: string, opts?: IFileCreateOptions): Promise<ContextChangeRecord<IFile>>;
    getStore(): HttpStore;
    spaces: {
        list: (options?: ContextListOptions) => Promise<ContextListResult<ISpace>>;
        add: (nameOrObject: string | ISpace) => Promise<ContextChangeRecord<ISpace>>;
        read: (key: string) => Promise<ISpace>;
        delete: (key: string) => Promise<ContextDeleteRecord>;
        addUser: (space: string, otherUserKey: string, role: PermissionRole, expires?: number) => Promise<void>;
        removeUser: (space: string, otherUserKey: string) => Promise<void>;
        patchUsers: (space: string, value: IAccessPatchInfo) => Promise<void>;
    };
    trash: {
        add: (entry: TrashEntryCreate, space: string) => Promise<ContextChangeRecord<TrashEntry>>;
        list: (options: ContextSpaceListOptions) => Promise<ContextListResult<TrashEntry>>;
        delete: (key: string) => Promise<ContextDeleteRecord>;
        batchDelete: (keys: string[]) => Promise<IBulkOperationResult<ContextDeleteRecord>>;
        restore: (key: string) => Promise<ContextChangeRecord<IFile>>;
        batchRestore: (keys: string[]) => Promise<IBulkOperationResult<ContextChangeRecord<IFile>>>;
        empty: (space: string) => Promise<void>;
    };
    revisions: {
        list: (key: string, options: ContextSpaceListOptions) => Promise<ContextListResult<IRevision>>;
    };
    media: {
        add: (key: string, contents: unknown, mime: string) => Promise<void>;
        read: (key: string) => Promise<unknown>;
        patch: (key: string, info: IPatchInfo) => Promise<IPatchRevision>;
    };
    files: {
        list: (options: ContextListOptions, kinds?: ListFileKind[]) => Promise<ContextListResult<IFile>>;
        add: (input: IFile, opts?: FileAddOptions) => Promise<ContextChangeRecord<IFile>>;
        read: (key: string) => Promise<IFile>;
        readBulk: (keys: string[]) => Promise<IBulkOperationResult<IFile>>;
        delete: (key: string) => Promise<string>;
        patch: (key: string, info: IPatchInfo) => Promise<IPatchRevision>;
        breadcrumbs: (key: string) => Promise<ContextListResult<FileBreadcrumb>>;
    };
    shared: {
        list: (options: ContextListOptions, kinds?: ListFileKind[]) => Promise<ContextListResult<IFile>>;
    };
    users: {
        list: (options?: ContextListOptions) => Promise<ContextListResult<IUser>>;
        me: () => Promise<IUser>;
        read: (key: string) => Promise<IUser>;
    };
    observeSpaces(): Promise<void>;
    unobserveSpaces(): Promise<void>;
    observeFiles(): Promise<void>;
    unobserveFiles(): Promise<void>;
    observeFile(key: string, alt?: 'media' | 'meta'): Promise<void>;
    unobserveFile(key: string, alt?: 'media' | 'meta'): Promise<void>;
    observeHistory(): Promise<void>;
    unobserveHistory(): Promise<void>;
    observeProjectExecutions(): Promise<void>;
    unobserveProjectExecutions(): Promise<void>;
    observeTrash(): Promise<void>;
    unobserveTrash(): Promise<void>;
    sendSocket(ws: WebSocket, command: unknown): Promise<void>;
    protected observePath(path: string): Promise<void>;
    protected unobservePath(path: string): Promise<void>;
    eventsSocket?: WebSocket;
    getEventsSocket(): Promise<WebSocket>;
    closeEventsSocket(): Promise<void>;
    protected storeEventHandler(e: MessageEvent): void;
}
export {};
//# sourceMappingURL=StoreBindings.d.ts.map