import type { RagStore } from "./types.js"; export type UploadAuthorizationResult = boolean | Response; export type UploadAuthorize = (request: Request) => UploadAuthorizationResult | Promise; export type UploadHandlerAuthConfig = { type: "none"; allowUnauthenticated: true; } | { authorize: UploadAuthorize; }; export interface UploadHandlerConfig { maxFileSize?: number; auth: UploadHandlerAuthConfig; } /** * Creates HTTP route handlers for upload, listing, and deletion. * * Pass `auth: { authorize }` to protect these handlers before they read * request bodies or access the RAG store. For local development, pass * `auth: { type: "none", allowUnauthenticated: true }` to explicitly allow * unauthenticated upload routes. Omitting `auth` is rejected during handler * construction so a missing configuration cannot expose an upload endpoint. * * Returns `{ POST, GET, DELETE }` handlers compatible with file-based routing. * POST accepts multipart form data with a `file` field, extracts text via * `loadUpload`, and ingests into the provided RAG store. When Veryfront Cloud * bootstrap is present, the original binary is also stored in the project's * uploads store via the cloud adapter. GET returns the upload list. DELETE * removes an upload by ID from the `id` query parameter or route params. * * @example * ```ts * // app/api/uploads/route.ts * import { createUploadHandler } from "veryfront/embedding"; * import { getEnv } from "veryfront"; * import { store } from "lib/store.ts"; * * export const { POST, GET, DELETE } = createUploadHandler(store, { * auth: { * authorize: (request) => { * const token = getEnv("UPLOAD_TOKEN"); * return token !== undefined && * request.headers.get("authorization") === `Bearer ${token}`; * }, * }, * }); * ``` */ export declare function createUploadHandler(store: RagStore, config: UploadHandlerConfig): { POST: (request: Request) => Promise; GET: (request?: Request) => Promise; DELETE: (request: Request, context?: { params?: Record; }) => Promise; }; //# sourceMappingURL=upload-handler.d.ts.map