UNPKG

@bufbuild/cel

Version:

A CEL evaluator for ECMAScript

86 lines (85 loc) 2.86 kB
declare namespace runtime { interface Location { line: number; column: number; offset: number; } interface LocationRange { source?: string | GrammarLocation; start: Location; end: Location; } interface Range { source?: string | GrammarLocation; start: number; end: number; } class GrammarLocation { source: string | GrammarLocation; start: Location; constructor(source: string | GrammarLocation, start: Location); toString(): string; offset(loc: Location): Location; static offsetStart(range: LocationRange): Location; static offsetEnd(range: LocationRange): Location; } function padEnd(str: string, targetLength: number, padString: string): string; interface SourceText { source: any; text: string; } interface Expectation { type: "literal" | "class" | "any" | "end" | "pattern" | "other"; value: string; } class ParseFailure { } class ParseOptions { currentPosition?: number; silentFails?: number; maxFailExpected?: Expectation[]; grammarSource?: string | GrammarLocation; library?: boolean; startRule?: string; [index: string]: unknown; } type Result<T> = Failure | Success<T>; interface Failure { success: false; remainder: string; failedExpectations: FailedExpectation[]; } interface Success<T> { success: true; value: T; remainder: string; failedExpectations: FailedExpectation[]; } interface FailedExpectation { expectation: Expectation; remainder: string; } function isFailure(r: Result<unknown>): r is Failure; function getLocation(source: string | GrammarLocation | undefined, input: string, start: string, remainder: string): runtime.LocationRange; function getRange(source: string | GrammarLocation | undefined, input: string, start: string, remainder: string): { source: string | GrammarLocation | undefined; start: number; end: number; }; function getText(start: string, remainder: string): string; } export declare class ParseError extends Error { #private; rawMessage: string; location: runtime.LocationRange; constructor(message: string, location: runtime.LocationRange, name?: string); } export declare class SyntaxError extends ParseError { #private; expected: runtime.Expectation[]; found: string | null; constructor(expected: runtime.Expectation[], found: string, location: runtime.LocationRange, name?: string); } import type { Expr } from "@bufbuild/cel-spec/cel/expr/syntax_pb.js"; export declare function parse(input: string, options?: runtime.ParseOptions): Expr; export {};