Capabilities / Conditions
ConditionEvaluationContext
- class teksi_hooks.capabilities.conditions.ConditionEvaluationContext(local_values, remote_values=<factory>, context_values=<factory>)[source]
Runtime values available during condition evaluation.
Conditions should be evaluated against explicit runtime data rather than fetching database state directly. This keeps the condition evaluator pure and easy to test.
- Parameters:
local_values (Mapping[str, Any])
remote_values (Mapping[str, Mapping[str, Any]])
context_values (Mapping[str, Any])
Fields
local_valuesType:
Mapping[str, Any]Values of the object currently being evaluated, keyed by attribute name.
remote_valuesType:
Mapping[str, Mapping[str, Any]]Values of related objects, keyed first by relation name and then by attribute name.
context_valuesType:
Mapping[str, Any]External runtime context values, for example provider id, dataowner id or organisation id.
ConditionsCapability
- class teksi_hooks.capabilities.conditions.ConditionsCapability[source]
Evaluates condition models against runtime values.
This capability is intentionally stateless. It evaluates logical, local and remote conditions using a supplied ConditionEvaluationContext.
It does not fetch related objects itself. Remote values must be provided by the caller or by a higher-level evaluator.
- evaluate(condition, context)[source]
Evaluate a condition against the given runtime context.
A missing condition is treated as true. This is useful for rules where when is optional.
- Parameters:
condition (Condition | None)
context (ConditionEvaluationContext)
- Return type:
bool
- evaluate_any(condition, context)[source]
Evaluate a logical OR condition.
- Parameters:
condition (AnyOfCondition)
context (ConditionEvaluationContext)
- Return type:
bool
- evaluate_all(condition, context)[source]
Evaluate a logical AND condition.
- Parameters:
condition (AllOfCondition)
context (ConditionEvaluationContext)
- Return type:
bool
- evaluate_local(condition, context)[source]
Evaluate a condition against the current object values.
- Parameters:
condition (LocalCondition)
context (ConditionEvaluationContext)
- Return type:
bool
- evaluate_remote(condition, context)[source]
Evaluate a condition against a related object.
The related object values must be present in context.remote_values[condition.relation].
- Parameters:
condition (RemoteCondition)
context (ConditionEvaluationContext)
- Return type:
bool
- compare(actual_value, operator, expected_value, context)[source]
Compare an actual value using the configured operator.
Supported operators should mirror the YAML condition DSL.
- Parameters:
actual_value (Any)
operator (str)
expected_value (Any)
context (ConditionEvaluationContext)
- Return type:
bool