import { IPublicTypeI18nMap, IPublicTypeUtilsMap, IPublicTypeContainerSchema, IPublicTypeJSONObject, IPublicTypeNodeSchema, IPublicTypeCompositeValue, IPublicTypeJSExpression, IPublicTypeJSFunction, IPublicTypeCompositeObject, InterpretDataSource } from '@alilc/lowcode-types';
import { IDependency, INpmPackage } from './deps';
import { ICompAnalyzeResult } from './analyze';
import { DataSourcePageHelperType } from './datasource-page-helper';
export interface IParseResult {
    containers: IContainerInfo[];
    globalUtils?: IUtilInfo;
    globalI18n?: IPublicTypeI18nMap;
    globalRouter?: IRouterInfo;
    project?: IProjectInfo;
}
export interface IWithDependency {
    deps?: IDependency[];
}
export interface IContainerInfo extends IPublicTypeContainerSchema, IWithDependency {
    containerType: string;
    moduleName: string;
    analyzeResult?: ICompAnalyzeResult;
}
export interface IUtilInfo extends IWithDependency {
    utils: IPublicTypeUtilsMap;
}
export interface RouterInfoItem {
    path: string;
    fileName: string;
    componentName: string;
    isFormRouter?: boolean;
    firstPage: 'true' | 'false';
    title: string;
}
export interface IRouterInfo extends IWithDependency {
    routes: Array<RouterInfoItem>;
}
export interface IFormInfo extends IPublicTypeFormContainerSchema, IWithDependency {
    containerType: string;
    moduleName: string;
    analyzeResult?: ICompAnalyzeResult;
}
/**
 * project's remarks
 */
export interface ProjectRemark {
    /** if current project only contain one container which type is `Component` */
    isSingleComponent?: boolean;
}
export interface IProjectInfo {
    css?: string;
    containersDeps?: IDependency[];
    utilsDeps?: IDependency[];
    constants?: IPublicTypeJSONObject;
    i18n?: IPublicTypeI18nMap;
    packages: INpmPackage[];
    meta?: {
        name?: string;
        title?: string;
    } | Record<string, any>;
    config?: Record<string, any>;
    dataSourcesTypes?: string[];
    projectRemark?: ProjectRemark;
}
export interface IPageMeta {
    router?: string;
}
/**
 * From meta
 * page title
 * router
 * spmb
 *
 * Utils
 *
 * constants
 *
 * i18n
 *
 * components
 *
 * pages
 *
 * layout
 */
/**
 * 容器结构描述
 */
export interface IPublicTypeFormContainerSchema extends IPublicTypeNodeSchema {
    /**
     * 'Block' | 'Page' | 'Component';
     */
    componentName: string;
    /**
     * 文件名称
     */
    fileName: string;
    /**
     * @todo 待文档定义
     */
    meta?: Record<string, unknown>;
    /**
     * 容器初始数据
     */
    state?: {
        [key: string]: IPublicTypeCompositeValue;
    };
    /**
     * 自定义方法设置
     */
    methods?: {
        [key: string]: IPublicTypeJSExpression | IPublicTypeJSFunction;
    };
    /**
     * 生命周期对象
     */
    lifeCycles?: {
        [key: string]: IPublicTypeJSExpression | IPublicTypeJSFunction;
    };
    /**
     * 样式文件
     */
    css?: string;
    /**
     * 异步数据源配置
     */
    dataSource?: ExtraInterpretDataSource;
    /**
     * 低代码业务组件默认属性
     */
    defaultProps?: IPublicTypeCompositeObject;
}
export type TypeDataSourceType = 'dynamicForm' | 'dataDictionary' | 'dynamicFormCache' | 'dynamicFormDetail' | 'dataLoginUserInfo' | 'listSelectUser' | 'listSelectDept' | 'listSelectOrg' | 'formPage';
/**
 * 自定义的额外信息
 */
export interface DataSourceCustomExtra {
    /**
     * 数据源类型（动态表单、数据字典、页面缓存）
     */
    dataSourceType: TypeDataSourceType;
    /**
     * 当前的组件id
     */
    componentId: string;
    /**
     * 使用的组件id（使用缓存数据的时候会用到）
     */
    usedComponentId?: string;
    /**
     * 数据源id（数据字典code、动态表单id）
     */
    id: string;
    /**
     * 数据源code（数据字典code、动态表单code）
     */
    code: string;
    /**
     * 用于存储属性和绑定字段对应关系
     */
    columnToAttribute: Record<string, any>;
    /**
     * 排序列
     */
    extraSortList?: DataSourceCustomOrderItem[];
    /**
     * 额外参数列表
     */
    extraParamList?: DataSourceExtraParams[];
    /**
     * 分页信息
     */
    pageHelperInfo?: DataSourcePageHelperType;
    /**
     * 是否需要将数据缓存
     */
    isOpenCache?: boolean;
    /**
     * 详情数据源配置面板
     */
    configItemVariable?: ConfigItemVariableReturnType;
}
/**
 * 数据源类型
 */
export interface ExtraInterpretDataSource extends InterpretDataSource {
    extra: Record<string, DataSourceCustomExtra>;
}
export type TypeCustomOrder = 'desc' | 'asc';
/**
 * 排序列
 */
export interface DataSourceCustomOrderItem {
    /**
     * 排序的id
     */
    key: string;
    /**
     * 排序的id
     */
    id?: string;
    /**
     * 排序的值
     */
    order: TypeCustomOrder;
}
/**
 * 额外字段
 */
export interface DataSourceExtraParams {
    /**
     * 排序的id
     */
    key: string;
    /**
     * 额外参数的id
     */
    id?: string;
    /**
     * 默认值
     */
    value?: string;
}
export type TypeDataFrom = 'query' | 'cookie' | 'local-storage' | 'session-storage';
export interface ConfigItemVariableReturnType {
    /**
     * 数据值来源
     */
    dataFrom: TypeDataFrom;
    /**
     * 数据值字段名称
     */
    dataField: string;
    /**
     * 数据默认值
     */
    defaultValue?: string;
}
