import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; import Long from "long"; import { Duration } from "../../../protobuf/duration"; import { NullValue } from "../../../protobuf/struct"; export declare const protobufPackage = "google.api.expr.v1alpha1"; /** An expression together with source information as returned by the parser. */ export interface ParsedExpr { /** The parsed expression. */ expr: Expr | undefined; /** The source info derived from input that generated the parsed `expr`. */ sourceInfo: SourceInfo | undefined; } /** * An abstract representation of a common expression. * * Expressions are abstractly represented as a collection of identifiers, * select statements, function calls, literals, and comprehensions. All * operators with the exception of the '.' operator are modelled as function * calls. This makes it easy to represent new operators into the existing AST. * * All references within expressions must resolve to a * [Decl][google.api.expr.v1alpha1.Decl] provided at type-check for an * expression to be valid. A reference may either be a bare identifier `name` or * a qualified identifier `google.api.name`. References may either refer to a * value or a function declaration. * * For example, the expression `google.api.name.startsWith('expr')` references * the declaration `google.api.name` within a * [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression, and the * function declaration `startsWith`. */ export interface Expr { /** * Required. An id assigned to this node by the parser which is unique in a * given expression tree. This is used to associate type information and other * attributes to a node in the parse tree. */ id: Long; /** Required. Variants of expressions. */ exprKind?: // /** A literal expression. */ { $case: "constExpr"; constExpr: Constant; } | // /** An identifier expression. */ { $case: "identExpr"; identExpr: Expr_Ident; } | // /** A field selection expression, e.g. `request.auth`. */ { $case: "selectExpr"; selectExpr: Expr_Select; } | // /** A call expression, including calls to predefined functions and operators. */ { $case: "callExpr"; callExpr: Expr_Call; } | // /** A list creation expression. */ { $case: "listExpr"; listExpr: Expr_CreateList; } | // /** A map or message creation expression. */ { $case: "structExpr"; structExpr: Expr_CreateStruct; } | // /** A comprehension expression. */ { $case: "comprehensionExpr"; comprehensionExpr: Expr_Comprehension; } | undefined; } /** An identifier expression. e.g. `request`. */ export interface Expr_Ident { /** * Required. Holds a single, unqualified identifier, possibly preceded by a * '.'. * * Qualified names are represented by the * [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression. */ name: string; } /** A field selection expression. e.g. `request.auth`. */ export interface Expr_Select { /** * Required. The target of the selection expression. * * For example, in the select expression `request.auth`, the `request` * portion of the expression is the `operand`. */ operand: Expr | undefined; /** * Required. The name of the field to select. * * For example, in the select expression `request.auth`, the `auth` portion * of the expression would be the `field`. */ field: string; /** * Whether the select is to be interpreted as a field presence test. * * This results from the macro `has(request.auth)`. */ testOnly: boolean; } /** * A call expression, including calls to predefined functions and operators. * * For example, `value == 10`, `size(map_value)`. */ export interface Expr_Call { /** * The target of an method call-style expression. For example, `x` in * `x.f()`. */ target: Expr | undefined; /** Required. The name of the function or method being called. */ function: string; /** The arguments. */ args: Expr[]; } /** * A list creation expression. * * Lists may either be homogenous, e.g. `[1, 2, 3]`, or heterogeneous, e.g. * `dyn([1, 'hello', 2.0])` */ export interface Expr_CreateList { /** The elements part of the list. */ elements: Expr[]; /** * The indices within the elements list which are marked as optional * elements. * * When an optional-typed value is present, the value it contains * is included in the list. If the optional-typed value is absent, the list * element is omitted from the CreateList result. */ optionalIndices: number[]; } /** * A map or message creation expression. * * Maps are constructed as `{'key_name': 'value'}`. Message construction is * similar, but prefixed with a type name and composed of field ids: * `types.MyType{field_id: 'value'}`. */ export interface Expr_CreateStruct { /** * The type name of the message to be created, empty when creating map * literals. */ messageName: string; /** The entries in the creation expression. */ entries: Expr_CreateStruct_Entry[]; } /** Represents an entry. */ export interface Expr_CreateStruct_Entry { /** * Required. An id assigned to this node by the parser which is unique * in a given expression tree. This is used to associate type * information and other attributes to the node. */ id: Long; /** The `Entry` key kinds. */ keyKind?: // /** The field key for a message creator statement. */ { $case: "fieldKey"; fieldKey: string; } | // /** The key expression for a map creation statement. */ { $case: "mapKey"; mapKey: Expr; } | undefined; /** * Required. The value assigned to the key. * * If the optional_entry field is true, the expression must resolve to an * optional-typed value. If the optional value is present, the key will be * set; however, if the optional value is absent, the key will be unset. */ value: Expr | undefined; /** Whether the key-value pair is optional. */ optionalEntry: boolean; } /** * A comprehension expression applied to a list or map. * * Comprehensions are not part of the core syntax, but enabled with macros. * A macro matches a specific call signature within a parsed AST and replaces * the call with an alternate AST block. Macro expansion happens at parse * time. * * The following macros are supported within CEL: * * Aggregate type macros may be applied to all elements in a list or all keys * in a map: * * * `all`, `exists`, `exists_one` - test a predicate expression against * the inputs and return `true` if the predicate is satisfied for all, * any, or only one value `list.all(x, x < 10)`. * * `filter` - test a predicate expression against the inputs and return * the subset of elements which satisfy the predicate: * `payments.filter(p, p > 1000)`. * * `map` - apply an expression to all elements in the input and return the * output aggregate type: `[1, 2, 3].map(i, i * i)`. * * The `has(m.x)` macro tests whether the property `x` is present in struct * `m`. The semantics of this macro depend on the type of `m`. For proto2 * messages `has(m.x)` is defined as 'defined, but not set`. For proto3, the * macro tests whether the property is set to its default. For map and struct * types, the macro tests whether the property `x` is defined on `m`. * * Comprehensions for the standard environment macros evaluation can be best * visualized as the following pseudocode: * * ``` * let `accu_var` = `accu_init` * for (let `iter_var` in `iter_range`) { * if (!`loop_condition`) { * break * } * `accu_var` = `loop_step` * } * return `result` * ``` * * Comprehensions for the optional V2 macros which support map-to-map * translation differ slightly from the standard environment macros in that * they expose both the key or index in addition to the value for each list * or map entry: * * ``` * let `accu_var` = `accu_init` * for (let `iter_var`, `iter_var2` in `iter_range`) { * if (!`loop_condition`) { * break * } * `accu_var` = `loop_step` * } * return `result` * ``` */ export interface Expr_Comprehension { /** * The name of the first iteration variable. * When the iter_range is a list, this variable is the list element. * When the iter_range is a map, this variable is the map entry key. */ iterVar: string; /** * The name of the second iteration variable, empty if not set. * When the iter_range is a list, this variable is the integer index. * When the iter_range is a map, this variable is the map entry value. * This field is only set for comprehension v2 macros. */ iterVar2: string; /** The range over which the comprehension iterates. */ iterRange: Expr | undefined; /** The name of the variable used for accumulation of the result. */ accuVar: string; /** The initial value of the accumulator. */ accuInit: Expr | undefined; /** * An expression which can contain iter_var, iter_var2, and accu_var. * * Returns false when the result has been computed and may be used as * a hint to short-circuit the remainder of the comprehension. */ loopCondition: Expr | undefined; /** * An expression which can contain iter_var, iter_var2, and accu_var. * * Computes the next value of accu_var. */ loopStep: Expr | undefined; /** * An expression which can contain accu_var. * * Computes the result. */ result: Expr | undefined; } /** * Represents a primitive literal. * * Named 'Constant' here for backwards compatibility. * * This is similar as the primitives supported in the well-known type * `google.protobuf.Value`, but richer so it can represent CEL's full range of * primitives. * * Lists and structs are not included as constants as these aggregate types may * contain [Expr][google.api.expr.v1alpha1.Expr] elements which require * evaluation and are thus not constant. * * Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`, * `true`, `null`. */ export interface Constant { /** Required. The valid constant kinds. */ constantKind?: // /** null value. */ { $case: "nullValue"; nullValue: NullValue; } | // /** boolean value. */ { $case: "boolValue"; boolValue: boolean; } | // /** int64 value. */ { $case: "int64Value"; int64Value: Long; } | // /** uint64 value. */ { $case: "uint64Value"; uint64Value: Long; } | // /** double value. */ { $case: "doubleValue"; doubleValue: number; } | // /** string value. */ { $case: "stringValue"; stringValue: string; } | // /** bytes value. */ { $case: "bytesValue"; bytesValue: Buffer; } | // /** * protobuf.Duration value. * * Deprecated: duration is no longer considered a builtin cel type. */ { $case: "durationValue"; durationValue: Duration; } | // /** * protobuf.Timestamp value. * * Deprecated: timestamp is no longer considered a builtin cel type. */ { $case: "timestampValue"; timestampValue: Date; } | undefined; } /** Source information collected at parse time. */ export interface SourceInfo { /** The syntax version of the source, e.g. `cel1`. */ syntaxVersion: string; /** * The location name. All position information attached to an expression is * relative to this location. * * The location could be a file, UI element, or similar. For example, * `acme/app/AnvilPolicy.cel`. */ location: string; /** * Monotonically increasing list of code point offsets where newlines * `\n` appear. * * The line number of a given position is the index `i` where for a given * `id` the `line_offsets[i] < id_positions[id] < line_offsets[i+1]`. The * column may be derivd from `id_positions[id] - line_offsets[i]`. */ lineOffsets: number[]; /** * A map from the parse node id (e.g. `Expr.id`) to the code point offset * within the source. */ positions: Map; /** * A map from the parse node id where a macro replacement was made to the * call `Expr` that resulted in a macro expansion. * * For example, `has(value.field)` is a function call that is replaced by a * `test_only` field selection in the AST. Likewise, the call * `list.exists(e, e > 10)` translates to a comprehension expression. The key * in the map corresponds to the expression id of the expanded macro, and the * value is the call `Expr` that was replaced. */ macroCalls: Map; /** * A list of tags for extensions that were used while parsing or type checking * the source expression. For example, optimizations that require special * runtime support may be specified. * * These are used to check feature support between components in separate * implementations. This can be used to either skip redundant work or * report an error if the extension is unsupported. */ extensions: SourceInfo_Extension[]; } /** An extension that was requested for the source expression. */ export interface SourceInfo_Extension { /** Identifier for the extension. Example: constant_folding */ id: string; /** * If set, the listed components must understand the extension for the * expression to evaluate correctly. * * This field has set semantics, repeated values should be deduplicated. */ affectedComponents: SourceInfo_Extension_Component[]; /** * Version info. May be skipped if it isn't meaningful for the extension. * (for example constant_folding might always be v0.0). */ version: SourceInfo_Extension_Version | undefined; } /** CEL component specifier. */ export declare enum SourceInfo_Extension_Component { /** COMPONENT_UNSPECIFIED - Unspecified, default. */ COMPONENT_UNSPECIFIED = 0, /** COMPONENT_PARSER - Parser. Converts a CEL string to an AST. */ COMPONENT_PARSER = 1, /** * COMPONENT_TYPE_CHECKER - Type checker. Checks that references in an AST are defined and types * agree. */ COMPONENT_TYPE_CHECKER = 2, /** * COMPONENT_RUNTIME - Runtime. Evaluates a parsed and optionally checked CEL AST against a * context. */ COMPONENT_RUNTIME = 3, UNRECOGNIZED = -1 } export declare function sourceInfo_Extension_ComponentFromJSON(object: any): SourceInfo_Extension_Component; export declare function sourceInfo_Extension_ComponentToJSON(object: SourceInfo_Extension_Component): string; /** Version */ export interface SourceInfo_Extension_Version { /** * Major version changes indicate different required support level from * the required components. */ major: Long; /** * Minor version changes must not change the observed behavior from * existing implementations, but may be provided informationally. */ minor: Long; } export interface SourceInfo_PositionsEntry { key: Long; value: number; } export interface SourceInfo_MacroCallsEntry { key: Long; value: Expr | undefined; } /** A specific position in source. */ export interface SourcePosition { /** The soucre location name (e.g. file name). */ location: string; /** The UTF-8 code unit offset. */ offset: number; /** * The 1-based index of the starting line in the source text * where the issue occurs, or 0 if unknown. */ line: number; /** * The 0-based index of the starting position within the line of source text * where the issue occurs. Only meaningful if line is nonzero. */ column: number; } export declare const ParsedExpr: MessageFns; export declare const Expr: MessageFns; export declare const Expr_Ident: MessageFns; export declare const Expr_Select: MessageFns; export declare const Expr_Call: MessageFns; export declare const Expr_CreateList: MessageFns; export declare const Expr_CreateStruct: MessageFns; export declare const Expr_CreateStruct_Entry: MessageFns; export declare const Expr_Comprehension: MessageFns; export declare const Constant: MessageFns; export declare const SourceInfo: MessageFns; export declare const SourceInfo_Extension: MessageFns; export declare const SourceInfo_Extension_Version: MessageFns; export declare const SourceInfo_PositionsEntry: MessageFns; export declare const SourceInfo_MacroCallsEntry: MessageFns; export declare const SourcePosition: MessageFns; type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T : T extends Long ? string | number | Long : T extends globalThis.Array ? globalThis.Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends { $case: string; } ? { [K in keyof Omit]?: DeepPartial; } & { $case: T["$case"]; } : T extends {} ? { [K in keyof T]?: DeepPartial; } : Partial; export interface MessageFns { encode(message: T, writer?: BinaryWriter): BinaryWriter; decode(input: BinaryReader | Uint8Array, length?: number): T; fromJSON(object: any): T; toJSON(message: T): unknown; create(base?: DeepPartial): T; fromPartial(object: DeepPartial): T; } export {};