type Kind … const DynKind … const AnyKind … const BoolKind … const BytesKind … const DoubleKind … const DurationKind … const IntKind … const ListKind … const MapKind … const NullTypeKind … const OpaqueKind … const StringKind … const StructKind … const TimestampKind … const TypeKind … const TypeParamKind … const UintKind … var AnyType … var BoolType … var BytesType … var DoubleType … var DurationType … var DynType … var IntType … var NullType … var StringType … var TimestampType … var TypeType … var UintType … var ListType … var MapType … var NullableType … var OptionalType … var OpaqueType … var ObjectType … var TypeParamType … type Type … // Constant creates an instances of an identifier declaration with a variable name, type, and value. func Constant(name string, t *Type, v ref.Val) EnvOption { … } // Variable creates an instance of a variable declaration with a variable name and type. func Variable(name string, t *Type) EnvOption { … } // Function defines a function and overloads with optional singleton or per-overload bindings. // // Using Function is roughly equivalent to calling Declarations() to declare the function signatures // and Functions() to define the function bindings, if they have been defined. Specifying the // same function name more than once will result in the aggregation of the function overloads. If any // signatures conflict between the existing and new function definition an error will be raised. // However, if the signatures are identical and the overload ids are the same, the redefinition will // be considered a no-op. // // One key difference with using Function() is that each FunctionDecl provided will handle dynamic // dispatch based on the type-signatures of the overloads provided which means overload resolution at // runtime is handled out of the box rather than via a custom binding for overload resolution via // Functions(): // // - Overloads are searched in the order they are declared // - Dynamic dispatch for lists and maps is limited by inspection of the list and map contents // // at runtime. Empty lists and maps will result in a 'default dispatch' // // - In the event that a default dispatch occurs, the first overload provided is the one invoked // // If you intend to use overloads which differentiate based on the key or element type of a list or // map, consider using a generic function instead: e.g. func(list(T)) or func(map(K, V)) as this // will allow your implementation to determine how best to handle dispatch and the default behavior // for empty lists and maps whose contents cannot be inspected. // // For functions which use parameterized opaque types (abstract types), consider using a singleton // function which is capable of inspecting the contents of the type and resolving the appropriate // overload as CEL can only make inferences by type-name regarding such types. func Function(name string, opts ...FunctionOpt) EnvOption { … } type FunctionOpt … // SingletonUnaryBinding creates a singleton function definition to be used for all function overloads. // // Note, this approach works well if operand is expected to have a specific trait which it implements, // e.g. traits.ContainerType. Otherwise, prefer per-overload function bindings. func SingletonUnaryBinding(fn functions.UnaryOp, traits ...int) FunctionOpt { … } // SingletonBinaryImpl creates a singleton function definition to be used with all function overloads. // // Note, this approach works well if operand is expected to have a specific trait which it implements, // e.g. traits.ContainerType. Otherwise, prefer per-overload function bindings. // // Deprecated: use SingletonBinaryBinding func SingletonBinaryImpl(fn functions.BinaryOp, traits ...int) FunctionOpt { … } // SingletonBinaryBinding creates a singleton function definition to be used with all function overloads. // // Note, this approach works well if operand is expected to have a specific trait which it implements, // e.g. traits.ContainerType. Otherwise, prefer per-overload function bindings. func SingletonBinaryBinding(fn functions.BinaryOp, traits ...int) FunctionOpt { … } // SingletonFunctionImpl creates a singleton function definition to be used with all function overloads. // // Note, this approach works well if operand is expected to have a specific trait which it implements, // e.g. traits.ContainerType. Otherwise, prefer per-overload function bindings. // // Deprecated: use SingletonFunctionBinding func SingletonFunctionImpl(fn functions.FunctionOp, traits ...int) FunctionOpt { … } // SingletonFunctionBinding creates a singleton function definition to be used with all function overloads. // // Note, this approach works well if operand is expected to have a specific trait which it implements, // e.g. traits.ContainerType. Otherwise, prefer per-overload function bindings. func SingletonFunctionBinding(fn functions.FunctionOp, traits ...int) FunctionOpt { … } // DisableDeclaration disables the function signatures, effectively removing them from the type-check // environment while preserving the runtime bindings. func DisableDeclaration(value bool) FunctionOpt { … } // Overload defines a new global overload with an overload id, argument types, and result type. Through the // use of OverloadOpt options, the overload may also be configured with a binding, an operand trait, and to // be non-strict. // // Note: function bindings should be commonly configured with Overload instances whereas operand traits and // strict-ness should be rare occurrences. func Overload(overloadID string, args []*Type, resultType *Type, opts ...OverloadOpt) FunctionOpt { … } // MemberOverload defines a new receiver-style overload (or member function) with an overload id, argument types, // and result type. Through the use of OverloadOpt options, the overload may also be configured with a binding, // an operand trait, and to be non-strict. // // Note: function bindings should be commonly configured with Overload instances whereas operand traits and // strict-ness should be rare occurrences. func MemberOverload(overloadID string, args []*Type, resultType *Type, opts ...OverloadOpt) FunctionOpt { … } type OverloadOpt … // UnaryBinding provides the implementation of a unary overload. The provided function is protected by a runtime // type-guard which ensures runtime type agreement between the overload signature and runtime argument types. func UnaryBinding(binding functions.UnaryOp) OverloadOpt { … } // BinaryBinding provides the implementation of a binary overload. The provided function is protected by a runtime // type-guard which ensures runtime type agreement between the overload signature and runtime argument types. func BinaryBinding(binding functions.BinaryOp) OverloadOpt { … } // FunctionBinding provides the implementation of a variadic overload. The provided function is protected by a runtime // type-guard which ensures runtime type agreement between the overload signature and runtime argument types. func FunctionBinding(binding functions.FunctionOp) OverloadOpt { … } // OverloadIsNonStrict enables the function to be called with error and unknown argument values. // // Note: do not use this option unless absoluately necessary as it should be an uncommon feature. func OverloadIsNonStrict() OverloadOpt { … } // OverloadOperandTrait configures a set of traits which the first argument to the overload must implement in order to be // successfully invoked. func OverloadOperandTrait(trait int) OverloadOpt { … } // TypeToExprType converts a CEL-native type representation to a protobuf CEL Type representation. func TypeToExprType(t *Type) (*exprpb.Type, error) { … } // ExprTypeToType converts a protobuf CEL type representation to a CEL-native type representation. func ExprTypeToType(t *exprpb.Type) (*Type, error) { … } // ExprDeclToDeclaration converts a protobuf CEL declaration to a CEL-native declaration, either a Variable or Function. func ExprDeclToDeclaration(d *exprpb.Decl) (EnvOption, error) { … }