import type { Schema } from 'amis-core';
import type { RendererInfo } from 'amis-editor';
import { Manager } from '../base/Manager';
import { ModelStore } from '../base/ModelStore';
import { ApiStrategyInterface } from './ApiStrategyInterface';
import { SharedContext } from './SharedContext';
import type { EditorPanel } from '../component/SchemaBuilderEditor';
import type { FieldItem, ModelItem, ExtraField, FeatType, ModelEntityApiSchema } from '../type';
export interface EditorView {
    label: string;
    value: string;
}
export interface SchemaBuilderInterface<T = any> {
    readonly manager: Manager;
    readonly model: ModelItem;
    readonly modelStore: ModelStore;
    readonly apiStrategy: ApiStrategyInterface;
    readonly sharedContext: SharedContext;
    makeDefaultOptions: (behavior?: string) => T | Promise<T>;
    guessOptionsFromSchema?: (schema: any, behavior?: string) => T;
    build: (options?: T, schema?: any, sharedContext?: SharedContext) => Promise<Schema> | Schema;
    dispose: () => void;
    /**
     * 从生成好的 schema 里面，猜测字段的配置项
     */
    guessFieldOptionsFromSchema?: (field: FieldItem, schema: any, region?: '') => any;
    /**
     * 构建字段的配置面板
     * @param field
     * @param options
     * @returns
     */
    buildFieldSettingForm?: (field: FieldItem, options?: any) => any;
    /**
     * 基于配置项构建字段的 amis schema
     * @param field
     * @param options
     * @returns
     */
    makeFieldSchema?: (field: FieldItem, options?: any, originSchema?: any) => any;
    /**
     * 设置成追踪模式，可以根据 schema 追踪出来是哪个场景的哪个字段
     * @param value
     * @returns
     */
    setTraceMode: (value: boolean) => void;
    /**
     * 根据值知道当前配置有哪些编辑器视图
     * 比如：列表视图，新增视图，编辑视图等等
     * @param options
     * @returns
     */
    getEditorViews?: (options: T) => Array<EditorView>;
    /**
     * 构建部分视图，给
     * @param options
     * @param editorView
     * @returns
     */
    buildPartialView?: (options: T, editorView: string) => Promise<Schema> | Schema;
    /**
     * 根据 traceId 构建配置面板
     * @param traceId
     * @param editorView
     * @returns
     */
    buildEditorPanel?: (options: T, traceId: string, editorView: string) => Promise<void | undefined | EditorPanel | EditorPanel[]>;
    /**
     * 干预 amis editor 里面的 node 配置，让其表现不一样
     * @param traceId
     * @param info
     * @returns
     */
    overrideAMISEditorNodeInfo?: (options: T, traceId: string, info: RendererInfo, editorView: string) => void;
    getDataByTraceId?: (options: T, traceId: string) => any;
    setDataByTraceId?: (options: T, traceId: string, value: any) => any;
    /**
     * 拖入字段
     * @param options 配置信息
     * @param field 字段信息
     * @param hostTraceId 拖入的父级 trceId
     * @param beforeTraceId 拖入的位置信息
     * @returns
     */
    insertField?: (options: T, field: FieldItem, hostTraceId: string, region: string, beforeTraceId?: string) => any;
    /**
     * 删除字段
     * @param options
     * @param traceId
     * @param hostTraceId
     * @returns
     */
    deleteField?: (options: T, traceId: string, hostTraceId: string) => any;
    /**
     * 移动字段
     * @param options
     * @param hostTraceId
     * @param sourceTraceId
     * @param beforeTraceId
     * @returns
     */
    moveField?: (options: T, hostTraceId: string, sourceTraceId: string, beforeTraceId?: string) => any;
    /**
     * 模型组件脚手架表单生成
     * @param options
     * @param schema
     * @returns
     */
    genScaffoldForm?: () => Promise<Array<any>>;
    /**
     * 模型右侧编辑面板表单生成
     * @param options
     * @param schema
     * @returns
     */
    genPanelForm?: (options: T, schema: any) => Promise<Array<any>>;
    /**
     * 模型字段右侧编辑面板构建
     * @param options
     * @param schema
     * @returns
     */
    genFieldPanelForm?: (options: T, field: FieldItem, region?: string, schema?: any) => Promise<Array<any>>;
    /**
     * 过滤配置
     * @param options
     * @returns
     */
    buildFieldSchema?: (options: T, field: FieldItem, fieldOptions: any, region: string, schema: any) => any;
}
/**
 * 可编辑节点相关配置
 */
