/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * A Plan's link kinds on the canvas (#1541, U10) — pure: each kind's links, * rows of the app's record, as the links the canvas draws. * * - **A link kind's link is a link of the canvas's list.** Its ends are its * two events, each named as `Plan.eventRef` names one — its kind's slot at * no path, its key the run — so the canvas finds each where it draws, the * links focus gathers its rows, and a far end the cells do not hold is read * by its key, all as for a link built in code (`root/events.ts`). Its * quantity is its kind's. * - **Its key names its kind and its row**, as East prints a reference * (`(kind="feed", key="F-1")`): no two kinds' links share one, an event's * element none either — a link kind's slot is no event kind's — and what * selects an event's element selects a link, and removes it, by the same * text. * - **With its drafts in place**, by the one rule of a kind held whole * (`draftsInPlace`): a stored link as drafted, one its draft deletes * nowhere, one its draft adds after them — a link the Connect tool drew — * and, through a carry-over, one the canvas last drew. * - **Saved beside the event kinds**: an editable kind — bound with its patch * door — is a record of the shared editing, its session named by its slot, * and its links are selected, drawn by Connect and removed. A kind read only * draws its links as a link built in code is drawn: none is selected. * - **Past the cap, none drawn**: a kind holding more links than an event * kind's events are drawn under draws none of them, is named with how many * it holds (`linksOver`), which the frame says in a notice, and Connect * draws none of it. Its binding still reads its record whole: the cap * bounds what is decoded and drawn, not what is read. * * @packageDocumentation */ import { type ValueTypeOf } from "@elaraai/east"; import type { PlanLinkKindType } from "@elaraai/e3-ui/internal"; import { type DraftedRowsByKind, type DraftedStanding } from "../../shared/schedule/drafted-rows.js"; import type { ScheduleChange, ScheduleEditingRecord } from "../../shared/schedule/editing.js"; import type { PlanEventEditing } from "../edit/events.js"; import type { PlanLinkValue } from "../model.js"; /** A link kind, as the payload carries it. */ export type PlanLinkKindValue = ValueTypeOf; /** A link's roles, as its kind reads them from its row: its two events and its quantity. */ export type PlanLinkRolesValue = ReturnType; /** One kind's stored links, by their keys' text: each one's roles beside its row's bytes. */ export type PlanLinkStoredRows = ReadonlyMap; /** What a read of the link kinds holds: each kind's stored links, by its slot, and the kinds whose links are too many to read. */ export interface PlanLinkKindsRead { /** Each kind's stored links, by its slot: none of a kind past the cap. */ readonly stored: ReadonlyMap; /** The kinds holding more links than are read, by their slots, each with how many it holds. */ readonly over: ReadonlyMap; } /** No link kind. */ export declare const NO_LINK_KINDS: readonly PlanLinkKindValue[]; /** Nothing read of the link kinds. */ export declare const NO_LINK_KINDS_READ: PlanLinkKindsRead; /** No link of a link kind. */ export declare const NO_KIND_LINKS: readonly PlanLinkValue[]; /** A link kind holding more links than are read: its slot, its name, and how many it holds. */ export interface PlanLinksOver { /** The kind's slot. */ readonly kind: string; /** Its name. */ readonly name: string; /** How many links its record holds. */ readonly links: number; } /** No link kind holds more links than are read. */ export declare const NO_LINKS_OVER: readonly PlanLinksOver[]; /** * A link kind's link's key on the canvas: its kind's slot and its row's key, as East prints a reference. * * @param slot - The link kind's slot * @param id - The link's key's text * @returns The key */ export declare function kindLinkKey(slot: string, id: string): string; /** An event, as a link's end names it: its kind's slot and its key's text. */ export interface PlanLinkEnd { /** Its kind's slot. */ readonly kind: string; /** Its key's text. */ readonly key: string; } /** * Why a kind makes no link between two events: its `start` or its `end` holds no event of that kind — or, at its * `end`, no key that event's prints as; no `key` can be made for it, or its `key` failed as it was built; the record * `held`s a link under the key its row builds; or its new row `failed` as it was made. */ export type PlanConnectRefusal = "start" | "end" | "key" | "held" | "failed"; /** The link a Connect makes: its key on the canvas, and the change that records its row. */ export interface PlanConnectMade { /** Its key on the canvas ({@link kindLinkKey}). */ readonly key: string; /** Its row, whole, as one change of its kind's session. */ readonly change: ScheduleChange; } /** * The link a Connect would draw between two events (#1541, U10): a new row of the kind's record, its ends their keys * and every other field its type's default, under a key its row builds (`rowKey`) or its session makes. * * @param kind - The link kind Connect draws * @param ends - The event it runs from, and the one it runs to * @param mint - Makes a new key's text for the kind's record; `undefined` where it can make none * @param holds - Whether the kind's record, its drafts in place, holds a row under a key's text * @param values - The values of the template the library holds for the kind, as its bytes; `undefined` for none held, * each field but the ends then its type's default * @returns The link, or why the kind makes none */ export declare function connectLink(kind: PlanLinkKindValue, ends: { readonly from: PlanLinkEnd; readonly to: PlanLinkEnd; }, mint: (slot: string) => string | undefined, holds: (slot: string, id: string) => boolean, values?: Uint8Array | undefined): PlanConnectMade | { readonly refused: PlanConnectRefusal; }; /** * The link kind and the row a canvas key names ({@link kindLinkKey}). * * @param kinds - The link kinds * @param key - A link's key on the canvas * @returns The kind and the link's key's text; `undefined` for a key that names no link kind's link — a link built in * code, an event's element */ export declare function kindLinkOf(kinds: readonly PlanLinkKindValue[], key: string): { readonly kind: PlanLinkKindValue; readonly id: string; } | undefined; /** * An event a link names, as the Plan names it to a viewer — the inspector's facts, Connect to…'s choices and Connect's * ghost: its title as its kind reads it, its drafts in place; its key's text where the page holds no such event, or * its read fails. * * @param editing - What reads an event: the Plan's event editing * @param ref - The event, by its kind's slot and its key's text * @returns Its name */ export declare function linkEndTitle(editing: Pick, ref: PlanLinkEnd): string; /** * A gesture's label in the history over link kinds' links — canonical English, as every history's labels are: one link * by its kind's name (`Delete flow`), several by their count (`Delete 3 links`), and links with events by how many * there are of both (`Delete 4 selected`). * * @param verb - What the gesture does (`Delete`, `Edit`) * @param kinds - The kind of each link it reaches * @param events - How many events it reaches with them; none unless given * @returns The label */ export declare function linkStepLabel(verb: string, kinds: readonly PlanLinkKindValue[], events?: number): string; /** * Whether a link kind's links are made, changed and removed here: it is bound with its patch door, its session one of * the shared editing's. A kind read only (`Data.bind`) draws its links as links built in code are drawn: none is * selected, drawn by Connect or removed. * * @param kind - The link kind * @returns Whether it is edited here */ export declare function linkKindEdits(kind: PlanLinkKindValue): boolean; /** * The link kinds edited here ({@link linkKindEdits}), in the payload's order. * * @param kinds - The link kinds * @returns Those edited here: the list given, where every one is */ export declare function editableLinkKinds(kinds: readonly PlanLinkKindValue[]): readonly PlanLinkKindValue[]; /** * The link kinds edited here, as records of the shared editing: a session each, named by its slot. * * @param kinds - The link kinds * @returns The records */ export declare function linkKindRecords(kinds: readonly PlanLinkKindValue[]): ScheduleEditingRecord[]; /** * The event kinds the end of a link kind edited here may name, by their slots: an event of one may be named by a * drafted link, so its key is never re-made beneath it. A kind read only drafts no link, and holds no event's key. * * @param kinds - The link kinds * @returns The slots */ export declare function linkedEventKinds(kinds: readonly PlanLinkKindValue[]): ReadonlySet; /** * Reads each link kind's stored links — each kind's record read whole by its binding, its links decoded only within * the cap. Tracked where it is called: it reads each kind's record. * * @param kinds - The link kinds * @returns Each kind's stored links, and the kinds with more than are read */ export declare function readLinkKinds(kinds: readonly PlanLinkKindValue[]): PlanLinkKindsRead; /** * The link kinds holding more links than are read, in the payload's order: none of such a kind's links is drawn, and * the frame says how many it holds. * * @param kinds - The link kinds * @param read - What was read of them * @returns Each such kind — one empty list while there is none */ export declare function linksOver(kinds: readonly PlanLinkKindValue[], read: PlanLinkKindsRead): readonly PlanLinksOver[]; /** * The link kinds' links as the canvas draws them, their drafts in place (see the module docs). * * @param kinds - The link kinds, in the payload's order * @param read - Each kind's stored links * @param drafted - Every kind's drafted rows (`useDraftedRows`) * @param standing - Which drafted rows stand, and what the canvas last drew, which these links replace * @returns The links, each kind's stored ones in their record's order, then those its drafts add */ export declare function kindLinks(kinds: readonly PlanLinkKindValue[], read: PlanLinkKindsRead, drafted: DraftedRowsByKind, standing: DraftedStanding): readonly PlanLinkValue[]; //# sourceMappingURL=kinds.d.ts.map