import * as v from 'valibot';
import type { BulkRequest, BulkResponse, UserRole } from '@donotdev/core/server';
import type { CallableFunction, CallableRequest } from 'firebase-functions/v2/https';
/**
 * Request type for the bulk endpoint. Identical to the wire schema; kept as a
 * named alias for parity with `CreateEntityRequest`, `UpdateEntityRequest`, etc.
 */
export type BulkEntityRequest = BulkRequest;
/**
 * Per-operation access split. The three write access roles are passed
 * individually so the factory can enforce them independently when a request
 * mixes op kinds (e.g. only the delete bucket fails ACL).
 */
interface BulkAccess {
    /** Minimum role to insert into the collection. */
    create: UserRole;
    /** Minimum role to update existing rows. */
    update: UserRole;
    /** Minimum role to delete rows. */
    delete: UserRole;
}
/**
 * Build the business-logic function consumed by {@link createBaseFunction}.
 *
 * Exported for unit testing only — the public entry is {@link bulkEntity}
 * which wraps this factory with auth, role, rate-limit, and schema
 * validation at the transport boundary.
 *
 * The logic itself is a pure delegation to {@link executeBulk}; the only
 * Firestore-specific code lives inside the `transact` closure which issues
 * `tx.set / tx.update / tx.delete` on pre-minted `doc()` references.
 *
 * @internal
 *
 * @example
 * ```typescript
 * const logic = bulkEntityLogicFactory('cars', createSchema, updateSchema, {
 *   create: 'user', update: 'user', delete: 'admin',
 * });
 * await logic({ inserts: [{ name: 'a' }] }, { uid: 'u', userRole: 'user', request: req });
 * ```
 *
 * @version 0.2.0
 * @since 0.2.0
 */
export declare function bulkEntityLogicFactory(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: BulkAccess): (data: BulkEntityRequest, context: {
    uid: string;
    userRole: UserRole;
    request: CallableRequest<any>;
}) => Promise<BulkResponse>;
/**
 * Generic function to perform transactional bulk CRUD in any Firestore
 * collection. Auto-registered as `bulk_${collection}` by
 * {@link createCrudFunctions}.
 *
 * **Atomicity contract** — all inserts / updates / deletes succeed or none
 * do. On any failure the entire Firestore transaction is rolled back and the
 * error is surfaced to the caller via `DoNotDevError`.
 *
 * **One of everything** — one HTTP round-trip, one transaction, one audit
 * entry (`crud.bulk.${collection}` with counts), one rate-limit hit (at
 * `createBaseFunction` entry). Collisions and schema validation fail *before*
 * the transaction is opened.
 *
 * @param collection - The Firestore collection name.
 * @param createSchema - Valibot schema to validate each insert payload.
 * @param updateSchema - Valibot schema to validate each update patch.
 * @param access - Required roles split per op kind.
 * @returns Firebase callable function returning a `BulkResponse`.
 *
 * @throws {BulkCollisionError} When the same id appears in `updates`+`deletes`
 *   or `inserts`+`updates`. No writes are attempted.
 * @throws {DoNotDevError} `permission-denied` when the caller lacks the
 *   per-op role (e.g. includes deletes but has no delete access).
 * @throws {DoNotDevError} `invalid-argument` when any insert fails
 *   `createSchema` or any update patch fails `updateSchema`. Transaction is
 *   not opened.
 *
 * @example
 * ```typescript
 * // Usually wired automatically by createCrudFunctions:
 * import { createCrudFunctions } from '@donotdev/functions/firebase';
 * import * as entities from 'entities';
 *
 * export const crud = createCrudFunctions(entities);
 * // → crud.bulk_cars, crud.bulk_orders, etc.
 *
 * // Manual wiring:
 * import { bulkEntity } from '@donotdev/functions/firebase';
 * import { createSchemas } from '@donotdev/core/server';
 * import { carEntity } from './entities/car';
 *
 * const schemas = createSchemas(carEntity);
 * export const bulk_cars = bulkEntity(
 *   carEntity.collection,
 *   schemas.create,
 *   schemas.update,
 *   carEntity.access,
 * );
 * ```
 *
 * @version 0.2.0
 * @since 0.2.0
 * @author AMBROISE PARK Consulting
 */
export declare const bulkEntity: (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: BulkAccess) => CallableFunction<BulkEntityRequest, Promise<BulkResponse>>;
export {};
