@nextlyhq/adapter-drizzle 0.0.1

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 (43) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +9 -0
  3. package/dist/adapter-BxJVtttb.d.ts +592 -0
  4. package/dist/adapter-nvlxFkF-.d.cts +592 -0
  5. package/dist/core-CVO7WYDj.d.cts +74 -0
  6. package/dist/core-CVO7WYDj.d.ts +74 -0
  7. package/dist/error-um1d_3Uo.d.cts +105 -0
  8. package/dist/error-um1d_3Uo.d.ts +105 -0
  9. package/dist/index.cjs +1137 -0
  10. package/dist/index.cjs.map +1 -0
  11. package/dist/index.d.cts +57 -0
  12. package/dist/index.d.ts +57 -0
  13. package/dist/index.mjs +1134 -0
  14. package/dist/index.mjs.map +1 -0
  15. package/dist/migration-BbO5meEV.d.cts +622 -0
  16. package/dist/migration-Qe70wDOC.d.ts +622 -0
  17. package/dist/migrations.cjs +195 -0
  18. package/dist/migrations.cjs.map +1 -0
  19. package/dist/migrations.d.cts +351 -0
  20. package/dist/migrations.d.ts +351 -0
  21. package/dist/migrations.mjs +185 -0
  22. package/dist/migrations.mjs.map +1 -0
  23. package/dist/schema/index.cjs +10 -0
  24. package/dist/schema/index.cjs.map +1 -0
  25. package/dist/schema/index.d.cts +133 -0
  26. package/dist/schema/index.d.ts +133 -0
  27. package/dist/schema/index.mjs +7 -0
  28. package/dist/schema/index.mjs.map +1 -0
  29. package/dist/schema-BDn8WfSL.d.cts +200 -0
  30. package/dist/schema-BIQ0YQZ_.d.ts +200 -0
  31. package/dist/types/index.cjs +24 -0
  32. package/dist/types/index.cjs.map +1 -0
  33. package/dist/types/index.d.cts +210 -0
  34. package/dist/types/index.d.ts +210 -0
  35. package/dist/types/index.mjs +21 -0
  36. package/dist/types/index.mjs.map +1 -0
  37. package/dist/version-check.cjs +154 -0
  38. package/dist/version-check.cjs.map +1 -0
  39. package/dist/version-check.d.cts +43 -0
  40. package/dist/version-check.d.ts +43 -0
  41. package/dist/version-check.mjs +150 -0
  42. package/dist/version-check.mjs.map +1 -0
  43. package/package.json +94 -0
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Core type definitions for the Nextly database adapter system.
3
+ *
4
+ * These types are the foundation for all database operations and are designed
5
+ * to be database-agnostic while supporting dialect-specific features.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ /**
10
+ * Supported database dialects.
11
+ *
12
+ * @remarks
13
+ * These are the database systems that Nextly officially supports through
14
+ * dedicated adapter packages.
15
+ *
16
+ * @public
17
+ */
18
+ type SupportedDialect = "postgresql" | "mysql" | "sqlite";
19
+ /**
20
+ * SQL parameter types that are safe to use across all database dialects.
21
+ *
22
+ * @remarks
23
+ * - `undefined` is included for optional parameters
24
+ * - `Date` objects will be converted to appropriate format per dialect
25
+ * - `null` represents SQL NULL
26
+ *
27
+ * @public
28
+ */
29
+ type SqlParam = string | number | boolean | Date | null | undefined;
30
+ /**
31
+ * JSON value types that can be stored in JSON/JSONB columns.
32
+ *
33
+ * @remarks
34
+ * Represents the valid JSON value types as defined by the JSON specification.
35
+ * This is a recursive type to support nested objects and arrays.
36
+ *
37
+ * @public
38
+ */
39
+ type JsonValue = string | number | boolean | null | JsonValue[] | {
40
+ [key: string]: JsonValue;
41
+ };
42
+ /**
43
+ * JSON object type for structured data.
44
+ *
45
+ * @remarks
46
+ * Useful for typed JSON column data where the structure is known.
47
+ *
48
+ * @public
49
+ */
50
+ type JsonObject = {
51
+ [key: string]: JsonValue;
52
+ };
53
+ /**
54
+ * JSON array type.
55
+ *
56
+ * @public
57
+ */
58
+ type JsonArray = JsonValue[];
59
+ /**
60
+ * Interface for resolving table names to Drizzle table objects.
61
+ *
62
+ * @remarks
63
+ * When a TableResolver is set on the adapter via `setTableResolver()`,
64
+ * CRUD methods will use Drizzle's query API instead of raw SQL string building.
65
+ * The nextly SchemaRegistry implements this interface.
66
+ *
67
+ * @public
68
+ */
69
+ interface TableResolver {
70
+ /** Look up a Drizzle table object by table name. Returns null if not found. */
71
+ getTable(tableName: string): unknown;
72
+ }
73
+
74
+ export type { JsonArray as J, SupportedDialect as S, TableResolver as T, SqlParam as a, JsonObject as b, JsonValue as c };
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Database error type definitions.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ /**
7
+ * Database error classification.
8
+ *
9
+ * @remarks
10
+ * Categorizes database errors for consistent error handling across adapters.
11
+ * Each adapter translates database-specific error codes to these kinds.
12
+ *
13
+ * @public
14
+ */
15
+ type DatabaseErrorKind = "connection" | "query" | "constraint" | "unique_violation" | "foreign_key_violation" | "check_violation" | "not_null_violation" | "deadlock" | "timeout" | "serialization_failure" | "unsupported_version" | "unknown";
16
+ /**
17
+ * Enhanced database error interface.
18
+ *
19
+ * @remarks
20
+ * Extends the standard Error interface with database-specific context.
21
+ * Adapters should throw errors implementing this interface for consistent
22
+ * error handling.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * try {
27
+ * await adapter.insert('users', { email: 'duplicate@example.com' });
28
+ * } catch (error) {
29
+ * if (isDatabaseError(error) && error.kind === 'unique_violation') {
30
+ * console.log(`Duplicate ${error.column} in ${error.table}`);
31
+ * }
32
+ * }
33
+ * ```
34
+ *
35
+ * @public
36
+ */
37
+ interface DatabaseError extends Error {
38
+ /** Error classification */
39
+ kind: DatabaseErrorKind;
40
+ /** Database-specific error code (e.g., "23505" for PostgreSQL unique violation) */
41
+ code?: string;
42
+ /** Constraint name that was violated (if applicable) */
43
+ constraint?: string;
44
+ /** Table name involved in the error */
45
+ table?: string;
46
+ /** Column name involved in the error */
47
+ column?: string;
48
+ /** Detailed error description from the database */
49
+ detail?: string;
50
+ /** Hint for resolving the error */
51
+ hint?: string;
52
+ /** Original error from the database driver */
53
+ cause?: Error;
54
+ }
55
+ /**
56
+ * Type guard for DatabaseError.
57
+ *
58
+ * @remarks
59
+ * Checks if an error is a DatabaseError with proper typing.
60
+ *
61
+ * @param error - Error to check
62
+ * @returns True if error is a DatabaseError
63
+ *
64
+ * @public
65
+ */
66
+ declare function isDatabaseError(error: unknown): error is DatabaseError;
67
+ /**
68
+ * Database error constructor options.
69
+ *
70
+ * @public
71
+ */
72
+ interface DatabaseErrorOptions {
73
+ /** Error classification */
74
+ kind: DatabaseErrorKind;
75
+ /** Error message */
76
+ message: string;
77
+ /** Database-specific error code */
78
+ code?: string;
79
+ /** Constraint name */
80
+ constraint?: string;
81
+ /** Table name */
82
+ table?: string;
83
+ /** Column name */
84
+ column?: string;
85
+ /** Detailed description */
86
+ detail?: string;
87
+ /** Resolution hint */
88
+ hint?: string;
89
+ /** Original error */
90
+ cause?: Error;
91
+ }
92
+ /**
93
+ * Create a DatabaseError instance.
94
+ *
95
+ * @remarks
96
+ * Helper function to create properly structured DatabaseError objects.
97
+ *
98
+ * @param options - Error options
99
+ * @returns DatabaseError instance
100
+ *
101
+ * @public
102
+ */
103
+ declare function createDatabaseError(options: DatabaseErrorOptions): DatabaseError;
104
+
105
+ export { type DatabaseErrorKind as D, type DatabaseError as a, type DatabaseErrorOptions as b, createDatabaseError as c, isDatabaseError as i };
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Database error type definitions.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ /**
7
+ * Database error classification.
8
+ *
9
+ * @remarks
10
+ * Categorizes database errors for consistent error handling across adapters.
11
+ * Each adapter translates database-specific error codes to these kinds.
12
+ *
13
+ * @public
14
+ */
15
+ type DatabaseErrorKind = "connection" | "query" | "constraint" | "unique_violation" | "foreign_key_violation" | "check_violation" | "not_null_violation" | "deadlock" | "timeout" | "serialization_failure" | "unsupported_version" | "unknown";
16
+ /**
17
+ * Enhanced database error interface.
18
+ *
19
+ * @remarks
20
+ * Extends the standard Error interface with database-specific context.
21
+ * Adapters should throw errors implementing this interface for consistent
22
+ * error handling.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * try {
27
+ * await adapter.insert('users', { email: 'duplicate@example.com' });
28
+ * } catch (error) {
29
+ * if (isDatabaseError(error) && error.kind === 'unique_violation') {
30
+ * console.log(`Duplicate ${error.column} in ${error.table}`);
31
+ * }
32
+ * }
33
+ * ```
34
+ *
35
+ * @public
36
+ */
37
+ interface DatabaseError extends Error {
38
+ /** Error classification */
39
+ kind: DatabaseErrorKind;
40
+ /** Database-specific error code (e.g., "23505" for PostgreSQL unique violation) */
41
+ code?: string;
42
+ /** Constraint name that was violated (if applicable) */
43
+ constraint?: string;
44
+ /** Table name involved in the error */
45
+ table?: string;
46
+ /** Column name involved in the error */
47
+ column?: string;
48
+ /** Detailed error description from the database */
49
+ detail?: string;
50
+ /** Hint for resolving the error */
51
+ hint?: string;
52
+ /** Original error from the database driver */
53
+ cause?: Error;
54
+ }
55
+ /**
56
+ * Type guard for DatabaseError.
57
+ *
58
+ * @remarks
59
+ * Checks if an error is a DatabaseError with proper typing.
60
+ *
61
+ * @param error - Error to check
62
+ * @returns True if error is a DatabaseError
63
+ *
64
+ * @public
65
+ */
66
+ declare function isDatabaseError(error: unknown): error is DatabaseError;
67
+ /**
68
+ * Database error constructor options.
69
+ *
70
+ * @public
71
+ */
72
+ interface DatabaseErrorOptions {
73
+ /** Error classification */
74
+ kind: DatabaseErrorKind;
75
+ /** Error message */
76
+ message: string;
77
+ /** Database-specific error code */
78
+ code?: string;
79
+ /** Constraint name */
80
+ constraint?: string;
81
+ /** Table name */
82
+ table?: string;
83
+ /** Column name */
84
+ column?: string;
85
+ /** Detailed description */
86
+ detail?: string;
87
+ /** Resolution hint */
88
+ hint?: string;
89
+ /** Original error */
90
+ cause?: Error;
91
+ }
92
+ /**
93
+ * Create a DatabaseError instance.
94
+ *
95
+ * @remarks
96
+ * Helper function to create properly structured DatabaseError objects.
97
+ *
98
+ * @param options - Error options
99
+ * @returns DatabaseError instance
100
+ *
101
+ * @public
102
+ */
103
+ declare function createDatabaseError(options: DatabaseErrorOptions): DatabaseError;
104
+
105
+ export { type DatabaseErrorKind as D, type DatabaseError as a, type DatabaseErrorOptions as b, createDatabaseError as c, isDatabaseError as i };