import type { ActionDefinition, TriggerDefinition, WorkflowMeta } from '@stonecrop/schema'; /** * Pure projection + write helpers backing {@link DocBuilderActionsPanel}. Extracted from the SFC * so they are unit-testable in a plain node environment — the panel itself embeds a Monaco editor * (`ACodeEditor`) that cannot mount in the nuxt package's DOM-less test env, so its wiring is * browser-verified while this logic is covered by `nuxt/test/docbuilderActions.test.ts`. * * The panel authors two sibling maps at once: `workflow.actions` (Transitions + stateless Commands, * created via the graph) and `workflow.triggers` (field-validation Triggers, created here). Both are * projected into one table; writes are routed back to the correct map, always preserving the other. */ export type RowKind = 'transition' | 'self-transition' | 'command' | 'trigger'; /** A single table row — column scalars ATable renders via `row[name]`, plus `__`-prefixed backrefs. */ export interface ActionRow { key: string; label: string; type: 'Transition' | 'Self-transition' | 'Command' | 'Trigger'; kind: RowKind; /** Comma-joined fire-set for Triggers; `'—'` for actions (they don't fire on field edits). */ on: string; allowedStates: string; nextState: string; __key: string; __kind: RowKind; __action?: ActionDefinition; __trigger?: TriggerDefinition; } /** Join a Trigger's `on` fire-set for display. */ export declare function formatOn(on: string[] | undefined): string; /** Parse the `on` text input (comma-separated fieldnames) into a trimmed, empty-free array. */ export declare function parseOnInput(value: string): string[]; /** * Project both sibling maps into one row list — action rows first, then trigger rows. The `kind` * discriminant drives the Type badge and routes cell edits (a Trigger can never be mistaken for a * Transition/Command because it comes from a different map, not a `stateless` guess). */ export declare function projectWorkflowRows(workflow: WorkflowMeta | undefined): ActionRow[]; /** The lowest-numbered `triggerN` key not already present — deterministic (no RNG). */ export declare function nextTriggerKey(triggers: Record | undefined): string; /** The lowest-numbered `commandN` key not already present in the actions map — deterministic. */ export declare function nextCommandKey(actions: Record | undefined): string; /** Write one field of an existing action, preserving every other action and the whole triggers map. */ export declare function writeActionField(workflow: WorkflowMeta, key: string, field: string, value: unknown): WorkflowMeta; /** Write one field of an existing trigger, preserving every other trigger and the whole actions map. */ export declare function writeTriggerField(workflow: WorkflowMeta, key: string, field: string, value: unknown): WorkflowMeta; /** Append an empty Trigger under a fresh `triggerN` key, seeding a workflow when there is none yet. */ export declare function addTrigger(workflow: WorkflowMeta | undefined): WorkflowMeta; /** * Append a stateless Command under a fresh `commandN` key, seeding a workflow when there is none yet. * Unlike a Trigger, a Command needs a non-empty label — `ActionDefinition.label` is `.min(1)`, so an * empty seed would fail doctype validation the instant it is added. It carries no `allowedStates`, so * it is available in every state; per-state scoping is not authored here (deferred to the graph). */ export declare function addCommand(workflow: WorkflowMeta | undefined): WorkflowMeta; /** Remove a Trigger, preserving every other trigger and the whole actions map. */ export declare function removeTrigger(workflow: WorkflowMeta, key: string): WorkflowMeta; /** * Remove an action from the actions map, preserving every other action and the triggers map. Used to * delete a Command from the panel — Transitions are never removed this way (they are graph-owned; you * delete a Transition by removing its edges), so the caller must guard by `kind`. */ export declare function removeAction(workflow: WorkflowMeta, key: string): WorkflowMeta;