-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
types.ts
108 lines (94 loc) · 2.43 KB
/
types.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import type { DMMF } from './dmmf'
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace JsonRPC {
export type Request = {
jsonrpc: '2.0'
method: string
params?: any
id: number
}
export type Response = SuccessResponse | ErrorResponse
export type SuccessResponse = {
jsonrpc: '2.0'
result: any
id: number
}
export type ErrorResponse = {
jsonrpc: '2.0'
error: {
code: number
message: string
data: any
}
id: number
}
}
export type Dictionary<T> = { [key: string]: T }
export interface GeneratorConfig {
name: string
output: EnvValue | null
isCustomOutput?: boolean
provider: EnvValue
config: Dictionary<string>
binaryTargets: BinaryTargetsEnvValue[]
// TODO why is this not optional?
previewFeatures: string[]
}
export interface EnvValue {
fromEnvVar: null | string
value: string
}
export interface BinaryTargetsEnvValue {
fromEnvVar: null | string
value: string
}
export type ConnectorType =
| 'mysql'
| 'mongodb'
| 'sqlite'
| 'postgresql'
| 'sqlserver'
| 'jdbc:sqlserver'
| 'cockroachdb'
export interface DataSource {
name: string
activeProvider: ConnectorType
provider: ConnectorType
url: EnvValue
config: { [key: string]: string }
}
export type BinaryPaths = {
migrationEngine?: { [binaryTarget: string]: string } // key: target, value: path
queryEngine?: { [binaryTarget: string]: string }
libqueryEngine?: { [binaryTarget: string]: string }
introspectionEngine?: { [binaryTarget: string]: string }
prismaFmt?: { [binaryTarget: string]: string }
}
/** The options passed to the generator implementations */
export type GeneratorOptions = {
generator: GeneratorConfig
// TODO: what is otherGenerators for?
otherGenerators: GeneratorConfig[]
schemaPath: string
dmmf: DMMF.Document
datasources: DataSource[]
// TODO deprecate datamodel & rename to schema?
datamodel: string
// TODO is it really always version hash? Feature is unclear.
version: string // version hash
binaryPaths?: BinaryPaths
dataProxy: boolean
}
export type EngineType = 'queryEngine' | 'libqueryEngine' | 'migrationEngine' | 'introspectionEngine' | 'prismaFmt'
export type GeneratorManifest = {
prettyName?: string
defaultOutput?: string
denylists?: {
models?: string[]
fields?: string[]
}
requiresGenerators?: string[]
requiresEngines?: EngineType[]
version?: string
requiresEngineVersion?: string
}