@relkit/drizzle 0.9.0 → 0.9.2

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 (41) hide show
  1. package/dist/mysql-client/bun/index.d.ts +4 -0
  2. package/dist/mysql-client/bun/index.d.ts.map +1 -0
  3. package/dist/mysql-client/bun/index.js +5 -0
  4. package/dist/mysql-client/bun/index.js.map +1 -0
  5. package/dist/mysql-client/index.d.ts +25 -0
  6. package/dist/mysql-client/index.d.ts.map +1 -0
  7. package/dist/mysql-client/index.js +26 -0
  8. package/dist/mysql-client/index.js.map +1 -0
  9. package/dist/mysql-client/mysql-client.types.d.ts +16 -0
  10. package/dist/mysql-client/mysql-client.types.d.ts.map +1 -0
  11. package/dist/mysql-client/mysql-client.types.js +2 -0
  12. package/dist/mysql-client/mysql-client.types.js.map +1 -0
  13. package/dist/mysql-client/node/index.d.ts +4 -0
  14. package/dist/mysql-client/node/index.d.ts.map +1 -0
  15. package/dist/mysql-client/node/index.js +5 -0
  16. package/dist/mysql-client/node/index.js.map +1 -0
  17. package/dist/mysql.d.ts +2 -0
  18. package/dist/mysql.d.ts.map +1 -1
  19. package/dist/mysql.js +1 -0
  20. package/dist/mysql.js.map +1 -1
  21. package/dist/pg-client/bun/index.d.ts +4 -0
  22. package/dist/pg-client/bun/index.d.ts.map +1 -0
  23. package/dist/pg-client/bun/index.js +5 -0
  24. package/dist/pg-client/bun/index.js.map +1 -0
  25. package/dist/pg-client/index.d.ts +25 -0
  26. package/dist/pg-client/index.d.ts.map +1 -0
  27. package/dist/pg-client/index.js +26 -0
  28. package/dist/pg-client/index.js.map +1 -0
  29. package/dist/pg-client/node/index.d.ts +4 -0
  30. package/dist/pg-client/node/index.d.ts.map +1 -0
  31. package/dist/pg-client/node/index.js +5 -0
  32. package/dist/pg-client/node/index.js.map +1 -0
  33. package/dist/pg-client/pg-client.types.d.ts +16 -0
  34. package/dist/pg-client/pg-client.types.d.ts.map +1 -0
  35. package/dist/pg-client/pg-client.types.js +2 -0
  36. package/dist/pg-client/pg-client.types.js.map +1 -0
  37. package/dist/pg.d.ts +2 -0
  38. package/dist/pg.d.ts.map +1 -1
  39. package/dist/pg.js +1 -0
  40. package/dist/pg.js.map +1 -1
  41. package/package.json +23 -5
