@kuckit/db 1.0.0

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,36 @@
1
+ //#region src/connection.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
+ function buildDatabaseUrl() {
18
+ if (process.env.DATABASE_URL) return process.env.DATABASE_URL;
19
+ const { DB_HOST, DB_USER, DB_PASSWORD, DB_NAME } = process.env;
20
+ if (DB_HOST && DB_USER && DB_PASSWORD && DB_NAME) return `postgresql://${DB_USER}:${encodeURIComponent(DB_PASSWORD)}@/${DB_NAME}?host=${DB_HOST}`;
21
+ throw new Error("Missing database configuration: provide DATABASE_URL or DB_HOST, DB_USER, DB_PASSWORD, DB_NAME");
22
+ }
23
+ /**
24
+ * Ensure DATABASE_URL is set in process.env
25
+ * Call this early in application startup to set up the environment
26
+ * for packages that read process.env.DATABASE_URL directly
27
+ */
28
+ function ensureDatabaseUrl() {
29
+ const url = buildDatabaseUrl();
30
+ process.env.DATABASE_URL = url;
31
+ return url;
32
+ }
33
+
34
+ //#endregion
35
+ export { ensureDatabaseUrl as n, buildDatabaseUrl as t };
36
+ //# sourceMappingURL=connection-DLElEUET.js.map
@@ -0,0 +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"}
@@ -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 { buildDatabaseUrl, ensureDatabaseUrl };
26
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","names":[],"sources":["../src/connection.ts"],"sourcesContent":[],"mappings":";;AAgBA;AAuBA;;;;;;;;;;;;;iBAvBgB,gBAAA,CAAA;;;;;;iBAuBA,iBAAA,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { n as ensureDatabaseUrl, t as buildDatabaseUrl } from "./connection-DLElEUET.js";
2
+
3
+ export { buildDatabaseUrl, ensureDatabaseUrl };
@@ -0,0 +1,10 @@
1
+ import * as drizzle_orm_node_postgres0 from "drizzle-orm/node-postgres";
2
+ import * as pg0 from "pg";
3
+
4
+ //#region src/index.d.ts
5
+ declare const db: drizzle_orm_node_postgres0.NodePgDatabase<Record<string, never>> & {
6
+ $client: pg0.Pool;
7
+ };
8
+ //#endregion
9
+ export { db };
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;cAGa,IAAE,0BAAA,CAAA,eAAA;WAAA,GAAA,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ import { t as buildDatabaseUrl } from "./connection-DLElEUET.js";
2
+ import { drizzle } from "drizzle-orm/node-postgres";
3
+
4
+ //#region src/index.ts
5
+ const db = drizzle(buildDatabaseUrl());
6
+
7
+ //#endregion
8
+ export { db };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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"}
@@ -0,0 +1,656 @@
1
+ import * as drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
2
+ import * as drizzle_orm0 from "drizzle-orm";
3
+
4
+ //#region src/schema/auth.d.ts
5
+ declare const user: drizzle_orm_pg_core0.PgTableWithColumns<{
6
+ name: "user";
7
+ schema: undefined;
8
+ columns: {
9
+ id: drizzle_orm_pg_core0.PgColumn<{
10
+ name: "id";
11
+ tableName: "user";
12
+ dataType: "string";
13
+ columnType: "PgText";
14
+ data: string;
15
+ driverParam: string;
16
+ notNull: true;
17
+ hasDefault: false;
18
+ isPrimaryKey: true;
19
+ isAutoincrement: false;
20
+ hasRuntimeDefault: false;
21
+ enumValues: [string, ...string[]];
22
+ baseColumn: never;
23
+ identity: undefined;
24
+ generated: undefined;
25
+ }, {}, {}>;
26
+ name: drizzle_orm_pg_core0.PgColumn<{
27
+ name: "name";
28
+ tableName: "user";
29
+ dataType: "string";
30
+ columnType: "PgText";
31
+ data: string;
32
+ driverParam: string;
33
+ notNull: true;
34
+ hasDefault: false;
35
+ isPrimaryKey: false;
36
+ isAutoincrement: false;
37
+ hasRuntimeDefault: false;
38
+ enumValues: [string, ...string[]];
39
+ baseColumn: never;
40
+ identity: undefined;
41
+ generated: undefined;
42
+ }, {}, {}>;
43
+ email: drizzle_orm_pg_core0.PgColumn<{
44
+ name: "email";
45
+ tableName: "user";
46
+ dataType: "string";
47
+ columnType: "PgText";
48
+ data: string;
49
+ driverParam: string;
50
+ notNull: true;
51
+ hasDefault: false;
52
+ isPrimaryKey: false;
53
+ isAutoincrement: false;
54
+ hasRuntimeDefault: false;
55
+ enumValues: [string, ...string[]];
56
+ baseColumn: never;
57
+ identity: undefined;
58
+ generated: undefined;
59
+ }, {}, {}>;
60
+ emailVerified: drizzle_orm_pg_core0.PgColumn<{
61
+ name: "email_verified";
62
+ tableName: "user";
63
+ dataType: "boolean";
64
+ columnType: "PgBoolean";
65
+ data: boolean;
66
+ driverParam: boolean;
67
+ notNull: true;
68
+ hasDefault: false;
69
+ isPrimaryKey: false;
70
+ isAutoincrement: false;
71
+ hasRuntimeDefault: false;
72
+ enumValues: undefined;
73
+ baseColumn: never;
74
+ identity: undefined;
75
+ generated: undefined;
76
+ }, {}, {}>;
77
+ image: drizzle_orm_pg_core0.PgColumn<{
78
+ name: "image";
79
+ tableName: "user";
80
+ dataType: "string";
81
+ columnType: "PgText";
82
+ data: string;
83
+ driverParam: string;
84
+ notNull: false;
85
+ hasDefault: false;
86
+ isPrimaryKey: false;
87
+ isAutoincrement: false;
88
+ hasRuntimeDefault: false;
89
+ enumValues: [string, ...string[]];
90
+ baseColumn: never;
91
+ identity: undefined;
92
+ generated: undefined;
93
+ }, {}, {}>;
94
+ permissions: drizzle_orm_pg_core0.PgColumn<{
95
+ name: "permissions";
96
+ tableName: "user";
97
+ dataType: "array";
98
+ columnType: "PgArray";
99
+ data: string[];
100
+ driverParam: string | string[];
101
+ notNull: true;
102
+ hasDefault: true;
103
+ isPrimaryKey: false;
104
+ isAutoincrement: false;
105
+ hasRuntimeDefault: false;
106
+ enumValues: [string, ...string[]];
107
+ baseColumn: drizzle_orm0.Column<{
108
+ name: "permissions";
109
+ tableName: "user";
110
+ dataType: "string";
111
+ columnType: "PgText";
112
+ data: string;
113
+ driverParam: string;
114
+ notNull: false;
115
+ hasDefault: false;
116
+ isPrimaryKey: false;
117
+ isAutoincrement: false;
118
+ hasRuntimeDefault: false;
119
+ enumValues: [string, ...string[]];
120
+ baseColumn: never;
121
+ identity: undefined;
122
+ generated: undefined;
123
+ }, {}, {}>;
124
+ identity: undefined;
125
+ generated: undefined;
126
+ }, {}, {
127
+ baseBuilder: drizzle_orm_pg_core0.PgColumnBuilder<{
128
+ name: "permissions";
129
+ dataType: "string";
130
+ columnType: "PgText";
131
+ data: string;
132
+ enumValues: [string, ...string[]];
133
+ driverParam: string;
134
+ }, {}, {}, drizzle_orm0.ColumnBuilderExtraConfig>;
135
+ size: undefined;
136
+ }>;
137
+ createdAt: drizzle_orm_pg_core0.PgColumn<{
138
+ name: "created_at";
139
+ tableName: "user";
140
+ dataType: "date";
141
+ columnType: "PgTimestamp";
142
+ data: Date;
143
+ driverParam: string;
144
+ notNull: true;
145
+ hasDefault: false;
146
+ isPrimaryKey: false;
147
+ isAutoincrement: false;
148
+ hasRuntimeDefault: false;
149
+ enumValues: undefined;
150
+ baseColumn: never;
151
+ identity: undefined;
152
+ generated: undefined;
153
+ }, {}, {}>;
154
+ updatedAt: drizzle_orm_pg_core0.PgColumn<{
155
+ name: "updated_at";
156
+ tableName: "user";
157
+ dataType: "date";
158
+ columnType: "PgTimestamp";
159
+ data: Date;
160
+ driverParam: string;
161
+ notNull: true;
162
+ hasDefault: false;
163
+ isPrimaryKey: false;
164
+ isAutoincrement: false;
165
+ hasRuntimeDefault: false;
166
+ enumValues: undefined;
167
+ baseColumn: never;
168
+ identity: undefined;
169
+ generated: undefined;
170
+ }, {}, {}>;
171
+ };
172
+ dialect: "pg";
173
+ }>;
174
+ declare const session: drizzle_orm_pg_core0.PgTableWithColumns<{
175
+ name: "session";
176
+ schema: undefined;
177
+ columns: {
178
+ id: drizzle_orm_pg_core0.PgColumn<{
179
+ name: "id";
180
+ tableName: "session";
181
+ dataType: "string";
182
+ columnType: "PgText";
183
+ data: string;
184
+ driverParam: string;
185
+ notNull: true;
186
+ hasDefault: false;
187
+ isPrimaryKey: true;
188
+ isAutoincrement: false;
189
+ hasRuntimeDefault: false;
190
+ enumValues: [string, ...string[]];
191
+ baseColumn: never;
192
+ identity: undefined;
193
+ generated: undefined;
194
+ }, {}, {}>;
195
+ expiresAt: drizzle_orm_pg_core0.PgColumn<{
196
+ name: "expires_at";
197
+ tableName: "session";
198
+ dataType: "date";
199
+ columnType: "PgTimestamp";
200
+ data: Date;
201
+ driverParam: string;
202
+ notNull: true;
203
+ hasDefault: false;
204
+ isPrimaryKey: false;
205
+ isAutoincrement: false;
206
+ hasRuntimeDefault: false;
207
+ enumValues: undefined;
208
+ baseColumn: never;
209
+ identity: undefined;
210
+ generated: undefined;
211
+ }, {}, {}>;
212
+ token: drizzle_orm_pg_core0.PgColumn<{
213
+ name: "token";
214
+ tableName: "session";
215
+ dataType: "string";
216
+ columnType: "PgText";
217
+ data: string;
218
+ driverParam: string;
219
+ notNull: true;
220
+ hasDefault: false;
221
+ isPrimaryKey: false;
222
+ isAutoincrement: false;
223
+ hasRuntimeDefault: false;
224
+ enumValues: [string, ...string[]];
225
+ baseColumn: never;
226
+ identity: undefined;
227
+ generated: undefined;
228
+ }, {}, {}>;
229
+ createdAt: drizzle_orm_pg_core0.PgColumn<{
230
+ name: "created_at";
231
+ tableName: "session";
232
+ dataType: "date";
233
+ columnType: "PgTimestamp";
234
+ data: Date;
235
+ driverParam: string;
236
+ notNull: true;
237
+ hasDefault: false;
238
+ isPrimaryKey: false;
239
+ isAutoincrement: false;
240
+ hasRuntimeDefault: false;
241
+ enumValues: undefined;
242
+ baseColumn: never;
243
+ identity: undefined;
244
+ generated: undefined;
245
+ }, {}, {}>;
246
+ updatedAt: drizzle_orm_pg_core0.PgColumn<{
247
+ name: "updated_at";
248
+ tableName: "session";
249
+ dataType: "date";
250
+ columnType: "PgTimestamp";
251
+ data: Date;
252
+ driverParam: string;
253
+ notNull: true;
254
+ hasDefault: false;
255
+ isPrimaryKey: false;
256
+ isAutoincrement: false;
257
+ hasRuntimeDefault: false;
258
+ enumValues: undefined;
259
+ baseColumn: never;
260
+ identity: undefined;
261
+ generated: undefined;
262
+ }, {}, {}>;
263
+ ipAddress: drizzle_orm_pg_core0.PgColumn<{
264
+ name: "ip_address";
265
+ tableName: "session";
266
+ dataType: "string";
267
+ columnType: "PgText";
268
+ data: string;
269
+ driverParam: string;
270
+ notNull: false;
271
+ hasDefault: false;
272
+ isPrimaryKey: false;
273
+ isAutoincrement: false;
274
+ hasRuntimeDefault: false;
275
+ enumValues: [string, ...string[]];
276
+ baseColumn: never;
277
+ identity: undefined;
278
+ generated: undefined;
279
+ }, {}, {}>;
280
+ userAgent: drizzle_orm_pg_core0.PgColumn<{
281
+ name: "user_agent";
282
+ tableName: "session";
283
+ dataType: "string";
284
+ columnType: "PgText";
285
+ data: string;
286
+ driverParam: string;
287
+ notNull: false;
288
+ hasDefault: false;
289
+ isPrimaryKey: false;
290
+ isAutoincrement: false;
291
+ hasRuntimeDefault: false;
292
+ enumValues: [string, ...string[]];
293
+ baseColumn: never;
294
+ identity: undefined;
295
+ generated: undefined;
296
+ }, {}, {}>;
297
+ userId: drizzle_orm_pg_core0.PgColumn<{
298
+ name: "user_id";
299
+ tableName: "session";
300
+ dataType: "string";
301
+ columnType: "PgText";
302
+ data: string;
303
+ driverParam: string;
304
+ notNull: true;
305
+ hasDefault: false;
306
+ isPrimaryKey: false;
307
+ isAutoincrement: false;
308
+ hasRuntimeDefault: false;
309
+ enumValues: [string, ...string[]];
310
+ baseColumn: never;
311
+ identity: undefined;
312
+ generated: undefined;
313
+ }, {}, {}>;
314
+ };
315
+ dialect: "pg";
316
+ }>;
317
+ declare const account: drizzle_orm_pg_core0.PgTableWithColumns<{
318
+ name: "account";
319
+ schema: undefined;
320
+ columns: {
321
+ id: drizzle_orm_pg_core0.PgColumn<{
322
+ name: "id";
323
+ tableName: "account";
324
+ dataType: "string";
325
+ columnType: "PgText";
326
+ data: string;
327
+ driverParam: string;
328
+ notNull: true;
329
+ hasDefault: false;
330
+ isPrimaryKey: true;
331
+ isAutoincrement: false;
332
+ hasRuntimeDefault: false;
333
+ enumValues: [string, ...string[]];
334
+ baseColumn: never;
335
+ identity: undefined;
336
+ generated: undefined;
337
+ }, {}, {}>;
338
+ accountId: drizzle_orm_pg_core0.PgColumn<{
339
+ name: "account_id";
340
+ tableName: "account";
341
+ dataType: "string";
342
+ columnType: "PgText";
343
+ data: string;
344
+ driverParam: string;
345
+ notNull: true;
346
+ hasDefault: false;
347
+ isPrimaryKey: false;
348
+ isAutoincrement: false;
349
+ hasRuntimeDefault: false;
350
+ enumValues: [string, ...string[]];
351
+ baseColumn: never;
352
+ identity: undefined;
353
+ generated: undefined;
354
+ }, {}, {}>;
355
+ providerId: drizzle_orm_pg_core0.PgColumn<{
356
+ name: "provider_id";
357
+ tableName: "account";
358
+ dataType: "string";
359
+ columnType: "PgText";
360
+ data: string;
361
+ driverParam: string;
362
+ notNull: true;
363
+ hasDefault: false;
364
+ isPrimaryKey: false;
365
+ isAutoincrement: false;
366
+ hasRuntimeDefault: false;
367
+ enumValues: [string, ...string[]];
368
+ baseColumn: never;
369
+ identity: undefined;
370
+ generated: undefined;
371
+ }, {}, {}>;
372
+ userId: drizzle_orm_pg_core0.PgColumn<{
373
+ name: "user_id";
374
+ tableName: "account";
375
+ dataType: "string";
376
+ columnType: "PgText";
377
+ data: string;
378
+ driverParam: string;
379
+ notNull: true;
380
+ hasDefault: false;
381
+ isPrimaryKey: false;
382
+ isAutoincrement: false;
383
+ hasRuntimeDefault: false;
384
+ enumValues: [string, ...string[]];
385
+ baseColumn: never;
386
+ identity: undefined;
387
+ generated: undefined;
388
+ }, {}, {}>;
389
+ accessToken: drizzle_orm_pg_core0.PgColumn<{
390
+ name: "access_token";
391
+ tableName: "account";
392
+ dataType: "string";
393
+ columnType: "PgText";
394
+ data: string;
395
+ driverParam: string;
396
+ notNull: false;
397
+ hasDefault: false;
398
+ isPrimaryKey: false;
399
+ isAutoincrement: false;
400
+ hasRuntimeDefault: false;
401
+ enumValues: [string, ...string[]];
402
+ baseColumn: never;
403
+ identity: undefined;
404
+ generated: undefined;
405
+ }, {}, {}>;
406
+ refreshToken: drizzle_orm_pg_core0.PgColumn<{
407
+ name: "refresh_token";
408
+ tableName: "account";
409
+ dataType: "string";
410
+ columnType: "PgText";
411
+ data: string;
412
+ driverParam: string;
413
+ notNull: false;
414
+ hasDefault: false;
415
+ isPrimaryKey: false;
416
+ isAutoincrement: false;
417
+ hasRuntimeDefault: false;
418
+ enumValues: [string, ...string[]];
419
+ baseColumn: never;
420
+ identity: undefined;
421
+ generated: undefined;
422
+ }, {}, {}>;
423
+ idToken: drizzle_orm_pg_core0.PgColumn<{
424
+ name: "id_token";
425
+ tableName: "account";
426
+ dataType: "string";
427
+ columnType: "PgText";
428
+ data: string;
429
+ driverParam: string;
430
+ notNull: false;
431
+ hasDefault: false;
432
+ isPrimaryKey: false;
433
+ isAutoincrement: false;
434
+ hasRuntimeDefault: false;
435
+ enumValues: [string, ...string[]];
436
+ baseColumn: never;
437
+ identity: undefined;
438
+ generated: undefined;
439
+ }, {}, {}>;
440
+ accessTokenExpiresAt: drizzle_orm_pg_core0.PgColumn<{
441
+ name: "access_token_expires_at";
442
+ tableName: "account";
443
+ dataType: "date";
444
+ columnType: "PgTimestamp";
445
+ data: Date;
446
+ driverParam: string;
447
+ notNull: false;
448
+ hasDefault: false;
449
+ isPrimaryKey: false;
450
+ isAutoincrement: false;
451
+ hasRuntimeDefault: false;
452
+ enumValues: undefined;
453
+ baseColumn: never;
454
+ identity: undefined;
455
+ generated: undefined;
456
+ }, {}, {}>;
457
+ refreshTokenExpiresAt: drizzle_orm_pg_core0.PgColumn<{
458
+ name: "refresh_token_expires_at";
459
+ tableName: "account";
460
+ dataType: "date";
461
+ columnType: "PgTimestamp";
462
+ data: Date;
463
+ driverParam: string;
464
+ notNull: false;
465
+ hasDefault: false;
466
+ isPrimaryKey: false;
467
+ isAutoincrement: false;
468
+ hasRuntimeDefault: false;
469
+ enumValues: undefined;
470
+ baseColumn: never;
471
+ identity: undefined;
472
+ generated: undefined;
473
+ }, {}, {}>;
474
+ scope: drizzle_orm_pg_core0.PgColumn<{
475
+ name: "scope";
476
+ tableName: "account";
477
+ dataType: "string";
478
+ columnType: "PgText";
479
+ data: string;
480
+ driverParam: string;
481
+ notNull: false;
482
+ hasDefault: false;
483
+ isPrimaryKey: false;
484
+ isAutoincrement: false;
485
+ hasRuntimeDefault: false;
486
+ enumValues: [string, ...string[]];
487
+ baseColumn: never;
488
+ identity: undefined;
489
+ generated: undefined;
490
+ }, {}, {}>;
491
+ password: drizzle_orm_pg_core0.PgColumn<{
492
+ name: "password";
493
+ tableName: "account";
494
+ dataType: "string";
495
+ columnType: "PgText";
496
+ data: string;
497
+ driverParam: string;
498
+ notNull: false;
499
+ hasDefault: false;
500
+ isPrimaryKey: false;
501
+ isAutoincrement: false;
502
+ hasRuntimeDefault: false;
503
+ enumValues: [string, ...string[]];
504
+ baseColumn: never;
505
+ identity: undefined;
506
+ generated: undefined;
507
+ }, {}, {}>;
508
+ createdAt: drizzle_orm_pg_core0.PgColumn<{
509
+ name: "created_at";
510
+ tableName: "account";
511
+ dataType: "date";
512
+ columnType: "PgTimestamp";
513
+ data: Date;
514
+ driverParam: string;
515
+ notNull: true;
516
+ hasDefault: false;
517
+ isPrimaryKey: false;
518
+ isAutoincrement: false;
519
+ hasRuntimeDefault: false;
520
+ enumValues: undefined;
521
+ baseColumn: never;
522
+ identity: undefined;
523
+ generated: undefined;
524
+ }, {}, {}>;
525
+ updatedAt: drizzle_orm_pg_core0.PgColumn<{
526
+ name: "updated_at";
527
+ tableName: "account";
528
+ dataType: "date";
529
+ columnType: "PgTimestamp";
530
+ data: Date;
531
+ driverParam: string;
532
+ notNull: true;
533
+ hasDefault: false;
534
+ isPrimaryKey: false;
535
+ isAutoincrement: false;
536
+ hasRuntimeDefault: false;
537
+ enumValues: undefined;
538
+ baseColumn: never;
539
+ identity: undefined;
540
+ generated: undefined;
541
+ }, {}, {}>;
542
+ };
543
+ dialect: "pg";
544
+ }>;
545
+ declare const verification: drizzle_orm_pg_core0.PgTableWithColumns<{
546
+ name: "verification";
547
+ schema: undefined;
548
+ columns: {
549
+ id: drizzle_orm_pg_core0.PgColumn<{
550
+ name: "id";
551
+ tableName: "verification";
552
+ dataType: "string";
553
+ columnType: "PgText";
554
+ data: string;
555
+ driverParam: string;
556
+ notNull: true;
557
+ hasDefault: false;
558
+ isPrimaryKey: true;
559
+ isAutoincrement: false;
560
+ hasRuntimeDefault: false;
561
+ enumValues: [string, ...string[]];
562
+ baseColumn: never;
563
+ identity: undefined;
564
+ generated: undefined;
565
+ }, {}, {}>;
566
+ identifier: drizzle_orm_pg_core0.PgColumn<{
567
+ name: "identifier";
568
+ tableName: "verification";
569
+ dataType: "string";
570
+ columnType: "PgText";
571
+ data: string;
572
+ driverParam: string;
573
+ notNull: true;
574
+ hasDefault: false;
575
+ isPrimaryKey: false;
576
+ isAutoincrement: false;
577
+ hasRuntimeDefault: false;
578
+ enumValues: [string, ...string[]];
579
+ baseColumn: never;
580
+ identity: undefined;
581
+ generated: undefined;
582
+ }, {}, {}>;
583
+ value: drizzle_orm_pg_core0.PgColumn<{
584
+ name: "value";
585
+ tableName: "verification";
586
+ dataType: "string";
587
+ columnType: "PgText";
588
+ data: string;
589
+ driverParam: string;
590
+ notNull: true;
591
+ hasDefault: false;
592
+ isPrimaryKey: false;
593
+ isAutoincrement: false;
594
+ hasRuntimeDefault: false;
595
+ enumValues: [string, ...string[]];
596
+ baseColumn: never;
597
+ identity: undefined;
598
+ generated: undefined;
599
+ }, {}, {}>;
600
+ expiresAt: drizzle_orm_pg_core0.PgColumn<{
601
+ name: "expires_at";
602
+ tableName: "verification";
603
+ dataType: "date";
604
+ columnType: "PgTimestamp";
605
+ data: Date;
606
+ driverParam: string;
607
+ notNull: true;
608
+ hasDefault: false;
609
+ isPrimaryKey: false;
610
+ isAutoincrement: false;
611
+ hasRuntimeDefault: false;
612
+ enumValues: undefined;
613
+ baseColumn: never;
614
+ identity: undefined;
615
+ generated: undefined;
616
+ }, {}, {}>;
617
+ createdAt: drizzle_orm_pg_core0.PgColumn<{
618
+ name: "created_at";
619
+ tableName: "verification";
620
+ dataType: "date";
621
+ columnType: "PgTimestamp";
622
+ data: Date;
623
+ driverParam: string;
624
+ notNull: false;
625
+ hasDefault: false;
626
+ isPrimaryKey: false;
627
+ isAutoincrement: false;
628
+ hasRuntimeDefault: false;
629
+ enumValues: undefined;
630
+ baseColumn: never;
631
+ identity: undefined;
632
+ generated: undefined;
633
+ }, {}, {}>;
634
+ updatedAt: drizzle_orm_pg_core0.PgColumn<{
635
+ name: "updated_at";
636
+ tableName: "verification";
637
+ dataType: "date";
638
+ columnType: "PgTimestamp";
639
+ data: Date;
640
+ driverParam: string;
641
+ notNull: false;
642
+ hasDefault: false;
643
+ isPrimaryKey: false;
644
+ isAutoincrement: false;
645
+ hasRuntimeDefault: false;
646
+ enumValues: undefined;
647
+ baseColumn: never;
648
+ identity: undefined;
649
+ generated: undefined;
650
+ }, {}, {}>;
651
+ };
652
+ dialect: "pg";
653
+ }>;
654
+ //#endregion
655
+ export { account, session, user, verification };
656
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.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,50 @@
1
+ import { boolean, pgTable, text, timestamp } from "drizzle-orm/pg-core";
2
+
3
+ //#region src/schema/auth.ts
4
+ const user = pgTable("user", {
5
+ id: text("id").primaryKey(),
6
+ name: text("name").notNull(),
7
+ email: text("email").notNull().unique(),
8
+ emailVerified: boolean("email_verified").notNull(),
9
+ image: text("image"),
10
+ permissions: text("permissions").array().notNull().default(["modules:read"]),
11
+ createdAt: timestamp("created_at").notNull(),
12
+ updatedAt: timestamp("updated_at").notNull()
13
+ });
14
+ const session = pgTable("session", {
15
+ id: text("id").primaryKey(),
16
+ expiresAt: timestamp("expires_at").notNull(),
17
+ token: text("token").notNull().unique(),
18
+ createdAt: timestamp("created_at").notNull(),
19
+ updatedAt: timestamp("updated_at").notNull(),
20
+ ipAddress: text("ip_address"),
21
+ userAgent: text("user_agent"),
22
+ userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" })
23
+ });
24
+ const account = pgTable("account", {
25
+ id: text("id").primaryKey(),
26
+ accountId: text("account_id").notNull(),
27
+ providerId: text("provider_id").notNull(),
28
+ userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
29
+ accessToken: text("access_token"),
30
+ refreshToken: text("refresh_token"),
31
+ idToken: text("id_token"),
32
+ accessTokenExpiresAt: timestamp("access_token_expires_at"),
33
+ refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
34
+ scope: text("scope"),
35
+ password: text("password"),
36
+ createdAt: timestamp("created_at").notNull(),
37
+ updatedAt: timestamp("updated_at").notNull()
38
+ });
39
+ const verification = pgTable("verification", {
40
+ id: text("id").primaryKey(),
41
+ identifier: text("identifier").notNull(),
42
+ value: text("value").notNull(),
43
+ expiresAt: timestamp("expires_at").notNull(),
44
+ createdAt: timestamp("created_at"),
45
+ updatedAt: timestamp("updated_at")
46
+ });
47
+
48
+ //#endregion
49
+ export { account, session, user, verification };
50
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","names":[],"sources":["../../src/schema/auth.ts"],"sourcesContent":["import { pgTable, text, timestamp, boolean } from 'drizzle-orm/pg-core'\n\nexport const user = pgTable('user', {\n\tid: text('id').primaryKey(),\n\tname: text('name').notNull(),\n\temail: text('email').notNull().unique(),\n\temailVerified: boolean('email_verified').notNull(),\n\timage: text('image'),\n\tpermissions: text('permissions').array().notNull().default(['modules:read']),\n\tcreatedAt: timestamp('created_at').notNull(),\n\tupdatedAt: timestamp('updated_at').notNull(),\n})\n\nexport const session = pgTable('session', {\n\tid: text('id').primaryKey(),\n\texpiresAt: timestamp('expires_at').notNull(),\n\ttoken: text('token').notNull().unique(),\n\tcreatedAt: timestamp('created_at').notNull(),\n\tupdatedAt: timestamp('updated_at').notNull(),\n\tipAddress: text('ip_address'),\n\tuserAgent: text('user_agent'),\n\tuserId: text('user_id')\n\t\t.notNull()\n\t\t.references(() => user.id, { onDelete: 'cascade' }),\n})\n\nexport const account = pgTable('account', {\n\tid: text('id').primaryKey(),\n\taccountId: text('account_id').notNull(),\n\tproviderId: text('provider_id').notNull(),\n\tuserId: text('user_id')\n\t\t.notNull()\n\t\t.references(() => user.id, { onDelete: 'cascade' }),\n\taccessToken: text('access_token'),\n\trefreshToken: text('refresh_token'),\n\tidToken: text('id_token'),\n\taccessTokenExpiresAt: timestamp('access_token_expires_at'),\n\trefreshTokenExpiresAt: timestamp('refresh_token_expires_at'),\n\tscope: text('scope'),\n\tpassword: text('password'),\n\tcreatedAt: timestamp('created_at').notNull(),\n\tupdatedAt: timestamp('updated_at').notNull(),\n})\n\nexport const verification = pgTable('verification', {\n\tid: text('id').primaryKey(),\n\tidentifier: text('identifier').notNull(),\n\tvalue: text('value').notNull(),\n\texpiresAt: timestamp('expires_at').notNull(),\n\tcreatedAt: timestamp('created_at'),\n\tupdatedAt: timestamp('updated_at'),\n})\n"],"mappings":";;;AAEA,MAAa,OAAO,QAAQ,QAAQ;CACnC,IAAI,KAAK,KAAK,CAAC,YAAY;CAC3B,MAAM,KAAK,OAAO,CAAC,SAAS;CAC5B,OAAO,KAAK,QAAQ,CAAC,SAAS,CAAC,QAAQ;CACvC,eAAe,QAAQ,iBAAiB,CAAC,SAAS;CAClD,OAAO,KAAK,QAAQ;CACpB,aAAa,KAAK,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC;CAC5E,WAAW,UAAU,aAAa,CAAC,SAAS;CAC5C,WAAW,UAAU,aAAa,CAAC,SAAS;CAC5C,CAAC;AAEF,MAAa,UAAU,QAAQ,WAAW;CACzC,IAAI,KAAK,KAAK,CAAC,YAAY;CAC3B,WAAW,UAAU,aAAa,CAAC,SAAS;CAC5C,OAAO,KAAK,QAAQ,CAAC,SAAS,CAAC,QAAQ;CACvC,WAAW,UAAU,aAAa,CAAC,SAAS;CAC5C,WAAW,UAAU,aAAa,CAAC,SAAS;CAC5C,WAAW,KAAK,aAAa;CAC7B,WAAW,KAAK,aAAa;CAC7B,QAAQ,KAAK,UAAU,CACrB,SAAS,CACT,iBAAiB,KAAK,IAAI,EAAE,UAAU,WAAW,CAAC;CACpD,CAAC;AAEF,MAAa,UAAU,QAAQ,WAAW;CACzC,IAAI,KAAK,KAAK,CAAC,YAAY;CAC3B,WAAW,KAAK,aAAa,CAAC,SAAS;CACvC,YAAY,KAAK,cAAc,CAAC,SAAS;CACzC,QAAQ,KAAK,UAAU,CACrB,SAAS,CACT,iBAAiB,KAAK,IAAI,EAAE,UAAU,WAAW,CAAC;CACpD,aAAa,KAAK,eAAe;CACjC,cAAc,KAAK,gBAAgB;CACnC,SAAS,KAAK,WAAW;CACzB,sBAAsB,UAAU,0BAA0B;CAC1D,uBAAuB,UAAU,2BAA2B;CAC5D,OAAO,KAAK,QAAQ;CACpB,UAAU,KAAK,WAAW;CAC1B,WAAW,UAAU,aAAa,CAAC,SAAS;CAC5C,WAAW,UAAU,aAAa,CAAC,SAAS;CAC5C,CAAC;AAEF,MAAa,eAAe,QAAQ,gBAAgB;CACnD,IAAI,KAAK,KAAK,CAAC,YAAY;CAC3B,YAAY,KAAK,aAAa,CAAC,SAAS;CACxC,OAAO,KAAK,QAAQ,CAAC,SAAS;CAC9B,WAAW,UAAU,aAAa,CAAC,SAAS;CAC5C,WAAW,UAAU,aAAa;CAClC,WAAW,UAAU,aAAa;CAClC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@kuckit/db",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "src/index.ts",
6
+ "types": "src/index.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "exports": {
11
+ ".": {
12
+ "types": "./src/index.ts",
13
+ "default": "./src/index.ts"
14
+ },
15
+ "./*": {
16
+ "types": "./src/*.ts",
17
+ "default": "./src/*.ts"
18
+ }
19
+ },
20
+ "publishConfig": {
21
+ "main": "dist/index.js",
22
+ "types": "dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "default": "./dist/index.js"
27
+ },
28
+ "./*": {
29
+ "types": "./dist/*.d.ts",
30
+ "default": "./dist/*.js"
31
+ }
32
+ }
33
+ },
34
+ "scripts": {
35
+ "build": "tsdown",
36
+ "db:push": "drizzle-kit push",
37
+ "db:studio": "drizzle-kit studio",
38
+ "db:generate": "drizzle-kit generate",
39
+ "db:migrate": "drizzle-kit migrate",
40
+ "db:start": "docker compose up -d",
41
+ "db:watch": "docker compose up",
42
+ "db:stop": "docker compose stop",
43
+ "db:down": "docker compose down"
44
+ },
45
+ "devDependencies": {
46
+ "drizzle-kit": "^0.31.2",
47
+ "@types/pg": "^8.11.11",
48
+ "tsdown": "catalog:"
49
+ },
50
+ "peerDependencies": {
51
+ "typescript": "^5"
52
+ },
53
+ "dependencies": {
54
+ "drizzle-orm": "catalog:",
55
+ "pg": "^8.14.1",
56
+ "dotenv": "catalog:",
57
+ "zod": "catalog:"
58
+ }
59
+ }
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { drizzle } from 'drizzle-orm/node-postgres'
2
+ import { buildDatabaseUrl } from './connection'
3
+
4
+ export const db = drizzle(buildDatabaseUrl())