@bufbuild/cel
Version:
A CEL evaluator for ECMAScript
116 lines (115 loc) • 4.39 kB
TypeScript
import type { Expr } from "@bufbuild/cel-spec/cel/expr/syntax_pb.js";
import { type Access, type Attribute } from "./access.js";
import { type Activation } from "./activation.js";
import type { CallDispatch, Dispatcher } from "./func.js";
import { Namespace } from "./namespace.js";
import { type CelError, type CelResult } from "./error.js";
import { type CelValue } from "./type.js";
import type { Registry } from "@bufbuild/protobuf";
export declare class Planner {
private readonly functions;
private readonly registry;
private readonly namespace;
private readonly factory;
constructor(functions: Dispatcher, registry: Registry, namespace?: Namespace);
plan(expr: Expr): Interpretable;
private planComprehension;
private planSelect;
private planCreateObj;
private planCreateStruct;
private planCreateList;
private planCall;
private planCallConditional;
private planCallIndex;
private constVal;
private relativeAttr;
private resolveType;
private isKnownType;
}
export interface Interpretable {
readonly id: number;
eval(ctx: Activation): CelResult;
}
export interface InterpretableCtor extends Interpretable {
args(): Interpretable[];
}
export declare class EvalHas implements Interpretable {
readonly id: number;
private attr;
private access;
readonly field: string;
constructor(id: number, attr: Interpretable & Attribute, access: Access, field: string);
eval(ctx: Activation): CelResult;
}
export declare class EvalErr implements Interpretable {
readonly id: number;
private readonly msg;
constructor(id: number, msg: string);
eval(_ctx: Activation): CelResult;
}
export declare class EvalConst implements Interpretable {
readonly id: number;
readonly value: CelValue;
constructor(id: number, value: CelValue);
eval(_ctx: Activation): CelResult;
}
export declare class EvalAttr implements Attribute, Interpretable {
readonly attr: Attribute;
readonly opt: boolean;
readonly id: number;
constructor(attr: Attribute, opt: boolean);
access(vars: Activation, obj: CelValue): CelResult | undefined;
isPresent(vars: Activation, obj: CelValue): CelResult<boolean>;
accessIfPresent(vars: Activation, obj: CelValue, presenceOnly: boolean): CelResult | undefined;
isOptional(): boolean;
eval(ctx: Activation): CelValue | CelError;
resolve(vars: Activation): CelResult | undefined;
addAccess(acc: Access): void;
}
export declare class EvalCall implements Interpretable {
readonly id: number;
readonly name: string;
readonly overload: string;
private readonly call;
readonly args: Interpretable[];
constructor(id: number, name: string, overload: string, call: CallDispatch | undefined, args: Interpretable[]);
eval(ctx: Activation): CelResult;
}
export declare class EvalObj implements InterpretableCtor {
readonly id: number;
readonly typeName: string;
fields: string[];
values: Interpretable[];
optionals: boolean[] | undefined;
constructor(id: number, typeName: string, fields: string[], values: Interpretable[], optionals: boolean[] | undefined);
args(): Interpretable[];
eval(ctx: Activation): CelResult;
}
export declare class EvalList implements InterpretableCtor {
readonly id: number;
private readonly elems;
constructor(id: number, elems: Interpretable[], _: boolean[] | undefined);
eval(ctx: Activation): CelResult;
args(): Interpretable[];
}
export declare class EvalMap implements InterpretableCtor {
readonly id: number;
private readonly keys;
private readonly values;
constructor(id: number, keys: Interpretable[], values: Interpretable[], _: boolean[] | undefined);
args(): Interpretable[];
eval(ctx: Activation): CelResult;
private mapKeyOrError;
}
export declare class EvalFold implements Interpretable {
readonly id: number;
readonly accuVar: string;
readonly iterVar: string;
readonly iterRange: Interpretable;
readonly accu: Interpretable;
readonly cond: Interpretable;
readonly step: Interpretable;
readonly result: Interpretable;
constructor(id: number, accuVar: string, iterVar: string, iterRange: Interpretable, accu: Interpretable, cond: Interpretable, step: Interpretable, result: Interpretable);
eval(ctx: Activation): CelResult;
}