/** * Declarative, dependency-free row schemas keyed by table. The engine validates * a mutation's writes against the schema before they're persisted (a bad write * is rejected, like a permission deny), and lazily **migrates** rows on read — * so changing a shape needs no up-front database migration. Field validators are * plain `(value) => boolean` functions; the `field` kit covers the common cases. */ /** Validates one field's value. Optionality is encoded by the validator (see `field.optional`). */ export type FieldValidator = (value: unknown) => boolean; export type TableSchema = { /** Per-field validators. On insert every field is checked; on update, only * the fields present in the payload. Extra fields not listed here are allowed. */ fields: Record; /** Schema version, for documentation/migration bookkeeping. Default 1. */ version?: number; /** Upcast a stored/raw row to the current shape — applied lazily on reads. */ migrate?: (row: Row) => Row; }; /** A `table` → {@link TableSchema} map. */ export type SchemaDefinition = Record>; /** * Define table schemas. Identity at runtime (for type inference). Pass to * `createSyncEngine({ schemas })` or register with `engine.registerSchema`. */ export declare const defineSchema: (schemas: S) => S; /** A small validator kit. Compose with `field.optional` / `field.array` / `field.enum`. */ export declare const field: { string: FieldValidator; number: FieldValidator; boolean: FieldValidator; /** Any defined value. */ any: FieldValidator; /** Allow `undefined` (the field may be omitted), else delegate to `inner`. */ optional: (inner: FieldValidator) => FieldValidator; /** An array whose every element satisfies `inner`. */ array: (inner: FieldValidator) => FieldValidator; /** One of the given literal values. */ enum: (...values: unknown[]) => FieldValidator; };