import { RefAttr } from "./Demand"; import { Geo } from "./Geo"; export type RefOrExpression = RefAttr | Expression; type MathType = RefOrExpression | number; type StringType = RefOrExpression | string; interface Add { $add: (MathType)[]; } interface Subtract { $subtract: [MathType, MathType]; } interface Multiply { $multiply: (MathType)[]; } interface Divide { $divide: [MathType, MathType]; } interface Abs { $abs: MathType; } interface Round { $round: [MathType, MathType]; } interface Floor { $floor: MathType; } interface Ceil { $ceil: MathType; } interface Pow { $pow: [MathType, MathType]; } interface Mod { $mod: [MathType, MathType]; } type MathExpression = Add | Subtract | Multiply | Divide | Abs | Round | Floor | Ceil | Pow | Mod; type CmpType = RefOrExpression | string | number; interface Gt { $gt: [CmpType, CmpType]; } interface Lt { $lt: [CmpType, CmpType]; } interface Eq { $eq: [CmpType, CmpType]; } interface Gte { $gte: [CmpType, CmpType]; } interface Lte { $lte: [CmpType, CmpType]; } interface Ne { $ne: [CmpType, CmpType]; } interface StartsWith { $startsWith: [RefOrExpression | string, RefOrExpression | string]; } interface EndsWith { $endsWith: [RefOrExpression | string, RefOrExpression | string]; } interface Includes { $includes: [RefOrExpression | string, RefOrExpression | string]; } type CompareExpression = Lt | Gt | Lte | Gte | Eq | Ne | StartsWith | EndsWith | Includes; interface BoolTrue { $true: Expression; } interface BoolFalse { $false: Expression; } type BoolExpression = BoolTrue | BoolFalse; interface LogicAnd { $and: Expression[]; } interface LogicOr { $or: Expression[]; } interface LogicNot { $not: Expression; } type LogicExpression = LogicAnd | LogicOr | LogicNot; interface DateYear { $year: RefOrExpression | Date | number; } interface DateMonth { $month: RefOrExpression | Date | number; } interface DateWeekday { $weekday: RefOrExpression | Date | number; } interface DateWeekOfYear { $weekOfYear: RefOrExpression | Date | number; } interface DateDay { $day: RefOrExpression | Date | number; } interface DateDayOfMonth { $dayOfMonth: RefOrExpression | Date | number; } interface DateDayOfWeek { $dayOfWeek: RefOrExpression | Date | number; } interface DateDayOfYear { $dayOfYear: RefOrExpression | Date | number; } interface DateDiff { $dateDiff: [RefOrExpression | Date | number, RefOrExpression | Date | number, 'y' | 'M' | 'd' | 'h' | 'm' | 's']; } interface DateCeiling { $dateCeil: [RefOrExpression | Date | number, 'y' | 'M' | 'd' | 'h' | 'm' | 's']; } interface DateFloor { $dateFloor: [RefOrExpression | Date | number, 'y' | 'M' | 'd' | 'h' | 'm' | 's']; } type DateExpression = DateYear | DateMonth | DateWeekday | DateWeekOfYear | DateDay | DateDayOfYear | DateDayOfMonth | DateDayOfWeek | DateDiff | DateCeiling | DateFloor; interface StringConcat { $concat: StringType[]; } type StringExpression = StringConcat; interface GeoContains { $contains: [RefOrExpression | Geo, RefOrExpression | Geo]; } interface GeoDistance { $distance: [RefOrExpression | Geo, RefOrExpression | Geo]; } type GeoExpression = GeoContains | GeoDistance; interface AggrCountExpression { $$count: RefOrExpression; } interface AggrSumExpression { $$sum: RefOrExpression; } interface AggrMaxExpression { $$max: RefOrExpression; } interface AggrMinExpression { $$min: RefOrExpression; } interface AggrAvgExpression { $$avg: RefOrExpression; } export type AggrExpression = AggrAvgExpression | AggrCountExpression | AggrSumExpression | AggrMaxExpression | AggrMinExpression; export type Expression = GeoExpression | DateExpression | LogicExpression | BoolExpression | CompareExpression | MathExpression | StringExpression; export type ExpressionConstant = Geo | number | Date | string | boolean; export declare function isGeoExpression(expression: any): expression is GeoExpression; export declare function isDateExpression(expression: any): expression is DateExpression; export declare function isLogicExpression(expression: any): expression is LogicExpression; export declare function isBoolExpression(expression: any): expression is BoolExpression; export declare function isCompareExpression(expression: any): expression is CompareExpression; export declare function isMathExpression(expression: any): expression is MathExpression; export declare function isStringExpression(expression: any): expression is StringExpression; export declare function isAggrExpression(expression: any): expression is AggrExpression; export declare function isExpression(expression: any): expression is Expression; export declare function opMultipleParams(op: string): boolean; export declare function execOp(op: string, params: any): ExpressionConstant; /** * 检查一个表达式,并分析其涉及到的属性 * @param expression * @returns { * '#current': [当前结点涉及的属性] * 'node-1': [node-1结点上涉及的属性] * } */ export declare function getAttrRefInExpression(expression: Expression): Record; export {};