/**
 * This file is part of the NocoBase (R) project.
 * Copyright (c) 2020-2024 NocoBase Co., Ltd.
 * Authors: NocoBase Team.
 *
 * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
 * For more information, please refer to: https://www.nocobase.com/agreement.
 */
import { SchemaKey } from '@formily/react';
import type { CollectionManager } from './CollectionManager';
type dumpable = 'required' | 'optional' | 'skip';
type CollectionSortable = string | boolean | {
    name?: string;
    scopeKey?: string;
};
export interface CollectionFieldOptions {
    name?: any;
    collectionName?: string;
    sourceKey?: string;
    uiSchema?: any;
    target?: string;
    [key: string]: any;
}
export interface CollectionOptions {
    name: string;
    title?: string;
    dataSource?: string;
    /**
     * Used for @nocobase/plugin-duplicator
     * @see packages/core/database/src/collection-group-manager.tss
     *
     * @prop {'required' | 'optional' | 'skip'} dumpable - Determine whether the collection is dumped
     * @prop {string[] | string} [with] - Collections dumped with this collection
     * @prop {any} [delayRestore] - A function to execute after all collections are restored
     */
    duplicator?: dumpable | {
        dumpable: dumpable;
        with?: string[] | string;
        delayRestore?: any;
    };
    tableName?: string;
    inherits?: string[] | string;
    inherit?: string;
    key?: string;
    viewName?: string;
    writableView?: boolean;
    filterTargetKey?: string;
    fields?: CollectionFieldOptions[];
    model?: any;
    repository?: any;
    sortable?: CollectionSortable;
    /**
     * @default true
     */
    autoGenId?: boolean;
    /**
     * @default 'options'
     */
    magicAttribute?: string;
    tree?: string;
    template?: string;
    isThrough?: boolean;
    autoCreate?: boolean;
    resource?: string;
    collectionName?: string;
    sourceKey?: string;
    uiSchema?: any;
    [key: string]: any;
}
export type GetCollectionFieldPredicate = ((collection: CollectionFieldOptions) => boolean) | CollectionFieldOptions | keyof CollectionFieldOptions;
export declare class Collection {
    protected options: CollectionOptions;
    collectionManager: CollectionManager;
    protected fieldsMap: Record<string, CollectionFieldOptions>;
    protected primaryKey: string;
    constructor(options: CollectionOptions, collectionManager: CollectionManager);
    get fields(): CollectionFieldOptions[];
    get app(): import("../..").Application;
    get dataSource(): string;
    get sourceKey(): string;
    get name(): string;
    get key(): string;
    get title(): string;
    get inherit(): string;
    get hidden(): any;
    get description(): any;
    get duplicator(): dumpable | {
        dumpable: dumpable;
        with?: string | string[];
        delayRestore?: any;
    };
    get category(): any;
    get targetKey(): any;
    get model(): any;
    get createdBy(): any;
    get updatedBy(): any;
    get logging(): any;
    get from(): any;
    get rawTitle(): any;
    getPrimaryKey(): string;
    getFilterTargetKey(): string;
    get inherits(): string | string[];
    get titleField(): any;
    get sources(): any;
    get template(): string;
    get tableName(): string;
    get viewName(): string;
    get writableView(): boolean;
    get filterTargetKey(): string;
    get sortable(): CollectionSortable;
    get autoGenId(): boolean;
    get magicAttribute(): string;
    get tree(): string;
    get isThrough(): boolean;
    get autoCreate(): boolean;
    get resource(): string;
    setOption(key: string, value: any): this;
    getOptions(): CollectionOptions;
    getOption<K extends keyof CollectionOptions>(key: K): CollectionOptions[K];
    /**
     * Get fields
     * @param predicate https://www.lodashjs.com/docs/lodash.filter
     * @example
     * getFields() // get all fields
     * getFields({ name: 'nickname' }) // Get the field with `name: 'nickname'`
     * getFields('primaryKey') // Get the field with `primaryKey: true`
     * getFields((field) => field.name === 'nickname') // Get the field with `name: 'nickname`'
     */
    getFields(predicate?: GetCollectionFieldPredicate): CollectionFieldOptions[];
    getAllFields(predicate?: GetCollectionFieldPredicate): CollectionFieldOptions[];
    protected getFieldsMap(): Record<string, CollectionFieldOptions>;
    private getFieldByAssociationName;
    getField(name: SchemaKey): any;
    hasField(name: SchemaKey): boolean;
    isTitleField(field: CollectionFieldOptions): boolean;
    /**
     * is inherited from other collections
     * @returns boolean
     */
    isInherited(): boolean;
}
export {};
