Files
agent-fox/prisma/schema.prisma
YANG JIANKUAN 95198e6a07 feat: 完善 MCP 接入体验与协议层稳定性
接入体验:
- 客户端选择器覆盖 7 个客户端(Claude Desktop/Code、Cursor、Cline、
  Windsurf、Codex、GitHub Copilot),自动生成对应配置
- API Key 一键含 key 复制(密码验证后写入剪贴板)
- 公开 /mcp/:projectId/info + Test connection 按钮
- 项目新增 Usage 标签(每日柱状图 + 工具调用分布)
- 导入完成后引导跳转到 MCP 配置

协议层稳定性:
- session 超时清理(5 分钟扫描 / 30 分钟 idle 关闭)
- 错误响应标准化为 { error: { code, message } }
- 调用日志捕获错误信息 + 4KB payload 截断
- McpCallLog 增加 errorMessage 字段(migration)

抽出可复用模块:PasswordRevealPrompt 组件、BarChart 组件、
trends helper(daysWindowStart + getDailyTrends)。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 12:52:47 +08:00

122 lines
3.2 KiB
Plaintext

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
enum Role {
USER
ADMIN
}
model User {
id String @id @default(uuid())
email String @unique
passwordHash String?
name String
avatarUrl String?
role Role @default(USER)
disabled Boolean @default(false)
apiKeyHash String?
apiKeyEncrypted String?
apiKeyPrefix String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
oauthAccounts OAuthAccount[]
projects Project[]
}
model OAuthAccount {
id String @id @default(uuid())
userId String
provider String
providerAccountId String
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
}
model McpCallLog {
id String @id @default(uuid())
projectId String
toolName String
calledAt DateTime @default(now())
durationMs Int
success Boolean
requestParams Json @default("{}")
responseSize Int @default(0)
clientIp String @default("")
estimatedTokens Int?
errorMessage String?
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
@@index([projectId])
@@index([calledAt])
@@index([toolName])
}
model Project {
id String @id @default(uuid())
userId String
name String
description String?
baseUrl String?
openApiSpec Json
openApiVersion String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
modules Module[]
endpoints Endpoint[]
mcpCallLogs McpCallLog[]
}
enum ModuleSource {
tag
path_prefix
manual
}
model Module {
id String @id @default(uuid())
projectId String
name String
description String?
sortOrder Int @default(0)
source ModuleSource
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
endpoints Endpoint[]
@@index([projectId])
}
model Endpoint {
id String @id @default(uuid())
projectId String
moduleId String
method String
path String
summary String?
description String?
operationId String?
parameters Json @default("[]")
requestBody Json?
responses Json @default("{}")
tags String[] @default([])
deprecated Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
module Module @relation(fields: [moduleId], references: [id], onDelete: Cascade)
@@index([projectId])
@@index([moduleId])
@@index([projectId, moduleId])
}