1 | import { DMMF } from './dmmf-types';
|
2 | import { DatasourceOverwrite } from '@prisma/engine-core/dist/NodeEngine';
|
3 | import { Document } from './query';
|
4 | import { GeneratorConfig } from '@prisma/generator-helper/dist/types';
|
5 | import { Dataloader } from './Dataloader';
|
6 | export declare type ErrorFormat = 'pretty' | 'colorless' | 'minimal';
|
7 | export declare type Datasource = {
|
8 | url?: string;
|
9 | };
|
10 | export declare type Datasources = Record<string, Datasource>;
|
11 | export interface PrismaClientOptions {
|
12 | |
13 |
|
14 |
|
15 | datasources?: Datasources;
|
16 | |
17 |
|
18 |
|
19 | errorFormat?: ErrorFormat;
|
20 | |
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | log?: Array<LogLevel | LogDefinition>;
|
36 | |
37 |
|
38 |
|
39 |
|
40 | __internal?: {
|
41 | debug?: boolean;
|
42 | hooks?: Hooks;
|
43 | useUds?: boolean;
|
44 | engine?: {
|
45 | cwd?: string;
|
46 | binaryPath?: string;
|
47 | endpoint?: string;
|
48 | enableEngineDebugMode?: boolean;
|
49 | };
|
50 | };
|
51 | }
|
52 | export declare type HookParams = {
|
53 | query: string;
|
54 | path: string[];
|
55 | rootField?: string;
|
56 | typeName?: string;
|
57 | document: any;
|
58 | clientMethod: string;
|
59 | args: any;
|
60 | };
|
61 |
|
62 |
|
63 |
|
64 | export declare type MiddlewareParams = {
|
65 | model?: string;
|
66 | action: Action;
|
67 | args: any;
|
68 | dataPath: string[];
|
69 | runInTransaction: boolean;
|
70 | };
|
71 |
|
72 |
|
73 |
|
74 | export declare type Middleware<T = any> = (params: MiddlewareParams, next: (params: MiddlewareParams) => Promise<T>) => Promise<T>;
|
75 | export interface InternalRequestParams extends MiddlewareParams {
|
76 | |
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 | clientMethod: string;
|
83 | callsite?: string;
|
84 | headers?: Record<string, string>;
|
85 | }
|
86 | export declare type HookPoint = 'all' | 'engine';
|
87 | export declare type EngineMiddlewareParams = {
|
88 | document: Document;
|
89 | runInTransaction?: boolean;
|
90 | };
|
91 | export declare type AllHookArgs = {
|
92 | params: HookParams;
|
93 | fetch: (params: HookParams) => Promise<any>;
|
94 | };
|
95 |
|
96 |
|
97 |
|
98 | export declare type EngineMiddleware<T = any> = (params: EngineMiddlewareParams, next: (params: EngineMiddlewareParams) => Promise<T>) => Promise<T>;
|
99 | export declare type Hooks = {
|
100 | beforeRequest?: (options: HookParams) => any;
|
101 | };
|
102 | export declare type LogLevel = 'info' | 'query' | 'warn' | 'error';
|
103 | export declare type LogDefinition = {
|
104 | level: LogLevel;
|
105 | emit: 'stdout' | 'event';
|
106 | };
|
107 | export declare type GetLogType<T extends LogLevel | LogDefinition> = T extends LogDefinition ? T['emit'] extends 'event' ? T['level'] : never : never;
|
108 | export declare type GetEvents<T extends Array<LogLevel | LogDefinition>> = GetLogType<T[0]> | GetLogType<T[1]> | GetLogType<T[2]>;
|
109 | export declare type QueryEvent = {
|
110 | timestamp: Date;
|
111 | query: string;
|
112 | params: string;
|
113 | duration: number;
|
114 | target: string;
|
115 | };
|
116 | export declare type LogEvent = {
|
117 | timestamp: Date;
|
118 | message: string;
|
119 | target: string;
|
120 | };
|
121 | export interface GetPrismaClientOptions {
|
122 | document: DMMF.Document;
|
123 | generator?: GeneratorConfig;
|
124 | sqliteDatasourceOverrides?: DatasourceOverwrite[];
|
125 | relativePath: string;
|
126 | dirname: string;
|
127 | clientVersion?: string;
|
128 | engineVersion?: string;
|
129 | }
|
130 | export declare type Action = 'findOne' | 'findMany' | 'create' | 'update' | 'updateMany' | 'upsert' | 'delete' | 'deleteMany' | 'executeRaw' | 'queryRaw' | 'aggregate';
|
131 | export declare function getPrismaClient(config: GetPrismaClientOptions): any;
|
132 | export declare class PrismaClientFetcher {
|
133 | prisma: any;
|
134 | debug: boolean;
|
135 | hooks: any;
|
136 | dataloader: Dataloader<{
|
137 | document: Document;
|
138 | runInTransaction?: boolean;
|
139 | headers?: Record<string, string>;
|
140 | }>;
|
141 | constructor(prisma: any, enableDebug?: boolean, hooks?: any);
|
142 | request({ document, dataPath, rootField, typeName, isList, callsite, clientMethod, runInTransaction, showColors, engineHook, args, headers, }: {
|
143 | document: Document;
|
144 | dataPath: string[];
|
145 | rootField: string;
|
146 | typeName: string;
|
147 | isList: boolean;
|
148 | clientMethod: string;
|
149 | callsite?: string;
|
150 | runInTransaction?: boolean;
|
151 | showColors?: boolean;
|
152 | engineHook?: EngineMiddleware;
|
153 | args: any;
|
154 | headers?: Record<string, string>;
|
155 | }): Promise<any>;
|
156 | sanitizeMessage(message: any): any;
|
157 | unpack(document: any, data: any, path: any, rootField: any): any;
|
158 | }
|
159 | export declare function getOperation(action: DMMF.ModelAction): 'query' | 'mutation';
|