import { analyzer } from '@antv/data-wizard'; import type { LevelOfMeasurement as LOM } from '@antv/ckb'; import type { Specification } from '../types'; /** * Type of different rules. * * @public */ export declare type RuleType = 'HARD' | 'SOFT' | 'DESIGN'; /** * this minimum subset of pipeline/DataProperty, make pipeline can start with step2(dataPropsToAdvice) * @public */ export interface BasicDataPropertyForAdvice { /** field name */ readonly name?: string; /** LOM */ readonly levelOfMeasurements?: LOM[]; /** used for split column xy series */ readonly rawData: any[]; /** required types in analyzer FieldInfo */ readonly recommendation: analyzer.FieldInfo['recommendation']; readonly type: analyzer.FieldInfo['type']; readonly distinct?: number; readonly count?: number; readonly sum?: number; readonly maximum?: any; readonly minimum?: any; readonly missing?: number; [key: string]: any; } /** * 偏好选项 * @public */ export interface Preferences { canvasLayout: 'landscape' | 'portrait'; } /** * @public */ export interface Info { chartType?: string; dataProps: BasicDataPropertyForAdvice[] | BasicDataPropertyForAdvice | Partial; purpose?: string; preferences?: Preferences; customWeight?: number; [key: string]: any; } /** * @public */ export declare type Validator = (args: Info) => number | boolean; export declare type Trigger = (args: Info) => boolean; export declare type Optimizer = (dataProps: BasicDataPropertyForAdvice[] | BasicDataPropertyForAdvice | Partial, chartSpec: Specification) => object; /** * @public */ export interface ChartRuleConfig { /** * customized weight for the rule */ weight?: number; /** * whether to ignore the rule */ off?: boolean; /** * user customized parameters of Validator */ extra?: Record; } /** * @public */ export declare type ChartRuleConfigMap = Record; /** * @public */ export declare type Docs = { lintText?: string; detailedText?: string; moreLink?: string; [key: string]: any; }; declare type DefaultRuleModule = { id: string; docs: Docs; trigger: Trigger; option?: ChartRuleConfig; }; export declare type ChartRuleModule = DefaultRuleModule & { type: 'HARD' | 'SOFT'; validator: Validator; }; export declare type DesignRuleModule = DefaultRuleModule & { type: 'DESIGN'; optimizer: Optimizer; }; export declare type RuleModule = ChartRuleModule | DesignRuleModule; /** * rule config * * @public */ export declare type RuleConfig = { /** * include: should contain standard ChartRuleID, or any string id for custom rule. */ include?: string[]; /** * exclude: should contain standard ChartRuleID, or any string id for custom rule. */ exclude?: string[]; /** * customized rule instance */ custom?: Record; /** * config for rules */ options?: ChartRuleConfigMap; }; export {};