@varaos/db 1.0.4 → 1.1.1
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/package.json
CHANGED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
-- AlterTable
|
|
2
|
+
ALTER TABLE "public"."integration_catalog" ADD COLUMN "category" TEXT,
|
|
3
|
+
ADD COLUMN "oauthType" TEXT,
|
|
4
|
+
ADD COLUMN "premium" BOOLEAN NOT NULL DEFAULT false,
|
|
5
|
+
ADD COLUMN "setupInstructions" JSONB;
|
|
6
|
+
|
|
7
|
+
-- CreateTable
|
|
8
|
+
CREATE TABLE "public"."Onboarding" (
|
|
9
|
+
"id" TEXT NOT NULL,
|
|
10
|
+
"userId" TEXT NOT NULL,
|
|
11
|
+
"persona" TEXT,
|
|
12
|
+
"setupType" TEXT,
|
|
13
|
+
"progress" JSONB,
|
|
14
|
+
"completed" BOOLEAN NOT NULL DEFAULT false,
|
|
15
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
16
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
17
|
+
|
|
18
|
+
CONSTRAINT "Onboarding_pkey" PRIMARY KEY ("id")
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
-- CreateTable
|
|
22
|
+
CREATE TABLE "public"."WorkflowTemplate" (
|
|
23
|
+
"id" TEXT NOT NULL,
|
|
24
|
+
"name" TEXT NOT NULL,
|
|
25
|
+
"description" TEXT,
|
|
26
|
+
"category" TEXT,
|
|
27
|
+
"recommended" BOOLEAN NOT NULL DEFAULT false,
|
|
28
|
+
"iconUrl" TEXT,
|
|
29
|
+
"estimatedSetupTime" INTEGER,
|
|
30
|
+
"status" "public"."Status" NOT NULL DEFAULT 'active',
|
|
31
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
32
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
33
|
+
|
|
34
|
+
CONSTRAINT "WorkflowTemplate_pkey" PRIMARY KEY ("id")
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
-- CreateTable
|
|
38
|
+
CREATE TABLE "public"."WorkflowStepTemplate" (
|
|
39
|
+
"id" TEXT NOT NULL,
|
|
40
|
+
"templateId" TEXT NOT NULL,
|
|
41
|
+
"type" TEXT NOT NULL,
|
|
42
|
+
"config" JSONB NOT NULL,
|
|
43
|
+
"order" INTEGER NOT NULL,
|
|
44
|
+
"status" TEXT NOT NULL DEFAULT 'active',
|
|
45
|
+
|
|
46
|
+
CONSTRAINT "WorkflowStepTemplate_pkey" PRIMARY KEY ("id")
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
-- CreateTable
|
|
50
|
+
CREATE TABLE "public"."OnboardingPersona" (
|
|
51
|
+
"id" TEXT NOT NULL,
|
|
52
|
+
"key" TEXT NOT NULL,
|
|
53
|
+
"title" TEXT NOT NULL,
|
|
54
|
+
"description" TEXT,
|
|
55
|
+
"iconUrl" TEXT,
|
|
56
|
+
"recommended" BOOLEAN NOT NULL DEFAULT false,
|
|
57
|
+
"status" "public"."Status" NOT NULL DEFAULT 'active',
|
|
58
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
59
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
60
|
+
|
|
61
|
+
CONSTRAINT "OnboardingPersona_pkey" PRIMARY KEY ("id")
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
-- CreateIndex
|
|
65
|
+
CREATE UNIQUE INDEX "Onboarding_userId_key" ON "public"."Onboarding"("userId");
|
|
66
|
+
|
|
67
|
+
-- CreateIndex
|
|
68
|
+
CREATE UNIQUE INDEX "OnboardingPersona_key_key" ON "public"."OnboardingPersona"("key");
|
|
69
|
+
|
|
70
|
+
-- AddForeignKey
|
|
71
|
+
ALTER TABLE "public"."Onboarding" ADD CONSTRAINT "Onboarding_userId_fkey" FOREIGN KEY ("userId") REFERENCES "public"."User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
72
|
+
|
|
73
|
+
-- AddForeignKey
|
|
74
|
+
ALTER TABLE "public"."WorkflowStepTemplate" ADD CONSTRAINT "WorkflowStepTemplate_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "public"."WorkflowTemplate"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
package/prisma/schema.prisma
CHANGED
|
@@ -8,7 +8,7 @@ datasource db {
|
|
|
8
8
|
directUrl = env("DIRECT_URL")
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
///
|
|
11
|
+
/// Global roles
|
|
12
12
|
enum Role {
|
|
13
13
|
user
|
|
14
14
|
support
|
|
@@ -18,88 +18,93 @@ enum Role {
|
|
|
18
18
|
admin
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
///
|
|
21
|
+
/// Common status values for most resources
|
|
22
22
|
enum Status {
|
|
23
23
|
active
|
|
24
24
|
suspended
|
|
25
25
|
deleted
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
///
|
|
28
|
+
/// Billing plans
|
|
29
29
|
enum Plan {
|
|
30
30
|
free
|
|
31
31
|
pro
|
|
32
32
|
enterprise
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
///
|
|
35
|
+
/// Chat message authors
|
|
36
|
+
enum MessageRole {
|
|
37
|
+
user
|
|
38
|
+
assistant
|
|
39
|
+
system
|
|
40
|
+
tool
|
|
41
|
+
moderator
|
|
42
|
+
}
|
|
43
|
+
|
|
36
44
|
model Workspace {
|
|
37
|
-
id String
|
|
45
|
+
id String @id @default(uuid())
|
|
38
46
|
name String
|
|
39
47
|
description String?
|
|
40
|
-
ownerId String
|
|
41
|
-
status Status
|
|
48
|
+
ownerId String @unique
|
|
49
|
+
status Status @default(active)
|
|
50
|
+
deletedAt DateTime?
|
|
42
51
|
|
|
43
52
|
createdAt DateTime @default(now())
|
|
44
53
|
updatedAt DateTime @updatedAt
|
|
45
54
|
|
|
46
|
-
owner
|
|
55
|
+
owner User @relation("UserWorkspaces", fields: [ownerId], references: [id])
|
|
56
|
+
defaultFor User? @relation("UserDefaultWorkspace")
|
|
57
|
+
|
|
47
58
|
integrations Integration[]
|
|
48
59
|
aiAgents AIAgent[]
|
|
49
60
|
Workflow Workflow[]
|
|
61
|
+
ChatSession ChatSession[]
|
|
62
|
+
|
|
63
|
+
@@index([status])
|
|
50
64
|
}
|
|
51
65
|
|
|
52
66
|
model User {
|
|
53
67
|
id String @id @default(uuid())
|
|
54
68
|
|
|
55
|
-
name
|
|
56
|
-
image
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
role Role @default(user)
|
|
67
|
-
|
|
68
|
-
timezone String?
|
|
69
|
-
language String?
|
|
70
|
-
|
|
71
|
-
status Status @default(active)
|
|
72
|
-
|
|
69
|
+
name String
|
|
70
|
+
image String?
|
|
71
|
+
email String @unique
|
|
72
|
+
password String?
|
|
73
|
+
emailVerified DateTime?
|
|
74
|
+
onboarding DateTime?
|
|
75
|
+
role Role @default(user)
|
|
76
|
+
timezone String?
|
|
77
|
+
language String?
|
|
78
|
+
status Status @default(active)
|
|
73
79
|
lastLogin DateTime?
|
|
74
80
|
lastPasswordChange DateTime?
|
|
75
81
|
twoFactorEnabled Boolean @default(false)
|
|
76
82
|
twoFactorSecret String?
|
|
83
|
+
metadata Json?
|
|
84
|
+
plan Plan @default(free)
|
|
85
|
+
tokenBalance Int @default(0)
|
|
86
|
+
creditsUsed Int @default(0)
|
|
87
|
+
deletedAt DateTime?
|
|
88
|
+
|
|
89
|
+
accounts Account[]
|
|
90
|
+
integrations Integration[]
|
|
91
|
+
tokenTransactions TokenTransaction[]
|
|
92
|
+
auditLogs AuditLog[]
|
|
93
|
+
subscriptions Subscription[]
|
|
94
|
+
workspaces Workspace[] @relation("UserWorkspaces")
|
|
95
|
+
defaultWorkspaceId String? @unique
|
|
96
|
+
defaultWorkspace Workspace? @relation("UserDefaultWorkspace", fields: [defaultWorkspaceId], references: [id])
|
|
97
|
+
Workflow Workflow[]
|
|
98
|
+
Notification Notification[]
|
|
99
|
+
Onboarding Onboarding?
|
|
100
|
+
ChatSession ChatSession[]
|
|
77
101
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
plan Plan @default(free)
|
|
81
|
-
tokenBalance Int @default(0)
|
|
82
|
-
creditsUsed Int @default(0)
|
|
83
|
-
|
|
84
|
-
accounts Account[]
|
|
85
|
-
integrations Integration[]
|
|
86
|
-
tokenTransactions TokenTransaction[]
|
|
87
|
-
auditLogs AuditLog[]
|
|
88
|
-
subscriptions Subscription[]
|
|
89
|
-
|
|
90
|
-
defaultWorkspaceId String?
|
|
91
|
-
|
|
92
|
-
// Inverse side of relation, no fields or references here!
|
|
93
|
-
defaultWorkspace Workspace? @relation()
|
|
102
|
+
createdAt DateTime @default(now())
|
|
103
|
+
updatedAt DateTime @updatedAt
|
|
94
104
|
|
|
95
|
-
|
|
96
|
-
updatedAt DateTime @updatedAt
|
|
97
|
-
deletedAt DateTime?
|
|
98
|
-
Workflow Workflow[]
|
|
99
|
-
Notification Notification[]
|
|
105
|
+
@@index([status])
|
|
100
106
|
}
|
|
101
107
|
|
|
102
|
-
/// OAuth or other third-party accounts linked to user
|
|
103
108
|
model Account {
|
|
104
109
|
id String @id @default(uuid())
|
|
105
110
|
userId String
|
|
@@ -122,7 +127,6 @@ model Account {
|
|
|
122
127
|
@@unique([provider, providerAccountId])
|
|
123
128
|
}
|
|
124
129
|
|
|
125
|
-
/// Email verification tokens for account security
|
|
126
130
|
model VerificationToken {
|
|
127
131
|
id String @id @default(uuid())
|
|
128
132
|
email String
|
|
@@ -132,7 +136,6 @@ model VerificationToken {
|
|
|
132
136
|
@@unique([email, token])
|
|
133
137
|
}
|
|
134
138
|
|
|
135
|
-
/// Password reset tokens
|
|
136
139
|
model PasswordResetToken {
|
|
137
140
|
id String @id @default(uuid())
|
|
138
141
|
email String
|
|
@@ -142,90 +145,92 @@ model PasswordResetToken {
|
|
|
142
145
|
@@unique([email, token])
|
|
143
146
|
}
|
|
144
147
|
|
|
145
|
-
/// User’s connected integrations scoped optionally by workspace
|
|
146
148
|
model Integration {
|
|
147
149
|
id String @id @default(cuid())
|
|
148
150
|
userId String
|
|
149
|
-
workspaceId String?
|
|
150
|
-
provider String
|
|
151
|
-
providerAccountId String
|
|
152
|
-
integration String
|
|
153
|
-
accessToken String
|
|
154
|
-
refreshToken String?
|
|
151
|
+
workspaceId String?
|
|
152
|
+
provider String
|
|
153
|
+
providerAccountId String
|
|
154
|
+
integration String
|
|
155
|
+
accessToken String
|
|
156
|
+
refreshToken String?
|
|
155
157
|
expiresAt DateTime?
|
|
156
|
-
scopes Json
|
|
157
|
-
profile Json
|
|
158
|
+
scopes Json
|
|
159
|
+
profile Json
|
|
158
160
|
status Status @default(active)
|
|
159
|
-
metadata Json?
|
|
161
|
+
metadata Json?
|
|
162
|
+
deletedAt DateTime?
|
|
160
163
|
|
|
161
|
-
createdAt DateTime
|
|
162
|
-
updatedAt DateTime
|
|
163
|
-
deletedAt DateTime?
|
|
164
|
+
createdAt DateTime @default(now())
|
|
165
|
+
updatedAt DateTime @updatedAt
|
|
164
166
|
|
|
165
167
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
166
168
|
workspace Workspace? @relation(fields: [workspaceId], references: [id])
|
|
167
169
|
integrationSyncLog IntegrationSyncLog[]
|
|
168
170
|
|
|
169
171
|
@@unique([userId, provider, integration, workspaceId], name: "user_provider_integration_workspace")
|
|
172
|
+
@@index([workspaceId])
|
|
173
|
+
@@index([status])
|
|
170
174
|
@@map("integrations")
|
|
171
175
|
}
|
|
172
176
|
|
|
173
|
-
/// Master list of officially supported integrations/tools
|
|
174
177
|
model IntegrationCatalog {
|
|
175
178
|
id String @id @default(uuid())
|
|
176
179
|
provider String
|
|
177
180
|
integration String
|
|
178
181
|
name String
|
|
182
|
+
category String?
|
|
179
183
|
showDuringOnboarding Boolean @default(true)
|
|
180
184
|
default Boolean @default(false)
|
|
185
|
+
premium Boolean @default(false)
|
|
181
186
|
iconUrl String?
|
|
182
187
|
description String?
|
|
183
188
|
docsUrl String?
|
|
189
|
+
oauthType String?
|
|
190
|
+
setupInstructions Json?
|
|
184
191
|
status Status @default(active)
|
|
185
192
|
|
|
186
193
|
createdAt DateTime @default(now())
|
|
187
194
|
updatedAt DateTime @updatedAt
|
|
188
195
|
|
|
189
196
|
@@unique([provider, integration])
|
|
197
|
+
@@index([status])
|
|
190
198
|
@@map("integration_catalog")
|
|
191
199
|
}
|
|
192
200
|
|
|
193
|
-
/// Log of sync activity for integrations
|
|
194
201
|
model IntegrationSyncLog {
|
|
195
202
|
id String @id @default(uuid())
|
|
196
203
|
integrationId String
|
|
197
|
-
syncStatus String
|
|
204
|
+
syncStatus String
|
|
198
205
|
errorMessage String?
|
|
199
206
|
timestamp DateTime @default(now())
|
|
200
207
|
|
|
201
208
|
integration Integration @relation(fields: [integrationId], references: [id])
|
|
202
209
|
}
|
|
203
210
|
|
|
204
|
-
/// Represents AI agents your platform offers
|
|
205
211
|
model AIAgent {
|
|
206
|
-
id String
|
|
212
|
+
id String @id @default(uuid())
|
|
207
213
|
name String
|
|
208
|
-
key String
|
|
214
|
+
key String @unique
|
|
209
215
|
description String?
|
|
210
|
-
active Boolean
|
|
211
|
-
config Json?
|
|
212
|
-
|
|
213
|
-
workspaceId String? // scoped to workspace if applicable
|
|
216
|
+
active Boolean @default(true)
|
|
217
|
+
config Json?
|
|
218
|
+
workspaceId String?
|
|
214
219
|
workspace Workspace? @relation(fields: [workspaceId], references: [id])
|
|
215
220
|
|
|
216
221
|
createdAt DateTime @default(now())
|
|
217
222
|
updatedAt DateTime @updatedAt
|
|
218
223
|
|
|
219
224
|
tokenTransactions TokenTransaction[]
|
|
225
|
+
ChatSession ChatSession[]
|
|
220
226
|
}
|
|
221
227
|
|
|
222
|
-
/// Tracks per-user AI token usage and actions
|
|
223
228
|
model TokenTransaction {
|
|
224
229
|
id String @id @default(uuid())
|
|
225
230
|
userId String
|
|
226
231
|
agentId String?
|
|
227
232
|
tokensUsed Int
|
|
228
|
-
action String
|
|
233
|
+
action String
|
|
229
234
|
metadata Json?
|
|
230
235
|
createdAt DateTime @default(now())
|
|
231
236
|
|
|
@@ -233,10 +238,9 @@ model TokenTransaction {
|
|
|
233
238
|
agent AIAgent? @relation(fields: [agentId], references: [id])
|
|
234
239
|
}
|
|
235
240
|
|
|
236
|
-
/// Security and system audit logs
|
|
237
241
|
model AuditLog {
|
|
238
242
|
id String @id @default(uuid())
|
|
239
|
-
userId String?
|
|
243
|
+
userId String?
|
|
240
244
|
eventType String
|
|
241
245
|
description String?
|
|
242
246
|
metadata Json?
|
|
@@ -245,12 +249,11 @@ model AuditLog {
|
|
|
245
249
|
user User? @relation(fields: [userId], references: [id])
|
|
246
250
|
}
|
|
247
251
|
|
|
248
|
-
/// User subscription and billing information
|
|
249
252
|
model Subscription {
|
|
250
253
|
id String @id @default(uuid())
|
|
251
254
|
userId String
|
|
252
255
|
plan Plan
|
|
253
|
-
status String
|
|
256
|
+
status String
|
|
254
257
|
startedAt DateTime
|
|
255
258
|
endedAt DateTime?
|
|
256
259
|
nextPayment DateTime?
|
|
@@ -268,24 +271,22 @@ model WaitList {
|
|
|
268
271
|
teamSize String?
|
|
269
272
|
useCase String?
|
|
270
273
|
consentToUpdates Boolean
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
referredBy String? // stores the referral code of the person who invited them
|
|
274
|
+
referralCode String? @unique
|
|
275
|
+
referredBy String?
|
|
274
276
|
|
|
275
277
|
createdAt DateTime @default(now())
|
|
276
278
|
updatedAt DateTime @updatedAt
|
|
277
279
|
}
|
|
278
280
|
|
|
279
|
-
/// Represents a queued job for async processing
|
|
280
281
|
model Job {
|
|
281
282
|
id String @id @default(uuid())
|
|
282
|
-
type String
|
|
283
|
-
status String @default("pending")
|
|
284
|
-
payload Json
|
|
283
|
+
type String
|
|
284
|
+
status String @default("pending")
|
|
285
|
+
payload Json
|
|
285
286
|
retries Int @default(0)
|
|
286
287
|
maxRetries Int @default(3)
|
|
287
288
|
error String?
|
|
288
|
-
scheduledAt DateTime?
|
|
289
|
+
scheduledAt DateTime?
|
|
289
290
|
startedAt DateTime?
|
|
290
291
|
finishedAt DateTime?
|
|
291
292
|
|
|
@@ -293,14 +294,13 @@ model Job {
|
|
|
293
294
|
updatedAt DateTime @updatedAt
|
|
294
295
|
}
|
|
295
296
|
|
|
296
|
-
/// Represents a user-created workflow (automation, pipeline, etc.)
|
|
297
297
|
model Workflow {
|
|
298
298
|
id String @id @default(uuid())
|
|
299
299
|
name String
|
|
300
300
|
description String?
|
|
301
|
-
status String @default("active")
|
|
302
|
-
userId String
|
|
303
|
-
workspaceId String?
|
|
301
|
+
status String @default("active")
|
|
302
|
+
userId String
|
|
303
|
+
workspaceId String?
|
|
304
304
|
|
|
305
305
|
user User @relation(fields: [userId], references: [id])
|
|
306
306
|
workspace Workspace? @relation(fields: [workspaceId], references: [id])
|
|
@@ -311,12 +311,11 @@ model Workflow {
|
|
|
311
311
|
WorkflowRun WorkflowRun[]
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
-
/// Individual step inside a workflow
|
|
315
314
|
model WorkflowStep {
|
|
316
315
|
id String @id @default(uuid())
|
|
317
316
|
workflowId String
|
|
318
|
-
type String
|
|
319
|
-
config Json
|
|
317
|
+
type String
|
|
318
|
+
config Json
|
|
320
319
|
order Int
|
|
321
320
|
status String @default("active")
|
|
322
321
|
|
|
@@ -327,11 +326,10 @@ model WorkflowStep {
|
|
|
327
326
|
WorkflowStepRun WorkflowStepRun[]
|
|
328
327
|
}
|
|
329
328
|
|
|
330
|
-
/// Execution of a workflow instance
|
|
331
329
|
model WorkflowRun {
|
|
332
330
|
id String @id @default(uuid())
|
|
333
331
|
workflowId String
|
|
334
|
-
status String @default("running")
|
|
332
|
+
status String @default("running")
|
|
335
333
|
input Json?
|
|
336
334
|
output Json?
|
|
337
335
|
error String?
|
|
@@ -341,9 +339,10 @@ model WorkflowRun {
|
|
|
341
339
|
|
|
342
340
|
workflow Workflow @relation(fields: [workflowId], references: [id])
|
|
343
341
|
steps WorkflowStepRun[]
|
|
342
|
+
|
|
343
|
+
@@index([workflowId, startedAt])
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
/// Execution log for a specific workflow step
|
|
347
346
|
model WorkflowStepRun {
|
|
348
347
|
id String @id @default(uuid())
|
|
349
348
|
workflowRunId String
|
|
@@ -363,7 +362,7 @@ model WorkflowStepRun {
|
|
|
363
362
|
model Notification {
|
|
364
363
|
id String @id @default(uuid())
|
|
365
364
|
userId String?
|
|
366
|
-
type String
|
|
365
|
+
type String
|
|
367
366
|
title String
|
|
368
367
|
body String?
|
|
369
368
|
read Boolean @default(false)
|
|
@@ -372,3 +371,97 @@ model Notification {
|
|
|
372
371
|
|
|
373
372
|
user User? @relation(fields: [userId], references: [id])
|
|
374
373
|
}
|
|
374
|
+
|
|
375
|
+
model Onboarding {
|
|
376
|
+
id String @id @default(uuid())
|
|
377
|
+
userId String @unique
|
|
378
|
+
persona String?
|
|
379
|
+
setupType String?
|
|
380
|
+
progress Json?
|
|
381
|
+
completed Boolean @default(false)
|
|
382
|
+
|
|
383
|
+
createdAt DateTime @default(now())
|
|
384
|
+
updatedAt DateTime @updatedAt
|
|
385
|
+
|
|
386
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
model WorkflowTemplate {
|
|
390
|
+
id String @id @default(uuid())
|
|
391
|
+
name String
|
|
392
|
+
description String?
|
|
393
|
+
category String?
|
|
394
|
+
recommended Boolean @default(false)
|
|
395
|
+
iconUrl String?
|
|
396
|
+
estimatedSetupTime Int?
|
|
397
|
+
status Status @default(active)
|
|
398
|
+
|
|
399
|
+
createdAt DateTime @default(now())
|
|
400
|
+
updatedAt DateTime @updatedAt
|
|
401
|
+
|
|
402
|
+
steps WorkflowStepTemplate[]
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
model WorkflowStepTemplate {
|
|
406
|
+
id String @id @default(uuid())
|
|
407
|
+
templateId String
|
|
408
|
+
type String
|
|
409
|
+
config Json
|
|
410
|
+
order Int
|
|
411
|
+
status String @default("active")
|
|
412
|
+
|
|
413
|
+
template WorkflowTemplate @relation(fields: [templateId], references: [id])
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
model OnboardingPersona {
|
|
417
|
+
id String @id @default(uuid())
|
|
418
|
+
key String @unique
|
|
419
|
+
title String
|
|
420
|
+
description String?
|
|
421
|
+
iconUrl String?
|
|
422
|
+
recommended Boolean @default(false)
|
|
423
|
+
status Status @default(active)
|
|
424
|
+
|
|
425
|
+
createdAt DateTime @default(now())
|
|
426
|
+
updatedAt DateTime @updatedAt
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
model ChatSession {
|
|
430
|
+
id String @id @default(uuid())
|
|
431
|
+
title String?
|
|
432
|
+
userId String?
|
|
433
|
+
workspaceId String?
|
|
434
|
+
aiAgentId String?
|
|
435
|
+
status String @default("active")
|
|
436
|
+
metadata Json?
|
|
437
|
+
deletedAt DateTime?
|
|
438
|
+
|
|
439
|
+
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
440
|
+
workspace Workspace? @relation(fields: [workspaceId], references: [id])
|
|
441
|
+
aiAgent AIAgent? @relation(fields: [aiAgentId], references: [id])
|
|
442
|
+
messages ChatMessage[]
|
|
443
|
+
|
|
444
|
+
createdAt DateTime @default(now())
|
|
445
|
+
updatedAt DateTime @updatedAt
|
|
446
|
+
|
|
447
|
+
@@index([userId, createdAt])
|
|
448
|
+
@@index([workspaceId, createdAt])
|
|
449
|
+
@@index([status])
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
model ChatMessage {
|
|
453
|
+
id String @id @default(uuid())
|
|
454
|
+
chatSessionId String
|
|
455
|
+
sender MessageRole
|
|
456
|
+
content String
|
|
457
|
+
style String?
|
|
458
|
+
tokensUsed Int?
|
|
459
|
+
metadata Json?
|
|
460
|
+
deletedAt DateTime?
|
|
461
|
+
|
|
462
|
+
chatSession ChatSession @relation(fields: [chatSessionId], references: [id])
|
|
463
|
+
|
|
464
|
+
createdAt DateTime @default(now())
|
|
465
|
+
|
|
466
|
+
@@index([chatSessionId, createdAt])
|
|
467
|
+
}
|