import type { PdfFormFieldValue } from '@pdfrx/engine'; import type { PagePlacement } from '@pdfrx/viewer-core'; /** Value update for a form field owned by an immutable source document. */ export interface SharedFormFieldChange { /** Session-level id of the source PDF containing the field. */ readonly documentId: string; /** Fully-qualified AcroForm field name inside that source PDF. */ readonly fieldName: string; /** New typed value; choice fields use selected option-label arrays. */ readonly value: PdfFormFieldValue; } /** Materialized shared value for one source-scoped AcroForm field. */ export interface SharedFormFieldRecord extends SharedFormFieldChange { } /** Authoritative form state, versioned independently from pages and annotations. */ export interface FormSessionSnapshot { /** Last committed form-operation revision. */ readonly revision: number; /** Latest materialized value for every changed field. */ readonly fields: readonly SharedFormFieldRecord[]; } /** Optimistic form operation submitted to an authoritative relay. */ export interface FormOperationRequest { /** Unique correlation id generated by the submitting client. */ readonly operationId: string; /** Stable participant id responsible for the update. */ readonly actorId: string; /** Form revision observed before submitting the update. */ readonly baseRevision: number; /** Requested source-scoped field update. */ readonly change: SharedFormFieldChange; } /** Accepted form operation with its authoritative sequence number. */ export interface CommittedFormOperation extends FormOperationRequest { /** Revision assigned by the relay. */ readonly revision: number; } /** * Validates and commits a form update against authoritative state. * @throws {@link FormProtocolError} for a stale revision or unknown source document. * @param snapshot - The current immutable session snapshot. * @param pages - The pages to process, in document order. * @param request - The request value (FormOperationRequest). * @returns The updated result. * */ export declare function commitFormOperation(snapshot: FormSessionSnapshot, pages: readonly PagePlacement[], request: FormOperationRequest): { readonly snapshot: FormSessionSnapshot; readonly committed: CommittedFormOperation; }; /** * Applies the next committed form event to a client-side snapshot. * @throws {@link FormProtocolError} when a revision is skipped or replayed. * @param snapshot - The current immutable session snapshot. * @param committed - The committed value (CommittedFormOperation). * @returns The resulting FormSessionSnapshot. * */ export declare function applyCommittedFormOperation(snapshot: FormSessionSnapshot, committed: CommittedFormOperation): FormSessionSnapshot; /** Protocol validation error carrying a machine-readable relay error code. */ export declare class FormProtocolError extends Error { readonly code: string; /** * Creates a form protocol failure with a relay-safe error code. * * @param code - The machine-readable error code. * @param message - The human-readable error message. * */ constructor(code: string, message: string); } //# sourceMappingURL=form-protocol.d.ts.map