-
Notifications
You must be signed in to change notification settings - Fork 9
/
types.ts
93 lines (78 loc) · 2.02 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
import { EventEmitter } from 'events'
import { TinyPgErrorTransformer } from './errors'
import { TlsOptions } from 'tls'
export interface TinyPgOptions {
connection_string: string
tls_options?: TlsOptions
root_dir?: string | string[]
error_transformer?: TinyPgErrorTransformer
capture_stack_trace?: boolean
pool_options?: {
max?: number
min?: number
connection_timeout_ms?: number
idle_timeout_ms?: number
application_name?: string
statement_timeout_ms?: number
keep_alive?: boolean
}
}
export type TinyPgPrimitive = string | number | boolean | object | Buffer | Date
export type TinyPgParams = undefined | null | object | { [key: string]: null | undefined | TinyPgPrimitive | TinyPgPrimitive[] }
export interface Result<T extends object> {
rows: T[]
command: string
row_count: number
}
export interface QueryBeginContext {
id: string
sql: string
start: number
name: string
params: TinyPgParams
}
export interface QueryCompleteContext extends QueryBeginContext {
end: number
duration: number
data: Result<any> | null
error: Error | null
}
export interface SqlParseResult {
parameterized_sql: string
mapping: ParamMapping[]
}
export interface ParamMapping {
index: number
name: string
}
export interface SqlFile {
name: string
key: string
path: string
path_parts: string[]
relative_path: string
text: string
parsed: SqlParseResult
}
export interface DbCallConfig {
name: string
key: string | null
parameter_map: ParamMapping[]
parameterized_query: string
text: string
prepared: boolean
}
export interface Disposable {
dispose(): void
}
export interface TinyPgEvents extends EventEmitter {
on(event: 'query', listener: (x: QueryBeginContext) => void): this
on(event: 'result', listener: (x: QueryCompleteContext) => void): this
emit(event: 'query' | 'result', ...args: any[]): boolean
}
declare module 'pg' {
export interface PoolConfig {
log?: any
statement_timeout?: number
}
}