import type { SupabaseClient } from '@supabase/supabase-js';
/**
 * Context passed to edge function handlers.
 *
 * @version 0.1.0
 * @since 0.6.0
 */
export interface EdgeFunctionContext {
    /** Authenticated user (null if no valid JWT or requireAuth=false) */
    user: {
        id: string;
        email?: string;
    } | null;
    /** Admin client (service role, bypasses RLS) - always available */
    supabaseAdmin: SupabaseClient;
    /** User-scoped client (RLS) - null if no valid JWT */
    userClient: SupabaseClient | null;
    /** JSON response with CORS headers */
    json: (data: unknown, status?: number) => Response;
    /** JSON error response: { error: message } with CORS headers */
    error: (message: string, status?: number) => Response;
    /** Raw response with CORS headers (for structured payloads) */
    respond: (data: unknown, status: number) => Response;
}
/** Configuration options for edge function creation. */
export interface EdgeFunctionOptions {
    /** Require JWT auth - returns 401 if missing/invalid (default: true) */
    requireAuth?: boolean;
    /** Extra CORS allowed headers (e.g., 'stripe-signature', 'x-build-secret') */
    extraHeaders?: string[];
}
/**
 * Create a Supabase Edge Function handler with CORS, optional auth, and response helpers.
 *
 * @example
 * ```typescript
 * // Auth required (default)
 * Deno.serve(createEdgeFunction(async (req, ctx) => {
 *   const body = await req.json();
 *   return ctx.json({ result: 'ok' });
 * }));
 *
 * // No auth (public endpoint)
 * Deno.serve(createEdgeFunction(async (req, ctx) => {
 *   return ctx.json({ public: true });
 * }, { requireAuth: false }));
 *
 * // Custom auth (webhook)
 * Deno.serve(createEdgeFunction(async (req, ctx) => {
 *   const sig = req.headers.get('stripe-signature');
 *   if (!sig) return ctx.error('Missing signature', 401);
 *   return ctx.json({ received: true });
 * }, { requireAuth: false, extraHeaders: ['stripe-signature'] }));
 * ```
 */
export declare function createEdgeFunction(handler: (req: Request, ctx: EdgeFunctionContext) => Promise<Response>, options?: EdgeFunctionOptions): (req: Request) => Promise<Response>;
