import { TAtscriptAnnotatedType, TAtscriptTypeArray, TAtscriptTypeObject, TValidatorPlugin, Validator } from "@atscript/typescript/utils"; //#region src/patch/patch-types.d.ts interface TArrayPatch { $replace?: A; $insert?: A; $upsert?: A; $update?: Array>>; $remove?: Array>>; } type TArrayElement = ArrayType extends ReadonlyArray ? ElementType : never; /** * Maps each property of T into a patch payload: * - Array properties become `TArrayPatch` * - Non-array properties become `Partial` */ type TDbPatch = { [K in keyof T]?: T[K] extends Array ? TArrayPatch : Partial }; /** * Extracts `@expect.array.key` properties from an array-of-objects type. * These keys uniquely identify an element inside the array and are used * for `$update`, `$remove`, and `$upsert` operations. * * @param def - Atscript array type definition. * @returns Set of property names marked as keys; empty set if none. */ declare function getKeyProps(def: TAtscriptAnnotatedType): Set; //#endregion //#region src/validator.d.ts /** Write operation mode for validator configuration. */ type ValidatorMode = "insert" | "patch" | "replace"; /** Singleton db validator plugin — stateless, safe to share across all validators. */ declare const dbPlugin: TValidatorPlugin; /** * Builds a validator for a given write mode. * * Shared between server-side (`AtscriptDbTable`) and client-side (`ClientValidator`). * Both use the same plugin, same `replace`, same `partial` logic. * * @param type - The annotated type to validate against. * @param mode - The write operation mode. * @param extraPlugins - Additional adapter-specific plugins (prepended before the db plugin). */ declare function buildDbValidator(type: TAtscriptAnnotatedType, mode: ValidatorMode, extraPlugins?: TValidatorPlugin[]): Validator; /** Returns true if the annotated type is a navigation relation (TO/FROM/VIA). */ declare function isNavRelation(type: TAtscriptAnnotatedType): boolean; /** * Forces nav fields non-optional so the plugin handles null/undefined checks. * The Validator caches replace results internally, so this allocates at most once per type node. */ declare function forceNavNonOptional(type: TAtscriptAnnotatedType): TAtscriptAnnotatedType; /** Result of {@link buildValidationContext}. */ interface ValidationContext { /** Flat map of dotted field paths → annotated types (same shape the server builds). */ flatMap: Map; /** Set of field paths that are navigation relations (TO/FROM/VIA). */ navFields: ReadonlySet; } /** * Builds a lightweight validation context from a deserialized Atscript type. * * This is the client-side equivalent of the server's `TableMetadata.build()`, * without any adapter-specific processing (physical columns, index resolution, etc.). * * @param type - A deserialized annotated type (from `deserializeAnnotatedType(meta.type)`). * @returns `flatMap` and `navFields` suitable for passing to `createDbValidatorPlugin` via `DbValidationContext`. */ declare function buildValidationContext(type: TAtscriptAnnotatedType): ValidationContext; //#endregion export { dbPlugin as a, TArrayPatch as c, buildValidationContext as i, TDbPatch as l, ValidatorMode as n, forceNavNonOptional as o, buildDbValidator as r, isNavRelation as s, ValidationContext as t, getKeyProps as u };