expressions.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. export enum QueryEditorPropertyType {
  2. String = 'string',
  3. }
  4. export interface QueryEditorProperty {
  5. type: QueryEditorPropertyType;
  6. name?: string;
  7. }
  8. export type QueryEditorOperatorType = string | boolean | number;
  9. type QueryEditorOperatorValueType = QueryEditorOperatorType | QueryEditorOperatorType[];
  10. export interface QueryEditorOperator<T extends QueryEditorOperatorValueType> {
  11. name?: string;
  12. value?: T;
  13. }
  14. export interface QueryEditorOperatorExpression {
  15. type: QueryEditorExpressionType.Operator;
  16. property: QueryEditorProperty;
  17. operator: QueryEditorOperator<QueryEditorOperatorValueType>;
  18. }
  19. export interface QueryEditorArrayExpression {
  20. type: QueryEditorExpressionType.And | QueryEditorExpressionType.Or;
  21. expressions: QueryEditorExpression[] | QueryEditorArrayExpression[];
  22. }
  23. export interface QueryEditorPropertyExpression {
  24. type: QueryEditorExpressionType.Property;
  25. property: QueryEditorProperty;
  26. }
  27. export enum QueryEditorExpressionType {
  28. Property = 'property',
  29. Operator = 'operator',
  30. Or = 'or',
  31. And = 'and',
  32. GroupBy = 'groupBy',
  33. Function = 'function',
  34. FunctionParameter = 'functionParameter',
  35. }
  36. export type QueryEditorExpression =
  37. | QueryEditorArrayExpression
  38. | QueryEditorPropertyExpression
  39. | QueryEditorGroupByExpression
  40. | QueryEditorFunctionExpression
  41. | QueryEditorFunctionParameterExpression
  42. | QueryEditorOperatorExpression;
  43. export interface QueryEditorGroupByExpression {
  44. type: QueryEditorExpressionType.GroupBy;
  45. property: QueryEditorProperty;
  46. }
  47. export interface QueryEditorFunctionExpression {
  48. type: QueryEditorExpressionType.Function;
  49. name?: string;
  50. parameters?: QueryEditorFunctionParameterExpression[];
  51. }
  52. export interface QueryEditorFunctionParameterExpression {
  53. type: QueryEditorExpressionType.FunctionParameter;
  54. name?: string;
  55. }