import { k as ExprNode } from "./shared-C7P2VCv4.js"; interface ParseOptions { params?: Record; mode?: 'normal' | 'delta'; } /** * Error thrown when a GROQ query contains a syntax error. * * Provides the position of the error as both a string offset and * a line/column pair. All values use UTF-16 code unit offsets, * matching JavaScript string indexing and the LSP default encoding. */ declare class GroqSyntaxError extends Error { /** * 0-based UTF-16 code unit offset from the start of the query string. */ position: number; /** * 1-based line number where the error occurred. */ line: number; /** * 1-based column number within the line, in UTF-16 code units. */ column: number; name: string; constructor(position: number, query: string, detail: string); } /** * Parses a GROQ query and returns a tree structure. */ declare function parse(input: string, options?: ParseOptions): ExprNode; /** Represents a document structure with a fixed type 'document', a name, and a collection of attributes.*/ interface Document { /** can be used to identify the type of the node, in this case it's always 'document' */ type: 'document'; /** the name of the document */ name: string; /** Attributes is defined by a key-value pair where the key is a string and the value is an ObjectAttribute. */ attributes: Record; } /** Defines a type declaration with a specific name and a value that describes the structure of the type using a TypeNode. */ interface TypeDeclaration { /** can be used to identify the type of the node, in this case it's always 'type' */ type: 'type'; /** the name of the type */ name: string; /** the value that describes the structure of the type */ value: TypeNode; } /** A schema consisting of a list of Document or TypeDeclaration items, allowing for complex type definitions. */ type Schema = (Document | TypeDeclaration)[]; /** Symbol to mark a string type as a datetime */ declare const STRING_TYPE_DATETIME: unique symbol; /** Describes a type node for string values, optionally including a value. If a value is provided it will always be the given string value. */ interface StringTypeNode { /** can be used to identify the type of the node, in this case it's always 'string' */ type: 'string'; /** an optional value of the string, if provided it will always be the given string value */ value?: string; /** marks this string as a datetime type for arithmetic operations */ [STRING_TYPE_DATETIME]?: true; } /** Describes a type node for number values, optionally including a value. If a value is provided it will always be the given numeric value.*/ interface NumberTypeNode { /** can be used to identify the type of the node, in this case it's always 'number' */ type: 'number'; /** an optional value of the number, if provided it will always be the given numeric value */ value?: number; } /** Describes a type node for boolean values, optionally including a value. If a value is provided it will always be the given boolean value. */ interface BooleanTypeNode { /** can be used to identify the type of the node, in this case it's always 'boolean' */ type: 'boolean'; /** an optional value of the boolean, if provided it will always be the given boolean value */ value?: boolean; } /** Union of any primitive type nodes. */ type PrimitiveTypeNode = StringTypeNode | NumberTypeNode | BooleanTypeNode; /** Describes a type node for null values, always being the null value. */ interface NullTypeNode { /** can be used to identify the type of the node, in this case it's always 'null' */ type: 'null'; } /** Describes a type node for inline values, including a name that references another type. */ interface InlineTypeNode { /** can be used to identify the type of the node, in this case it's always 'inline' */ type: 'inline'; /** the name of the referenced type */ name: string; } /** * Describes a type node for object values, including a collection of attributes and an optional rest value. * The rest value can be another ObjectTypeNode, an UnknownTypeNode, or an InlineTypeNode. * If the rest value is an ObjectTypeNode, it means that the object can have additional attributes. * If the rest value is an UnknownTypeNode, the entire object is unknown. * If the rest value is an InlineTypeNode, it means that the object has additional attributes from the referenced type. */ interface ObjectTypeNode { /** can be used to identify the type of the node, in this case it's always 'object' */ type: 'object'; /** a collection of attributes */ attributes: Record>; /** an optional rest value */ rest?: ObjectTypeNode | UnknownTypeNode | InlineTypeNode; dereferencesTo?: string; } /** Describes a type node for object attributes, including a type and an optional flag for being optional. */ interface ObjectAttribute { /** can be used to identify the type of the node, in this case it's always 'objectAttribute' */ type: 'objectAttribute'; /** the type of the attribute */ value: T; /** an optional flag if the attribute is optional set on the object */ optional?: boolean; } /** Describes a type node for union values. */ interface UnionTypeNode { /** can be used to identify the type of the node, in this case it's always 'union' */ type: 'union'; /** a collection of types */ of: T[]; } /** Describes a type node for array values. */ interface ArrayTypeNode { /** can be used to identify the type of the node, in this case it's always 'array' */ type: 'array'; /** the type of the array elements */ of: T; } /** Describes a type node for unknown value. */ type UnknownTypeNode = { /** can be used to identify the type of the node, in this case it's always 'unknown' */ type: 'unknown'; }; /** All possible type nodes. */ type TypeNode = ObjectTypeNode | StringTypeNode | NullTypeNode | NumberTypeNode | BooleanTypeNode | ArrayTypeNode | UnionTypeNode | InlineTypeNode | UnknownTypeNode; /** * Evaluates the type of a query and schema. * * @param ast - The query ast to evaluate. * @param schema - The schemas to use for type evaluation. * @returns The type of the query. * @beta */ declare function typeEvaluate(ast: ExprNode, schema: Schema): TypeNode; /** * createReferenceTypeNode creates a ObjectTypeNode representing a reference type * it adds required attributes for a reference type. * @param name - The name of the reference type * @param inArray - Whether the reference is in an array * @returns A ObjectTypeNode representing a reference type * @internal */ declare function createReferenceTypeNode(name: string, inArray?: boolean): ObjectTypeNode; export { UnknownTypeNode as _, Document as a, ParseOptions as b, NumberTypeNode as c, PrimitiveTypeNode as d, Schema as f, UnionTypeNode as g, TypeNode as h, BooleanTypeNode as i, ObjectAttribute as l, TypeDeclaration as m, typeEvaluate as n, InlineTypeNode as o, StringTypeNode as p, ArrayTypeNode as r, NullTypeNode as s, createReferenceTypeNode as t, ObjectTypeNode as u, GroqSyntaxError as v, parse as y }; //# sourceMappingURL=1-0fhXnGQk.d.ts.map