import { type ActionContext } from '../actions.js';
import { type FetchFormsParams, type FormDefinition, type FormEmbedSettings, type FormField, type FormNotificationSettings, type FormSchemaVersion, type FormSpamSettings, type FormStats, type FormStatus, type FormsSidebarCount } from './types.js';
export declare const FORMS_COLLECTION = "forms";
/** Parse a raw `forms` document row into the typed `FormDefinition` shape. */
export declare function parseFormDefinition(doc: any): FormDefinition;
export interface SchemaValidationResult {
    valid: boolean;
    errors: string[];
}
/**
 * Validate a set of fields against config limits and structural rules. This is
 * the single gate used by both the admin "Save Schema" flow and form creation.
 */
export declare function validateFormSchema(fields: unknown): SchemaValidationResult;
export declare function listSchemaVersions(formId: string): Promise<FormSchemaVersion[]>;
export declare function getSchemaVersion(versionId: string): Promise<FormSchemaVersion | null>;
export interface ListFormsResult {
    forms: FormDefinition[];
    total: number;
    page: number;
    pageSize: number;
}
export declare function listForms(params?: FetchFormsParams): Promise<ListFormsResult>;
export declare function getFormById(id: string): Promise<FormDefinition | null>;
export declare function getFormBySlug(slug: string): Promise<FormDefinition | null>;
export interface CreateFormInput {
    name: string;
    slug?: string;
    description?: string;
    status?: FormStatus;
    fields?: FormField[];
    notificationSettings?: FormNotificationSettings;
    embedSettings?: FormEmbedSettings;
    spamSettings?: FormSpamSettings;
    successMessage?: string;
    redirectUrl?: string;
}
export declare function createForm(ctx: ActionContext, input: CreateFormInput): Promise<FormDefinition>;
export interface UpdateFormInput {
    name?: string;
    description?: string;
    status?: FormStatus;
    successMessage?: string;
    redirectUrl?: string;
    spamSettings?: FormSpamSettings;
    embedSettings?: FormEmbedSettings;
}
export declare function updateForm(ctx: ActionContext, id: string, patch: UpdateFormInput): Promise<FormDefinition>;
export declare function archiveForm(ctx: ActionContext, id: string): Promise<FormDefinition>;
export declare function restoreForm(ctx: ActionContext, id: string): Promise<FormDefinition>;
export declare function duplicateForm(ctx: ActionContext, id: string): Promise<FormDefinition>;
export interface DeleteFormOptions {
    force?: boolean;
}
export declare function deleteForm(ctx: ActionContext, id: string, options?: DeleteFormOptions): Promise<void>;
export declare function saveFormSchema(ctx: ActionContext, id: string, fields: FormField[], notes?: string): Promise<{
    form: FormDefinition;
    version: FormSchemaVersion;
}>;
export declare function getFormSchema(id: string): Promise<{
    fields: FormField[];
    activeVersionId: string | null;
    versions: FormSchemaVersion[];
}>;
export declare function getNotificationSettings(id: string): Promise<FormNotificationSettings>;
export declare function updateNotificationSettings(ctx: ActionContext, id: string, patch: Partial<FormNotificationSettings>): Promise<FormNotificationSettings>;
/** Toggle the notify flag (maps to the Notify switch in the forms table). */
export declare function setNotifyEnabled(ctx: ActionContext, id: string, enabled: boolean): Promise<FormNotificationSettings>;
export declare function getEmbedSettings(id: string): Promise<FormEmbedSettings>;
export declare function updateEmbedSettings(ctx: ActionContext, id: string, patch: Partial<FormEmbedSettings>): Promise<FormEmbedSettings>;
export declare function getFormStats(): Promise<FormStats>;
/**
 * Unread counts for the sidebar. Only active, non-hidden forms contribute to
 * the parent badge; archived/draft forms are excluded so the rail reflects
 * live, publicly-collecting forms.
 */
export declare function getFormsSidebarCounts(): Promise<FormsSidebarCount[]>;
export declare class FormNotFoundError extends Error {
    constructor(id: string);
}
export declare class FormValidationError extends Error {
    errors: string[];
    constructor(errors: string[]);
}
export declare class FormConflictError extends Error {
    constructor(message: string);
}
export declare class FormHasSubmissionsError extends Error {
    submissionCount: number;
    constructor(submissionCount: number);
}
//# sourceMappingURL=service.d.ts.map