@bunit/qb 0.0.0 → 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.
@@ -1,5 +1,4 @@
1
- import type { DatabaseIntrospector, Dialect, DialectAdapter, Driver, QueryCompiler } from "kysely";
2
- import type { Kysely } from "kysely";
1
+ import type { Kysely, DatabaseIntrospector, Dialect, DialectAdapter, Driver, QueryCompiler } from "kysely";
3
2
  import type { BunSQLDialectConfig } from "../types";
4
3
  export interface MySQLDialectConfig extends BunSQLDialectConfig {
5
4
  }
@@ -1,6 +1,4 @@
1
- import { MysqlAdapter } from "kysely";
2
- import { MysqlIntrospector } from "kysely";
3
- import { MysqlQueryCompiler } from "kysely";
1
+ import { MysqlAdapter, MysqlIntrospector, MysqlQueryCompiler } from "kysely";
4
2
  import { BunSQLDriver } from "../sql";
5
3
 
6
4
  export class MySQLDialect {
@@ -1,5 +1,4 @@
1
- import type { DatabaseIntrospector, Dialect, DialectAdapter, Driver, QueryCompiler } from "kysely";
2
- import type { Kysely } from "kysely";
1
+ import type { Kysely, DatabaseIntrospector, Dialect, DialectAdapter, Driver, QueryCompiler } from "kysely";
3
2
  import type { BunSQLDialectConfig } from "../types";
4
3
  export interface PostgresDialectConfig extends BunSQLDialectConfig {
5
4
  }
@@ -1,6 +1,4 @@
1
- import { PostgresAdapter } from "kysely";
2
- import { PostgresIntrospector } from "kysely";
3
- import { PostgresQueryCompiler } from "kysely";
1
+ import { PostgresAdapter, PostgresIntrospector, PostgresQueryCompiler } from "kysely";
4
2
  import { BunSQLDriver } from "../sql";
5
3
 
6
4
  export class PostgresDialect {
@@ -1,5 +1,4 @@
1
- import type { DatabaseIntrospector, Dialect, DialectAdapter, Driver, QueryCompiler } from "kysely";
2
- import type { Kysely } from "kysely";
1
+ import type { Kysely, DatabaseIntrospector, Dialect, DialectAdapter, Driver, QueryCompiler } from "kysely";
3
2
  import type { BunSQLDialectConfig } from "../types";
4
3
  export interface SQLiteDialectConfig extends BunSQLDialectConfig {
5
4
  }
@@ -1,6 +1,4 @@
1
- import { SqliteAdapter } from "kysely";
2
- import { SqliteIntrospector } from "kysely";
3
- import { SqliteQueryCompiler } from "kysely";
1
+ import { SqliteAdapter, SqliteIntrospector, SqliteQueryCompiler } from "kysely";
4
2
  import { BunSQLDriver } from "../sql";
5
3
 
6
4
  export class SQLiteDialect {
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "kysely";
2
2
  export * from "./sql";
3
+ export * from "./types";
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- export*from"kysely";import{CompiledQuery as z}from"kysely";var{SQL:A}=globalThis.Bun;class E{#h;#x;constructor(x){this.#h=x}async init(){let{url:x,options:h}=this.#h;if(x)this.#x=new A(x,h??{});else if(h)this.#x=new A(h);else throw Error("Either url or options must be provided");await this.#x.connect()}async acquireConnection(){if(!this.#x)throw Error("Driver not initialized. Call init() first.");return new D(this.#x)}async beginTransaction(x,h){if(h.isolationLevel||h.accessMode){let j="start transaction";if(h.isolationLevel)j+=` isolation level ${h.isolationLevel}`;if(h.accessMode)j+=` ${h.accessMode}`;await x.executeQuery(z.raw(j))}else await x.executeQuery(z.raw("begin"))}async commitTransaction(x){await x.executeQuery(z.raw("commit"))}async rollbackTransaction(x){await x.executeQuery(z.raw("rollback"))}async releaseConnection(x){}async destroy(){if(this.#x)await this.#x.end(),this.#x=void 0}}class D{#h;constructor(x){this.#h=x}async executeQuery(x){let{sql:h,parameters:j}=x,v=await this.#h.unsafe(h,[...j]);return{rows:Array.isArray(v)?v:v?[v]:[]}}streamQuery(x,h){throw Error("Streaming queries are not supported")}}export{E as BunSQLDriver};
2
+ import{a as n}from"./sql.mjs";export*from"kysely";export{n as BunSQLDriver};
package/dist/sql.mjs ADDED
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{CompiledQuery as z}from"kysely";var{SQL:A}=globalThis.Bun;class E{#j;#h;constructor(h){this.#j=h}async init(){let{url:h,options:j}=this.#j;if(h)this.#h=new A(h,j??{});else if(j)this.#h=new A(j);else throw Error("Either url or options must be provided");await this.#h.connect()}async acquireConnection(){if(!this.#h)throw Error("Driver not initialized. Call init() first.");return new D(this.#h)}async beginTransaction(h,j){if(j.isolationLevel||j.accessMode){let v="start transaction";if(j.isolationLevel)v+=` isolation level ${j.isolationLevel}`;if(j.accessMode)v+=` ${j.accessMode}`;await h.executeQuery(z.raw(v))}else await h.executeQuery(z.raw("begin"))}async commitTransaction(h){await h.executeQuery(z.raw("commit"))}async rollbackTransaction(h){await h.executeQuery(z.raw("rollback"))}async releaseConnection(h){}async destroy(){if(this.#h)await this.#h.end(),this.#h=void 0}}class D{#j;constructor(h){this.#j=h}async executeQuery(h){let{sql:j,parameters:v}=h,x=await this.#j.unsafe(j,[...v]);return{rows:Array.isArray(x)?x:x?[x]:[]}}streamQuery(h,j){throw Error("Streaming queries are not supported")}}export{E as BunSQLDriver};
3
+ export{E as a};
@@ -1,9 +1,9 @@
1
1
  import type { SQL } from "bun";
2
2
  export interface BunSQLDialectConfig {
3
- url?: string | URL;
4
- options?: ConstructorParameters<typeof SQL>[0];
3
+ url?: string | URL;
4
+ options?: ConstructorParameters<typeof SQL>[0];
5
5
  }
6
6
  /** @internal */
7
7
  export interface BunSQLDriverConfig extends BunSQLDialectConfig {
8
- adapter: "postgres" | "mysql" | "sqlite";
8
+ adapter: "postgres" | "mysql" | "sqlite";
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunit/qb",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "description": "Kysely dialects powered by Bun's native SQL client for PostgreSQL, MySQL, and SQLite",
5
5
  "keywords": [
6
6
  "bun",
@@ -1,13 +0,0 @@
1
- import type { DatabaseConnection, Driver, TransactionSettings } from "kysely";
2
- import type { BunSQLDriverConfig } from "./types";
3
- export declare class BunSQLDriver implements Driver {
4
- #private;
5
- constructor(config: BunSQLDriverConfig);
6
- init(): Promise<void>;
7
- acquireConnection(): Promise<DatabaseConnection>;
8
- beginTransaction(connection: DatabaseConnection, settings: TransactionSettings): Promise<void>;
9
- commitTransaction(connection: DatabaseConnection): Promise<void>;
10
- rollbackTransaction(connection: DatabaseConnection): Promise<void>;
11
- releaseConnection(_connection: DatabaseConnection): Promise<void>;
12
- destroy(): Promise<void>;
13
- }