forked from Vincit/db-errors
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
93 lines (73 loc) · 1.91 KB
/
index.d.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
declare namespace DbTypes {
type DBErrorClient = 'postgres' | 'mysql' | 'mssql' | 'sqlite';
interface DBErrorArgs {
nativeError: Error;
client: DBErrorClient;
}
class DBError extends Error {
constructor(args: DBErrorArgs);
name: string;
nativeError: Error;
client: DBErrorClient;
}
interface CheckViolationErrorArgs extends DBErrorArgs {
table: string;
constraint: string;
}
class CheckViolationError extends DBError {
constructor(args: CheckViolationErrorArgs);
table: string;
constraint: string;
}
class ConstraintViolationError extends DBError {}
class DataError extends DBError {}
interface ForeignKeyViolationErrorArgs extends DBErrorArgs {
table: string;
constraint: string;
schema?: string;
}
class ForeignKeyViolationError extends ConstraintViolationError {
constructor(args: ForeignKeyViolationErrorArgs);
table: string;
constraint: string;
schema?: string;
}
interface NotNullViolationErrorArgs extends DBErrorArgs {
table: string;
column: string;
database?: string;
schema?: string;
}
class NotNullViolationError extends ConstraintViolationError {
constructor(args: NotNullViolationErrorArgs);
table: string;
column: string;
database?: string;
schema?: string;
}
interface UniqueViolationErrorArgs extends DBErrorArgs {
table: string;
columns: string[];
constraint: string;
schema?: string;
}
class UniqueViolationError extends ConstraintViolationError {
constructor(args: UniqueViolationErrorArgs);
table: string;
columns: string[];
constraint: string;
schema?: string;
}
function wrapError(err: Error): DBError;
export {
wrapError,
DBError,
CheckViolationError,
ConstraintViolationError,
DataError,
ForeignKeyViolationError,
NotNullViolationError,
UniqueViolationError,
};
}
export = DbTypes;