/**
 * @fileoverview Supabase bulk CRUD handler.
 * @description Thin Supabase RPC adapter on top of the shared `executeBulk`
 *   orchestrator. Assembles a `supabaseAdmin.rpc('crud_bulk', ...)` call as
 *   the target-specific `transact` callback; all other policy (validation,
 *   collision, per-bucket ACL, metadata stamping, audit) lives in
 *   {@link executeBulk} so Firestore, Vercel, GraphQL and future REST-CRUD
 *   server aids share one correctness surface.
 *
 *   The Postgres RPC `crud_bulk` wraps `BEGIN ... COMMIT`, so one RPC call
 *   is one transaction from the client's perspective.
 *
 * @version 0.2.0
 * @since 0.6.0
 * @author AMBROISE PARK Consulting
 */
import * as v from 'valibot';
import type { BulkRequest, EntityAccessConfig } from '@donotdev/core/server';
/** Request payload accepted by the bulk handler — mirrors {@link BulkRequestSchema}. */
export type BulkEntityRequest = BulkRequest;
/**
 * Create a Supabase Edge Function handler for atomic bulk CRUD on one collection.
 *
 * @description
 * One HTTP round-trip, one rate-limit hit, one audit line, one DB transaction.
 * Inserts, updates and deletes run in input order inside the `crud_bulk` RPC
 * which wraps `BEGIN ... COMMIT` — any failure triggers `ROLLBACK` and the
 * client observes a rejected promise with no partial state.
 *
 * The factory returns a handler that is auto-registered as `bulk_${collection}`
 * by {@link createSupabaseCrudFunctions}.
 *
 * @param collection - Postgres table name for the entity.
 * @param createSchema - Valibot schema validating each `inserts[]` row.
 * @param updateSchema - Valibot schema validating each `updates[].patch` object.
 * @param access - Entity access config; per-bucket role check runs before writes.
 * @returns A `(req: Request) => Promise<Response>` handler for `Deno.serve`.
 * @throws BulkCollisionError — via the thrown DoNotDevError when an id appears in two buckets.
 *
 * @example
 * ```typescript
 * // Auto-registration (preferred):
 * import * as entities from '../_shared/entities.ts';
 * import { createSupabaseCrudFunctions } from '@donotdev/functions/supabase';
 * const { serve } = createSupabaseCrudFunctions(entities);
 * Deno.serve(serve);
 * // POST { _functionName: 'bulk_events', inserts: [...], updates: [...], deletes: [...] }
 *
 * // Manual registration:
 * import { createSupabaseBulkEntity } from '@donotdev/functions/supabase';
 * import { eventEntity, eventCreateSchema, eventUpdateSchema } from '../_shared/entities.ts';
 * Deno.serve(createSupabaseBulkEntity(
 *   eventEntity.collection,
 *   eventCreateSchema,
 *   eventUpdateSchema,
 *   eventEntity.access,
 * ));
 * ```
 *
 * @version 0.2.0
 * @since 0.6.0
 */
export declare function createSupabaseBulkEntity(collection: string, createSchema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>, draftCreateSchema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>, updateSchema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>, access: EntityAccessConfig): (req: Request) => Promise<Response>;
