@varaos/db 1.0.3 → 1.0.4
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,108 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "public"."Job" (
|
|
3
|
+
"id" TEXT NOT NULL,
|
|
4
|
+
"type" TEXT NOT NULL,
|
|
5
|
+
"status" TEXT NOT NULL DEFAULT 'pending',
|
|
6
|
+
"payload" JSONB NOT NULL,
|
|
7
|
+
"retries" INTEGER NOT NULL DEFAULT 0,
|
|
8
|
+
"maxRetries" INTEGER NOT NULL DEFAULT 3,
|
|
9
|
+
"error" TEXT,
|
|
10
|
+
"scheduledAt" TIMESTAMP(3),
|
|
11
|
+
"startedAt" TIMESTAMP(3),
|
|
12
|
+
"finishedAt" TIMESTAMP(3),
|
|
13
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
14
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
15
|
+
|
|
16
|
+
CONSTRAINT "Job_pkey" PRIMARY KEY ("id")
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
-- CreateTable
|
|
20
|
+
CREATE TABLE "public"."Workflow" (
|
|
21
|
+
"id" TEXT NOT NULL,
|
|
22
|
+
"name" TEXT NOT NULL,
|
|
23
|
+
"description" TEXT,
|
|
24
|
+
"status" TEXT NOT NULL DEFAULT 'active',
|
|
25
|
+
"userId" TEXT NOT NULL,
|
|
26
|
+
"workspaceId" TEXT,
|
|
27
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
28
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
29
|
+
|
|
30
|
+
CONSTRAINT "Workflow_pkey" PRIMARY KEY ("id")
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
-- CreateTable
|
|
34
|
+
CREATE TABLE "public"."WorkflowStep" (
|
|
35
|
+
"id" TEXT NOT NULL,
|
|
36
|
+
"workflowId" TEXT NOT NULL,
|
|
37
|
+
"type" TEXT NOT NULL,
|
|
38
|
+
"config" JSONB NOT NULL,
|
|
39
|
+
"order" INTEGER NOT NULL,
|
|
40
|
+
"status" TEXT NOT NULL DEFAULT 'active',
|
|
41
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
42
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
43
|
+
|
|
44
|
+
CONSTRAINT "WorkflowStep_pkey" PRIMARY KEY ("id")
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
-- CreateTable
|
|
48
|
+
CREATE TABLE "public"."WorkflowRun" (
|
|
49
|
+
"id" TEXT NOT NULL,
|
|
50
|
+
"workflowId" TEXT NOT NULL,
|
|
51
|
+
"status" TEXT NOT NULL DEFAULT 'running',
|
|
52
|
+
"input" JSONB,
|
|
53
|
+
"output" JSONB,
|
|
54
|
+
"error" TEXT,
|
|
55
|
+
"startedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
56
|
+
"finishedAt" TIMESTAMP(3),
|
|
57
|
+
|
|
58
|
+
CONSTRAINT "WorkflowRun_pkey" PRIMARY KEY ("id")
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
-- CreateTable
|
|
62
|
+
CREATE TABLE "public"."WorkflowStepRun" (
|
|
63
|
+
"id" TEXT NOT NULL,
|
|
64
|
+
"workflowRunId" TEXT NOT NULL,
|
|
65
|
+
"workflowStepId" TEXT NOT NULL,
|
|
66
|
+
"status" TEXT NOT NULL DEFAULT 'pending',
|
|
67
|
+
"input" JSONB,
|
|
68
|
+
"output" JSONB,
|
|
69
|
+
"error" TEXT,
|
|
70
|
+
"startedAt" TIMESTAMP(3),
|
|
71
|
+
"finishedAt" TIMESTAMP(3),
|
|
72
|
+
|
|
73
|
+
CONSTRAINT "WorkflowStepRun_pkey" PRIMARY KEY ("id")
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
-- CreateTable
|
|
77
|
+
CREATE TABLE "public"."Notification" (
|
|
78
|
+
"id" TEXT NOT NULL,
|
|
79
|
+
"userId" TEXT,
|
|
80
|
+
"type" TEXT NOT NULL,
|
|
81
|
+
"title" TEXT NOT NULL,
|
|
82
|
+
"body" TEXT,
|
|
83
|
+
"read" BOOLEAN NOT NULL DEFAULT false,
|
|
84
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
85
|
+
|
|
86
|
+
CONSTRAINT "Notification_pkey" PRIMARY KEY ("id")
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
-- AddForeignKey
|
|
90
|
+
ALTER TABLE "public"."Workflow" ADD CONSTRAINT "Workflow_userId_fkey" FOREIGN KEY ("userId") REFERENCES "public"."User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
91
|
+
|
|
92
|
+
-- AddForeignKey
|
|
93
|
+
ALTER TABLE "public"."Workflow" ADD CONSTRAINT "Workflow_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "public"."Workspace"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
94
|
+
|
|
95
|
+
-- AddForeignKey
|
|
96
|
+
ALTER TABLE "public"."WorkflowStep" ADD CONSTRAINT "WorkflowStep_workflowId_fkey" FOREIGN KEY ("workflowId") REFERENCES "public"."Workflow"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
97
|
+
|
|
98
|
+
-- AddForeignKey
|
|
99
|
+
ALTER TABLE "public"."WorkflowRun" ADD CONSTRAINT "WorkflowRun_workflowId_fkey" FOREIGN KEY ("workflowId") REFERENCES "public"."Workflow"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
100
|
+
|
|
101
|
+
-- AddForeignKey
|
|
102
|
+
ALTER TABLE "public"."WorkflowStepRun" ADD CONSTRAINT "WorkflowStepRun_workflowRunId_fkey" FOREIGN KEY ("workflowRunId") REFERENCES "public"."WorkflowRun"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
103
|
+
|
|
104
|
+
-- AddForeignKey
|
|
105
|
+
ALTER TABLE "public"."WorkflowStepRun" ADD CONSTRAINT "WorkflowStepRun_workflowStepId_fkey" FOREIGN KEY ("workflowStepId") REFERENCES "public"."WorkflowStep"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
106
|
+
|
|
107
|
+
-- AddForeignKey
|
|
108
|
+
ALTER TABLE "public"."Notification" ADD CONSTRAINT "Notification_userId_fkey" FOREIGN KEY ("userId") REFERENCES "public"."User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
package/prisma/schema.prisma
CHANGED
|
@@ -43,57 +43,60 @@ model Workspace {
|
|
|
43
43
|
createdAt DateTime @default(now())
|
|
44
44
|
updatedAt DateTime @updatedAt
|
|
45
45
|
|
|
46
|
-
owner User
|
|
46
|
+
owner User @relation(fields: [ownerId], references: [id]) // defining side
|
|
47
47
|
integrations Integration[]
|
|
48
48
|
aiAgents AIAgent[]
|
|
49
|
+
Workflow Workflow[]
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
model User {
|
|
52
|
-
id
|
|
53
|
+
id String @id @default(uuid())
|
|
53
54
|
|
|
54
|
-
name
|
|
55
|
-
image
|
|
55
|
+
name String
|
|
56
|
+
image String?
|
|
56
57
|
|
|
57
|
-
email
|
|
58
|
+
email String @unique
|
|
58
59
|
|
|
59
|
-
password
|
|
60
|
+
password String?
|
|
60
61
|
|
|
61
|
-
emailVerified
|
|
62
|
+
emailVerified DateTime?
|
|
62
63
|
|
|
63
|
-
onboarding
|
|
64
|
+
onboarding DateTime?
|
|
64
65
|
|
|
65
|
-
role
|
|
66
|
+
role Role @default(user)
|
|
66
67
|
|
|
67
|
-
timezone
|
|
68
|
-
language
|
|
68
|
+
timezone String?
|
|
69
|
+
language String?
|
|
69
70
|
|
|
70
|
-
status
|
|
71
|
+
status Status @default(active)
|
|
71
72
|
|
|
72
73
|
lastLogin DateTime?
|
|
73
74
|
lastPasswordChange DateTime?
|
|
74
75
|
twoFactorEnabled Boolean @default(false)
|
|
75
76
|
twoFactorSecret String?
|
|
76
77
|
|
|
77
|
-
metadata
|
|
78
|
+
metadata Json?
|
|
78
79
|
|
|
79
|
-
plan
|
|
80
|
-
tokenBalance
|
|
81
|
-
creditsUsed
|
|
80
|
+
plan Plan @default(free)
|
|
81
|
+
tokenBalance Int @default(0)
|
|
82
|
+
creditsUsed Int @default(0)
|
|
82
83
|
|
|
83
|
-
accounts
|
|
84
|
-
integrations
|
|
85
|
-
tokenTransactions
|
|
86
|
-
auditLogs
|
|
87
|
-
subscriptions
|
|
84
|
+
accounts Account[]
|
|
85
|
+
integrations Integration[]
|
|
86
|
+
tokenTransactions TokenTransaction[]
|
|
87
|
+
auditLogs AuditLog[]
|
|
88
|
+
subscriptions Subscription[]
|
|
88
89
|
|
|
89
90
|
defaultWorkspaceId String?
|
|
90
91
|
|
|
91
92
|
// Inverse side of relation, no fields or references here!
|
|
92
93
|
defaultWorkspace Workspace? @relation()
|
|
93
94
|
|
|
94
|
-
createdAt
|
|
95
|
-
updatedAt
|
|
96
|
-
deletedAt
|
|
95
|
+
createdAt DateTime @default(now())
|
|
96
|
+
updatedAt DateTime @updatedAt
|
|
97
|
+
deletedAt DateTime?
|
|
98
|
+
Workflow Workflow[]
|
|
99
|
+
Notification Notification[]
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
/// OAuth or other third-party accounts linked to user
|
|
@@ -257,8 +260,8 @@ model Subscription {
|
|
|
257
260
|
}
|
|
258
261
|
|
|
259
262
|
model WaitList {
|
|
260
|
-
id String
|
|
261
|
-
email String
|
|
263
|
+
id String @id @default(uuid())
|
|
264
|
+
email String @unique
|
|
262
265
|
name String?
|
|
263
266
|
company String?
|
|
264
267
|
role String?
|
|
@@ -266,9 +269,106 @@ model WaitList {
|
|
|
266
269
|
useCase String?
|
|
267
270
|
consentToUpdates Boolean
|
|
268
271
|
|
|
269
|
-
referralCode
|
|
270
|
-
referredBy
|
|
272
|
+
referralCode String? @unique // the code this user can share
|
|
273
|
+
referredBy String? // stores the referral code of the person who invited them
|
|
271
274
|
|
|
272
275
|
createdAt DateTime @default(now())
|
|
273
276
|
updatedAt DateTime @updatedAt
|
|
274
|
-
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/// Represents a queued job for async processing
|
|
280
|
+
model Job {
|
|
281
|
+
id String @id @default(uuid())
|
|
282
|
+
type String // e.g. "email", "workflow_step", "ai_generation"
|
|
283
|
+
status String @default("pending") // pending, processing, success, failed, canceled
|
|
284
|
+
payload Json // arbitrary job data
|
|
285
|
+
retries Int @default(0)
|
|
286
|
+
maxRetries Int @default(3)
|
|
287
|
+
error String?
|
|
288
|
+
scheduledAt DateTime? // optional delayed job
|
|
289
|
+
startedAt DateTime?
|
|
290
|
+
finishedAt DateTime?
|
|
291
|
+
|
|
292
|
+
createdAt DateTime @default(now())
|
|
293
|
+
updatedAt DateTime @updatedAt
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/// Represents a user-created workflow (automation, pipeline, etc.)
|
|
297
|
+
model Workflow {
|
|
298
|
+
id String @id @default(uuid())
|
|
299
|
+
name String
|
|
300
|
+
description String?
|
|
301
|
+
status String @default("active") // draft, active, paused, archived
|
|
302
|
+
userId String // owner
|
|
303
|
+
workspaceId String? // optional workspace context
|
|
304
|
+
|
|
305
|
+
user User @relation(fields: [userId], references: [id])
|
|
306
|
+
workspace Workspace? @relation(fields: [workspaceId], references: [id])
|
|
307
|
+
steps WorkflowStep[]
|
|
308
|
+
|
|
309
|
+
createdAt DateTime @default(now())
|
|
310
|
+
updatedAt DateTime @updatedAt
|
|
311
|
+
WorkflowRun WorkflowRun[]
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/// Individual step inside a workflow
|
|
315
|
+
model WorkflowStep {
|
|
316
|
+
id String @id @default(uuid())
|
|
317
|
+
workflowId String
|
|
318
|
+
type String // e.g. "ai_agent", "http_request", "email", "integration_action"
|
|
319
|
+
config Json // JSON definition of the step (inputs, outputs, etc.)
|
|
320
|
+
order Int
|
|
321
|
+
status String @default("active")
|
|
322
|
+
|
|
323
|
+
workflow Workflow @relation(fields: [workflowId], references: [id])
|
|
324
|
+
|
|
325
|
+
createdAt DateTime @default(now())
|
|
326
|
+
updatedAt DateTime @updatedAt
|
|
327
|
+
WorkflowStepRun WorkflowStepRun[]
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/// Execution of a workflow instance
|
|
331
|
+
model WorkflowRun {
|
|
332
|
+
id String @id @default(uuid())
|
|
333
|
+
workflowId String
|
|
334
|
+
status String @default("running") // running, success, failed, canceled
|
|
335
|
+
input Json?
|
|
336
|
+
output Json?
|
|
337
|
+
error String?
|
|
338
|
+
|
|
339
|
+
startedAt DateTime @default(now())
|
|
340
|
+
finishedAt DateTime?
|
|
341
|
+
|
|
342
|
+
workflow Workflow @relation(fields: [workflowId], references: [id])
|
|
343
|
+
steps WorkflowStepRun[]
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/// Execution log for a specific workflow step
|
|
347
|
+
model WorkflowStepRun {
|
|
348
|
+
id String @id @default(uuid())
|
|
349
|
+
workflowRunId String
|
|
350
|
+
workflowStepId String
|
|
351
|
+
status String @default("pending")
|
|
352
|
+
input Json?
|
|
353
|
+
output Json?
|
|
354
|
+
error String?
|
|
355
|
+
|
|
356
|
+
startedAt DateTime?
|
|
357
|
+
finishedAt DateTime?
|
|
358
|
+
|
|
359
|
+
workflowRun WorkflowRun @relation(fields: [workflowRunId], references: [id])
|
|
360
|
+
workflowStep WorkflowStep @relation(fields: [workflowStepId], references: [id])
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
model Notification {
|
|
364
|
+
id String @id @default(uuid())
|
|
365
|
+
userId String?
|
|
366
|
+
type String // e.g. "workflow_failed", "subscription_updated"
|
|
367
|
+
title String
|
|
368
|
+
body String?
|
|
369
|
+
read Boolean @default(false)
|
|
370
|
+
|
|
371
|
+
createdAt DateTime @default(now())
|
|
372
|
+
|
|
373
|
+
user User? @relation(fields: [userId], references: [id])
|
|
374
|
+
}
|