Files
zeekayandHanzo Dev f77d5010d8 ee: delete the relocated upstream commercial code and its paywall
Papermark dual-licenses: AGPL-3.0 for the tree, a separate commercial
licence for ee/. We hold the first and not the second, so none of the
second may live here.

ee/ was already absent from main, but it was never deleted. 98f0da7fa
("ci: amd64-only build") renamed 150 files out of ee/ byte-identical
into features/, lib/billing/legacy/ (ee/stripe), lib/billing/limits/
(ee/limits), and flattened app/(ee)/ into app/ — putting commercially
licensed code under our AGPL root LICENSE. A rename is not a deletion.
Every path that commit moved is now gone, edited-since or not.

Deleted, with their routes and UI entry points: features/ai and
app/api/ai, features/workflows and app/api/{workflows,workflow-entry},
features/conversations and the Q&A/FAQ surface, features/security/sso
with app/api/auth/saml + app/api/scim + lib/jackson.ts (we use Hanzo
IAM OIDC natively), features/dataroom-invitations, features/templates,
features/access-notifications, features/conversions, features/
permissions. Five of these were gated by lib/featureFlags, which reads
@vercel/edge-config and returns false for every flag when EDGE_CONFIG
is unset — every non-Vercel deployment we run. Those flags are gone too.

Deleted the commercial gating outright rather than reimplementing it:
lib/billing/legacy (ee/stripe) and lib/billing/limits (ee/limits), the
upgrade modals and banners, UpgradeButton, FeaturePreview, PlanBadge,
the trial and blocking modals, /settings/upgrade, /settings/billing and
the billing checkout/seat/pause/cancel API. usePlan() no longer returns
capability booleans — the plan tag describes provisioning, it is not a
permission — and useLimits() is gone with every quota check it fed.
Subscription pause went the same way. Also dropped the npm dependencies
that existed only for the removed features (@boxyhq/saml-jackson, the
@ai-sdk packages, openai, streamdown, use-stick-to-bottom,
@trigger.dev/python) and the Jackson-specific next.config webpack shims.

Rewritten as original Hanzo code where a capability was load-bearing:
- lib/utils/get-file-size-limits.ts — one UPLOAD_LIMITS set plus
  getFileSizeLimit(contentType), env-overridable. Operational limits,
  not commercial ones, so the tus and browser-upload paths still refuse
  oversized files without consulting a plan matrix.
- components/links/link-sheet/permissions-sheet.tsx — a flat, depth
  annotated item list with view/download switches over the same
  /permission-groups API. Two states, not three. ItemPermission now has
  a single definition in lib/types.ts.
- app/api/links/[id]/upload/route.ts — visitor uploads, built around one
  authorize() helper shared by GET and POST, and a notification debounce
  keyed per (link, viewer) instead of listing and cancelling runs.

There is now exactly one link sheet: the ee DataroomLinkSheet duplicated
the AGPL LinkSheet, which already handled DATAROOM_LINK. Replaced
upstream's Omit<LinkType, "WORKFLOW_LINK"> — Omit on a string union
yields an object type and never narrowed anything — with a real union.

Verified: the S3/tus upload+download harness passes 13/13 against MinIO
after the deletions, and tsc goes from 257 pre-existing errors on
origin/main to 192 with zero files worse than baseline.

Reasoning recorded in LLM.md. LICENSE untouched.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-03 20:19:21 -07:00

422 lines
10 KiB
TypeScript

