@varaos/db 1.4.3 → 1.4.5

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.4.3",
3
+ "version": "1.4.5",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "files": [
@@ -0,0 +1,21 @@
1
+ -- CreateTable
2
+ CREATE TABLE "tool_requests" (
3
+ "id" TEXT NOT NULL,
4
+ "userId" TEXT NOT NULL,
5
+ "catalogId" TEXT NOT NULL,
6
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
7
+
8
+ CONSTRAINT "tool_requests_pkey" PRIMARY KEY ("id")
9
+ );
10
+
11
+ -- CreateIndex
12
+ CREATE UNIQUE INDEX "tool_requests_userId_catalogId_key" ON "tool_requests"("userId", "catalogId");
13
+
14
+ -- CreateIndex
15
+ CREATE INDEX "tool_requests_catalogId_idx" ON "tool_requests"("catalogId");
16
+
17
+ -- AddForeignKey
18
+ ALTER TABLE "tool_requests" ADD CONSTRAINT "tool_requests_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
19
+
20
+ -- AddForeignKey
21
+ ALTER TABLE "tool_requests" ADD CONSTRAINT "tool_requests_catalogId_fkey" FOREIGN KEY ("catalogId") REFERENCES "integration_catalog"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -1,11 +1,13 @@
1
1
  generator client {
2
2
  provider = "prisma-client-js"
3
+ previewFeatures = ["postgresqlExtensions"]
3
4
  }
4
5
 
5
6
  datasource db {
6
7
  provider = "postgresql"
7
8
  url = env("DATABASE_URL")
8
9
  directUrl = env("DIRECT_URL")
10
+ extensions = [vector]
9
11
  }
10
12
 
11
13
  /// ─────────────────────────────────────────────
@@ -365,6 +367,14 @@ model User {
365
367
  memories Memory[]
366
368
  documents Document[]
367
369
 
370
+ toolRequests ToolRequest[]
371
+
372
+ /// Admin panel relations
373
+ adminSessions AdminSession[]
374
+ adminOTPs AdminOTP[]
375
+ impersonationsAsActor ImpersonationSession[] @relation("ImpersonationActor")
376
+ impersonationsAsTarget ImpersonationSession[] @relation("ImpersonationTarget")
377
+
368
378
  @@index([status])
369
379
  }
370
380
 
@@ -585,6 +595,8 @@ model IntegrationCatalog {
585
595
  updatedAt DateTime @updatedAt
586
596
  Integration Integration[]
587
597
 
598
+ toolRequests ToolRequest[]
599
+
588
600
  @@unique([provider, integration])
589
601
  @@index([status])
590
602
  @@map("integration_catalog")
@@ -600,6 +612,24 @@ model IntegrationSyncLog {
600
612
  integration Integration @relation(fields: [integrationId], references: [id])
601
613
  }
602
614
 
615
+ /// ─────────────────────────────────────────────
616
+ /// TOOL REQUESTS (User Upvotes for Upcoming Tools)
617
+ /// ─────────────────────────────────────────────
618
+
619
+ model ToolRequest {
620
+ id String @id @default(uuid())
621
+ userId String
622
+ catalogId String
623
+ createdAt DateTime @default(now())
624
+
625
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
626
+ catalog IntegrationCatalog @relation(fields: [catalogId], references: [id], onDelete: Cascade)
627
+
628
+ @@unique([userId, catalogId])
629
+ @@index([catalogId])
630
+ @@map("tool_requests")
631
+ }
632
+
603
633
  /// ─────────────────────────────────────────────
604
634
  /// AUTOMATIONS / AI / WORKFLOWS
605
635
  /// ─────────────────────────────────────────────
@@ -2025,3 +2055,57 @@ model DeadLetterJob {
2025
2055
  @@index([reviewed])
2026
2056
  @@index([createdAt])
2027
2057
  }
2058
+
2059
+
2060
+ /// ─────────────────────────────────────────────────────────────
2061
+ /// ADMIN USER MANAGEMENT (For SaaS Admin Panel)
2062
+ /// ─────────────────────────────────────────────────────────────
2063
+
2064
+ model AdminSession {
2065
+ id String @id @default(uuid())
2066
+ userId String
2067
+ token String @unique
2068
+ role Role
2069
+ ip String?
2070
+ userAgent String?
2071
+ expiresAt DateTime
2072
+ revokedAt DateTime?
2073
+ createdAt DateTime @default(now())
2074
+
2075
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
2076
+
2077
+ @@index([userId])
2078
+ @@index([token])
2079
+ }
2080
+
2081
+ model AdminOTP {
2082
+ id String @id @default(uuid())
2083
+ userId String
2084
+ code String
2085
+ used Boolean @default(false)
2086
+ expiresAt DateTime
2087
+ createdAt DateTime @default(now())
2088
+
2089
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
2090
+
2091
+ @@index([userId, used])
2092
+ }
2093
+
2094
+ model ImpersonationSession {
2095
+ id String @id @default(uuid())
2096
+ actorId String
2097
+ targetId String
2098
+ token String @unique
2099
+ reason String
2100
+ used Boolean @default(false)
2101
+ usedAt DateTime?
2102
+ expiresAt DateTime
2103
+ revokedAt DateTime?
2104
+ createdAt DateTime @default(now())
2105
+
2106
+ actor User @relation("ImpersonationActor", fields: [actorId], references: [id])
2107
+ target User @relation("ImpersonationTarget", fields: [targetId], references: [id])
2108
+
2109
+ @@index([actorId])
2110
+ @@index([targetId])
2111
+ }