@kysera/dialects 0.7.4 → 0.8.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.
package/README.md CHANGED
@@ -635,7 +635,7 @@ await truncateAllTables(db, 'postgres', ['migrations', 'schema_version'])
635
635
 
636
636
  ### Factory Functions
637
637
 
638
- #### `getAdapter(dialect: DatabaseDialect): DialectAdapter`
638
+ #### `getAdapter(dialect: Dialect): DialectAdapter`
639
639
 
640
640
  Get singleton adapter for specified dialect.
641
641
 
@@ -649,7 +649,7 @@ Get singleton adapter for specified dialect.
649
649
 
650
650
  ---
651
651
 
652
- #### `createDialectAdapter(dialect: DatabaseDialect): DialectAdapter`
652
+ #### `createDialectAdapter(dialect: Dialect): DialectAdapter`
653
653
 
654
654
  Create new adapter instance.
655
655
 
@@ -683,7 +683,7 @@ Interface for dialect-specific operations.
683
683
 
684
684
  **Properties:**
685
685
 
686
- - `dialect: DatabaseDialect` - The dialect this adapter handles
686
+ - `dialect: Dialect` - The dialect this adapter handles
687
687
 
688
688
  **Methods:**
689
689
 
@@ -717,7 +717,7 @@ Parse connection URL into configuration object.
717
717
 
718
718
  ---
719
719
 
720
- #### `buildConnectionUrl(dialect: DatabaseDialect, config: ConnectionConfig): string`
720
+ #### `buildConnectionUrl(dialect: Dialect, config: ConnectionConfig): string`
721
721
 
722
722
  Build connection URL from configuration.
723
723
 
@@ -730,7 +730,7 @@ Build connection URL from configuration.
730
730
 
731
731
  ---
732
732
 
733
- #### `getDefaultPort(dialect: DatabaseDialect): number | null`
733
+ #### `getDefaultPort(dialect: Dialect): number | null`
734
734
 
735
735
  Get default port for dialect.
736
736
 
@@ -744,67 +744,67 @@ Get default port for dialect.
744
744
 
745
745
  ### Helper Functions
746
746
 
747
- #### `tableExists(db: Kysely<any>, tableName: string, dialect: DatabaseDialect): Promise<boolean>`
747
+ #### `tableExists(db: Kysely<any>, tableName: string, dialect: Dialect): Promise<boolean>`
748
748
 
749
749
  Check if table exists.
750
750
 
751
751
  ---
752
752
 
753
- #### `getTableColumns(db: Kysely<any>, tableName: string, dialect: DatabaseDialect): Promise<string[]>`
753
+ #### `getTableColumns(db: Kysely<any>, tableName: string, dialect: Dialect): Promise<string[]>`
754
754
 
755
755
  Get column names for a table.
756
756
 
757
757
  ---
758
758
 
759
- #### `getTables(db: Kysely<any>, dialect: DatabaseDialect): Promise<string[]>`
759
+ #### `getTables(db: Kysely<any>, dialect: Dialect): Promise<string[]>`
760
760
 
761
761
  Get all tables in database.
762
762
 
763
763
  ---
764
764
 
765
- #### `escapeIdentifier(identifier: string, dialect: DatabaseDialect): string`
765
+ #### `escapeIdentifier(identifier: string, dialect: Dialect): string`
766
766
 
767
767
  Escape identifier for SQL.
768
768
 
769
769
  ---
770
770
 
771
- #### `getCurrentTimestamp(dialect: DatabaseDialect): string`
771
+ #### `getCurrentTimestamp(dialect: Dialect): string`
772
772
 
773
773
  Get SQL expression for current timestamp.
774
774
 
775
775
  ---
776
776
 
777
- #### `formatDate(date: Date, dialect: DatabaseDialect): string`
777
+ #### `formatDate(date: Date, dialect: Dialect): string`
778
778
 
779
779
  Format date for SQL.
780
780
 
781
781
  ---
