/** * Runtime introspection — builds collections in memory from the live database. * * This is what makes BaaS mode work with zero configuration: instead of loading * collection files from disk, the server reads `information_schema` at boot and * derives a collection per table, so any database is served over REST without a * single config file. * * Distinct from `introspect-db.ts`, which runs the same queries but emits * TypeScript *source* for a developer to edit and commit (declared collections). The two * share the mapping helpers in `introspect-db-logic.ts` so a table is described * the same way whether it was generated or introspected. */ import type { PostgresCollectionConfig } from "@rebasepro/types"; import { TableMeta } from "./introspect-db-logic"; export interface IntrospectedSchema { tablesMap: Map; enumMap: Map; joinTables: Set; } /** Whether a table carries an authorization model of its own. */ export interface TableRlsStatus { table: string; /** ALTER TABLE … ENABLE ROW LEVEL SECURITY has been run. */ rlsEnabled: boolean; /** Policies attached to it. RLS enabled with none = nothing is visible. */ policyCount: number; } /** * Read the RLS posture of each table in a schema. * * This is what decides whether baas mode may serve a table. A table with RLS * disabled has no authorization model: since every authenticated request runs * as `rebase_user`, and that role is granted DML on the schema, serving such a * table hands every row to every logged-in user. */ export declare function readRlsStatus(client: Queryable, pgSchema: string): Promise>; /** Minimal query surface — satisfied by pg.Client and pg.Pool alike. */ export interface Queryable { query(text: string, values?: unknown[]): Promise<{ rows: R[]; }>; } /** * Read tables, columns, enums, primary keys and foreign keys for a schema. * Mirrors the queries in introspect-db.ts. */ export declare function introspectSchema(client: Queryable, pgSchema: string): Promise; /** * Turn an introspected schema into collections. * * Join tables are skipped: they carry no identity of their own and exist to * express a many-to-many edge between two other tables. */ export declare function buildCollectionsFromSchema({ tablesMap, enumMap, joinTables }: IntrospectedSchema, pgSchema: string): PostgresCollectionConfig[]; /** Introspect the database and return ready-to-serve collections. */ export declare function introspectCollections(client: Queryable, pgSchema: string): Promise;