/** * Internal contracts shared by the mapped persistence modules. * * Public flush options are kept here as well so the coordinator entrypoint can * stay focused on orchestration while row, projection, and SQL helpers share a * single set of contracts. */ import type { RegisteredSyncProjectionDefinition } from "../../../contracts/sheets/sheetsProvisioning.js"; import type { SyncTimingSink } from "../../../contracts/shared/observability/syncTiming.js"; import type { TypedSheetsEntityWriterOptions } from "../../../contracts/sync-orm/writer.js"; import type { CanonicalCommitInput, CanonicalFieldWrite } from "../../../storage/state/canonical/canonicalCommit.js"; import type { FencingContext, NewEffect } from "@hikoutei/ikisaki"; import type { RegisteredSyncSheet } from "../../../storage/sync/shared/syncRegistry.js"; import type { SqlExecutor, SqlStorageAdapter } from "../../../contracts/storage/sql.js"; import type { ScalarEntityFlushChange, ScalarEntityFlushContext, ScalarEntityFlushCoordinator } from "../../../contracts/storage/scalar.js"; import type { TypedSheetsEntityFieldMapping, TypedSheetsEntityMapping, TypedSheetsEntityMappingRegistry } from "../../mapping/contracts.js"; export type { TypedSheetsEntityWriterOptions }; /** Default lease role used by mapped entity writes. */ export declare const DEFAULT_MAPPED_WRITER_ROLE = "typed-sheets-entity-writer"; /** Default lease duration used by mapped entity writes. */ export declare const DEFAULT_MAPPED_WRITER_LEASE_DURATION_MS = 60000; /** Effect target kinds emitted by mapped entity persistence. */ export declare const MAPPED_EFFECT_TARGET_KINDS: { readonly ENTITY: "entity"; readonly PROJECTION_ROW: "projection_row"; }; /** Effect lifecycle states read while deriving the next projection baseline. */ export declare const MAPPED_EFFECT_STATUSES: { readonly PENDING: "pending"; readonly PROCESSING: "processing"; readonly APPLIED: "applied"; }; /** Options for deriving a built-in flush coordinator from mapping metadata. */ export interface CreateMappedTypedSheetsFlushCoordinatorOptions { readonly mappings: TypedSheetsEntityMappingRegistry | readonly TypedSheetsEntityMapping[]; readonly writer: TypedSheetsEntityWriterOptions; /** * Internal sync behavior injected after each mapped flush commit. * * The callback runs inside the same SQLite transaction as the entity, * canonical, and outbox writes so NEEDS_REBASE auditing and implicit * system-wins resolution stay atomic with the flush. It is service-side * only and never part of the root application contract. */ readonly syncFlushHook?: MappedFlushSyncHook; } /** One committed mapped flush result handed to the internal sync hook. */ export interface MappedFlushSyncPlan { readonly mapping: TypedSheetsEntityMapping; readonly change: ScalarEntityFlushChange; readonly changedFields: readonly TypedSheetsEntityFieldMapping[]; readonly entityId: string; readonly rowBindingId: string; readonly commitId: string; /** True when an active row candidate suppressed the User_Input projection. */ readonly suppressedUserProjection: boolean; } /** * Internal flush/runtime callback contract injected by the sync service. * * The hook may plan conflict audits and resolutions but never changes the * public ORM surface; `src/index.ts` does not expose it. */ export type MappedFlushSyncHook = (input: { readonly sql: SqlExecutor; readonly fence: FencingContext; readonly writer: ResolvedWriterOptions; readonly plan: MappedFlushSyncPlan; }) => Promise; /** A registered route with headers ready for provider-side provisioning. */ export interface RegisteredTypedSheetsMappedProjection { readonly mapping: TypedSheetsEntityMapping; readonly sheet: RegisteredSyncSheet; readonly headers: readonly string[]; } /** Normalized writer options used by all persistence helpers. */ export interface ResolvedWriterOptions { readonly writerId: string; readonly role: string; readonly leaseDurationMs: number; readonly now: () => number; readonly createId: () => string; readonly onTiming: SyncTimingSink | undefined; /** See {@link TypedSheetsEntityWriterOptions.onStartupLeaseWait}. */ readonly onStartupLeaseWait?: () => void; } /** Confirmed or queued baseline used when creating the next projection effect. */ export interface ProjectionBaseline { readonly expectedVisibleRevision: number; readonly expectedVisibleHash: string; readonly createIfMissing: boolean; readonly streamSequence: number; } /** One validated mapped entity lifecycle change and its selected fields. */ export interface MappedChangePlan { readonly mapping: TypedSheetsEntityMapping; readonly change: ScalarEntityFlushChange; readonly changedFields: readonly TypedSheetsEntityFieldMapping[]; } /** Provider-neutral coordinator shape used by the scalar persistence provider. */ export type { ScalarEntityFlushCoordinator as TypedSheetsFlushCoordinator, ScalarEntityFlushContext as TypedSheetsFlushContext, }; /** Keeps the API imports used by persistence modules explicit in one contract file. */ export type { CanonicalCommitInput, CanonicalFieldWrite, FencingContext, NewEffect, RegisteredSyncProjectionDefinition, RegisteredSyncSheet, SqlExecutor, SqlStorageAdapter, }; export type { ScalarEntityFlushChange, ScalarEntityFlushContext, ScalarEntityFlushCoordinator, }; //# sourceMappingURL=contracts.d.ts.map