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

182 lines 4.29 kB
export interface IR { config: ConfigBlock; datasources: Record<string, Datasource>; models: Record<string, Model>; enums?: Record<string, EnumType>; } export interface ConfigBlock { strict: boolean; limits: Limits; } export interface Limits { maxIncludeDepth: number; maxFanOut: number; maxConcurrentRequests: number; requestTimeoutMs: number; postFilterRowLimit: number; } export interface Datasource { name: string; provider: 'postgres' | 'postgresql' | 'mysql' | 'mongodb' | 'mongo' | 'http' | 'mssql' | 'sqlserver'; url?: string; baseUrl?: string; oauth?: OAuthConfig; } export interface EnumType { name: string; values: string[]; } export interface OAuthConfig { script: string; cacheTtl?: string; optional?: boolean; } export interface Model { name: string; datasource: string; fields: Record<string, Field>; endpoints?: Record<string, EndpointConfig>; limits?: Partial<Limits>; } export interface Field { name: string; type: string; isId?: boolean; isUnique?: boolean; isOptional?: boolean; isList?: boolean; default?: DefaultValue; relation?: RelationConfig; computed?: ComputedConfig; index?: boolean; map?: string; } export interface DefaultValue { type: 'literal' | 'function'; value: any; } export interface RelationConfig { fields: string[]; references: string[]; strategy: 'lookup' | 'join'; model: string; } export interface ComputedConfig { resolver: string; async: boolean; io: boolean; } export interface EndpointConfig { method: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE'; path: string; query?: Record<string, string>; body?: Record<string, string>; response: ResponseMapping; } export interface ResponseMapping { item?: string; items?: string; total?: string; } export interface FindManyArgs<T = any> { where?: WhereInput<T>; select?: SelectInput<T>; include?: IncludeInput<T>; orderBy?: OrderByInput<T>; skip?: number; take?: number; $options?: QueryOptions; } export interface FindUniqueArgs<T = any> { where: UniqueWhereInput<T>; select?: SelectInput<T>; include?: IncludeInput<T>; $options?: QueryOptions; } export interface CreateArgs<T = any> { data: CreateInput<T>; $options?: QueryOptions; } export interface UpdateArgs<T = any> { where: UniqueWhereInput<T>; data: UpdateInput<T>; $options?: QueryOptions; } export interface DeleteArgs<T = any> { where: UniqueWhereInput<T>; $options?: QueryOptions; } export interface QueryOptions { strict?: boolean; limits?: Partial<Limits>; } export type WhereInput<T> = { [K in keyof T]?: T[K] extends string ? StringFilter | T[K] : T[K] extends number ? NumberFilter | T[K] : T[K] extends boolean ? BooleanFilter | T[K] : any; } & { AND?: WhereInput<T>[]; OR?: WhereInput<T>[]; NOT?: WhereInput<T>; }; export type UniqueWhereInput<T> = { [K in keyof T]?: T[K]; }; export type SelectInput<T> = { [K in keyof T]?: boolean | SelectInput<any>; }; export type IncludeInput<T> = { [K in keyof T]?: boolean | { select?: SelectInput<any>; where?: WhereInput<any>; }; }; export type OrderByInput<T> = { [K in keyof T]?: 'asc' | 'desc'; }; export type CreateInput<T> = { [K in keyof T]?: any; }; export type UpdateInput<T> = { [K in keyof T]?: any; }; export interface StringFilter { eq?: string; ne?: string; in?: string[]; notIn?: string[]; contains?: string; startsWith?: string; endsWith?: string; gt?: string; gte?: string; lt?: string; lte?: string; } export interface NumberFilter { eq?: number; ne?: number; in?: number[]; notIn?: number[]; gt?: number; gte?: number; lt?: number; lte?: number; } export interface BooleanFilter { eq?: boolean; ne?: boolean; } export interface QueryResult<T> { data: T; $meta?: QueryMetadata; } export interface QueryMetadata { issues?: Issue[]; timings?: Record<string, number>; traceId?: string; } export interface Issue { type: 'warning' | 'error'; message: string; path?: string[]; } //# sourceMappingURL=ir.d.ts.map