782
782
 
783
- #### `isUniqueConstraintError(error: unknown, dialect: DatabaseDialect): boolean`
783
+ #### `isUniqueConstraintError(error: unknown, dialect: Dialect): boolean`
784
784
 
785
785
  Check if error is unique constraint violation.
786
786
 
787
787
  ---
788
788
 
789
- #### `isForeignKeyError(error: unknown, dialect: DatabaseDialect): boolean`
789
+ #### `isForeignKeyError(error: unknown, dialect: Dialect): boolean`
790
790
 
791
791
  Check if error is foreign key violation.
792
792
 
793
793
  ---
794
794
 
795
- #### `isNotNullError(error: unknown, dialect: DatabaseDialect): boolean`
795
+ #### `isNotNullError(error: unknown, dialect: Dialect): boolean`
796
796
 
797
797
  Check if error is not-null violation.
798
798
 
799
799
  ---
800
800
 
801
- #### `getDatabaseSize(db: Kysely<any>, databaseName: string | undefined, dialect: DatabaseDialect): Promise<number>`
801
+ #### `getDatabaseSize(db: Kysely<any>, databaseName: string | undefined, dialect: Dialect): Promise<number>`
802
802
 
803
803
  Get database size in bytes.
804
804
 
805
805
  ---
806
806
 
807
- #### `truncateAllTables(db: Kysely<any>, dialect: DatabaseDialect, exclude?: string[]): Promise<void>`
807
+ #### `truncateAllTables(db: Kysely<any>, dialect: Dialect, exclude?: string[]): Promise<void>`
808
808
 
809
809
  Truncate all tables in database.
810
810
 
