PgliteClient
Connects Effect SQL to PGlite, the embedded PostgreSQL-compatible database
from @electric-sql/pglite.
This module can create a managed PGlite instance or wrap an existing one and
expose it as both PgliteClient and the generic Effect SQL client. The client
runs PostgreSQL-style SQL, adds helpers for JSON values and LISTEN/NOTIFY
messages, can dump the PGlite data directory, and can refresh PGlite array
types. It also provides layers and maps common PostgreSQL-style failures into
Effect SQL errors.
Constructors
fromClient
Builds a PgliteClient around an existing PGlite instance, adding SQL client operations, LISTEN/NOTIFY, dump helpers, and serialized access.
Signature
declare function fromClient(options: Base & { readonly liveClient: PGliteInterface;}): Effect<PgliteClient, SqlError, Scope | Reactivity>Creates a scoped PGlite SQL client. When no live client is supplied it creates and closes a PGlite instance; when liveClient is supplied, the caller retains ownership.
Signature
declare function make(options: PgliteClientConfig): Effect<PgliteClient, SqlError, Scope | Reactivity>makeCompiler
Creates the PGlite statement compiler, using PostgreSQL $1 placeholders, double-quoted identifiers, returning clauses, and optional JSON value transformation.
Signature
declare function makeCompiler(transform?: (_: string) => string, transformJson: boolean): CompilerLayers
Creates a layer from a concrete PGlite client configuration, providing both PgliteClient and SqlClient.
Signature
declare function layer(config?: PgliteClientConfig): Layer<PgliteClient | SqlClient, SqlError>layerConfig
Creates a layer from a Config-wrapped PGlite client configuration, providing both PgliteClient and SqlClient.
Signature
declare const layerConfig: (config: Config.Wrap<PgliteClientConfig.ConfigBase>) => Layer.Layer<PgliteClient | Client.SqlClient, Config.ConfigError | SqlError>Creates a layer from an effect that acquires a PgliteClient, providing both PgliteClient and SqlClient.
Signature
declare function layerFrom<E, R>(acquire: Effect<PgliteClient, E, R>): Layer<PgliteClient | SqlClient, E, Exclude<R, Scope | Reactivity>>Models
PGlite-specific custom statement fragments supported by the compiler, currently JSON parameter fragments.
Signature
type PgCustom = PgJsonPgliteClientConfig type
Configuration for a PGlite client, either by supplying PGlite creation options or an existing live PGlite client.
Signature
type PgliteClientConfig = PgliteClientConfig.Create | PgliteClientConfig.LiveOther
PgliteClientConfig
Namespace containing the configuration variants for PgliteClient.
Services
PgliteClient
Service tag for the PGlite client service.
When to use
Use to access or provide a PGlite client through the Effect context.
Signature
declare const PgliteClient: Service<PgliteClient, PgliteClient>PgliteClient interface
PGlite-backed PostgreSQL client service, extending SqlClient with access to the PGlite instance, JSON fragments, LISTEN/NOTIFY, data directory dumps, and array type refresh.
Signature
interface PgliteClient extends SqlClient { <A extends object = Row>(strings: TemplateStringsArray, ...args: Array<any>): Statement<A>; (value: string): Identifier; readonly "~@effect/sql-pglite/PgliteClient": "~@effect/sql-pglite/PgliteClient"; readonly config: PgliteClientConfig; readonly dumpDataDir: (compression?: "none" | "gzip" | "auto") => Effect<File | Blob, SqlError>; readonly json: (_: unknown) => Fragment; readonly listen: (channel: string) => Effect<Dequeue<string, never>, SqlError, Scope>; readonly notify: (channel: string, payload: string) => Effect<void, SqlError>; readonly pglite: PGliteInterface; readonly refreshArrayTypes: Effect<void, SqlError>;}