/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * Parsing steps (#933): a jq program back into the steps it is made of. Each * canonical form (`Query Editor Spec.md` ยง4.7) is recognised on the program * east's `parseJq` makes, never on its text, so layout and comments do not * matter; a segment no recogniser takes is a jq step, and so is every * segment after it. * * @packageDocumentation */ import { type EastType, type ParsedJq, type QueryErrorType, type ValueTypeOf } from "@elaraai/east"; import { type Shape } from "./shape.js"; import { type Aggregate, type StepQuery } from "./values.js"; /** A problem that keeps a program from being steps, as the query wire types hold one. */ export type StepParseError = ValueTypeOf; /** Where a step was read from in the program's text: the segments it was made of, first to last. */ export interface StepSpan { /** The step's id. */ readonly stepId: string; /** The offset its first segment starts at. */ readonly from: number; /** The offset after its last segment. */ readonly to: number; } /** The name a total takes until its author names it: count, the field's name for a sum, `fn_field` otherwise. */ export declare function defaultTotalName(shape: Shape, fn: Aggregate["fn"]["type"], ref: string | undefined): string; /** * Parses a jq program into steps. * * @param program - the program's text, or what east's `parseJq` made of it * @param root - the root's type: a struct of the data sources * @returns the query as steps, with where each was read from in the text; or * the problem that keeps it from being steps * * @remarks * The program starts with the `.ds as $ds` binds of its Look ups, then reads * a data source; every canonical form after it becomes its step, and a * segment no form takes is a jq step, as is every segment after it. Ids are * fresh on every parse. A program that does not parse, or does not start * from a data source, is not steps. */ export declare function parseSteps(program: string | ParsedJq, root: EastType): { query: StepQuery; spans: readonly StepSpan[]; } | { error: StepParseError; }; //# sourceMappingURL=parse.d.ts.map