@allbluecn/database 0.11.0 → 0.12.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/index.ts +14 -17
- package/package.json +29 -21
- package/pglite-init.ts +75 -0
- package/LICENSE +0 -661
- package/desktop-init.ts +0 -162
- package/generated-sqlite/browser.ts +0 -499
- package/generated-sqlite/client.ts +0 -523
- package/generated-sqlite/commonInputTypes.ts +0 -722
- package/generated-sqlite/enums.ts +0 -15
- package/generated-sqlite/internal/class.ts +0 -1154
- package/generated-sqlite/internal/prismaNamespace.ts +0 -9576
- package/generated-sqlite/internal/prismaNamespaceBrowser.ts +0 -1761
- package/generated-sqlite/models/AgentConversation.ts +0 -1647
- package/generated-sqlite/models/AgentMessage.ts +0 -1406
- package/generated-sqlite/models/AiProvider.ts +0 -1605
- package/generated-sqlite/models/AiProviderConfig.ts +0 -1610
- package/generated-sqlite/models/AiStreamChunk.ts +0 -1157
- package/generated-sqlite/models/AiUsageLog.ts +0 -1905
- package/generated-sqlite/models/AnyHubApp.ts +0 -1908
- package/generated-sqlite/models/AnyHubMarketApp.ts +0 -1997
- package/generated-sqlite/models/AnyHubPermission.ts +0 -1419
- package/generated-sqlite/models/AnyHubRecommendation.ts +0 -1867
- package/generated-sqlite/models/AnyHubRecommender.ts +0 -1467
- package/generated-sqlite/models/ArticleFavorite.ts +0 -1349
- package/generated-sqlite/models/AuditLog.ts +0 -1287
- package/generated-sqlite/models/Blob.ts +0 -1425
- package/generated-sqlite/models/Block.ts +0 -1648
- package/generated-sqlite/models/BlockComponent.ts +0 -1730
- package/generated-sqlite/models/BlockInstance.ts +0 -2039
- package/generated-sqlite/models/BookmarkCategory.ts +0 -1667
- package/generated-sqlite/models/BusinessAgentBinding.ts +0 -1549
- package/generated-sqlite/models/ChatInterrupt.ts +0 -1736
- package/generated-sqlite/models/ChatMessage.ts +0 -1464
- package/generated-sqlite/models/ChatPersistenceMeta.ts +0 -1119
- package/generated-sqlite/models/ChatRun.ts +0 -1802
- package/generated-sqlite/models/ChatThread.ts +0 -2417
- package/generated-sqlite/models/CodeSnippet.ts +0 -1552
- package/generated-sqlite/models/Comment.ts +0 -2201
- package/generated-sqlite/models/CommentIgnore.ts +0 -1426
- package/generated-sqlite/models/ComplianceExport.ts +0 -1343
- package/generated-sqlite/models/Component.ts +0 -2132
- package/generated-sqlite/models/ComponentInstance.ts +0 -2097
- package/generated-sqlite/models/CustomRole.ts +0 -1209
- package/generated-sqlite/models/Design.ts +0 -2497
- package/generated-sqlite/models/DesignPage.ts +0 -2398
- package/generated-sqlite/models/DesignVersion.ts +0 -2117
- package/generated-sqlite/models/DesktopSetting.ts +0 -1057
- package/generated-sqlite/models/DeveloperLog.ts +0 -1281
- package/generated-sqlite/models/DictionaryTerm.ts +0 -1639
- package/generated-sqlite/models/EmailLog.ts +0 -1343
- package/generated-sqlite/models/EmailPreference.ts +0 -1255
- package/generated-sqlite/models/EmailSubscriber.ts +0 -1231
- package/generated-sqlite/models/EmailVerificationToken.ts +0 -1377
- package/generated-sqlite/models/GenerationRun.ts +0 -1732
- package/generated-sqlite/models/HarnessPlugin.ts +0 -1666
- package/generated-sqlite/models/HarnessWorkspace.ts +0 -1647
- package/generated-sqlite/models/IndustryCompliance.ts +0 -1794
- package/generated-sqlite/models/InvitationCode.ts +0 -1471
- package/generated-sqlite/models/InvitationUse.ts +0 -1420
- package/generated-sqlite/models/Invoice.ts +0 -1707
- package/generated-sqlite/models/Iteration.ts +0 -1874
- package/generated-sqlite/models/IterationAutoSchedule.ts +0 -1483
- package/generated-sqlite/models/KnowledgeBase.ts +0 -2238
- package/generated-sqlite/models/KnowledgeDocument.ts +0 -2450
- package/generated-sqlite/models/KnowledgeShareRecord.ts +0 -1349
- package/generated-sqlite/models/LegalRegulation.ts +0 -1905
- package/generated-sqlite/models/LicenseActivation.ts +0 -1203
- package/generated-sqlite/models/LicenseKey.ts +0 -1443
- package/generated-sqlite/models/LoginLog.ts +0 -1447
- package/generated-sqlite/models/NotificationPreference.ts +0 -1313
- package/generated-sqlite/models/OAuthProviderConfig.ts +0 -1225
- package/generated-sqlite/models/PageVersion.ts +0 -1520
- package/generated-sqlite/models/PasswordResetToken.ts +0 -1377
- package/generated-sqlite/models/Plan.ts +0 -2250
- package/generated-sqlite/models/Project.ts +0 -2628
- package/generated-sqlite/models/ProjectActivity.ts +0 -1578
- package/generated-sqlite/models/ProjectKnowledgeBase.ts +0 -1426
- package/generated-sqlite/models/ProjectMember.ts +0 -1508
- package/generated-sqlite/models/ProviderEvent.ts +0 -1225
- package/generated-sqlite/models/Reference.ts +0 -1175
- package/generated-sqlite/models/Review.ts +0 -1903
- package/generated-sqlite/models/ReviewComment.ts +0 -1899
- package/generated-sqlite/models/RoleAssignment.ts +0 -1125
- package/generated-sqlite/models/SandboxInstance.ts +0 -1283
- package/generated-sqlite/models/Share.ts +0 -1674
- package/generated-sqlite/models/ShareVersion.ts +0 -1385
- package/generated-sqlite/models/SsoMapping.ts +0 -1181
- package/generated-sqlite/models/SsoProvider.ts +0 -1266
- package/generated-sqlite/models/Story.ts +0 -3263
- package/generated-sqlite/models/Subscription.ts +0 -2137
- package/generated-sqlite/models/SystemPromptTemplate.ts +0 -1581
- package/generated-sqlite/models/SystemPromptVersion.ts +0 -1456
- package/generated-sqlite/models/SystemSetting.ts +0 -1215
- package/generated-sqlite/models/TeamInvitation.ts +0 -1758
- package/generated-sqlite/models/TeamJoinRequest.ts +0 -1793
- package/generated-sqlite/models/TeamMembership.ts +0 -1433
- package/generated-sqlite/models/Template.ts +0 -1389
- package/generated-sqlite/models/TemplateBlock.ts +0 -1660
- package/generated-sqlite/models/ThirdPartyDependency.ts +0 -1471
- package/generated-sqlite/models/UsageRecord.ts +0 -1498
- package/generated-sqlite/models/User.ts +0 -21247
- package/generated-sqlite/models/UserAgent.ts +0 -2146
- package/generated-sqlite/models/UserSkill.ts +0 -1453
- package/generated-sqlite/models/WebsiteBookmark.ts +0 -2215
- package/generated-sqlite/models/Workspace.ts +0 -2341
- package/generated-sqlite/models/WorkspaceFile.ts +0 -1532
- package/generated-sqlite/models/WorkspaceKnowledgeBase.ts +0 -1426
- package/generated-sqlite/models/WorkspaceQuickDoc.ts +0 -2025
- package/generated-sqlite/models.ts +0 -107
- package/schema.sqlite.prisma +0 -2045
package/schema.sqlite.prisma
DELETED
|
@@ -1,2045 +0,0 @@
|
|
|
1
|
-
// SPIKE 0.2 结论:策略 2(双 schema/generated)✅ 验证通过
|
|
2
|
-
// 适配工作量:enum 6 定义+6 字段→String / @db.Text 21 处删除 / Json 37 处(25 保留 + 12 default 改 dbgenerated)/ String[] 1 处→Json / Unsupported 0 / @@schema 0
|
|
3
|
-
// ⚠️ 关键发现:Prisma 7.8 SQLite 下 Json @default("{}") 会生成非法 DEFAULT {}(裸 token),
|
|
4
|
-
// 必须改用 @default(dbgenerated("'{}'")) 传 SQL 字面量,否则 db push 报 "unrecognized token: {"
|
|
5
|
-
// generate:DATABASE_URL="file:./x.db" pnpm prisma generate --schema=./schema.sqlite.prisma → ./generated-sqlite/
|
|
6
|
-
// db push:DATABASE_URL="file:./x.db" pnpm prisma db push --schema=./schema.sqlite.prisma(已验证 54 表全部建成功)
|
|
7
|
-
// 此文件作为 Phase A.5(Prisma client 多 provider)的基础保留
|
|
8
|
-
generator client {
|
|
9
|
-
provider = "prisma-client"
|
|
10
|
-
output = "./generated-sqlite"
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
datasource db {
|
|
14
|
-
provider = "sqlite"
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// 系统配置表
|
|
18
|
-
model SystemSetting {
|
|
19
|
-
id String @id @default(cuid())
|
|
20
|
-
key String @unique
|
|
21
|
-
value String
|
|
22
|
-
category String @default("general") // 配置分类
|
|
23
|
-
desc String? // 说明
|
|
24
|
-
createdAt DateTime @default(now())
|
|
25
|
-
updatedAt DateTime @updatedAt
|
|
26
|
-
|
|
27
|
-
@@index([category])
|
|
28
|
-
@@map("system_settings")
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// 用户表
|
|
32
|
-
model User {
|
|
33
|
-
id String @id @default(cuid())
|
|
34
|
-
email String @unique
|
|
35
|
-
username String @unique
|
|
36
|
-
password String
|
|
37
|
-
emailVerified DateTime?
|
|
38
|
-
image String?
|
|
39
|
-
role String @default("USER")
|
|
40
|
-
status String @default("ACTIVE")
|
|
41
|
-
/// 密码凭据版本号:重置/管理重置密码时 +1,auth callback 比对 JWT 内记账值不匹配即拒绝旧会话
|
|
42
|
-
tokenVersion Int @default(0)
|
|
43
|
-
createdAt DateTime @default(now())
|
|
44
|
-
updatedAt DateTime @updatedAt
|
|
45
|
-
lastLoginAt DateTime?
|
|
46
|
-
|
|
47
|
-
avatarConfig Json? @default(dbgenerated("'{}'"))
|
|
48
|
-
bgShape String?
|
|
49
|
-
bgColor String?
|
|
50
|
-
|
|
51
|
-
aiProvider String? // "openrouter" | "openai"
|
|
52
|
-
aiApiKey String? // 用户 AI API Key(TODO: 加密存储)
|
|
53
|
-
aiModel String? // 默认 "openai/gpt-4o-mini"
|
|
54
|
-
aiSourceMode String? // 模型来源模式:hosted | local-agent | byok;null = 未选择(默认 byok 行为)
|
|
55
|
-
locale String? // 用户语言偏好(zh / en),null 表示未设置
|
|
56
|
-
|
|
57
|
-
storyDisplayOptions Json? // Story Display Options 个人偏好(URL 无参数时的默认值,跨设备持久化)
|
|
58
|
-
|
|
59
|
-
timezone String? // 用户全局时区,如 "Asia/Shanghai"。null = 浏览器时区
|
|
60
|
-
|
|
61
|
-
/// 用户偏好的计费币种(子项目 3 新增)
|
|
62
|
-
preferredCurrency String @default("usd")
|
|
63
|
-
|
|
64
|
-
/// 用户默认 workspace ID(B3 精确化)
|
|
65
|
-
defaultWorkspaceId String?
|
|
66
|
-
|
|
67
|
-
invitationUses InvitationUse[]
|
|
68
|
-
loginLogs LoginLog[]
|
|
69
|
-
passwordResetTokens PasswordResetToken[]
|
|
70
|
-
emailVerificationTokens EmailVerificationToken[]
|
|
71
|
-
emailPreference EmailPreference?
|
|
72
|
-
notificationPreference NotificationPreference?
|
|
73
|
-
designs Design[]
|
|
74
|
-
knowledgeBases KnowledgeBase[]
|
|
75
|
-
knowledgeDocuments KnowledgeDocument[]
|
|
76
|
-
knowledgeShares KnowledgeShareRecord[]
|
|
77
|
-
legalRegulations LegalRegulation[]
|
|
78
|
-
industryCompliances IndustryCompliance[]
|
|
79
|
-
dictionaryTerms DictionaryTerm[]
|
|
80
|
-
websiteBookmarks WebsiteBookmark[]
|
|
81
|
-
bookmarkCategories BookmarkCategory[]
|
|
82
|
-
articleFavorites ArticleFavorite[]
|
|
83
|
-
anyhubApps AnyHubApp[]
|
|
84
|
-
anyhubMarketApps AnyHubMarketApp[]
|
|
85
|
-
reviewedAnyhubRecommendations AnyHubRecommendation[] @relation("reviewedAnyhubRecommendations")
|
|
86
|
-
anyhubRecommenders AnyHubRecommender[]
|
|
87
|
-
designVersions DesignVersion[]
|
|
88
|
-
reviewComments ReviewComment[]
|
|
89
|
-
comments Comment[]
|
|
90
|
-
commentIgnores CommentIgnore[]
|
|
91
|
-
reviews Review[] @relation("reviewer")
|
|
92
|
-
chatThreads ChatThread[]
|
|
93
|
-
aiProviderConfigs AiProviderConfig[]
|
|
94
|
-
agentConversations AgentConversation[]
|
|
95
|
-
ownedProjects Project[] @relation("projectOwner")
|
|
96
|
-
projectMemberships ProjectMember[]
|
|
97
|
-
iterationsCreated Iteration[] @relation("iterationCreator")
|
|
98
|
-
storiesCreated Story[] @relation("storyCreator")
|
|
99
|
-
storiesAssigned Story[] @relation("storyAssignee")
|
|
100
|
-
storiesEdited Story[] @relation("storyEditor")
|
|
101
|
-
projectActivities ProjectActivity[]
|
|
102
|
-
ownedWorkspaces Workspace[] @relation("workspaceOwner")
|
|
103
|
-
workspaceMemberships TeamMembership[] @relation("teamOwner")
|
|
104
|
-
teamJoined TeamMembership? @relation("teamMember")
|
|
105
|
-
sentInvitations TeamInvitation[] @relation("invitationOwner")
|
|
106
|
-
ownedJoinRequests TeamJoinRequest[] @relation("joinRequestOwner")
|
|
107
|
-
applicantJoinRequests TeamJoinRequest[] @relation("joinRequestApplicant")
|
|
108
|
-
aiUsageLogs AiUsageLog[]
|
|
109
|
-
agents UserAgent[]
|
|
110
|
-
skills UserSkill[]
|
|
111
|
-
subscription Subscription?
|
|
112
|
-
createdQuickDocs WorkspaceQuickDoc[]
|
|
113
|
-
plugins HarnessPlugin[]
|
|
114
|
-
harnessWorkspaces HarnessWorkspace[]
|
|
115
|
-
agentBindings BusinessAgentBinding[]
|
|
116
|
-
codeSnippets CodeSnippet[]
|
|
117
|
-
blobs Blob[]
|
|
118
|
-
|
|
119
|
-
@@map("users")
|
|
120
|
-
@@index([role])
|
|
121
|
-
@@index([status])
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// 项目
|
|
125
|
-
model Project {
|
|
126
|
-
id String @id @default(cuid())
|
|
127
|
-
displayId String? // 用户层项目ID,全大写字母数字,1-10位
|
|
128
|
-
name String
|
|
129
|
-
description String?
|
|
130
|
-
icon String @default("folder")
|
|
131
|
-
timezone String? // 项目时区,null = 跟随用户全局时区
|
|
132
|
-
ownerId String
|
|
133
|
-
owner User @relation("projectOwner", fields: [ownerId], references: [id], onDelete: Restrict)
|
|
134
|
-
workspaceId String?
|
|
135
|
-
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: SetNull)
|
|
136
|
-
members ProjectMember[]
|
|
137
|
-
activities ProjectActivity[]
|
|
138
|
-
knowledgeBases ProjectKnowledgeBase[]
|
|
139
|
-
iterations Iteration[]
|
|
140
|
-
iterationAutoSchedule IterationAutoSchedule?
|
|
141
|
-
stories Story[]
|
|
142
|
-
createdAt DateTime @default(now())
|
|
143
|
-
updatedAt DateTime @updatedAt
|
|
144
|
-
|
|
145
|
-
@@unique([ownerId, displayId])
|
|
146
|
-
@@index([ownerId])
|
|
147
|
-
@@index([workspaceId])
|
|
148
|
-
@@map("projects")
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// 项目成员
|
|
152
|
-
model ProjectMember {
|
|
153
|
-
id String @id @default(cuid())
|
|
154
|
-
projectId String
|
|
155
|
-
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
156
|
-
userId String
|
|
157
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
158
|
-
role String @default("member") // owner | admin | member | viewer
|
|
159
|
-
status String @default("active") // active | invited | suspended
|
|
160
|
-
joinedAt DateTime @default(now())
|
|
161
|
-
|
|
162
|
-
@@unique([projectId, userId])
|
|
163
|
-
@@index([projectId])
|
|
164
|
-
@@map("project_members")
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// 工作空间(项目的上一级容器)
|
|
168
|
-
model Workspace {
|
|
169
|
-
id String @id @default(cuid())
|
|
170
|
-
name String
|
|
171
|
-
icon String @default("folder")
|
|
172
|
-
description String?
|
|
173
|
-
pinnedToSidebar Boolean @default(false)
|
|
174
|
-
ownerId String
|
|
175
|
-
owner User @relation("workspaceOwner", fields: [ownerId], references: [id], onDelete: Restrict)
|
|
176
|
-
projects Project[]
|
|
177
|
-
workspaceKbLinks WorkspaceKnowledgeBase[]
|
|
178
|
-
knowledgeBases KnowledgeBase[]
|
|
179
|
-
quickDocs WorkspaceQuickDoc[]
|
|
180
|
-
usageRecords UsageRecord[]
|
|
181
|
-
aiUsageLogs AiUsageLog[]
|
|
182
|
-
createdAt DateTime @default(now())
|
|
183
|
-
updatedAt DateTime @updatedAt
|
|
184
|
-
|
|
185
|
-
@@index([ownerId])
|
|
186
|
-
@@map("workspaces")
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// 团队隶属关系
|
|
190
|
-
model TeamMembership {
|
|
191
|
-
id String @id @default(cuid())
|
|
192
|
-
ownerId String
|
|
193
|
-
owner User @relation("teamOwner", fields: [ownerId], references: [id], onDelete: Cascade)
|
|
194
|
-
memberId String
|
|
195
|
-
member User @relation("teamMember", fields: [memberId], references: [id], onDelete: Cascade)
|
|
196
|
-
seatType String @default("member")
|
|
197
|
-
joinedAt DateTime @default(now())
|
|
198
|
-
|
|
199
|
-
@@unique([memberId])
|
|
200
|
-
@@index([ownerId])
|
|
201
|
-
@@map("team_memberships")
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// 团队邀请
|
|
205
|
-
model TeamInvitation {
|
|
206
|
-
id String @id @default(cuid())
|
|
207
|
-
ownerId String
|
|
208
|
-
owner User @relation("invitationOwner", fields: [ownerId], references: [id], onDelete: Cascade)
|
|
209
|
-
email String?
|
|
210
|
-
seatType String @default("member")
|
|
211
|
-
token String @unique
|
|
212
|
-
channel String @default("email")
|
|
213
|
-
status String @default("pending")
|
|
214
|
-
expiresAt DateTime
|
|
215
|
-
createdAt DateTime @default(now())
|
|
216
|
-
acceptedBy String?
|
|
217
|
-
applicantEmail String?
|
|
218
|
-
message String?
|
|
219
|
-
joinRequests TeamJoinRequest[]
|
|
220
|
-
|
|
221
|
-
@@unique([ownerId, email])
|
|
222
|
-
@@index([ownerId])
|
|
223
|
-
@@index([email])
|
|
224
|
-
@@map("team_invitations")
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
model TeamJoinRequest {
|
|
228
|
-
id String @id @default(cuid())
|
|
229
|
-
invitationId String
|
|
230
|
-
invitation TeamInvitation @relation(fields: [invitationId], references: [id], onDelete: Cascade)
|
|
231
|
-
ownerId String
|
|
232
|
-
owner User @relation("joinRequestOwner", fields: [ownerId], references: [id], onDelete: Cascade)
|
|
233
|
-
userId String?
|
|
234
|
-
applicant User? @relation("joinRequestApplicant", fields: [userId], references: [id], onDelete: SetNull)
|
|
235
|
-
email String
|
|
236
|
-
status String @default("pending")
|
|
237
|
-
seatType String @default("member")
|
|
238
|
-
createdAt DateTime @default(now())
|
|
239
|
-
processedAt DateTime?
|
|
240
|
-
|
|
241
|
-
@@unique([invitationId, email])
|
|
242
|
-
@@index([ownerId, status])
|
|
243
|
-
@@map("team_join_requests")
|
|
244
|
-
@@index([userId])
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// 项目活动记录
|
|
248
|
-
model ProjectActivity {
|
|
249
|
-
id String @id @default(cuid())
|
|
250
|
-
projectId String
|
|
251
|
-
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
252
|
-
userId String
|
|
253
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
254
|
-
action String // created | updated | deleted | member_invited | member_joined | member_removed | role_changed | module_viewed
|
|
255
|
-
targetType String? // project | member | requirement | prd | design | testcase | bug | acceptance
|
|
256
|
-
targetId String?
|
|
257
|
-
metadata Json?
|
|
258
|
-
createdAt DateTime @default(now())
|
|
259
|
-
|
|
260
|
-
@@index([projectId, createdAt])
|
|
261
|
-
@@map("project_activities")
|
|
262
|
-
@@index([userId])
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
model ChatThread {
|
|
266
|
-
id String @id @default(cuid())
|
|
267
|
-
userId String
|
|
268
|
-
title String?
|
|
269
|
-
isArchived Boolean @default(false)
|
|
270
|
-
sandboxPolicy String @default("readonly")
|
|
271
|
-
createdAt DateTime @default(now())
|
|
272
|
-
updatedAt DateTime @updatedAt
|
|
273
|
-
|
|
274
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
275
|
-
messages ChatMessage[]
|
|
276
|
-
runs ChatRun[]
|
|
277
|
-
interrupts ChatInterrupt[]
|
|
278
|
-
generations GenerationRun[]
|
|
279
|
-
agentId String?
|
|
280
|
-
agent UserAgent? @relation(fields: [agentId], references: [id], onDelete: SetNull)
|
|
281
|
-
workspaceId String?
|
|
282
|
-
workspace HarnessWorkspace? @relation(fields: [workspaceId], references: [id], onDelete: SetNull)
|
|
283
|
-
|
|
284
|
-
@@index([userId, updatedAt])
|
|
285
|
-
@@map("chat_threads")
|
|
286
|
-
@@index([agentId])
|
|
287
|
-
@@index([workspaceId])
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
model ChatMessage {
|
|
291
|
-
id String @id @default(cuid())
|
|
292
|
-
threadId String
|
|
293
|
-
role String
|
|
294
|
-
content Json?
|
|
295
|
-
parts Json?
|
|
296
|
-
thinking String?
|
|
297
|
-
citations Json?
|
|
298
|
-
toolCallId String?
|
|
299
|
-
createdAt DateTime @default(now())
|
|
300
|
-
|
|
301
|
-
thread ChatThread @relation(fields: [threadId], references: [id], onDelete: Cascade)
|
|
302
|
-
|
|
303
|
-
@@index([threadId, createdAt])
|
|
304
|
-
@@map("chat_messages")
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
model ChatRun {
|
|
308
|
-
id String @id @default(cuid())
|
|
309
|
-
threadId String
|
|
310
|
-
userId String
|
|
311
|
-
status String
|
|
312
|
-
startedAt DateTime @default(now())
|
|
313
|
-
finishedAt DateTime?
|
|
314
|
-
detachedSince DateTime?
|
|
315
|
-
usage Json?
|
|
316
|
-
error String?
|
|
317
|
-
sandboxKey String?
|
|
318
|
-
cancelRequested Boolean?
|
|
319
|
-
driverEpoch Int?
|
|
320
|
-
|
|
321
|
-
thread ChatThread @relation(fields: [threadId], references: [id], onDelete: Cascade)
|
|
322
|
-
interrupts ChatInterrupt[]
|
|
323
|
-
|
|
324
|
-
@@index([threadId, startedAt])
|
|
325
|
-
@@index([userId, status])
|
|
326
|
-
@@map("chat_runs")
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
model ChatInterrupt {
|
|
330
|
-
id String @id @default(cuid())
|
|
331
|
-
runId String
|
|
332
|
-
threadId String
|
|
333
|
-
userId String
|
|
334
|
-
kind String
|
|
335
|
-
toolName String?
|
|
336
|
-
state String
|
|
337
|
-
payload Json?
|
|
338
|
-
resolution Json?
|
|
339
|
-
requestedAt DateTime @default(now())
|
|
340
|
-
createdAt DateTime @default(now())
|
|
341
|
-
resolvedAt DateTime?
|
|
342
|
-
|
|
343
|
-
run ChatRun @relation(fields: [runId], references: [id], onDelete: Cascade)
|
|
344
|
-
thread ChatThread @relation(fields: [threadId], references: [id], onDelete: Cascade)
|
|
345
|
-
|
|
346
|
-
@@index([runId])
|
|
347
|
-
@@index([threadId, state])
|
|
348
|
-
@@map("chat_interrupts")
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
model ChatPersistenceMeta {
|
|
352
|
-
namespace String
|
|
353
|
-
key String
|
|
354
|
-
value Json @default(dbgenerated("'{}'"))
|
|
355
|
-
updatedAt DateTime @updatedAt
|
|
356
|
-
|
|
357
|
-
@@unique([namespace, key])
|
|
358
|
-
@@map("chat_persistence_meta")
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// dsh(DeepSeek-Harness)兼容插件(设计 v8 ADR 21:插件定义 DB 持久化,运行态随页面)
|
|
362
|
-
model HarnessPlugin {
|
|
363
|
-
id String @id @default(cuid())
|
|
364
|
-
userId String
|
|
365
|
-
name String
|
|
366
|
-
purpose String
|
|
367
|
-
codeHost String?
|
|
368
|
-
codeClient String?
|
|
369
|
-
// plugin_define 求值后插件经 harness.defineTool 上报的工具定义(JSON Schema 数组)
|
|
370
|
-
tools Json @default(dbgenerated("'[]'"))
|
|
371
|
-
version Int @default(1)
|
|
372
|
-
// defined | running | stopped | error
|
|
373
|
-
status String @default("defined")
|
|
374
|
-
lastError String?
|
|
375
|
-
createdAt DateTime @default(now())
|
|
376
|
-
updatedAt DateTime @updatedAt
|
|
377
|
-
isDeleted Boolean @default(false)
|
|
378
|
-
|
|
379
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
380
|
-
|
|
381
|
-
@@unique([userId, name])
|
|
382
|
-
@@index([userId])
|
|
383
|
-
@@map("harness_plugins")
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
// P2 提示词平台:系统提示词模板(DB 版本化,服务端唯一来源)
|
|
387
|
-
model SystemPromptTemplate {
|
|
388
|
-
id String @id @default(cuid())
|
|
389
|
-
key String @unique
|
|
390
|
-
name String
|
|
391
|
-
description String?
|
|
392
|
-
sections Json @default(dbgenerated("'[]'"))
|
|
393
|
-
variables Json @default(dbgenerated("'[]'"))
|
|
394
|
-
version Int @default(1)
|
|
395
|
-
isActive Boolean @default(true)
|
|
396
|
-
isProtected Boolean @default(false)
|
|
397
|
-
updatedBy String?
|
|
398
|
-
createdAt DateTime @default(now())
|
|
399
|
-
updatedAt DateTime @updatedAt
|
|
400
|
-
versions SystemPromptVersion[]
|
|
401
|
-
|
|
402
|
-
@@map("system_prompt_templates")
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// P2 提示词平台:系统提示词模板的历史版本快照。
|
|
406
|
-
// 设计取舍:仅快照 sections(真正发给 LLM 的提示词主体);variables 作为
|
|
407
|
-
// 元数据随模板演进不纳入版本管理——回滚只还原提示词文本,变量声明由模板表当前值兜底。
|
|
408
|
-
model SystemPromptVersion {
|
|
409
|
-
id String @id @default(cuid())
|
|
410
|
-
templateId String
|
|
411
|
-
template SystemPromptTemplate @relation(fields: [templateId], references: [id], onDelete: Cascade)
|
|
412
|
-
version Int
|
|
413
|
-
sections Json @default(dbgenerated("'[]'"))
|
|
414
|
-
note String?
|
|
415
|
-
createdBy String?
|
|
416
|
-
createdAt DateTime @default(now())
|
|
417
|
-
|
|
418
|
-
@@unique([templateId, version])
|
|
419
|
-
@@map("system_prompt_versions")
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// P2 异构多智能体:板块 agent 绑定(三级链第①级:板块绑定 > 用户默认 > 系统默认)。
|
|
423
|
-
// 设计取舍:① 硬删(无独立业务生命周期,upsert/deleteMany 管理)而非 isDeleted 软删;
|
|
424
|
-
// ② workspaceId 为跨工作区绑定的预留字段,当前不建 relation——bizKey 已表达业务作用域,
|
|
425
|
-
// 工作区级绑定待 P3 启用时再补 relation + 索引。
|
|
426
|
-
model BusinessAgentBinding {
|
|
427
|
-
id String @id @default(cuid())
|
|
428
|
-
userId String
|
|
429
|
-
bizKey String
|
|
430
|
-
agentId String
|
|
431
|
-
workspaceId String?
|
|
432
|
-
createdAt DateTime @default(now())
|
|
433
|
-
updatedAt DateTime @updatedAt
|
|
434
|
-
|
|
435
|
-
agent UserAgent @relation(fields: [agentId], references: [id], onDelete: Cascade)
|
|
436
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
437
|
-
|
|
438
|
-
@@unique([userId, bizKey])
|
|
439
|
-
@@index([userId])
|
|
440
|
-
@@map("business_agent_bindings")
|
|
441
|
-
@@index([agentId])
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
model GenerationRun {
|
|
445
|
-
id String @id @default(cuid())
|
|
446
|
-
threadId String
|
|
447
|
-
userId String
|
|
448
|
-
kind String
|
|
449
|
-
status String
|
|
450
|
-
input Json?
|
|
451
|
-
result Json?
|
|
452
|
-
artifactId String?
|
|
453
|
-
activity String?
|
|
454
|
-
provider String?
|
|
455
|
-
model String?
|
|
456
|
-
artifacts Json?
|
|
457
|
-
usage Json?
|
|
458
|
-
error String?
|
|
459
|
-
startedAt DateTime @default(now())
|
|
460
|
-
finishedAt DateTime?
|
|
461
|
-
linkedTarget Json?
|
|
462
|
-
|
|
463
|
-
thread ChatThread @relation(fields: [threadId], references: [id], onDelete: Cascade)
|
|
464
|
-
|
|
465
|
-
@@index([threadId, startedAt])
|
|
466
|
-
@@index([userId, status])
|
|
467
|
-
@@map("generation_runs")
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
// 登录日志
|
|
471
|
-
model LoginLog {
|
|
472
|
-
id String @id @default(cuid())
|
|
473
|
-
userId String
|
|
474
|
-
ip String?
|
|
475
|
-
userAgent String?
|
|
476
|
-
location String? // 地理位置,如 "北京, 中国";开发环境为 "本地"
|
|
477
|
-
success Boolean @default(true)
|
|
478
|
-
message String? // 失败原因(中文),成功时为 null
|
|
479
|
-
createdAt DateTime @default(now())
|
|
480
|
-
|
|
481
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
482
|
-
|
|
483
|
-
@@map("login_logs")
|
|
484
|
-
@@index([userId])
|
|
485
|
-
@@index([createdAt])
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
// 邀请码
|
|
489
|
-
model InvitationCode {
|
|
490
|
-
id String @id @default(cuid())
|
|
491
|
-
code String @unique
|
|
492
|
-
maxUses Int @default(1)
|
|
493
|
-
usedCount Int @default(0)
|
|
494
|
-
expiresAt DateTime
|
|
495
|
-
createdAt DateTime @default(now())
|
|
496
|
-
// DB-13 决策:保留不删、暂不加 FK。原判「悬空列」不实——admin invitations
|
|
497
|
-
// 写入 createdById(session.user.id)并按 id 联表展示创建者,删除前置条件
|
|
498
|
-
// 「0 引用」不成立;存量数据未清洗,直接加 FK 有约束创建失败风险。
|
|
499
|
-
// 后续任务:回填清洗(孤儿置 null)→ 加 relation + SetNull + 索引。
|
|
500
|
-
createdById String?
|
|
501
|
-
disabledAt DateTime?
|
|
502
|
-
|
|
503
|
-
uses InvitationUse[]
|
|
504
|
-
|
|
505
|
-
@@map("invitation_codes")
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
// 邀请码使用记录
|
|
509
|
-
model InvitationUse {
|
|
510
|
-
id String @id @default(cuid())
|
|
511
|
-
codeId String
|
|
512
|
-
userId String
|
|
513
|
-
usedAt DateTime @default(now())
|
|
514
|
-
|
|
515
|
-
code InvitationCode @relation(fields: [codeId], references: [id], onDelete: Cascade)
|
|
516
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
517
|
-
|
|
518
|
-
@@map("invitation_uses")
|
|
519
|
-
@@index([codeId])
|
|
520
|
-
@@index([userId])
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
// 密码重置令牌
|
|
524
|
-
model PasswordResetToken {
|
|
525
|
-
id String @id @default(cuid())
|
|
526
|
-
token String @unique
|
|
527
|
-
userId String
|
|
528
|
-
expiresAt DateTime
|
|
529
|
-
usedAt DateTime?
|
|
530
|
-
createdAt DateTime @default(now())
|
|
531
|
-
|
|
532
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
533
|
-
|
|
534
|
-
@@map("password_reset_tokens")
|
|
535
|
-
@@index([userId])
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
// 邮箱验证令牌
|
|
539
|
-
model EmailVerificationToken {
|
|
540
|
-
id String @id @default(cuid())
|
|
541
|
-
token String @unique
|
|
542
|
-
userId String
|
|
543
|
-
expiresAt DateTime
|
|
544
|
-
usedAt DateTime?
|
|
545
|
-
createdAt DateTime @default(now())
|
|
546
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
547
|
-
|
|
548
|
-
@@map("email_verification_tokens")
|
|
549
|
-
@@index([userId])
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
// 出站邮件日志
|
|
553
|
-
model EmailLog {
|
|
554
|
-
id String @id @default(cuid())
|
|
555
|
-
to String
|
|
556
|
-
templateKey String
|
|
557
|
-
category String
|
|
558
|
-
status String
|
|
559
|
-
provider String
|
|
560
|
-
messageId String?
|
|
561
|
-
dedupeKey String? @unique
|
|
562
|
-
error String?
|
|
563
|
-
userId String?
|
|
564
|
-
createdAt DateTime @default(now())
|
|
565
|
-
sentAt DateTime?
|
|
566
|
-
|
|
567
|
-
@@index([to, createdAt])
|
|
568
|
-
@@index([userId, createdAt])
|
|
569
|
-
@@index([status])
|
|
570
|
-
@@map("email_logs")
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
// 用户邮件偏好
|
|
574
|
-
model EmailPreference {
|
|
575
|
-
userId String @id
|
|
576
|
-
unsubscribedAll Boolean @default(false)
|
|
577
|
-
unsubscribedCategories Json @default(dbgenerated("'[]'"))
|
|
578
|
-
suppressed Boolean @default(false)
|
|
579
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
580
|
-
|
|
581
|
-
@@map("email_preferences")
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
// 第三方登录配置(admin 后台维护)
|
|
585
|
-
model OAuthProviderConfig {
|
|
586
|
-
id String @id @default(cuid())
|
|
587
|
-
provider String @unique
|
|
588
|
-
clientId String
|
|
589
|
-
clientSecret String // AES-256-GCM 密文
|
|
590
|
-
enabled Boolean @default(false)
|
|
591
|
-
extra Json?
|
|
592
|
-
createdAt DateTime @default(now())
|
|
593
|
-
updatedAt DateTime @updatedAt
|
|
594
|
-
|
|
595
|
-
@@map("oauth_provider_configs")
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
// 产品更新订阅者(changelog)
|
|
599
|
-
model EmailSubscriber {
|
|
600
|
-
id String @id @default(cuid())
|
|
601
|
-
email String @unique
|
|
602
|
-
locale String @default("zh")
|
|
603
|
-
confirmToken String @unique
|
|
604
|
-
confirmedAt DateTime?
|
|
605
|
-
unsubscribedAt DateTime?
|
|
606
|
-
source String @default("changelog")
|
|
607
|
-
createdAt DateTime @default(now())
|
|
608
|
-
|
|
609
|
-
@@index([confirmedAt, unsubscribedAt])
|
|
610
|
-
@@map("email_subscribers")
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
// (enum 已移除:SQLite 无原生 enum,Role/UserStatus/IconType/MarketplaceAppStatus/ReviewStatus/ShareStatus 改为 String 存 TEXT)
|
|
614
|
-
|
|
615
|
-
// 知识库
|
|
616
|
-
model KnowledgeBase {
|
|
617
|
-
id String @id @default(cuid())
|
|
618
|
-
name String
|
|
619
|
-
description String?
|
|
620
|
-
icon String @default("notebook")
|
|
621
|
-
tags Json @default(dbgenerated("'[]'"))
|
|
622
|
-
visibility String @default("private")
|
|
623
|
-
userId String
|
|
624
|
-
workspaceId String?
|
|
625
|
-
pinnedToSidebar Boolean @default(false)
|
|
626
|
-
isDeleted Boolean @default(false)
|
|
627
|
-
createdAt DateTime @default(now())
|
|
628
|
-
updatedAt DateTime @updatedAt
|
|
629
|
-
|
|
630
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
631
|
-
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: SetNull)
|
|
632
|
-
documents KnowledgeDocument[]
|
|
633
|
-
projectLinks ProjectKnowledgeBase[]
|
|
634
|
-
workspaceLinks WorkspaceKnowledgeBase[]
|
|
635
|
-
|
|
636
|
-
@@index([userId])
|
|
637
|
-
@@index([workspaceId])
|
|
638
|
-
@@map("knowledge_bases")
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
// 项目关联知识库(join 表;关联时仅允许 visibility=team,general 全局可见无需关联,private 跨用户不可读)
|
|
642
|
-
model ProjectKnowledgeBase {
|
|
643
|
-
id String @id @default(cuid())
|
|
644
|
-
projectId String
|
|
645
|
-
kbId String
|
|
646
|
-
createdAt DateTime @default(now())
|
|
647
|
-
|
|
648
|
-
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
649
|
-
kb KnowledgeBase @relation(fields: [kbId], references: [id], onDelete: Cascade)
|
|
650
|
-
|
|
651
|
-
@@unique([projectId, kbId])
|
|
652
|
-
@@index([projectId])
|
|
653
|
-
@@index([kbId])
|
|
654
|
-
@@map("project_knowledge_bases")
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
// 工作空间关联知识库(join 表;仅允许 visibility=team)
|
|
658
|
-
model WorkspaceKnowledgeBase {
|
|
659
|
-
id String @id @default(cuid())
|
|
660
|
-
workspaceId String
|
|
661
|
-
kbId String
|
|
662
|
-
createdAt DateTime @default(now())
|
|
663
|
-
|
|
664
|
-
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
|
665
|
-
kb KnowledgeBase @relation(fields: [kbId], references: [id], onDelete: Cascade)
|
|
666
|
-
|
|
667
|
-
@@unique([workspaceId, kbId])
|
|
668
|
-
@@index([workspaceId])
|
|
669
|
-
@@index([kbId])
|
|
670
|
-
@@map("workspace_knowledge_bases")
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
// 工作空间快捷文档(单表双轨:docId 或 externalGroup+externalId 二选一非空,serverFn 层校验)
|
|
674
|
-
model WorkspaceQuickDoc {
|
|
675
|
-
id String @id @default(cuid())
|
|
676
|
-
workspaceId String
|
|
677
|
-
docId String?
|
|
678
|
-
externalGroup String?
|
|
679
|
-
externalId String?
|
|
680
|
-
displayTitle String
|
|
681
|
-
columnIndex Int @default(0)
|
|
682
|
-
sortOrder Int @default(0)
|
|
683
|
-
label String?
|
|
684
|
-
icon String?
|
|
685
|
-
createdBy String
|
|
686
|
-
createdAt DateTime @default(now())
|
|
687
|
-
updatedAt DateTime @updatedAt
|
|
688
|
-
|
|
689
|
-
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
|
690
|
-
doc KnowledgeDocument? @relation(fields: [docId], references: [id], onDelete: Cascade)
|
|
691
|
-
creator User @relation(fields: [createdBy], references: [id], onDelete: Cascade)
|
|
692
|
-
|
|
693
|
-
@@index([workspaceId])
|
|
694
|
-
@@index([workspaceId, docId])
|
|
695
|
-
@@map("workspace_quick_docs")
|
|
696
|
-
@@index([createdBy])
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
model KnowledgeDocument {
|
|
700
|
-
id String @id @default(cuid())
|
|
701
|
-
kbId String
|
|
702
|
-
parentId String?
|
|
703
|
-
title String
|
|
704
|
-
type String @default("doc")
|
|
705
|
-
content Json @default(dbgenerated("'{}'"))
|
|
706
|
-
icon String?
|
|
707
|
-
isHomepage Boolean @default(false)
|
|
708
|
-
sortOrder Int @default(0)
|
|
709
|
-
isDeleted Boolean @default(false)
|
|
710
|
-
createdBy String
|
|
711
|
-
tags Json @default(dbgenerated("'[]'"))
|
|
712
|
-
properties Json @default(dbgenerated("'{}'"))
|
|
713
|
-
createdAt DateTime @default(now())
|
|
714
|
-
updatedAt DateTime @updatedAt
|
|
715
|
-
|
|
716
|
-
kb KnowledgeBase @relation(fields: [kbId], references: [id], onDelete: Cascade)
|
|
717
|
-
parent KnowledgeDocument? @relation("DocumentTree", fields: [parentId], references: [id], onDelete: SetNull)
|
|
718
|
-
children KnowledgeDocument[] @relation("DocumentTree")
|
|
719
|
-
creator User @relation(fields: [createdBy], references: [id], onDelete: Cascade)
|
|
720
|
-
workspaceQuickDocs WorkspaceQuickDoc[]
|
|
721
|
-
|
|
722
|
-
@@index([kbId])
|
|
723
|
-
@@index([parentId])
|
|
724
|
-
@@index([kbId, isHomepage])
|
|
725
|
-
@@map("knowledge_documents")
|
|
726
|
-
@@index([createdBy])
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
// Design 文档表
|
|
730
|
-
model Design {
|
|
731
|
-
id String @id @default(cuid())
|
|
732
|
-
icon String @default("file") // 图标名称
|
|
733
|
-
name String // Design 名称
|
|
734
|
-
description String? // 介绍
|
|
735
|
-
kind String @default("doc") // 板块合并:doc=文档型,canvas=画板型
|
|
736
|
-
settings Json? @default(dbgenerated("'{}'")) // 文档设置(布局、主题等)
|
|
737
|
-
userId String // 所属用户
|
|
738
|
-
isDeleted Boolean @default(false)
|
|
739
|
-
deletedAt DateTime?
|
|
740
|
-
createdAt DateTime @default(now())
|
|
741
|
-
updatedAt DateTime @updatedAt
|
|
742
|
-
|
|
743
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
744
|
-
pages DesignPage[]
|
|
745
|
-
versions DesignVersion[]
|
|
746
|
-
reviews Review[]
|
|
747
|
-
comments Comment[]
|
|
748
|
-
shares Share[]
|
|
749
|
-
agentConversations AgentConversation[]
|
|
750
|
-
|
|
751
|
-
@@index([userId])
|
|
752
|
-
@@map("designs")
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
// Agent 原型生成会话
|
|
756
|
-
model AgentConversation {
|
|
757
|
-
id String @id @default(cuid())
|
|
758
|
-
userId String
|
|
759
|
-
designId String
|
|
760
|
-
title String @default("新会话")
|
|
761
|
-
createdAt DateTime @default(now())
|
|
762
|
-
updatedAt DateTime @updatedAt
|
|
763
|
-
|
|
764
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
765
|
-
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
766
|
-
messages AgentMessage[]
|
|
767
|
-
|
|
768
|
-
@@index([userId, designId])
|
|
769
|
-
@@map("agent_conversations")
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
// Agent 会话消息
|
|
773
|
-
model AgentMessage {
|
|
774
|
-
id String @id @default(cuid())
|
|
775
|
-
conversationId String
|
|
776
|
-
role String // "user" | "assistant"
|
|
777
|
-
content String // 消息文本
|
|
778
|
-
components Json? // AI 生成的组件数据(assistant 消息)
|
|
779
|
-
isError Boolean @default(false)
|
|
780
|
-
createdAt DateTime @default(now())
|
|
781
|
-
|
|
782
|
-
conversation AgentConversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
|
783
|
-
|
|
784
|
-
@@index([conversationId])
|
|
785
|
-
@@map("agent_messages")
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
// 基础组件表(后台维护)
|
|
789
|
-
model Component {
|
|
790
|
-
id String @id @default(cuid())
|
|
791
|
-
name String
|
|
792
|
-
description String? // 组件描述
|
|
793
|
-
type String // "component" | "block" | "template"
|
|
794
|
-
category String? // 分类
|
|
795
|
-
subCategory String? // 子分类
|
|
796
|
-
path String? // 树形分组路径(如 "基础组件/表单/输入框")
|
|
797
|
-
defaultWidth Int @default(200)
|
|
798
|
-
defaultHeight Int @default(40)
|
|
799
|
-
prototypeKey String? // unique key for registry lookup (e.g. "text", "button")
|
|
800
|
-
config Json @default(dbgenerated("'{}'")) // 属性描述 schema(props定义、slots、events)
|
|
801
|
-
defaultProps Json? // 默认属性值
|
|
802
|
-
defaultStyle Json? // 默认样式
|
|
803
|
-
preview String? // 预览图URL
|
|
804
|
-
version Int @default(1)
|
|
805
|
-
sortOrder Int @default(0) // 排序权重(越大越前)
|
|
806
|
-
source String @default("manual") // "npm" | "file" | "manual"
|
|
807
|
-
sourceId String? // npm 包名 / 文件名
|
|
808
|
-
isHidden Boolean @default(false) // 隐藏/显示
|
|
809
|
-
isDeleted Boolean @default(false)
|
|
810
|
-
createdAt DateTime @default(now())
|
|
811
|
-
updatedAt DateTime @updatedAt
|
|
812
|
-
|
|
813
|
-
blockItems BlockComponent[] @relation("componentRef")
|
|
814
|
-
instances ComponentInstance[] @relation("componentRef")
|
|
815
|
-
tags Json @default(dbgenerated("'[]'"))
|
|
816
|
-
|
|
817
|
-
@@index([type, category])
|
|
818
|
-
@@index([isDeleted])
|
|
819
|
-
@@index([isHidden])
|
|
820
|
-
@@index([sortOrder])
|
|
821
|
-
@@map("components")
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
// 区块定义表(后台维护)
|
|
825
|
-
model Block {
|
|
826
|
-
id String @id @default(cuid())
|
|
827
|
-
name String
|
|
828
|
-
description String?
|
|
829
|
-
category String?
|
|
830
|
-
isDeleted Boolean @default(false)
|
|
831
|
-
createdAt DateTime @default(now())
|
|
832
|
-
updatedAt DateTime @updatedAt
|
|
833
|
-
|
|
834
|
-
items BlockComponent[]
|
|
835
|
-
instances BlockInstance[] @relation("blockRef")
|
|
836
|
-
templateItems TemplateBlock[] @relation("templateBlockRef")
|
|
837
|
-
|
|
838
|
-
@@index([isDeleted])
|
|
839
|
-
@@map("blocks")
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
// 区块内组件布局
|
|
843
|
-
model BlockComponent {
|
|
844
|
-
id String @id @default(cuid())
|
|
845
|
-
blockId String
|
|
846
|
-
componentId String
|
|
847
|
-
x Float @default(0)
|
|
848
|
-
y Float @default(0)
|
|
849
|
-
width Float @default(100)
|
|
850
|
-
height Float @default(100)
|
|
851
|
-
zIndex Int @default(0)
|
|
852
|
-
propsOverride Json? // 局部覆写属性
|
|
853
|
-
styleOverride Json? // 局部覆写样式
|
|
854
|
-
|
|
855
|
-
block Block @relation(fields: [blockId], references: [id], onDelete: Cascade)
|
|
856
|
-
component Component @relation("componentRef", fields: [componentId], references: [id], onDelete: Cascade)
|
|
857
|
-
|
|
858
|
-
@@map("block_components")
|
|
859
|
-
@@index([blockId])
|
|
860
|
-
@@index([componentId])
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
// 模板定义表(后台维护)
|
|
864
|
-
model Template {
|
|
865
|
-
id String @id @default(cuid())
|
|
866
|
-
name String
|
|
867
|
-
description String?
|
|
868
|
-
category String?
|
|
869
|
-
isDeleted Boolean @default(false)
|
|
870
|
-
createdAt DateTime @default(now())
|
|
871
|
-
updatedAt DateTime @updatedAt
|
|
872
|
-
|
|
873
|
-
items TemplateBlock[]
|
|
874
|
-
|
|
875
|
-
@@index([isDeleted])
|
|
876
|
-
@@map("templates")
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
// 模板内区块排布
|
|
880
|
-
model TemplateBlock {
|
|
881
|
-
id String @id @default(cuid())
|
|
882
|
-
templateId String
|
|
883
|
-
blockId String
|
|
884
|
-
order Int @default(0) // 排布顺序
|
|
885
|
-
x Float? @default(0)
|
|
886
|
-
y Float? @default(0)
|
|
887
|
-
width Float?
|
|
888
|
-
height Float?
|
|
889
|
-
|
|
890
|
-
template Template @relation(fields: [templateId], references: [id], onDelete: Cascade)
|
|
891
|
-
block Block @relation("templateBlockRef", fields: [blockId], references: [id], onDelete: Cascade)
|
|
892
|
-
|
|
893
|
-
@@map("template_blocks")
|
|
894
|
-
@@index([templateId])
|
|
895
|
-
@@index([blockId])
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
// Design 页面/目录树节点
|
|
899
|
-
model DesignPage {
|
|
900
|
-
id String @id @default(cuid())
|
|
901
|
-
designId String
|
|
902
|
-
parentId String? // 父节点,构建树形结构(null = 根级)
|
|
903
|
-
name String
|
|
904
|
-
order Int @default(0) // 排序
|
|
905
|
-
type String @default("page") // "page" | "folder"
|
|
906
|
-
canvas Json? // 原型画板数据
|
|
907
|
-
content Json? // Design 文档内容
|
|
908
|
-
version Int @default(1) // 页面版本号
|
|
909
|
-
createdAt DateTime @default(now())
|
|
910
|
-
updatedAt DateTime @updatedAt
|
|
911
|
-
|
|
912
|
-
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
913
|
-
parent DesignPage? @relation("PageHierarchy", fields: [parentId], references: [id], onDelete: Cascade)
|
|
914
|
-
children DesignPage[] @relation("PageHierarchy")
|
|
915
|
-
componentInstances ComponentInstance[]
|
|
916
|
-
blockInstances BlockInstance[]
|
|
917
|
-
pageVersions PageVersion[]
|
|
918
|
-
|
|
919
|
-
@@index([designId, order])
|
|
920
|
-
@@map("design_pages")
|
|
921
|
-
@@index([parentId])
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
// 组件实例(画布上)
|
|
925
|
-
model ComponentInstance {
|
|
926
|
-
id String @id @default(cuid())
|
|
927
|
-
pageId String
|
|
928
|
-
componentId String? // null = 已解绑的游离副本
|
|
929
|
-
blockInstanceId String? // 所属区块实例
|
|
930
|
-
name String? // 实例别名
|
|
931
|
-
x Float @default(0)
|
|
932
|
-
y Float @default(0)
|
|
933
|
-
width Float @default(100)
|
|
934
|
-
height Float @default(100)
|
|
935
|
-
zIndex Int @default(0)
|
|
936
|
-
props Json? // 局部覆写属性
|
|
937
|
-
style Json? // 局部覆写样式
|
|
938
|
-
createdAt DateTime @default(now())
|
|
939
|
-
updatedAt DateTime @updatedAt
|
|
940
|
-
|
|
941
|
-
page DesignPage @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
|
942
|
-
component Component? @relation("componentRef", fields: [componentId], references: [id], onDelete: SetNull)
|
|
943
|
-
blockInstance BlockInstance? @relation(fields: [blockInstanceId], references: [id], onDelete: SetNull)
|
|
944
|
-
|
|
945
|
-
@@index([pageId])
|
|
946
|
-
@@map("component_instances")
|
|
947
|
-
@@index([componentId])
|
|
948
|
-
@@index([blockInstanceId])
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
// 区块实例(画布上)
|
|
952
|
-
model BlockInstance {
|
|
953
|
-
id String @id @default(cuid())
|
|
954
|
-
pageId String
|
|
955
|
-
blockId String? // null = 已解绑的游离副本
|
|
956
|
-
name String? // 实例别名
|
|
957
|
-
x Float @default(0)
|
|
958
|
-
y Float @default(0)
|
|
959
|
-
width Float @default(400)
|
|
960
|
-
height Float @default(300)
|
|
961
|
-
zIndex Int @default(0)
|
|
962
|
-
props Json? // 局部覆写属性
|
|
963
|
-
style Json? // 局部覆写样式
|
|
964
|
-
createdAt DateTime @default(now())
|
|
965
|
-
updatedAt DateTime @updatedAt
|
|
966
|
-
|
|
967
|
-
page DesignPage @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
|
968
|
-
block Block? @relation("blockRef", fields: [blockId], references: [id], onDelete: SetNull)
|
|
969
|
-
instances ComponentInstance[]
|
|
970
|
-
|
|
971
|
-
@@index([pageId])
|
|
972
|
-
@@map("block_instances")
|
|
973
|
-
@@index([blockId])
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
// Design 版本(手动发布创建)
|
|
977
|
-
model DesignVersion {
|
|
978
|
-
id String @id @default(cuid())
|
|
979
|
-
designId String
|
|
980
|
-
major Int @default(1)
|
|
981
|
-
minor Int @default(0)
|
|
982
|
-
patch Int @default(0)
|
|
983
|
-
versionLabel String // 如 "v1", "v1.1", "v1.1.1"
|
|
984
|
-
parentVersion String? // 上一版本ID(版本链)
|
|
985
|
-
pageVersions Json @default(dbgenerated("'[]'")) // [{ pageId, pageName, version, canvas, content }]
|
|
986
|
-
notes String? // 发版说明
|
|
987
|
-
userId String
|
|
988
|
-
createdAt DateTime @default(now())
|
|
989
|
-
updatedAt DateTime?
|
|
990
|
-
|
|
991
|
-
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
992
|
-
// 产品决策(审查修复):Restrict——版本归属共享 Design 而非创建者个人,删创建者
|
|
993
|
-
// 级联删版本会经 Review.version/ReviewComment/ShareVersion 销毁他人数据。
|
|
994
|
-
user User @relation(fields: [userId], references: [id], onDelete: Restrict)
|
|
995
|
-
reviews Review[]
|
|
996
|
-
shareVersions ShareVersion[]
|
|
997
|
-
|
|
998
|
-
@@index([designId, createdAt])
|
|
999
|
-
@@index([userId])
|
|
1000
|
-
@@map("design_versions")
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
// 页面版本(独立的页面级别版本历史)
|
|
1004
|
-
model PageVersion {
|
|
1005
|
-
id String @id @default(cuid())
|
|
1006
|
-
pageId String
|
|
1007
|
-
version Int // 整数版本号,自增
|
|
1008
|
-
notes String? // 版本说明(用户可编辑)
|
|
1009
|
-
canvas Json? @default(dbgenerated("'{}'")) // 原型快照
|
|
1010
|
-
content Json? // 文档快照
|
|
1011
|
-
restoredFromVersion Int? // 从哪个版本号还原而来(null 表示非还原版本)
|
|
1012
|
-
fromDesignVersionId String? // 来源:从哪个 Design 版本创建(可选标记)
|
|
1013
|
-
createdAt DateTime @default(now())
|
|
1014
|
-
|
|
1015
|
-
page DesignPage @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
|
1016
|
-
|
|
1017
|
-
@@index([pageId, createdAt])
|
|
1018
|
-
@@index([pageId, version])
|
|
1019
|
-
@@map("page_versions")
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
// 评审工作流
|
|
1023
|
-
model Review {
|
|
1024
|
-
id String @id @default(cuid())
|
|
1025
|
-
designId String
|
|
1026
|
-
versionId String
|
|
1027
|
-
status String @default("PENDING")
|
|
1028
|
-
reviewerId String?
|
|
1029
|
-
notes String?
|
|
1030
|
-
createdAt DateTime @default(now())
|
|
1031
|
-
completedAt DateTime?
|
|
1032
|
-
|
|
1033
|
-
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
1034
|
-
version DesignVersion @relation(fields: [versionId], references: [id], onDelete: Cascade)
|
|
1035
|
-
reviewer User? @relation("reviewer", fields: [reviewerId], references: [id], onDelete: SetNull)
|
|
1036
|
-
comments ReviewComment[]
|
|
1037
|
-
|
|
1038
|
-
@@unique([designId, versionId])
|
|
1039
|
-
@@index([designId])
|
|
1040
|
-
@@index([versionId])
|
|
1041
|
-
@@index([reviewerId])
|
|
1042
|
-
@@map("reviews")
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
// 评审留言
|
|
1046
|
-
model ReviewComment {
|
|
1047
|
-
id String @id @default(cuid())
|
|
1048
|
-
reviewId String
|
|
1049
|
-
userId String
|
|
1050
|
-
content String
|
|
1051
|
-
pageId String? // 关联页面
|
|
1052
|
-
elementId String? // 关联具体元素
|
|
1053
|
-
parentId String? // 回复上级留言
|
|
1054
|
-
createdAt DateTime @default(now())
|
|
1055
|
-
|
|
1056
|
-
review Review @relation(fields: [reviewId], references: [id], onDelete: Cascade)
|
|
1057
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1058
|
-
parent ReviewComment? @relation("ReviewCommentReplies", fields: [parentId], references: [id], onDelete: SetNull)
|
|
1059
|
-
replies ReviewComment[] @relation("ReviewCommentReplies")
|
|
1060
|
-
|
|
1061
|
-
@@index([reviewId])
|
|
1062
|
-
@@index([userId])
|
|
1063
|
-
@@index([parentId])
|
|
1064
|
-
@@map("review_comments")
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
// 评论(Design 级别 / 页面级别 / 元素级别)
|
|
1068
|
-
model Comment {
|
|
1069
|
-
id String @id @default(cuid())
|
|
1070
|
-
designId String
|
|
1071
|
-
pageId String? // 可选:针对某页面
|
|
1072
|
-
elementId String? // 可选:针对某元素(组件/区块实例ID)
|
|
1073
|
-
userId String
|
|
1074
|
-
content String
|
|
1075
|
-
parentId String? // 回复上级评论
|
|
1076
|
-
position Json? // 文本选区位置 { from: number, to: number }
|
|
1077
|
-
resolved Boolean @default(false)
|
|
1078
|
-
createdAt DateTime @default(now())
|
|
1079
|
-
updatedAt DateTime @updatedAt
|
|
1080
|
-
|
|
1081
|
-
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
1082
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1083
|
-
parent Comment? @relation("CommentReplies", fields: [parentId], references: [id], onDelete: SetNull)
|
|
1084
|
-
replies Comment[] @relation("CommentReplies")
|
|
1085
|
-
ignores CommentIgnore[]
|
|
1086
|
-
|
|
1087
|
-
@@index([designId])
|
|
1088
|
-
@@index([userId])
|
|
1089
|
-
@@index([parentId])
|
|
1090
|
-
@@index([pageId])
|
|
1091
|
-
@@map("comments")
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
model CommentIgnore {
|
|
1095
|
-
id String @id @default(cuid())
|
|
1096
|
-
userId String
|
|
1097
|
-
commentId String
|
|
1098
|
-
createdAt DateTime @default(now())
|
|
1099
|
-
|
|
1100
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1101
|
-
comment Comment @relation(fields: [commentId], references: [id], onDelete: Cascade)
|
|
1102
|
-
|
|
1103
|
-
@@unique([userId, commentId])
|
|
1104
|
-
@@index([userId])
|
|
1105
|
-
@@index([commentId])
|
|
1106
|
-
@@map("comment_ignores")
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
// 分享链接
|
|
1110
|
-
model Share {
|
|
1111
|
-
id String @id @default(cuid())
|
|
1112
|
-
designId String
|
|
1113
|
-
token String @unique
|
|
1114
|
-
type String @default("prd") // "prd" | 预留扩展
|
|
1115
|
-
status String @default("ACTIVE")
|
|
1116
|
-
password String? // 加密分享密码(4位,数字+大写+小写字母)
|
|
1117
|
-
hasPassword Boolean @default(false)
|
|
1118
|
-
expiresAt DateTime?
|
|
1119
|
-
createdAt DateTime @default(now())
|
|
1120
|
-
updatedAt DateTime @updatedAt
|
|
1121
|
-
|
|
1122
|
-
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
1123
|
-
shareVersions ShareVersion[]
|
|
1124
|
-
|
|
1125
|
-
@@index([designId, type, status])
|
|
1126
|
-
@@index([status])
|
|
1127
|
-
@@index([expiresAt])
|
|
1128
|
-
@@map("shares")
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
model Reference {
|
|
1132
|
-
id String @id @default(uuid())
|
|
1133
|
-
sourceModule String
|
|
1134
|
-
sourceEntityId String
|
|
1135
|
-
targetModule String
|
|
1136
|
-
targetEntityId String
|
|
1137
|
-
createdAt DateTime @default(now())
|
|
1138
|
-
|
|
1139
|
-
@@index([sourceModule, sourceEntityId])
|
|
1140
|
-
@@index([targetModule, targetEntityId])
|
|
1141
|
-
@@map("references")
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
model ShareVersion {
|
|
1145
|
-
id String @id @default(cuid())
|
|
1146
|
-
shareId String
|
|
1147
|
-
versionId String
|
|
1148
|
-
|
|
1149
|
-
share Share @relation(fields: [shareId], references: [id], onDelete: Cascade)
|
|
1150
|
-
version DesignVersion @relation(fields: [versionId], references: [id], onDelete: Cascade)
|
|
1151
|
-
|
|
1152
|
-
@@unique([shareId, versionId])
|
|
1153
|
-
@@index([shareId])
|
|
1154
|
-
@@index([versionId])
|
|
1155
|
-
@@map("share_versions")
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
|
-
// ========== AnyHub 模型 ==========
|
|
1159
|
-
|
|
1160
|
-
model AnyHubApp {
|
|
1161
|
-
id String @id @default(cuid())
|
|
1162
|
-
name String @unique
|
|
1163
|
-
displayName String
|
|
1164
|
-
description String?
|
|
1165
|
-
version String @default("0.1.0")
|
|
1166
|
-
source String
|
|
1167
|
-
url String?
|
|
1168
|
-
localPath String?
|
|
1169
|
-
proxyBasePath String?
|
|
1170
|
-
iconUrl String?
|
|
1171
|
-
pinned Boolean @default(false)
|
|
1172
|
-
status String @default("installing")
|
|
1173
|
-
userId String
|
|
1174
|
-
githubUrl String?
|
|
1175
|
-
createdAt DateTime @default(now())
|
|
1176
|
-
updatedAt DateTime @updatedAt
|
|
1177
|
-
|
|
1178
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1179
|
-
permissions AnyHubPermission[]
|
|
1180
|
-
|
|
1181
|
-
@@index([userId])
|
|
1182
|
-
@@index([pinned])
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
model AnyHubPermission {
|
|
1186
|
-
id String @id @default(cuid())
|
|
1187
|
-
appId String
|
|
1188
|
-
capability String
|
|
1189
|
-
granted Boolean @default(false)
|
|
1190
|
-
userId String
|
|
1191
|
-
createdAt DateTime @default(now())
|
|
1192
|
-
updatedAt DateTime @updatedAt
|
|
1193
|
-
|
|
1194
|
-
app AnyHubApp @relation(fields: [appId], references: [id], onDelete: Cascade)
|
|
1195
|
-
|
|
1196
|
-
@@unique([appId, capability, userId])
|
|
1197
|
-
@@index([appId])
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
model AnyHubMarketApp {
|
|
1201
|
-
id String @id @default(cuid())
|
|
1202
|
-
name String
|
|
1203
|
-
displayName String
|
|
1204
|
-
description String?
|
|
1205
|
-
entryUrl String
|
|
1206
|
-
icon String?
|
|
1207
|
-
iconType String @default("ICON")
|
|
1208
|
-
logo String?
|
|
1209
|
-
category String?
|
|
1210
|
-
tags String?
|
|
1211
|
-
downloads Int @default(0)
|
|
1212
|
-
capabilities Json @default(dbgenerated("'{}'"))
|
|
1213
|
-
status String @default("DRAFT")
|
|
1214
|
-
publishedAt DateTime?
|
|
1215
|
-
userId String
|
|
1216
|
-
recommendationId String? @unique
|
|
1217
|
-
createdAt DateTime @default(now())
|
|
1218
|
-
updatedAt DateTime @updatedAt
|
|
1219
|
-
|
|
1220
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1221
|
-
recommendation AnyHubRecommendation? @relation("anyhubRecommendation", fields: [recommendationId], references: [id], onDelete: SetNull)
|
|
1222
|
-
|
|
1223
|
-
@@index([status])
|
|
1224
|
-
@@index([category])
|
|
1225
|
-
@@index([userId])
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
model AnyHubRecommendation {
|
|
1229
|
-
id String @id @default(cuid())
|
|
1230
|
-
githubUrl String @unique
|
|
1231
|
-
name String?
|
|
1232
|
-
displayName String?
|
|
1233
|
-
description String?
|
|
1234
|
-
status String @default("pending")
|
|
1235
|
-
reviewedBy String?
|
|
1236
|
-
reviewedAt DateTime?
|
|
1237
|
-
marketplaceAppId String?
|
|
1238
|
-
createdAt DateTime @default(now())
|
|
1239
|
-
updatedAt DateTime @updatedAt
|
|
1240
|
-
|
|
1241
|
-
marketplaceApp AnyHubMarketApp? @relation("anyhubRecommendation")
|
|
1242
|
-
reviewer User? @relation("reviewedAnyhubRecommendations", fields: [reviewedBy], references: [id], onDelete: SetNull)
|
|
1243
|
-
recommenders AnyHubRecommender[]
|
|
1244
|
-
|
|
1245
|
-
@@index([status])
|
|
1246
|
-
@@index([reviewedBy])
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
|
-
model AnyHubRecommender {
|
|
1250
|
-
id String @id @default(cuid())
|
|
1251
|
-
recommendationId String
|
|
1252
|
-
userId String
|
|
1253
|
-
reason String?
|
|
1254
|
-
createdAt DateTime @default(now())
|
|
1255
|
-
|
|
1256
|
-
recommendation AnyHubRecommendation @relation(fields: [recommendationId], references: [id], onDelete: Cascade)
|
|
1257
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1258
|
-
|
|
1259
|
-
@@unique([recommendationId, userId])
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
// AI 服务商元数据(admin 维护)
|
|
1263
|
-
model AiProvider {
|
|
1264
|
-
id String @id @default(cuid())
|
|
1265
|
-
providerId String @unique // 业务标识 "openai" "anthropic",用于 adapter 路由与 AiProviderConfig 软关联
|
|
1266
|
-
displayName String
|
|
1267
|
-
brandName String
|
|
1268
|
-
description String
|
|
1269
|
-
category String @default("popular") // recommended|popular|local
|
|
1270
|
-
adapterKind String // openai|anthropic|gemini|groq|grok|openrouter|ollama|openai-compatible
|
|
1271
|
-
defaultBaseUrl String?
|
|
1272
|
-
keyUrl String?
|
|
1273
|
-
docsUrl String?
|
|
1274
|
-
keyPlaceholder String?
|
|
1275
|
-
iconSlug String?
|
|
1276
|
-
brandColor String @default("#6467F2")
|
|
1277
|
-
badge String? // 卡片角标文案(如「推荐」「热门」「NEW」),admin 可配
|
|
1278
|
-
isLocal Boolean @default(false)
|
|
1279
|
-
enabled Boolean @default(true) // 平台级开关:停用后未配置用户看不到,已配置用户继续可用
|
|
1280
|
-
models Json @default(dbgenerated("'[]'")) // AiModelMeta[](admin 可编辑)
|
|
1281
|
-
sortOrder Int @default(0)
|
|
1282
|
-
createdAt DateTime @default(now())
|
|
1283
|
-
updatedAt DateTime @updatedAt
|
|
1284
|
-
|
|
1285
|
-
@@map("ai_providers")
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
// 用户级 AI 服务商配置
|
|
1289
|
-
model AiProviderConfig {
|
|
1290
|
-
id String @id @default(cuid())
|
|
1291
|
-
userId String
|
|
1292
|
-
providerId String // 业务 providerId,软关联 AiProvider.providerId(不设外键 cascade,避免 admin 删除丢失用户配置)
|
|
1293
|
-
apiKey String? // 加密存储 TODO
|
|
1294
|
-
baseUrl String?
|
|
1295
|
-
voiceApiKey String? // BytePlus Voice 独立 API key(speech/transcription 用,与 Ark apiKey 分开)
|
|
1296
|
-
voiceBaseUrl String? // BytePlus Voice Base URL(默认 fallback 到 baseUrl)
|
|
1297
|
-
enabled Boolean @default(false) // 用户级开关:是否在对话模型选择器中暴露
|
|
1298
|
-
models Json? // string[] 用户启用的模型 ID(有序,顺序 = 模型选择器展示顺序)
|
|
1299
|
-
customModels Json? // AiModelMeta[] 用户私有的自定义/刷新获取的模型元数据,与 AiProvider.models 取并集按 id 去重
|
|
1300
|
-
agentMeta Json? // 模式2 本地 Agent 元数据:{ binary, resolvedPath, version, auth, workspaceDir, detectedAt };不存任何密钥
|
|
1301
|
-
createdAt DateTime @default(now())
|
|
1302
|
-
updatedAt DateTime @updatedAt
|
|
1303
|
-
|
|
1304
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1305
|
-
|
|
1306
|
-
@@unique([userId, providerId])
|
|
1307
|
-
@@index([userId])
|
|
1308
|
-
@@index([providerId])
|
|
1309
|
-
@@map("ai_provider_configs")
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1312
|
-
// 第三方依赖版本管理(admin 决策是否升级)
|
|
1313
|
-
// currentVersion 实时读 monorepo 各 package.json,不存 DB;latestVersion 缓存自 npm registry
|
|
1314
|
-
model ThirdPartyDependency {
|
|
1315
|
-
id String @id @default(cuid())
|
|
1316
|
-
name String @unique // npm 包名,如 "@tiptap/core" / "mind-elixir"
|
|
1317
|
-
displayName String? // 展示名(默认取 name)
|
|
1318
|
-
description String? // 依赖用途说明(admin 可编辑)
|
|
1319
|
-
homepage String? // 官网 / 仓库
|
|
1320
|
-
category String @default("other") // framework|ui|editor|ai|state|tool|other
|
|
1321
|
-
isWatched Boolean @default(true) // 是否置顶「关注列表」
|
|
1322
|
-
priority String @default("normal") // high|normal|low
|
|
1323
|
-
latestVersion String? // 缓存的 npm registry latest 版本
|
|
1324
|
-
latestChangelog String? // 最新版本的更新日志(来自 GitHub Releases,markdown)
|
|
1325
|
-
lastSyncAt DateTime? // 最后一次成功同步 npm registry 的时间
|
|
1326
|
-
notes String? // 备注(升级注意事项等)
|
|
1327
|
-
sortOrder Int @default(0)
|
|
1328
|
-
createdAt DateTime @default(now())
|
|
1329
|
-
updatedAt DateTime @updatedAt
|
|
1330
|
-
|
|
1331
|
-
@@index([category])
|
|
1332
|
-
@@index([isWatched])
|
|
1333
|
-
@@map("third_party_dependencies")
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
// ============ 公共知识库:法律法规 ============
|
|
1337
|
-
model LegalRegulation {
|
|
1338
|
-
id String @id @default(cuid())
|
|
1339
|
-
canonicalId String
|
|
1340
|
-
title String
|
|
1341
|
-
code String?
|
|
1342
|
-
jurisdiction String
|
|
1343
|
-
region String?
|
|
1344
|
-
country String?
|
|
1345
|
-
category String
|
|
1346
|
-
issuingAuthority String?
|
|
1347
|
-
effectiveDate DateTime?
|
|
1348
|
-
summary String?
|
|
1349
|
-
content String?
|
|
1350
|
-
sourceUrl String?
|
|
1351
|
-
likeCount Int @default(0)
|
|
1352
|
-
tags Json @default(dbgenerated("'[]'"))
|
|
1353
|
-
visibility String @default("private")
|
|
1354
|
-
userId String
|
|
1355
|
-
isDeleted Boolean @default(false)
|
|
1356
|
-
createdAt DateTime @default(now())
|
|
1357
|
-
updatedAt DateTime @updatedAt
|
|
1358
|
-
|
|
1359
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1360
|
-
|
|
1361
|
-
@@index([canonicalId, visibility])
|
|
1362
|
-
@@index([userId, visibility])
|
|
1363
|
-
@@index([jurisdiction, category])
|
|
1364
|
-
@@map("legal_regulations")
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
model IndustryCompliance {
|
|
1368
|
-
id String @id @default(cuid())
|
|
1369
|
-
canonicalId String
|
|
1370
|
-
title String
|
|
1371
|
-
industry String
|
|
1372
|
-
regulatoryBody String?
|
|
1373
|
-
region String?
|
|
1374
|
-
summary String?
|
|
1375
|
-
content String?
|
|
1376
|
-
requirements Json @default(dbgenerated("'[]'"))
|
|
1377
|
-
sourceUrl String?
|
|
1378
|
-
likeCount Int @default(0)
|
|
1379
|
-
tags Json @default(dbgenerated("'[]'"))
|
|
1380
|
-
visibility String @default("private")
|
|
1381
|
-
userId String
|
|
1382
|
-
isDeleted Boolean @default(false)
|
|
1383
|
-
createdAt DateTime @default(now())
|
|
1384
|
-
updatedAt DateTime @updatedAt
|
|
1385
|
-
|
|
1386
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1387
|
-
|
|
1388
|
-
@@index([canonicalId, visibility])
|
|
1389
|
-
@@index([userId, visibility])
|
|
1390
|
-
@@index([industry])
|
|
1391
|
-
@@map("industry_compliances")
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
model DictionaryTerm {
|
|
1395
|
-
id String @id @default(cuid())
|
|
1396
|
-
canonicalId String
|
|
1397
|
-
title String
|
|
1398
|
-
industry String
|
|
1399
|
-
definition String?
|
|
1400
|
-
aliases Json @default(dbgenerated("'[]'"))
|
|
1401
|
-
examples Json @default(dbgenerated("'[]'"))
|
|
1402
|
-
referenceUrl String?
|
|
1403
|
-
tags Json @default(dbgenerated("'[]'"))
|
|
1404
|
-
visibility String @default("private")
|
|
1405
|
-
userId String
|
|
1406
|
-
isDeleted Boolean @default(false)
|
|
1407
|
-
createdAt DateTime @default(now())
|
|
1408
|
-
updatedAt DateTime @updatedAt
|
|
1409
|
-
|
|
1410
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1411
|
-
|
|
1412
|
-
@@index([canonicalId, visibility])
|
|
1413
|
-
@@index([userId, visibility])
|
|
1414
|
-
@@index([title])
|
|
1415
|
-
@@map("dictionary_terms")
|
|
1416
|
-
}
|
|
1417
|
-
|
|
1418
|
-
model WebsiteBookmark {
|
|
1419
|
-
id String @id @default(cuid())
|
|
1420
|
-
canonicalId String
|
|
1421
|
-
title String
|
|
1422
|
-
url String
|
|
1423
|
-
categoryId String?
|
|
1424
|
-
summary String?
|
|
1425
|
-
faviconUrl String?
|
|
1426
|
-
faviconSyncedAt DateTime?
|
|
1427
|
-
isGithub Boolean @default(false)
|
|
1428
|
-
githubOwner String?
|
|
1429
|
-
githubRepo String?
|
|
1430
|
-
githubStars Int?
|
|
1431
|
-
githubLatestVersion String?
|
|
1432
|
-
githubVersionDate DateTime?
|
|
1433
|
-
githubRepoUpdatedAt DateTime?
|
|
1434
|
-
githubSyncedAt DateTime?
|
|
1435
|
-
tags Json @default(dbgenerated("'[]'"))
|
|
1436
|
-
visibility String @default("private")
|
|
1437
|
-
userId String
|
|
1438
|
-
isDeleted Boolean @default(false)
|
|
1439
|
-
createdAt DateTime @default(now())
|
|
1440
|
-
updatedAt DateTime @updatedAt
|
|
1441
|
-
|
|
1442
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1443
|
-
category BookmarkCategory? @relation(fields: [categoryId], references: [id], onDelete: SetNull)
|
|
1444
|
-
|
|
1445
|
-
@@index([canonicalId, visibility])
|
|
1446
|
-
@@index([userId, visibility])
|
|
1447
|
-
@@index([categoryId])
|
|
1448
|
-
@@index([isGithub])
|
|
1449
|
-
@@map("website_bookmarks")
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
|
-
model BookmarkCategory {
|
|
1453
|
-
id String @id @default(cuid())
|
|
1454
|
-
name String
|
|
1455
|
-
icon String @default("Folder")
|
|
1456
|
-
sortOrder Int @default(0)
|
|
1457
|
-
isDefault Boolean @default(false)
|
|
1458
|
-
userId String?
|
|
1459
|
-
createdAt DateTime @default(now())
|
|
1460
|
-
updatedAt DateTime @updatedAt
|
|
1461
|
-
|
|
1462
|
-
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1463
|
-
bookmarks WebsiteBookmark[]
|
|
1464
|
-
|
|
1465
|
-
@@unique([userId, name])
|
|
1466
|
-
@@index([userId])
|
|
1467
|
-
@@map("bookmark_categories")
|
|
1468
|
-
}
|
|
1469
|
-
|
|
1470
|
-
model KnowledgeShareRecord {
|
|
1471
|
-
id String @id @default(cuid())
|
|
1472
|
-
entityType String
|
|
1473
|
-
canonicalId String
|
|
1474
|
-
userId String
|
|
1475
|
-
sharedAt DateTime @default(now())
|
|
1476
|
-
|
|
1477
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1478
|
-
|
|
1479
|
-
@@unique([entityType, canonicalId, userId])
|
|
1480
|
-
@@index([entityType, canonicalId])
|
|
1481
|
-
@@map("knowledge_share_records")
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
|
-
model ArticleFavorite {
|
|
1485
|
-
id String @id @default(cuid())
|
|
1486
|
-
entityType String
|
|
1487
|
-
entityId String
|
|
1488
|
-
userId String
|
|
1489
|
-
createdAt DateTime @default(now())
|
|
1490
|
-
|
|
1491
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1492
|
-
|
|
1493
|
-
@@unique([entityType, entityId, userId])
|
|
1494
|
-
@@index([userId, entityType])
|
|
1495
|
-
@@map("article_favorites")
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1498
|
-
// ── 子项目 2:托管 AI 与 BYOK 统一层 ──
|
|
1499
|
-
|
|
1500
|
-
/// 订阅计划定义(seed 数据)
|
|
1501
|
-
model Plan {
|
|
1502
|
-
id String @id @default(cuid())
|
|
1503
|
-
name String @unique
|
|
1504
|
-
displayName String
|
|
1505
|
-
description String?
|
|
1506
|
-
priceMonthly Int @default(0)
|
|
1507
|
-
priceYearly Int?
|
|
1508
|
-
currency String @default("usd")
|
|
1509
|
-
maxSeats Int?
|
|
1510
|
-
maxGuestSeats Int?
|
|
1511
|
-
maxWorkspaces Int?
|
|
1512
|
-
aiQuotaMonthly Int?
|
|
1513
|
-
features Json @default(dbgenerated("'{}'"))
|
|
1514
|
-
isPublic Boolean @default(true)
|
|
1515
|
-
sortOrder Int @default(0)
|
|
1516
|
-
createdAt DateTime @default(now())
|
|
1517
|
-
updatedAt DateTime @updatedAt
|
|
1518
|
-
|
|
1519
|
-
/// Provider 产品与价格同步(子项目 3 新增)
|
|
1520
|
-
providerPriceIdUsd String?
|
|
1521
|
-
providerPriceIdCny String?
|
|
1522
|
-
providerPriceIdUsdYearly String?
|
|
1523
|
-
providerPriceIdCnyYearly String?
|
|
1524
|
-
|
|
1525
|
-
seatPriceMonthly Int?
|
|
1526
|
-
providerSeatPriceIdUsd String?
|
|
1527
|
-
providerSeatPriceIdCny String?
|
|
1528
|
-
|
|
1529
|
-
agentQuota Int?
|
|
1530
|
-
skillQuota Int?
|
|
1531
|
-
sandboxMinutesMonthly Int?
|
|
1532
|
-
mediaGenerationsMonthly Int?
|
|
1533
|
-
galleryStorageMb Int?
|
|
1534
|
-
installQuota Int?
|
|
1535
|
-
blobStorageMb Int?
|
|
1536
|
-
|
|
1537
|
-
subscriptions Subscription[]
|
|
1538
|
-
|
|
1539
|
-
@@map("plans")
|
|
1540
|
-
}
|
|
1541
|
-
|
|
1542
|
-
/// 订阅记录(User 级,一人一订阅)
|
|
1543
|
-
model Subscription {
|
|
1544
|
-
id String @id @default(cuid())
|
|
1545
|
-
userId String @unique
|
|
1546
|
-
user User @relation(fields: [userId], references: [id], onDelete: Restrict)
|
|
1547
|
-
planId String
|
|
1548
|
-
plan Plan @relation(fields: [planId], references: [id], onDelete: Restrict)
|
|
1549
|
-
status String @default("ACTIVE")
|
|
1550
|
-
addonSeats Int @default(0)
|
|
1551
|
-
|
|
1552
|
-
provider String @default("creem")
|
|
1553
|
-
providerCustomerId String?
|
|
1554
|
-
providerSubscriptionId String? @unique
|
|
1555
|
-
providerPriceId String?
|
|
1556
|
-
providerSeatSubscriptionId String?
|
|
1557
|
-
|
|
1558
|
-
currentPeriodStart DateTime?
|
|
1559
|
-
currentPeriodEnd DateTime?
|
|
1560
|
-
cancelAtPeriodEnd Boolean @default(false)
|
|
1561
|
-
canceledAt DateTime?
|
|
1562
|
-
trialEndsAt DateTime?
|
|
1563
|
-
|
|
1564
|
-
createdAt DateTime @default(now())
|
|
1565
|
-
updatedAt DateTime @updatedAt
|
|
1566
|
-
|
|
1567
|
-
/// 关联发票(子项目 3 新增)
|
|
1568
|
-
invoices Invoice[]
|
|
1569
|
-
|
|
1570
|
-
@@map("subscriptions")
|
|
1571
|
-
@@index([planId])
|
|
1572
|
-
}
|
|
1573
|
-
|
|
1574
|
-
/// 用量记录(按月聚合,用于额度判断)
|
|
1575
|
-
model UsageRecord {
|
|
1576
|
-
id String @id @default(cuid())
|
|
1577
|
-
workspaceId String
|
|
1578
|
-
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Restrict)
|
|
1579
|
-
metric String
|
|
1580
|
-
period String
|
|
1581
|
-
count Int @default(0)
|
|
1582
|
-
resetAt DateTime
|
|
1583
|
-
|
|
1584
|
-
createdAt DateTime @default(now())
|
|
1585
|
-
updatedAt DateTime @updatedAt
|
|
1586
|
-
|
|
1587
|
-
@@unique([workspaceId, metric, period])
|
|
1588
|
-
@@index([workspaceId, metric])
|
|
1589
|
-
@@map("usage_records")
|
|
1590
|
-
}
|
|
1591
|
-
|
|
1592
|
-
/// AI 用量明细(按次扣减 + 成本审计)
|
|
1593
|
-
model AiUsageLog {
|
|
1594
|
-
id String @id @default(cuid())
|
|
1595
|
-
workspaceId String?
|
|
1596
|
-
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: Restrict)
|
|
1597
|
-
userId String
|
|
1598
|
-
user User @relation(fields: [userId], references: [id], onDelete: Restrict)
|
|
1599
|
-
source String @default("byok")
|
|
1600
|
-
activity String?
|
|
1601
|
-
provider String
|
|
1602
|
-
model String
|
|
1603
|
-
inputTokens Int @default(0)
|
|
1604
|
-
outputTokens Int @default(0)
|
|
1605
|
-
costUsd String?
|
|
1606
|
-
success Boolean @default(true)
|
|
1607
|
-
errorMessage String?
|
|
1608
|
-
durationMs Int?
|
|
1609
|
-
|
|
1610
|
-
createdAt DateTime @default(now())
|
|
1611
|
-
|
|
1612
|
-
@@index([workspaceId, createdAt])
|
|
1613
|
-
@@index([userId, createdAt])
|
|
1614
|
-
@@index([workspaceId, source, createdAt])
|
|
1615
|
-
@@index([workspaceId, success, createdAt])
|
|
1616
|
-
@@map("ai_usage_logs")
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
|
-
// ── 子项目 3:计费与订阅系统 ──
|
|
1620
|
-
|
|
1621
|
-
/// 账单记录(Webhook 同步)
|
|
1622
|
-
model Invoice {
|
|
1623
|
-
id String @id @default(cuid())
|
|
1624
|
-
subscriptionId String
|
|
1625
|
-
subscription Subscription @relation(fields: [subscriptionId], references: [id], onDelete: Restrict)
|
|
1626
|
-
providerInvoiceId String @unique
|
|
1627
|
-
providerEventId String?
|
|
1628
|
-
amountDue Int
|
|
1629
|
-
amountPaid Int
|
|
1630
|
-
currency String @default("usd")
|
|
1631
|
-
status String
|
|
1632
|
-
pdfUrl String?
|
|
1633
|
-
hostedInvoiceUrl String?
|
|
1634
|
-
periodStart DateTime
|
|
1635
|
-
periodEnd DateTime
|
|
1636
|
-
paidAt DateTime?
|
|
1637
|
-
|
|
1638
|
-
createdAt DateTime @default(now())
|
|
1639
|
-
|
|
1640
|
-
@@index([subscriptionId, createdAt])
|
|
1641
|
-
@@map("invoices")
|
|
1642
|
-
}
|
|
1643
|
-
|
|
1644
|
-
/// Provider Webhook 事件幂等记录
|
|
1645
|
-
model ProviderEvent {
|
|
1646
|
-
id String @id @default(cuid())
|
|
1647
|
-
providerEventId String @unique
|
|
1648
|
-
type String
|
|
1649
|
-
status String @default("processing")
|
|
1650
|
-
payload Json?
|
|
1651
|
-
errorMessage String?
|
|
1652
|
-
processedAt DateTime?
|
|
1653
|
-
|
|
1654
|
-
createdAt DateTime @default(now())
|
|
1655
|
-
|
|
1656
|
-
@@index([type, createdAt])
|
|
1657
|
-
@@map("provider_events")
|
|
1658
|
-
}
|
|
1659
|
-
|
|
1660
|
-
// ==================== 子项目 5:企业治理模型(sqlite 降级版)====================
|
|
1661
|
-
|
|
1662
|
-
model LicenseKey {
|
|
1663
|
-
id String @id @default(cuid())
|
|
1664
|
-
key String @unique
|
|
1665
|
-
signature String
|
|
1666
|
-
payload String @default(dbgenerated("'{}'"))
|
|
1667
|
-
customerId String
|
|
1668
|
-
customerName String
|
|
1669
|
-
customerEmail String
|
|
1670
|
-
plan String @default("enterprise")
|
|
1671
|
-
seats Int
|
|
1672
|
-
features String @default(dbgenerated("'{}'"))
|
|
1673
|
-
issuedAt DateTime @default(now())
|
|
1674
|
-
expiresAt DateTime?
|
|
1675
|
-
revokedAt DateTime?
|
|
1676
|
-
issuedById String?
|
|
1677
|
-
|
|
1678
|
-
@@map("license_keys")
|
|
1679
|
-
@@index([issuedById])
|
|
1680
|
-
@@index([customerId])
|
|
1681
|
-
}
|
|
1682
|
-
|
|
1683
|
-
model LicenseActivation {
|
|
1684
|
-
id String @id @default(cuid())
|
|
1685
|
-
licenseId String
|
|
1686
|
-
instanceId String @unique
|
|
1687
|
-
fingerprint String
|
|
1688
|
-
activatedAt DateTime @default(now())
|
|
1689
|
-
lastSeenAt DateTime?
|
|
1690
|
-
revokedAt DateTime?
|
|
1691
|
-
|
|
1692
|
-
@@map("license_activations")
|
|
1693
|
-
@@index([licenseId])
|
|
1694
|
-
}
|
|
1695
|
-
|
|
1696
|
-
model AuditLog {
|
|
1697
|
-
// 悬空预留列(DB-09 决策:保留不删):与 pg 不同,sqlite 侧不建 relation/FK——
|
|
1698
|
-
// desktop 已发版(v0.0.x~v0.11.0)存在存量库,且 sidecar SQL 仅首启建表、
|
|
1699
|
-
// 存量库永不重放,删列会造成「fresh 与存量库形状不一致」;web 端
|
|
1700
|
-
// workspace.ts 的 auditLog 写路径编译进 sidecar,无法证明零引用。
|
|
1701
|
-
id String @id @default(cuid())
|
|
1702
|
-
workspaceId String?
|
|
1703
|
-
userId String?
|
|
1704
|
-
action String
|
|
1705
|
-
resourceType String
|
|
1706
|
-
resourceId String?
|
|
1707
|
-
metadata String @default(dbgenerated("'{}'"))
|
|
1708
|
-
ip String?
|
|
1709
|
-
userAgent String?
|
|
1710
|
-
createdAt DateTime @default(now())
|
|
1711
|
-
|
|
1712
|
-
@@index([workspaceId, createdAt])
|
|
1713
|
-
@@index([userId, createdAt])
|
|
1714
|
-
@@index([action])
|
|
1715
|
-
@@map("audit_logs")
|
|
1716
|
-
}
|
|
1717
|
-
|
|
1718
|
-
model SsoProvider {
|
|
1719
|
-
id String @id @default(cuid())
|
|
1720
|
-
workspaceId String
|
|
1721
|
-
type String
|
|
1722
|
-
name String
|
|
1723
|
-
config String @default(dbgenerated("'{}'"))
|
|
1724
|
-
domain String?
|
|
1725
|
-
enabled Boolean @default(true)
|
|
1726
|
-
createdAt DateTime @default(now())
|
|
1727
|
-
updatedAt DateTime @updatedAt
|
|
1728
|
-
|
|
1729
|
-
@@unique([workspaceId, type, domain])
|
|
1730
|
-
@@map("sso_providers")
|
|
1731
|
-
}
|
|
1732
|
-
|
|
1733
|
-
model SsoMapping {
|
|
1734
|
-
id String @id @default(cuid())
|
|
1735
|
-
providerId String
|
|
1736
|
-
externalId String
|
|
1737
|
-
userId String
|
|
1738
|
-
email String?
|
|
1739
|
-
createdAt DateTime @default(now())
|
|
1740
|
-
|
|
1741
|
-
@@unique([providerId, externalId])
|
|
1742
|
-
@@map("sso_mappings")
|
|
1743
|
-
@@index([userId])
|
|
1744
|
-
}
|
|
1745
|
-
|
|
1746
|
-
model CustomRole {
|
|
1747
|
-
id String @id @default(cuid())
|
|
1748
|
-
workspaceId String
|
|
1749
|
-
name String
|
|
1750
|
-
permissions String @default(dbgenerated("'{}'"))
|
|
1751
|
-
isSystem Boolean @default(false)
|
|
1752
|
-
createdAt DateTime @default(now())
|
|
1753
|
-
updatedAt DateTime @updatedAt
|
|
1754
|
-
|
|
1755
|
-
@@unique([workspaceId, name])
|
|
1756
|
-
@@map("custom_roles")
|
|
1757
|
-
}
|
|
1758
|
-
|
|
1759
|
-
model RoleAssignment {
|
|
1760
|
-
id String @id @default(cuid())
|
|
1761
|
-
roleId String
|
|
1762
|
-
userId String
|
|
1763
|
-
createdAt DateTime @default(now())
|
|
1764
|
-
|
|
1765
|
-
@@unique([roleId, userId])
|
|
1766
|
-
@@map("role_assignments")
|
|
1767
|
-
}
|
|
1768
|
-
|
|
1769
|
-
model ComplianceExport {
|
|
1770
|
-
id String @id @default(cuid())
|
|
1771
|
-
type String
|
|
1772
|
-
scope String
|
|
1773
|
-
targetId String
|
|
1774
|
-
status String @default("pending")
|
|
1775
|
-
downloadUrl String?
|
|
1776
|
-
expiresAt DateTime?
|
|
1777
|
-
error String?
|
|
1778
|
-
content String?
|
|
1779
|
-
requestedBy String?
|
|
1780
|
-
createdAt DateTime @default(now())
|
|
1781
|
-
completedAt DateTime?
|
|
1782
|
-
|
|
1783
|
-
@@map("compliance_exports")
|
|
1784
|
-
}
|
|
1785
|
-
|
|
1786
|
-
// P6 用户自定义 Agent(人设/工具/模型/温度/开场白/建议问题/知识库绑定)
|
|
1787
|
-
model UserAgent {
|
|
1788
|
-
id String @id @default(cuid())
|
|
1789
|
-
userId String
|
|
1790
|
-
name String
|
|
1791
|
-
description String?
|
|
1792
|
-
avatarEmoji String?
|
|
1793
|
-
systemPrompt String
|
|
1794
|
-
allowedTools Json @default(dbgenerated("'[]'"))
|
|
1795
|
-
model String?
|
|
1796
|
-
temperature Float?
|
|
1797
|
-
greeting String?
|
|
1798
|
-
suggestedPrompts Json?
|
|
1799
|
-
knowledgeBaseIds Json @default(dbgenerated("'[]'"))
|
|
1800
|
-
createdAt DateTime @default(now())
|
|
1801
|
-
updatedAt DateTime @updatedAt
|
|
1802
|
-
isDeleted Boolean @default(false)
|
|
1803
|
-
isDefault Boolean @default(false)
|
|
1804
|
-
harnessKind String?
|
|
1805
|
-
|
|
1806
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1807
|
-
threads ChatThread[]
|
|
1808
|
-
agentBindings BusinessAgentBinding[]
|
|
1809
|
-
|
|
1810
|
-
@@index([userId])
|
|
1811
|
-
@@map("user_agents")
|
|
1812
|
-
}
|
|
1813
|
-
|
|
1814
|
-
// P6 用户自定义 Skill(斜杠指令模板)
|
|
1815
|
-
model UserSkill {
|
|
1816
|
-
id String @id @default(cuid())
|
|
1817
|
-
userId String
|
|
1818
|
-
name String
|
|
1819
|
-
title String
|
|
1820
|
-
template String
|
|
1821
|
-
createdAt DateTime @default(now())
|
|
1822
|
-
updatedAt DateTime @updatedAt
|
|
1823
|
-
isDeleted Boolean @default(false)
|
|
1824
|
-
|
|
1825
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1826
|
-
|
|
1827
|
-
@@unique([userId, name])
|
|
1828
|
-
@@map("user_skills")
|
|
1829
|
-
}
|
|
1830
|
-
|
|
1831
|
-
// 开发者日志(Changelog 条目,agent 自动生成 + admin 手动管理)
|
|
1832
|
-
model DeveloperLog {
|
|
1833
|
-
id String @id @default(cuid())
|
|
1834
|
-
date String
|
|
1835
|
-
year String
|
|
1836
|
-
title String
|
|
1837
|
-
desc String
|
|
1838
|
-
tags Json @default(dbgenerated("'[]'"))
|
|
1839
|
-
commitSha String?
|
|
1840
|
-
createdAt DateTime @default(now())
|
|
1841
|
-
updatedAt DateTime @updatedAt
|
|
1842
|
-
isDeleted Boolean @default(false)
|
|
1843
|
-
|
|
1844
|
-
@@index([year, date])
|
|
1845
|
-
@@map("developer_logs")
|
|
1846
|
-
}
|
|
1847
|
-
|
|
1848
|
-
// 需求(简化版,与 psql schema 对齐)
|
|
1849
|
-
model Story {
|
|
1850
|
-
id String @id @default(cuid())
|
|
1851
|
-
sequenceId Int
|
|
1852
|
-
boardOrder Int @default(0)
|
|
1853
|
-
identifier String
|
|
1854
|
-
projectId String
|
|
1855
|
-
project Project @relation(fields: [projectId], references: [id], onDelete: Restrict)
|
|
1856
|
-
name String
|
|
1857
|
-
description String?
|
|
1858
|
-
state String @default("backlog")
|
|
1859
|
-
priority String @default("none")
|
|
1860
|
-
archived Boolean @default(false)
|
|
1861
|
-
archivedAt DateTime?
|
|
1862
|
-
assigneeId String?
|
|
1863
|
-
assignee User? @relation("storyAssignee", fields: [assigneeId], references: [id], onDelete: SetNull)
|
|
1864
|
-
startDate DateTime?
|
|
1865
|
-
targetDate DateTime?
|
|
1866
|
-
createdById String
|
|
1867
|
-
createdBy User @relation("storyCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
|
1868
|
-
updatedById String?
|
|
1869
|
-
updatedBy User? @relation("storyEditor", fields: [updatedById], references: [id], onDelete: SetNull)
|
|
1870
|
-
parentId String?
|
|
1871
|
-
parent Story? @relation("StoryHierarchy", fields: [parentId], references: [id], onDelete: SetNull)
|
|
1872
|
-
children Story[] @relation("StoryHierarchy")
|
|
1873
|
-
iterationId String?
|
|
1874
|
-
iteration Iteration? @relation(fields: [iterationId], references: [id], onDelete: SetNull)
|
|
1875
|
-
createdAt DateTime @default(now())
|
|
1876
|
-
updatedAt DateTime @updatedAt
|
|
1877
|
-
|
|
1878
|
-
@@unique([projectId, identifier])
|
|
1879
|
-
@@index([projectId, sequenceId])
|
|
1880
|
-
@@index([state])
|
|
1881
|
-
@@index([archived])
|
|
1882
|
-
@@index([archived, state, createdAt])
|
|
1883
|
-
@@index([assigneeId])
|
|
1884
|
-
@@index([createdById])
|
|
1885
|
-
@@map("stories")
|
|
1886
|
-
@@index([updatedById])
|
|
1887
|
-
@@index([parentId])
|
|
1888
|
-
@@index([iterationId])
|
|
1889
|
-
}
|
|
1890
|
-
|
|
1891
|
-
// 迭代(时间盒冲刺,状态由日期动态推导,不存状态字段)
|
|
1892
|
-
model Iteration {
|
|
1893
|
-
id String @id @default(cuid())
|
|
1894
|
-
projectId String
|
|
1895
|
-
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
1896
|
-
name String
|
|
1897
|
-
description String?
|
|
1898
|
-
startDate DateTime
|
|
1899
|
-
endDate DateTime
|
|
1900
|
-
archived Boolean @default(false)
|
|
1901
|
-
archivedAt DateTime?
|
|
1902
|
-
createdById String
|
|
1903
|
-
createdBy User @relation("iterationCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
|
1904
|
-
createdAt DateTime @default(now())
|
|
1905
|
-
updatedAt DateTime @updatedAt
|
|
1906
|
-
stories Story[]
|
|
1907
|
-
|
|
1908
|
-
@@index([projectId, startDate])
|
|
1909
|
-
@@index([archived])
|
|
1910
|
-
@@map("iterations")
|
|
1911
|
-
@@index([createdById])
|
|
1912
|
-
}
|
|
1913
|
-
|
|
1914
|
-
// 迭代自动排期配置(一项目一行)
|
|
1915
|
-
model IterationAutoSchedule {
|
|
1916
|
-
projectId String @id
|
|
1917
|
-
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
1918
|
-
enabled Boolean @default(false)
|
|
1919
|
-
title String @default("迭代")
|
|
1920
|
-
durationDays Int @default(14)
|
|
1921
|
-
cooldownDays Int @default(0)
|
|
1922
|
-
startsOn DateTime
|
|
1923
|
-
futureCount Int @default(2)
|
|
1924
|
-
autoRollover Boolean @default(false)
|
|
1925
|
-
lastSeq Int @default(0)
|
|
1926
|
-
|
|
1927
|
-
@@map("iteration_auto_schedules")
|
|
1928
|
-
}
|
|
1929
|
-
|
|
1930
|
-
// 通知偏好(免打扰时段、分类开关)
|
|
1931
|
-
model NotificationPreference {
|
|
1932
|
-
userId String @id
|
|
1933
|
-
categories Json @default(dbgenerated("'{}'"))
|
|
1934
|
-
emailCategories Json @default(dbgenerated("'{}'"))
|
|
1935
|
-
dndEnabled Boolean @default(false)
|
|
1936
|
-
dndStart String @default("22:00")
|
|
1937
|
-
dndEnd String @default("08:00")
|
|
1938
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1939
|
-
|
|
1940
|
-
@@map("notification_preferences")
|
|
1941
|
-
}
|
|
1942
|
-
|
|
1943
|
-
// 编排模式可复用片段:用户保存的跨请求编排逻辑。运行时经 getSnippetBindings
|
|
1944
|
-
// 暴露为 snippet_<name> 绑定,片段函数体在嵌套沙箱内执行并可调用 external_* 工具。
|
|
1945
|
-
model CodeSnippet {
|
|
1946
|
-
id String @id @default(cuid())
|
|
1947
|
-
userId String
|
|
1948
|
-
name String
|
|
1949
|
-
title String
|
|
1950
|
-
description String
|
|
1951
|
-
params Json @default(dbgenerated("'{}'"))
|
|
1952
|
-
code String
|
|
1953
|
-
enabled Boolean @default(true)
|
|
1954
|
-
createdAt DateTime @default(now())
|
|
1955
|
-
updatedAt DateTime @updatedAt
|
|
1956
|
-
isDeleted Boolean @default(false)
|
|
1957
|
-
|
|
1958
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1959
|
-
|
|
1960
|
-
@@unique([userId, name])
|
|
1961
|
-
@@index([userId, enabled, isDeleted])
|
|
1962
|
-
@@map("code_snippets")
|
|
1963
|
-
}
|
|
1964
|
-
|
|
1965
|
-
model SandboxInstance {
|
|
1966
|
-
key String @id
|
|
1967
|
-
provider String
|
|
1968
|
-
providerSandboxId String
|
|
1969
|
-
latestSnapshotId String?
|
|
1970
|
-
threadId String
|
|
1971
|
-
latestRunId String?
|
|
1972
|
-
updatedAt BigInt
|
|
1973
|
-
createdAt DateTime @default(now())
|
|
1974
|
-
|
|
1975
|
-
@@index([threadId])
|
|
1976
|
-
@@map("sandbox_instances")
|
|
1977
|
-
}
|
|
1978
|
-
|
|
1979
|
-
model AiStreamChunk {
|
|
1980
|
-
id BigInt @id @default(autoincrement())
|
|
1981
|
-
runId String
|
|
1982
|
-
chunk Json @default(dbgenerated("'{}'"))
|
|
1983
|
-
createdAt DateTime @default(now())
|
|
1984
|
-
|
|
1985
|
-
@@index([runId, id])
|
|
1986
|
-
@@map("ai_stream_chunks")
|
|
1987
|
-
}
|
|
1988
|
-
|
|
1989
|
-
model DesktopSetting {
|
|
1990
|
-
key String @id // "aiSourceMode" | "localAgentConfig"
|
|
1991
|
-
value Json @default(dbgenerated("'{}'"))
|
|
1992
|
-
|
|
1993
|
-
@@map("desktop_settings")
|
|
1994
|
-
}
|
|
1995
|
-
|
|
1996
|
-
/// Harness 工作区(云端持久化文件区 + 业务数据视图入口)
|
|
1997
|
-
model HarnessWorkspace {
|
|
1998
|
-
id String @id @default(cuid())
|
|
1999
|
-
name String
|
|
2000
|
-
ownerId String
|
|
2001
|
-
kind String @default("cloud") // "cloud" | "local-meta"(本地挂载只存元数据)
|
|
2002
|
-
createdAt DateTime @default(now())
|
|
2003
|
-
updatedAt DateTime @updatedAt
|
|
2004
|
-
|
|
2005
|
-
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
|
|
2006
|
-
files WorkspaceFile[]
|
|
2007
|
-
threads ChatThread[]
|
|
2008
|
-
|
|
2009
|
-
@@index([ownerId, updatedAt])
|
|
2010
|
-
@@map("harness_workspaces")
|
|
2011
|
-
}
|
|
2012
|
-
|
|
2013
|
-
/// 工作区文件(上传文件 + AI 生成物 + 沙箱产出)
|
|
2014
|
-
model WorkspaceFile {
|
|
2015
|
-
id String @id @default(cuid())
|
|
2016
|
-
workspaceId String
|
|
2017
|
-
path String // 相对路径,如 "src/index.ts"
|
|
2018
|
-
mimeType String @default("application/octet-stream")
|
|
2019
|
-
size Int @default(0)
|
|
2020
|
-
content String? // sqlite 无 @db.Text,降级为普通 String
|
|
2021
|
-
source String @default("upload") // "upload" | "ai-generated" | "sandbox"
|
|
2022
|
-
createdAt DateTime @default(now())
|
|
2023
|
-
updatedAt DateTime @updatedAt
|
|
2024
|
-
|
|
2025
|
-
workspace HarnessWorkspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
|
2026
|
-
|
|
2027
|
-
@@unique([workspaceId, path])
|
|
2028
|
-
@@index([workspaceId])
|
|
2029
|
-
@@map("workspace_files")
|
|
2030
|
-
}
|
|
2031
|
-
|
|
2032
|
-
// AI 附件二进制存储(P5 Wave 2)
|
|
2033
|
-
model Blob {
|
|
2034
|
-
id String @id @default(cuid())
|
|
2035
|
-
mimeType String
|
|
2036
|
-
bytes Bytes
|
|
2037
|
-
size Int
|
|
2038
|
-
userId String
|
|
2039
|
-
createdAt DateTime @default(now())
|
|
2040
|
-
|
|
2041
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
2042
|
-
|
|
2043
|
-
@@index([userId])
|
|
2044
|
-
@@map("blobs")
|
|
2045
|
-
}
|