import type { ResultSet } from '@libsql/client'; import type { BuildQueryJoinAliases, DrizzleAdapter, extendDrizzleTable } from '@payloadcms/drizzle'; import type { BaseSQLiteAdapter, BaseSQLiteArgs } from '@payloadcms/drizzle/sqlite'; import type { DrizzleConfig, Relation, Relations, SQL } from 'drizzle-orm'; import type { AnyD1Database, DrizzleD1Database } from 'drizzle-orm/d1'; import type { LibSQLDatabase } from 'drizzle-orm/libsql'; import type { AnySQLiteColumn, SQLiteInsertOnConflictDoUpdateConfig, SQLiteTableWithColumns, SQLiteTransactionConfig } from 'drizzle-orm/sqlite-core'; import type { SQLiteRaw } from 'drizzle-orm/sqlite-core/query-builders/raw'; import type { Payload, PayloadRequest } from 'payload'; type SQLiteSchema = { relations: Record; tables: Record>; }; type SQLiteSchemaHookArgs = { extendTable: typeof extendDrizzleTable; schema: SQLiteSchema; }; export type SQLiteSchemaHook = (args: SQLiteSchemaHookArgs) => Promise | SQLiteSchema; export type Args = { binding: AnyD1Database; /** * Experimental. Enables read replicas support with the `first-primary` strategy. * * @experimental * @example * * ```readReplicas: 'first-primary'``` */ readReplicas?: 'first-primary'; } & BaseSQLiteArgs; export type GenericColumns = { [x: string]: AnySQLiteColumn; }; export type GenericTable = SQLiteTableWithColumns<{ columns: GenericColumns; dialect: string; name: string; schema: string; }>; export type GenericRelation = Relations>>; export type CountDistinct = (args: { db: LibSQLDatabase; joins: BuildQueryJoinAliases; tableName: string; where: SQL; }) => Promise; export type DeleteWhere = (args: { db: LibSQLDatabase; tableName: string; where: SQL; }) => Promise; export type DropDatabase = (args: { adapter: SQLiteD1Adapter; }) => Promise; export type Execute = (args: { db?: LibSQLDatabase; drizzle?: LibSQLDatabase; raw?: string; sql?: SQL; }) => SQLiteRaw> | SQLiteRaw; export type Insert = (args: { db: LibSQLDatabase; onConflictDoUpdate?: SQLiteInsertOnConflictDoUpdateConfig; tableName: string; values: Record | Record[]; }) => Promise[]>; type SQLiteDrizzleAdapter = Omit; export interface GeneratedDatabaseSchema { schemaUntyped: Record; } type Drizzle = { $client: AnyD1Database; } & DrizzleD1Database>; export type SQLiteD1Adapter = { binding: Args['binding']; client: AnyD1Database; drizzle: Drizzle; /** * Experimental. Enables read replicas support with the `first-primary` strategy. * * @example * * ```readReplicas: 'first-primary'``` */ readReplicas?: 'first-primary'; } & BaseSQLiteAdapter & SQLiteDrizzleAdapter; export type IDType = 'integer' | 'numeric' | 'text'; export type MigrateUpArgs = { /** * The SQLite Drizzle instance that you can use to execute SQL directly within the current transaction. * @example * ```ts * import { type MigrateUpArgs, sql } from '@payloadcms/db-sqlite' * * export async function up({ db, payload, req }: MigrateUpArgs): Promise { * const { rows: posts } = await db.run(sql`SELECT * FROM posts`) * } * ``` */ db: Drizzle; /** * The Payload instance that you can use to execute Local API methods * To use the current transaction you must pass `req` to arguments * @example * ```ts * import { type MigrateUpArgs } from '@payloadcms/db-sqlite' * * export async function up({ db, payload, req }: MigrateUpArgs): Promise { * const posts = await payload.find({ collection: 'posts', req }) * } * ``` */ payload: Payload; /** * The `PayloadRequest` object that contains the current transaction */ req: PayloadRequest; }; export type MigrateDownArgs = { /** * The SQLite Drizzle instance that you can use to execute SQL directly within the current transaction. * @example * ```ts * import { type MigrateDownArgs, sql } from '@payloadcms/db-sqlite' * * export async function down({ db, payload, req }: MigrateDownArgs): Promise { * const { rows: posts } = await db.run(sql`SELECT * FROM posts`) * } * ``` */ db: Drizzle; /** * The Payload instance that you can use to execute Local API methods * To use the current transaction you must pass `req` to arguments * @example * ```ts * import { type MigrateDownArgs } from '@payloadcms/db-sqlite' * * export async function down({ db, payload, req }: MigrateDownArgs): Promise { * const posts = await payload.find({ collection: 'posts', req }) * } * ``` */ payload: Payload; /** * The `PayloadRequest` object that contains the current transaction */ req: PayloadRequest; }; declare module 'payload' { interface DatabaseAdapter extends Omit, DrizzleAdapter { beginTransaction: (options?: SQLiteTransactionConfig) => Promise; drizzle: Drizzle; /** * An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name * Used for returning properly formed errors from unique fields */ fieldConstraints: Record>; idType: Args['idType']; initializing: Promise; localesSuffix?: string; logger: DrizzleConfig['logger']; prodMigrations?: { down: (args: MigrateDownArgs) => Promise; name: string; up: (args: MigrateUpArgs) => Promise; }[]; push: boolean; rejectInitializing: () => void; relationshipsSuffix?: string; resolveInitializing: () => void; schema: Record; tableNameMap: Map; transactionOptions: SQLiteTransactionConfig; versionsSuffix?: string; } } export {}; //# sourceMappingURL=types.d.ts.map