// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. export type CompareOp = ">" | ">=" | "<" | "<="; export type Completion = { /** * What to show: a field's path, or a value as it is. */ label: string, /** * What replaces the span: `@method:`, `@header.`, or a value quoted when it needs to be. */ insert: string, kind: CompletionKind, /** * What a field is, from its definition. */ info: string | null, /** * A term using the field, from its definition. */ example: string | null, /** * The term is not finished after inserting (a field still needs its value, a map field its * key), so completion should open again. */ reopen: boolean, }; export type CompletionKind = "field" | "value"; /** * Completions for the term at the cursor, all replacing `span`. */ export type Completions = { span: Span, items: Array, }; /** * Something in a query the schema does not accept. The query still parses and runs; the * offending term matches nothing. */ export type Diagnostic = { "type": "unknownField", path: string, span: Span, } | { "type": "invalidValue", path: string, span: Span, }; export type DocValue = boolean | number | string; /** * One value or several. */ export type DocValues = DocValue | Array; /** * What a query is matched against: free text for bare words and phrases, and field values by * lowercase dotted path. A map field's values sit under `name.key` (`header.x-cache`). */ export type Document = { text?: string, fields?: { [key in string]?: DocValues }, }; /** * One field: `@name:value`. */ export type FieldDef = { /** * The field's path, dotted when nested: `method`, `req.header`. */ name: string, kind: FieldKind, /** * A map of named values, such as headers: `@header.:value` is valid for any key, and * the key is matched against the document's keys (case-insensitively). */ map?: boolean, /** * What the field is, in a few words, shown with it in completions: `GET, POST, …`. */ info?: string, /** * A term using it, shown with it in completions: `@method:post`. */ example?: string, }; export type FieldKind = { "type": "text" } | { "type": "number", units: Array, } | { "type": "flag" }; /** * What a field term's value asks for. The shape is decided by the parser alone; the schema * decides what it means for a given field. */ export type FieldValue = { "type": "text", text: string, quoted: boolean, } | { "type": "wildcard", pattern: string, } | { "type": "exists" } | { "type": "compare", op: CompareOp, number: NumberLiteral, } | { "type": "range", low: NumberLiteral, high: NumberLiteral, }; /** * How a bare word matches the document's free text. A quoted phrase is always a substring. */ export type FreeText = "fuzzy" | "substring"; /** * A node of the parsed query. */ export type Node = { "type": "And", children: Array, span: Span, } | { "type": "Or", children: Array, span: Span, } | { "type": "Not", node: Node, span: Span, } | { "type": "Term", text: string, span: Span, } | { "type": "Phrase", text: string, span: Span, } | { "type": "Field", /** * The dotted path, one entry per identifier: `@req.header.accept` is * `["req", "header", "accept"]`. */ path: Array, value: FieldValue, span: Span, /** * `@path:`, from the `@` through the colon. */ pathSpan: Span, /** * The value as written, quotes included. Empty (and at the end of the field) when * nothing follows the colon. */ valueSpan: Span, }; /** * A number as written in a comparison or range, with its unit when it has one (`500ms`, * `2.5mb`). The schema says which units a field accepts and what they are worth. */ export type NumberLiteral = { value: number, unit: string | null, /** * The number as it appears in the source, unit included. */ raw: string, }; /** * A consumer's searchable fields. */ export type Schema = { fields: Array, /** * Substring when left out. */ freeText?: FreeText, }; /** * A half-open byte range `start..end` in the query source. */ export type Span = { start: number, end: number, }; export type Token = { kind: TokenKind, span: Span, }; export type TokenKind = "field" | "value" | "operator" | "quote" | "paren" | "negation" | "text"; /** * A unit a number may be written in, and how many of the field's base unit it is worth: * `{ name: "s", factor: 1000 }` for a field counted in milliseconds. */ export type Unit = { name: string, factor: number, };