@@ -854,9 +854,9 @@ interface DatabaseErrorLike {
854
854
 
855
855
  ```typescript
856
856
  // ✅ Good: Works with any dialect
857
- import { getAdapter } from '@kysera/dialects'
857
+ import { getAdapter, type Dialect } from '@kysera/dialects'
858
858
 
859
- function checkSchema(db: Kysely<any>, dialect: DatabaseDialect) {
859
+ function checkSchema(db: Kysely<any>, dialect: Dialect) {
860
860
  const adapter = getAdapter(dialect)
861
861
  return adapter.tableExists(db, 'users')
862
862
  }
@@ -884,10 +884,10 @@ const exists = await adapter.tableExists(db, 'users')
884
884
  ### 3. Centralize Error Handling
885
885
 
886
886
  ```typescript
887
- import { getAdapter } from '@kysera/dialects'
887
+ import { getAdapter, type Dialect } from '@kysera/dialects'
888
888
  import { parseDatabaseError } from '@kysera/core'
889
889
 
890
- async function handleDatabaseError(error: unknown, dialect: DatabaseDialect) {
890
+ async function handleDatabaseError(error: unknown, dialect: Dialect) {
891
891
  const adapter = getAdapter(dialect)
892
892
 
893
893
  if (adapter.isUniqueConstraintError(error)) {
@@ -951,11 +951,11 @@ try {
951
951
  ### 6. Escape Dynamic Identifiers
952
952
 
953
953
  ```typescript
954
- import { escapeIdentifier } from '@kysera/dialects'
954
+ import { escapeIdentifier, type Dialect } from '@kysera/dialects'
955
955
  import { sql } from 'kysely'
956
956
 
957
957
  // ✅ Good: Escape dynamic table/column names
958
- function selectFromTable(tableName: string, dialect: DatabaseDialect) {
958
+ function selectFromTable(tableName: string, dialect: Dialect) {
959
959
  const escaped = escapeIdentifier(tableName, dialect)
960
960
  return db.selectFrom(sql.raw(escaped)).selectAll()
961
961
  }
package/dist/index.d.ts CHANGED
@@ -8,14 +8,6 @@ export { Dialect } from '@kysera/core';
8
8
  * Dialect-specific types and interfaces for database operations
9
9
  */
10
10
 
11
- /**
12
- * Supported database dialects
13
- *
14
- * @deprecated Use `Dialect` from '@kysera/core' instead.
15
- * This alias is kept for backwards compatibility.
16
- */
17
- type DatabaseDialect = Dialect;
18
-
19
11
  /**
20
12
  * Database connection configuration
21
13
  */
@@ -354,4 +346,4 @@ declare function getDatabaseSize(db: Kysely<any>, dialect: Dialect, databaseName
354
346
  */
355
347
  declare function truncateAllTables(db: Kysely<any>, dialect: Dialect, exclude?: string[]): Promise<void>;
356
348
 
357
- export { type ConnectionConfig, type DatabaseDialect, type DatabaseErrorLike, type DialectAdapter, MSSQLAdapter, MySQLAdapter, PostgresAdapter, SQLiteAdapter, assertValidIdentifier, buildConnectionUrl, createDialectAdapter, escapeIdentifier, formatDate, getAdapter, getCurrentTimestamp, getDatabaseSize, getDefaultPort, getTableColumns, getTables, isForeignKeyError, isNotNullError, isUniqueConstraintError, mssqlAdapter, mysqlAdapter, parseConnectionUrl, postgresAdapter, registerAdapter, sqliteAdapter, tableExists, truncateAllTables, validateIdentifier };
349
+ export { type ConnectionConfig, type DatabaseErrorLike, type DialectAdapter, MSSQLAdapter, MySQLAdapter, PostgresAdapter, SQLiteAdapter, assertValidIdentifier, buildConnectionUrl, createDialectAdapter, escapeIdentifier, formatDate, getAdapter, getCurrentTimestamp, getDatabaseSize, getDefaultPort, getTableColumns, getTables, isForeignKeyError, isNotNullError, isUniqueConstraintError, mssqlAdapter, mysqlAdapter, parseConnectionUrl, postgresAdapter, registerAdapter, sqliteAdapter, tableExists, truncateAllTables, validateIdentifier };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kysera/dialects",
3
- "version": "0.7.4",
3
+ "version": "0.8.1",
4
4
  "description": "Dialect-specific utilities for Kysely - PostgreSQL, MySQL, SQLite support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -19,7 +19,7 @@
19
19
  "kysely": ">=0.28.8"
20
20
  },
21
21
  "dependencies": {
22
- "@kysera/core": "0.7.4"
22
+ "@kysera/core": "0.8.1"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/better-sqlite3": "^7.6.13",
package/src/index.ts CHANGED
@@ -28,15 +28,7 @@
28
28
  */
29
29
 
30
30
  // Types - Dialect is the canonical type from @kysera/core
31
- // DatabaseDialect is kept for backwards compatibility
32
- export type {
33
- Dialect,
34
- // eslint-disable-next-line @typescript-eslint/no-deprecated -- Exported for backwards compatibility
35
- DatabaseDialect,
36
- ConnectionConfig,
37
- DialectAdapter,
38
- DatabaseErrorLike
39
- } from './types.js'
31
+ export type { Dialect, ConnectionConfig, DialectAdapter, DatabaseErrorLike } from './types.js'
40
32
 
41
33
  // Factory and adapters
42
34
  export { getAdapter, createDialectAdapter, registerAdapter } from './factory.js'
package/src/types.ts CHANGED
@@ -7,16 +7,8 @@
7
7
  import type { Kysely } from 'kysely'
8
8
  import type { Dialect } from '@kysera/core'
9
9
 
10
- /**
11
- * Supported database dialects
12
- *
13
- * @deprecated Use `Dialect` from '@kysera/core' instead.
14
- * This alias is kept for backwards compatibility.
15
- */
16
- export type DatabaseDialect = Dialect
17
-
18
10
  // Re-export Dialect from core for convenience
19
- export type { Dialect } from '@kysera/core'
11
+ export type { Dialect }
20
12
 
21
13
  /**
22
14
  * Database connection configuration