import { Cause, Context, Effect, Layer } from "effect";
import type { AbstractQuery } from "@executor-js/fumadb/query";
import type { AnySchema, AnyTable, Schema as FumaSchema } from "@executor-js/fumadb/schema";
declare const StorageError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
    readonly _tag: "StorageError";
} & Readonly<A>;
export declare class StorageError extends StorageError_base<{
    readonly message: string;
    readonly cause: unknown;
}> {
}
declare const UniqueViolationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
    readonly _tag: "UniqueViolationError";
} & Readonly<A>;
export declare class UniqueViolationError extends UniqueViolationError_base<{
    readonly model?: string;
}> {
}
export type StorageFailure = StorageError | UniqueViolationError;
export type FumaTables = Record<string, AnyTable>;
type EmptyFumaSchema = FumaSchema<"latest", Record<never, never>>;
export type TablesToFumaSchema<TTables extends FumaTables | undefined> = TTables extends FumaTables ? string extends keyof TTables ? AnySchema : FumaSchema<"latest", TTables> : EmptyFumaSchema;
export type FumaDb<TSchema extends AnySchema = AnySchema> = AbstractQuery<TSchema>;
export type FumaQuery<TSchema extends AnySchema = AnySchema> = Omit<AbstractQuery<TSchema>, "internal" | "withContext" | "transaction"> & {
    readonly transaction: <A>(run: (db: FumaQuery<TSchema>) => Promise<A>) => Promise<A>;
};
export type FumaRow<TTable extends AnyTable> = Omit<{
    readonly [K in keyof TTable["columns"]]: TTable["columns"][K]["$out"];
}, "row_id">;
export declare const isStorageFailure: (error: unknown) => error is StorageFailure;
export declare const fumaFailureFromCause: (label: string, cause: unknown) => StorageFailure;
export declare const fumaEffect: <A>(label: string, run: () => Promise<A>) => Effect.Effect<A, StorageFailure>;
export declare const activeFumaDbRef: Context.Reference<FumaDb<AnySchema> | null>;
export type IFumaClient<TSchema extends AnySchema = AnySchema> = Readonly<{
    use: <A>(label: string, fn: (db: FumaQuery<TSchema>) => Promise<A>) => Effect.Effect<A, StorageFailure>;
    transaction: <A, E>(effect: Effect.Effect<A, E>) => Effect.Effect<A, E | StorageFailure>;
}>;
export interface MakeFumaClientOptions {
    readonly tables?: ReadonlySet<string>;
}
export declare const makeFumaClient: (db: FumaDb, options?: MakeFumaClientOptions) => IFumaClient;
declare const FumaClient_base: Context.ServiceClass<FumaClient, "executor/FumaClient", Readonly<{
    use: <A>(label: string, fn: (db: FumaQuery<AnySchema>) => Promise<A>) => Effect.Effect<A, StorageFailure, never>;
    transaction: <A, E>(effect: Effect.Effect<A, E>) => Effect.Effect<A, E | StorageFailure>;
}>>;
export declare class FumaClient extends FumaClient_base {
    static layer: (db: FumaDb) => Layer.Layer<FumaClient, never, never>;
}
export {};
//# sourceMappingURL=fuma-runtime.d.ts.map