import "../index-DrgOX0Fu.js";
import { SQLWrapper } from "drizzle-orm";
import { DrizzleD1Database } from "drizzle-orm/d1";
import "drizzle-orm/sqlite-core";
//#region src/sqlite/types.d.ts
type Schema = Record<string, unknown>;
//#endregion
//#region src/sqlite/d1.d.ts
/** D1Database binding from the Workers runtime; hosts provide its concrete type. */
type D1Binding = unknown;
interface D1ClientOptions<S extends Schema> {
  schema?: S;
}
/** A D1 statement prepared by this client for one atomic binding batch. */
interface D1BatchItem<Row = unknown> {
  /** Compile-time result shape; runtime query bytes remain private to the client. */
  readonly _: {
    readonly result: readonly Row[];
  };
}
type D1BatchResult<T extends readonly D1BatchItem[]> = { readonly [K in keyof T]: T[K] extends D1BatchItem<infer Row> ? Row[] : never; };
/** Package-owned execution plan contributed to one host-owned D1 atomic batch. */
interface D1PreparedContribution<Result, Item extends D1BatchItem = D1BatchItem> {
  readonly items: readonly [Item, ...Item[]];
  /** Valid only after the host-owned batch commits successfully. */
  readonly result: Result;
}
/** Structural error so callers do not depend on a provider exception instance. */
declare class D1BatchError extends Error {
  readonly detail: string;
  readonly code = "d1-batch";
  constructor(detail: string);
}
/**
 * Batch guard for optimistic writes. Place this immediately after a D1 UPDATE/DELETE
 * whose affected-row count must match exactly. A mismatch deliberately raises a
 * SQLite JSON error, which aborts and rolls back the whole binding batch.
 */
declare function d1AssertPreviousChanges(expected?: number): SQLWrapper;
declare function isD1BatchError(error: unknown): error is D1BatchError;
type D1Client<S extends Schema = Record<string, never>> = Omit<DrizzleD1Database<S>, 'transaction' | 'execute' | 'batch'> & {
  execute<Row extends Record<string, unknown> = Record<string, unknown>>(query: SQLWrapper): Promise<readonly Row[]>;
  prepare<Row = unknown>(query: SQLWrapper): D1BatchItem<Row>;
  batch<T extends readonly [D1BatchItem, ...D1BatchItem[]]>(items: T): Promise<D1BatchResult<T>>;
};
/**
 * Creates D1's truthful capability surface: ordinary queries plus one-shot atomic batches.
 * D1 has no interactive callback transaction API.
 */
declare function createD1Client<S extends Schema = Record<string, never>>(binding: D1Binding, opts?: D1ClientOptions<S>): D1Client<S>;
//#endregion
export { D1BatchError, D1BatchItem, D1BatchResult, D1Binding, D1Client, D1ClientOptions, D1PreparedContribution, type DrizzleD1Database, createD1Client, d1AssertPreviousChanges, isD1BatchError };