import { Hono } from "hono"; import { AuthAdapter, DataDriver, CollectionConfig } from "@rebasepro/types"; import { HonoEnv } from "../types"; /** * Lightweight REST API generator that leverages existing Rebase DataDriver. * Supports `include` query parameter for eager-loading relations via Drizzle. */ export declare class RestApiGenerator { private collections; private router; private driver; private authAdapter?; constructor(collections: CollectionConfig[], driver: DataDriver, authAdapter?: AuthAdapter); /** * Generate REST routes using existing DataDriver */ generateRoutes(): Hono; /** * Check API key permissions for a collection operation. * Throws 403 if the key doesn't have the required permission. * No-ops if the request is not authenticated via an API key. */ private enforceApiKeyPermission; /** * Get the request-scoped driver. Throws if none is set — never falls * back to the unscoped `this.driver` to avoid bypassing RLS/auth. */ private getScopedDriver; /** * Create REST routes for a collection using existing Rebase patterns */ private createCollectionRoutes; /** * Catch-all routes for subcollection paths. * * Matches URL patterns like: * GET /authors/111094/posts → list child collection * GET /authors/111094/posts/43 → get child entity * POST /authors/111094/posts → create child entity * PUT /authors/111094/posts/43 → update child entity * DELETE /authors/111094/posts/43 → delete child entity * * The `:rest{.+}` regex param captures the full remainder of the URL * path (Hono v4 `*` wildcard does not populate `c.req.param("*")`). * We split it into segments and reconstruct the `collectionPath` * (e.g. "authors/111094/posts") and optional `id` (e.g. "43"). * * The DataDriver.save / fetchCollection / etc. already know how to * resolve multi-segment relation paths, so we just forward to them. */ private createSubcollectionRoutes; /** * Format successful API response */ private formatResponse; /** * Fetch raw collection data without Entity wrapper (fallback for non-Postgres) */ private fetchRawCollection; /** * Count raw entities for a collection */ private countRawEntities; /** * Fetch single entity raw data without Entity wrapper (fallback) */ private fetchRawEntity; }