import { ZodObject, ZodTypeAny, z } from 'zod'; import { PApi, PTable } from './papi'; import type { ApiOptions, ExtractResultFromQuery, PActionBody, PHooks, ZodSchemaToKysely } from '../types'; import type { CompiledQuery, InsertQueryBuilder, Kysely, RawBuilder, SelectQueryBuilder } from 'kysely'; export declare class SqliteApi> extends PApi { table & string>(tableName: K, opts?: { ky?: Kysely>; hooks?: PHooks[]; }): PTable[K], z.input[K], K>; /** * only working cloudflare D1 and sqlite * use this api to execute one sql query with multiple parameters * https://developers.cloudflare.com/d1/platform/client-api/#dbbatch * @param batchParams order of params is not automatic like what kysely does */ batchOneSmt, any, any> | InsertQueryBuilder, any, any>>(sqlQuery: { compile: () => CompiledQuery>; } | RawBuilder>, batchParams: Array, opts?: ApiOptions): Promise<{ rows: ExtractResultFromQuery[]; error: any; }>; $batchOneSmt(sqlQuery: { compile: () => CompiledQuery>; } | RawBuilder>, batchParams: Array): PActionBody; batchAllSmt(sqlQuerys: Array<{ compile: () => CompiledQuery>; }>, opts?: ApiOptions): Promise<{ error: any; rows: any[]; getOne: (index: number) => X | undefined; getMany: (index: number) => X[]; }>; bulk(operations: { [key in V]: PActionBody | { compile: () => CompiledQuery>; } | RawBuilder> | undefined; }, opts?: ApiOptions & { isTransaction: boolean; }): Promise<{ data: { key: string; results: any[]; table: string; }[]; error: any; getOne: (key: V, table?: keyof z.output, extend?: ZodObject) => X | undefined; getMany: (key: V, table?: string, extend?: ZodObject) => X[]; }>; /** * extend the origin zod schema * it similar to withTables on kysely * * ```typescript * const extendApi = api.withTables( * { * NewTable: z.object({ * id: z.number().optional(), * name: z.string(), * }), * }, * { // option * newTable: o => o.table('NewTable'), * }) * ``` **/ withTables) => PTable; }, ExtendSchema extends ZodObject & T, any, any, z.input & { [k in keyof T]: z.input; }, z.output & { [k in keyof T]: z.output; }>>(schema: T, extendApi?: ExtendApi): PApi & { [key in keyof ExtendApi]: ReturnType; }; }