studiocms
Version:
Astro Native CMS for AstroDB. Built from the ground up by the Astro community.
30 lines (29 loc) • 1.83 kB
TypeScript
import { Effect } from '../../../effect.js';
export { LibSQLClientError } from '@withstudiocms/effect/drizzle';
declare const AstroDB_base: Effect.Service.Class<AstroDB, "studiocms/sdk/effect/db/AstroDB", {
readonly effect: Effect.Effect<{
db: import("@astrojs/db/runtime").Database;
execute: <T>(fn: (client: import("drizzle-orm/libsql").LibSQLDatabase<Record<string, never>> | import("@astrojs/db/runtime").Database) => Promise<T>) => Effect.Effect<T, import("@withstudiocms/effect/drizzle").LibSQLClientError, never>;
makeQuery: <A, E, R, Input = never>(queryFn: (execute: import("@withstudiocms/effect/drizzle").ExecuteFn<Record<string, unknown>>, input: Input) => Effect.Effect<A, E, R>) => (...args: [Input] extends [never] ? [] : [input: Input]) => Effect.Effect<A, E, R>;
}, never, never>;
}>;
/**
* Provides an Effect-based service wrapper for interacting with an AstroDB database client.
*
* @remarks
* This service exposes utility functions for executing queries, managing transactions, and composing
* database effects using the Effect system. It handles error mapping for LibSQL client errors and
* supports transactional execution with proper error propagation.
*
* @property db - The underlying database client instance.
* @property execute - Executes a function against the database client, mapping errors to LibSQLDatabaseError when possible.
* @property makeQuery - Composes a query effect, optionally using a transaction context if available.
* @property transaction - Runs a provided effect within a database transaction, ensuring proper error handling and commit/rollback semantics.
*
* @example
* ```typescript
* const result = await AstroDB.execute((client) => client.query('SELECT * FROM users'));
* ```
*/
export declare class AstroDB extends AstroDB_base {
}