@nextlyhq/adapter-drizzle 0.0.2-alpha.7 → 0.0.2-alpha.70

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.
Files changed (64) hide show
  1. package/README.md +25 -1
  2. package/dist/adapter-BypoOEEN.d.cts +1166 -0
  3. package/dist/adapter-CSP-Ek-L.d.ts +1166 -0
  4. package/dist/index-BYb6cDli.d.ts +1168 -0
  5. package/dist/index-C4HJsfwA.d.cts +1168 -0
  6. package/dist/index.cjs +2302 -1085
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.cts +5 -9
  9. package/dist/index.d.ts +5 -9
  10. package/dist/index.mjs +2301 -1083
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/migrations.cjs +345 -146
  13. package/dist/migrations.cjs.map +1 -1
  14. package/dist/migrations.d.cts +93 -109
  15. package/dist/migrations.d.ts +93 -109
  16. package/dist/migrations.mjs +344 -144
  17. package/dist/migrations.mjs.map +1 -1
  18. package/dist/schema/index.cjs +21 -6
  19. package/dist/schema/index.cjs.map +1 -1
  20. package/dist/schema/index.d.cts +5 -116
  21. package/dist/schema/index.d.ts +5 -116
  22. package/dist/schema/index.mjs +20 -4
  23. package/dist/schema/index.mjs.map +1 -1
  24. package/dist/schema-Bkkr3JMC.d.cts +264 -0
  25. package/dist/schema-Bkkr3JMC.d.ts +264 -0
  26. package/dist/schema-name.cjs +42 -0
  27. package/dist/schema-name.cjs.map +1 -0
  28. package/dist/schema-name.d.cts +12 -0
  29. package/dist/schema-name.d.ts +12 -0
  30. package/dist/schema-name.mjs +40 -0
  31. package/dist/schema-name.mjs.map +1 -0
  32. package/dist/text-match.cjs +50 -0
  33. package/dist/text-match.cjs.map +1 -0
  34. package/dist/text-match.d.cts +32 -0
  35. package/dist/text-match.d.ts +32 -0
  36. package/dist/text-match.mjs +48 -0
  37. package/dist/text-match.mjs.map +1 -0
  38. package/dist/types/index.cjs +8 -24
  39. package/dist/types/index.d.cts +3 -210
  40. package/dist/types/index.d.ts +3 -210
  41. package/dist/types/index.mjs +1 -21
  42. package/dist/types-CNyA1oIm.cjs +185 -0
  43. package/dist/types-CNyA1oIm.cjs.map +1 -0
  44. package/dist/types-CaF_5jNk.mjs +150 -0
  45. package/dist/types-CaF_5jNk.mjs.map +1 -0
  46. package/dist/version-check.cjs +119 -127
  47. package/dist/version-check.cjs.map +1 -1
  48. package/dist/version-check.d.cts +54 -39
  49. package/dist/version-check.d.ts +54 -39
  50. package/dist/version-check.mjs +117 -125
  51. package/dist/version-check.mjs.map +1 -1
  52. package/package.json +23 -17
  53. package/dist/adapter-BxJVtttb.d.ts +0 -592
  54. package/dist/adapter-nvlxFkF-.d.cts +0 -592
  55. package/dist/core-CVO7WYDj.d.cts +0 -74
  56. package/dist/core-CVO7WYDj.d.ts +0 -74
  57. package/dist/error-um1d_3Uo.d.cts +0 -105
  58. package/dist/error-um1d_3Uo.d.ts +0 -105
  59. package/dist/migration-BbO5meEV.d.cts +0 -622
  60. package/dist/migration-Qe70wDOC.d.ts +0 -622
  61. package/dist/schema-BDn8WfSL.d.cts +0 -200
  62. package/dist/schema-BIQ0YQZ_.d.ts +0 -200
  63. package/dist/types/index.cjs.map +0 -1
  64. package/dist/types/index.mjs.map +0 -1
