@varaos/db 1.1.0 → 1.1.2
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
package/prisma/migrations/20250926070321_added_chat_messages_and_unique_indexing/migration.sql
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- A unique constraint covering the columns `[defaultWorkspaceId]` on the table `User` will be added. If there are existing duplicate values, this will fail.
|
|
5
|
+
|
|
6
|
+
*/
|
|
7
|
+
-- CreateEnum
|
|
8
|
+
CREATE TYPE "public"."MessageRole" AS ENUM ('user', 'assistant', 'system', 'tool', 'moderator');
|
|
9
|
+
|
|
10
|
+
-- AlterTable
|
|
11
|
+
ALTER TABLE "public"."Workspace" ADD COLUMN "deletedAt" TIMESTAMP(3);
|
|
12
|
+
|
|
13
|
+
-- CreateTable
|
|
14
|
+
CREATE TABLE "public"."ChatSession" (
|
|
15
|
+
"id" TEXT NOT NULL,
|
|
16
|
+
"title" TEXT,
|
|
17
|
+
"userId" TEXT,
|
|
18
|
+
"workspaceId" TEXT,
|
|
19
|
+
"aiAgentId" TEXT,
|
|
20
|
+
"status" TEXT NOT NULL DEFAULT 'active',
|
|
21
|
+
"metadata" JSONB,
|
|
22
|
+
"deletedAt" TIMESTAMP(3),
|
|
23
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
24
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
25
|
+
|
|
26
|
+
CONSTRAINT "ChatSession_pkey" PRIMARY KEY ("id")
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
-- CreateTable
|
|
30
|
+
CREATE TABLE "public"."ChatMessage" (
|
|
31
|
+
"id" TEXT NOT NULL,
|
|
32
|
+
"chatSessionId" TEXT NOT NULL,
|
|
33
|
+
"sender" "public"."MessageRole" NOT NULL,
|
|
34
|
+
"content" TEXT NOT NULL,
|
|
35
|
+
"style" TEXT,
|
|
36
|
+
"tokensUsed" INTEGER,
|
|
37
|
+
"metadata" JSONB,
|
|
38
|
+
"deletedAt" TIMESTAMP(3),
|
|
39
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
40
|
+
|
|
41
|
+
CONSTRAINT "ChatMessage_pkey" PRIMARY KEY ("id")
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
-- CreateIndex
|
|
45
|
+
CREATE INDEX "ChatSession_userId_createdAt_idx" ON "public"."ChatSession"("userId", "createdAt");
|
|
46
|
+
|
|
47
|
+
-- CreateIndex
|
|
48
|
+
CREATE INDEX "ChatSession_workspaceId_createdAt_idx" ON "public"."ChatSession"("workspaceId", "createdAt");
|
|
49
|
+
|
|
50
|
+
-- CreateIndex
|
|
51
|
+
CREATE INDEX "ChatSession_status_idx" ON "public"."ChatSession"("status");
|
|
52
|
+
|
|
53
|
+
-- CreateIndex
|
|
54
|
+
CREATE INDEX "ChatMessage_chatSessionId_createdAt_idx" ON "public"."ChatMessage"("chatSessionId", "createdAt");
|
|
55
|
+
|
|
56
|
+
-- CreateIndex
|
|
57
|
+
CREATE UNIQUE INDEX "User_defaultWorkspaceId_key" ON "public"."User"("defaultWorkspaceId");
|
|
58
|
+
|
|
59
|
+
-- CreateIndex
|
|
60
|
+
CREATE INDEX "User_status_idx" ON "public"."User"("status");
|
|
61
|
+
|
|
62
|
+
-- CreateIndex
|
|
63
|
+
CREATE INDEX "WorkflowRun_workflowId_startedAt_idx" ON "public"."WorkflowRun"("workflowId", "startedAt");
|
|
64
|
+
|
|
65
|
+
-- CreateIndex
|
|
66
|
+
CREATE INDEX "Workspace_status_idx" ON "public"."Workspace"("status");
|
|
67
|
+
|
|
68
|
+
-- CreateIndex
|
|
69
|
+
CREATE INDEX "integration_catalog_status_idx" ON "public"."integration_catalog"("status");
|
|
70
|
+
|
|
71
|
+
-- CreateIndex
|
|
72
|
+
CREATE INDEX "integrations_workspaceId_idx" ON "public"."integrations"("workspaceId");
|
|
73
|
+
|
|
74
|
+
-- CreateIndex
|
|
75
|
+
CREATE INDEX "integrations_status_idx" ON "public"."integrations"("status");
|
|
76
|
+
|
|
77
|
+
-- AddForeignKey
|
|
78
|
+
ALTER TABLE "public"."User" ADD CONSTRAINT "User_defaultWorkspaceId_fkey" FOREIGN KEY ("defaultWorkspaceId") REFERENCES "public"."Workspace"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
79
|
+
|
|
80
|
+
-- AddForeignKey
|
|
81
|
+
ALTER TABLE "public"."ChatSession" ADD CONSTRAINT "ChatSession_userId_fkey" FOREIGN KEY ("userId") REFERENCES "public"."User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
82
|
+
|
|
83
|
+
-- AddForeignKey
|
|
84
|
+
ALTER TABLE "public"."ChatSession" ADD CONSTRAINT "ChatSession_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "public"."Workspace"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
85
|
+
|
|
86
|
+
-- AddForeignKey
|
|
87
|
+
ALTER TABLE "public"."ChatSession" ADD CONSTRAINT "ChatSession_aiAgentId_fkey" FOREIGN KEY ("aiAgentId") REFERENCES "public"."AIAgent"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
88
|
+
|
|
89
|
+
-- AddForeignKey
|
|
90
|
+
ALTER TABLE "public"."ChatMessage" ADD CONSTRAINT "ChatMessage_chatSessionId_fkey" FOREIGN KEY ("chatSessionId") REFERENCES "public"."ChatSession"("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,89 +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[]
|
|
100
|
-
Onboarding Onboarding?
|
|
105
|
+
@@index([status])
|
|
101
106
|
}
|
|
102
107
|
|
|
103
|
-
/// OAuth or other third-party accounts linked to user
|
|
104
108
|
model Account {
|
|
105
109
|
id String @id @default(uuid())
|
|
106
110
|
userId String
|
|
@@ -123,7 +127,6 @@ model Account {
|
|
|
123
127
|
@@unique([provider, providerAccountId])
|
|
124
128
|
}
|
|
125
129
|
|
|
126
|
-
/// Email verification tokens for account security
|
|
127
130
|
model VerificationToken {
|
|
128
131
|
id String @id @default(uuid())
|
|
129
132
|
email String
|
|
@@ -133,7 +136,6 @@ model VerificationToken {
|
|
|
133
136
|
@@unique([email, token])
|
|
134
137
|
}
|
|
135
138
|
|
|
136
|
-
/// Password reset tokens
|
|
137
139
|
model PasswordResetToken {
|
|
138
140
|
id String @id @default(uuid())
|
|
139
141
|
email String
|
|
@@ -143,95 +145,92 @@ model PasswordResetToken {
|
|
|
143
145
|
@@unique([email, token])
|
|
144
146
|
}
|
|
145
147
|
|
|
146
|
-
/// User’s connected integrations scoped optionally by workspace
|
|
147
148
|
model Integration {
|
|
148
149
|
id String @id @default(cuid())
|
|
149
150
|
userId String
|
|
150
|
-
workspaceId String?
|
|
151
|
-
provider String
|
|
152
|
-
providerAccountId String
|
|
153
|
-
integration String
|
|
154
|
-
accessToken String
|
|
155
|
-
refreshToken String?
|
|
151
|
+
workspaceId String?
|
|
152
|
+
provider String
|
|
153
|
+
providerAccountId String
|
|
154
|
+
integration String
|
|
155
|
+
accessToken String
|
|
156
|
+
refreshToken String?
|
|
156
157
|
expiresAt DateTime?
|
|
157
|
-
scopes Json
|
|
158
|
-
profile Json
|
|
158
|
+
scopes Json
|
|
159
|
+
profile Json
|
|
159
160
|
status Status @default(active)
|
|
160
|
-
metadata Json?
|
|
161
|
+
metadata Json?
|
|
162
|
+
deletedAt DateTime?
|
|
161
163
|
|
|
162
|
-
createdAt DateTime
|
|
163
|
-
updatedAt DateTime
|
|
164
|
-
deletedAt DateTime?
|
|
164
|
+
createdAt DateTime @default(now())
|
|
165
|
+
updatedAt DateTime @updatedAt
|
|
165
166
|
|
|
166
167
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
167
168
|
workspace Workspace? @relation(fields: [workspaceId], references: [id])
|
|
168
169
|
integrationSyncLog IntegrationSyncLog[]
|
|
169
170
|
|
|
170
171
|
@@unique([userId, provider, integration, workspaceId], name: "user_provider_integration_workspace")
|
|
172
|
+
@@index([workspaceId])
|
|
173
|
+
@@index([status])
|
|
171
174
|
@@map("integrations")
|
|
172
175
|
}
|
|
173
176
|
|
|
174
|
-
/// Master list of officially supported integrations/tools
|
|
175
177
|
model IntegrationCatalog {
|
|
176
|
-
id String
|
|
177
|
-
provider String
|
|
178
|
-
integration String
|
|
178
|
+
id String @id @default(uuid())
|
|
179
|
+
provider String
|
|
180
|
+
integration String
|
|
179
181
|
name String
|
|
180
|
-
category String?
|
|
181
|
-
showDuringOnboarding Boolean
|
|
182
|
-
default Boolean
|
|
183
|
-
premium Boolean
|
|
182
|
+
category String?
|
|
183
|
+
showDuringOnboarding Boolean @default(true)
|
|
184
|
+
default Boolean @default(false)
|
|
185
|
+
premium Boolean @default(false)
|
|
184
186
|
iconUrl String?
|
|
185
187
|
description String?
|
|
186
188
|
docsUrl String?
|
|
187
|
-
oauthType String?
|
|
188
|
-
setupInstructions Json?
|
|
189
|
-
status Status
|
|
189
|
+
oauthType String?
|
|
190
|
+
setupInstructions Json?
|
|
191
|
+
status Status @default(active)
|
|
190
192
|
|
|
191
193
|
createdAt DateTime @default(now())
|
|
192
194
|
updatedAt DateTime @updatedAt
|
|
193
195
|
|
|
194
196
|
@@unique([provider, integration])
|
|
197
|
+
@@index([status])
|
|
195
198
|
@@map("integration_catalog")
|
|
196
199
|
}
|
|
197
200
|
|
|
198
|
-
|
|
199
|
-
/// Log of sync activity for integrations
|
|
200
201
|
model IntegrationSyncLog {
|
|
201
202
|
id String @id @default(uuid())
|
|
202
203
|
integrationId String
|
|
203
|
-
syncStatus String
|
|
204
|
+
syncStatus String
|
|
204
205
|
errorMessage String?
|
|
205
206
|
timestamp DateTime @default(now())
|
|
206
207
|
|
|
207
208
|
integration Integration @relation(fields: [integrationId], references: [id])
|
|
208
209
|
}
|
|
209
210
|
|
|
210
|
-
/// Represents AI agents your platform offers
|
|
211
211
|
model AIAgent {
|
|
212
|
-
id String
|
|
212
|
+
id String @id @default(uuid())
|
|
213
213
|
name String
|
|
214
|
-
key String
|
|
214
|
+
key String @unique
|
|
215
215
|
description String?
|
|
216
|
-
active Boolean
|
|
217
|
-
config Json?
|
|
218
|
-
|
|
219
|
-
workspaceId String? // scoped to workspace if applicable
|
|
216
|
+
active Boolean @default(true)
|
|
217
|
+
config Json?
|
|
218
|
+
workspaceId String?
|
|
220
219
|
workspace Workspace? @relation(fields: [workspaceId], references: [id])
|
|
221
220
|
|
|
222
221
|
createdAt DateTime @default(now())
|
|
223
222
|
updatedAt DateTime @updatedAt
|
|
224
223
|
|
|
225
224
|
tokenTransactions TokenTransaction[]
|
|
225
|
+
ChatSession ChatSession[]
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
/// Tracks per-user AI token usage and actions
|
|
229
228
|
model TokenTransaction {
|
|
230
229
|
id String @id @default(uuid())
|
|
231
230
|
userId String
|
|
232
231
|
agentId String?
|
|
233
232
|
tokensUsed Int
|
|
234
|
-
action String
|
|
233
|
+
action String
|
|
235
234
|
metadata Json?
|
|
236
235
|
createdAt DateTime @default(now())
|
|
237
236
|
|
|
@@ -239,10 +238,9 @@ model TokenTransaction {
|
|
|
239
238
|
agent AIAgent? @relation(fields: [agentId], references: [id])
|
|
240
239
|
}
|
|
241
240
|
|
|
242
|
-
/// Security and system audit logs
|
|
243
241
|
model AuditLog {
|
|
244
242
|
id String @id @default(uuid())
|
|
245
|
-
userId String?
|
|
243
|
+
userId String?
|
|
246
244
|
eventType String
|
|
247
245
|
description String?
|
|
248
246
|
metadata Json?
|
|
@@ -251,12 +249,11 @@ model AuditLog {
|
|
|
251
249
|
user User? @relation(fields: [userId], references: [id])
|
|
252
250
|
}
|
|
253
251
|
|
|
254
|
-
/// User subscription and billing information
|
|
255
252
|
model Subscription {
|
|
256
253
|
id String @id @default(uuid())
|
|
257
254
|
userId String
|
|
258
255
|
plan Plan
|
|
259
|
-
status String
|
|
256
|
+
status String
|
|
260
257
|
startedAt DateTime
|
|
261
258
|
endedAt DateTime?
|
|
262
259
|
nextPayment DateTime?
|
|
@@ -274,24 +271,22 @@ model WaitList {
|
|
|
274
271
|
teamSize String?
|
|
275
272
|
useCase String?
|
|
276
273
|
consentToUpdates Boolean
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
referredBy String? // stores the referral code of the person who invited them
|
|
274
|
+
referralCode String? @unique
|
|
275
|
+
referredBy String?
|
|
280
276
|
|
|
281
277
|
createdAt DateTime @default(now())
|
|
282
278
|
updatedAt DateTime @updatedAt
|
|
283
279
|
}
|
|
284
280
|
|
|
285
|
-
/// Represents a queued job for async processing
|
|
286
281
|
model Job {
|
|
287
282
|
id String @id @default(uuid())
|
|
288
|
-
type String
|
|
289
|
-
status String @default("pending")
|
|
290
|
-
payload Json
|
|
283
|
+
type String
|
|
284
|
+
status String @default("pending")
|
|
285
|
+
payload Json
|
|
291
286
|
retries Int @default(0)
|
|
292
287
|
maxRetries Int @default(3)
|
|
293
288
|
error String?
|
|
294
|
-
scheduledAt DateTime?
|
|
289
|
+
scheduledAt DateTime?
|
|
295
290
|
startedAt DateTime?
|
|
296
291
|
finishedAt DateTime?
|
|
297
292
|
|
|
@@ -299,14 +294,13 @@ model Job {
|
|
|
299
294
|
updatedAt DateTime @updatedAt
|
|
300
295
|
}
|
|
301
296
|
|
|
302
|
-
/// Represents a user-created workflow (automation, pipeline, etc.)
|
|
303
297
|
model Workflow {
|
|
304
298
|
id String @id @default(uuid())
|
|
305
299
|
name String
|
|
306
300
|
description String?
|
|
307
|
-
status String @default("active")
|
|
308
|
-
userId String
|
|
309
|
-
workspaceId String?
|
|
301
|
+
status String @default("active")
|
|
302
|
+
userId String
|
|
303
|
+
workspaceId String?
|
|
310
304
|
|
|
311
305
|
user User @relation(fields: [userId], references: [id])
|
|
312
306
|
workspace Workspace? @relation(fields: [workspaceId], references: [id])
|
|
@@ -317,12 +311,11 @@ model Workflow {
|
|
|
317
311
|
WorkflowRun WorkflowRun[]
|
|
318
312
|
}
|
|
319
313
|
|
|
320
|
-
/// Individual step inside a workflow
|
|
321
314
|
model WorkflowStep {
|
|
322
315
|
id String @id @default(uuid())
|
|
323
316
|
workflowId String
|
|
324
|
-
type String
|
|
325
|
-
config Json
|
|
317
|
+
type String
|
|
318
|
+
config Json
|
|
326
319
|
order Int
|
|
327
320
|
status String @default("active")
|
|
328
321
|
|
|
@@ -333,11 +326,10 @@ model WorkflowStep {
|
|
|
333
326
|
WorkflowStepRun WorkflowStepRun[]
|
|
334
327
|
}
|
|
335
328
|
|
|
336
|
-
/// Execution of a workflow instance
|
|
337
329
|
model WorkflowRun {
|
|
338
330
|
id String @id @default(uuid())
|
|
339
331
|
workflowId String
|
|
340
|
-
status String @default("running")
|
|
332
|
+
status String @default("running")
|
|
341
333
|
input Json?
|
|
342
334
|
output Json?
|
|
343
335
|
error String?
|
|
@@ -347,9 +339,10 @@ model WorkflowRun {
|
|
|
347
339
|
|
|
348
340
|
workflow Workflow @relation(fields: [workflowId], references: [id])
|
|
349
341
|
steps WorkflowStepRun[]
|
|
342
|
+
|
|
343
|
+
@@index([workflowId, startedAt])
|
|
350
344
|
}
|
|
351
345
|
|
|
352
|
-
/// Execution log for a specific workflow step
|
|
353
346
|
model WorkflowStepRun {
|
|
354
347
|
id String @id @default(uuid())
|
|
355
348
|
workflowRunId String
|
|
@@ -369,7 +362,7 @@ model WorkflowStepRun {
|
|
|
369
362
|
model Notification {
|
|
370
363
|
id String @id @default(uuid())
|
|
371
364
|
userId String?
|
|
372
|
-
type String
|
|
365
|
+
type String
|
|
373
366
|
title String
|
|
374
367
|
body String?
|
|
375
368
|
read Boolean @default(false)
|
|
@@ -379,13 +372,12 @@ model Notification {
|
|
|
379
372
|
user User? @relation(fields: [userId], references: [id])
|
|
380
373
|
}
|
|
381
374
|
|
|
382
|
-
/// Tracks user onboarding flow & preferences
|
|
383
375
|
model Onboarding {
|
|
384
376
|
id String @id @default(uuid())
|
|
385
377
|
userId String @unique
|
|
386
|
-
persona String?
|
|
387
|
-
setupType String?
|
|
388
|
-
progress Json?
|
|
378
|
+
persona String?
|
|
379
|
+
setupType String?
|
|
380
|
+
progress Json?
|
|
389
381
|
completed Boolean @default(false)
|
|
390
382
|
|
|
391
383
|
createdAt DateTime @default(now())
|
|
@@ -394,17 +386,15 @@ model Onboarding {
|
|
|
394
386
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
395
387
|
}
|
|
396
388
|
|
|
397
|
-
|
|
398
|
-
/// Predefined workflow templates shown during onboarding
|
|
399
389
|
model WorkflowTemplate {
|
|
400
|
-
id
|
|
401
|
-
name
|
|
402
|
-
description
|
|
403
|
-
category
|
|
404
|
-
recommended
|
|
405
|
-
iconUrl
|
|
406
|
-
estimatedSetupTime Int?
|
|
407
|
-
status
|
|
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)
|
|
408
398
|
|
|
409
399
|
createdAt DateTime @default(now())
|
|
410
400
|
updatedAt DateTime @updatedAt
|
|
@@ -412,23 +402,20 @@ model WorkflowTemplate {
|
|
|
412
402
|
steps WorkflowStepTemplate[]
|
|
413
403
|
}
|
|
414
404
|
|
|
415
|
-
/// Template version of workflow steps
|
|
416
405
|
model WorkflowStepTemplate {
|
|
417
|
-
id
|
|
418
|
-
templateId
|
|
419
|
-
type
|
|
420
|
-
config
|
|
421
|
-
order
|
|
422
|
-
status
|
|
406
|
+
id String @id @default(uuid())
|
|
407
|
+
templateId String
|
|
408
|
+
type String
|
|
409
|
+
config Json
|
|
410
|
+
order Int
|
|
411
|
+
status String @default("active")
|
|
423
412
|
|
|
424
413
|
template WorkflowTemplate @relation(fields: [templateId], references: [id])
|
|
425
414
|
}
|
|
426
415
|
|
|
427
|
-
|
|
428
|
-
/// Catalog of onboarding personas/roles
|
|
429
416
|
model OnboardingPersona {
|
|
430
417
|
id String @id @default(uuid())
|
|
431
|
-
key String @unique
|
|
418
|
+
key String @unique
|
|
432
419
|
title String
|
|
433
420
|
description String?
|
|
434
421
|
iconUrl String?
|
|
@@ -438,3 +425,43 @@ model OnboardingPersona {
|
|
|
438
425
|
createdAt DateTime @default(now())
|
|
439
426
|
updatedAt DateTime @updatedAt
|
|
440
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
|
+
}
|