/**
 * Copyright (c) OpenLens Maintainers. All rights reserved.
 * Licensed under MIT License. See LICENSE in root directory for more information.
 */
import type { Disposer } from "@openlens/utilities";
import type { KubeJsonApiDataFor, KubeObject } from "@openlens/kube-object";
import type { IKubeWatchEvent } from "./kube-watch-event";
import { ItemStore } from "../item.store";
import type { KubeApiQueryParams, KubeApi } from "./kube-api";
import type { RequestInit } from "@openlens/node-fetch";
import type { Patch } from "rfc6902";
import type { Logger } from "@openlens/logger";
import type { PartialDeep } from "type-fest";
import type { ClusterContext } from "../../renderer/cluster-frame-context/cluster-frame-context";
export type OnLoadFailure = (error: unknown) => void;
export interface KubeObjectStoreLoadingParams {
    namespaces: string[];
    reqInit?: RequestInit;
    /**
     * A function that is called when listing fails. If set then blocks errors
     * being rejected with
     */
    onLoadFailure?: OnLoadFailure;
}
export interface KubeObjectStoreLoadAllParams {
    namespaces?: string[];
    merge?: boolean;
    reqInit?: RequestInit;
    /**
     * A function that is called when listing fails. If set then blocks errors
     * being rejected with
     */
    onLoadFailure?: OnLoadFailure;
}
export interface KubeObjectStoreSubscribeParams {
    /**
     * A function that is called when listing fails. If set then blocks errors
     * being rejected with
     */
    onLoadFailure?: OnLoadFailure;
    /**
     * An optional parent abort controller
     */
    abortController?: AbortController;
}
export interface MergeItemsOptions {
    merge?: boolean;
    updateStore?: boolean;
    sort?: boolean;
    filter?: boolean;
    namespaces: string[];
}
export interface StatusProvider<K> {
    getStatuses(items: K[]): Record<string, number>;
}
export interface KubeObjectStoreOptions {
    limit?: number;
    bufferSize?: number;
}
export type KubeApiDataFrom<K extends KubeObject, A> = A extends KubeApi<K, infer D> ? D extends KubeJsonApiDataFor<K> ? D : never : never;
export type JsonPatch = Patch;
export interface KubeObjectStoreDependencies {
    readonly context: ClusterContext;
    readonly logger: Logger;
}
export declare class KubeObjectStore<K extends KubeObject = KubeObject, A extends KubeApi<K, D> = KubeApi<K, KubeJsonApiDataFor<K>>, D extends KubeJsonApiDataFor<K> = KubeApiDataFrom<K, A>> extends ItemStore<K> {
    protected readonly dependencies: KubeObjectStoreDependencies;
    readonly api: A;
    readonly limit: number | undefined;
    readonly bufferSize: number;
    private readonly loadedNamespaces;
    constructor(dependencies: KubeObjectStoreDependencies, api: A, opts?: KubeObjectStoreOptions);
    get contextItems(): K[];
    getTotalCount(): number;
    get query(): KubeApiQueryParams;
    getAllByNs(namespace: string | string[], strict?: boolean): K[];
    getById(id: string): K | undefined;
    getByName(name: string, namespace?: string): K | undefined;
    getByPath(path: string): K | undefined;
    getByLabel(labels: string[] | Partial<Record<string, string>>): K[];
    protected loadItems({ namespaces, reqInit, onLoadFailure }: KubeObjectStoreLoadingParams): Promise<K[]>;
    protected filterItemsOnLoad(items: K[]): K[];
    loadAll({ namespaces, merge, reqInit, onLoadFailure }?: KubeObjectStoreLoadAllParams): Promise<undefined | K[]>;
    reloadAll(opts?: {
        force?: boolean;
        namespaces?: string[];
        merge?: boolean;
    }): Promise<undefined | K[]>;
    protected mergeItems(partialItems: K[], { merge, updateStore, sort, filter, namespaces }: MergeItemsOptions): K[];
    protected resetOnError(error: any): void;
    protected loadItem(params: {
        name: string;
        namespace?: string;
    }): Promise<K | null>;
    load(params: {
        name: string;
        namespace?: string;
    }): Promise<K>;
    loadFromPath(resourcePath: string): Promise<K>;
    protected createItem(params: {
        name: string;
        namespace?: string;
    }, data?: PartialDeep<K>): Promise<K | null>;
    create(params: {
        name: string;
        namespace?: string;
    }, data?: PartialDeep<K>): Promise<K>;
    private postUpdate;
    patch(item: K, patch: JsonPatch): Promise<K>;
    update(item: K, data: PartialDeep<K>): Promise<K>;
    remove(item: K): Promise<void>;
    removeSelectedItems(): Promise<void>;
    removeItems(items: K[]): Promise<void>;
    protected readonly eventsBuffer: import("mobx").IObservableArray<IKubeWatchEvent<D>>;
    protected bindWatchEventsUpdater(delay?: number): void;
    subscribe({ onLoadFailure, abortController }?: KubeObjectStoreSubscribeParams): Disposer;
    private watchNamespace;
    protected updateFromEventsBuffer(): void;
}
