@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.
- package/dist/auth-Do_CXnv3.js +50 -0
- package/dist/auth-Do_CXnv3.js.map +1 -0
- package/dist/auth-DwdzzHD4.d.ts +656 -0
- package/dist/auth-DwdzzHD4.d.ts.map +1 -0
- package/dist/chunk-076AhbV_.js +26 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/index.js +4 -0
- package/dist/config/types.d.ts +2 -0
- package/dist/config/types.js +1 -0
- package/dist/connection-CqOTA50h.d.ts +26 -0
- package/dist/connection-CqOTA50h.d.ts.map +1 -0
- package/dist/{connection-DLElEUET.js → connection-qCY3AVOI.js} +1 -1
- package/dist/{connection-DLElEUET.js.map → connection-qCY3AVOI.js.map} +1 -1
- package/dist/connection.d.ts +2 -26
- package/dist/connection.js +1 -1
- package/dist/index.d.ts +34 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -3
- package/dist/index.js.map +1 -1
- package/dist/schema/auth.d.ts +2 -656
- package/dist/schema/auth.js +2 -49
- package/dist/schema-discovery.d.ts +17 -0
- package/dist/schema-discovery.d.ts.map +1 -0
- package/dist/schema-discovery.js +110 -0
- package/dist/schema-discovery.js.map +1 -0
- package/dist/types-Dq-KsFrs.d.ts +21 -0
- package/dist/types-Dq-KsFrs.d.ts.map +1 -0
- package/package.json +9 -1
- package/dist/connection.d.ts.map +0 -1
- package/dist/schema/auth.d.ts.map +0 -1
- package/dist/schema/auth.js.map +0 -1
|
@@ -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,C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
|
|
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 @@
|
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-
|
|
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"}
|
package/dist/connection.d.ts
CHANGED
|
@@ -1,26 +1,2 @@
|
|
|
1
|
-
|
|
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 };
|
package/dist/connection.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
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
|
-
|
|
6
|
-
|
|
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 {
|
|
38
|
+
export { type DbConfig, DrizzleDb, account, buildDatabaseUrl, createDatabase, createDb, createDbPool, ensureDatabaseUrl, session, user, verification };
|
|
10
39
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":"
|
|
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-
|
|
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
|
-
|
|
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 {
|
|
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
|
|
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"}
|