import React from 'react'; import type { ApiClient } from './api-context'; import type { ColumnDefinition } from './types'; export type StageAutomationActionType = 'add_tag' | 'remove_tag' | 'set_field'; export interface StageAutomationAction { type: StageAutomationActionType; field: string; value: string; } export interface StageAutomation { id: string | number; model: string; /** Source stage the card is leaving. `'*'` = any stage. */ from_stage: string; /** Destination stage that triggers the rule (the lane's stage key). */ to_stage: string; actions: StageAutomationAction[]; enabled: boolean; } /** Draft for a new rule — a single action, keyed to a destination stage. */ export interface NewStageAutomation { model: string; from_stage: string; to_stage: string; actions: StageAutomationAction[]; enabled: boolean; } /** Whether a column holds a tag/json array (valid target for add/remove_tag). */ export declare function isTagColumn(col: ColumnDefinition): boolean; /** * Columns a given action type may target: * - add_tag / remove_tag → only tag/json columns * - set_field → any editable (non-readonly, non-hidden) column * Hidden and readonly columns are never offered. */ export declare function automationFieldOptions(columns: ColumnDefinition[], actionType: StageAutomationActionType): ColumnDefinition[]; /** Rules grouped by their destination stage key (only what the lane needs). */ export declare function groupAutomationsByStage(rules: StageAutomation[]): Map; /** Count of ENABLED rules for a stage — drives the lane's ⚡ indicator. */ export declare function activeAutomationCount(rules: StageAutomation[] | undefined): number; export interface UseStageAutomationsResult { /** False when the endpoint is missing/errored — hide the ⚡ affordance. */ available: boolean; loading: boolean; /** Destination-stage-keyed rules. */ byStage: Map; create: (draft: NewStageAutomation) => Promise; update: (id: StageAutomation['id'], patch: Partial) => Promise; remove: (id: StageAutomation['id']) => Promise; } /** * Loads a model's stage automations and exposes CRUD. Swallows a missing * endpoint (404 / network error) into `available: false` so the kanban never * breaks; real mutation failures surface a toast and re-throw so the dialog can * keep its draft. */ export declare function useStageAutomations(model: string): UseStageAutomationsResult; export interface StageAutomationsButtonProps { model: string; /** The lane's stage key + human label (destination that triggers rules). */ stageKey: string; stageLabel: string; columns: ColumnDefinition[]; rules: StageAutomation[]; onCreate: (draft: NewStageAutomation) => Promise; onUpdate: (id: StageAutomation['id'], patch: Partial) => Promise; onRemove: (id: StageAutomation['id']) => Promise; } /** * The per-lane ⚡ button: shows an active-rule count badge and opens the rule * editor for THIS stage. Rendered only when the endpoint is available. */ export declare function StageAutomationsButton({ model, stageKey, stageLabel, columns, rules, onCreate, onUpdate, onRemove, }: StageAutomationsButtonProps): React.JSX.Element; export type { ApiClient }; //# sourceMappingURL=stage-automations.d.ts.map