@trycompai/db 1.0.3 → 1.0.6
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/README.md +60 -0
- package/package.json +17 -22
package/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# @trycompai/db
|
|
2
|
+
|
|
3
|
+
Database package with Prisma client and schema for Comp AI applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @trycompai/db @prisma/client prisma
|
|
9
|
+
# or
|
|
10
|
+
bun add @trycompai/db @prisma/client prisma
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Setup
|
|
14
|
+
|
|
15
|
+
After installing, generate the Prisma client:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
prisma generate --schema=./node_modules/@trycompai/db/dist/prisma/schema.prisma
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or add this to your package.json scripts:
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"scripts": {
|
|
26
|
+
"db:generate": "prisma generate --schema=./node_modules/@trycompai/db/dist/prisma/schema.prisma",
|
|
27
|
+
"postinstall": "npm run db:generate"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { db, PrismaClient, Prisma } from '@trycompai/db';
|
|
36
|
+
|
|
37
|
+
// Use the pre-configured db instance (recommended)
|
|
38
|
+
const users = await db.user.findMany();
|
|
39
|
+
|
|
40
|
+
// Or create your own client
|
|
41
|
+
const client = new PrismaClient();
|
|
42
|
+
|
|
43
|
+
// Full TypeScript support for all Prisma types
|
|
44
|
+
type User = Prisma.UserCreateInput;
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Environment Variables
|
|
48
|
+
|
|
49
|
+
Make sure to set your `DATABASE_URL` environment variable:
|
|
50
|
+
|
|
51
|
+
```env
|
|
52
|
+
DATABASE_URL="postgresql://user:password@localhost:5432/database"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Key Features
|
|
56
|
+
|
|
57
|
+
- ✅ **Server-side only**: Safe for use in server environments (no client-side bundle pollution)
|
|
58
|
+
- ✅ **Full TypeScript support**: Complete type definitions for all database models
|
|
59
|
+
- ✅ **Pre-configured client**: Ready-to-use database connection with optimized settings
|
|
60
|
+
- ✅ **Schema included**: All database schemas and migrations included
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trycompai/db",
|
|
3
3
|
"description": "Database package with Prisma client and schema for Comp AI",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.6",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@prisma/client": "6.9.0",
|
|
7
7
|
"prisma": "6.9.0"
|
|
@@ -22,11 +22,6 @@
|
|
|
22
22
|
"types": "./dist/types.d.ts",
|
|
23
23
|
"import": "./dist/types.mjs",
|
|
24
24
|
"require": "./dist/types.js"
|
|
25
|
-
},
|
|
26
|
-
"./client": {
|
|
27
|
-
"types": "./dist/client.d.ts",
|
|
28
|
-
"import": "./dist/client.mjs",
|
|
29
|
-
"require": "./dist/client.js"
|
|
30
25
|
}
|
|
31
26
|
},
|
|
32
27
|
"files": [
|
|
@@ -69,23 +64,23 @@
|
|
|
69
64
|
"docker:up": "docker-compose up -d",
|
|
70
65
|
"lint": "prettier --check 'src/**/*.{ts,tsx,js,jsx,json}' 'prisma/**/*.prisma' && tsc --noEmit",
|
|
71
66
|
"postbuild": "cp -r prisma dist/ || echo 'No prisma directory to copy'",
|
|
72
|
-
"postinstall": "prisma generate",
|
|
67
|
+
"postinstall": "prisma generate --schema=./dist/prisma/schema.prisma || echo 'Prisma generate failed - please run manually: prisma generate --schema=./node_modules/@trycompai/db/dist/prisma/schema.prisma'",
|
|
73
68
|
"typecheck": "tsc --noEmit"
|
|
74
69
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
70
|
+
"tsup": {
|
|
71
|
+
"entry": [
|
|
72
|
+
"src/index.ts",
|
|
73
|
+
"src/types.ts"
|
|
74
|
+
],
|
|
75
|
+
"format": [
|
|
76
|
+
"cjs",
|
|
77
|
+
"esm"
|
|
78
|
+
],
|
|
79
|
+
"dts": true,
|
|
80
|
+
"clean": true,
|
|
81
|
+
"external": [
|
|
82
|
+
"@prisma/client"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
90
85
|
"types": "./dist/index.d.ts"
|
|
91
86
|
}
|