driftsql 1.0.17 → 1.0.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "driftsql",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "A lightweight SQL client for TypeScript",
5
5
  "scripts": {
6
6
  "build": "unbuild",
@@ -0,0 +1,43 @@
1
+ import type { DatabaseDriver, QueryResult } from '../types'
2
+ import ky from 'ky'
3
+
4
+ export interface BobSQLConfig {
5
+ url: string
6
+ authToken?: string
7
+ }
8
+
9
+ export class BobSQLDriver implements DatabaseDriver {
10
+ private httpClient: typeof ky
11
+
12
+ constructor(config: BobSQLConfig) {
13
+ this.httpClient = ky.create({
14
+ prefixUrl: config.url,
15
+ ...(config.authToken ? { headers: { Authorization: `Bearer ${config.authToken}` } } : {}),
16
+ })
17
+ }
18
+
19
+ async query<T = any>(sql: string, params?: any[]): Promise<QueryResult<T>> {
20
+ try {
21
+ if (params) {
22
+ throw new Error('BobSQL does not support args at this moment.')
23
+ }
24
+
25
+ const response = await this.httpClient
26
+ .post('query', {
27
+ json: { sql },
28
+ })
29
+ .json<{ rows: T[] }>()
30
+
31
+ return {
32
+ rows: response.rows,
33
+ rowCount: response.rows.length,
34
+ }
35
+ } catch (error) {
36
+ throw new Error(`Query failed: ${error}`)
37
+ }
38
+ }
39
+
40
+ async close(): Promise<void> {
41
+ return Promise.resolve()
42
+ }
43
+ }
package/src/index.ts CHANGED
@@ -12,7 +12,7 @@ export { PostgresDriver } from './drivers/postgres'
12
12
  export { LibSQLDriver } from './drivers/libsql'
13
13
  export { MySQLDriver } from './drivers/mysql'
14
14
  export { SqliteDriver } from './drivers/sqlite'
15
-
15
+ export { BobSQLDriver, type BobSQLConfig } from './drivers/bobsql'
16
16
  // Re-export inspection utilities
17
17
  export { inspectDB, inspectPostgres, inspectLibSQL, inspectMySQL, inspectSQLite } from './pull'
18
18
 
package/src/types.ts CHANGED
@@ -15,11 +15,11 @@ export interface QueryField {
15
15
  // Base driver interface that all drivers must implement
16
16
  export interface DatabaseDriver {
17
17
  query<T = any>(sql: string, params?: any[]): Promise<QueryResult<T>>
18
- findMany?<T = any>(sql: string, params?: any[]): Promise<QueryResult<T>>
19
- findFirst?<T = any>(sql: string, params?: any[]): Promise<T | null>
20
- insert?<T = any>(table: string, data: Partial<T>): Promise<QueryResult<T>>
21
- update?<T = any>(table: string, data: Partial<T>, where: Partial<T>): Promise<QueryResult<T>>
22
- delete?<T = any>(table: string, where: Partial<T>): Promise<QueryResult<T>>
18
+ // findMany?<T = any>(sql: string, params?: any[]): Promise<QueryResult<T>>
19
+ // findFirst?<T = any>(sql: string, params?: any[]): Promise<T | null>
20
+ // insert?<T = any>(table: string, data: Partial<T>): Promise<QueryResult<T>>
21
+ // update?<T = any>(table: string, data: Partial<T>, where: Partial<T>): Promise<QueryResult<T>>
22
+ // delete?<T = any>(table: string, where: Partial<T>): Promise<QueryResult<T>>
23
23
  close(): Promise<void>
24
24
  }
25
25