import {
Agreement,
CustomField,
DataroomDocument,
DataroomFolder,
Document,
DocumentVersion,
Link,
PermissionGroupAccessControls,
User as PrismaUser,
View,
ViewerGroupAccessControls,
} from "@prisma/client";
import { User as NextAuthUser } from "next-auth";
import { z } from "zod";
export type CustomUser = NextAuthUser & PrismaUser & { organization?: string };
export interface CreateUserEmailProps {
user: {
name: string | null | undefined;
email: string | null | undefined;
};
}
export interface DocumentWithLinksAndLinkCountAndViewCount extends Document {
_count: {
links: number;
views: number;
versions: number;
datarooms: number;
};
links: Link[];
folder: {
name: string;
path: string;
};
folderList: string[];
}
export interface DocumentWithVersion extends Document {
versions: DocumentVersion[];
folder: {
name: string;
path: string;
};
datarooms: {
dataroom: {
id: string;
name: string;
};
folder: {
id: string;
name: string;
path: string;
};
}[];
hasPageLinks: boolean;
}
export interface LinkWithViews extends Link {
_count: {
views: number;
};
views: View[];
feedback: { id: true; data: { question: string; type: string } } | null;
customFields: CustomField[];
tags: TagProps[];
uploadFolderName: string | undefined;
visitorGroups?: { visitorGroupId: string }[];
}
export interface LinkWithDocument extends Link {
document: Document & {
versions: {
id: string;
versionNumber: number;
type: string;
hasPages: boolean;
file: string;
isVertical: boolean;
}[];
team: {
plan: string;
} | null;
};
feedback: {
id: string;
data: {
question: string;
type: string;
};
} | null;
agreement: Agreement | null;
customFields: CustomField[];
}
export interface LinkWithDataroomDocument extends Link {
dataroomDocument: DataroomDocument & {
document: Document & {
versions: {
id: string;
versionNumber: number;
type: string;
hasPages: boolean;
file: string;
isVertical: boolean;
}[];
};
};
feedback: {
id: string;
data: {
question: string;
type: string;
};
} | null;
agreement: Agreement | null;
customFields: CustomField[];
teamId: string;
team: {
plan: string;
};
}
export interface LinkWithDataroom extends Link {
dataroom: {
id: string;
name: string;
teamId: string;
documents: {
id: string;
folderId: string | null;
updatedAt: Date;
orderIndex: number | null;
hierarchicalIndex: string | null;
document: {
id: string;
name: string;
versions: {
id: string;
versionNumber: number;
type: string;
hasPages: boolean;
file: string;
isVertical: boolean;
updatedAt: Date;
}[];
};
}[];
folders: DataroomFolder[];
lastUpdatedAt: Date;
createdAt: Date;
};
group?: {
accessControls: ViewerGroupAccessControls[];
};
accessControls?:
| ViewerGroupAccessControls[]
| PermissionGroupAccessControls[];
agreement: Agreement | null;
customFields: CustomField[];
enableIndexFile: boolean;
}
export interface Geo {
city?: string | undefined;
country?: string | undefined;
region?: string | undefined;
latitude?: string | undefined;
longitude?: string | undefined;
}
// Custom Domain Types
export type DomainVerificationStatusProps =
| "Valid Configuration"
| "Invalid Configuration"
| "Pending Verification"
| "Domain Not Found"
| "Unknown Error"
| "Conflicting DNS Records";
// From https://vercel.com/docs/rest-api/endpoints#get-a-project-domain
export interface DomainResponse {
name: string;
apexName: string;
projectId: string;
redirect?: string | null;
redirectStatusCode?: (307 | 301 | 302 | 308) | null;
gitBranch?: string | null;
updatedAt?: number;
createdAt?: number;
/** `true` if the domain is verified for use with the project. If `false` it will not be used as an alias on this project until the challenge in `verification` is completed. */
verified: boolean;
/** A list of verification challenges, one of which must be completed to verify the domain for use on the project. After the challenge is complete `POST /projects/:idOrName/domains/:domain/verify` to verify the domain. Possible challenges: - If `verification.type = TXT` the `verification.domain` will be checked for a TXT record matching `verification.value`. */
verification: {
type: string;
domain: string;
value: string;
reason: string;
}[];
}
// From https://vercel.com/docs/rest-api/endpoints#get-a-domain-s-configuration
export interface DomainConfigResponse {
/** How we see the domain's configuration. - `CNAME`: Domain has a CNAME pointing to Vercel. - `A`: Domain's A record is resolving to Vercel. - `http`: Domain is resolving to Vercel but may be behind a Proxy. - `null`: Domain is not resolving to Vercel. */
configuredBy?: ("CNAME" | "A" | "http") | null;
/** Which challenge types the domain can use for issuing certs. */
acceptedChallenges?: ("dns-01" | "http-01")[];
/** Whether or not the domain is configured AND we can automatically generate a TLS certificate. */
misconfigured: boolean;
/** conflicts */
conflicts: {
name: string;
type: string;
value: string;
}[];
}
// From https://vercel.com/docs/rest-api/endpoints#verify-project-domain
export interface DomainVerificationResponse {
name: string;
apexName: string;
projectId: string;
redirect?: string | null;
redirectStatusCode?: (307 | 301 | 302 | 308) | null;
gitBranch?: string | null;
updatedAt?: number;
createdAt?: number;
/** `true` if the domain is verified for use with the project. If `false` it will not be used as an alias on this project until the challenge in `verification` is completed. */
verified: boolean;
/** A list of verification challenges, one of which must be completed to verify the domain for use on the project. After the challenge is complete `POST /projects/:idOrName/domains/:domain/verify` to verify the domain. Possible challenges: - If `verification.type = TXT` the `verification.domain` will be checked for a TXT record matching `verification.value`. */
verification?: {
type: string;
domain: string;
value: string;
reason: string;
}[];
}
export type AnalyticsEvents =
| {
event: "User Signed Up";
userId: string;
email: string | null | undefined;
}
| {
event: "Document Added";
documentId: string;
name: string;
fileSize: string | null | undefined;
path: string | null | undefined;
}
| {
event: "Link Added";
linkId: string;
documentId: string;
customDomain: string | null | undefined;
}
| { event: "User Upgraded"; email: string | null | undefined }
| {
event: "User Signed In";
email: string | null | undefined;
}
| {
event: "Link Viewed";
documentId: string;
linkId: string;
viewerId: string;
viewerEmail: string | null | undefined;
}
| {
event: "Domain Added";
slug: string;
}
| {
event: "Domain Verified";
slug: string;
}
| {
event: "Domain Deleted";
slug: string;
}
| {
event: "Team Member Invitation Accepted";
teamId: string;
}
| {
event: "User Sign In Attempted";
email: string | undefined;
userId: string;
};
export interface Team {
id: string;
name?: string;
logo?: React.ElementType;
plan?: string;
createdAt?: Date;
enableExcelAdvancedMode?: boolean;
replicateDataroomFolders?: boolean;
}
export interface TeamDetail {
id: string;
name: string;
users: {
role: "ADMIN" | "MANAGER" | "MEMBER";
status: "ACTIVE";
teamId: string;
userId: string;
user: {
email: string;
name: string;
};
}[];
documents: {
owner: {
name: string;
id: string;
};
}[];
}
export const WatermarkConfigSchema = z.object({
text: z.string().min(1, "Text is required."),
isTiled: z.boolean(),
position: z.enum([
"top-left",
"top-center",
"top-right",
"middle-left",
"middle-center",
"middle-right",
"bottom-left",
"bottom-center",
"bottom-right",
]),
rotation: z.union([
z.literal(0),
z.literal(30),
z.literal(45),
z.literal(90),
z.literal(180),
]),
color: z.string().refine((val) => /^#([0-9A-F]{3}){1,2}$/i.test(val), {
message: "Invalid color format. Use HEX format like #RRGGBB.",
}),
fontSize: z.number().min(1, "Font size must be greater than 0."),
opacity: z.number().min(0).max(1, "Opacity must be between 0 and 1."),
});
export type WatermarkConfig = z.infer<typeof WatermarkConfigSchema>;
export type NotionTheme = "light" | "dark";
/**
* The link kinds the link sheet can create. Upstream wrote this as
* `Omit<LinkType, "WORKFLOW_LINK">`, but Omit on a string union yields an
* object type, not a narrowed union — so it never narrowed anything.
*/
export type ShareableLinkType = "DOCUMENT_LINK" | "DATAROOM_LINK";
/**
* The two kinds of thing a dataroom permission can name. Mirrors the
* `itemType` column, which the schema stores as a plain string.
*/
export const ITEM_TYPE = {
document: "DATAROOM_DOCUMENT",
folder: "DATAROOM_FOLDER",
} as const;
export type DataroomItemType = (typeof ITEM_TYPE)[keyof typeof ITEM_TYPE];
/**
* Per-item access for a dataroom, keyed by dataroom document / folder id.
* An empty map means "the whole dataroom" — the absence of restrictions,
* not the absence of access.
*/
export type ItemPermission = Record<
string,
{ view: boolean; download: boolean; itemType: DataroomItemType }
>;
export type BasePlan =
| "free"
| "pro"
| "business"
| "datarooms"
| "datarooms-plus"
| "datarooms-premium"
| "enterprise";
export const tagColors = [
"red",
"yellow",
"green",
"blue",
"purple",
"pink",
"slate",
"fuchsia",
] as const;
export type TagColorProps = (typeof tagColors)[number];
export interface TagsWithTotalCount {
tags: TagProps[];
totalCount: number;
}
export interface TagProps {
id: string;
name: string;
description: string | null;
color: TagColorProps | string;
_count?: {
items: number;
};
}