@@ -1,200 +0,0 @@
1
- import { a as SqlParam } from './core-CVO7WYDj.cjs';
2
-
3
- /**
4
- * Database schema type definitions.
5
- *
6
- * @packageDocumentation
7
- */
8
-
9
- /**
10
- * Column definition for schema operations.
11
- *
12
- * @remarks
13
- * Defines the structure of a database column in a database-agnostic way.
14
- * Adapters translate these definitions to dialect-specific DDL.
15
- *
16
- * @public
17
- */
18
- interface ColumnDefinition {
19
- /** Column name */
20
- name: string;
21
- /**
22
- * Column data type.
23
- *
24
- * @remarks
25
- * Common types across databases:
26
- * - Text: varchar(n), text, char(n)
27
- * - Numbers: int, bigint, decimal, numeric
28
- * - Boolean: boolean
29
- * - Date/Time: timestamp, date, time
30
- * - JSON: json, jsonb (PostgreSQL)
31
- * - UUID: uuid (PostgreSQL), char(36) (MySQL/SQLite)
32
- *
33
- * Adapters handle dialect-specific type mapping.
34
- */
35
- type: string;
36
- /** Allow NULL values (default: true) */
37
- nullable?: boolean;
38
- /** Primary key column */
39
- primaryKey?: boolean;
40
- /** Unique constraint */
41
- unique?: boolean;
42
- /** Default value (literal or SQL expression) */
43
- default?: SqlParam | {
44
- sql: string;
45
- };
46
- /** Foreign key reference */
47
- references?: {
48
- /** Referenced table name */
49
- table: string;
50
- /** Referenced column name */
51
- column: string;
52
- /** Action on DELETE */
53
- onDelete?: "no action" | "restrict" | "cascade" | "set null" | "set default";
54
- /** Action on UPDATE */
55
- onUpdate?: "no action" | "restrict" | "cascade" | "set null" | "set default";
56
- };
57
- /** Check constraint expression */
58
- check?: string;
59
- /** Generated column definition (computed column) */
60
- generated?: {
61
- /** SQL expression to generate the value */
62
- as: string;
63
- /** Store the value (true) or compute on-the-fly (false) */
64
- stored?: boolean;
65
- };
66
- }
67
- /**
68
- * Index definition for schema operations.
69
- *
70
- * @remarks
71
- * Defines database indexes for performance optimization.
72
- *
73
- * @public
74
- */
75
- interface IndexDefinition {
76
- /** Index name */
77
- name: string;
78
- /** Columns included in the index */
79
- columns: string[];
80
- /** Unique index (enforces uniqueness) */
81
- unique?: boolean;
82
- /** Partial index condition (WHERE clause) */
83
- where?: string;
84
- /** Index type (database-specific) */
85
- using?: "btree" | "hash" | "gin" | "gist" | "brin";
86
- }
87
- /**
88
- * Table constraint definition.
89
- *
90
- * @public
91
- */
92
- interface TableConstraint {
93
- /** Constraint name */
94
- name: string;
95
- /** Constraint type */
96
- type: "unique" | "check" | "foreign_key" | "primary_key";
97
- /** Columns involved in the constraint */
98
- columns?: string[];
99
- /** Check constraint expression */
100
- expression?: string;
101
- /** Foreign key reference (for foreign_key type) */
102
- references?: {
103
- /** Referenced table name */
104
- table: string;
105
- /** Referenced columns */
106
- columns: string[];
107
- /** Action on DELETE */
108
- onDelete?: "no action" | "restrict" | "cascade" | "set null" | "set default";
109
- /** Action on UPDATE */
110
- onUpdate?: "no action" | "restrict" | "cascade" | "set null" | "set default";
111
- };
112
- }
113
- /**
114
- * Complete table definition.
115
- *
116
- * @remarks
117
- * Defines the complete structure of a database table including columns,
118
- * indexes, and constraints.
119
- *
120
- * @public
121
- */
122
- interface TableDefinition {
123
- /** Table name */
124
- name: string;
125
- /** Column definitions */
126
- columns: ColumnDefinition[];
127
- /** Composite primary key (if not defined at column level) */
128
- primaryKey?: string[];
129
- /** Index definitions */
130
- indexes?: IndexDefinition[];
131
- /** Table-level constraints */
132
- constraints?: TableConstraint[];
133
- /** Table comment/description */
134
- comment?: string;
135
- }
136
- /**
137
- * Options for table creation.
138
- *
139
- * @public
140
- */
141
- interface CreateTableOptions {
142
- /** Don't throw error if table exists */
143
- ifNotExists?: boolean;
144
- /** Temporary table (session-scoped) */
145
- temporary?: boolean;
146
- }
147
- /**
148
- * Options for table dropping.
149
- *
150
- * @public
151
- */
152
- interface DropTableOptions {
153
- /** Don't throw error if table doesn't exist */
154
- ifExists?: boolean;
155
- /** Drop dependent objects (CASCADE) */
156
- cascade?: boolean;
157
- /** Restrict drop if dependencies exist (default) */
158
- restrict?: boolean;
159
- }
160
- /**
161
- * Options for table alteration.
162
- *
163
- * @public
164
- */
165
- interface AlterTableOptions {
166
- /** Validation mode for constraints */
167
- validate?: boolean;
168
- }
169
- /**
170
- * Table alteration operations.
171
- *
172
- * @remarks
173
- * Defines the types of operations that can be performed when altering a table.
174
- *
175
- * @public
176
- */
177
- type AlterTableOperation = {
178
- kind: "add_column";
179
- column: ColumnDefinition;
180
- } | {
181
- kind: "drop_column";
182
- columnName: string;
183
- cascade?: boolean;
184
- } | {
185
- kind: "rename_column";
186
- from: string;
187
- to: string;
188
- } | {
189
- kind: "modify_column";
190
- column: ColumnDefinition;
191
- } | {
192
- kind: "add_constraint";
193
- constraint: TableConstraint;
194
- } | {
195
- kind: "drop_constraint";
196
- constraintName: string;
197
- cascade?: boolean;
198
- };
199
-
200
- export type { AlterTableOperation as A, CreateTableOptions as C, DropTableOptions as D, IndexDefinition as I, TableDefinition as T, AlterTableOptions as a, ColumnDefinition as b, TableConstraint as c };
@@ -1,200 +0,0 @@
1
- import { a as SqlParam } from './core-CVO7WYDj.js';
2
-
3
- /**
4
- * Database schema type definitions.
5
- *
6
- * @packageDocumentation
7
- */
8
-
9
- /**
10
- * Column definition for schema operations.
11
- *
12
- * @remarks
13
- * Defines the structure of a database column in a database-agnostic way.
14
- * Adapters translate these definitions to dialect-specific DDL.
15
- *
16
- * @public
17
- */
18
- interface ColumnDefinition {
19
- /** Column name */
20
- name: string;
21
- /**
22
- * Column data type.
23
- *
24
- * @remarks
25
- * Common types across databases:
26
- * - Text: varchar(n), text, char(n)
27
- * - Numbers: int, bigint, decimal, numeric
28
- * - Boolean: boolean
29
- * - Date/Time: timestamp, date, time
30
- * - JSON: json, jsonb (PostgreSQL)
31
- * - UUID: uuid (PostgreSQL), char(36) (MySQL/SQLite)
32
- *
33
- * Adapters handle dialect-specific type mapping.
34
- */
35
- type: string;
36
- /** Allow NULL values (default: true) */
37
- nullable?: boolean;
38
- /** Primary key column */
39
- primaryKey?: boolean;
40
- /** Unique constraint */
41
- unique?: boolean;
42
- /** Default value (literal or SQL expression) */
43
- default?: SqlParam | {
44
- sql: string;
45
- };
46
- /** Foreign key reference */
47
- references?: {
48
- /** Referenced table name */
49
- table: string;
50
- /** Referenced column name */
51
- column: string;
52
- /** Action on DELETE */
53
- onDelete?: "no action" | "restrict" | "cascade" | "set null" | "set default";
54
- /** Action on UPDATE */
55
- onUpdate?: "no action" | "restrict" | "cascade" | "set null" | "set default";
56
- };
57
- /** Check constraint expression */
58
- check?: string;
59
- /** Generated column definition (computed column) */
60
- generated?: {
61
- /** SQL expression to generate the value */
62
- as: string;
63
- /** Store the value (true) or compute on-the-fly (false) */
64
- stored?: boolean;
65
- };
66
- }
67
- /**
68
- * Index definition for schema operations.
69
- *
70
- * @remarks
71
- * Defines database indexes for performance optimization.
72
- *
73
- * @public
74
- */
75
- interface IndexDefinition {
76
- /** Index name */
77
- name: string;
78
- /** Columns included in the index */
79
- columns: string[];
80
- /** Unique index (enforces uniqueness) */
81
- unique?: boolean;
82
- /** Partial index condition (WHERE clause) */
83
- where?: string;
84
- /** Index type (database-specific) */
85
- using?: "btree" | "hash" | "gin" | "gist" | "brin";
86
- }
87
- /**
88
- * Table constraint definition.
89
- *
90
- * @public
91
- */
92
- interface TableConstraint {
93
- /** Constraint name */
94
- name: string;
95
- /** Constraint type */
96
- type: "unique" | "check" | "foreign_key" | "primary_key";
97
- /** Columns involved in the constraint */
98
- columns?: string[];
99
- /** Check constraint expression */
100
- expression?: string;
101
- /** Foreign key reference (for foreign_key type) */
102
- references?: {
103
- /** Referenced table name */
104
- table: string;
105
- /** Referenced columns */
106
- columns: string[];
107
- /** Action on DELETE */
108
- onDelete?: "no action" | "restrict" | "cascade" | "set null" | "set default";
109
- /** Action on UPDATE */
110
- onUpdate?: "no action" | "restrict" | "cascade" | "set null" | "set default";
111
- };
112
- }
113
- /**
114
- * Complete table definition.
115
- *
116
- * @remarks
117
- * Defines the complete structure of a database table including columns,
118
- * indexes, and constraints.
119
- *
120
- * @public
121
- */
122
- interface TableDefinition {
123
- /** Table name */
124
- name: string;
125
- /** Column definitions */
126
- columns: ColumnDefinition[];
127
- /** Composite primary key (if not defined at column level) */
128
- primaryKey?: string[];
129
- /** Index definitions */
130
- indexes?: IndexDefinition[];
131
- /** Table-level constraints */
132
- constraints?: TableConstraint[];
133
- /** Table comment/description */
134
- comment?: string;
135
- }
136
- /**
137
- * Options for table creation.
138
- *
139
- * @public
140
- */
141
- interface CreateTableOptions {
142
- /** Don't throw error if table exists */
143
- ifNotExists?: boolean;
144
- /** Temporary table (session-scoped) */
145
- temporary?: boolean;
146
- }
147
- /**
148
- * Options for table dropping.
149
- *
150
- * @public
151
- */
152
- interface DropTableOptions {
153
- /** Don't throw error if table doesn't exist */
154
- ifExists?: boolean;
155
- /** Drop dependent objects (CASCADE) */
156
- cascade?: boolean;
157
- /** Restrict drop if dependencies exist (default) */
158
- restrict?: boolean;
159
- }
160
- /**
161
- * Options for table alteration.
162
- *
163
- * @public
164
- */
165
- interface AlterTableOptions {
166
- /** Validation mode for constraints */
167
- validate?: boolean;
168
- }
169
- /**
170
- * Table alteration operations.
171
- *
172
- * @remarks
173
- * Defines the types of operations that can be performed when altering a table.
174
- *
175
- * @public
176
- */
177
- type AlterTableOperation = {
178
- kind: "add_column";
179
- column: ColumnDefinition;
180
- } | {
181
- kind: "drop_column";
182
- columnName: string;
183
- cascade?: boolean;
184
- } | {
185
- kind: "rename_column";
186
- from: string;
187
- to: string;
188
- } | {
189
- kind: "modify_column";
190
- column: ColumnDefinition;
191
- } | {
192
- kind: "add_constraint";
193
- constraint: TableConstraint;
194
- } | {
195
- kind: "drop_constraint";
196
- constraintName: string;
197
- cascade?: boolean;
198
- };
199
-
200
- export type { AlterTableOperation as A, CreateTableOptions as C, DropTableOptions as D, IndexDefinition as I, TableDefinition as T, AlterTableOptions as a, ColumnDefinition as b, TableConstraint as c };
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/types/error.ts"],"names":[],"mappings":";;;AAuFO,SAAS,gBAAgB,KAAA,EAAwC;AACtE,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,MAAA,IAAU,KAAA,IACV,OAAQ,KAAA,CAAwB,IAAA,KAAS,QAAA;AAE7C;AA+CO,SAAS,oBACd,OAAA,EACe;AACf,EAAA,MAAM,KAAA,GAAQ,IAAI,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA;AACvC,EAAA,KAAA,CAAM,IAAA,GAAO,eAAA;AACb,EAAA,KAAA,CAAM,OAAO,OAAA,CAAQ,IAAA;AAErB,EAAA,IAAI,OAAA,CAAQ,IAAA,KAAS,MAAA,EAAW,KAAA,CAAM,OAAO,OAAA,CAAQ,IAAA;AACrD,EAAA,IAAI,OAAA,CAAQ,UAAA,KAAe,MAAA,EAAW,KAAA,CAAM,aAAa,OAAA,CAAQ,UAAA;AACjE,EAAA,IAAI,OAAA,CAAQ,KAAA,KAAU,MAAA,EAAW,KAAA,CAAM,QAAQ,OAAA,CAAQ,KAAA;AACvD,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,MAAA,EAAW,KAAA,CAAM,SAAS,OAAA,CAAQ,MAAA;AACzD,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,MAAA,EAAW,KAAA,CAAM,SAAS,OAAA,CAAQ,MAAA;AACzD,EAAA,IAAI,OAAA,CAAQ,IAAA,KAAS,MAAA,EAAW,KAAA,CAAM,OAAO,OAAA,CAAQ,IAAA;AACrD,EAAA,IAAI,OAAA,CAAQ,KAAA,KAAU,MAAA,EAAW,KAAA,CAAM,QAAQ,OAAA,CAAQ,KAAA;AAEvD,EAAA,OAAO,KAAA;AACT","file":"index.cjs","sourcesContent":["/**\n * Database error type definitions.\n *\n * @packageDocumentation\n */\n\n/**\n * Database error classification.\n *\n * @remarks\n * Categorizes database errors for consistent error handling across adapters.\n * Each adapter translates database-specific error codes to these kinds.\n *\n * @public\n */\nexport type DatabaseErrorKind =\n | \"connection\" // Connection/network errors\n | \"query\" // Syntax or execution errors\n | \"constraint\" // Generic constraint violation\n | \"unique_violation\" // Unique constraint violation\n | \"foreign_key_violation\" // Foreign key constraint violation\n | \"check_violation\" // Check constraint violation\n | \"not_null_violation\" // NOT NULL constraint violation\n | \"deadlock\" // Transaction deadlock\n | \"timeout\" // Query or connection timeout\n | \"serialization_failure\" // Serializable transaction conflict\n | \"unsupported_version\" // F17: DB version below minimum or unparseable at connect\n | \"unknown\"; // Unclassified error\n\n/**\n * Enhanced database error interface.\n *\n * @remarks\n * Extends the standard Error interface with database-specific context.\n * Adapters should throw errors implementing this interface for consistent\n * error handling.\n *\n * @example\n * ```typescript\n * try {\n * await adapter.insert('users', { email: 'duplicate@example.com' });\n * } catch (error) {\n * if (isDatabaseError(error) && error.kind === 'unique_violation') {\n * console.log(`Duplicate ${error.column} in ${error.table}`);\n * }\n * }\n * ```\n *\n * @public\n */\nexport interface DatabaseError extends Error {\n /** Error classification */\n kind: DatabaseErrorKind;\n\n /** Database-specific error code (e.g., \"23505\" for PostgreSQL unique violation) */\n code?: string;\n\n /** Constraint name that was violated (if applicable) */\n constraint?: string;\n\n /** Table name involved in the error */\n table?: string;\n\n /** Column name involved in the error */\n column?: string;\n\n /** Detailed error description from the database */\n detail?: string;\n\n /** Hint for resolving the error */\n hint?: string;\n\n /** Original error from the database driver */\n cause?: Error;\n}\n\n/**\n * Type guard for DatabaseError.\n *\n * @remarks\n * Checks if an error is a DatabaseError with proper typing.\n *\n * @param error - Error to check\n * @returns True if error is a DatabaseError\n *\n * @public\n */\nexport function isDatabaseError(error: unknown): error is DatabaseError {\n return (\n typeof error === \"object\" &&\n error !== null &&\n \"kind\" in error &&\n typeof (error as DatabaseError).kind === \"string\"\n );\n}\n\n/**\n * Database error constructor options.\n *\n * @public\n */\nexport interface DatabaseErrorOptions {\n /** Error classification */\n kind: DatabaseErrorKind;\n\n /** Error message */\n message: string;\n\n /** Database-specific error code */\n code?: string;\n\n /** Constraint name */\n constraint?: string;\n\n /** Table name */\n table?: string;\n\n /** Column name */\n column?: string;\n\n /** Detailed description */\n detail?: string;\n\n /** Resolution hint */\n hint?: string;\n\n /** Original error */\n cause?: Error;\n}\n\n/**\n * Create a DatabaseError instance.\n *\n * @remarks\n * Helper function to create properly structured DatabaseError objects.\n *\n * @param options - Error options\n * @returns DatabaseError instance\n *\n * @public\n */\nexport function createDatabaseError(\n options: DatabaseErrorOptions\n): DatabaseError {\n const error = new Error(options.message) as DatabaseError;\n error.name = \"DatabaseError\";\n error.kind = options.kind;\n\n if (options.code !== undefined) error.code = options.code;\n if (options.constraint !== undefined) error.constraint = options.constraint;\n if (options.table !== undefined) error.table = options.table;\n if (options.column !== undefined) error.column = options.column;\n if (options.detail !== undefined) error.detail = options.detail;\n if (options.hint !== undefined) error.hint = options.hint;\n if (options.cause !== undefined) error.cause = options.cause;\n\n return error;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/types/error.ts"],"names":[],"mappings":";AAuFO,SAAS,gBAAgB,KAAA,EAAwC;AACtE,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,MAAA,IAAU,KAAA,IACV,OAAQ,KAAA,CAAwB,IAAA,KAAS,QAAA;AAE7C;AA+CO,SAAS,oBACd,OAAA,EACe;AACf,EAAA,MAAM,KAAA,GAAQ,IAAI,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA;AACvC,EAAA,KAAA,CAAM,IAAA,GAAO,eAAA;AACb,EAAA,KAAA,CAAM,OAAO,OAAA,CAAQ,IAAA;AAErB,EAAA,IAAI,OAAA,CAAQ,IAAA,KAAS,MAAA,EAAW,KAAA,CAAM,OAAO,OAAA,CAAQ,IAAA;AACrD,EAAA,IAAI,OAAA,CAAQ,UAAA,KAAe,MAAA,EAAW,KAAA,CAAM,aAAa,OAAA,CAAQ,UAAA;AACjE,EAAA,IAAI,OAAA,CAAQ,KAAA,KAAU,MAAA,EAAW,KAAA,CAAM,QAAQ,OAAA,CAAQ,KAAA;AACvD,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,MAAA,EAAW,KAAA,CAAM,SAAS,OAAA,CAAQ,MAAA;AACzD,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,MAAA,EAAW,KAAA,CAAM,SAAS,OAAA,CAAQ,MAAA;AACzD,EAAA,IAAI,OAAA,CAAQ,IAAA,KAAS,MAAA,EAAW,KAAA,CAAM,OAAO,OAAA,CAAQ,IAAA;AACrD,EAAA,IAAI,OAAA,CAAQ,KAAA,KAAU,MAAA,EAAW,KAAA,CAAM,QAAQ,OAAA,CAAQ,KAAA;AAEvD,EAAA,OAAO,KAAA;AACT","file":"index.mjs","sourcesContent":["/**\n * Database error type definitions.\n *\n * @packageDocumentation\n */\n\n/**\n * Database error classification.\n *\n * @remarks\n * Categorizes database errors for consistent error handling across adapters.\n * Each adapter translates database-specific error codes to these kinds.\n *\n * @public\n */\nexport type DatabaseErrorKind =\n | \"connection\" // Connection/network errors\n | \"query\" // Syntax or execution errors\n | \"constraint\" // Generic constraint violation\n | \"unique_violation\" // Unique constraint violation\n | \"foreign_key_violation\" // Foreign key constraint violation\n | \"check_violation\" // Check constraint violation\n | \"not_null_violation\" // NOT NULL constraint violation\n | \"deadlock\" // Transaction deadlock\n | \"timeout\" // Query or connection timeout\n | \"serialization_failure\" // Serializable transaction conflict\n | \"unsupported_version\" // F17: DB version below minimum or unparseable at connect\n | \"unknown\"; // Unclassified error\n\n/**\n * Enhanced database error interface.\n *\n * @remarks\n * Extends the standard Error interface with database-specific context.\n * Adapters should throw errors implementing this interface for consistent\n * error handling.\n *\n * @example\n * ```typescript\n * try {\n * await adapter.insert('users', { email: 'duplicate@example.com' });\n * } catch (error) {\n * if (isDatabaseError(error) && error.kind === 'unique_violation') {\n * console.log(`Duplicate ${error.column} in ${error.table}`);\n * }\n * }\n * ```\n *\n * @public\n */\nexport interface DatabaseError extends Error {\n /** Error classification */\n kind: DatabaseErrorKind;\n\n /** Database-specific error code (e.g., \"23505\" for PostgreSQL unique violation) */\n code?: string;\n\n /** Constraint name that was violated (if applicable) */\n constraint?: string;\n\n /** Table name involved in the error */\n table?: string;\n\n /** Column name involved in the error */\n column?: string;\n\n /** Detailed error description from the database */\n detail?: string;\n\n /** Hint for resolving the error */\n hint?: string;\n\n /** Original error from the database driver */\n cause?: Error;\n}\n\n/**\n * Type guard for DatabaseError.\n *\n * @remarks\n * Checks if an error is a DatabaseError with proper typing.\n *\n * @param error - Error to check\n * @returns True if error is a DatabaseError\n *\n * @public\n */\nexport function isDatabaseError(error: unknown): error is DatabaseError {\n return (\n typeof error === \"object\" &&\n error !== null &&\n \"kind\" in error &&\n typeof (error as DatabaseError).kind === \"string\"\n );\n}\n\n/**\n * Database error constructor options.\n *\n * @public\n */\nexport interface DatabaseErrorOptions {\n /** Error classification */\n kind: DatabaseErrorKind;\n\n /** Error message */\n message: string;\n\n /** Database-specific error code */\n code?: string;\n\n /** Constraint name */\n constraint?: string;\n\n /** Table name */\n table?: string;\n\n /** Column name */\n column?: string;\n\n /** Detailed description */\n detail?: string;\n\n /** Resolution hint */\n hint?: string;\n\n /** Original error */\n cause?: Error;\n}\n\n/**\n * Create a DatabaseError instance.\n *\n * @remarks\n * Helper function to create properly structured DatabaseError objects.\n *\n * @param options - Error options\n * @returns DatabaseError instance\n *\n * @public\n */\nexport function createDatabaseError(\n options: DatabaseErrorOptions\n): DatabaseError {\n const error = new Error(options.message) as DatabaseError;\n error.name = \"DatabaseError\";\n error.kind = options.kind;\n\n if (options.code !== undefined) error.code = options.code;\n if (options.constraint !== undefined) error.constraint = options.constraint;\n if (options.table !== undefined) error.table = options.table;\n if (options.column !== undefined) error.column = options.column;\n if (options.detail !== undefined) error.detail = options.detail;\n if (options.hint !== undefined) error.hint = options.hint;\n if (options.cause !== undefined) error.cause = options.cause;\n\n return error;\n}\n"]}