import { JsonFormsCore, JsonSchema, Layout } from '../../.external/lib/@jsonforms/core'; export type { JsonSchema, Layout, UISchemaElement } from '../../.external/lib/@jsonforms/core'; /** The backend `PRIMARY_KEY` alias. */ export type PrimaryKey = number | string | string[]; /** A relationship reference (`RelInfo`). */ export interface RelInfo { id: PrimaryKey; value: string; } /** Column metadata in an `/_info` payload (`ColumnInfo`). */ export interface ColumnInfo { description: string; label: string; name: string; required: boolean; type: string; unique: boolean; } /** A column whose values come from a fixed enum (`ColumnEnumInfo`). */ export interface ColumnEnumInfo extends ColumnInfo { values: (string | number)[]; } /** A column backed by a relationship (`ColumnRelationInfo`). */ export interface ColumnRelationInfo extends ColumnInfo { count: number; values: RelInfo[]; } /** A single column filter operator entry inside an `/_info.filters[col]` payload (`SearchFilter`). */ export interface ColumnFilterOperator { /** The display name of the filter (e.g., 'Equal to', 'Greater than'). */ name: string; /** The operator key forwarded to the backend (e.g., 'eq', 'gt'). */ operator: string; } /** The `/_info` payload (`InfoResponse`). */ export interface InfoResponse { add_columns: AnyColumnInfo[]; add_title: string; add_schema: JsonSchema; add_uischema: Layout | null; add_translations: { [locale: string]: { [key: string]: string; }; } | null; add_type: 'json' | 'form'; edit_columns: AnyColumnInfo[]; edit_title: string; edit_schema: JsonSchema; edit_uischema: Layout | null; edit_translations: { [locale: string]: { [key: string]: string; }; } | null; edit_type: 'json' | 'form'; filters: { [column: string]: FilterInfo; }; filter_options: Record; permissions: string[]; relations: string[]; } /** Fields shared by every CRUD response (`BaseResponse`). */ export interface BaseResponse { description_columns: { [column: string]: string; }; label_columns: { [column: string]: string; }; } /** A single-item (show) response (`BaseResponseSingle`). */ export interface BaseResponseSingle extends BaseResponse { id: PrimaryKey; show_columns: string[]; show_title: string; result: ResultRow | null; } /** A multi-item (list) response (`BaseResponseMany`). */ export interface BaseResponseMany extends BaseResponse { count: number | null; ids: PrimaryKey[]; list_columns: string[]; list_title: string; order_columns: string[]; result: ResultRow[] | null; } /** A plain detail message response (`GeneralResponse`). */ export interface GeneralResponse { detail: string; } /** A column-less filter (`OprFilterSchema`): operator + value, no column name. */ export interface OprFilterSchema { opr: string; value: PrimaryKey | boolean | Record | (PrimaryKey | boolean | Record)[]; } /** A single column filter (`FilterSchema`); `OprFilterSchema` plus the column name. */ export interface FilterSchema extends OprFilterSchema { col: string; } /** The list/show query parameters as sent over the wire (`QuerySchema`); array fields are JSON-encoded strings. */ export interface QuerySchema { page: number; page_size: number | null; order_column: string | null; order_direction: 'asc' | 'desc' | null; columns: string; filters: string; opr_filters: string; global_filter: string | null; with_count: boolean; q: string | null; } /** The query parameters when sent in a request body (`QueryBody`); `filters` is a structured list, not a JSON string. */ export interface QueryBody extends Omit { filters: FilterSchema[]; } /** Union of every `/_info` column metadata variant (derived helper). */ export type AnyColumnInfo = ColumnInfo | ColumnEnumInfo | ColumnRelationInfo; /** The structured per-column filter metadata served at `/_info.filters[col]` (ad-hoc backend dict, not a `schemas.py` class). */ export interface FilterInfo { /** The available filter operators for the column. */ filters: ColumnFilterOperator[]; /** The human-readable label for the column. */ label: string; /** The column metadata (mirrors the column's entry in `add_columns` / `edit_columns`). */ schema: AnyColumnInfo; } /** One entry of the `GET /info/` response (`InfoApi.get_info`): metadata for an exposed API, used to build the app menu. Ad-hoc backend dict, not a `schemas.py` class. */ export interface AppApiInfo { name: string; icon: string; permission_name: string; path: string; type: 'table' | 'default'; level: 'security' | 'default'; } /** A single CRUD result row, keyed by per-model column name; cell values vary per column type and are model-driven at runtime. */ export type ResultRow = Record; /** A converted add/edit column group derived from the `/_info` payload (`ConvertedColumnGroup`). */ export interface ConvertedColumnGroup { columns: AnyColumnInfo[]; title: string; schema: TSchema; defaultValues: ResultRow; } /** The `/_info` payload augmented with derived add/edit form metadata (`ConvertedInfo`). */ export type ConvertedInfo = InfoResponse & { add: ConvertedColumnGroup; edit: ConvertedColumnGroup; }; /** A single structured filter in a query bag, before serialization to the wire `filters` JSON string. */ export interface QueryFilter { col: string; opr: string; value: any; } /** * A mutable bag of list/show query parameters, merged across renders and serialized by * `createFetchParams`. The frontend pre-serialization counterpart of the backend `QuerySchema` * (`py/fastapi_rtk/schemas.py`): the array / scalar values here are JSON-encoded onto the wire. * All fields optional because callers patch a subset per render. The CSV-download keys * (`check_validity`, `label`, `export_mode`, `delimiter`, `quotechar`) are added by `downloadItems`. */ export type QueryParams = Partial<{ page: number; page_size: number; order_column: string | null; order_direction: 'asc' | 'desc' | null; columns: string[]; filters: QueryFilter[]; opr_filters: Omit[]; global_filter: string; with_count: boolean; q: string; streaming: boolean; check_validity: boolean; label: string; export_mode: string; delimiter: string; quotechar: string; }>; /** A list-data page used by the non-streaming data query: a `BaseResponseMany` plus the client-injected request context. */ export type DataPage = BaseResponseMany & { path?: string; queryParams?: QueryParams; }; /** A single fetched page of streaming data. */ export interface StreamingPage { result: ResultRow[]; ids: PrimaryKey[]; queryParams?: QueryParams; path?: string; } /** A single AJV validation error from JsonForms' `onChange` (ajv `ErrorObject`, surfaced via `@jsonforms/core`). */ export type ValidationError = NonNullable[number];