/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import { type ValueTypeOf, type option } from "@elaraai/east"; import type { RecordSliceBindType } from "@elaraai/east-ui/internal"; import { type EditHistory, type Origin } from "@elaraai/east-ui-components"; import { type ScheduleEditing, type ScheduleEntryRef } from "../shared/schedule/editing.js"; import { type FlowchartDrafts, type FlowchartLanded } from "./drafted.js"; import type { FlowchartValue } from "./model.js"; import { type FlowchartHeld, type FlowchartSort } from "./read.js"; /** A state's write, decoded. */ export type FlowchartStateWrite = ValueTypeOf; /** A transition's write, decoded. */ export type FlowchartTransitionWrite = ValueTypeOf; /** A lane's write, decoded. */ export type FlowchartLaneWrite = ValueTypeOf; /** The fields an author's card or the form sets on a row, as a kind's `set` takes them. */ export type FlowchartFieldWrites = Parameters[1]; /** * One row a gesture changes, and how (R8): each through its kind's own * functions, as the module docs say. */ export type FlowchartEdit = { readonly op: "createState"; readonly key: string; readonly write: FlowchartStateWrite; readonly values: option; } | { readonly op: "writeState"; readonly key: string; readonly write: FlowchartStateWrite; } | { readonly op: "createTransition"; readonly key: string; readonly write: FlowchartTransitionWrite; readonly values: option; } | { readonly op: "writeTransition"; readonly key: string; readonly write: FlowchartTransitionWrite; } /** A transition given a card's values, its ends and its key kept. */ | { readonly op: "retypeTransition"; readonly key: string; readonly values: Uint8Array; } | { readonly op: "createLane"; readonly key: string; readonly write: FlowchartLaneWrite; readonly values: option; } | { readonly op: "writeLane"; readonly key: string; readonly write: FlowchartLaneWrite; } /** A deleted state's key taken out of a decision's queue. */ | { readonly op: "unqueue"; readonly key: string; readonly state: string; } /** A state's key replaced in a decision's queue by the new key it moves to (#1549). */ | { readonly op: "requeue"; readonly key: string; readonly from: string; readonly to: string; } /** Fields no role writes: the form's, or an author's card's. */ | { readonly op: "set"; readonly sort: FlowchartSort; readonly key: string; readonly sets: FlowchartFieldWrites; } /** A row whole: the one a kind's own Details hands back. */ | { readonly op: "row"; readonly sort: FlowchartSort; readonly key: string; readonly row: Uint8Array; } /** * A new row under `key`, a copy of the row under `from` as its session finds it — a duplicate, or a new row under the * key the form gives it — its order written where given. In a swap or a shift (#1581) it `replaces` the row the * gesture moves off `key`, never a new one. */ | { readonly op: "copy"; readonly sort: FlowchartSort; readonly key: string; readonly from: string; readonly order?: number | undefined; readonly replaces?: true; } | { readonly op: "remove"; readonly sort: FlowchartSort; readonly key: string; }; /** What the key check says, in the flowchart's words. */ export interface FlowchartKeyCheckWords { /** A new row's key e3 holds already — `A state is keyed "SCN" already`. */ readonly held: (p: { sort: FlowchartSort; key: string; }) => string; /** While e3 is asked for it — `Checking the key "SCN"`. */ readonly checking: (p: { sort: FlowchartSort; key: string; }) => string; /** A new row held under a placeholder, its key still to be typed (#1549) — `Type this lane's key: Save waits for it`. */ readonly placeholder: (p: { sort: FlowchartSort; }) => string; } /** A new row's key, as its kind makes it (#1549). */ export type FlowchartNewKey = /** Its key: built from its row, made up, one past the largest, or a placeholder until the viewer types its key. */ { readonly key: string; } /** None: the key its row builds is held already, by the row of that key. */ | { readonly taken: string; } /** None: its kind's keys are of a type the form can't type — by the type's name — and its kind builds none. */ | { readonly untyped: string; }; /** A row a gesture moves under the key its fields build once the gesture writes them (#1549). */ export interface FlowchartMove { /** Its kind. */ readonly sort: FlowchartSort; /** Its key. */ readonly key: string; /** The key its row builds after the gesture. */ readonly to: string; } /** The Flowchart's editing: its history, every kind's drafts, and how a gesture is recorded. */ export interface FlowchartEditing { /** The shared Schedule editing over the records: each one's session, and what each holds. */ readonly schedule: ScheduleEditing; /** The one history over them. */ readonly history: EditHistory; /** Whether any record is edited: a kind bound with its patch door, and the Flowchart not read only. */ readonly edits: boolean; /** Every kind's drafts, each decoded once. */ readonly drafts: FlowchartDrafts; /** * What each confirmed Save landed of the kinds read by key, as their sessions keep it (`EditSession.landed`), each row * decoded once: laid under the drafts over stored rows read before the Save (`drafted.ts`' `landedDrafts`). */ readonly landed: FlowchartLanded; /** The history's version: it moves with every change of it or of its sessions. */ readonly version: number; /** * Lets go of what Saves landed of a kind's rows, once the stored rows hold them as the record does now (`drafted.ts`' * `landedRead`). * * @param sort - The kind * @param keys - The rows' keys */ shown(sort: FlowchartSort, keys: readonly string[]): void; /** * Whether the decisions queue states by their keys: a queue is given them — a state's Del takes its key out, and a * state moved to a new key takes it there. */ readonly unqueues: boolean; /** Whether the lanes' order takes a whole number alone: an Integer field, whose write and create give none for another. */ readonly wholeLaneOrders: boolean; /** * Whether a kind is edited at all: bound with its patch door, and the Flowchart not read only (R13). * * @param sort - The kind */ editable(sort: FlowchartSort): boolean; /** * Whether a kind takes an edit now: its session takes one, and nothing the canvas draws is retained. * * @param sort - The kind */ available(sort: FlowchartSort): boolean; /** * Records one gesture's edits as one step of the history. * * @param edits - The rows it changes, and how * @param origin - The gesture * @param label - Its label in the history * @returns Whether anything was recorded: nothing is when a kind refuses a row, a row's read is in flight, or what the * canvas draws is retained */ record(edits: readonly FlowchartEdit[], origin: Origin, label: string): boolean; /** * Whether the Flowchart holds a key of a kind already: read, or drafted — a new row's among them. * * @param sort - The kind * @param key - The key */ taken(sort: FlowchartSort, key: string): boolean; /** * Whether a row of a kind stands under a key (#1549): drafted, else read — a key whose row a draft deletes stands * free, so a row built under it again takes it back. * * @param sort - The kind * @param key - The key */ stands(sort: FlowchartSort, key: string): boolean; /** * A new transition's key: minted unique (`crypto.randomUUID()`) among every key the Flowchart has read and drafted * of the transitions, and those given — never drawn (R9). * * @param minted - The keys the gesture has minted already */ mintTransition(minted: ReadonlySet): string; /** * A new row's key, as its kind makes one (#1549; the module docs): built from the row the edit makes, by the * kind's `key`, refused where a row holds it; else, keyed by String, the text the gesture makes up; by Integer, * one past the largest; by a type the form types, the text made up as a placeholder; by any other, none. * * @param sort - The row's kind * @param made - The edit making the row, under any key: what the kind's `key` builds its key from * @param madeUp - The text the gesture makes up, unique by what it is told is taken: `lane-`, `state-`, a UUID * @param minted - The keys the gesture has made already * @returns The key, or why there is none; `undefined` while a kind read through its source asks its record for its * largest, or where the kind makes no row of the edit */ newKey(sort: FlowchartSort, made: FlowchartEdit, madeUp: (taken: (key: string) => boolean) => string, minted?: ReadonlySet): FlowchartNewKey | undefined; /** * The rows a gesture moves under the keys their fields build once it writes them (#1549): each row it finds held — * never one it makes — whose kind builds its key from its row, where the key its row builds changes, to another than * the one it stands under — a row whose fields an app wrote apart from its key, edited back to build it, stays (#1581). * * @param edits - The gesture's edits * @returns Each row it moves, and the key it moves under */ moves(edits: readonly FlowchartEdit[]): FlowchartMove[]; /** * Whether a kind builds a new row's key from its row: its `key`, which a key field never edits (#1549). * * @param sort - The kind */ builds(sort: FlowchartSort): boolean; /** * Why a kind adds no row (#1549): its keys are of a type the form can't type, and it builds none. * * @param sort - The kind * @returns The key type's name; `undefined` for a kind that keys the rows it adds */ untyped(sort: FlowchartSort): string | undefined; } /** A kind of any sort, as the payload carries it. */ type AnyKind = FlowchartValue["states"] | NonNullable ? T : never> | NonNullable ? T : never> | NonNullable ? T : never>; /** * A kind of the payload, by its sort. * * @param value - The payload * @param sort - The kind * @returns It; `undefined` for a kind the Flowchart is not given */ export declare function kindOf(value: FlowchartValue, sort: FlowchartSort): AnyKind | undefined; /** * The Flowchart's sessions over its records, and their drafts (see the module * docs). * * @param value - The payload * @param storageKey - The Flowchart's key: its sessions and their history are kept under it * @param recordSlices - The slice's parts over the kinds read through their sources: each Save notice counts what leaves its own * @param held - Each kind's stored rows the read holds: the keys a new row's key is unique among * @param words - What the key check says * @param retained - Whether what the canvas draws is retained: no record takes an edit while it is * @returns The editing */ export declare function useFlowchartEditing(value: FlowchartValue, storageKey: string, recordSlices: readonly ValueTypeOf[], held: FlowchartHeld, words: FlowchartKeyCheckWords, retained?: boolean): FlowchartEditing; export {}; //# sourceMappingURL=editing.d.ts.map