Skip to content

dag-cost / Exports / CelCostEvaluator

Class: CelCostEvaluator

Evaluates CEL (Common Expression Language) formulas to compute costs.

Results are always returned as finite number values. BigInt results from integer-only CEL expressions are coerced to number.

Table of contents

Constructors

Methods

Constructors

constructor

new CelCostEvaluator(): CelCostEvaluator

Returns

CelCostEvaluator

Methods

evaluate

evaluate(formula, context): TResult<number, IDagError>

Evaluate a CEL formula against the given context and return a numeric cost.

Parameters

NameTypeDescription
formulastringCEL expression string (e.g. "baseCost + surcharge")
contextRecord<string, unknown>variable bindings available inside the expression

Returns

TResult<number, IDagError>

TResult\<number, IDagError\>ok: true with the numeric value, or ok: false with a structured error

Defined in

services/cel-cost-evaluator.ts:18


validate

validate(formula): TResult<void, IDagError>

Validate that a CEL formula is syntactically correct without evaluating it.

Parameters

NameTypeDescription
formulastringCEL expression string

Returns

TResult<void, IDagError>

TResult\<void, IDagError\>ok: true if valid, ok: false with parse error details otherwise

Defined in

services/cel-cost-evaluator.ts:46

Released under the MIT License.