cel library
FFX-CEL alone (05 §3): the parser, the evaluator and celFieldsRead,
the same engine the emulator runs, without the rule decisions of
rules.dart.
Classes
- CelEnvironment
- The variable environment of one evaluation (05 §3.5).
- CelFieldsRead
-
What one expression reads under one variable root,
recordornewRecord(local data, 5.13): the top-level field names it reads, or all of it. A phone decides from this whether a rule's denial can be final (every field the denial read is known on the phone). - CelProgram
Constants
- maxRuleExpressionLength → const int
- The configuration schema and TypeScript parser enforce the same budgets.
- maxSpend → const int
-
The most credits one rule's
spend()takes: as many as a pack may hold, the largest integer every client reads exactly (packages/schema config/payments-limits.tscreditsAmountMax).
Functions
-
celFieldsRead(
CelProgram program, String variable) → CelFieldsRead -
The top-level fields
programreads undervariable(recordornewRecord; any other root name, such asparams, reads its members the same way).size(newRecord.title) <= 80reads{title}undernewRecordand nothing underrecord(sizeis a function in FFX-CEL, never a method:newRecord.title.size()does not parse). AchangedFields()call reads the whole of bothrecordandnewRecord. -
celFieldType(
Map< String, Object?> spec) → Map<String, Object?> ? -
The rules engine's type of one config field (
{type, values?, model?}, rules-enginefieldToCelType), or null for a type rules cannot address (map, bytes, geopoint). -
celFieldTypes(
String model, Map< String, Map< fields) → Map<String, Object?> >String, Object?> -
Every field type a rule over
modelcan address (rules-enginemodelFieldCelTypes): the system fields, then each declared field offields(config field specs, by name) that celFieldType types. -
evaluateCel(
CelProgram program, CelEnvironment env) → bool -
Evaluates
programinenvto its boolean. Throws CelEvaluationError on a deterministic evaluation error — callers DENY on it (05 §6.3). -
parseCel(
String expression) → CelProgram - Parses one FFX-CEL expression (05 §3.2). Throws CelParseError (message
-
runCel(
CelProgram program, CelEnvironment env) → ({bool allowed, Map< String, int> spends}) -
Evaluates
programinenv, and what itsspend("…", n)calls spend when it allows: the credits on the path that allowed it, summed by name (05 §3.4); empty when it denies. Throws as evaluateCel does.
Typedefs
-
RecordLookup
= Map<
String, Object?> ? Function(String model, String id) - One parsed FFX-CEL expression, evaluated any number of times by evaluateCel.
Exceptions / Errors
- CelEvaluationError
- A deterministic evaluation error (05 §3.6): null in an ordering, arithmetic, membership, or method; a type mismatch the schema-free parse could not see; a record read with no record bound; or a non-boolean result. Callers deny on it — it is never a 500 (05 §6.3).
- CelParseError
-
A grammar, limit, or schema-free typing violation in an expression — what
the platform reports at publish time. Carries the platform's
fix.