ultra-dex 3.1.0 → 3.2.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.
- package/README.md +79 -74
- package/assets/code-patterns/clerk-middleware.ts +138 -0
- package/assets/code-patterns/prisma-schema.prisma +224 -0
- package/assets/code-patterns/rls-policies.sql +246 -0
- package/assets/code-patterns/server-actions.ts +191 -0
- package/assets/code-patterns/trpc-router.ts +258 -0
- package/assets/cursor-rules/13-ai-integration.mdc +155 -0
- package/assets/cursor-rules/14-server-components.mdc +81 -0
- package/assets/cursor-rules/15-server-actions.mdc +102 -0
- package/assets/cursor-rules/16-edge-middleware.mdc +105 -0
- package/assets/cursor-rules/17-streaming-ssr.mdc +138 -0
- package/bin/ultra-dex.js +38 -1
- package/lib/commands/agents.js +16 -13
- package/lib/commands/banner.js +43 -21
- package/lib/commands/build.js +26 -17
- package/lib/commands/doctor.js +98 -79
- package/lib/commands/generate.js +19 -16
- package/lib/commands/init.js +52 -56
- package/lib/commands/scaffold.js +151 -0
- package/lib/commands/serve.js +15 -13
- package/lib/commands/state.js +43 -70
- package/lib/commands/swarm.js +31 -9
- package/lib/config/theme.js +47 -0
- package/lib/templates/code/clerk-middleware.ts +138 -0
- package/lib/templates/code/prisma-schema.prisma +224 -0
- package/lib/templates/code/rls-policies.sql +246 -0
- package/lib/templates/code/server-actions.ts +191 -0
- package/lib/templates/code/trpc-router.ts +258 -0
- package/lib/themes/doomsday.js +229 -0
- package/lib/ui/index.js +5 -0
- package/lib/ui/interface.js +241 -0
- package/lib/ui/spinners.js +116 -0
- package/lib/ui/theme.js +183 -0
- package/lib/utils/agents.js +32 -0
- package/lib/utils/help.js +64 -0
- package/lib/utils/messages.js +35 -0
- package/lib/utils/progress.js +24 -0
- package/lib/utils/prompts.js +47 -0
- package/lib/utils/spinners.js +46 -0
- package/lib/utils/status.js +31 -0
- package/lib/utils/tables.js +41 -0
- package/lib/utils/theme-state.js +9 -0
- package/lib/utils/version-display.js +32 -0
- package/package.json +10 -1
package/README.md
CHANGED
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
> Scaffold Ultra-Dex projects from the command line, now with **AI-powered plan generation** and **God Mode** autonomous agents.
|
|
4
4
|
|
|
5
|
-
## What's New in
|
|
5
|
+
## What's New in v3.2.0 (Professional Purple)
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
# 🤖 Autonomous
|
|
9
|
-
npx ultra-dex
|
|
8
|
+
# 🤖 Autonomous agent swarms with parallel execution
|
|
9
|
+
npx ultra-dex swarm "Build user authentication" --parallel
|
|
10
10
|
|
|
11
|
-
# 🔄
|
|
12
|
-
npx ultra-dex
|
|
13
|
-
|
|
14
|
-
# 🛡️ Self-Healing CI/CD Monitor
|
|
15
|
-
npx ultra-dex ci-monitor --port 3003
|
|
11
|
+
# 🔄 Start the Active Kernel (MCP + WebSocket + Dashboard)
|
|
12
|
+
npx ultra-dex serve
|
|
16
13
|
|
|
17
14
|
# 🧠 Structural Graph Health Check
|
|
18
15
|
npx ultra-dex check
|
|
19
16
|
|
|
20
17
|
# 🖥️ Live Dashboard with Brain Visualization
|
|
21
18
|
npx ultra-dex dashboard
|
|
19
|
+
|
|
20
|
+
# 🛠️ Self-Healing CI/CD Monitor
|
|
21
|
+
npx ultra-dex ci-monitor --port 3003
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
## First 10 Minutes
|
|
@@ -43,53 +43,61 @@ npm install -g ultra-dex
|
|
|
43
43
|
ultra-dex generate "Your idea"
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
##
|
|
46
|
+
## Scaffold Command (NEW)
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Fully autonomous feature implementation loop:
|
|
48
|
+
Generate production-ready boilerplate instantly:
|
|
51
49
|
|
|
52
50
|
```bash
|
|
53
|
-
#
|
|
54
|
-
npx ultra-dex
|
|
51
|
+
# List available templates
|
|
52
|
+
npx ultra-dex scaffold --list
|
|
53
|
+
|
|
54
|
+
# Generate Next.js 15 + Prisma + Clerk project
|
|
55
|
+
npx ultra-dex scaffold next15-prisma-clerk
|
|
56
|
+
|
|
57
|
+
# Generate Remix + Supabase project
|
|
58
|
+
npx ultra-dex scaffold remix-supabase
|
|
55
59
|
|
|
56
|
-
#
|
|
57
|
-
npx ultra-dex
|
|
60
|
+
# Generate SvelteKit + Drizzle project
|
|
61
|
+
npx ultra-dex scaffold sveltekit-drizzle
|
|
58
62
|
```
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
1. **Structural Analysis:** Scans the Code Property Graph (CPG) for impact.
|
|
62
|
-
2. **Planning:** @Planner breaks down the task.
|
|
63
|
-
3. **Execution:** @Backend/@Frontend implement the code.
|
|
64
|
-
4. **Verification:** @Testing verifies the changes.
|
|
64
|
+
## AI Commands (God Mode)
|
|
65
65
|
|
|
66
|
-
### `
|
|
66
|
+
### `swarm` - Autonomous Agent Pipeline
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
Run complex task pipelines with multiple agents:
|
|
69
69
|
|
|
70
70
|
```bash
|
|
71
|
-
#
|
|
72
|
-
npx ultra-dex
|
|
71
|
+
# Build a feature with a swarm of agents
|
|
72
|
+
npx ultra-dex swarm "Implement Stripe subscriptions" --parallel
|
|
73
73
|
|
|
74
|
-
#
|
|
75
|
-
npx ultra-dex
|
|
74
|
+
# Dry run to see the plan
|
|
75
|
+
npx ultra-dex swarm "Migrate to Tailwind" --dry-run
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
### `
|
|
78
|
+
### `serve` - Active Kernel
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
Start the MCP-compatible server for IDE integration and dashboard:
|
|
81
81
|
|
|
82
82
|
```bash
|
|
83
|
-
npx ultra-dex
|
|
83
|
+
npx ultra-dex serve
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### `auto-implement` - Autonomous Engineer
|
|
87
|
+
|
|
88
|
+
Fully autonomous feature implementation loop:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Implement a feature from scratch
|
|
92
|
+
npx ultra-dex auto-implement "Create a user profile page with Avatar upload"
|
|
84
93
|
```
|
|
85
|
-
*Configure your CI provider (GitHub Actions) to send webhooks to this port.*
|
|
86
94
|
|
|
87
95
|
### `watch` - Real-time Daemon
|
|
88
96
|
|
|
89
|
-
Keep the Code Property Graph updated as you code:
|
|
97
|
+
Keep the project state and Code Property Graph updated as you code:
|
|
90
98
|
|
|
91
99
|
```bash
|
|
92
|
-
npx ultra-dex watch
|
|
100
|
+
npx ultra-dex watch --interval 1000
|
|
93
101
|
```
|
|
94
102
|
|
|
95
103
|
## Core Commands
|
|
@@ -115,7 +123,7 @@ Start development with AI agents (Interactive Mode):
|
|
|
115
123
|
npx ultra-dex build
|
|
116
124
|
|
|
117
125
|
# Specific agent
|
|
118
|
-
npx ultra-dex
|
|
126
|
+
npx ultra-dex run backend --task "Create user API endpoints"
|
|
119
127
|
```
|
|
120
128
|
|
|
121
129
|
### `review` - Graph-Aware Code Review
|
|
@@ -148,54 +156,51 @@ npx ultra-dex check
|
|
|
148
156
|
ANTHROPIC_API_KEY=sk-ant-... # Claude (recommended for complex tasks)
|
|
149
157
|
OPENAI_API_KEY=sk-... # OpenAI
|
|
150
158
|
GOOGLE_AI_KEY=... # Gemini
|
|
151
|
-
ULTRA_DEX_DEFAULT_PROVIDER=
|
|
159
|
+
ULTRA_DEX_DEFAULT_PROVIDER=claude # Default AI provider
|
|
152
160
|
```
|
|
153
161
|
|
|
154
|
-
## All Commands
|
|
162
|
+
## All Commands (38+)
|
|
155
163
|
|
|
156
164
|
| Command | Description |
|
|
157
165
|
|---------|-------------|
|
|
166
|
+
| `init` | Initialize a new project |
|
|
167
|
+
| `scaffold` | **NEW** Generate production boilerplate |
|
|
158
168
|
| `generate` | Generate full SaaS plan from idea |
|
|
159
|
-
| `
|
|
169
|
+
| `swarm` | Run autonomous agent pipeline |
|
|
170
|
+
| `auto-implement` | Autonomously implement a feature |
|
|
171
|
+
| `serve` | Start the Active Kernel (MCP + Dashboard) |
|
|
172
|
+
| `watch` | Auto-update state on file changes |
|
|
160
173
|
| `build` | Interactive AI agent development loop |
|
|
161
|
-
| `review` | Review code against plan
|
|
174
|
+
| `review` | Review code against plan |
|
|
162
175
|
| `align` | Quick alignment score |
|
|
163
|
-
| `sync` | **(NEW)** Sync project state across devices |
|
|
164
|
-
| `check` | **(NEW)** Verify repository health |
|
|
165
|
-
| `watch` | **(NEW)** Real-time graph synchronization daemon |
|
|
166
|
-
| `ci-monitor` | **(NEW)** Self-healing CI/CD webhook listener |
|
|
167
|
-
| `dashboard` | Start the JARVIS web dashboard |
|
|
168
|
-
| `init` | Initialize a new project |
|
|
169
176
|
| `audit` | Audit project for completeness |
|
|
170
|
-
| `
|
|
171
|
-
| `
|
|
172
|
-
| `
|
|
173
|
-
| `
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
✓ Created .ultra/state.json (GOD MODE ACTIVE)
|
|
198
|
-
```
|
|
177
|
+
| `validate` | Validate project against 21-step framework |
|
|
178
|
+
| `check` | Verify repository health |
|
|
179
|
+
| `doctor` | Diagnose project issues |
|
|
180
|
+
| `dashboard` | Start the local web dashboard |
|
|
181
|
+
| `sync` | Sync project state across devices |
|
|
182
|
+
| `fetch` | Download assets for offline use |
|
|
183
|
+
| `hooks` | Manage Git hooks |
|
|
184
|
+
| `export` | Export project context |
|
|
185
|
+
| `upgrade` | Check for CLI updates |
|
|
186
|
+
| `config` | Manage CLI and editor configuration |
|
|
187
|
+
| `agents` | List available AI agents |
|
|
188
|
+
| `agent` | Show specific agent prompt |
|
|
189
|
+
| `workflow` | Show specific production workflow |
|
|
190
|
+
| `suggest` | Get AI-powered task suggestions |
|
|
191
|
+
| `plan` | Generate or update implementation plan |
|
|
192
|
+
| `fix` | Automatically fix project issues |
|
|
193
|
+
| `team` | Team collaboration commands |
|
|
194
|
+
| `memory` | Manage long-term agent memory |
|
|
195
|
+
| `verify` | Run executable verification |
|
|
196
|
+
| `ci-monitor` | Self-healing CI/CD listener |
|
|
197
|
+
| `status` | Show project and kernel status |
|
|
198
|
+
| `pre-commit` | Run pre-commit checks |
|
|
199
|
+
| `state` | Manage machine-readable state |
|
|
200
|
+
| `examples` | Access reference workflows |
|
|
201
|
+
| `pack` | Bundle agents and rules |
|
|
202
|
+
| `run` | Execute agent task |
|
|
203
|
+
| `diff` | Compare plan vs implemented code |
|
|
199
204
|
|
|
200
205
|
## Links
|
|
201
206
|
|
|
@@ -206,4 +211,4 @@ $ npx ultra-dex generate "A booking platform for dog groomers"
|
|
|
206
211
|
|
|
207
212
|
## License
|
|
208
213
|
|
|
209
|
-
MIT
|
|
214
|
+
MIT
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// Ultra-Dex Production Pattern: Clerk Middleware
|
|
2
|
+
// Copy to middleware.ts in your Next.js root
|
|
3
|
+
|
|
4
|
+
import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server';
|
|
5
|
+
import { NextResponse } from 'next/server';
|
|
6
|
+
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// ROUTE MATCHERS
|
|
9
|
+
// =============================================================================
|
|
10
|
+
|
|
11
|
+
// Public routes - accessible without authentication
|
|
12
|
+
const isPublicRoute = createRouteMatcher([
|
|
13
|
+
'/',
|
|
14
|
+
'/sign-in(.*)',
|
|
15
|
+
'/sign-up(.*)',
|
|
16
|
+
'/api/webhooks(.*)',
|
|
17
|
+
'/pricing',
|
|
18
|
+
'/about',
|
|
19
|
+
'/blog(.*)',
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
// Admin routes - require admin role
|
|
23
|
+
const isAdminRoute = createRouteMatcher([
|
|
24
|
+
'/admin(.*)',
|
|
25
|
+
'/api/admin(.*)',
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
// API routes that need special handling
|
|
29
|
+
const isApiRoute = createRouteMatcher(['/api(.*)']);
|
|
30
|
+
|
|
31
|
+
// =============================================================================
|
|
32
|
+
// MIDDLEWARE
|
|
33
|
+
// =============================================================================
|
|
34
|
+
|
|
35
|
+
export default clerkMiddleware(async (auth, req) => {
|
|
36
|
+
const { userId, sessionClaims } = await auth();
|
|
37
|
+
|
|
38
|
+
// Allow public routes
|
|
39
|
+
if (isPublicRoute(req)) {
|
|
40
|
+
return NextResponse.next();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Protect all non-public routes
|
|
44
|
+
if (!userId) {
|
|
45
|
+
const signInUrl = new URL('/sign-in', req.url);
|
|
46
|
+
signInUrl.searchParams.set('redirect_url', req.url);
|
|
47
|
+
return NextResponse.redirect(signInUrl);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Check admin routes
|
|
51
|
+
if (isAdminRoute(req)) {
|
|
52
|
+
const role = sessionClaims?.metadata?.role as string | undefined;
|
|
53
|
+
|
|
54
|
+
if (role !== 'admin' && role !== 'super_admin') {
|
|
55
|
+
return NextResponse.redirect(new URL('/unauthorized', req.url));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Add user info to headers for API routes
|
|
60
|
+
if (isApiRoute(req)) {
|
|
61
|
+
const requestHeaders = new Headers(req.headers);
|
|
62
|
+
requestHeaders.set('x-user-id', userId);
|
|
63
|
+
|
|
64
|
+
return NextResponse.next({
|
|
65
|
+
request: {
|
|
66
|
+
headers: requestHeaders,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return NextResponse.next();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export const config = {
|
|
75
|
+
matcher: [
|
|
76
|
+
// Skip Next.js internals and static files
|
|
77
|
+
'/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',
|
|
78
|
+
// Always run for API routes
|
|
79
|
+
'/(api|trpc)(.*)',
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// =============================================================================
|
|
84
|
+
// USAGE EXAMPLES
|
|
85
|
+
// =============================================================================
|
|
86
|
+
|
|
87
|
+
/*
|
|
88
|
+
// In a Server Component - get current user:
|
|
89
|
+
|
|
90
|
+
import { auth, currentUser } from '@clerk/nextjs/server';
|
|
91
|
+
|
|
92
|
+
export default async function DashboardPage() {
|
|
93
|
+
const { userId } = await auth();
|
|
94
|
+
const user = await currentUser();
|
|
95
|
+
|
|
96
|
+
if (!userId) {
|
|
97
|
+
redirect('/sign-in');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return <div>Welcome, {user?.firstName}!</div>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// In a Client Component - use hooks:
|
|
104
|
+
|
|
105
|
+
'use client';
|
|
106
|
+
|
|
107
|
+
import { useUser, useAuth } from '@clerk/nextjs';
|
|
108
|
+
|
|
109
|
+
export function UserProfile() {
|
|
110
|
+
const { user, isLoaded } = useUser();
|
|
111
|
+
const { signOut } = useAuth();
|
|
112
|
+
|
|
113
|
+
if (!isLoaded) return <div>Loading...</div>;
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<div>
|
|
117
|
+
<p>Hello, {user?.firstName}</p>
|
|
118
|
+
<button onClick={() => signOut()}>Sign Out</button>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// In an API Route:
|
|
124
|
+
|
|
125
|
+
import { auth } from '@clerk/nextjs/server';
|
|
126
|
+
import { NextResponse } from 'next/server';
|
|
127
|
+
|
|
128
|
+
export async function GET() {
|
|
129
|
+
const { userId } = await auth();
|
|
130
|
+
|
|
131
|
+
if (!userId) {
|
|
132
|
+
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Your logic here
|
|
136
|
+
return NextResponse.json({ userId });
|
|
137
|
+
}
|
|
138
|
+
*/
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
// Ultra-Dex Production Pattern: Full Prisma Schema
|
|
2
|
+
// Copy to prisma/schema.prisma
|
|
3
|
+
|
|
4
|
+
generator client {
|
|
5
|
+
provider = "prisma-client-js"
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
datasource db {
|
|
9
|
+
provider = "postgresql"
|
|
10
|
+
url = env("DATABASE_URL")
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// =============================================================================
|
|
14
|
+
// CORE MODELS
|
|
15
|
+
// =============================================================================
|
|
16
|
+
|
|
17
|
+
model User {
|
|
18
|
+
id String @id @default(cuid())
|
|
19
|
+
clerkId String @unique
|
|
20
|
+
email String @unique
|
|
21
|
+
name String?
|
|
22
|
+
imageUrl String?
|
|
23
|
+
role UserRole @default(USER)
|
|
24
|
+
createdAt DateTime @default(now())
|
|
25
|
+
updatedAt DateTime @updatedAt
|
|
26
|
+
|
|
27
|
+
// Relations
|
|
28
|
+
organizationMemberships OrganizationMember[]
|
|
29
|
+
createdOrganizations Organization[] @relation("OrganizationCreator")
|
|
30
|
+
projects Project[]
|
|
31
|
+
comments Comment[]
|
|
32
|
+
activityLogs ActivityLog[]
|
|
33
|
+
|
|
34
|
+
@@index([clerkId])
|
|
35
|
+
@@index([email])
|
|
36
|
+
@@map("users")
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
enum UserRole {
|
|
40
|
+
USER
|
|
41
|
+
ADMIN
|
|
42
|
+
SUPER_ADMIN
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// =============================================================================
|
|
46
|
+
// MULTI-TENANCY MODELS
|
|
47
|
+
// =============================================================================
|
|
48
|
+
|
|
49
|
+
model Organization {
|
|
50
|
+
id String @id @default(cuid())
|
|
51
|
+
name String
|
|
52
|
+
slug String @unique
|
|
53
|
+
logo String?
|
|
54
|
+
plan Plan @default(FREE)
|
|
55
|
+
createdAt DateTime @default(now())
|
|
56
|
+
updatedAt DateTime @updatedAt
|
|
57
|
+
|
|
58
|
+
// Relations
|
|
59
|
+
creatorId String
|
|
60
|
+
creator User @relation("OrganizationCreator", fields: [creatorId], references: [id])
|
|
61
|
+
members OrganizationMember[]
|
|
62
|
+
projects Project[]
|
|
63
|
+
invoices Invoice[]
|
|
64
|
+
|
|
65
|
+
@@index([slug])
|
|
66
|
+
@@map("organizations")
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
model OrganizationMember {
|
|
70
|
+
id String @id @default(cuid())
|
|
71
|
+
role MemberRole @default(MEMBER)
|
|
72
|
+
joinedAt DateTime @default(now())
|
|
73
|
+
organizationId String
|
|
74
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
75
|
+
userId String
|
|
76
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
77
|
+
|
|
78
|
+
@@unique([organizationId, userId])
|
|
79
|
+
@@map("organization_members")
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
enum MemberRole {
|
|
83
|
+
OWNER
|
|
84
|
+
ADMIN
|
|
85
|
+
MEMBER
|
|
86
|
+
VIEWER
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
enum Plan {
|
|
90
|
+
FREE
|
|
91
|
+
PRO
|
|
92
|
+
ENTERPRISE
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// =============================================================================
|
|
96
|
+
// PROJECT MODELS
|
|
97
|
+
// =============================================================================
|
|
98
|
+
|
|
99
|
+
model Project {
|
|
100
|
+
id String @id @default(cuid())
|
|
101
|
+
name String
|
|
102
|
+
description String?
|
|
103
|
+
status ProjectStatus @default(ACTIVE)
|
|
104
|
+
createdAt DateTime @default(now())
|
|
105
|
+
updatedAt DateTime @updatedAt
|
|
106
|
+
|
|
107
|
+
// Relations
|
|
108
|
+
organizationId String
|
|
109
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
110
|
+
ownerId String
|
|
111
|
+
owner User @relation(fields: [ownerId], references: [id])
|
|
112
|
+
tasks Task[]
|
|
113
|
+
comments Comment[]
|
|
114
|
+
|
|
115
|
+
@@index([organizationId])
|
|
116
|
+
@@map("projects")
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
enum ProjectStatus {
|
|
120
|
+
ACTIVE
|
|
121
|
+
ARCHIVED
|
|
122
|
+
COMPLETED
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
model Task {
|
|
126
|
+
id String @id @default(cuid())
|
|
127
|
+
title String
|
|
128
|
+
description String?
|
|
129
|
+
status TaskStatus @default(TODO)
|
|
130
|
+
priority Priority @default(MEDIUM)
|
|
131
|
+
dueDate DateTime?
|
|
132
|
+
createdAt DateTime @default(now())
|
|
133
|
+
updatedAt DateTime @updatedAt
|
|
134
|
+
|
|
135
|
+
// Relations
|
|
136
|
+
projectId String
|
|
137
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
138
|
+
comments Comment[]
|
|
139
|
+
|
|
140
|
+
@@index([projectId])
|
|
141
|
+
@@index([status])
|
|
142
|
+
@@map("tasks")
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
enum TaskStatus {
|
|
146
|
+
TODO
|
|
147
|
+
IN_PROGRESS
|
|
148
|
+
IN_REVIEW
|
|
149
|
+
DONE
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
enum Priority {
|
|
153
|
+
LOW
|
|
154
|
+
MEDIUM
|
|
155
|
+
HIGH
|
|
156
|
+
URGENT
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
model Comment {
|
|
160
|
+
id String @id @default(cuid())
|
|
161
|
+
content String
|
|
162
|
+
createdAt DateTime @default(now())
|
|
163
|
+
updatedAt DateTime @updatedAt
|
|
164
|
+
|
|
165
|
+
// Relations
|
|
166
|
+
authorId String
|
|
167
|
+
author User @relation(fields: [authorId], references: [id])
|
|
168
|
+
projectId String?
|
|
169
|
+
project Project? @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
170
|
+
taskId String?
|
|
171
|
+
task Task? @relation(fields: [taskId], references: [id], onDelete: Cascade)
|
|
172
|
+
|
|
173
|
+
@@map("comments")
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// =============================================================================
|
|
177
|
+
// BILLING MODELS
|
|
178
|
+
// =============================================================================
|
|
179
|
+
|
|
180
|
+
model Invoice {
|
|
181
|
+
id String @id @default(cuid())
|
|
182
|
+
stripeId String @unique
|
|
183
|
+
amount Int
|
|
184
|
+
currency String @default("usd")
|
|
185
|
+
status InvoiceStatus @default(PENDING)
|
|
186
|
+
paidAt DateTime?
|
|
187
|
+
createdAt DateTime @default(now())
|
|
188
|
+
|
|
189
|
+
// Relations
|
|
190
|
+
organizationId String
|
|
191
|
+
organization Organization @relation(fields: [organizationId], references: [id])
|
|
192
|
+
|
|
193
|
+
@@index([organizationId])
|
|
194
|
+
@@map("invoices")
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
enum InvoiceStatus {
|
|
198
|
+
PENDING
|
|
199
|
+
PAID
|
|
200
|
+
FAILED
|
|
201
|
+
REFUNDED
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// =============================================================================
|
|
205
|
+
// AUDIT LOG
|
|
206
|
+
// =============================================================================
|
|
207
|
+
|
|
208
|
+
model ActivityLog {
|
|
209
|
+
id String @id @default(cuid())
|
|
210
|
+
action String
|
|
211
|
+
entity String
|
|
212
|
+
entityId String
|
|
213
|
+
metadata Json?
|
|
214
|
+
createdAt DateTime @default(now())
|
|
215
|
+
|
|
216
|
+
// Relations
|
|
217
|
+
userId String
|
|
218
|
+
user User @relation(fields: [userId], references: [id])
|
|
219
|
+
|
|
220
|
+
@@index([userId])
|
|
221
|
+
@@index([entity, entityId])
|
|
222
|
+
@@index([createdAt])
|
|
223
|
+
@@map("activity_logs")
|
|
224
|
+
}
|