Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
chore: fix merge conflicts
Marc Seitzd25d829ce8cd
diff --git a/lib/types.ts b/lib/types.tsindex 95ba66d6..17ad2410 100644--- a/lib/types.ts+++ b/lib/types.ts@@ -38,7 +38,17 @@ export interface LinkWithViews extends Link {export interface LinkWithDocument extends Link {document: Document & {- versions: { id: string; versionNumber: number; hasPages: true }[];+ versions: {+ id: string;+ versionNumber: number;+ type: string;+ hasPages: boolean;+ file: string;+ }[] & {+ team?: {+ plan: string;+ };+ };};}diff --git a/package-lock.json b/package-lock.jsonindex 5444e11f..1a79b658 100644--- a/package-lock.json+++ b/package-lock.json@@ -31,9 +31,9 @@"@stripe/stripe-js": "^2.1.7","@tailwindcss/typography": "^0.5.10","@tremor/react": "^3.11.1",- "@trigger.dev/nextjs": "^2.2.6",- "@trigger.dev/react": "^2.2.6",- "@trigger.dev/sdk": "^2.2.6",+ "@trigger.dev/nextjs": "^2.2.9",+ "@trigger.dev/react": "^2.2.9",+ "@trigger.dev/sdk": "^2.2.9","@types/node": "^20.9.0","@types/react": "^18.2.37","@types/react-dom": "^18.2.15",@@ -2483,11 +2483,11 @@}},"node_modules/@trigger.dev/core": {- "version": "2.2.6",- "resolved": "https://registry.npmjs.org/@trigger.dev/core/-/core-2.2.6.tgz",- "integrity": "sha512-4Tphi9OThYsZK38Id/qtm2ojFgtnAUdSDRUl7NqEhnamlvrOOlyhGTHHF7fAPwnPO0VjZ2MlXq/Bn3wgZ5Y/FA==",+ "version": "2.2.9",+ "resolved": "https://registry.npmjs.org/@trigger.dev/core/-/core-2.2.9.tgz",+ "integrity": "sha512-ALLG4EBVSvVwk9dC9ucWq6Qsot7s/3TrRolIk+aDKOX9AMY4jAHapIdPFYVmKWBl60U/inkHPdO/s5cmnwPJEA==","dependencies": {- "ulid": "^2.3.0",+ "ulidx": "^2.2.1","zod": "3.22.3","zod-error": "1.5.0"},@@ -2496,9 +2496,9 @@}},"node_modules/@trigger.dev/core-backend": {- "version": "2.2.6",- "resolved": "https://registry.npmjs.org/@trigger.dev/core-backend/-/core-backend-2.2.6.tgz",- "integrity": "sha512-WVfVcRIknCgkhUv53jKVEurN7MjqRZX5LodS5tHn4SjoHUQ0asJBPwMOuns+5OxYdHpe8FacGBgR5mo8jJXsLA==",+ "version": "2.2.9",+ "resolved": "https://registry.npmjs.org/@trigger.dev/core-backend/-/core-backend-2.2.9.tgz",+ "integrity": "sha512-v06ngyjLIVfa8TXAn73GKzuJjH4qYNtu2ELlOqaTp6saABmFfRSYc0iw3M8RkjVc5C+z6uJuY6Y7inFLNgVfhA==","engines": {"node": ">=18.0.0"}@@ -2512,9 +2512,9 @@}},"node_modules/@trigger.dev/nextjs": {- "version": "2.2.6",- "resolved": "https://registry.npmjs.org/@trigger.dev/nextjs/-/nextjs-2.2.6.tgz",- "integrity": "sha512-XrSUn+9wL2bOWEM75v1cYXIL4l3YVx8ExjnwR3xs+UBpaU1KTjCIKQHwAbKbHtQ+/tkEuA7FoSBxKF+La4QRdg==",+ "version": "2.2.9",+ "resolved": "https://registry.npmjs.org/@trigger.dev/nextjs/-/nextjs-2.2.9.tgz",+ "integrity": "sha512-MDa+mvED4Y2EWNLJ7Tec2cIg3iZuTvV8gxvtgWlTv765JG5QttqPjGmZ9DB5Z4DsJOV5fI+XY9mUfWHUtrWWPA==","dependencies": {"debug": "^4.3.4"},@@ -2522,17 +2522,17 @@"node": ">=18.0.0"},"peerDependencies": {- "@trigger.dev/sdk": "^2.2.6",+ "@trigger.dev/sdk": "^2.2.9","next": ">=12.0.0"}},"node_modules/@trigger.dev/react": {- "version": "2.2.6",- "resolved": "https://registry.npmjs.org/@trigger.dev/react/-/react-2.2.6.tgz",- "integrity": "sha512-7yp14e0kz8SaErM6Pa9swYh3TPPMNON9hVDFUXxVoq3YrxVoaVOws8rz7XEzhQtoVBs3L3T4ojm38NjZKYGh9Q==",+ "version": "2.2.9",+ "resolved": "https://registry.npmjs.org/@trigger.dev/react/-/react-2.2.9.tgz",+ "integrity": "sha512-Xb6n+v45uG21xksNzJ9dEHLUrwf+qaWqRdVHPXuaS5IC9nsgy0JLibX0bKEF9+oQ7i0Um9+LiI8PxEia/N4Rfw==","dependencies": {"@tanstack/react-query": "5.0.0-beta.2",- "@trigger.dev/core": "^2.2.6",+ "@trigger.dev/core": "^2.2.9","debug": "^4.3.4","zod": "3.22.3"},@@ -2549,12 +2549,12 @@}},"node_modules/@trigger.dev/sdk": {- "version": "2.2.6",- "resolved": "https://registry.npmjs.org/@trigger.dev/sdk/-/sdk-2.2.6.tgz",- "integrity": "sha512-TBSSpaOXYvIT5ji1QqjFtR512mG3cl4bpbOceZ5HPpwOIAmV35AJ0/tADkF/K4ojxIQAb0dVPVP6dheNci4BCA==",+ "version": "2.2.9",+ "resolved": "https://registry.npmjs.org/@trigger.dev/sdk/-/sdk-2.2.9.tgz",+ "integrity": "sha512-y0KZQ+paxyPN2BRNAgsNKhIdSNEdA4SZQBT48Mnso8FBgn6HADk4Oh3cdJnmupKa6Qaw8t3TCdafaVGeA/yBDg==","dependencies": {- "@trigger.dev/core": "^2.2.6",- "@trigger.dev/core-backend": "^2.2.6",+ "@trigger.dev/core": "^2.2.9",+ "@trigger.dev/core-backend": "^2.2.9","chalk": "^5.2.0","colorette": "^2.0.20","cronstrue": "^2.21.0",@@ -4423,9 +4423,9 @@"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="},"node_modules/cronstrue": {- "version": "2.41.0",- "resolved": "https://registry.npmjs.org/cronstrue/-/cronstrue-2.41.0.tgz",- "integrity": "sha512-3ZS3eMJaxMRBGmDauKCKbyIRgVcph6uSpkhSbbZvvJWkelHiSTzGJbBqmu8io7Hspd2F45bQKnC1kzoNvtku2g==",+ "version": "2.44.0",+ "resolved": "https://registry.npmjs.org/cronstrue/-/cronstrue-2.44.0.tgz",+ "integrity": "sha512-71aQD16uXrqjDUYHsFYY4/SSmEepzQZqTqWsU9x2kDMCYKyIp/5e0QW/cp2lBNO9PJB1xOpIbBJuQEa5yKx98A==","bin": {"cronstrue": "bin/cli.js"}@@ -7730,6 +7730,11 @@"language-subtag-registry": "~0.3.2"}},+ "node_modules/layerr": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/layerr/-/layerr-2.0.1.tgz",+ "integrity": "sha512-z0730CwG/JO24evdORnyDkwG1Q7b7mF2Tp1qRQ0YvrMMARbt1DFG694SOv439Gm7hYKolyZyaB49YIrYIfZBdg=="+ },"node_modules/leac": {"version": "0.6.0","resolved": "https://registry.npmjs.org/leac/-/leac-0.6.0.tgz",@@ -11507,6 +11512,17 @@"ulid": "bin/cli.js"}},+ "node_modules/ulidx": {+ "version": "2.2.1",+ "resolved": "https://registry.npmjs.org/ulidx/-/ulidx-2.2.1.tgz",+ "integrity": "sha512-DU9F5t1tihdafuNyW3fIrXUFHHiHxmwuQSGVGIbSpqkc93IH4P0dU8nPhk0gOW7ARxaFu4+P/9cxVwn6PdnIaQ==",+ "dependencies": {+ "layerr": "^2.0.1"+ },+ "engines": {+ "node": ">=16"+ }+ },"node_modules/unbox-primitive": {"version": "1.0.2","resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",diff --git a/pages/api/links/[id]/index.ts b/pages/api/links/[id]/index.tsindex 99202810..00621d6b 100644--- a/pages/api/links/[id]/index.ts+++ b/pages/api/links/[id]/index.ts@@ -36,6 +36,7 @@ export default async function handle(versionNumber: true,type: true,hasPages: true,+ file: true,},take: 1,},diff --git a/pages/api/links/domains/[...domainSlug].ts b/pages/api/links/domains/[...domainSlug].tsindex eaaa82fd..e04cd02b 100644--- a/pages/api/links/domains/[...domainSlug].ts+++ b/pages/api/links/domains/[...domainSlug].ts@@ -34,7 +34,12 @@ export default async function handle(team: { select: { plan: true } },versions: {where: { isPrimary: true },- select: { versionNumber: true },+ select: {+ versionNumber: true,+ hasPages: true,+ type: true,+ file: true,+ },take: 1,},},diff --git a/pages/view/[linkId].tsx b/pages/view/[linkId].tsxdeleted file mode 100644index 1f3e9c4d..00000000--- a/pages/view/[linkId].tsx+++ /dev/null@@ -1,89 +0,0 @@-import LoadingSpinner from "@/components/ui/loading-spinner";-import DocumentView from "@/components/view/document-view";-import { useLink } from "@/lib/swr/use-link";-import { CustomUser, LinkWithDocument } from "@/lib/types";-import NotFound from "@/pages/404";-import { GetStaticPropsContext } from "next";-import { useSession } from "next-auth/react";-import { useRouter } from "next/router";--export default function ViewPage({ link }: { link: LinkWithDocument }) {- const router = useRouter();- const { data: session, status } = useSession();-- if (!link || status === "loading" || router.isFallback) {- return (- <div className="h-screen flex items-center justify-center">- <LoadingSpinner className="h-20 w-20" />- </div>- );- }-- const {- expiresAt,- emailProtected,- password: linkPassword,- isArchived,- } = link;-- const { email: userEmail, id: userId } = (session?.user as CustomUser) || {};-- // If the link is expired, show a 404 page- if (expiresAt && new Date(expiresAt) < new Date()) {- return (- <NotFound message="Sorry, the link you're looking for is expired." />- );- }-- if (isArchived) {- return (- <NotFound message="Sorry, the file you're looking for is archived." />- );- }-- if (emailProtected || linkPassword) {- return (- <DocumentView- link={link}- userEmail={userEmail}- userId={userId}- isProtected={true}- />- );- }-- return (- <DocumentView- link={link}- userEmail={userEmail}- userId={userId}- isProtected={false}- />- );-}--export async function getStaticProps(context: GetStaticPropsContext) {- const linkId = context.params?.linkId as string;-- // Fetch the link- const res = await fetch(`${process.env.NEXTAUTH_URL}/api/links/${linkId}`);- if (!res.ok) {- return { notFound: true };- }- const link = (await res.json()) as LinkWithDocument;-- console.log(link);-- return {- props: {- link,- },- };-}--export async function getStaticPaths() {- return {- paths: [],- fallback: true,- };-}diff --git a/pages/view/[linkId]/index.tsx b/pages/view/[linkId]/index.tsxindex 203b3534..33efe1dc 100644--- a/pages/view/[linkId]/index.tsx+++ b/pages/view/[linkId]/index.tsx@@ -2,43 +2,23 @@ import LoadingSpinner from "@/components/ui/loading-spinner";import DocumentView from "@/components/view/document-view";import NotFound from "@/pages/404";import { useSession } from "next-auth/react";-import prisma from "@/lib/prisma";import { ExtendedRecordMap } from "notion-types";import notion from "@/lib/notion";-import { LinkWithDocument } from "@/lib/types";+import { CustomUser, LinkWithDocument } from "@/lib/types";import { parsePageId } from "notion-utils";+import { GetStaticPropsContext } from "next";+import { useRouter } from "next/router";-export const getStaticProps = async (context: {- params: { linkId: string };-}) => {- const linkId = context.params.linkId as string;+export const getStaticProps = async (context: GetStaticPropsContext) => {+ const { linkId } = context.params as { linkId: string };- console.log("linkId", linkId);-- const link = await prisma.link.findUnique({- where: {- id: linkId,- },- select: {- id: true,- expiresAt: true,- emailProtected: true,- allowDownload: true,- password: true,- isArchived: true,- document: {- select: {- id: true,- versions: {- where: { isPrimary: true },- select: { versionNumber: true, type: true, file: true },- take: 1,- },- },- },- },- });+ // Fetch the link+ const res = await fetch(`${process.env.NEXTAUTH_URL}/api/links/${linkId}`);+ if (!res.ok) {+ return { notFound: true };+ }+ const link = (await res.json()) as LinkWithDocument;if (!link || !link.document) {return {@@ -100,9 +80,10 @@ export default function ViewPage({recordMap: ExtendedRecordMap | null;};}) {+ const router = useRouter();const { data: session, status } = useSession();- if (!link || status === "loading") {+ if (!link || status === "loading" || router.isFallback) {return (<div className="h-screen flex items-center justify-center"><LoadingSpinner className="h-20 w-20" />@@ -117,7 +98,7 @@ export default function ViewPage({isArchived,} = link;- const { email: userEmail } = session?.user || {};+ const { email: userEmail, id: userId } = (session?.user as CustomUser) || {};// If the link is expired, show a 404 pageif (expiresAt && new Date(expiresAt) < new Date()) {@@ -137,6 +118,7 @@ export default function ViewPage({<DocumentViewlink={link}userEmail={userEmail}+ userId={userId}isProtected={true}notionData={notionData}/>@@ -147,6 +129,7 @@ export default function ViewPage({<DocumentViewlink={link}userEmail={userEmail}+ userId={userId}isProtected={false}notionData={notionData}/>diff --git a/pages/view/domains/[domain]/[slug]/index.tsx b/pages/view/domains/[domain]/[slug]/index.tsxindex d155a3e6..56d3bdac 100644--- a/pages/view/domains/[domain]/[slug]/index.tsx+++ b/pages/view/domains/[domain]/[slug]/index.tsx@@ -12,57 +12,19 @@ import { ExtendedRecordMap } from "notion-types";import notion from "@/lib/notion";import { parsePageId } from "notion-utils";-export const getStaticProps = async (context: {- params: { domain: string; slug: string };-}) => {- const domain = context.params.domain as string;- const slug = context.params.slug as string;-- console.log("domain", domain);- console.log("slug", slug);-- const link = await prisma.link.findUnique({- where: {- domainSlug_slug: {- slug: slug,- domainSlug: domain,- },- },- select: {- id: true,- expiresAt: true,- emailProtected: true,- allowDownload: true,- password: true,- isArchived: true,- document: {- select: {- id: true,- team: { select: { plan: true } },- versions: {- where: { isPrimary: true },- select: { versionNumber: true, type: true, file: true },- take: 1,- },- },- },- },- });-- if (!link || !link.document.team) {- return {- notFound: true,- };- }-- console.log("plan", link.document.team.plan);-- // if owner of document is on free plan, return 404- if (link.document.team.plan === "free") {- return {- notFound: true,- };+export const getStaticProps = async (context: GetStaticPropsContext) => {+ const { domain, slug } = context.params as { domain: string; slug: string };++ // Fetch the link+ const res = await fetch(+ `${process.env.NEXTAUTH_URL}/api/links/domains/${encodeURIComponent(+ domain,+ )}/${encodeURIComponent(slug)}`,+ );+ if (!res.ok) {+ return { notFound: true };}+ const link = (await res.json()) as LinkWithDocument;let pageId = null;let recordMap = null;@@ -70,9 +32,6 @@ export const getStaticProps = async (context: {const { type, file, ...versionWithoutTypeAndFile } =link.document.versions[0];- console.log("type", type);- console.log("file", file);-if (type === "notion") {// regex match to get the page id from the notion urlconst notionPageId = parsePageId(file, { uuid: false });@@ -176,40 +135,3 @@ export default function ViewPage({/>);}--// export async function getStaticProps(context: GetStaticPropsContext) {-// // const router = useRouter()-// // const { domain, slug } = router.query as {-// // domain: string;-// // slug: string;-// // };-// const { domain, slug } = context.params as { domain: string; slug: string };--// console.log(context.params);--// // Fetch the link-// const res = await fetch(-// `${process.env.NEXTAUTH_URL}/api/links/domains/${encodeURIComponent(-// domain,-// )}/${encodeURIComponent(slug)}`,-// );-// if (!res.ok) {-// return { notFound: true };-// }-// const link = (await res.json()) as LinkWithDocument;--// console.log(link);--// return {-// props: {-// link,-// },-// };-// }--// export async function getStaticPaths() {-// return {-// paths: [],-// fallback: true,-// };-// }