import type { RouteDefinition } from "../../core/src/index.js"; import type { DiscoveredModel } from "./model.js"; /** * Auto-CRUD — discovers ORM models and auto-generates REST endpoints. * * Generated endpoints per model: * GET /api/{table} — list with pagination, filtering, sorting * GET /api/{table}/{id} — get single record * POST /api/{table} — create record * PUT /api/{table}/{id} — update record * DELETE /api/{table}/{id} — delete record */ /** * Options accepted by the AutoCrud registration API. * * `public` is the cross-backend escape hatch (parity with python's `public=True` * and php's `bool $public`). Write routes (POST/PUT/DELETE) are secure-by-default * — the router gates them unless a def sets `secure: false`. Set `public: true` * to open the generated write routes explicitly. Reads (GET) are always public. */ export interface AutoCrudOptions { /** When true, the generated write routes (POST/PUT/DELETE) are OPEN (secure:false). Default false → secure. */ public?: boolean; } export declare class AutoCrud { private static registered; /** tableName -> public-writes flag (default secure); mirrors php's `$this->public`. */ private static publicWrites; /** * Register a model for auto-CRUD. * * @param options.public If true, the generated write routes are OPEN (no auth). * Default (false) keeps them secure-by-default, matching the framework's write gate. */ static register(model: DiscoveredModel, prefix?: string, options?: AutoCrudOptions): void; /** * Discover models from the provided array and register them. * (In Node.js, models are discovered by the server and passed in.) */ static discover(discoveredModels: DiscoveredModel[], prefix?: string, options?: AutoCrudOptions): string[]; /** * Return all registered models. */ static models(): Map; /** * Clear all registered models (useful for testing). */ static clear(): void; /** * Generate route definitions for all registered models, honouring each * model's per-table `public` flag (set at register/discover time). */ static generateRoutes(): RouteDefinition[]; } /** * Filter discovered models down to those that explicitly opted into auto-CRUD via * `static autoCrud = true` (the documented opt-in gate; default false). The server * passes only these to generateCrudRoutes, so a model without the flag gets no CRUD * endpoints. Exported so the opt-in gate is locked in by a test rather than * re-implemented at each call site. */ export declare function crudEligibleModels(models: DiscoveredModel[]): DiscoveredModel[]; /** * Generate CRUD route definitions for the given models. * (Standalone function for backward compatibility.) * * @param options.public When true, the generated write routes (POST/PUT/DELETE) * opt OUT of the router's secure-by-default write gate (`secure: false`) — the * cross-backend escape hatch (parity with python `public=True` / php `$public`). * Default (false) leaves `secure` unset so the router gates writes (secure:true). * GET routes are unaffected (reads are already public). */ export declare function generateCrudRoutes(models: DiscoveredModel[], options?: AutoCrudOptions): RouteDefinition[];