import { z } from "zod"; /** * Filter operator vocabulary the LLM may emit. Every operator listed here is * recognised by `applyDrizzleFilters`; carte authors restrict which ones a * given field accepts via `AllowedFilter.operators`. */ export type FilterOperator = "eq" | "neq" | "in" | "nin" | "gt" | "gte" | "lt" | "lte" | "contains" | "startsWith" | "isNull" | "isNotNull"; export type FilterValue = string | number | boolean | string[] | number[] | null; export interface Filter { field: string; op: FilterOperator; /** * Value to compare against. Required for most operators; ignored for * `isNull` and `isNotNull` (which compare structurally). Pass `null` or * omit when using a null operator — the schema accepts either. */ value?: FilterValue; } /** * Carte-author-declared shape: which built-in filters are allowed on a given * query, what type their values must be, and which operators they support. * Typically supplied via `defineParams({ filters: ... })`. Used by both * `parsePlan` (to reject LLM-emitted filters that don't fit) and * `generatePrompt` (to teach the LLM what's available). */ export interface AllowedFilter { type: "string" | "number" | "datetime" | "boolean"; operators: FilterOperator[]; /** Optional human-readable description shown in the prompt. */ description?: string; /** * Case-sensitive matching for `contains` / `startsWith` on string fields. * Default `false` (case-insensitive — uses `ilike`). Has no effect on * non-string types. Worth setting `true` for case-sensitive identifier * fields like `id` columns where "ABC" and "abc" should not match. */ caseSensitive?: boolean; } export type AllowedFilters = Record; export declare const filterSchema: z.ZodType; /** * Sugar for `z.array(filterSchema)`. `defineParams({ filters: ... })` adds this * automatically for built-in filter support. You can still use it directly in * a plain params schema when you want to own filter semantics yourself. */ export declare const filtersParamSchema: z.ZodArray>>; export declare const allowedFilterSchema: z.ZodType; /** * Returns a human-readable error message if `filter` is not allowed under * `allowed`, or `undefined` if it passes. Used by `validatePlan`; also handy * for any custom executor. * * Checks (in order): * 1. The field is in `allowed`. * 2. The operator is in `allowed[field].operators`. * 3. The value type matches `allowed[field].type` (with array-arity rules * for `in` / `nin`). */ export declare function checkFilter(filter: Filter, allowed: AllowedFilters): string | undefined; //# sourceMappingURL=filters.d.ts.map