From 223aa1fdeafc087c0724d86d813b8c807df19269 Mon Sep 17 00:00:00 2001 From: Tom Spencer Date: Fri, 20 Mar 2020 21:56:36 +0000 Subject: [PATCH] Add constructor types --- index.d.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/index.d.ts b/index.d.ts index 099e376..40444a3 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,11 +1,24 @@ declare namespace DbTypes { + interface DBErrorArgs { + nativeError: Error; + client: 'postgres' | 'mysql' | 'mssql' | 'sqlite'; + } + class DBError extends Error { + constructor(args: DBErrorArgs); name: string; nativeError: Error; + client: 'postgres' | 'mysql' | 'mssql' | 'sqlite'; + } + + interface CheckViolationErrorArgs extends DBErrorArgs { + table: string; + constraint: string; } class CheckViolationError extends DBError { + constructor(args: CheckViolationErrorArgs); table: string; constraint: string; } @@ -14,20 +27,43 @@ declare namespace DbTypes { class DataError extends DBError {} + interface ForeignKeyViolationErrorArgs extends DBErrorArgs { + constructor(args: ForeignKeyViolationErrorArgs); + table: string; + constraint: string; + schema?: string; + } + class ForeignKeyViolationError extends ConstraintViolationError { table: string; constraint: string; schema?: string; } + interface NotNullViolationErrorArgs extends DBErrorArgs { + table: string; + column: string; + schema?: string; + database?: string; + } + class NotNullViolationError extends ConstraintViolationError { + constructor(args: NotNullViolationErrorArgs); table: string; column: string; + schema?: string; database?: 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;