import * as v from 'valibot';
import type { UserRole, SecurityContext } from '@donotdev/core/server';
import type { SupabaseClient } from '@supabase/supabase-js';
/**
 * Context passed to Supabase Edge Function business logic
 *
 * @version 0.1.0
 * @since 0.5.0
 */
export interface SupabaseHandlerContext {
    /** Authenticated user ID (from JWT verification) */
    uid: string;
    /** User role extracted from app_metadata.role */
    userRole: UserRole;
    /** Supabase admin client (service role — full access) */
    supabaseAdmin: SupabaseClient;
}
/**
 * Create a Supabase Edge Function handler with built-in auth, validation, role checking, and error handling.
 *
 * @param operationName - Operation name for logging
 * @param schema - Valibot schema for request body validation
 * @param handler - Business logic function
 * @param requiredRole - Minimum role required (default: 'user')
 * @returns A `(req: Request) => Promise<Response>` handler for Deno.serve
 *
 * @example
 * ```typescript
 * import * as v from 'valibot';
 * import { createSupabaseHandler } from '@donotdev/functions/supabase';
 *
 * const schema = v.object({ userId: v.string() });
 *
 * export default createSupabaseHandler('delete-account', schema, async (data, ctx) => {
 *   await ctx.supabaseAdmin.auth.admin.deleteUser(data.userId);
 *   return { success: true };
 * }, 'admin');
 * ```
 *
 * @version 0.1.0
 * @since 0.5.0
 */
export declare function createSupabaseHandler<TReq, TRes>(operationName: string, schema: v.BaseSchema<unknown, TReq, v.BaseIssue<unknown>>, handler: (data: TReq, context: SupabaseHandlerContext) => Promise<TRes>, requiredRole?: UserRole, security?: SecurityContext): (req: Request) => Promise<Response>;
