entities.py 947 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from collections.abc import Sequence
  2. from typing import Literal
  3. from pydantic import BaseModel, Field
  4. SupportedComparisonOperator = Literal[
  5. # for string or array
  6. "contains",
  7. "not contains",
  8. "start with",
  9. "end with",
  10. "is",
  11. "is not",
  12. "empty",
  13. "not empty",
  14. "in",
  15. "not in",
  16. "all of",
  17. # for number
  18. "=",
  19. "≠",
  20. ">",
  21. "<",
  22. "≥",
  23. "≤",
  24. "null",
  25. "not null",
  26. ]
  27. class SubCondition(BaseModel):
  28. key: str
  29. comparison_operator: SupportedComparisonOperator
  30. value: str | Sequence[str] | None = None
  31. class SubVariableCondition(BaseModel):
  32. logical_operator: Literal["and", "or"]
  33. conditions: list[SubCondition] = Field(default=list)
  34. class Condition(BaseModel):
  35. variable_selector: list[str]
  36. comparison_operator: SupportedComparisonOperator
  37. value: str | Sequence[str] | None = None
  38. sub_variable_condition: SubVariableCondition | None = None