Documentation ¶
Index ¶
- Constants
- func EvaluateQuery(env envs.Environment, query *ContactQuery, queryable Queryable) (bool, error)
- func NewErrorListener() *errorListener
- type BoolCombination
- type BoolOperator
- type Comparator
- type Condition
- func (c *Condition) Comparator() Comparator
- func (c *Condition) Evaluate(env envs.Environment, queryable Queryable) (bool, error)
- func (c *Condition) PropertyKey() string
- func (c *Condition) PropertyType() PropertyType
- func (c *Condition) String() string
- func (c *Condition) Validate() error
- func (c *Condition) Value() string
- type ContactQuery
- type FieldResolverFunc
- type PropertyType
- type QueryNode
- type Queryable
Constants ¶
const ( AttributeID = "id" AttributeName = "name" AttributeLanguage = "language" AttributeURN = "urn" AttributeCreatedOn = "created_on" )
Fixed attributes that can be searched
Variables ¶
This section is empty.
Functions ¶
func EvaluateQuery ¶
func EvaluateQuery(env envs.Environment, query *ContactQuery, queryable Queryable) (bool, error)
EvaluateQuery evaluates the given parsed query against a queryable object
func NewErrorListener ¶ added in v0.6.2
func NewErrorListener() *errorListener
Types ¶
type BoolCombination ¶
type BoolCombination struct {
// contains filtered or unexported fields
}
BoolCombination is a AND or OR combination of multiple conditions
func NewBoolCombination ¶
func NewBoolCombination(op BoolOperator, children ...QueryNode) *BoolCombination
NewBoolCombination creates a new boolean combination
func (*BoolCombination) Children ¶ added in v0.41.15
func (b *BoolCombination) Children() []QueryNode
Children returns the children of this boolean combination
func (*BoolCombination) Evaluate ¶
func (b *BoolCombination) Evaluate(env envs.Environment, queryable Queryable) (bool, error)
Evaluate returns whether this combination evaluates to true or false
func (*BoolCombination) Operator ¶ added in v0.41.15
func (b *BoolCombination) Operator() BoolOperator
Operator returns the type of boolean operator this combination is
func (*BoolCombination) String ¶
func (b *BoolCombination) String() string
type BoolOperator ¶ added in v0.41.15
type BoolOperator string
BoolOperator is a boolean operator (and or or)
const ( // BoolOperatorAnd is our constant for an AND operation BoolOperatorAnd BoolOperator = "and" // BoolOperatorOr is our constant for an OR operation BoolOperatorOr BoolOperator = "or" )
type Comparator ¶ added in v0.66.1
type Comparator string
Comparator is a way of comparing two values in a condition
const ( ComparatorEqual Comparator = "=" ComparatorNotEqual Comparator = "!=" ComparatorContains Comparator = "~" ComparatorGreaterThan Comparator = ">" ComparatorLessThan Comparator = "<" ComparatorGreaterThanOrEqual Comparator = ">=" ComparatorLessThanOrEqual Comparator = "<=" )
supported comparators
type Condition ¶
type Condition struct {
// contains filtered or unexported fields
}
Condition represents a comparison between a keywed value on the contact and a provided value
func (*Condition) Comparator ¶ added in v0.41.15
func (c *Condition) Comparator() Comparator
Comparator returns the type of comparison being made
func (*Condition) PropertyKey ¶ added in v0.45.1
PropertyKey returns the key for the property being queried
func (*Condition) PropertyType ¶ added in v0.45.1
func (c *Condition) PropertyType() PropertyType
PropertyType returns the type (attribute, scheme, field)
type ContactQuery ¶
type ContactQuery struct {
// contains filtered or unexported fields
}
func ParseQuery ¶
func ParseQuery(text string, redaction envs.RedactionPolicy, fieldResolver FieldResolverFunc) (*ContactQuery, error)
ParseQuery parses a ContactQL query from the given input
func (*ContactQuery) Evaluate ¶
func (q *ContactQuery) Evaluate(env envs.Environment, queryable Queryable) (bool, error)
func (*ContactQuery) Root ¶ added in v0.41.15
func (q *ContactQuery) Root() QueryNode
func (*ContactQuery) String ¶
func (q *ContactQuery) String() string
type FieldResolverFunc ¶ added in v0.45.1
FieldResolverFunc resolves a query property key to a possible contact field
type PropertyType ¶ added in v0.45.1
type PropertyType string
PropertyType is the type of the lefthand side of a condition
const ( // PropertyTypeAttribute is builtin property PropertyTypeAttribute PropertyType = "attribute" // PropertyTypeScheme is a URN scheme PropertyTypeScheme PropertyType = "scheme" // PropertyTypeField is a custom contact field PropertyTypeField PropertyType = "field" )
type Queryable ¶
type Queryable interface {
QueryProperty(envs.Environment, string, PropertyType) []interface{}
}
Queryable is the interface objects must implement queried