import type { FilterSchema } from '../types'; /** * Column mapping - maps public field names to internal DB column names */ export type ColumnMapping = Record; /** * JSONB path mapping - maps public field names to JSONB paths */ export type JsonPathMapping = Record; /** * Expression mapping for computed fields */ export type ExpressionMapping = Record; /** * Combined field mapping configuration */ export interface FieldMappingConfig { /** Map field name -> DB column name */ columns?: ColumnMapping; /** Map field name -> JSONB path expression */ jsonPaths?: JsonPathMapping; /** Map field name -> computed expression (field becomes computed) */ expressions?: ExpressionMapping; } /** * Apply column mapping to a public schema * This keeps the public schema clean (for sending to FE) while adding * internal DB column mappings on the backend. * * @example * ```typescript * const publicSchema = { * fields: { * tags: { type: 'array', operators: ['contains'] }, * authorName: { type: 'string', operators: ['eq'] }, * }, * }; * * const mapping = { * tags: '_tags', * authorName: { table: 'authors', column: 'name' }, * }; * * const fullSchema = applyColumnMapping(publicSchema, mapping); * // Result: * // tags.column = '_tags' * // authorName.column = 'authors.name' (logic in sanitizer escapes this correctly) * ``` */ export declare function applyColumnMapping(schema: FilterSchema, mapping: ColumnMapping): FilterSchema; /** * Apply JSONB path mapping to a public schema * * @example * ```typescript * const publicSchema = { * fields: { * 'metadata.priority': { type: 'string', operators: ['eq'] }, * }, * }; * * const mapping = { * 'metadata.priority': "data->>'priority'", * }; * * const fullSchema = applyJsonPathMapping(publicSchema, mapping); * ``` */ export declare function applyJsonPathMapping(schema: FilterSchema, mapping: JsonPathMapping): FilterSchema; /** * Apply all field mappings at once * * @example * ```typescript * const publicSchema = { * fields: { * tags: { type: 'array', operators: ['contains'] }, * priority: { type: 'string', operators: ['eq'] }, * fullName: { type: 'string', operators: ['ilike'] }, * }, * }; * * const fullSchema = applyFieldMappings(publicSchema, { * columns: { tags: '_tags' }, * jsonPaths: { priority: "metadata->>'priority'" }, * expressions: { fullName: "first_name || ' ' || last_name" }, * }); * ``` */ export declare function applyFieldMappings(schema: FilterSchema, config: FieldMappingConfig): FilterSchema; /** * Strip internal mapping fields from schema for sending to frontend * Removes: column, jsonPath, expression, computed * * @example * ```typescript * const fullSchema = { ... }; // Has column mappings * const publicSchema = toPublicSchema(fullSchema); * // Send publicSchema to frontend * ``` */ export declare function toPublicSchema(schema: FilterSchema): FilterSchema; //# sourceMappingURL=schema-mapping.d.ts.map