/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * The drawing's issues (#1391, `Schematic Builder Spec.md` §9, SC16) — pure * and React-free: what the inspector's Issues tab lists, each naming what a * click on it selects — and, an issue of a record's row, the row and the field * it names, which the click asks of the row's Details. * * - **A link or a net naming an item no kind holds** — an end or a member of * a slot no item kind has, or of an item kind read whole that holds no row * of its key, the drafts in place. A kind read through its source is asked * nothing: what its narrowing leaves out, the drawing cannot say is gone. * - **An item outside the extent** — its centre past the drawing's bounds. * - **Geometry outside its entity's box** — an item's footprint past its box * about its centre, a zone's shape past its box: its vertices, the arcs its * bulges draw (as the painter draws them), and a band's half-width. * - **A colour naming no theme colour** (D14) — an item's, a zone's or a * layer's, which draws its tone instead. * - **A stored row's number outside its field's bounds** (#1585) — a row the * drawing draws, or its details row, as its read holds it (`bounds.ts`). * - **The app's `ready` refusals**, and a changed row's number outside its * field's bounds — they hold Save. * - **A Save's conflict or refusal**, while it stands. * * The last three name a field by its form's label, as every builder's do. * * The last two block, and come first, then the stored rows' bounds; the rest * warn, and Save goes ahead with them. Two items of one key in one kind can't * arise: each kind is a record keyed by String. * * What is checked is what the drawing holds — a kind read by area's rows read * around the view, and the drafts drawn — and every unsaved change it leaves * out, waiting in its session where a narrowing leaves out the row it drafts, * as its draft has it (`drafted.ts`' `waitingDrafts`, which the frame hands * beside the drawing): never a read of a kind's other rows, which are checked * as the view reaches them; the inspector says so (ruled 27 Oct 2026, "Checked * in view, said so"). * * @packageDocumentation */ import { type ValueTypeOf, type option } from "@elaraai/east"; import type { Schematic } from "@elaraai/e3-ui/internal"; import type { FieldSpecValue } from "@elaraai/east-ui/internal"; import type { EditSession } from "@elaraai/east-ui-components"; import { type SchematicDrawn, type SchematicRef } from "./canvas/drawn.js"; /** Shape geometry, decoded. */ type Geometry = ValueTypeOf; /** What an issue says, before its words. */ export type SchematicIssueWord = /** An end or a member naming an item no kind holds: its kind's name — or its slot, for one no item kind has — and its key. */ { readonly issue: "missing"; readonly kind: string; readonly key: string; } /** An item whose centre lies outside the drawing's extent. */ | { readonly issue: "outside"; } /** A footprint, or a zone's shape, reaching past its box. */ | { readonly issue: "geometry"; } /** A colour naming no theme colour token: it draws its tone. */ | { readonly issue: "colour"; readonly colour: string; } /** A stored row's number its field's bounds don't hold (#1585): its field by its form's label, and the bound in its hint's own words. */ | { readonly issue: "bounds"; readonly field: string; readonly message: string; } /** The app's check refusing a drafted row, which holds Save — its field by its form's label, if it names one. */ | { readonly issue: "ready"; readonly field: string | undefined; readonly message: string; } /** A Save's conflict or refusal, in the source's own words — its field by its form's label, if it names one. */ | { readonly issue: "save"; readonly field: string | undefined; readonly message: string; }; /** One issue of the drawing, as the Issues tab lists it. */ export interface SchematicIssue { /** * What a click on it selects: an entity, by its id — one the drawing leaves out, waiting in its session, once the * choices that hide it are cleared; `undefined` for nothing — a layer, or a record's words that name no row. */ readonly at: string | undefined; /** Whether it blocks — the app's check holds Save, or a Save was stopped — rather than warns. */ readonly blocking: boolean; /** What it names: its kind's name — `undefined` for a layer — and its own name, as the Schematic names it everywhere. */ readonly where: { readonly kind: string | undefined; readonly name: string; }; /** What it says. */ readonly word: SchematicIssueWord; /** * The row it names, as its record's session names it — the record by its key in the history, its kind's slot or its * details record's, and the row's key — and the field it names, by its form's key: a click on it asks the row's * Details for the field, which takes the keyboard there, as it does for the toolbar's issue gone to. `undefined` for * an issue of the drawing's own, which names no row's field. */ readonly row?: { readonly record: string; readonly entry: string; readonly field: string | undefined; } | undefined; } /** What the drawing's issues are worked out from. */ export interface SchematicIssueArgs { /** * What is checked: what the canvas draws — the stored rows, the drafts in place — and the drafted rows it leaves out, * each as its draft has it (`drafted.ts`' `withWaiting`). */ readonly drawn: SchematicDrawn; /** The drawing's world bounds. */ readonly extent: { readonly width: number; readonly height: number; }; /** Each kind's name, by its slot. */ readonly names: ReadonlyMap; /** * Each entity's name, by its id, as the Schematic names it everywhere (`inspect.ts`' `entityNames`): what an issue's * row names it — a link by its ends, a net by its label or its ends, never a key the Schematic minted. */ readonly nameOf: (id: string) => string; /** * Whether an item is held: `false` for one of a slot no item kind has, or one an item kind read whole holds no row * of; `undefined` where it can't be said — a kind read through its source. */ readonly holds: (ref: SchematicRef) => boolean | undefined; /** The layers: each its key, its name and its colour. */ readonly layers: readonly { readonly key: string; readonly label: string; readonly color: option; }[]; /** The theme colour tokens a colour may name. */ readonly colours: ReadonlySet; } /** A shape's reach about its anchor: its least and greatest offsets along each axis. */ export interface ShapeExtent { readonly minX: number; readonly minY: number; readonly maxX: number; readonly maxY: number; } /** * A shape's reach about its anchor (D22): a circle's radius every way; a * polygon's or a polyline's vertices and the arcs their bulges draw — a * polygon's closing edge among them — and a polyline's band half its width * past them; nothing for the box itself. * * @param geometry - The shape * @returns Its reach; `undefined` for the box (`rect`) or a shape with no vertex */ export declare function shapeExtent(geometry: Geometry): ShapeExtent | undefined; /** * Whether a shape reaches past a box about its anchor. * * @param geometry - The shape * @param width - The box's width * @param height - The box's height * @returns Whether some of it lies outside the box */ export declare function outsideBox(geometry: Geometry, width: number, height: number): boolean; /** * The drawing's own issues (see the module docs): its items' — outside the * extent, a footprint past its box, a colour naming no theme colour — then its * zones', its links' and its nets' — an end or a member no kind holds — and * its layers', each in the drawing's order. Each warns. * * @param args - The drawing, its extent, its kinds' names, what the item kinds hold, its layers and the theme's colours * @returns Its issues */ export declare function drawingIssues(args: SchematicIssueArgs): SchematicIssue[]; /** * A number a row the drawing draws holds outside its field's bounds (#1585): the row's, or its details row's, as its draft * has it, else as its read holds it (`bounds.ts`). */ export interface SchematicBreach { /** The row's record's key in the history: its kind's slot, or its details record's (`detailsKey`). */ readonly record: string; /** The row's key. */ readonly key: string; /** The field, by its form's label. */ readonly field: string; /** The field, by its form's key: what a click on its issue asks of its row's Details. */ readonly fieldKey: string; /** The bound it breaks, in its hint's own words — `at most 10` — as its session's readiness says it of a changed row. */ readonly message: string; /** Whether a draft changed the row: its session's readiness raises the breach then, holding Save. */ readonly changed: boolean; } /** The breaches of the rows the drawing draws, by the id of the entity each row is drawn as: one whose rows break none is absent. */ export type SchematicBreaches = ReadonlyMap; /** * The stored rows' breaches, as Issues lists them (see the module docs): each a warning naming its entity and the field * by its form's label, in the drawing's order. A changed row's is its session's readiness's, which blocks: never here. * * @param breaches - The breaches of the rows the drawing draws, by entity * @param names - Each kind's name, by its slot * @param nameOf - Each entity's name, by its id, as the Schematic names it everywhere * @returns The issues */ export declare function boundsIssues(breaches: SchematicBreaches, names: ReadonlyMap, nameOf: (id: string) => string): SchematicIssue[]; /** A record's session as Issues reads it: the kind or the details record it is, and where its Save stands. */ export interface SchematicIssueSession { /** The record's key in the history: a kind's slot, or its details record's (`detailsKey`). */ readonly kind: string; /** Its session: where its latest Save stands, its source's words, and its drafts' readiness. */ readonly session: Pick, "status" | "issues" | "readiness">; /** Its row's form: what an issue names a field by. */ readonly fields: readonly FieldSpecValue[]; } /** * The issues each record's session raises (see the module docs): the app's * check refusing its drafted rows, and its latest Save's conflict or refusal * while it stands — each blocking, naming the entity of its row and a field * by its form's label, and the row and the field by its key, which a click * asks of the row's Details. * * @param sessions - Each record's session * @param names - Each kind's name, by its slot * @param labelOf - An entity's name by its id: its label, where the drawing draws it * @returns The issues, in the sessions' order */ export declare function sessionIssues(sessions: readonly SchematicIssueSession[], names: ReadonlyMap, labelOf: (id: string) => string | undefined): SchematicIssue[]; export {}; //# sourceMappingURL=issues.d.ts.map