-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Library.ts
50 lines (45 loc) · 1.56 KB
/
Library.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import type { ErrorCapturingDriverAdapter } from '@prisma/driver-adapter-utils'
import type { QueryEngineConfig } from '../../common/types/QueryEngine'
export type QueryEngineInstance = {
connect(headers: string): Promise<void>
disconnect(headers: string): Promise<void>
/**
* @param requestStr JSON.stringified `QueryEngineRequest | QueryEngineBatchRequest`
* @param headersStr JSON.stringified `QueryEngineRequestHeaders`
*/
query(requestStr: string, headersStr: string, transactionId?: string): Promise<string>
sdlSchema(): Promise<string>
dmmf(traceparent: string): Promise<string>
startTransaction(options: string, traceHeaders: string): Promise<string>
commitTransaction(id: string, traceHeaders: string): Promise<string>
rollbackTransaction(id: string, traceHeaders: string): Promise<string>
metrics(options: string): Promise<string>
}
export interface QueryEngineConstructor {
new (
config: QueryEngineConfig,
logger: (log: string) => void,
adapter?: ErrorCapturingDriverAdapter,
): QueryEngineInstance
}
export interface LibraryLoader {
loadLibrary(): Promise<Library>
}
// Main
export type Library = {
QueryEngine: QueryEngineConstructor
version: () => {
// The commit hash of the engine
commit: string
// Currently 0.1.0 (Set in Cargo.toml)
version: string
}
/**
* This returns a string representation of `DMMF.Document`
*/
dmmf: (datamodel: string) => Promise<string>
/**
* Artificial panic function that can be used to test the query engine
*/
debugPanic: (message?: string) => Promise<never>
}