@@ -0,0 +1,4 @@
1
+ import type { OpenMysql } from "../mysql-client.types.js";
2
+ /** Connects to a MySQL URL with Bun's SQL client; it connects on the first query. */
3
+ export declare const openBunMysql: OpenMysql;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mysql-client/bun/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAEzE,qFAAqF;AACrF,eAAO,MAAM,YAAY,EAAE,SACuD,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** MySQL on Bun: Bun's built-in SQL client through Drizzle's `bun-sql` driver. */
2
+ import { drizzle } from "drizzle-orm/bun-sql";
3
+ /** Connects to a MySQL URL with Bun's SQL client; it connects on the first query. */
4
+ export const openBunMysql = (url, config) => drizzle.mysql({ ...config, connection: url });
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mysql-client/bun/index.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,qFAAqF;AACrF,MAAM,CAAC,MAAM,YAAY,GAAc,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CACrD,OAAO,CAAC,KAAK,CAAC,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,CAAoC,CAAC"}
@@ -0,0 +1,25 @@
1
+ /** Connects to MySQL with the driver of the runtime the application runs on. */
2
+ import type { AnyRelations, EmptyRelations } from "drizzle-orm/relations";
3
+ import type { MysqlDatabase, MysqlDatabaseConfig } from "./mysql-client.types.js";
4
+ export type { MysqlDatabase, MysqlDatabaseConfig } from "./mysql-client.types.js";
5
+ /**
6
+ * Connects to a MySQL database with Bun's built-in SQL client on Bun and `mysql2` on Node, so
7
+ * one Drizzle service runs on both. Only the current runtime's driver is loaded: a Node
8
+ * application needs `mysql2` installed, a Bun application needs nothing more.
9
+ * @param url - Connection URL, such as `mysql://user:password@localhost:3306/app`.
10
+ * @param config - Drizzle settings, such as `logger`, passed to the runtime's driver.
11
+ * @returns The Drizzle database; end its connections with `database.$client.end()`.
12
+ * @example
13
+ * ```ts
14
+ * import { openMysqlDatabase } from "@relkit/drizzle/mysql";
15
+ *
16
+ * // Nothing connects until the first query runs, such as `database.execute(sql\`select 1\`)`.
17
+ * const database = await openMysqlDatabase("mysql://app@localhost:3306/app");
18
+ * console.assert(typeof database.execute === "function");
19
+ * await database.$client.end();
20
+ * ```
21
+ * @category Database
22
+ * @since 0.9.1
23
+ */
24
+ export declare function openMysqlDatabase<Relations extends AnyRelations = EmptyRelations>(url: string, config?: MysqlDatabaseConfig<Relations>): Promise<MysqlDatabase<Relations>>;
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mysql-client/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAClF,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAElF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,iBAAiB,CAAC,SAAS,SAAS,YAAY,GAAG,cAAc,EACrF,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC,GACtC,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAMnC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Connects to a MySQL database with Bun's built-in SQL client on Bun and `mysql2` on Node, so
3
+ * one Drizzle service runs on both. Only the current runtime's driver is loaded: a Node
4
+ * application needs `mysql2` installed, a Bun application needs nothing more.
5
+ * @param url - Connection URL, such as `mysql://user:password@localhost:3306/app`.
6
+ * @param config - Drizzle settings, such as `logger`, passed to the runtime's driver.
7
+ * @returns The Drizzle database; end its connections with `database.$client.end()`.
8
+ * @example
9
+ * ```ts
10
+ * import { openMysqlDatabase } from "@relkit/drizzle/mysql";
11
+ *
12
+ * // Nothing connects until the first query runs, such as `database.execute(sql\`select 1\`)`.
13
+ * const database = await openMysqlDatabase("mysql://app@localhost:3306/app");
14
+ * console.assert(typeof database.execute === "function");
15
+ * await database.$client.end();
16
+ * ```
17
+ * @category Database
18
+ * @since 0.9.1
19
+ */
20
+ export async function openMysqlDatabase(url, config) {
21
+ const open = typeof process.versions.bun === "string"
22
+ ? (await import("./bun/index.js")).openBunMysql
23
+ : (await import("./node/index.js")).openNodeMysql;
24
+ return open(url, config);
25
+ }
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mysql-client/index.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,GAAW,EACX,MAAuC;IAEvC,MAAM,IAAI,GACR,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,KAAK,QAAQ;QACtC,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,YAAY;QAC/C,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,aAAa,CAAC;IACtD,OAAO,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,16 @@
1
+ /** The Drizzle MySQL database `openMysqlDatabase` returns on either runtime. */
2
+ import type { MySqlAsyncDatabase } from "drizzle-orm/mysql-core/async/db";
3
+ import type { MySqlQueryResultHKT } from "drizzle-orm/mysql-core/session";
4
+ import type { DrizzleMySqlConfig } from "drizzle-orm/mysql-core/utils";
5
+ import type { AnyRelations, EmptyRelations } from "drizzle-orm/relations";
6
+ /** An asynchronous Drizzle MySQL database whose connection pool can be ended. */
7
+ export type MysqlDatabase<Relations extends AnyRelations = EmptyRelations> = MySqlAsyncDatabase<MySqlQueryResultHKT, Relations> & {
8
+ readonly $client: {
9
+ end(): Promise<void>;
10
+ };
11
+ };
12
+ /** Drizzle settings passed through to the runtime's driver. */
13
+ export type MysqlDatabaseConfig<Relations extends AnyRelations = EmptyRelations> = DrizzleMySqlConfig<Relations>;
14
+ /** Connects to one MySQL URL with a runtime's driver. */
15
+ export type OpenMysql = <Relations extends AnyRelations = EmptyRelations>(url: string, config?: MysqlDatabaseConfig<Relations>) => MysqlDatabase<Relations>;
16
+ //# sourceMappingURL=mysql-client.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mysql-client.types.d.ts","sourceRoot":"","sources":["../../src/mysql-client/mysql-client.types.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE1E,iFAAiF;AACjF,MAAM,MAAM,aAAa,CAAC,SAAS,SAAS,YAAY,GAAG,cAAc,IAAI,kBAAkB,CAC7F,mBAAmB,EACnB,SAAS,CACV,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE;QAAE,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAA;CAAE,CAAC;AAEnD,+DAA+D;AAC/D,MAAM,MAAM,mBAAmB,CAAC,SAAS,SAAS,YAAY,GAAG,cAAc,IAC7E,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAEhC,yDAAyD;AACzD,MAAM,MAAM,SAAS,GAAG,CAAC,SAAS,SAAS,YAAY,GAAG,cAAc,EACtE,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC,KACpC,aAAa,CAAC,SAAS,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mysql-client.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mysql-client.types.js","sourceRoot":"","sources":["../../src/mysql-client/mysql-client.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { OpenMysql } from "../mysql-client.types.js";
2
+ /** Connects to a MySQL URL with a `mysql2` pool; it connects on the first query. */
3
+ export declare const openNodeMysql: OpenMysql;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mysql-client/node/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAEzE,oFAAoF;AACpF,eAAO,MAAM,aAAa,EAAE,SACgD,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** MySQL on Node: a `mysql2` connection pool through Drizzle's `mysql2` driver. */
2
+ import { drizzle } from "drizzle-orm/mysql2";
3
+ /** Connects to a MySQL URL with a `mysql2` pool; it connects on the first query. */
4
+ export const openNodeMysql = (url, config) => drizzle({ ...config, connection: url });
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mysql-client/node/index.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C,oFAAoF;AACpF,MAAM,CAAC,MAAM,aAAa,GAAc,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CACtD,OAAO,CAAC,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,CAAoC,CAAC"}
package/dist/mysql.d.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  import type { MySqlAsyncDatabase } from "drizzle-orm/mysql-core/async/db";
3
3
  import type { DefineModel } from "./model.types.js";
4
4
  export * from "./index.js";
5
+ export { openMysqlDatabase } from "./mysql-client/index.js";
6
+ export type { MysqlDatabase, MysqlDatabaseConfig } from "./mysql-client/index.js";
5
7
  /** Native database injected into model extensions for the selected dialect. */
6
8
  export type DialectDatabase = Omit<MySqlAsyncDatabase<any, any>, "query">;
7
9
  /** Declares lazy native extensions with this dialect's real transaction client type. */
@@ -1 +1 @@
1
- {"version":3,"file":"mysql.d.ts","sourceRoot":"","sources":["../src/mysql.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,cAAc,YAAY,CAAC;AAE3B,+EAA+E;AAC/E,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;AAE1E,wFAAwF;AACxF,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,eAAe,CAAqB,CAAC"}
1
+ {"version":3,"file":"mysql.d.ts","sourceRoot":"","sources":["../src/mysql.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAElF,+EAA+E;AAC/E,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;AAE1E,wFAAwF;AACxF,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,eAAe,CAAqB,CAAC"}
package/dist/mysql.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { defineModel as defineNativeModel } from "./model.js";
2
2
  export * from "./index.js";
3
+ export { openMysqlDatabase } from "./mysql-client/index.js";
3
4
  /** Declares lazy native extensions with this dialect's real transaction client type. */
4
5
  export const defineModel = defineNativeModel;
5
6
  //# sourceMappingURL=mysql.js.map
package/dist/mysql.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mysql.js","sourceRoot":"","sources":["../src/mysql.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE9D,cAAc,YAAY,CAAC;AAK3B,wFAAwF;AACxF,MAAM,CAAC,MAAM,WAAW,GAAiC,iBAAiB,CAAC"}
1
+ {"version":3,"file":"mysql.js","sourceRoot":"","sources":["../src/mysql.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE9D,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAM5D,wFAAwF;AACxF,MAAM,CAAC,MAAM,WAAW,GAAiC,iBAAiB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { OpenPostgres } from "../pg-client.types.js";
2
+ /** Connects to a PostgreSQL URL with Bun's SQL client; it connects on the first query. */
3
+ export declare const openBunPostgres: OpenPostgres;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pg-client/bun/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,uBAAuB,CAAC;AAE5E,0FAA0F;AAC1F,eAAO,MAAM,eAAe,EAAE,YAC0D,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** PostgreSQL on Bun: Bun's built-in SQL client through Drizzle's `bun-sql` driver. */
2
+ import { drizzle } from "drizzle-orm/bun-sql";
3
+ /** Connects to a PostgreSQL URL with Bun's SQL client; it connects on the first query. */
4
+ export const openBunPostgres = (url, config) => drizzle.postgres({ ...config, connection: url });
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pg-client/bun/index.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,0FAA0F;AAC1F,MAAM,CAAC,MAAM,eAAe,GAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAC3D,OAAO,CAAC,QAAQ,CAAC,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,CAAuC,CAAC"}
@@ -0,0 +1,25 @@
1
+ /** Connects to PostgreSQL with the driver of the runtime the application runs on. */
2
+ import type { AnyRelations, EmptyRelations } from "drizzle-orm/relations";
3
+ import type { PostgresDatabase, PostgresDatabaseConfig } from "./pg-client.types.js";
4
+ export type { PostgresDatabase, PostgresDatabaseConfig } from "./pg-client.types.js";
5
+ /**
6
+ * Connects to a PostgreSQL database with Bun's built-in SQL client on Bun and `pg` on Node, so
7
+ * one Drizzle service runs on both. Only the current runtime's driver is loaded: a Node
8
+ * application needs `pg` installed, a Bun application needs nothing more.
9
+ * @param url - Connection URL, such as `postgres://user:password@localhost:5432/app`.
10
+ * @param config - Drizzle settings, such as `logger`, passed to the runtime's driver.
11
+ * @returns The Drizzle database; end its connections with `database.$client.end()`.
12
+ * @example
13
+ * ```ts
14
+ * import { openPostgresDatabase } from "@relkit/drizzle/pg";
15
+ *
16
+ * // Nothing connects until the first query runs, such as `database.execute(sql\`select 1\`)`.
17
+ * const database = await openPostgresDatabase("postgres://app@localhost:5432/app");
18
+ * console.assert(typeof database.execute === "function");
19
+ * await database.$client.end();
20
+ * ```
21
+ * @category Database
22
+ * @since 0.9.1
23
+ */
24
+ export declare function openPostgresDatabase<Relations extends AnyRelations = EmptyRelations>(url: string, config?: PostgresDatabaseConfig<Relations>): Promise<PostgresDatabase<Relations>>;
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pg-client/index.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACrF,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAErF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,oBAAoB,CAAC,SAAS,SAAS,YAAY,GAAG,cAAc,EACxF,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,sBAAsB,CAAC,SAAS,CAAC,GACzC,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAMtC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Connects to a PostgreSQL database with Bun's built-in SQL client on Bun and `pg` on Node, so
3
+ * one Drizzle service runs on both. Only the current runtime's driver is loaded: a Node
4
+ * application needs `pg` installed, a Bun application needs nothing more.
5
+ * @param url - Connection URL, such as `postgres://user:password@localhost:5432/app`.
6
+ * @param config - Drizzle settings, such as `logger`, passed to the runtime's driver.
7
+ * @returns The Drizzle database; end its connections with `database.$client.end()`.
8
+ * @example
9
+ * ```ts
10
+ * import { openPostgresDatabase } from "@relkit/drizzle/pg";
11
+ *
12
+ * // Nothing connects until the first query runs, such as `database.execute(sql\`select 1\`)`.
13
+ * const database = await openPostgresDatabase("postgres://app@localhost:5432/app");
14
+ * console.assert(typeof database.execute === "function");
15
+ * await database.$client.end();
16
+ * ```
17
+ * @category Database
18
+ * @since 0.9.1
19
+ */
20
+ export async function openPostgresDatabase(url, config) {
21
+ const open = typeof process.versions.bun === "string"
22
+ ? (await import("./bun/index.js")).openBunPostgres
23
+ : (await import("./node/index.js")).openNodePostgres;
24
+ return open(url, config);
25
+ }
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pg-client/index.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,GAAW,EACX,MAA0C;IAE1C,MAAM,IAAI,GACR,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,KAAK,QAAQ;QACtC,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,eAAe;QAClD,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,CAAC;IACzD,OAAO,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { OpenPostgres } from "../pg-client.types.js";
2
+ /** Connects to a PostgreSQL URL with a `pg` pool; it connects on the first query. */
3
+ export declare const openNodePostgres: OpenPostgres;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pg-client/node/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,uBAAuB,CAAC;AAE5E,qFAAqF;AACrF,eAAO,MAAM,gBAAgB,EAAE,YACgD,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** PostgreSQL on Node: a `pg` connection pool through Drizzle's `node-postgres` driver. */
2
+ import { drizzle } from "drizzle-orm/node-postgres";
3
+ /** Connects to a PostgreSQL URL with a `pg` pool; it connects on the first query. */
4
+ export const openNodePostgres = (url, config) => drizzle({ ...config, connection: url });
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pg-client/node/index.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAGpD,qFAAqF;AACrF,MAAM,CAAC,MAAM,gBAAgB,GAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAC5D,OAAO,CAAC,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,CAAuC,CAAC"}
@@ -0,0 +1,16 @@
1
+ /** The Drizzle PostgreSQL database `openPostgresDatabase` returns on either runtime. */
2
+ import type { PgAsyncDatabase } from "drizzle-orm/pg-core/async/db";
3
+ import type { PgQueryResultHKT } from "drizzle-orm/pg-core/session";
4
+ import type { DrizzlePgConfig } from "drizzle-orm/pg-core/utils";
5
+ import type { AnyRelations, EmptyRelations } from "drizzle-orm/relations";
6
+ /** An asynchronous Drizzle PostgreSQL database whose connection pool can be ended. */
7
+ export type PostgresDatabase<Relations extends AnyRelations = EmptyRelations> = PgAsyncDatabase<PgQueryResultHKT, Relations> & {
8
+ readonly $client: {
9
+ end(): Promise<void>;
10
+ };
11
+ };
12
+ /** Drizzle settings passed through to the runtime's driver. */
13
+ export type PostgresDatabaseConfig<Relations extends AnyRelations = EmptyRelations> = DrizzlePgConfig<Relations>;
14
+ /** Connects to one PostgreSQL URL with a runtime's driver. */
15
+ export type OpenPostgres = <Relations extends AnyRelations = EmptyRelations>(url: string, config?: PostgresDatabaseConfig<Relations>) => PostgresDatabase<Relations>;
16
+ //# sourceMappingURL=pg-client.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pg-client.types.d.ts","sourceRoot":"","sources":["../../src/pg-client/pg-client.types.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE1E,sFAAsF;AACtF,MAAM,MAAM,gBAAgB,CAAC,SAAS,SAAS,YAAY,GAAG,cAAc,IAAI,eAAe,CAC7F,gBAAgB,EAChB,SAAS,CACV,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE;QAAE,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAA;CAAE,CAAC;AAEnD,+DAA+D;AAC/D,MAAM,MAAM,sBAAsB,CAAC,SAAS,SAAS,YAAY,GAAG,cAAc,IAChF,eAAe,CAAC,SAAS,CAAC,CAAC;AAE7B,8DAA8D;AAC9D,MAAM,MAAM,YAAY,GAAG,CAAC,SAAS,SAAS,YAAY,GAAG,cAAc,EACzE,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,sBAAsB,CAAC,SAAS,CAAC,KACvC,gBAAgB,CAAC,SAAS,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=pg-client.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pg-client.types.js","sourceRoot":"","sources":["../../src/pg-client/pg-client.types.ts"],"names":[],"mappings":""}
package/dist/pg.d.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  import type { PgAsyncDatabase } from "drizzle-orm/pg-core/async/db";
3
3
  import type { DefineModel } from "./model.types.js";
4
4
  export * from "./index.js";
5
+ export { openPostgresDatabase } from "./pg-client/index.js";
6
+ export type { PostgresDatabase, PostgresDatabaseConfig } from "./pg-client/index.js";
5
7
  /** Native database injected into model extensions for the selected dialect. */
6
8
  export type DialectDatabase = Omit<PgAsyncDatabase<any, any>, "query">;
7
9
  /** Declares lazy native extensions with this dialect's real transaction client type. */
package/dist/pg.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pg.d.ts","sourceRoot":"","sources":["../src/pg.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,cAAc,YAAY,CAAC;AAE3B,+EAA+E;AAC/E,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;AAEvE,wFAAwF;AACxF,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,eAAe,CAAqB,CAAC"}
1
+ {"version":3,"file":"pg.d.ts","sourceRoot":"","sources":["../src/pg.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAErF,+EAA+E;AAC/E,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;AAEvE,wFAAwF;AACxF,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,eAAe,CAAqB,CAAC"}
package/dist/pg.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { defineModel as defineNativeModel } from "./model.js";
2
2
  export * from "./index.js";
3
+ export { openPostgresDatabase } from "./pg-client/index.js";
3
4
  /** Declares lazy native extensions with this dialect's real transaction client type. */
4
5
  export const defineModel = defineNativeModel;
5
6
  //# sourceMappingURL=pg.js.map
package/dist/pg.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pg.js","sourceRoot":"","sources":["../src/pg.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE9D,cAAc,YAAY,CAAC;AAK3B,wFAAwF;AACxF,MAAM,CAAC,MAAM,WAAW,GAAiC,iBAAiB,CAAC"}
1
+ {"version":3,"file":"pg.js","sourceRoot":"","sources":["../src/pg.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE9D,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAM5D,wFAAwF;AACxF,MAAM,CAAC,MAAM,WAAW,GAAiC,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relkit/drizzle",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Drizzle ORM integration for RelKit functions.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -47,18 +47,21 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "effect": "4.0.1",
50
- "relkit": "0.9.0",
50
+ "relkit": "0.9.2",
51
51
  "zod": "4.6.7"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@effect/vitest": "4.0.1",
55
+ "@types/pg": "8.15.6",
55
56
  "drizzle-orm": "1.0.0-rc.5-169397b",
56
57
  "mysql2": "3.23.1",
58
+ "pg": "8.23.0",
57
59
  "vitest": "5.0.1"
58
60
  },
59
61
  "peerDependencies": {
60
62
  "drizzle-orm": "1.0.0-rc.5-169397b",
61
- "mysql2": ">=2.0.0"
63
+ "mysql2": ">=2.0.0",
64
+ "pg": ">=8.0.0"
62
65
  },
63
66
  "peerDependenciesMeta": {
64
67
  "drizzle-orm": {
@@ -66,6 +69,9 @@
66
69
  },
67
70
  "mysql2": {
68
71
  "optional": true
72
+ },
73
+ "pg": {
74
+ "optional": true
69
75
  }
70
76
  },
71
77
  "relkit": {
@@ -97,13 +103,25 @@
97
103
  {
98
104
  "package": "mysql2",
99
105
  "supportedRange": ">=2.0.0",
100
- "installSection": "devDependencies",
106
+ "installSection": "dependencies",
101
107
  "capabilities": [
102
108
  "mysql"
103
109
  ],
104
110
  "phases": [
105
111
  "check",
106
- "build"
112
+ "build",
113
+ "runtime"
114
+ ]
115
+ },
116
+ {
117
+ "package": "pg",
118
+ "supportedRange": ">=8.0.0",
119
+ "installSection": "dependencies",
120
+ "capabilities": [
121
+ "pg"
122
+ ],
123
+ "phases": [
124
+ "runtime"
107
125
  ]
108
126
  }
109
127
  ]