import { SynthOSConfig } from '../init'; /** * Schema sidecar IO + additive-merge logic. Used by both shared-table and * per-page-table routes — the only difference is the parent folder where the * `.schema.json` file lives. * * Spec: docs/specs/shared-tables-schema-sidecar.md */ export interface SchemaWrapper { version: number; schema: Record; createdAt: string; updatedAt: string; definedBy?: string; } export type MergeMode = 'additive' | 'replace'; export interface MergeConflict { field: string; existing: unknown; incoming: unknown; } /** Sidecar file path: `/
.schema.json`. */ export declare function schemaFile(parent: string, table: string): string; /** Load the wrapper. Returns undefined if missing or unparsable. */ export declare function loadSchema(config: SynthOSConfig, parent: string, table: string): Promise; /** Persist a wrapper to disk. */ export declare function saveSchema(config: SynthOSConfig, parent: string, table: string, wrapper: SchemaWrapper): Promise; /** Delete the schema sidecar. No-op if it doesn't exist. */ export declare function deleteSchema(config: SynthOSConfig, parent: string, table: string): Promise; /** * Apply `incoming` against `existing` per `mode`: * - 'replace' → drop existing entirely; incoming wins. * - 'additive' → union of `properties` (existing wins on overlap if types match; * conflicting types reported via `conflicts`); union of `required`. * * Returns the merged schema and any conflicts. On conflict, callers should * surface them as a 409 and NOT persist the result. */ export declare function mergeSchema(existing: Record | undefined, incoming: Record, mode: MergeMode): { merged: Record; conflicts: MergeConflict[]; }; /** * Validate the structural shape of an incoming JSON Schema. Strict-mode * validation against the meta-schema is out of scope; we only check that the * payload is a plain object so we don't persist garbage. */ export declare function isValidSchemaPayload(s: unknown): s is Record; /** * Build a SchemaWrapper from a plain JSON Schema, using `now` for both * timestamps when no existing wrapper is being preserved. */ export declare function newSchemaWrapper(schema: Record, now: string, definedBy?: string): SchemaWrapper; /** * Update an existing wrapper, preserving createdAt and bumping updatedAt. */ export declare function updateSchemaWrapper(existing: SchemaWrapper, schema: Record, now: string, definedBy?: string): SchemaWrapper; /** * Enumerate tables in a namespace folder. A "table" is either: * - a subfolder containing record files, OR * - a `.schema.json` sidecar (table may be schemaless until first save). * * Returns one entry per unique table name, with hasSchema + recordCount. * * `reserved` filters out names that occupy the namespace for non-table use * (e.g. `files`, the per-page uploads folder). */ export declare function listTables(config: SynthOSConfig, parent: string, reserved?: ReadonlySet): Promise>; //# sourceMappingURL=sharedTableSchema.d.ts.map