/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * Step cards (#934): a query's steps as the Query tab draws them * (`Query Editor Spec.md` §4.3, §4.4) — each step's title and icon, its rows * of words, slots, inputs and chips, its feet and notes, the problem lines * under the rows that caused them, and the shape line after it; and a * query's outline, one line of words per finished step, which a library * card's wireframe draws (§5). * * @packageDocumentation */ import { type EastType } from "@elaraai/east"; import type { CheckedSteps, StepFix } from "../steps/check.js"; import { type Step, type StepQuery } from "../steps/values.js"; import type { ActionRef, InputRef, RemoveRef, SlotRef } from "./refs.js"; import { type QueryWords } from "./words.js"; /** One part of a card's row. */ export type CardPart = /** Words; a joiner (`and`, `or`) sits in the joiner column. */ { readonly t: "word"; readonly text: string; readonly joiner?: boolean; } /** A slot: what it shows, its placeholder while empty, and whether it reads as data or has a problem. */ | { readonly t: "slot"; readonly slot: SlotRef; readonly text: string; readonly empty: boolean; readonly placeholder: string; readonly mono: boolean; readonly error: boolean; } /** An input: a count, a name, a value or a bound. */ | { readonly t: "input"; readonly input: InputRef; readonly value: string; readonly width: "count" | "name" | "value" | "range"; readonly mono: boolean; readonly error: boolean; } /** A chip with its ×: a field a Look up brings in. */ | { readonly t: "chip"; readonly text: string; readonly remove: RemoveRef; } /** An add: a foot's, or Look up's Add field. */ | { readonly t: "add"; readonly text: string; readonly action: ActionRef; readonly ghost: boolean; } /** A row's ×. */ | { readonly t: "remove"; readonly label: string; readonly target: RemoveRef; } /** A jq step's code. */ | { readonly t: "code"; readonly text: string; }; /** A problem under a row: its plain words, the checker's, and its fixes. */ export interface ProblemLine { /** An error, a warning, or a jq step's note. */ readonly severity: "error" | "warning" | "note"; /** Its code. */ readonly code: string; /** The plain sentence. */ readonly text: string; /** The checker's own sentence, one step away (on hover). */ readonly message: string; /** Its fixes, best first. */ readonly fixes: readonly { readonly label: string; readonly fix: StepFix; }[]; } /** One line of a card. */ export interface CardLine { /** A row of parts; a group, with its own head and lines; a foot of adds; a note; a jq step's code. */ readonly kind: "row" | "group" | "foot" | "note" | "code"; /** Its parts. */ readonly parts: readonly CardPart[]; /** A group's head: its match and its words. */ readonly head?: readonly CardPart[]; /** A group's lines. */ readonly lines?: readonly CardLine[]; /** The problems under it. */ readonly problems: readonly ProblemLine[]; } /** The line between two steps: the shape in words. */ export interface ShapeLine { /** The shape, or the count after a fresh run — `16 shipped orders`. */ readonly text: string; /** What changed: `+ name, region` after a Look up or a date part, or the fields after a reshaping step. */ readonly extra: string; /** The East type, for hover. */ readonly type: string; /** Whether the text is a count. */ readonly counted: boolean; } /** A step's card. */ export interface Card { /** The step's id. */ readonly stepId: string; /** Its place, from 0. */ readonly index: number; /** Its kind. */ readonly kind: Step["type"]; /** Its title. */ readonly title: string; /** Its icon. */ readonly icon: string; /** Its head: a filter's match, when it has two conditions or more. */ readonly head: readonly CardPart[]; /** Its lines. */ readonly lines: readonly CardLine[]; /** Whether it is finished, and so in the program. */ readonly complete: boolean; /** Its problems that stop the query running. */ readonly errors: number; /** Its warnings, unfinished slots aside. */ readonly warnings: number; /** The shape after it. */ readonly shape: ShapeLine; } /** The source's card: what the query starts with. */ export interface SourceCard { /** `Start with orders`. */ readonly title: string; /** The source's plain kind — `list of orders`. */ readonly kind: string; /** The shape it gives. */ readonly shape: ShapeLine; } /** * A query's step cards (`Query Editor Spec.md` §4.3, §4.4). * * @param query - the query * @param root - the root's type: a struct of the data sources * @param checked - its check (`checkSteps`) * @param words - the words * @param counts - the rows a fresh run counted, by step id (`readCounts`), so the shape lines count * @returns one card per step, in order */ export declare function cardsFor(query: StepQuery, root: EastType, checked: CheckedSteps, words: QueryWords, counts?: ReadonlyMap): Card[]; /** * The source's card: `Start with orders`, its plain kind and its shape. * * @param query - the query * @param root - the root's type * @param checked - its check * @param words - the words * @param counts - the rows a fresh run counted (`SOURCE_COUNT` for the source's) * @returns the card */ export declare function sourceCard(query: StepQuery, root: EastType, checked: CheckedSteps, words: QueryWords, counts?: ReadonlyMap): SourceCard; /** One line of an outline: a finished step's icon, title and words. */ export interface OutlineLine { /** The step's icon. */ readonly icon: string; /** Its title. */ readonly title: string; /** What it does, in words — `status is shipped and total is at least 100`. */ readonly words: string; } /** * A query's outline: one line per finished step, which a library card's * wireframe draws (`Query Editor Spec.md` §5). * * @param query - the query * @param checked - its check, for the rows each step takes * @param words - the words * @returns the lines, in order: each step's icon, title and {@link stepWords} */ export declare function outlineOf(query: StepQuery, checked: CheckedSteps, words: QueryWords): OutlineLine[]; /** * The first empty slot of a card: where an added step opens. * * @param card - the card * @returns the slot, or `undefined` when every slot is filled */ export declare function firstEmptySlot(card: Card): SlotRef | undefined; //# sourceMappingURL=cards.d.ts.map