@varaos/db 1.1.5 → 1.1.6

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varaos/db",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "files": [
@@ -0,0 +1,34 @@
1
+ -- CreateTable
2
+ CREATE TABLE "public"."EmailCampaign" (
3
+ "id" TEXT NOT NULL,
4
+ "name" TEXT NOT NULL,
5
+ "templateId" TEXT NOT NULL,
6
+ "subject" TEXT NOT NULL,
7
+ "audience" TEXT NOT NULL,
8
+ "segmentFilter" JSONB,
9
+ "sentCount" INTEGER NOT NULL DEFAULT 0,
10
+ "status" TEXT NOT NULL DEFAULT 'draft',
11
+ "metadata" JSONB,
12
+ "createdById" TEXT,
13
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
14
+ "updatedAt" TIMESTAMP(3) NOT NULL,
15
+
16
+ CONSTRAINT "EmailCampaign_pkey" PRIMARY KEY ("id")
17
+ );
18
+
19
+ -- CreateTable
20
+ CREATE TABLE "public"."EmailSendLog" (
21
+ "id" TEXT NOT NULL,
22
+ "campaignId" TEXT NOT NULL,
23
+ "recipient" TEXT NOT NULL,
24
+ "status" TEXT NOT NULL,
25
+ "messageId" TEXT,
26
+ "error" TEXT,
27
+ "metadata" JSONB,
28
+ "sentAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
29
+
30
+ CONSTRAINT "EmailSendLog_pkey" PRIMARY KEY ("id")
31
+ );
32
+
33
+ -- AddForeignKey
34
+ ALTER TABLE "public"."EmailSendLog" ADD CONSTRAINT "EmailSendLog_campaignId_fkey" FOREIGN KEY ("campaignId") REFERENCES "public"."EmailCampaign"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
@@ -562,24 +562,52 @@ model Onboarding {
562
562
  user User @relation(fields: [userId], references: [id], onDelete: Cascade)
563
563
  }
564
564
 
565
-
566
-
567
565
  /////////////////////
568
566
  // Unique Visitors
569
567
  //////////////////////
570
568
  model Visitor {
571
- id String @id @default(uuid())
572
- visitorId String @unique // cookie or fingerprint ID
573
- ipAddress String?
574
- userAgent String?
575
- country String? // optional if you plan to use GeoIP later
576
- referrer String?
577
- firstVisit DateTime @default(now())
578
- lastVisit DateTime @updatedAt
579
- visitCount Int @default(1)
580
-
581
- createdAt DateTime @default(now())
582
- updatedAt DateTime @updatedAt
569
+ id String @id @default(uuid())
570
+ visitorId String @unique // cookie or fingerprint ID
571
+ ipAddress String?
572
+ userAgent String?
573
+ country String? // optional if you plan to use GeoIP later
574
+ referrer String?
575
+ firstVisit DateTime @default(now())
576
+ lastVisit DateTime @updatedAt
577
+ visitCount Int @default(1)
578
+
579
+ createdAt DateTime @default(now())
580
+ updatedAt DateTime @updatedAt
583
581
 
584
582
  @@index([createdAt])
585
- }
583
+ }
584
+
585
+ model EmailCampaign {
586
+ id String @id @default(uuid())
587
+ name String
588
+ templateId String
589
+ subject String
590
+ audience String // e.g. "waitlist", "users", "custom"
591
+ segmentFilter Json? // optional query/filter metadata
592
+ sentCount Int @default(0)
593
+ status String @default("draft") // draft | sending | sent | failed
594
+ metadata Json?
595
+ createdById String?
596
+ createdAt DateTime @default(now())
597
+ updatedAt DateTime @updatedAt
598
+
599
+ logs EmailSendLog[]
600
+ }
601
+
602
+ model EmailSendLog {
603
+ id String @id @default(uuid())
604
+ campaignId String
605
+ recipient String
606
+ status String
607
+ messageId String?
608
+ error String?
609
+ metadata Json?
610
+ sentAt DateTime @default(now())
611
+
612
+ campaign EmailCampaign @relation(fields: [campaignId], references: [id])
613
+ }