UNPKG

@aradox/multi-orm

Version:

Type-safe ORM with multi-datasource support, row-level security, and Prisma-like API for PostgreSQL, SQL Server, and HTTP APIs

74 lines 2.73 kB
export interface Adapter { findMany(model: string, args: FindManyAdapterArgs): Promise<any[]>; findUnique(model: string, args: FindUniqueAdapterArgs): Promise<any | null>; create(model: string, args: CreateAdapterArgs): Promise<any>; update(model: string, args: UpdateAdapterArgs): Promise<any>; delete(model: string, args: DeleteAdapterArgs): Promise<any>; count(model: string, args: CountAdapterArgs): Promise<number>; capabilities: AdapterCapabilities; beginTransaction?(options?: TransactionOptions): Promise<Transaction>; } export interface AdapterCapabilities { transactions?: boolean; bulkByIds?: boolean; maxIn?: number; supportedOperators?: string[]; } export type IsolationLevel = 'READ UNCOMMITTED' | 'READ COMMITTED' | 'REPEATABLE READ' | 'SERIALIZABLE'; export interface TransactionOptions { isolationLevel?: IsolationLevel; timeout?: number; } export interface Transaction { id: string; commit(): Promise<void>; rollback(): Promise<void>; findMany(model: string, args: FindManyAdapterArgs): Promise<any[]>; findUnique(model: string, args: FindUniqueAdapterArgs): Promise<any | null>; create(model: string, args: CreateAdapterArgs): Promise<any>; update(model: string, args: UpdateAdapterArgs): Promise<any>; delete(model: string, args: DeleteAdapterArgs): Promise<any>; count(model: string, args: CountAdapterArgs): Promise<number>; } export interface FindManyAdapterArgs { where?: Record<string, any>; select?: Record<string, boolean>; orderBy?: Record<string, 'asc' | 'desc'>; skip?: number; take?: number; } export interface FindUniqueAdapterArgs { where: Record<string, any>; select?: Record<string, boolean>; } export interface CreateAdapterArgs { data: Record<string, any>; } export interface UpdateAdapterArgs { where: Record<string, any>; data: Record<string, any>; } export interface DeleteAdapterArgs { where: Record<string, any>; } export interface CountAdapterArgs { where?: Record<string, any>; } export interface OAuthContext { persist: (key: string, value: any) => Promise<void>; get: (key: string) => Promise<any>; set: (key: string, value: any) => Promise<void>; } export interface OAuthResult { headers?: Record<string, string>; expiresAt?: number; refresh?: (reason: 'expired' | '401') => Promise<Pick<OAuthResult, 'headers' | 'expiresAt'>>; } export type OAuthHook = (ctx: OAuthContext) => Promise<OAuthResult>; export interface ComputedContext { row: any; includes?: Record<string, any>; model: string; } export type ComputedResolver = (ctx: ComputedContext) => any | Promise<any>; //# sourceMappingURL=adapter.d.ts.map