@danielcok17/prisma-db 1.20.23 → 1.20.24

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": "@danielcok17/prisma-db",
3
- "version": "1.20.23",
3
+ "version": "1.20.24",
4
4
  "description": "Shared Prisma schema for Legal AI applications",
5
5
  "repository": {
6
6
  "type": "git",
package/prisma/app.prisma CHANGED
@@ -952,6 +952,17 @@ enum IndexingJobStatus {
952
952
  FAILED
953
953
  }
954
954
 
955
+ // Paid AI operations on customer files (indexing + user-file search), tracked
956
+ // for an admin-only cost overview.
957
+ enum FileOperationType {
958
+ OCR // text extraction from images / scanned PDFs
959
+ EMBEDDING // vector embedding of summary cards at index time
960
+ CARD_GEN // LLM summary-card generation
961
+ SEARCH_EMBEDDING // query embedding during user-file search
962
+ RERANK // reranker call during user-file search
963
+ ANSWER // LLM answer over user files
964
+ }
965
+
955
966
  enum FolderType {
956
967
  PERSONAL
957
968
  MATTER
@@ -1393,6 +1404,37 @@ model FileIndexingJob {
1393
1404
  @@index([createdAt])
1394
1405
  }
1395
1406
 
1407
+ // Append-only ledger of paid AI operations on customer files. Scalar fileId/
1408
+ // userId (no relations) so cost records survive file/user deletion for accounting.
1409
+ model FileOperationCost {
1410
+ id String @id @default(cuid())
1411
+ userId String
1412
+ fileId String? // null for search/answer ops not tied to one file
1413
+ conversationId String? // set for SEARCH_EMBEDDING / RERANK / ANSWER
1414
+
1415
+ operationType FileOperationType
1416
+ provider String // openai | mistral | google | gemini | cohere
1417
+ model String? // e.g. text-embedding-3-large, mistral-ocr-latest
1418
+
1419
+ costUsd Float @default(0)
1420
+ estimated Boolean @default(true) // false = actual usage from provider
1421
+
1422
+ inputTokens Int?
1423
+ outputTokens Int?
1424
+ totalTokens Int?
1425
+ pages Int? // OCR pages
1426
+ units Int? // generic unit count (embedded docs, chars, etc.)
1427
+ durationMs Int?
1428
+
1429
+ createdAt DateTime @default(now())
1430
+
1431
+ @@index([userId])
1432
+ @@index([fileId])
1433
+ @@index([operationType])
1434
+ @@index([createdAt])
1435
+ @@index([userId, createdAt])
1436
+ }
1437
+
1396
1438
  model FileDeadline {
1397
1439
  id String @id @default(cuid())
1398
1440
  fileId String
@@ -0,0 +1,39 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "FileOperationType" AS ENUM ('OCR', 'EMBEDDING', 'CARD_GEN', 'SEARCH_EMBEDDING', 'RERANK', 'ANSWER');
3
+
4
+ -- CreateTable
5
+ CREATE TABLE "FileOperationCost" (
6
+ "id" TEXT NOT NULL,
7
+ "userId" TEXT NOT NULL,
8
+ "fileId" TEXT,
9
+ "conversationId" TEXT,
10
+ "operationType" "FileOperationType" NOT NULL,
11
+ "provider" TEXT NOT NULL,
12
+ "model" TEXT,
13
+ "costUsd" DOUBLE PRECISION NOT NULL DEFAULT 0,
14
+ "estimated" BOOLEAN NOT NULL DEFAULT true,
15
+ "inputTokens" INTEGER,
16
+ "outputTokens" INTEGER,
17
+ "totalTokens" INTEGER,
18
+ "pages" INTEGER,
19
+ "units" INTEGER,
20
+ "durationMs" INTEGER,
21
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
22
+
23
+ CONSTRAINT "FileOperationCost_pkey" PRIMARY KEY ("id")
24
+ );
25
+
26
+ -- CreateIndex
27
+ CREATE INDEX "FileOperationCost_userId_idx" ON "FileOperationCost"("userId");
28
+
29
+ -- CreateIndex
30
+ CREATE INDEX "FileOperationCost_fileId_idx" ON "FileOperationCost"("fileId");
31
+
32
+ -- CreateIndex
33
+ CREATE INDEX "FileOperationCost_operationType_idx" ON "FileOperationCost"("operationType");
34
+
35
+ -- CreateIndex
36
+ CREATE INDEX "FileOperationCost_createdAt_idx" ON "FileOperationCost"("createdAt");
37
+
38
+ -- CreateIndex
39
+ CREATE INDEX "FileOperationCost_userId_createdAt_idx" ON "FileOperationCost"("userId", "createdAt");