Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat(ee): add redactions

Marc Seitz0a62004a2a8f
diff --git a/components/documents/document-header.tsx b/components/documents/document-header.tsx
index e1504619..00fc8905 100644
--- a/components/documents/document-header.tsx
+++ b/components/documents/document-header.tsx
@@ -1,3 +1,4 @@
+import dynamic from "next/dynamic";
import Link from "next/link";
import { useRouter } from "next/router";
@@ -19,6 +20,7 @@ import {
FolderIcon,
FolderInputIcon,
MoonIcon,
+ ScanEyeIcon,
ServerIcon,
SheetIcon,
SunIcon,
@@ -30,6 +32,7 @@ import { toast } from "sonner";
import { mutate } from "swr";
import { getFile } from "@/lib/files/get-file";
+import { useFeatureFlags } from "@/lib/hooks/use-feature-flags";
import { useSelfMembership } from "@/lib/hooks/use-self-membership";
import { usePlan } from "@/lib/swr/use-billing";
import useDataroomsSimple from "@/lib/swr/use-datarooms-simple";
@@ -66,6 +69,24 @@ import {
import PlanBadge from "../billing/plan-badge";
import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
+
+// Redaction dialogs are only opened on demand from the 3-dot menu. Dynamic
+// imports keep their (lucide + radix + feature code) off the document-page
+// initial bundle.
+const RedactionJobsDialog = dynamic(
+ () =>
+ import("@/ee/features/redaction/components/redaction-jobs-dialog").then(
+ (mod) => ({ default: mod.RedactionJobsDialog }),
+ ),
+ { ssr: false },
+);
+const RedactionConfigDialog = dynamic(
+ () =>
+ import("@/ee/features/redaction/components/redaction-config-dialog").then(
+ (mod) => ({ default: mod.RedactionConfigDialog }),
+ ),
+ { ssr: false },
+);
import AdvancedSheet from "../shared/icons/advanced-sheet";
import PortraitLandscape from "../shared/icons/portrait-landscape";
import LoadingSpinner from "../ui/loading-spinner";
@@ -111,6 +132,8 @@ export default function DocumentHeader({
theme === "light" || (theme === "system" && systemTheme === "light");
const { isPro, isFree, isTrial, isBusiness, isDatarooms } = usePlan();
const { canUseAI, isAIEnabled } = useTeamAI();
+ const { isFeatureEnabled } = useFeatureFlags();
+ const isRedactionEnabled = isFeatureEnabled("redaction");
const [isEditingName, setIsEditingName] = useState<boolean>(false);
const [menuOpen, setMenuOpen] = useState<boolean>(false);
const [isFirstClick, setIsFirstClick] = useState<boolean>(false);
@@ -119,6 +142,8 @@ export default function DocumentHeader({
const [moveFolderOpen, setMoveFolderOpen] = useState<boolean>(false);
const [addDocumentVersion, setAddDocumentVersion] = useState<boolean>(false);
const [openAddDocModal, setOpenAddDocModal] = useState<boolean>(false);
+ const [redactionJobsOpen, setRedactionJobsOpen] = useState<boolean>(false);
+ const [redactionConfigOpen, setRedactionConfigOpen] = useState<boolean>(false);
const [planModalOpen, setPlanModalOpen] = useState<boolean>(false);
const [planModalTrigger, setPlanModalTrigger] = useState<string>("");
const [selectedPlan, setSelectedPlan] = useState<PlanEnum>(PlanEnum.Pro);
@@ -811,6 +836,19 @@ export default function DocumentHeader({
</DropdownMenuItem>
)}
+ {/* Redaction jobs - beta, PDFs only */}
+ {isRedactionEnabled && primaryVersion.type === "pdf" ? (
+ <DropdownMenuItem
+ onClick={() => {
+ setRedactionJobsOpen(true);
+ setMenuOpen(false);
+ }}
+ >
+ <ScanEyeIcon className="mr-2 h-4 w-4" />
+ Redaction jobs
+ </DropdownMenuItem>
+ ) : null}
+
{onBulkImportLinks && (
<DropdownMenuItem
onClick={() => {
@@ -1137,6 +1175,28 @@ export default function DocumentHeader({
agentsEnabled={prismaDocument.agentsEnabled}
vectorStoreFileId={primaryVersion.vectorStoreFileId}
/>
+
+ {isRedactionEnabled && primaryVersion.type === "pdf" ? (
+ <>
+ {redactionJobsOpen ? (
+ <RedactionJobsDialog
+ open={redactionJobsOpen}
+ onOpenChange={setRedactionJobsOpen}
+ documentId={prismaDocument.id}
+ documentName={prismaDocument.name}
+ onStartNew={() => setRedactionConfigOpen(true)}
+ />
+ ) : null}
+ {redactionConfigOpen ? (
+ <RedactionConfigDialog
+ open={redactionConfigOpen}
+ onOpenChange={setRedactionConfigOpen}
+ documentId={prismaDocument.id}
+ documentName={prismaDocument.name}
+ />
+ ) : null}
+ </>
+ ) : null}
</header>
);
}
diff --git a/lib/featureFlags/index.ts b/lib/featureFlags/index.ts
index cf9de2e5..914d7bf2 100644
--- a/lib/featureFlags/index.ts
+++ b/lib/featureFlags/index.ts
@@ -17,6 +17,7 @@ export type BetaFeatures =
| "ai"
| "sso"
| "textSelection"
+ | "redaction"
| "requestList"
| "logoOnAccessForm";
@@ -40,6 +41,7 @@ export const getFeatureFlags = async ({ teamId }: { teamId?: string }) => {
ai: false,
sso: false,
textSelection: false,
+ redaction: false,
requestList: false,
logoOnAccessForm: false,
};
diff --git a/lib/trigger/queues.ts b/lib/trigger/queues.ts
index 8cf4ce89..9ba3e0d6 100644
--- a/lib/trigger/queues.ts
+++ b/lib/trigger/queues.ts
@@ -49,6 +49,17 @@ export const addFileToVectorStoreQueue = queue({
concurrencyLimit: 10,
});
+// Redaction queues
+export const detectRedactionsQueue = queue({
+ name: "detect-redactions",
+ concurrencyLimit: 5,
+});
+
+export const applyRedactionsQueue = queue({
+ name: "apply-redactions",
+ concurrencyLimit: 5,
+});
+
// Plan-based conversion queues (used at trigger time)
const concurrencyConfig: Record<string, number> = {
free: 1,
diff --git a/package-lock.json b/package-lock.json
index dc42157d..b6c01006 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -69,9 +69,9 @@
"@tiptap/react": "^3.22.5",
"@tiptap/starter-kit": "^3.22.5",
"@tremor/react": "^3.18.7",
- "@trigger.dev/python": "4.5.3",
- "@trigger.dev/react-hooks": "4.5.3",
- "@trigger.dev/sdk": "4.5.3",
+ "@trigger.dev/python": "4.5.5",
+ "@trigger.dev/react-hooks": "4.5.5",
+ "@trigger.dev/sdk": "4.5.5",
"@tus/s3-store": "^1.9.1",
"@tus/server": "^1.10.2",
"@tus/utils": "^0.5.1",
@@ -167,7 +167,7 @@
"devDependencies": {
"@react-email/ui": "^6.3.2",
"@tailwindcss/forms": "^0.5.11",
- "@trigger.dev/build": "4.5.3",
+ "@trigger.dev/build": "4.5.5",
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
"@types/bcryptjs": "^2.4.6",
"@types/cookie": "^0.6.0",
@@ -9232,13 +9232,13 @@
}
},
"node_modules/@trigger.dev/build": {
- "version": "4.5.3",
- "resolved": "https://registry.npmjs.org/@trigger.dev/build/-/build-4.5.3.tgz",
- "integrity": "sha512-O4DtEgi2DYvopSpSApubrf4xajmarZI619LSB1IA5Bs93icIhkJqqQCQ1SHrh84NxJ46GTdpbUlBfE+jKokkrQ==",
+ "version": "4.5.5",
+ "resolved": "https://registry.npmjs.org/@trigger.dev/build/-/build-4.5.5.tgz",
+ "integrity": "sha512-OHEAUyStIxO77fC4o9p31pEg7PxNOZx5VVgIvlzy+YDdj26Qx1zY7A9OCCHT2LFquInZmMvIxvrmaVsx+lR0VA==",
"license": "MIT",
"dependencies": {
"@prisma/config": "^6.10.0",
- "@trigger.dev/core": "4.5.3",
+ "@trigger.dev/core": "4.5.5",
"mlly": "^1.7.1",
"pkg-types": "^1.1.3",
"resolve": "^1.22.8",
@@ -9250,9 +9250,9 @@
}
},
"node_modules/@trigger.dev/core": {
- "version": "4.5.3",
- "resolved": "https://registry.npmjs.org/@trigger.dev/core/-/core-4.5.3.tgz",
- "integrity": "sha512-xtVvpQIDKIKWcWW4obdb5pXlhTxVKQL3ZvRlcY8K1LARlNhn++j3j0O1KZN7llVF5Rd7tAGGgkBE7948IGuYXA==",
+ "version": "4.5.5",
+ "resolved": "https://registry.npmjs.org/@trigger.dev/core/-/core-4.5.5.tgz",
+ "integrity": "sha512-LKShPW6b049PRJ03ZOWuWXQ7d6gIS+LTrni6W3V87AXJEkp9+qwsboe2oelmQk8uHVk8QYk6CLItENkrofhvag==",
"license": "MIT",
"dependencies": {
"@bugsnag/cuid": "^3.1.1",
@@ -9490,29 +9490,29 @@
}
},
"node_modules/@trigger.dev/python": {
- "version": "4.5.3",
- "resolved": "https://registry.npmjs.org/@trigger.dev/python/-/python-4.5.3.tgz",
- "integrity": "sha512-IDjIXfpF0n4GkJ33QFz/XIbv7+csTs0ZPe4y6r/eNAozbfcO16XgFkqPu/nIipaYHYTiO6Ipa5iyCm+5YTeXrQ==",
+ "version": "4.5.5",
+ "resolved": "https://registry.npmjs.org/@trigger.dev/python/-/python-4.5.5.tgz",
+ "integrity": "sha512-iMK26IPOi9n99Z7bdFk/67H1uhQG69cRi1LBjbTzeaMIq9uxvj0Zt0SNBh2TO3/d1pg0ogQgm5qSJrYwfnb/7w==",
"license": "MIT",
"dependencies": {
- "@trigger.dev/core": "4.5.3",
+ "@trigger.dev/core": "4.5.5",
"tinyexec": "^0.3.2"
},
"engines": {
"node": ">=18.20.0"
},
"peerDependencies": {
- "@trigger.dev/build": "^4.5.3",
- "@trigger.dev/sdk": "^4.5.3"
+ "@trigger.dev/build": "^4.5.5",
+ "@trigger.dev/sdk": "^4.5.5"
}
},
"node_modules/@trigger.dev/react-hooks": {
- "version": "4.5.3",
- "resolved": "https://registry.npmjs.org/@trigger.dev/react-hooks/-/react-hooks-4.5.3.tgz",
- "integrity": "sha512-3LDZdQIbUXaLAAyGjKq/JGiBCPQ1kGHp+TSfQWa5aWa5pWaHtZ47t7EIfdvWNCxOmsjNuC2Sf3rPm35Cin3xRQ==",
+ "version": "4.5.5",
+ "resolved": "https://registry.npmjs.org/@trigger.dev/react-hooks/-/react-hooks-4.5.5.tgz",
+ "integrity": "sha512-hEXzILWQrOxUamTqjQWLU1xYTi96+Nx6hwI25MVGE2eFuODo3ykQdSjQEM05AfkfHI1ktH5Q07ZksE3xfeorWQ==",
"license": "MIT",
"dependencies": {
- "@trigger.dev/core": "^4.5.3",
+ "@trigger.dev/core": "^4.5.5",
"swr": "^2.2.5"
},
"engines": {
@@ -9524,14 +9524,14 @@
}
},
"node_modules/@trigger.dev/sdk": {
- "version": "4.5.3",
- "resolved": "https://registry.npmjs.org/@trigger.dev/sdk/-/sdk-4.5.3.tgz",
- "integrity": "sha512-yzeeBk8V1px1fmOMmugXFlbkADyFnh3eJFRVuA3TKyUF4veZ1WgOWX7bzx0wBT5RnyLZmA6at/laXL8NmNmqaA==",
+ "version": "4.5.5",
+ "resolved": "https://registry.npmjs.org/@trigger.dev/sdk/-/sdk-4.5.5.tgz",
+ "integrity": "sha512-4aJDjJe+l3rxOqSUlLAjQB9aCyuGd0ABH8ASxfLXZeU65pJ0pVh51NJTaAH5NdYitBbFnLjm/dSZN79u+Z0y2w==",
"license": "MIT",
"dependencies": {
"@opentelemetry/api": "1.9.1",
"@opentelemetry/semantic-conventions": "1.41.1",
- "@trigger.dev/core": "4.5.3",
+ "@trigger.dev/core": "4.5.5",
"chalk": "^5.2.0",
"cronstrue": "^2.21.0",
"debug": "^4.3.4",
@@ -23552,9 +23552,9 @@
}
},
"node_modules/systeminformation": {
- "version": "5.31.16",
- "resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.31.16.tgz",
- "integrity": "sha512-37NsFaeaqwYxanLgdJAGWj8OXIRgvSBsDXGhlC0uUoHyl9nf4HrNsZjqtQ9Gc99bj9FQpffzYccPVuQ6gpjfqg==",
+ "version": "5.33.0",
+ "resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.33.0.tgz",
+ "integrity": "sha512-0LYSL01CCbjVeJG7iXI8fUCFU76zMjzbHd/EU3or4QpSFYCLMgslR11prwHuA3siz5jmOkqoLhjgOyDRmXBKmA==",
"license": "MIT",
"os": [
"darwin",
@@ -23570,7 +23570,7 @@
"systeminformation": "lib/cli.js"
},
"engines": {
- "node": ">=8.0.0"
+ "node": ">=10.0.0"
},
"funding": {
"type": "Buy me a coffee",
diff --git a/package.json b/package.json
index 4bfe490e..65289e33 100644
--- a/package.json
+++ b/package.json
@@ -81,9 +81,9 @@
"@tiptap/react": "^3.22.5",
"@tiptap/starter-kit": "^3.22.5",
"@tremor/react": "^3.18.7",
- "@trigger.dev/python": "4.5.3",
- "@trigger.dev/react-hooks": "4.5.3",
- "@trigger.dev/sdk": "4.5.3",
+ "@trigger.dev/python": "4.5.5",
+ "@trigger.dev/react-hooks": "4.5.5",
+ "@trigger.dev/sdk": "4.5.5",
"@tus/s3-store": "^1.9.1",
"@tus/server": "^1.10.2",
"@tus/utils": "^0.5.1",
@@ -179,7 +179,7 @@
"devDependencies": {
"@react-email/ui": "^6.3.2",
"@tailwindcss/forms": "^0.5.11",
- "@trigger.dev/build": "4.5.3",
+ "@trigger.dev/build": "4.5.5",
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
"@types/bcryptjs": "^2.4.6",
"@types/cookie": "^0.6.0",
diff --git a/pages/api/file/s3/get-presigned-get-url-proxy.ts b/pages/api/file/s3/get-presigned-get-url-proxy.ts
index 77189419..61d3f173 100644
--- a/pages/api/file/s3/get-presigned-get-url-proxy.ts
+++ b/pages/api/file/s3/get-presigned-get-url-proxy.ts
@@ -20,8 +20,9 @@ export default async function handler(
return res.status(401).json({ message: "Unauthorized" });
}
- const { key, responseContentDisposition } = req.body as {
+ const { key, expiresIn, responseContentDisposition } = req.body as {
key: string;
+ expiresIn?: number;
responseContentDisposition?: string;
};
@@ -68,6 +69,7 @@ export default async function handler(
},
body: JSON.stringify({
key,
+ ...(expiresIn ? { expiresIn } : {}),
...(responseContentDisposition ? { responseContentDisposition } : {}),
}),
},
diff --git a/pages/documents/[id]/index.tsx b/pages/documents/[id]/index.tsx
index 686633d3..17175f91 100644
--- a/pages/documents/[id]/index.tsx
+++ b/pages/documents/[id]/index.tsx
@@ -5,6 +5,7 @@ import ErrorPage from "next/error";
import { Suspense, useState } from "react";
import { useTeam } from "@/context/team-context";
+import { RedactionLauncher } from "@/ee/features/redaction/components/redaction-launcher";
import { PlanEnum } from "@/ee/stripe/constants";
import { useDocumentLinks } from "@/lib/swr/use-document";
@@ -185,6 +186,12 @@ export default function DocumentPage() {
showTooltip
className="h-8 whitespace-nowrap text-xs lg:h-9 lg:text-sm"
/>,
+ <RedactionLauncher
+ key={"redaction-launcher"}
+ documentId={prismaDocument.id}
+ documentName={prismaDocument.name}
+ documentType={primaryVersion.type}
+ />,
<AddLinkButton key={"create-link"} />,
]}
/>
diff --git a/pages/documents/[id]/redactions/[jobId].tsx b/pages/documents/[id]/redactions/[jobId].tsx
new file mode 100644
index 00000000..5c18423e
--- /dev/null
+++ b/pages/documents/[id]/redactions/[jobId].tsx
@@ -0,0 +1,41 @@
+import { useRouter } from "next/router";
+
+import { RedactionWorkspace } from "@/ee/features/redaction/components/redaction-workspace";
+
+import { useDocumentOverview } from "@/lib/swr/use-document-overview";
+
+import AppLayout from "@/components/layouts/app";
+import LoadingSpinner from "@/components/ui/loading-spinner";
+
+/**
+ * Full-page redaction workspace.
+ *
+ * The detection and apply phases run in background Trigger.dev tasks, so this
+ * page is safe to close and revisit at any time — the job state lives on the
+ * `DocumentRedactionJob` row and real-time progress is re-subscribed on load.
+ */
+export default function DocumentRedactionJobPage() {
+ const router = useRouter();
+ const { id, jobId } = router.query as { id?: string; jobId?: string };
+ const { document: prismaDocument, loading } = useDocumentOverview();
+
+ if (!id || !jobId || loading || !prismaDocument) {
+ return (
+ <AppLayout>
+ <div className="flex h-[calc(100vh-4rem)] items-center justify-center">
+ <LoadingSpinner className="h-10 w-10" />
+ </div>
+ </AppLayout>
+ );
+ }
+
+ return (
+ <AppLayout>
+ <RedactionWorkspace
+ documentId={id}
+ documentName={prismaDocument.name}
+ jobId={jobId}
+ />
+ </AppLayout>
+ );
+}
diff --git a/prisma/migrations/20260424000000_add_redactions_model/migration.sql b/prisma/migrations/20260424000000_add_redactions_model/migration.sql
new file mode 100644
index 00000000..51f30263
--- /dev/null
+++ b/prisma/migrations/20260424000000_add_redactions_model/migration.sql
@@ -0,0 +1,77 @@
+-- CreateTable
+CREATE TABLE "DocumentRedaction" (
+ "id" TEXT NOT NULL,
+ "jobId" TEXT NOT NULL,
+ "pageNumber" INTEGER NOT NULL,
+ "x" DOUBLE PRECISION NOT NULL,
+ "y" DOUBLE PRECISION NOT NULL,
+ "width" DOUBLE PRECISION NOT NULL,
+ "height" DOUBLE PRECISION NOT NULL,
+ "category" TEXT,
+ "confidence" TEXT,
+ "reason" TEXT,
+ "source" TEXT NOT NULL DEFAULT 'AI',
+ "status" TEXT NOT NULL DEFAULT 'PENDING',
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "updatedAt" TIMESTAMP(3) NOT NULL,
+ "textPreview" TEXT,
+
+ CONSTRAINT "DocumentRedaction_pkey" PRIMARY KEY ("id")
+);
+
+-- CreateTable
+CREATE TABLE "DocumentRedactionJob" (
+ "id" TEXT NOT NULL,
+ "documentId" TEXT NOT NULL,
+ "documentVersionId" TEXT NOT NULL,
+ "teamId" TEXT NOT NULL,
+ "createdById" TEXT NOT NULL,
+ "status" TEXT NOT NULL DEFAULT 'PENDING',
+ "customTerms" TEXT[],
+ "reasons" TEXT[],
+ "resultVersionId" TEXT,
+ "error" TEXT,
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "updatedAt" TIMESTAMP(3) NOT NULL,
+ "applyRunId" TEXT,
+ "detectRunId" TEXT,
+
+ CONSTRAINT "DocumentRedactionJob_pkey" PRIMARY KEY ("id")
+);
+
+-- CreateIndex
+CREATE INDEX "DocumentRedaction_jobId_idx" ON "DocumentRedaction"("jobId" ASC);
+
+-- CreateIndex
+CREATE INDEX "DocumentRedaction_jobId_pageNumber_idx" ON "DocumentRedaction"("jobId" ASC, "pageNumber" ASC);
+
+-- CreateIndex
+CREATE INDEX "DocumentRedaction_jobId_status_idx" ON "DocumentRedaction"("jobId" ASC, "status" ASC);
+
+-- CreateIndex
+CREATE INDEX "DocumentRedactionJob_documentId_idx" ON "DocumentRedactionJob"("documentId" ASC);
+
+-- CreateIndex
+CREATE INDEX "DocumentRedactionJob_documentVersionId_idx" ON "DocumentRedactionJob"("documentVersionId" ASC);
+
+-- CreateIndex
+CREATE INDEX "DocumentRedactionJob_teamId_idx" ON "DocumentRedactionJob"("teamId" ASC);
+
+-- CreateIndex
+CREATE INDEX "DocumentRedactionJob_teamId_status_idx" ON "DocumentRedactionJob"("teamId" ASC, "status" ASC);
+
+-- AddForeignKey
+ALTER TABLE "DocumentRedaction" ADD CONSTRAINT "DocumentRedaction_jobId_fkey" FOREIGN KEY ("jobId") REFERENCES "DocumentRedactionJob"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "DocumentRedactionJob" ADD CONSTRAINT "DocumentRedactionJob_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "DocumentRedactionJob" ADD CONSTRAINT "DocumentRedactionJob_documentId_fkey" FOREIGN KEY ("documentId") REFERENCES "Document"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "DocumentRedactionJob" ADD CONSTRAINT "DocumentRedactionJob_documentVersionId_fkey" FOREIGN KEY ("documentVersionId") REFERENCES "DocumentVersion"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "DocumentRedactionJob" ADD CONSTRAINT "DocumentRedactionJob_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+
diff --git a/prisma/schema/document.prisma b/prisma/schema/document.prisma
index dacc2f82..e2983740 100644
--- a/prisma/schema/document.prisma
+++ b/prisma/schema/document.prisma
@@ -27,9 +27,10 @@ model Document {
folderId String? // Optional Folder ID for documents in folders
folder Folder? @relation(fields: [folderId], references: [id], onDelete: SetNull)
- datarooms DataroomDocument[] // Datarooms associated with this document
- tags TagItem[]
- annotations DocumentAnnotation[] // Annotations for this document
+ datarooms DataroomDocument[] // Datarooms associated with this document
+ tags TagItem[]
+ annotations DocumentAnnotation[] // Annotations for this document
+ redactionJobs DocumentRedactionJob[] // Redaction jobs for this document
// upload external documents
uploadedDocument DocumentUpload[]
@@ -60,6 +61,7 @@ model DocumentVersion {
fileId String? // This is the file ID of the OpenAI File API
vectorStoreFileId String? // OpenAI vector store file ID for AI search
pages DocumentPage[]
+ redactionJobs DocumentRedactionJob[] // Redaction jobs that target this version
hasPages Boolean @default(false) // Indicates if the document has pages
length Int? // This is the length of the video in seconds
createdAt DateTime @default(now())
diff --git a/prisma/schema/redaction.prisma b/prisma/schema/redaction.prisma
new file mode 100644
index 00000000..882110fa
--- /dev/null
+++ b/prisma/schema/redaction.prisma
@@ -0,0 +1,56 @@
+model DocumentRedactionJob {
+ id String @id @default(cuid())
+ documentId String
+ document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)
+ documentVersionId String
+ documentVersion DocumentVersion @relation(fields: [documentVersionId], references: [id], onDelete: Cascade)
+ teamId String
+ team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
+ createdById String
+ createdBy User @relation(fields: [createdById], references: [id])
+ status String @default("PENDING") // Validated via Zod: PENDING | DETECTING | REVIEW | APPLYING | APPLIED | FAILED
+ customTerms String[]
+ reasons String[] // Validated via Zod: PRIVACY | GDPR | CPRA | STRATEGIC | COMMERCIAL | OTHER
+ resultVersionId String? // The DocumentVersion that was produced after APPLY
+ error String?
+ // Trigger.dev run ids so the UI can resubscribe to progress after a refresh
+ // or when the job is reopened from the 3-dot menu.
+ detectRunId String?
+ applyRunId String?
+ redactions DocumentRedaction[]
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
+
+ @@index([documentId])
+ @@index([documentVersionId])
+ @@index([teamId])
+ @@index([teamId, status])
+}
+
+model DocumentRedaction {
+ id String @id @default(cuid())
+ jobId String
+ job DocumentRedactionJob @relation(fields: [jobId], references: [id], onDelete: Cascade)
+ pageNumber Int
+ // Coordinates are stored on Gemini's normalized 0-1000 scale.
+ x Float
+ y Float
+ width Float
+ height Float
+ // A masked preview of the detected text (e.g. "Jo••••oe"). We deliberately
+ // do NOT store the raw PII value that Gemini returned — that plaintext only
+ // lives in memory long enough to be used for the post-redaction assertion
+ // in apply-redactions. Keep this short (≤32 chars) so indexes stay small.
+ textPreview String?
+ category String? // Validated via Zod: PII_NAME | PII_EMAIL | PII_PHONE | PII_SSN | PII_ADDRESS | PII_TAX_ID | PII_ACCOUNT_NUMBER | CUSTOM_TERM | IMAGE | OTHER
+ confidence String? // LOW | MEDIUM | HIGH
+ reason String?
+ source String @default("AI") // AI | MANUAL
+ status String @default("PENDING") // PENDING | ACCEPTED | DECLINED | APPLIED
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
+
+ @@index([jobId])
+ @@index([jobId, pageNumber])
+ @@index([jobId, status])
+}
diff --git a/prisma/schema/schema.prisma b/prisma/schema/schema.prisma
index 1f87edd7..60d68a68 100644
--- a/prisma/schema/schema.prisma
+++ b/prisma/schema/schema.prisma
@@ -70,6 +70,7 @@ model User {
// FAQ system
publishedFaqItems DataroomFaqItem[]
createdAnnotations DocumentAnnotation[] // Annotations created by this user
+ createdRedactionJobs DocumentRedactionJob[] // Redaction jobs created by this user
installedIntegrations InstalledIntegration[]
diff --git a/prisma/schema/team.prisma b/prisma/schema/team.prisma
index 64eaca34..21a5cc2f 100644
--- a/prisma/schema/team.prisma
+++ b/prisma/schema/team.prisma
@@ -27,6 +27,7 @@ model Team {
uploadedDocuments DocumentUpload[]
Tag Tag[]
annotations DocumentAnnotation[] // Annotations created by team members
+ redactionJobs DocumentRedactionJob[] // Redaction jobs owned by this team
installedIntegrations InstalledIntegration[]