import * as Client from '@effect/sql/SqlClient'; import { ConfigError } from 'effect/ConfigError'; import { ConnectionConfig } from '@voltro/database'; import { Context } from 'effect'; import { Duration } from 'effect'; import { Layer } from 'effect'; import { RetryDecision } from '@voltro/database'; import { SqlClient } from '@effect/sql/SqlClient'; import { SqlDialect } from '@voltro/database'; import { SqlError } from '@effect/sql/SqlError'; export declare const connectionFromConfig: (config: ConnectionConfig) => ParsedTursoConnection; export declare const isTursoRetryableFailure: (err: unknown) => boolean; /** * @category models */ export declare interface LibsqlClient extends Client.SqlClient { readonly [TypeId_2]: TypeId_2; readonly config: LibsqlClientConfig; } /** * @category tags */ export declare const LibsqlClient: Context.Tag; /** * @category models */ export declare interface LibsqlClientConfig { /** * The database URL. Remote Turso Cloud uses `libsql://`, `https://`, or * `wss://`; an embedded replica uses a local `file:` path (paired with * `syncUrl`). */ readonly url: string; /** * Turso Cloud auth token. Sourced from config/env (`DB_AUTH_TOKEN`); never * logged or baked into the build. */ readonly authToken?: string | undefined; /** * Embedded-replica sync source: the remote Turso Cloud primary a local * `file:` replica syncs FROM. When set with a `file:` url, the client runs an * embedded replica — local reads, writes forwarded to the primary, periodic * pull-sync of the primary's frames. */ readonly syncUrl?: string | undefined; /** * Embedded-replica pull-sync interval. When set (and `syncUrl` is set), the * client resyncs on this cadence; unset means sync only on explicit * `client.sync()` (which this layer fires once at startup). */ readonly syncInterval?: Duration.DurationInput | undefined; /** * Read-your-writes for an embedded replica: after a write to the primary, * block local reads until the replica has caught up to that write. Defaults * to the driver's default (on). */ readonly readYourWrites?: boolean | undefined; /** Encryption key for a local embedded-replica file at rest. */ readonly encryptionKey?: string | undefined; readonly spanAttributes?: Record | undefined; readonly transformResultNames?: ((str: string) => string) | undefined; readonly transformQueryNames?: ((str: string) => string) | undefined; } /** The parsed remote / embedded-replica (libsql-client) connection shape. */ export declare interface LibsqlConnection { readonly kind: 'remote'; /** `libsql://` / `https://` / `wss://` (Turso Cloud), or a `file:` embedded replica. */ readonly url: string; /** Turso Cloud auth token (from env; never logged/baked). */ readonly authToken?: string; /** Embedded-replica sync source — the remote primary a `file:` replica syncs from. */ readonly syncUrl?: string; /** Embedded-replica pull-sync interval, in seconds. */ readonly syncIntervalSeconds?: number; /** Read-your-writes for an embedded replica. */ readonly readYourWrites?: boolean; /** Encryption key for a local embedded-replica file at rest. */ readonly encryptionKey?: string; } export declare const makeLibsqlSqlLayer: (options: Omit) => TursoSqlLayer; export declare const makeTursoSqlLayer: (options: Omit) => TursoSqlLayer; export declare const makeTursoSqlLayerFromConfig: (config: ConnectionConfig) => TursoSqlLayer; export declare type ParsedTursoConnection = TursoConnection | LibsqlConnection; /** * @category models */ export declare interface TursoClient extends Client.SqlClient { readonly [TypeId]: TypeId; readonly config: TursoClientConfig; } /** * @category tags */ export declare const TursoClient: Context.Tag; /** * @category models */ export declare interface TursoClientConfig { /** `file:`-stripped path, or `:memory:` for an ephemeral in-process DB. */ readonly filename: string; readonly readonly?: boolean | undefined; /** * Connection-pool size. The MVCC write-concurrency knob — this many * `BEGIN CONCURRENT` transactions can run at once. Default 4. Forced to 1 * for `:memory:` (each `:memory:` connection is a PRIVATE database, so a * pool would split state). */ readonly maxConnections?: number | undefined; /** * How long a statement waits for a held lock before failing with * `database is locked`, in milliseconds. Default 5000; `0` restores the * engine's fail-immediately behavior. See the pragma in `makeConnection` for * why a non-zero default is mandatory with a pool. */ readonly busyTimeoutMs?: number | undefined; readonly prepareCacheSize?: number | undefined; readonly prepareCacheTTL?: Duration.DurationInput | undefined; readonly spanAttributes?: Record | undefined; readonly transformResultNames?: ((str: string) => string) | undefined; readonly transformQueryNames?: ((str: string) => string) | undefined; } /** The parsed local (Rust-engine) connection shape. */ export declare interface TursoConnection { readonly kind: 'local'; /** Absolute or relative path, or `:memory:` for ephemeral. */ readonly filename: string; readonly readonly?: boolean; /** Connection-pool size (the MVCC write-concurrency knob). */ readonly maxConnections?: number; /** Lock-wait before `database is locked`, ms. Default 5000; `0` fails at once. */ readonly busyTimeoutMs?: number; } export declare const tursoDialect: SqlDialect; export declare const tursoRetryFilter: (err: unknown) => RetryDecision; declare type TursoSqlLayer = Layer.Layer; /** * @category type ids */ declare const TypeId: unique symbol; declare type TypeId = typeof TypeId; /** * @category type ids */ declare const TypeId_2: unique symbol; declare type TypeId_2 = typeof TypeId_2; export { }