import { DeepClient } from './client.js';
import { Id, Link, MinilinksResult } from './minilinks.js';
export interface PackageIdentifier {
    name?: string;
    version?: string;
    uri?: string;
    type?: string;
    options?: any;
}
export interface Package {
    package?: PackageIdentifier;
    data?: Array<PackageItem>;
    dependencies?: Array<PackageIdentifier>;
    strict?: boolean;
    errors?: PackagerError[];
}
export interface PackageItem {
    id: Id | string;
    type?: Id | string;
    from?: Id | string;
    to?: Id | string;
    value?: PackagerValue;
    alias?: Id;
    package?: {
        dependencyId: Id;
        containValue: string;
    };
    _?: boolean;
    updated?: string[];
}
export interface PackagerValue {
    id?: Id;
    link_id?: Id;
    value?: number | string | any;
}
export type PackagerError = any;
export interface PackagerImportResult {
    errors?: PackagerError[];
    ids?: Id[];
    packageId?: Id;
    namespaceId?: Id;
    inserting?: any[];
    updating?: any[];
    pckg?: Package;
}
export type PackagerMutated = {
    [index: number]: boolean;
};
export interface PackagerExportOptions {
    packageLinkId: Id;
}
export interface PackagerLink extends Link<any> {
    value?: any;
}
export declare function sort(pckg: Package, data: any[], errors: PackagerError[], references: {
    id: string;
    from: string;
    to: string;
    type: string;
}): {
    sorted: any[];
};
export declare class Packager<L extends Link<any>> {
    pckg: Package;
    client: DeepClient<any>;
    constructor(client: DeepClient<L>);
    fetchPackageNamespaceId(name: string, deep: DeepClient<Link<Id>>): Promise<{
        error: any;
        namespaceId: Id;
    }>;
    fetchDependenciedLinkId(pckg: Package, dependedLink: PackageItem): Promise<number>;
    insertItem(items: PackageItem[], item: PackageItem, errors: PackagerError[], mutated: PackagerMutated): Promise<void>;
    insertItems(pckg: Package, data: PackageItem[], counter: number, dependedLinks: PackageItem[], errors?: PackagerError[], mutated?: {
        [index: number]: boolean;
    }): Promise<any>;
    updateItems(pckg: Package, _data: PackageItem[], counter: number, dependedLinks: PackageItem[], updating: PackageItem[], inserting: PackageItem[], errors?: PackagerError[], mutated?: {
        [index: number]: boolean;
    }): Promise<any>;
    globalizeIds(pckg: Package, ids: Id[], links: PackageItem[]): Promise<{
        global: PackageItem[];
        difference: {
            [id: Id]: Id;
        };
        updating: PackageItem[];
        inserting: PackageItem[];
    }>;
    validate(pckg: Package, errors: any[]): void;
    import(pckg: Package): Promise<PackagerImportResult>;
    update(packageId: Id, pckg: Package): Promise<{
        errors: any[];
        ids?: undefined;
        namespaceId?: undefined;
        packageId?: undefined;
        updating?: undefined;
        inserting?: undefined;
    } | {
        ids: Id[];
        errors: any[];
        namespaceId: Id;
        packageId: Id;
        updating: PackageItem[];
        inserting: PackageItem[];
    } | {
        ids: any[];
        errors: any[];
        namespaceId?: undefined;
        packageId?: undefined;
        updating?: undefined;
        inserting?: undefined;
    }>;
    selectLinks(options: PackagerExportOptions): Promise<MinilinksResult<PackagerLink>>;
    deserialize(pckg: Package, errors?: PackagerError[]): Promise<{
        data: PackageItem[];
        errors?: PackagerError[];
        counter: number;
        dependedLinks: PackageItem[];
        packageId: Id;
        namespaceId: Id;
    }>;
    serialize(globalLinks: MinilinksResult<PackagerLink>, options: PackagerExportOptions, pckg: Package): Promise<Package>;
    export(options: PackagerExportOptions): Promise<Package>;
}
export declare class Packager2<L extends Link<any>> {
    pckg: Package;
    client: DeepClient<any>;
    constructor(client: DeepClient<L>);
    validate(pckg: Package, errors: any[]): void;
    update(packageId: Id, pckg: Package): Promise<PackagerImportResult>;
    import(pckg: Package): Promise<PackagerImportResult>;
    apply(pckg: Package, _packageId?: Id): Promise<{
        inserting?: any[];
        updating?: any[];
        package?: PackageIdentifier;
        packageId?: Id;
        ids?: Id[];
        errors?: any[];
    }>;
    exec({ pckg, packageId, inserting, updating, insertPackage }: {
        pckg: Package;
        packageId?: Id;
        inserting?: any[];
        updating?: any[];
        insertPackage?: boolean;
    }): Promise<{
        packageId: Id;
        namespaceId: any;
    }>;
    export(options: PackagerExportOptions | Id): Promise<Package>;
}
