import type { AnyVersionChainBuilder, CreateFactory, DocumentDefinition, EnvelopeOptions, VersionChainContext, VersionChainVersions, LatestPayload, NormalizeEnvelopeKeys } from "./types.js"; /** * Options accepted by {@link defineDocument}. * * @typeParam TVersionChain - Fluent version-chain builder. * @typeParam TType - Durable document type string. * @typeParam TContext - Migration context type. * @typeParam TEnvelope - Optional custom envelope key configuration. */ export type DefineDocumentOptions, TEnvelope extends EnvelopeOptions | undefined = undefined> = { /** Durable document type string stored in persisted envelopes. */ readonly type: TType; /** Linear version chain produced by {@link version}. */ readonly versions: TVersionChain; /** * Factory for creating a new latest-version payload. * * @remarks * The factory may accept application-defined arguments. Those argument types * are preserved on the returned document's `create` method. * * The returned value is validated against the latest schema when * {@link DocumentDefinition.create} is called. */ readonly create?: CreateFactory>>; /** * Default context object passed to migrations. * * @remarks * Operation-level context passed to `decode` overrides this value. */ readonly context?: TContext; /** Optional custom persisted envelope key names. */ readonly envelope?: TEnvelope; /** * Validate each migration output before continuing to the next step. * * @defaultValue true */ readonly validateAfterMigration?: boolean; /** * Validate the starting payload before running migrations. * * @defaultValue true */ readonly validateBeforeMigration?: boolean; }; /** * Compile a version chain into a document definition. * * @remarks * The returned definition owns envelope parsing, version dispatch, payload * validation, migration execution, encoding, metadata inspection, and type * inference. User schemas validate only payload data. * * @example * ```ts * const BoardDocument = defineDocument({ * type: "tasks.board", * versions: version(1, BoardV1) * .becomes(2, BoardV2, migrateV1ToV2) * .becomes(3, BoardV3, migrateV2ToV3), * create: () => ({ columns: [], cards: {}, archivedCardIds: [] }), * }); * ``` * * @typeParam TType - Durable document type string. * @typeParam TVersionChain - Fluent version-chain builder. * @typeParam TContext - Migration context type. * @typeParam TEnvelope - Optional custom envelope key configuration. */ export declare function defineDocument>>, TContext = VersionChainContext, const TEnvelope extends EnvelopeOptions | undefined = undefined>(options: DefineDocumentOptions & { readonly create: TCreate; }): DocumentDefinition, TContext, NormalizeEnvelopeKeys, TCreate>; export declare function defineDocument, const TEnvelope extends EnvelopeOptions | undefined = undefined>(options: Omit, "create"> & { readonly create?: never; }): DocumentDefinition, TContext, NormalizeEnvelopeKeys, undefined>; //# sourceMappingURL=document.d.ts.map