@prisma-next/sql-errors 0.3.0-pr.71.6 → 0.3.0-pr.71.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/errors.d.ts +44 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/exports/index.d.ts +2 -45
- package/dist/exports/index.d.ts.map +1 -0
- package/package.json +4 -3
- package/src/errors.ts +80 -0
- package/src/exports/index.ts +1 -0
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface SqlDriverError<Kind extends string> {
|
|
2
|
+
readonly kind: Kind;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* SQL query error for query-related failures (syntax errors, constraint violations, permissions).
|
|
6
|
+
*/
|
|
7
|
+
export declare class SqlQueryError extends Error implements SqlDriverError<'sql_query'> {
|
|
8
|
+
static readonly ERROR_NAME: "SqlQueryError";
|
|
9
|
+
readonly kind: "sql_query";
|
|
10
|
+
readonly sqlState: string | undefined;
|
|
11
|
+
readonly constraint: string | undefined;
|
|
12
|
+
readonly table: string | undefined;
|
|
13
|
+
readonly column: string | undefined;
|
|
14
|
+
readonly detail: string | undefined;
|
|
15
|
+
constructor(message: string, options?: {
|
|
16
|
+
readonly cause?: Error;
|
|
17
|
+
readonly sqlState?: string;
|
|
18
|
+
readonly constraint?: string;
|
|
19
|
+
readonly table?: string;
|
|
20
|
+
readonly column?: string;
|
|
21
|
+
readonly detail?: string;
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Type predicate to check if an error is a SqlQueryError.
|
|
25
|
+
*/
|
|
26
|
+
static is(error: unknown): error is SqlQueryError;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* SQL connection error (timeouts, connection resets, etc.).
|
|
30
|
+
*/
|
|
31
|
+
export declare class SqlConnectionError extends Error implements SqlDriverError<'sql_connection'> {
|
|
32
|
+
static readonly ERROR_NAME: "SqlConnectionError";
|
|
33
|
+
readonly kind: "sql_connection";
|
|
34
|
+
readonly transient: boolean | undefined;
|
|
35
|
+
constructor(message: string, options?: {
|
|
36
|
+
readonly cause?: Error;
|
|
37
|
+
readonly transient?: boolean;
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* Type predicate to check if an error is a SqlConnectionError.
|
|
41
|
+
*/
|
|
42
|
+
static is(error: unknown): error is SqlConnectionError;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc,CAAC,IAAI,SAAS,MAAM;IACjD,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACrB;AACD;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAM,YAAW,cAAc,CAAC,WAAW,CAAC;IAC7E,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAG,eAAe,CAAU;IACtD,QAAQ,CAAC,IAAI,EAAG,WAAW,CAAU;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;gBAGlC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;QACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;KAC1B;IAWH;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa;CAQlD;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAM,YAAW,cAAc,CAAC,gBAAgB,CAAC;IACvF,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAG,oBAAoB,CAAU;IAC3D,QAAQ,CAAC,IAAI,EAAG,gBAAgB,CAAU;IAC1C,QAAQ,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC;gBAGtC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;QACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;KAC9B;IAOH;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB;CAQvD"}
|
package/dist/exports/index.d.ts
CHANGED
|
@@ -1,45 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* SQL query error for query-related failures (syntax errors, constraint violations, permissions).
|
|
6
|
-
*/
|
|
7
|
-
declare class SqlQueryError extends Error implements SqlDriverError<'sql_query'> {
|
|
8
|
-
static readonly ERROR_NAME: "SqlQueryError";
|
|
9
|
-
readonly kind: "sql_query";
|
|
10
|
-
readonly sqlState: string | undefined;
|
|
11
|
-
readonly constraint: string | undefined;
|
|
12
|
-
readonly table: string | undefined;
|
|
13
|
-
readonly column: string | undefined;
|
|
14
|
-
readonly detail: string | undefined;
|
|
15
|
-
constructor(message: string, options?: {
|
|
16
|
-
readonly cause?: Error;
|
|
17
|
-
readonly sqlState?: string;
|
|
18
|
-
readonly constraint?: string;
|
|
19
|
-
readonly table?: string;
|
|
20
|
-
readonly column?: string;
|
|
21
|
-
readonly detail?: string;
|
|
22
|
-
});
|
|
23
|
-
/**
|
|
24
|
-
* Type predicate to check if an error is a SqlQueryError.
|
|
25
|
-
*/
|
|
26
|
-
static is(error: unknown): error is SqlQueryError;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* SQL connection error (timeouts, connection resets, etc.).
|
|
30
|
-
*/
|
|
31
|
-
declare class SqlConnectionError extends Error implements SqlDriverError<'sql_connection'> {
|
|
32
|
-
static readonly ERROR_NAME: "SqlConnectionError";
|
|
33
|
-
readonly kind: "sql_connection";
|
|
34
|
-
readonly transient: boolean | undefined;
|
|
35
|
-
constructor(message: string, options?: {
|
|
36
|
-
readonly cause?: Error;
|
|
37
|
-
readonly transient?: boolean;
|
|
38
|
-
});
|
|
39
|
-
/**
|
|
40
|
-
* Type predicate to check if an error is a SqlConnectionError.
|
|
41
|
-
*/
|
|
42
|
-
static is(error: unknown): error is SqlConnectionError;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export { SqlConnectionError, SqlQueryError };
|
|
1
|
+
export { SqlConnectionError, SqlQueryError } from '../errors';
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/sql-errors",
|
|
3
|
-
"version": "0.3.0-pr.71.
|
|
3
|
+
"version": "0.3.0-pr.71.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Normalized SQL driver error types for Prisma Next",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"@prisma-next/test-utils": "0.0.1"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"src"
|
|
17
18
|
],
|
|
18
19
|
"exports": {
|
|
19
20
|
".": {
|
|
@@ -22,7 +23,7 @@
|
|
|
22
23
|
}
|
|
23
24
|
},
|
|
24
25
|
"scripts": {
|
|
25
|
-
"build": "tsup --config tsup.config.ts",
|
|
26
|
+
"build": "tsup --config tsup.config.ts && tsc --project tsconfig.build.json",
|
|
26
27
|
"test": "vitest run",
|
|
27
28
|
"test:coverage": "vitest run --coverage",
|
|
28
29
|
"typecheck": "tsc --project tsconfig.json --noEmit",
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export interface SqlDriverError<Kind extends string> {
|
|
2
|
+
readonly kind: Kind;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* SQL query error for query-related failures (syntax errors, constraint violations, permissions).
|
|
6
|
+
*/
|
|
7
|
+
export class SqlQueryError extends Error implements SqlDriverError<'sql_query'> {
|
|
8
|
+
static readonly ERROR_NAME = 'SqlQueryError' as const;
|
|
9
|
+
readonly kind = 'sql_query' as const;
|
|
10
|
+
readonly sqlState: string | undefined;
|
|
11
|
+
readonly constraint: string | undefined;
|
|
12
|
+
readonly table: string | undefined;
|
|
13
|
+
readonly column: string | undefined;
|
|
14
|
+
readonly detail: string | undefined;
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
message: string,
|
|
18
|
+
options?: {
|
|
19
|
+
readonly cause?: Error;
|
|
20
|
+
readonly sqlState?: string;
|
|
21
|
+
readonly constraint?: string;
|
|
22
|
+
readonly table?: string;
|
|
23
|
+
readonly column?: string;
|
|
24
|
+
readonly detail?: string;
|
|
25
|
+
},
|
|
26
|
+
) {
|
|
27
|
+
super(message, { cause: options?.cause });
|
|
28
|
+
this.name = SqlQueryError.ERROR_NAME;
|
|
29
|
+
this.sqlState = options?.sqlState;
|
|
30
|
+
this.constraint = options?.constraint;
|
|
31
|
+
this.table = options?.table;
|
|
32
|
+
this.column = options?.column;
|
|
33
|
+
this.detail = options?.detail;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Type predicate to check if an error is a SqlQueryError.
|
|
38
|
+
*/
|
|
39
|
+
static is(error: unknown): error is SqlQueryError {
|
|
40
|
+
return (
|
|
41
|
+
typeof error === 'object' &&
|
|
42
|
+
error !== null &&
|
|
43
|
+
Object.hasOwn(error, 'kind') &&
|
|
44
|
+
(error as { kind: unknown }).kind === 'sql_query'
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* SQL connection error (timeouts, connection resets, etc.).
|
|
51
|
+
*/
|
|
52
|
+
export class SqlConnectionError extends Error implements SqlDriverError<'sql_connection'> {
|
|
53
|
+
static readonly ERROR_NAME = 'SqlConnectionError' as const;
|
|
54
|
+
readonly kind = 'sql_connection' as const;
|
|
55
|
+
readonly transient: boolean | undefined;
|
|
56
|
+
|
|
57
|
+
constructor(
|
|
58
|
+
message: string,
|
|
59
|
+
options?: {
|
|
60
|
+
readonly cause?: Error;
|
|
61
|
+
readonly transient?: boolean;
|
|
62
|
+
},
|
|
63
|
+
) {
|
|
64
|
+
super(message, { cause: options?.cause });
|
|
65
|
+
this.name = SqlConnectionError.ERROR_NAME;
|
|
66
|
+
this.transient = options?.transient;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Type predicate to check if an error is a SqlConnectionError.
|
|
71
|
+
*/
|
|
72
|
+
static is(error: unknown): error is SqlConnectionError {
|
|
73
|
+
return (
|
|
74
|
+
typeof error === 'object' &&
|
|
75
|
+
error !== null &&
|
|
76
|
+
Object.hasOwn(error, 'kind') &&
|
|
77
|
+
(error as { kind: unknown }).kind === 'sql_connection'
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SqlConnectionError, SqlQueryError } from '../errors';
|