export interface SchemaBuilderNode<T = any> {
    key?: string;
    /**
     * 决定要不要使用这个面板
     *
     * @param ns
     * @param id
     * @returns
     */
    test: (ns: string, id?: string) => any;
    /**
     * 编辑器点选的时候，配置这个点选节点的属性
     * 比如：是否可以接收拖入节点，是否可被删除等等
     *
     * @param options
     * @param info
     * @returns
     */
    overrideEditorNodeInfo?: (info: RendererInfo, options: T, id?: string) => void;
    /**
     * 构建面板表单
     * @param options
     * @returns
     */
    buildForm: (builder: BaseSchemaBuilder, options: T, id?: string) => Promise<Omit<EditorPanel, 'traceId'>> | Omit<EditorPanel, 'traceId'>;
    /**
     * 获取面板数据
     * @param options
     * @returns
     */
    getData?: (options: T, id?: string) => any;
    /**
     * 设置面板数据
     * @param options
     * @param values
     * @returns
     */
    setData?: (options: T, values: any, id?: string) => T;
    /**
     * 这个节点下面插入元素的时候调用
     * @param options
     * @param child
     * @param beforeTraceId
     * @returns
     */
    insert?: (options: T, child: any, beforeTraceId?: string) => T | void;
    /**
     * 这个节点下面移动元素的时候调用
     * @param options
     * @param sourceId
     * @param beforeTraceId
     * @returns
     */
    moveChild?: (options: T, sourceId: string, beforeTraceId?: string) => T | void;
    /**
     * 这个节点移除元素的时候调用
     * @param options
     * @param id
     * @returns
     */
    removeChild?: (options: T, id: string) => T | void;
}
export declare abstract class BaseSchemaBuilder<T = any> implements SchemaBuilderInterface<T> {
    readonly model: ModelItem;
    readonly apiStrategy: ApiStrategyInterface;
    readonly manager: Manager;
    readonly sharedContext: SharedContext;
    readonly modelStore: ModelStore;
    isTraceMode: boolean;
    readonly nodes: Array<SchemaBuilderNode<T>>;
    /** 已注册字段类型映射集合 */
    fieldTypeMap: Record<string, string>;
    constructor(model: ModelItem, apiStrategy: ApiStrategyInterface, manager: Manager, sharedContext: SharedContext);
    makeDefaultOptions(behavior?: string | string[]): T | Promise<T>;
    build(options?: T, schema?: Schema): Schema | Promise<Schema>;
    dispose(): void;
    initEditor(): void;
    /**
     * 开启后生成 schema 的时候会打标记。
     * 根据标记让编辑器
     * @param value
     */
    setTraceMode(value: boolean): void;
    /**
     * 返回 [namespace, id]
     * @param id
     * @returns
     */
    parseTraceId(id?: string): string[];
    /**
     * 干预 amis editor 里面的 node 配置，让其表现不一样
     * @param traceId
     * @param info
     * @returns
     */
    overrideAMISEditorNodeInfo(options: T, traceId: string, info: RendererInfo, editorView: string): void;
    /**
     * 根据 traceId 构建配置面板
     * @param traceId
     * @param editorView
     * @returns
     */
    buildEditorPanel(options: T, traceId: string, editorView: string): Promise<void | undefined | EditorPanel | EditorPanel[]>;
    /**
     * 根据 traceId 获取面板配置数据
     */
    getDataByTraceId(options: T, traceId: string): any;
    /**
     * 根据 traceId 设置面板配置数据
     */
    setDataByTraceId(options: T, traceId: string, values: any): any;
    insertField(options: T, field: FieldItem, hostTraceId: string, region: string, beforeTraceId?: string): any;
    deleteField(options: T, traceId: string): any;
    moveField(options: T, hostTraceId: string, sourceTraceId: string, beforeTraceId?: string): any;
    getFilterableFields(): Promise<{
        data: any;
        simple: any;
        advanced: any;
    }[]>;
    /**
     * -----------------------
     * 前端脚手架构建使用
     * -----------------------
     */
    /** 初始化注册的字段类型 */
    getFeildTypeMap(): {
        /** 补充一下关系字段具体名称 */
        '1:1': string;
        '1:n': string;
        'n:1': string;
        'n:n': string;
    };
    /** 获取字段类型名称 */
    getTypeLabel(field: ExtraField): string;
    /** 获取可以使用的字段集合 */
    getAvailableFields(model: ModelStore, config?: {
        defaultChecked?: boolean;
        /** 是否返回ConditionBuilder的相关信息 */
        enableCB?: boolean;
        feat?: FeatType;
    }): Promise<ExtraField[]>;
    /** 给API Schema添加一些公共属性 */
    getApiSBaseSchema(model: ModelStore, feat: FeatType, fields?: ExtraField[]): ModelEntityApiSchema;
}
export interface SchemaBuilderClass {
    new (model: ModelItem, apiStrategy: ApiStrategyInterface, manager: Manager, sharedContext?: SharedContext): SchemaBuilderInterface;
    id: string;
}
export declare function registerBuilder(factory: SchemaBuilderClass): void;
export declare function makeSchemaBuilder(manager: Manager, model: ModelItem | string, apiStrategy: ApiStrategyInterface, kind: string, sharedContext?: SharedContext): SchemaBuilderInterface<any>;
