@kuckit/db 1.0.3 → 2.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-DwdzzHD4.d.ts","names":[],"sources":["../src/schema/auth.ts"],"sourcesContent":[],"mappings":";;;;cAEa,2BAAI;;;;IAAJ,EAAA,EASX,oBAAA,CAAA,QAAA,CAAA;MAAA,IAAA,EAAA,IAAA;;;;;;;;;;;;;gBATe,SAAA;MAAA,SAAA,EAAA,SAAA;IAWJ,CAAA,EAAA,CAAA,CAAA,EAWX,CAAA,CAAA,CAAA;IAAA,IAAA,+BAAA,CAAA;;;;;;;;;;;uBAXkB,EAAA,KAAA;MAAA,UAAA,EAAA,CAAA,MAAA,EAAA,GAAA,MAAA,EAAA,CAAA;MAaP,UAgBX,EAAA,KAAA;MAAA,QAAA,EAAA,SAAA;;;;;;;;;;;;;;;;;gBAhBkB,SAAA;MAAA,SAAA,EAAA,SAAA;IAkBP,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA;IAOX,aAAA,+BAAA,CAAA;;;;;;;;;kBAPuB,EAAA,KAAA;MAAA,eAAA,EAAA,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA/BZ,8BAAO;;;;QAWlB,oBAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEW,8BAAO;;;;QAgBlB,oBAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEW,mCAAY;;;;QAOvB,oBAAA,CAAA"}
@@ -0,0 +1,26 @@
1
+ import { createRequire } from "node:module";
2
+
3
+ //#region rolldown:runtime
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
21
+ value: mod,
22
+ enumerable: true
23
+ }) : target, mod));
24
+
25
+ //#endregion
26
+ export { };
@@ -0,0 +1,4 @@
1
+ import { i as verification, n as session, r as user, t as account } from "../auth-DwdzzHD4.js";
2
+ import { n as ensureDatabaseUrl, t as buildDatabaseUrl } from "../connection-CqOTA50h.js";
3
+ import { t as DbConfig } from "../types-Dq-KsFrs.js";
4
+ export { type DbConfig, account, buildDatabaseUrl, ensureDatabaseUrl, session, user, verification };
@@ -0,0 +1,4 @@
1
+ import { n as ensureDatabaseUrl, t as buildDatabaseUrl } from "../connection-qCY3AVOI.js";
2
+ import { i as verification, n as session, r as user, t as account } from "../auth-Do_CXnv3.js";
3
+
4
+ export { account, buildDatabaseUrl, ensureDatabaseUrl, session, user, verification };
@@ -0,0 +1,2 @@
1
+ import { t as DbConfig } from "../types-Dq-KsFrs.js";
2
+ export { DbConfig };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,26 @@
1
+ //#region src/connection.d.ts
2
+ /**
3
+ * Database connection utilities
4
+ * Single source of truth for DATABASE_URL construction
5
+ */
6
+ /**
7
+ * Build DATABASE_URL from environment variables
8
+ *
9
+ * Supports two modes:
10
+ * 1. Direct DATABASE_URL - used in local development
11
+ * 2. Individual DB_* vars - used in Cloud Run with Cloud SQL Auth Proxy
12
+ *
13
+ * Cloud SQL Unix socket format: postgresql://user:password@/dbname?host=/cloudsql/connection-name
14
+ *
15
+ * @throws Error if neither DATABASE_URL nor complete DB_* vars are provided
16
+ */
17
+ declare function buildDatabaseUrl(): string;
18
+ /**
19
+ * Ensure DATABASE_URL is set in process.env
20
+ * Call this early in application startup to set up the environment
21
+ * for packages that read process.env.DATABASE_URL directly
22
+ */
23
+ declare function ensureDatabaseUrl(): string;
24
+ //#endregion
25
+ export { ensureDatabaseUrl as n, buildDatabaseUrl as t };
26
+ //# sourceMappingURL=connection-CqOTA50h.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-CqOTA50h.d.ts","names":[],"sources":["../src/connection.ts"],"sourcesContent":[],"mappings":";;AAgBA;AAuBA;;;;;;;;;;;;;iBAvBgB,gBAAA,CAAA;;;;;;iBAuBA,iBAAA,CAAA"}
@@ -33,4 +33,4 @@ function ensureDatabaseUrl() {
33
33
 
34
34
  //#endregion
35
35
  export { ensureDatabaseUrl as n, buildDatabaseUrl as t };
36
- //# sourceMappingURL=connection-DLElEUET.js.map
36
+ //# sourceMappingURL=connection-qCY3AVOI.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection-DLElEUET.js","names":[],"sources":["../src/connection.ts"],"sourcesContent":["/**\n * Database connection utilities\n * Single source of truth for DATABASE_URL construction\n */\n\n/**\n * Build DATABASE_URL from environment variables\n *\n * Supports two modes:\n * 1. Direct DATABASE_URL - used in local development\n * 2. Individual DB_* vars - used in Cloud Run with Cloud SQL Auth Proxy\n *\n * Cloud SQL Unix socket format: postgresql://user:password@/dbname?host=/cloudsql/connection-name\n *\n * @throws Error if neither DATABASE_URL nor complete DB_* vars are provided\n */\nexport function buildDatabaseUrl(): string {\n\t// Prefer DATABASE_URL if provided directly\n\tif (process.env.DATABASE_URL) {\n\t\treturn process.env.DATABASE_URL\n\t}\n\n\t// Construct from individual components (Cloud Run with Cloud SQL)\n\tconst { DB_HOST, DB_USER, DB_PASSWORD, DB_NAME } = process.env\n\tif (DB_HOST && DB_USER && DB_PASSWORD && DB_NAME) {\n\t\t// Cloud SQL Auth Proxy uses Unix socket path in host\n\t\treturn `postgresql://${DB_USER}:${encodeURIComponent(DB_PASSWORD)}@/${DB_NAME}?host=${DB_HOST}`\n\t}\n\n\tthrow new Error(\n\t\t'Missing database configuration: provide DATABASE_URL or DB_HOST, DB_USER, DB_PASSWORD, DB_NAME'\n\t)\n}\n\n/**\n * Ensure DATABASE_URL is set in process.env\n * Call this early in application startup to set up the environment\n * for packages that read process.env.DATABASE_URL directly\n */\nexport function ensureDatabaseUrl(): string {\n\tconst url = buildDatabaseUrl()\n\tprocess.env.DATABASE_URL = url\n\treturn url\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAgB,mBAA2B;AAE1C,KAAI,QAAQ,IAAI,aACf,QAAO,QAAQ,IAAI;CAIpB,MAAM,EAAE,SAAS,SAAS,aAAa,YAAY,QAAQ;AAC3D,KAAI,WAAW,WAAW,eAAe,QAExC,QAAO,gBAAgB,QAAQ,GAAG,mBAAmB,YAAY,CAAC,IAAI,QAAQ,QAAQ;AAGvF,OAAM,IAAI,MACT,iGACA;;;;;;;AAQF,SAAgB,oBAA4B;CAC3C,MAAM,MAAM,kBAAkB;AAC9B,SAAQ,IAAI,eAAe;AAC3B,QAAO"}
1
+ {"version":3,"file":"connection-qCY3AVOI.js","names":[],"sources":["../src/connection.ts"],"sourcesContent":["/**\n * Database connection utilities\n * Single source of truth for DATABASE_URL construction\n */\n\n/**\n * Build DATABASE_URL from environment variables\n *\n * Supports two modes:\n * 1. Direct DATABASE_URL - used in local development\n * 2. Individual DB_* vars - used in Cloud Run with Cloud SQL Auth Proxy\n *\n * Cloud SQL Unix socket format: postgresql://user:password@/dbname?host=/cloudsql/connection-name\n *\n * @throws Error if neither DATABASE_URL nor complete DB_* vars are provided\n */\nexport function buildDatabaseUrl(): string {\n\t// Prefer DATABASE_URL if provided directly\n\tif (process.env.DATABASE_URL) {\n\t\treturn process.env.DATABASE_URL\n\t}\n\n\t// Construct from individual components (Cloud Run with Cloud SQL)\n\tconst { DB_HOST, DB_USER, DB_PASSWORD, DB_NAME } = process.env\n\tif (DB_HOST && DB_USER && DB_PASSWORD && DB_NAME) {\n\t\t// Cloud SQL Auth Proxy uses Unix socket path in host\n\t\treturn `postgresql://${DB_USER}:${encodeURIComponent(DB_PASSWORD)}@/${DB_NAME}?host=${DB_HOST}`\n\t}\n\n\tthrow new Error(\n\t\t'Missing database configuration: provide DATABASE_URL or DB_HOST, DB_USER, DB_PASSWORD, DB_NAME'\n\t)\n}\n\n/**\n * Ensure DATABASE_URL is set in process.env\n * Call this early in application startup to set up the environment\n * for packages that read process.env.DATABASE_URL directly\n */\nexport function ensureDatabaseUrl(): string {\n\tconst url = buildDatabaseUrl()\n\tprocess.env.DATABASE_URL = url\n\treturn url\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAgB,mBAA2B;AAE1C,KAAI,QAAQ,IAAI,aACf,QAAO,QAAQ,IAAI;CAIpB,MAAM,EAAE,SAAS,SAAS,aAAa,YAAY,QAAQ;AAC3D,KAAI,WAAW,WAAW,eAAe,QAExC,QAAO,gBAAgB,QAAQ,GAAG,mBAAmB,YAAY,CAAC,IAAI,QAAQ,QAAQ;AAGvF,OAAM,IAAI,MACT,iGACA;;;;;;;AAQF,SAAgB,oBAA4B;CAC3C,MAAM,MAAM,kBAAkB;AAC9B,SAAQ,IAAI,eAAe;AAC3B,QAAO"}
@@ -1,26 +1,2 @@
1
- //#region src/connection.d.ts
2
- /**
3
- * Database connection utilities
4
- * Single source of truth for DATABASE_URL construction
5
- */
6
- /**
7
- * Build DATABASE_URL from environment variables
8
- *
9
- * Supports two modes:
10
- * 1. Direct DATABASE_URL - used in local development
11
- * 2. Individual DB_* vars - used in Cloud Run with Cloud SQL Auth Proxy
12
- *
13
- * Cloud SQL Unix socket format: postgresql://user:password@/dbname?host=/cloudsql/connection-name
14
- *
15
- * @throws Error if neither DATABASE_URL nor complete DB_* vars are provided
16
- */
17
- declare function buildDatabaseUrl(): string;
18
- /**
19
- * Ensure DATABASE_URL is set in process.env
20
- * Call this early in application startup to set up the environment
21
- * for packages that read process.env.DATABASE_URL directly
22
- */
23
- declare function ensureDatabaseUrl(): string;
24
- //#endregion
25
- export { buildDatabaseUrl, ensureDatabaseUrl };
26
- //# sourceMappingURL=connection.d.ts.map
1
+ import { n as ensureDatabaseUrl, t as buildDatabaseUrl } from "./connection-CqOTA50h.js";
2
+ export { buildDatabaseUrl, ensureDatabaseUrl };
@@ -1,3 +1,3 @@
1
- import { n as ensureDatabaseUrl, t as buildDatabaseUrl } from "./connection-DLElEUET.js";
1
+ import { n as ensureDatabaseUrl, t as buildDatabaseUrl } from "./connection-qCY3AVOI.js";
2
2
 
3
3
  export { buildDatabaseUrl, ensureDatabaseUrl };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,39 @@
1
- import * as drizzle_orm_node_postgres0 from "drizzle-orm/node-postgres";
2
- import * as pg0 from "pg";
1
+ import { i as verification, n as session, r as user, t as account } from "./auth-DwdzzHD4.js";
2
+ import { n as ensureDatabaseUrl, t as buildDatabaseUrl } from "./connection-CqOTA50h.js";
3
+ import { t as DbConfig } from "./types-Dq-KsFrs.js";
4
+ import { NodePgDatabase } from "drizzle-orm/node-postgres";
5
+ import { Pool } from "pg";
3
6
 
4
7
  //#region src/index.d.ts
5
- declare const db: drizzle_orm_node_postgres0.NodePgDatabase<Record<string, never>> & {
6
- $client: pg0.Pool;
8
+
9
+ /**
10
+ * Database type (Drizzle with node-postgres)
11
+ */
12
+ type DrizzleDb = NodePgDatabase;
13
+ /**
14
+ * Create a database connection pool
15
+ *
16
+ * @param connectionString - PostgreSQL connection URL
17
+ * @returns Pool instance
18
+ */
19
+ declare function createDbPool(connectionString: string): Pool;
20
+ /**
21
+ * Create a Drizzle database instance from a connection pool
22
+ *
23
+ * @param pool - pg Pool instance
24
+ * @returns Drizzle database instance
25
+ */
26
+ declare function createDb(pool: Pool): DrizzleDb;
27
+ /**
28
+ * Create both pool and db in one call
29
+ *
30
+ * @param connectionString - PostgreSQL connection URL
31
+ * @returns Object with pool and db
32
+ */
33
+ declare function createDatabase(connectionString: string): {
34
+ pool: Pool;
35
+ db: DrizzleDb;
7
36
  };
8
37
  //#endregion
9
- export { db };
38
+ export { type DbConfig, DrizzleDb, account, buildDatabaseUrl, createDatabase, createDb, createDbPool, ensureDatabaseUrl, session, user, verification };
10
39
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;cAGa,IAAE,0BAAA,CAAA,eAAA;WAAA,GAAA,CAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAeA;AAQgB,KARJ,SAAA,GAAY,cAQoC;AAe5D;AAUA;;;;;iBAzBgB,YAAA,4BAAwC;;;;;;;iBAexC,QAAA,OAAe,OAAO;;;;;;;iBAUtB,cAAA;QAAkD;MAAU"}
package/dist/index.js CHANGED
@@ -1,9 +1,46 @@
1
- import { t as buildDatabaseUrl } from "./connection-DLElEUET.js";
1
+ import { n as ensureDatabaseUrl, t as buildDatabaseUrl } from "./connection-qCY3AVOI.js";
2
+ import { i as verification, n as session, r as user, t as account } from "./auth-Do_CXnv3.js";
2
3
  import { drizzle } from "drizzle-orm/node-postgres";
4
+ import { Pool } from "pg";
3
5
 
4
6
  //#region src/index.ts
5
- const db = drizzle(buildDatabaseUrl());
7
+ /**
8
+ * Create a database connection pool
9
+ *
10
+ * @param connectionString - PostgreSQL connection URL
11
+ * @returns Pool instance
12
+ */
13
+ function createDbPool(connectionString) {
14
+ return new Pool({
15
+ connectionString,
16
+ max: 20,
17
+ idleTimeoutMillis: 3e4,
18
+ connectionTimeoutMillis: 2e3
19
+ });
20
+ }
21
+ /**
22
+ * Create a Drizzle database instance from a connection pool
23
+ *
24
+ * @param pool - pg Pool instance
25
+ * @returns Drizzle database instance
26
+ */
27
+ function createDb(pool) {
28
+ return drizzle(pool);
29
+ }
30
+ /**
31
+ * Create both pool and db in one call
32
+ *
33
+ * @param connectionString - PostgreSQL connection URL
34
+ * @returns Object with pool and db
35
+ */
36
+ function createDatabase(connectionString) {
37
+ const pool = createDbPool(connectionString);
38
+ return {
39
+ pool,
40
+ db: createDb(pool)
41
+ };
42
+ }
6
43
 
7
44
  //#endregion
8
- export { db };
45
+ export { account, buildDatabaseUrl, createDatabase, createDb, createDbPool, ensureDatabaseUrl, session, user, verification };
9
46
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { drizzle } from 'drizzle-orm/node-postgres'\nimport { buildDatabaseUrl } from './connection'\n\nexport const db = drizzle(buildDatabaseUrl())\n"],"mappings":";;;;AAGA,MAAa,KAAK,QAAQ,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { drizzle, type NodePgDatabase } from 'drizzle-orm/node-postgres'\nimport { Pool } from 'pg'\n\n// Re-export schemas for convenience\nexport * from './schema/auth'\n\n// Re-export connection utilities\nexport { buildDatabaseUrl, ensureDatabaseUrl } from './connection'\n\n// Export types\nexport type { DbConfig } from './config/types'\n\n/**\n * Database type (Drizzle with node-postgres)\n */\nexport type DrizzleDb = NodePgDatabase\n\n/**\n * Create a database connection pool\n *\n * @param connectionString - PostgreSQL connection URL\n * @returns Pool instance\n */\nexport function createDbPool(connectionString: string): Pool {\n\treturn new Pool({\n\t\tconnectionString,\n\t\tmax: 20,\n\t\tidleTimeoutMillis: 30000,\n\t\tconnectionTimeoutMillis: 2000,\n\t})\n}\n\n/**\n * Create a Drizzle database instance from a connection pool\n *\n * @param pool - pg Pool instance\n * @returns Drizzle database instance\n */\nexport function createDb(pool: Pool): DrizzleDb {\n\treturn drizzle(pool)\n}\n\n/**\n * Create both pool and db in one call\n *\n * @param connectionString - PostgreSQL connection URL\n * @returns Object with pool and db\n */\nexport function createDatabase(connectionString: string): { pool: Pool; db: DrizzleDb } {\n\tconst pool = createDbPool(connectionString)\n\tconst db = createDb(pool)\n\treturn { pool, db }\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,SAAgB,aAAa,kBAAgC;AAC5D,QAAO,IAAI,KAAK;EACf;EACA,KAAK;EACL,mBAAmB;EACnB,yBAAyB;EACzB,CAAC;;;;;;;;AASH,SAAgB,SAAS,MAAuB;AAC/C,QAAO,QAAQ,KAAK;;;;;;;;AASrB,SAAgB,eAAe,kBAAyD;CACvF,MAAM,OAAO,aAAa,iBAAiB;AAE3C,QAAO;EAAE;EAAM,IADJ,SAAS,KAAK;EACN"}