driftsql 1.0.5 → 1.0.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/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PoolConfig } from 'pg';
2
2
  import { Config } from '@libsql/client';
3
- import mysql from 'mysql2/promise';
3
+ import { ConnectionOptions } from 'mysql2/promise';
4
4
 
5
5
  type Drivers = ClientOptions['drivers'];
6
6
  declare const inspectDB: (drivers: Drivers) => Promise<never>;
@@ -20,7 +20,7 @@ interface ClientOptions {
20
20
  drivers?: {
21
21
  libsql?: Config;
22
22
  postgres?: PoolConfig;
23
- mysql?: mysql.ConnectionOptions;
23
+ mysql?: ConnectionOptions;
24
24
  };
25
25
  options?: {
26
26
  defaultTimeout?: number;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PoolConfig } from 'pg';
2
2
  import { Config } from '@libsql/client';
3
- import mysql from 'mysql2/promise';
3
+ import { ConnectionOptions } from 'mysql2/promise';
4
4
 
5
5
  type Drivers = ClientOptions['drivers'];
6
6
  declare const inspectDB: (drivers: Drivers) => Promise<never>;
@@ -20,7 +20,7 @@ interface ClientOptions {
20
20
  drivers?: {
21
21
  libsql?: Config;
22
22
  postgres?: PoolConfig;
23
- mysql?: mysql.ConnectionOptions;
23
+ mysql?: ConnectionOptions;
24
24
  };
25
25
  options?: {
26
26
  defaultTimeout?: number;
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ import { createClient } from '@libsql/client';
5
5
  import mysql from 'mysql2/promise';
6
6
  import fs from 'node:fs/promises';
7
7
 
8
- const supportedDrivers = ["postgres", "mysql"];
8
+ const supportedDrivers = ["postgres", "mysql", "libsql"];
9
9
  const mapDatabaseTypeToTypeScript = (dataType, isNullable = false, driverType = "postgres") => {
10
10
  const nullable = isNullable ? " | null" : "";
11
11
  const lowerType = dataType.toLowerCase();
@@ -118,13 +118,19 @@ const inspectDB = async (drivers) => {
118
118
  AND TABLE_TYPE = 'BASE TABLE'
119
119
  ORDER BY TABLE_NAME`;
120
120
  tableSchemaFilter = currentDatabase;
121
- } else {
121
+ } else if (activeDriver === "postgres") {
122
122
  tablesQuery = `SELECT table_name
123
123
  FROM information_schema.tables
124
124
  WHERE table_schema = $1
125
125
  AND table_type = 'BASE TABLE'
126
126
  ORDER BY table_name`;
127
127
  tableSchemaFilter = "public";
128
+ } else {
129
+ tablesQuery = `SELECT name as table_name
130
+ FROM sqlite_master
131
+ WHERE type = 'table'
132
+ ORDER BY name`;
133
+ tableSchemaFilter = void 0;
128
134
  }
129
135
  const tables = await client.query(tablesQuery, tableSchemaFilter ? [tableSchemaFilter] : []);
130
136
  console.log("Tables in the database:", tables.rows.map((t) => t.table_name).join(", "));
@@ -146,7 +152,7 @@ const inspectDB = async (drivers) => {
146
152
  ORDER BY ORDINAL_POSITION
147
153
  `;
148
154
  queryParams = [tableName, tableSchemaFilter];
149
- } else {
155
+ } else if (activeDriver === "postgres") {
150
156
  columnsQuery = `
151
157
  SELECT
152
158
  column_name,
@@ -159,6 +165,17 @@ const inspectDB = async (drivers) => {
159
165
  ORDER BY ordinal_position
160
166
  `;
161
167
  queryParams = [tableName, tableSchemaFilter];
168
+ } else {
169
+ columnsQuery = `
170
+ SELECT
171
+ name as column_name,
172
+ type as data_type,
173
+ CASE WHEN "notnull" = 0 THEN 'YES' ELSE 'NO' END as is_nullable,
174
+ dflt_value as column_default
175
+ FROM pragma_table_info(?)
176
+ ORDER BY cid
177
+ `;
178
+ queryParams = [tableName];
162
179
  }
163
180
  const columns = await client.query(columnsQuery, queryParams);
164
181
  if (columns.rows.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "driftsql",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "author": "lasse vestergaard",
5
5
  "description": "A lightweight SQL client for TypeScript, supporting multiple databases like PostgreSQL, MySQL, and LibSQL.",
6
6
  "repository": "lassejlv/driftsql",
@@ -27,16 +27,16 @@
27
27
  "test:types": "tsc --noEmit --skipLibCheck"
28
28
  },
29
29
  "devDependencies": {
30
- "@types/node": "^22.13.13",
31
- "@vitest/coverage-v8": "^3.0.9",
30
+ "@types/node": "^22.15.34",
31
+ "@vitest/coverage-v8": "^3.2.4",
32
32
  "automd": "^0.4.0",
33
33
  "changelogen": "^0.6.1",
34
- "eslint": "^9.23.0",
34
+ "eslint": "^9.30.0",
35
35
  "eslint-config-unjs": "^0.4.2",
36
- "prettier": "^3.5.3",
37
- "typescript": "^5.8.2",
36
+ "prettier": "^3.6.2",
37
+ "typescript": "^5.8.3",
38
38
  "unbuild": "^3.5.0",
39
- "vitest": "^3.0.9"
39
+ "vitest": "^3.2.4"
40
40
  },
41
41
  "packageManager": "pnpm@10.12.1",
42
42
  "dependencies": {
@@ -48,7 +48,7 @@
48
48
  "drizzle-orm": "^0.44.2",
49
49
  "ky": "^1.8.1",
50
50
  "mysql2": "^3.14.1",
51
- "pg": "^8.16.0",
51
+ "pg": "^8.16.3",
52
52
  "postgres": "^3.4.7"
53
53
  }
54
54
  }