added seed script + renamed table fields + added field

This commit is contained in:
daniel31x13 2023-12-22 13:13:43 -05:00
parent 385bdc2343
commit 98106b9f25
15 changed files with 957 additions and 370 deletions

View File

@ -25,9 +25,10 @@ export default function NewLinkModal({ onClose }: Props) {
description: "", description: "",
type: "url", type: "url",
tags: [], tags: [],
screenshotPath: "", preview: "",
pdfPath: "", image: "",
readabilityPath: "", pdf: "",
readable: "",
textContent: "", textContent: "",
collection: { collection: {
name: "", name: "",

View File

@ -70,12 +70,12 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
const isReady = () => { const isReady = () => {
return ( return (
collectionOwner.archiveAsScreenshot === collectionOwner.archiveAsScreenshot ===
(link && link.pdfPath && link.pdfPath !== "pending") && (link && link.pdf && link.pdf !== "pending") &&
collectionOwner.archiveAsPDF === collectionOwner.archiveAsPDF ===
(link && link.pdfPath && link.pdfPath !== "pending") && (link && link.pdf && link.pdf !== "pending") &&
link && link &&
link.readabilityPath && link.readable &&
link.readabilityPath !== "pending" link.readable !== "pending"
); );
}; };
@ -107,7 +107,7 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
clearInterval(interval); clearInterval(interval);
} }
}; };
}, [link?.screenshotPath, link?.pdfPath, link?.readabilityPath]); }, [link?.image, link?.pdf, link?.readable]);
const updateArchive = async () => { const updateArchive = async () => {
const load = toast.loading("Sending request..."); const load = toast.loading("Sending request...");
@ -154,7 +154,7 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
name={"Screenshot"} name={"Screenshot"}
icon={"bi-file-earmark-image"} icon={"bi-file-earmark-image"}
format={ format={
link?.screenshotPath?.endsWith("png") link?.image?.endsWith("png")
? ArchivedFormat.png ? ArchivedFormat.png
: ArchivedFormat.jpeg : ArchivedFormat.jpeg
} }

View File

@ -27,9 +27,10 @@ export default function UploadFileModal({ onClose }: Props) {
description: "", description: "",
type: "url", type: "url",
tags: [], tags: [],
screenshotPath: "", preview: "",
pdfPath: "", image: "",
readabilityPath: "", pdf: "",
readable: "",
textContent: "", textContent: "",
collection: { collection: {
name: "", name: "",

View File

@ -43,7 +43,7 @@ export default function PreservedFormatRow({
})(); })();
let interval: any; let interval: any;
if (link?.screenshotPath === "pending" || link?.pdfPath === "pending") { if (link?.image === "pending" || link?.pdf === "pending") {
interval = setInterval(async () => { interval = setInterval(async () => {
const data = await getLink(link.id as number, isPublic); const data = await getLink(link.id as number, isPublic);
setLink( setLink(
@ -61,7 +61,7 @@ export default function PreservedFormatRow({
clearInterval(interval); clearInterval(interval);
} }
}; };
}, [link?.screenshotPath, link?.pdfPath, link?.readabilityPath]); }, [link?.image, link?.pdf, link?.readable]);
const handleDownload = () => { const handleDownload = () => {
const path = `/api/v1/archives/${link?.id}?format=${format}`; const path = `/api/v1/archives/${link?.id}?format=${format}`;

View File

@ -62,12 +62,12 @@ export default function ReadableView({ link }: Props) {
let interval: any; let interval: any;
if ( if (
link && link &&
(link?.screenshotPath === "pending" || (link?.image === "pending" ||
link?.pdfPath === "pending" || link?.pdf === "pending" ||
link?.readabilityPath === "pending" || link?.readable === "pending" ||
!link?.screenshotPath || !link?.image ||
!link?.pdfPath || !link?.pdf ||
!link?.readabilityPath) !link?.readable)
) { ) {
interval = setInterval(() => getLink(link.id as number), 5000); interval = setInterval(() => getLink(link.id as number), 5000);
} else { } else {
@ -81,7 +81,7 @@ export default function ReadableView({ link }: Props) {
clearInterval(interval); clearInterval(interval);
} }
}; };
}, [link?.screenshotPath, link?.pdfPath, link?.readabilityPath]); }, [link?.image, link?.pdf, link?.readable]);
const rgbToHex = (r: number, g: number, b: number): string => const rgbToHex = (r: number, g: number, b: number): string =>
"#" + "#" +
@ -225,7 +225,7 @@ export default function ReadableView({ link }: Props) {
</div> </div>
<div className="flex flex-col gap-5 h-full"> <div className="flex flex-col gap-5 h-full">
{link?.readabilityPath?.startsWith("archives") ? ( {link?.readable?.startsWith("archives") ? (
<div <div
className="line-break px-1 reader-view" className="line-break px-1 reader-view"
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{
@ -235,9 +235,7 @@ export default function ReadableView({ link }: Props) {
) : ( ) : (
<div <div
className={`w-full h-full flex flex-col justify-center p-10 ${ className={`w-full h-full flex flex-col justify-center p-10 ${
link?.readabilityPath === "pending" || !link?.readabilityPath link?.readable === "pending" || !link?.readable ? "skeleton" : ""
? "skeleton"
: ""
}`} }`}
> >
<svg <svg

View File

@ -46,18 +46,15 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) {
where: { id: link.id }, where: { id: link.id },
data: { data: {
type: linkType, type: linkType,
screenshotPath: image:
user.archiveAsScreenshot && user.archiveAsScreenshot && !link.image?.startsWith("archive")
!link.screenshotPath?.startsWith("archive")
? "pending" ? "pending"
: undefined, : undefined,
pdfPath: pdf:
user.archiveAsPDF && !link.pdfPath?.startsWith("archive") user.archiveAsPDF && !link.pdf?.startsWith("archive")
? "pending"
: undefined,
readabilityPath: !link.readabilityPath?.startsWith("archive")
? "pending" ? "pending"
: undefined, : undefined,
readable: !link.readable?.startsWith("archive") ? "pending" : undefined,
lastPreserved: new Date().toISOString(), lastPreserved: new Date().toISOString(),
}, },
}); });
@ -107,7 +104,7 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) {
await prisma.link.update({ await prisma.link.update({
where: { id: link.id }, where: { id: link.id },
data: { data: {
readabilityPath: `archives/${targetLink.collectionId}/${link.id}_readability.json`, readable: `archives/${targetLink.collectionId}/${link.id}_readability.json`,
textContent: articleText, textContent: articleText,
}, },
}); });
@ -156,10 +153,10 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) {
await prisma.link.update({ await prisma.link.update({
where: { id: link.id }, where: { id: link.id },
data: { data: {
screenshotPath: user.archiveAsScreenshot image: user.archiveAsScreenshot
? `archives/${linkExists.collectionId}/${link.id}.png` ? `archives/${linkExists.collectionId}/${link.id}.png`
: undefined, : undefined,
pdfPath: user.archiveAsPDF pdf: user.archiveAsPDF
? `archives/${linkExists.collectionId}/${link.id}.pdf` ? `archives/${linkExists.collectionId}/${link.id}.pdf`
: undefined, : undefined,
}, },
@ -179,13 +176,13 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) {
await prisma.link.update({ await prisma.link.update({
where: { id: link.id }, where: { id: link.id },
data: { data: {
readabilityPath: !finalLink.readabilityPath?.startsWith("archives") readable: !finalLink.readable?.startsWith("archives")
? "unavailable" ? "unavailable"
: undefined, : undefined,
screenshotPath: !finalLink.screenshotPath?.startsWith("archives") image: !finalLink.image?.startsWith("archives")
? "unavailable" ? "unavailable"
: undefined, : undefined,
pdfPath: !finalLink.pdfPath?.startsWith("archives") pdf: !finalLink.pdf?.startsWith("archives")
? "unavailable" ? "unavailable"
: undefined, : undefined,
}, },
@ -245,7 +242,7 @@ const imageHandler = async ({ url, id }: Link, extension: string) => {
await prisma.link.update({ await prisma.link.update({
where: { id }, where: { id },
data: { data: {
screenshotPath: `archives/${linkExists.collectionId}/${id}.${extension}`, image: `archives/${linkExists.collectionId}/${id}.${extension}`,
}, },
}); });
} }
@ -269,7 +266,7 @@ const pdfHandler = async ({ url, id }: Link) => {
await prisma.link.update({ await prisma.link.update({
where: { id }, where: { id },
data: { data: {
pdfPath: `archives/${linkExists.collectionId}/${id}.pdf`, pdf: `archives/${linkExists.collectionId}/${id}.pdf`,
}, },
}); });
} }

View File

@ -1,26 +1,23 @@
export function screenshotAvailable(link: any) { export function screenshotAvailable(link: any) {
return ( return (
link && link &&
link.screenshotPath && link.image &&
link.screenshotPath !== "pending" && link.image !== "pending" &&
link.screenshotPath !== "unavailable" link.image !== "unavailable"
); );
} }
export function pdfAvailable(link: any) { export function pdfAvailable(link: any) {
return ( return (
link && link && link.pdf && link.pdf !== "pending" && link.pdf !== "unavailable"
link.pdfPath &&
link.pdfPath !== "pending" &&
link.pdfPath !== "unavailable"
); );
} }
export function readabilityAvailable(link: any) { export function readabilityAvailable(link: any) {
return ( return (
link && link &&
link.readabilityPath && link.readable &&
link.readabilityPath !== "pending" && link.readable !== "pending" &&
link.readabilityPath !== "unavailable" link.readable !== "unavailable"
); );
} }

View File

@ -6,6 +6,9 @@
"author": "Daniel31X13 <daniel31x13@gmail.com>", "author": "Daniel31X13 <daniel31x13@gmail.com>",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"private": true, "private": true,
"prisma": {
"seed": "node ./prisma/seed.js"
},
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
"worker": "ts-node --skip-project scripts/worker.ts", "worker": "ts-node --skip-project scripts/worker.ts",

View File

@ -125,7 +125,7 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
// await prisma.link.update({ // await prisma.link.update({
// where: { id: linkId }, // where: { id: linkId },
// data: { // data: {
// screenshotPath: `archives/${collectionPermissions?.id}/${ // image: `archives/${collectionPermissions?.id}/${
// linkId + suffix // linkId + suffix
// }`, // }`,
// lastPreserved: new Date().toISOString(), // lastPreserved: new Date().toISOString(),

View File

@ -14,7 +14,9 @@ import AppleProvider from "next-auth/providers/apple";
import AtlassianProvider from "next-auth/providers/atlassian"; import AtlassianProvider from "next-auth/providers/atlassian";
import Auth0Provider from "next-auth/providers/auth0"; import Auth0Provider from "next-auth/providers/auth0";
import AuthentikProvider from "next-auth/providers/authentik"; import AuthentikProvider from "next-auth/providers/authentik";
import BattleNetProvider, {BattleNetIssuer} from "next-auth/providers/battlenet"; import BattleNetProvider, {
BattleNetIssuer,
} from "next-auth/providers/battlenet";
import BoxProvider from "next-auth/providers/box"; import BoxProvider from "next-auth/providers/box";
import CognitoProvider from "next-auth/providers/cognito"; import CognitoProvider from "next-auth/providers/cognito";
import CoinbaseProvider from "next-auth/providers/coinbase"; import CoinbaseProvider from "next-auth/providers/coinbase";
@ -61,22 +63,24 @@ import WordpressProvider from "next-auth/providers/wordpress";
import YandexProvider from "next-auth/providers/yandex"; import YandexProvider from "next-auth/providers/yandex";
import ZitadelProvider from "next-auth/providers/zitadel"; import ZitadelProvider from "next-auth/providers/zitadel";
import ZohoProvider from "next-auth/providers/zoho"; import ZohoProvider from "next-auth/providers/zoho";
import ZoomProvider from "next-auth/providers/zoom" import ZoomProvider from "next-auth/providers/zoom";
import * as process from "process"; import * as process from "process";
const emailEnabled = const emailEnabled =
process.env.EMAIL_FROM && process.env.EMAIL_SERVER ? true : false; process.env.EMAIL_FROM && process.env.EMAIL_SERVER ? true : false;
const newSsoUsersDisabled = process.env.DISABLE_NEW_SSO_USERS === 'true'; const newSsoUsersDisabled = process.env.DISABLE_NEW_SSO_USERS === "true";
;
const adapter = PrismaAdapter(prisma); const adapter = PrismaAdapter(prisma);
const STRIPE_SECRET_KEY = process.env.STRIPE_SECRET_KEY; const STRIPE_SECRET_KEY = process.env.STRIPE_SECRET_KEY;
const providers: Provider[] = []; const providers: Provider[] = [];
if (process.env.NEXT_PUBLIC_CREDENTIALS_ENABLED === 'true' || process.env.NEXT_PUBLIC_CREDENTIALS_ENABLED === undefined) { // undefined is for backwards compatibility if (
process.env.NEXT_PUBLIC_CREDENTIALS_ENABLED === "true" ||
process.env.NEXT_PUBLIC_CREDENTIALS_ENABLED === undefined
) {
// undefined is for backwards compatibility
providers.push( providers.push(
CredentialsProvider({ CredentialsProvider({
type: "credentials", type: "credentials",
@ -119,7 +123,7 @@ if (process.env.NEXT_PUBLIC_CREDENTIALS_ENABLED === 'true' || process.env.NEXT_P
} else return null as any; } else return null as any;
}, },
}) })
) );
} }
if (emailEnabled) { if (emailEnabled) {
@ -136,7 +140,7 @@ if (emailEnabled) {
} }
// 42 School // 42 School
if (process.env.NEXT_PUBLIC_FORTYTWO_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_FORTYTWO_ENABLED === "true") {
providers.push( providers.push(
FortyTwoProvider({ FortyTwoProvider({
id: "42-school", id: "42-school",
@ -150,7 +154,7 @@ if (process.env.NEXT_PUBLIC_FORTYTWO_ENABLED === 'true') {
email: profile.email, email: profile.email,
image: profile.image_url, image: profile.image_url,
username: profile.id.toString(), username: profile.id.toString(),
} };
}, },
}) })
); );
@ -159,11 +163,11 @@ if (process.env.NEXT_PUBLIC_FORTYTWO_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Apple // Apple
if (process.env.NEXT_PUBLIC_APPLE_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_APPLE_ENABLED === "true") {
providers.push( providers.push(
AppleProvider({ AppleProvider({
clientId: process.env.APPLE_CLIENT_ID!, clientId: process.env.APPLE_CLIENT_ID!,
@ -175,9 +179,8 @@ if (process.env.NEXT_PUBLIC_APPLE_ENABLED === 'true') {
email: profile.email, email: profile.email,
image: null, image: null,
username: profile.sub, username: profile.sub,
} };
}, },
}) })
); );
@ -185,19 +188,20 @@ if (process.env.NEXT_PUBLIC_APPLE_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Atlassian // Atlassian
if (process.env.NEXT_PUBLIC_ATLASSIAN_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_ATLASSIAN_ENABLED === "true") {
providers.push( providers.push(
AtlassianProvider({ AtlassianProvider({
clientId: process.env.ATLASSIAN_CLIENT_ID!, clientId: process.env.ATLASSIAN_CLIENT_ID!,
clientSecret: process.env.ATLASSIAN_CLIENT_SECRET!, clientSecret: process.env.ATLASSIAN_CLIENT_SECRET!,
authorization: { authorization: {
params: { params: {
scope: "write:jira-work read:jira-work read:jira-user offline_access read:me" scope:
} "write:jira-work read:jira-work read:jira-user offline_access read:me",
},
}, },
profile(profile) { profile(profile) {
return { return {
@ -206,7 +210,7 @@ if (process.env.NEXT_PUBLIC_ATLASSIAN_ENABLED === 'true') {
email: profile.email, email: profile.email,
image: profile.picture, image: profile.picture,
username: profile.account_id, username: profile.account_id,
} };
}, },
}) })
); );
@ -215,16 +219,16 @@ if (process.env.NEXT_PUBLIC_ATLASSIAN_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Auth0 // Auth0
if(process.env.NEXT_PUBLIC_AUTH0_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_AUTH0_ENABLED === "true") {
providers.push( providers.push(
Auth0Provider({ Auth0Provider({
clientId: process.env.AUTH0_CLIENT_ID!, clientId: process.env.AUTH0_CLIENT_ID!,
clientSecret: process.env.AUTH0_CLIENT_SECRET!, clientSecret: process.env.AUTH0_CLIENT_SECRET!,
issuer: process.env.AUTH0_ISSUER issuer: process.env.AUTH0_ISSUER,
}) })
); );
@ -232,11 +236,11 @@ if(process.env.NEXT_PUBLIC_AUTH0_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Authentik // Authentik
if (process.env.NEXT_PUBLIC_AUTHENTIK_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_AUTHENTIK_ENABLED === "true") {
providers.push( providers.push(
AuthentikProvider({ AuthentikProvider({
clientId: process.env.AUTHENTIK_CLIENT_ID!, clientId: process.env.AUTHENTIK_CLIENT_ID!,
@ -257,16 +261,16 @@ if (process.env.NEXT_PUBLIC_AUTHENTIK_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Battle.net // Battle.net
if(process.env.NEXT_PUBLIC_BATTLENET_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_BATTLENET_ENABLED === "true") {
providers.push( providers.push(
BattleNetProvider({ BattleNetProvider({
clientId: process.env.BATTLENET_CLIENT_ID!, clientId: process.env.BATTLENET_CLIENT_ID!,
clientSecret: process.env.BATTLENET_CLIENT_SECRET!, clientSecret: process.env.BATTLENET_CLIENT_SECRET!,
issuer: process.env.BATLLENET_ISSUER as BattleNetIssuer issuer: process.env.BATLLENET_ISSUER as BattleNetIssuer,
}) })
); );
@ -274,15 +278,15 @@ if(process.env.NEXT_PUBLIC_BATTLENET_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Box // Box
if(process.env.NEXT_PUBLIC_BOX_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_BOX_ENABLED === "true") {
providers.push( providers.push(
BoxProvider({ BoxProvider({
clientId: process.env.BOX_CLIENT_ID, clientId: process.env.BOX_CLIENT_ID,
clientSecret: process.env.BOX_CLIENT_SECRET clientSecret: process.env.BOX_CLIENT_SECRET,
}) })
); );
@ -290,11 +294,11 @@ if(process.env.NEXT_PUBLIC_BOX_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Cognito // Cognito
if(process.env.NEXT_PUBLIC_COGNITO_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_COGNITO_ENABLED === "true") {
providers.push( providers.push(
CognitoProvider({ CognitoProvider({
clientId: process.env.COGNITO_CLIENT_ID!, clientId: process.env.COGNITO_CLIENT_ID!,
@ -307,15 +311,15 @@ if(process.env.NEXT_PUBLIC_COGNITO_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Coinbase // Coinbase
if(process.env.NEXT_PUBLIC_COINBASE_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_COINBASE_ENABLED === "true") {
providers.push( providers.push(
CoinbaseProvider({ CoinbaseProvider({
clientId: process.env.COINBASE_CLIENT_ID, clientId: process.env.COINBASE_CLIENT_ID,
clientSecret: process.env.COINBASE_CLIENT_SECRET clientSecret: process.env.COINBASE_CLIENT_SECRET,
}) })
); );
@ -323,15 +327,15 @@ if(process.env.NEXT_PUBLIC_COINBASE_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Discord // Discord
if(process.env.NEXT_PUBLIC_DISCORD_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_DISCORD_ENABLED === "true") {
providers.push( providers.push(
DiscordProvider({ DiscordProvider({
clientId: process.env.DISCORD_CLIENT_ID!, clientId: process.env.DISCORD_CLIENT_ID!,
clientSecret: process.env.DISCORD_CLIENT_SECRET! clientSecret: process.env.DISCORD_CLIENT_SECRET!,
}) })
); );
@ -339,15 +343,15 @@ if(process.env.NEXT_PUBLIC_DISCORD_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Dropbox // Dropbox
if(process.env.NEXT_PUBLIC_DROPBOX_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_DROPBOX_ENABLED === "true") {
providers.push( providers.push(
DropboxProvider({ DropboxProvider({
clientId: process.env.DROPBOX_CLIENT_ID, clientId: process.env.DROPBOX_CLIENT_ID,
clientSecret: process.env.DROPBOX_CLIENT_SECRET clientSecret: process.env.DROPBOX_CLIENT_SECRET,
}) })
); );
@ -355,11 +359,11 @@ if(process.env.NEXT_PUBLIC_DROPBOX_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Duende IdentityServer6 // Duende IdentityServer6
if(process.env.NEXT_PUBLIC_DUENDE_IDS6_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_DUENDE_IDS6_ENABLED === "true") {
providers.push( providers.push(
DuendeIDS6Provider({ DuendeIDS6Provider({
clientId: process.env.DUENDE_IDS6_ID!, clientId: process.env.DUENDE_IDS6_ID!,
@ -372,15 +376,15 @@ if(process.env.NEXT_PUBLIC_DUENDE_IDS6_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// EVE Online // EVE Online
if(process.env.NEXT_PUBLIC_EVEONLINE_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_EVEONLINE_ENABLED === "true") {
providers.push( providers.push(
EVEOnlineProvider({ EVEOnlineProvider({
clientId: process.env.EVE_CLIENT_ID!, clientId: process.env.EVE_CLIENT_ID!,
clientSecret: process.env.EVE_CLIENT_SECRET! clientSecret: process.env.EVE_CLIENT_SECRET!,
}) })
); );
@ -388,15 +392,15 @@ if(process.env.NEXT_PUBLIC_EVEONLINE_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Facebook // Facebook
if(process.env.NEXT_PUBLIC_FACEBOOK_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_FACEBOOK_ENABLED === "true") {
providers.push( providers.push(
FacebookProvider({ FacebookProvider({
clientId: process.env.FACEBOOK_CLIENT_ID!, clientId: process.env.FACEBOOK_CLIENT_ID!,
clientSecret: process.env.FACEBOOK_CLIENT_SECRET! clientSecret: process.env.FACEBOOK_CLIENT_SECRET!,
}) })
); );
@ -404,15 +408,15 @@ if(process.env.NEXT_PUBLIC_FACEBOOK_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// FACEIT // FACEIT
if(process.env.NEXT_PUBLIC_FACEIT_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_FACEIT_ENABLED === "true") {
providers.push( providers.push(
FaceItProvider({ FaceItProvider({
clientId: process.env.FACEIT_CLIENT_ID, clientId: process.env.FACEIT_CLIENT_ID,
clientSecret: process.env.FACEIT_CLIENT_SECRET clientSecret: process.env.FACEIT_CLIENT_SECRET,
}) })
); );
@ -420,16 +424,16 @@ if(process.env.NEXT_PUBLIC_FACEIT_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Foursquare // Foursquare
if(process.env.NEXT_PUBLIC_FOURSQUARE_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_FOURSQUARE_ENABLED === "true") {
providers.push( providers.push(
FourSquareProvider({ FourSquareProvider({
clientId: process.env.FOURSQUARE_CLIENT_ID, clientId: process.env.FOURSQUARE_CLIENT_ID,
clientSecret: process.env.FOURSQUARE_CLIENT_SECRET, clientSecret: process.env.FOURSQUARE_CLIENT_SECRET,
apiVersion: process.env.FOURSQUARE_APIVERSION apiVersion: process.env.FOURSQUARE_APIVERSION,
}) })
); );
@ -437,11 +441,11 @@ if(process.env.NEXT_PUBLIC_FOURSQUARE_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Freshbooks // Freshbooks
if(process.env.NEXT_PUBLIC_FRESHBOOKS_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_FRESHBOOKS_ENABLED === "true") {
providers.push( providers.push(
FreshbooksProvider({ FreshbooksProvider({
clientId: process.env.FRESHBOOKS_CLIENT_ID, clientId: process.env.FRESHBOOKS_CLIENT_ID,
@ -453,11 +457,11 @@ if(process.env.NEXT_PUBLIC_FRESHBOOKS_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// FusionAuth // FusionAuth
if(process.env.NEXT_PUBLIC_FUSIONAUTH_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_FUSIONAUTH_ENABLED === "true") {
providers.push( providers.push(
FusionAuthProvider({ FusionAuthProvider({
id: "fusionauth", id: "fusionauth",
@ -465,23 +469,23 @@ if(process.env.NEXT_PUBLIC_FUSIONAUTH_ENABLED === 'true') {
issuer: process.env.FUSIONAUTH_ISSUER, issuer: process.env.FUSIONAUTH_ISSUER,
clientId: process.env.FUSIONAUTH_CLIENT_ID!, clientId: process.env.FUSIONAUTH_CLIENT_ID!,
clientSecret: process.env.FUSIONAUTH_SECRET!, clientSecret: process.env.FUSIONAUTH_SECRET!,
tenantId: process.env.FUSIONAUTH_TENANT_ID tenantId: process.env.FUSIONAUTH_TENANT_ID,
}), })
); );
const _linkAccount = adapter.linkAccount; const _linkAccount = adapter.linkAccount;
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// GitHub // GitHub
if(process.env.NEXT_PUBLIC_GITHUB_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_GITHUB_ENABLED === "true") {
providers.push( providers.push(
GitHubProvider({ GitHubProvider({
clientId: process.env.GITHUB_ID!, clientId: process.env.GITHUB_ID!,
clientSecret: process.env.GITHUB_SECRET! clientSecret: process.env.GITHUB_SECRET!,
}) })
); );
@ -489,15 +493,15 @@ if(process.env.NEXT_PUBLIC_GITHUB_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// GitLab // GitLab
if(process.env.NEXT_PUBLIC_GITLAB_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_GITLAB_ENABLED === "true") {
providers.push( providers.push(
GitlabProvider({ GitlabProvider({
clientId: process.env.GITLAB_CLIENT_ID!, clientId: process.env.GITLAB_CLIENT_ID!,
clientSecret: process.env.GITLAB_CLIENT_SECRET! clientSecret: process.env.GITLAB_CLIENT_SECRET!,
}) })
); );
@ -505,15 +509,15 @@ if(process.env.NEXT_PUBLIC_GITLAB_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Google // Google
if(process.env.NEXT_PUBLIC_GOOGLE_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_GOOGLE_ENABLED === "true") {
providers.push( providers.push(
GoogleProvider({ GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID!, clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET! clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
}) })
); );
@ -521,15 +525,15 @@ if(process.env.NEXT_PUBLIC_GOOGLE_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// HubSpot // HubSpot
if(process.env.NEXT_PUBLIC_HUBSPOT_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_HUBSPOT_ENABLED === "true") {
providers.push( providers.push(
HubspotProvider({ HubspotProvider({
clientId: process.env.HUBSPOT_CLIENT_ID!, clientId: process.env.HUBSPOT_CLIENT_ID!,
clientSecret: process.env.HUBSPOT_CLIENT_SECRET! clientSecret: process.env.HUBSPOT_CLIENT_SECRET!,
}) })
); );
@ -537,18 +541,18 @@ if(process.env.NEXT_PUBLIC_HUBSPOT_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// IdentityServer4 // IdentityServer4
if(process.env.NEXT_PUBLIC_IDS4_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_IDS4_ENABLED === "true") {
providers.push( providers.push(
IdentityServer4Provider({ IdentityServer4Provider({
id: "identity-server4", id: "identity-server4",
name: "IdentityServer4", name: "IdentityServer4",
issuer: process.env.IdentityServer4_Issuer, issuer: process.env.IdentityServer4_Issuer,
clientId: process.env.IdentityServer4_CLIENT_ID, clientId: process.env.IdentityServer4_CLIENT_ID,
clientSecret: process.env.IdentityServer4_CLIENT_SECRET clientSecret: process.env.IdentityServer4_CLIENT_SECRET,
}) })
); );
@ -556,15 +560,15 @@ if(process.env.NEXT_PUBLIC_IDS4_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Kakao // Kakao
if(process.env.NEXT_PUBLIC_KAKAO_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_KAKAO_ENABLED === "true") {
providers.push( providers.push(
KakaoProvider({ KakaoProvider({
clientId: process.env.KAKAO_CLIENT_ID!, clientId: process.env.KAKAO_CLIENT_ID!,
clientSecret: process.env.KAKAO_CLIENT_SECRET! clientSecret: process.env.KAKAO_CLIENT_SECRET!,
}) })
); );
@ -572,11 +576,11 @@ if(process.env.NEXT_PUBLIC_KAKAO_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Keycloak // Keycloak
if (process.env.NEXT_PUBLIC_KEYCLOAK_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_KEYCLOAK_ENABLED === "true") {
providers.push( providers.push(
KeycloakProvider({ KeycloakProvider({
clientId: process.env.KEYCLOAK_CLIENT_ID!, clientId: process.env.KEYCLOAK_CLIENT_ID!,
@ -600,11 +604,11 @@ if (process.env.NEXT_PUBLIC_KEYCLOAK_ENABLED === 'true') {
} }
// LINE // LINE
if(process.env.NEXT_PUBLIC_LINE_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_LINE_ENABLED === "true") {
providers.push( providers.push(
LineProvider({ LineProvider({
clientId: process.env.LINE_CLIENT_ID!, clientId: process.env.LINE_CLIENT_ID!,
clientSecret: process.env.LINE_CLIENT_SECRET! clientSecret: process.env.LINE_CLIENT_SECRET!,
}) })
); );
@ -612,15 +616,15 @@ if(process.env.NEXT_PUBLIC_LINE_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// LinkedIn // LinkedIn
if(process.env.NEXT_PUBLIC_LINKEDIN_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_LINKEDIN_ENABLED === "true") {
providers.push( providers.push(
LinkedInProvider({ LinkedInProvider({
clientId: process.env.LINKEDIN_CLIENT_ID!, clientId: process.env.LINKEDIN_CLIENT_ID!,
clientSecret: process.env.LINKEDIN_CLIENT_SECRET! clientSecret: process.env.LINKEDIN_CLIENT_SECRET!,
}) })
); );
@ -628,15 +632,15 @@ if(process.env.NEXT_PUBLIC_LINKEDIN_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Mailchimp // Mailchimp
if(process.env.NEXT_PUBLIC_MAILCHIMP_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_MAILCHIMP_ENABLED === "true") {
providers.push( providers.push(
MailchimpProvider({ MailchimpProvider({
clientId: process.env.MAILCHIMP_CLIENT_ID, clientId: process.env.MAILCHIMP_CLIENT_ID,
clientSecret: process.env.MAILCHIMP_CLIENT_SECRET clientSecret: process.env.MAILCHIMP_CLIENT_SECRET,
}) })
); );
@ -644,15 +648,15 @@ if(process.env.NEXT_PUBLIC_MAILCHIMP_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Mail.ru // Mail.ru
if(process.env.NEXT_PUBLIC_MAILRU_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_MAILRU_ENABLED === "true") {
providers.push( providers.push(
MailRuProvider({ MailRuProvider({
clientId: process.env.MAILRU_CLIENT_ID, clientId: process.env.MAILRU_CLIENT_ID,
clientSecret: process.env.MAILRU_CLIENT_SECRET clientSecret: process.env.MAILRU_CLIENT_SECRET,
}) })
); );
@ -660,15 +664,15 @@ if(process.env.NEXT_PUBLIC_MAILRU_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Naver // Naver
if(process.env.NEXT_PUBLIC_NAVER_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_NAVER_ENABLED === "true") {
providers.push( providers.push(
NaverProvider({ NaverProvider({
clientId: process.env.NAVER_CLIENT_ID!, clientId: process.env.NAVER_CLIENT_ID!,
clientSecret: process.env.NAVER_CLIENT_SECRET! clientSecret: process.env.NAVER_CLIENT_SECRET!,
}) })
); );
@ -676,15 +680,15 @@ if(process.env.NEXT_PUBLIC_NAVER_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Netlify // Netlify
if(process.env.NEXT_PUBLIC_NETLIFY_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_NETLIFY_ENABLED === "true") {
providers.push( providers.push(
NetlifyProvider({ NetlifyProvider({
clientId: process.env.NETLIFY_CLIENT_ID, clientId: process.env.NETLIFY_CLIENT_ID,
clientSecret: process.env.NETLIFY_CLIENT_SECRET clientSecret: process.env.NETLIFY_CLIENT_SECRET,
}) })
); );
@ -692,16 +696,16 @@ if(process.env.NEXT_PUBLIC_NETLIFY_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Okta // Okta
if(process.env.NEXT_PUBLIC_OKTA_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_OKTA_ENABLED === "true") {
providers.push( providers.push(
OktaProvider({ OktaProvider({
clientId: process.env.OKTA_CLIENT_ID!, clientId: process.env.OKTA_CLIENT_ID!,
clientSecret: process.env.OKTA_CLIENT_SECRET!, clientSecret: process.env.OKTA_CLIENT_SECRET!,
issuer: process.env.OKTA_ISSUER issuer: process.env.OKTA_ISSUER,
}) })
); );
@ -709,16 +713,16 @@ if(process.env.NEXT_PUBLIC_OKTA_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// OneLogin // OneLogin
if(process.env.NEXT_PUBLIC_ONELOGIN_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_ONELOGIN_ENABLED === "true") {
providers.push( providers.push(
OneLoginProvider({ OneLoginProvider({
clientId: process.env.ONELOGIN_CLIENT_ID, clientId: process.env.ONELOGIN_CLIENT_ID,
clientSecret: process.env.ONELOGIN_CLIENT_SECRET, clientSecret: process.env.ONELOGIN_CLIENT_SECRET,
issuer: process.env.ONELOGIN_ISSUER issuer: process.env.ONELOGIN_ISSUER,
}) })
); );
@ -726,16 +730,16 @@ if(process.env.NEXT_PUBLIC_ONELOGIN_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Osso // Osso
if(process.env.NEXT_PUBLIC_OSSO_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_OSSO_ENABLED === "true") {
providers.push( providers.push(
OssoProvider({ OssoProvider({
clientId: process.env.OSSO_CLIENT_ID, clientId: process.env.OSSO_CLIENT_ID,
clientSecret: process.env.OSSO_CLIENT_SECRET, clientSecret: process.env.OSSO_CLIENT_SECRET,
issuer: process.env.OSSO_ISSUER issuer: process.env.OSSO_ISSUER,
}) })
); );
@ -743,15 +747,15 @@ if(process.env.NEXT_PUBLIC_OSSO_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// osu! // osu!
if(process.env.NEXT_PUBLIC_OSU_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_OSU_ENABLED === "true") {
providers.push( providers.push(
OsuProvider({ OsuProvider({
clientId: process.env.OSU_CLIENT_ID!, clientId: process.env.OSU_CLIENT_ID!,
clientSecret: process.env.OSU_CLIENT_SECRET! clientSecret: process.env.OSU_CLIENT_SECRET!,
}) })
); );
@ -759,11 +763,11 @@ if(process.env.NEXT_PUBLIC_OSU_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Patreon // Patreon
if(process.env.NEXT_PUBLIC_PATREON_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_PATREON_ENABLED === "true") {
providers.push( providers.push(
PatreonProvider({ PatreonProvider({
clientId: process.env.PATREON_ID!, clientId: process.env.PATREON_ID!,
@ -775,15 +779,15 @@ if(process.env.NEXT_PUBLIC_PATREON_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Pinterest // Pinterest
if(process.env.NEXT_PUBLIC_PINTEREST_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_PINTEREST_ENABLED === "true") {
providers.push( providers.push(
PinterestProvider({ PinterestProvider({
clientId: process.env.PINTEREST_ID!, clientId: process.env.PINTEREST_ID!,
clientSecret: process.env.PINTEREST_SECRET! clientSecret: process.env.PINTEREST_SECRET!,
}) })
); );
@ -791,11 +795,11 @@ if(process.env.NEXT_PUBLIC_PINTEREST_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Pipedrive // Pipedrive
if(process.env.NEXT_PUBLIC_PIPEDRIVE_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_PIPEDRIVE_ENABLED === "true") {
providers.push( providers.push(
PipedriveProvider({ PipedriveProvider({
clientId: process.env.PIPEDRIVE_CLIENT_ID!, clientId: process.env.PIPEDRIVE_CLIENT_ID!,
@ -807,15 +811,15 @@ if(process.env.NEXT_PUBLIC_PIPEDRIVE_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Reddit // Reddit
if(process.env.NEXT_PUBLIC_REDDIT_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_REDDIT_ENABLED === "true") {
providers.push( providers.push(
RedditProvider({ RedditProvider({
clientId: process.env.REDDIT_CLIENT_ID, clientId: process.env.REDDIT_CLIENT_ID,
clientSecret: process.env.REDDIT_CLIENT_SECRET clientSecret: process.env.REDDIT_CLIENT_SECRET,
}) })
); );
@ -823,11 +827,11 @@ if(process.env.NEXT_PUBLIC_REDDIT_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Salesforce // Salesforce
if(process.env.NEXT_PUBLIC_SALESFORCE_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_SALESFORCE_ENABLED === "true") {
providers.push( providers.push(
SalesforceProvider({ SalesforceProvider({
clientId: process.env.SALESFORCE_CLIENT_ID!, clientId: process.env.SALESFORCE_CLIENT_ID!,
@ -839,15 +843,15 @@ if(process.env.NEXT_PUBLIC_SALESFORCE_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Slack // Slack
if(process.env.NEXT_PUBLIC_SLACK_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_SLACK_ENABLED === "true") {
providers.push( providers.push(
SlackProvider({ SlackProvider({
clientId: process.env.SLACK_CLIENT_ID!, clientId: process.env.SLACK_CLIENT_ID!,
clientSecret: process.env.SLACK_CLIENT_SECRET! clientSecret: process.env.SLACK_CLIENT_SECRET!,
}) })
); );
@ -855,15 +859,15 @@ if(process.env.NEXT_PUBLIC_SLACK_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Spotify // Spotify
if(process.env.NEXT_PUBLIC_SPOTIFY_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_SPOTIFY_ENABLED === "true") {
providers.push( providers.push(
SpotifyProvider({ SpotifyProvider({
clientId: process.env.SPOTIFY_CLIENT_ID!, clientId: process.env.SPOTIFY_CLIENT_ID!,
clientSecret: process.env.SPOTIFY_CLIENT_SECRET! clientSecret: process.env.SPOTIFY_CLIENT_SECRET!,
}) })
); );
@ -871,11 +875,11 @@ if(process.env.NEXT_PUBLIC_SPOTIFY_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Strava // Strava
if(process.env.NEXT_PUBLIC_STRAVA_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_STRAVA_ENABLED === "true") {
providers.push( providers.push(
StravaProvider({ StravaProvider({
clientId: process.env.STRAVA_CLIENT_ID!, clientId: process.env.STRAVA_CLIENT_ID!,
@ -887,15 +891,15 @@ if(process.env.NEXT_PUBLIC_STRAVA_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Todoist // Todoist
if(process.env.NEXT_PUBLIC_TODOIST_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_TODOIST_ENABLED === "true") {
providers.push( providers.push(
TodoistProvider({ TodoistProvider({
clientId: process.env.TODOIST_ID!, clientId: process.env.TODOIST_ID!,
clientSecret: process.env.TODOIST_SECRET! clientSecret: process.env.TODOIST_SECRET!,
}) })
); );
@ -903,15 +907,15 @@ if(process.env.NEXT_PUBLIC_TODOIST_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Twitch // Twitch
if(process.env.NEXT_PUBLIC_TWITCH_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_TWITCH_ENABLED === "true") {
providers.push( providers.push(
TwitchProvider({ TwitchProvider({
clientId: process.env.TWITCH_CLIENT_ID!, clientId: process.env.TWITCH_CLIENT_ID!,
clientSecret: process.env.TWITCH_CLIENT_SECRET! clientSecret: process.env.TWITCH_CLIENT_SECRET!,
}) })
); );
@ -919,16 +923,16 @@ if(process.env.NEXT_PUBLIC_TWITCH_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// United Effects // United Effects
if(process.env.NEXT_PUBLIC_UNITED_EFFECTS_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_UNITED_EFFECTS_ENABLED === "true") {
providers.push( providers.push(
UnitedEffectsProvider({ UnitedEffectsProvider({
clientId: process.env.UNITED_EFFECTS_CLIENT_ID!, clientId: process.env.UNITED_EFFECTS_CLIENT_ID!,
clientSecret: process.env.UNITED_EFFECTS_CLIENT_SECRET!, clientSecret: process.env.UNITED_EFFECTS_CLIENT_SECRET!,
issuer: process.env.UNITED_EFFECTS_ISSUER! issuer: process.env.UNITED_EFFECTS_ISSUER!,
}) })
); );
@ -936,15 +940,15 @@ if(process.env.NEXT_PUBLIC_UNITED_EFFECTS_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// VK // VK
if(process.env.NEXT_PUBLIC_VK_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_VK_ENABLED === "true") {
providers.push( providers.push(
VkProvider({ VkProvider({
clientId: process.env.VK_CLIENT_ID!, clientId: process.env.VK_CLIENT_ID!,
clientSecret: process.env.VK_CLIENT_SECRET! clientSecret: process.env.VK_CLIENT_SECRET!,
}) })
); );
@ -952,15 +956,15 @@ if(process.env.NEXT_PUBLIC_VK_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Wikimedia // Wikimedia
if(process.env.NEXT_PUBLIC_WIKIMEDIA_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_WIKIMEDIA_ENABLED === "true") {
providers.push( providers.push(
WikimediaProvider({ WikimediaProvider({
clientId: process.env.WIKIMEDIA_CLIENT_ID!, clientId: process.env.WIKIMEDIA_CLIENT_ID!,
clientSecret: process.env.WIKIMEDIA_CLIENT_SECRET! clientSecret: process.env.WIKIMEDIA_CLIENT_SECRET!,
}) })
); );
@ -968,15 +972,15 @@ if(process.env.NEXT_PUBLIC_WIKIMEDIA_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Wordpress.com // Wordpress.com
if(process.env.NEXT_PUBLIC_WORDPRESS_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_WORDPRESS_ENABLED === "true") {
providers.push( providers.push(
WordpressProvider({ WordpressProvider({
clientId: process.env.WORDPRESS_CLIENT_ID, clientId: process.env.WORDPRESS_CLIENT_ID,
clientSecret: process.env.WORDPRESS_CLIENT_SECRET clientSecret: process.env.WORDPRESS_CLIENT_SECRET,
}) })
); );
@ -984,15 +988,15 @@ if(process.env.NEXT_PUBLIC_WORDPRESS_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Yandex // Yandex
if(process.env.NEXT_PUBLIC_YANDEX_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_YANDEX_ENABLED === "true") {
providers.push( providers.push(
YandexProvider({ YandexProvider({
clientId: process.env.YANDEX_CLIENT_ID!, clientId: process.env.YANDEX_CLIENT_ID!,
clientSecret: process.env.YANDEX_CLIENT_SECRET! clientSecret: process.env.YANDEX_CLIENT_SECRET!,
}) })
); );
@ -1000,11 +1004,11 @@ if(process.env.NEXT_PUBLIC_YANDEX_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Zitadel // Zitadel
if(process.env.NEXT_PUBLIC_ZITADEL_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_ZITADEL_ENABLED === "true") {
providers.push( providers.push(
ZitadelProvider({ ZitadelProvider({
issuer: process.env.ZITADEL_ISSUER, issuer: process.env.ZITADEL_ISSUER,
@ -1017,15 +1021,15 @@ if(process.env.NEXT_PUBLIC_ZITADEL_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Zoho // Zoho
if(process.env.NEXT_PUBLIC_ZOHO_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_ZOHO_ENABLED === "true") {
providers.push( providers.push(
ZohoProvider({ ZohoProvider({
clientId: process.env.ZOHO_CLIENT_ID, clientId: process.env.ZOHO_CLIENT_ID,
clientSecret: process.env.ZOHO_CLIENT_SECRET clientSecret: process.env.ZOHO_CLIENT_SECRET,
}) })
); );
@ -1033,15 +1037,15 @@ if(process.env.NEXT_PUBLIC_ZOHO_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
// Zoom // Zoom
if(process.env.NEXT_PUBLIC_ZOOM_ENABLED_ENABLED === 'true') { if (process.env.NEXT_PUBLIC_ZOOM_ENABLED_ENABLED === "true") {
providers.push( providers.push(
ZoomProvider({ ZoomProvider({
clientId: process.env.ZOOM_CLIENT_ID!, clientId: process.env.ZOOM_CLIENT_ID!,
clientSecret: process.env.ZOOM_CLIENT_SECRET! clientSecret: process.env.ZOOM_CLIENT_SECRET!,
}) })
); );
@ -1049,7 +1053,7 @@ if(process.env.NEXT_PUBLIC_ZOOM_ENABLED_ENABLED === 'true') {
adapter.linkAccount = (account) => { adapter.linkAccount = (account) => {
const { "not-before-policy": _, refresh_expires_in, ...data } = account; const { "not-before-policy": _, refresh_expires_in, ...data } = account;
return _linkAccount ? _linkAccount(data) : undefined; return _linkAccount ? _linkAccount(data) : undefined;
} };
} }
export const authOptions: AuthOptions = { export const authOptions: AuthOptions = {
@ -1065,7 +1069,8 @@ export const authOptions: AuthOptions = {
}, },
callbacks: { callbacks: {
async signIn({ user, account, profile, email, credentials }) { async signIn({ user, account, profile, email, credentials }) {
if (account?.provider !== "credentials") { // registration via SSO can be separately disabled if (account?.provider !== "credentials") {
// registration via SSO can be separately disabled
const existingUser = await prisma.account.findFirst({ const existingUser = await prisma.account.findFirst({
where: { where: {
providerAccountId: account?.providerAccountId, providerAccountId: account?.providerAccountId,

View File

@ -73,9 +73,9 @@ const deleteArchivedFiles = async (link: Link & { collection: Collection }) => {
id: link.id, id: link.id,
}, },
data: { data: {
screenshotPath: null, image: null,
pdfPath: null, pdf: null,
readabilityPath: null, readable: null,
}, },
}); });

View File

@ -0,0 +1,13 @@
/*
Warnings:
- You are about to drop the column `pdf` on the `Link` table. All the data in the column will be lost.
- You are about to drop the column `readable` on the `Link` table. All the data in the column will be lost.
- You are about to drop the column `screenshotPath` on the `Link` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "Link" RENAME COLUMN "screenshotPath" TO "image";
ALTER TABLE "Link" RENAME COLUMN "pdfPath" TO "pdf";
ALTER TABLE "Link" RENAME COLUMN "readabilityPath" TO "readable";
ALTER TABLE "Link" ADD COLUMN "preview" TEXT;

View File

@ -46,7 +46,7 @@ model User {
archiveAsWaybackMachine Boolean @default(false) archiveAsWaybackMachine Boolean @default(false)
isPrivate Boolean @default(false) isPrivate Boolean @default(false)
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now()) updatedAt DateTime @default(now()) @updatedAt
} }
model WhitelistedUser { model WhitelistedUser {
@ -55,7 +55,7 @@ model WhitelistedUser {
User User? @relation(fields: [userId], references: [id]) User User? @relation(fields: [userId], references: [id])
userId Int? userId Int?
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now()) updatedAt DateTime @default(now()) @updatedAt
} }
model VerificationToken { model VerificationToken {
@ -63,7 +63,7 @@ model VerificationToken {
token String @unique token String @unique
expires DateTime expires DateTime
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now()) updatedAt DateTime @default(now()) @updatedAt
@@unique([identifier, token]) @@unique([identifier, token])
} }
@ -79,7 +79,7 @@ model Collection {
members UsersAndCollections[] members UsersAndCollections[]
links Link[] links Link[]
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now()) updatedAt DateTime @default(now()) @updatedAt
@@unique([name, ownerId]) @@unique([name, ownerId])
} }
@ -93,7 +93,7 @@ model UsersAndCollections {
canUpdate Boolean canUpdate Boolean
canDelete Boolean canDelete Boolean
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now()) updatedAt DateTime @default(now()) @updatedAt
@@id([userId, collectionId]) @@id([userId, collectionId])
} }
@ -109,12 +109,13 @@ model Link {
tags Tag[] tags Tag[]
url String? url String?
textContent String? textContent String?
screenshotPath String? preview String?
pdfPath String? image String?
readabilityPath String? pdf String?
readable String?
lastPreserved DateTime? lastPreserved DateTime?
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now()) updatedAt DateTime @default(now()) @updatedAt
} }
model Tag { model Tag {
@ -124,7 +125,7 @@ model Tag {
owner User @relation(fields: [ownerId], references: [id]) owner User @relation(fields: [ownerId], references: [id])
ownerId Int ownerId Int
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now()) updatedAt DateTime @default(now()) @updatedAt
@@unique([name, ownerId]) @@unique([name, ownerId])
} }
@ -138,7 +139,7 @@ model Subscription {
user User @relation(fields: [userId], references: [id]) user User @relation(fields: [userId], references: [id])
userId Int @unique userId Int @unique
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now()) updatedAt DateTime @default(now()) @updatedAt
} }
model ApiKey { model ApiKey {
@ -150,7 +151,7 @@ model ApiKey {
expires DateTime expires DateTime
lastUsedAt DateTime? lastUsedAt DateTime?
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now()) updatedAt DateTime @default(now()) @updatedAt
@@unique([token, userId]) @@unique([token, userId])
} }

571
prisma/seed.js Normal file
View File

@ -0,0 +1,571 @@
// A dirty script to seed the database with some data
const { PrismaClient } = require("@prisma/client");
const bcrypt = require("bcrypt");
const prisma = new PrismaClient();
async function main() {
const saltRounds = 10;
const defaultPassword = "11111111";
const hashedPassword = bcrypt.hashSync(defaultPassword, saltRounds);
// Subscription dates
const currentPeriodStart = new Date();
const currentPeriodEnd = new Date();
currentPeriodEnd.setFullYear(currentPeriodEnd.getFullYear() + 10);
// Operations to be executed within a transaction
const transaction = await prisma.$transaction(async (prisma) => {
// Create users with subscriptions
const user1 = await prisma.user.create({
data: {
name: "John Doe",
username: "user1",
email: "user1@example.com",
emailVerified: new Date(),
password: hashedPassword,
subscriptions: {
create: {
stripeSubscriptionId: "sub_4323",
active: true,
currentPeriodStart,
currentPeriodEnd,
},
},
},
});
const user2 = await prisma.user.create({
data: {
name: "Mary Smith",
username: "user2",
email: "user2@example.com",
emailVerified: new Date(),
password: hashedPassword,
subscriptions: {
create: {
stripeSubscriptionId: "sub_5435",
active: true,
currentPeriodStart,
currentPeriodEnd,
},
},
},
});
const user3 = await prisma.user.create({
data: {
name: "Linda Jones",
username: "user3",
email: "user3@example.com",
emailVerified: new Date(),
password: hashedPassword,
subscriptions: {
create: {
stripeSubscriptionId: "sub_6435",
active: true,
currentPeriodStart,
currentPeriodEnd,
},
},
},
});
const user4 = await prisma.user.create({
data: {
name: "Betty Sanchez",
username: "user4",
email: "user4@example.com",
emailVerified: new Date(),
password: hashedPassword,
subscriptions: {
create: {
stripeSubscriptionId: "sub_7868",
active: true,
currentPeriodStart,
currentPeriodEnd,
},
},
},
});
const user5 = await prisma.user.create({
data: {
name: "Jeffrey Edwards",
username: "user5",
email: "user5@example.com",
emailVerified: new Date(),
password: hashedPassword,
subscriptions: {
create: {
stripeSubscriptionId: "sub_5653",
active: true,
currentPeriodStart,
currentPeriodEnd,
},
},
},
});
// Define and create collections
const collectionsUser1 = [
{
name: "Health and Wellness",
description: "Latest articles on health and wellness.",
ownerId: user1.id,
color: "#ff1100",
},
{
name: "Research",
description: "Latest articles on research.",
ownerId: user1.id,
color: "#000dff",
},
{
name: "Technology",
description: "Latest articles on technology.",
ownerId: user1.id,
color: "#0080ff",
},
{
name: "Personal Finance",
description: "Latest articles on personal finance.",
ownerId: user1.id,
color: "#00ff40",
},
{
name: "Productivity",
description: "Latest articles on productivity.",
ownerId: user1.id,
color: "#ff00f7",
},
{
name: "Recipes",
description: "Latest recipes.",
ownerId: user1.id,
color: "#eeff00",
},
];
const collectionsUser2 = [
{
name: "Project Alpha",
description: "Articles for Project Alpha.",
ownerId: user2.id,
},
];
const user1Collections = await Promise.all(
collectionsUser1.map((c) => prisma.collection.create({ data: c }))
);
const user2Collections = await Promise.all(
collectionsUser2.map((c) => prisma.collection.create({ data: c }))
);
// Share one collection between users with permissions
await Promise.allSettled([
prisma.usersAndCollections.create({
data: {
userId: user1.id,
collectionId: user2Collections[0].id,
canCreate: true,
canUpdate: true,
canDelete: true,
},
}),
prisma.usersAndCollections.create({
data: {
userId: user2.id,
collectionId: user1Collections[1].id,
canCreate: true,
canUpdate: true,
canDelete: true,
},
}),
prisma.usersAndCollections.create({
data: {
userId: user3.id,
collectionId: user1Collections[1].id,
canCreate: true,
canUpdate: true,
canDelete: true,
},
}),
prisma.usersAndCollections.create({
data: {
userId: user4.id,
collectionId: user1Collections[1].id,
canCreate: true,
canUpdate: true,
canDelete: true,
},
}),
prisma.usersAndCollections.create({
data: {
userId: user5.id,
collectionId: user1Collections[1].id,
canCreate: true,
canUpdate: true,
canDelete: true,
},
}),
prisma.usersAndCollections.create({
data: {
userId: user2.id,
collectionId: user2Collections[0].id,
canCreate: true,
canUpdate: true,
canDelete: true,
},
}),
prisma.usersAndCollections.create({
data: {
userId: user3.id,
collectionId: user2Collections[0].id,
canCreate: true,
canUpdate: true,
canDelete: true,
},
}),
prisma.usersAndCollections.create({
data: {
userId: user2.id,
collectionId: user1Collections[0].id,
canCreate: true,
canUpdate: true,
canDelete: true,
},
}),
]);
let projectAlphaCollection = await prisma.collection.findFirst({
where: {
name: "Project Alpha",
ownerId: user2.id,
},
});
const projectAlphaLinks = [
{
name: "More than 10,000 research papers were retracted in 2023 — a new record",
url: "https://www.nature.com/articles/d41586-023-03974-8",
},
{
name: "Advances in Liver Cancer Research",
url: "https://www.cancer.gov/types/liver/research",
},
{
name: "NEW RESEARCH REVEALS TOP AI TOOLS UTILIZED BY MUSIC PRODUCERS",
url: "https://edm.com/gear-tech/top-ai-tools-music-producers",
},
{
name: "New Google research: What we now know about 'decoding' consumer decision-making",
url: "https://www.thinkwithgoogle.com/intl/en-emea/consumer-insights/consumer-journey/the-consumer-decision-making-process/",
},
{
name: "Drug Overdose Death Rates",
url: "https://nida.nih.gov/research-topics/trends-statistics/overdose-death-rates",
},
{
name: "Explore the latest research making an impact in your field",
url: "https://biologue.plos.org/2023/10/25/latest-biological-science-research/",
},
];
for (const link of projectAlphaLinks) {
await prisma.link.create({
data: {
name: link.name,
url: link.url,
collectionId: projectAlphaCollection.id,
},
});
}
for (const [collectionName, links] of Object.entries(linksAndCollections)) {
let collection = await prisma.collection.findFirst({
where: {
name: collectionName,
ownerId: user1.id,
},
});
if (!collection) {
collection = await prisma.collection.create({
data: {
name: collectionName,
ownerId: user1.id,
},
});
}
for (const link of links) {
await prisma.link.create({
data: {
name: link.name,
url: link.url,
collectionId: collection.id,
},
});
}
}
const tags = [
{ name: "technology", ownerId: user1.id },
{ name: "finance", ownerId: user1.id },
{ name: "future", ownerId: user1.id },
{ name: "health", ownerId: user1.id },
{ name: "hacks", ownerId: user1.id },
{ name: "lifestyle", ownerId: user1.id },
{ name: "routine", ownerId: user1.id },
{ name: "personal", ownerId: user1.id },
];
});
return transaction;
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});
const linksAndCollections = {
"Health and Wellness": [
{
name: "50 Wellness Gifts for Anyone Who Could Use Some Self-Care",
url: "https://www.self.com/gallery/healthy-gift-ideas-for-wellness-gurus",
},
{
name: "Hearing aids slow cognitive decline in people at high risk",
url: "https://www.nih.gov/news-events/nih-research-matters/hearing-aids-slow-cognitive-decline-people-high-risk",
},
{
name: "Why Are Healthy Habits Important at Work and Home?",
url: "https://info.totalwellnesshealth.com/blog/why-are-healthy-habits-important",
},
{
name: "Wellness Travel BC explores shifting travel trends as health and wellness take center stage for Canadians",
url: "https://www.vancouverisawesome.com/sponsored/wellness-travel-bc-explores-shifting-travel-trends-as-health-and-wellness-take-center-stage-for-canadians-8004505",
},
{
name: "50 Wellness Gifts for Anyone Who Could Use Some Self-Care",
url: "https://www.self.com/gallery/healthy-gift-ideas-for-wellness-gurus",
},
{
name: "Example",
url: "https://example.com",
},
{
name: "Example",
url: "https://example.com",
},
{
name: "Example",
url: "https://example.com",
},
{
name: "Example",
url: "https://example.com",
},
],
Research: [
{
name: "More than 10,000 research papers were retracted in 2023 — a new record",
url: "https://www.nature.com/articles/d41586-023-03974-8",
},
{
name: "Advances in Liver Cancer Research",
url: "https://www.cancer.gov/types/liver/research",
},
{
name: "NEW RESEARCH REVEALS TOP AI TOOLS UTILIZED BY MUSIC PRODUCERS",
url: "https://edm.com/gear-tech/top-ai-tools-music-producers",
},
{
name: "New Google research: What we now know about 'decoding' consumer decision-making",
url: "https://www.thinkwithgoogle.com/intl/en-emea/consumer-insights/consumer-journey/the-consumer-decision-making-process/",
},
{
name: "Drug Overdose Death Rates",
url: "https://nida.nih.gov/research-topics/trends-statistics/overdose-death-rates",
},
{
name: "Explore the latest research making an impact in your field",
url: "https://biologue.plos.org/2023/10/25/latest-biological-science-research/",
},
{
name: "Example",
url: "https://example.com",
},
],
Technology: [
{
name: "These six questions will dictate the future of generative AI",
url: "https://www.technologyreview.com/2023/12/19/1084505/generative-ai-artificial-intelligence-bias-jobs-copyright-misinformation/",
},
{
name: "Q&A: People will only use technology they trust, Microsoft expert says",
url: "https://www.euronews.com/next/2023/12/21/qa-people-will-only-use-technology-they-trust-microsoft-expert-says",
},
{
name: "How technology and economics can help save endangered species",
url: "https://news.osu.edu/how-technology-and-economics-can-help-save-endangered-species/",
},
{
name: "How technology can help save Indigenous forests and our planet",
url: "https://www.eco-business.com/opinion/how-technology-can-help-save-indigenous-forests-and-our-planet/",
},
{
name: "The most energy-efficient way to build homes",
url: "https://www.technologyreview.com/2023/12/22/1084532/passive-house-energy-efficient-harold-orr/",
},
{
name: "Using virtual reality to diagnose Alzheimer's disease",
url: "https://www.bbc.com/news/technology-67794645",
},
],
"Personal Finance": [
{
name: "Turn your homes empty bedroom into $875 in monthly rent",
url: "https://www.theglobeandmail.com/investing/personal-finance/household-finances/article-turn-your-homes-empty-bedroom-into-875-in-monthly-rent/",
},
{
name: "Dont let financial constraints slow down your gift-giving",
url: "https://www.thespec.com/life/personal-finance/don-t-let-financial-constraints-slow-down-your-gift-giving/article_e3c99ac5-912c-59a9-a815-654befcd4c9c.html",
},
{
name: "The worst retirement planning mistakes you should avoid, according to an expert",
url: "https://www.ctvnews.ca/business/the-worst-retirement-planning-mistakes-you-should-avoid-according-to-an-expert-1.6694093",
},
{
name: "What to Do About That Credit-Card Debt",
url: "https://www.thecut.com/2023/12/what-to-do-about-that-credit-card-debt.html",
},
{
name: "How to become rich: Nine golden personal finance rules that may help you make money",
url: "https://www.livemint.com/money/personal-finance/how-to-become-rich-nine-golden-personal-finance-rules-that-may-help-you-make-money-11703059139843.html",
},
{
name: "Saving Money: Smart Strategies for Keeping Your Financial New Years Resolutions",
url: "https://www.tipranks.com/news/personal-finance/saving-money-smart-strategies-for-keeping-your-financial-new-years-resolutions",
},
{
name: "Example",
url: "https://example.com",
},
{
name: "Example",
url: "https://example.com",
},
],
Productivity: [
{
name: "Efficiency Vs. Productivity At Work: How To Balance Both",
url: "https://www.forbes.com/sites/carolinecastrillon/2023/12/20/efficiency-vs-productivity-at-work-how-to-increase-both/?sh=4c7d486f1bee",
},
{
name: "Is it worth measuring software developer productivity? CIOs weigh in",
url: "https://www.cio.com/article/1255774/is-it-worth-measuring-software-developer-productivity-cios-weigh-in.html",
},
{
name: "Avoid These 10 Business Habits to Increase Workplace Productivity",
url: "https://www.entrepreneur.com/growing-a-business/10-bad-business-habits-that-destroy-productivity/466381",
},
{
name: "The value of productivity",
url: "https://www.tribuneindia.com/news/musings/the-value-of-productivity-573858",
},
{
name: "This new Canonical feature solves my biggest problem with online productivity apps",
url: "https://www.zdnet.com/article/canonical-will-soon-make-it-even-easier-to-work-with-google-workspace-and-office-365-online/",
},
{
name: "10 Practical Recommendations for Increasing Work Results and Value",
url: "https://www.inc.com/martin-zwilling/10-practical-recommendations-for-increasing-work-results-value.html",
},
{
name: "Example",
url: "https://example.com",
},
{
name: "Example",
url: "https://example.com",
},
{
name: "Example",
url: "https://example.com",
},
{
name: "Example",
url: "https://example.com",
},
{
name: "Example",
url: "https://example.com",
},
{
name: "Example",
url: "https://example.com",
},
],
Recipes: [
{
name: "Joe Woodhouses vegetarian standouts for Christmas day recipes",
url: "https://www.theguardian.com/food/2023/dec/22/joe-woodhouses-vegetarian-standouts-for-christmas-day-recipes",
},
{
name: "10 cookie recipes to bake for your holiday party",
url: "https://www.deseret.com/2023/12/21/24009656/best-holiday-cookie-recipes",
},
{
name: "The Best Potato Recipes for Holiday Season and Beyond, According to Eater Staff",
url: "https://www.eater.com/24003490/the-best-potato-recipes-for-holiday-season-and-beyond-according-to-eater-staff",
},
{
name: "The Most-Saved Recipes in the Epicurious App This Week",
url: "https://www.epicurious.com/recipes-menus/most-saved-recipes",
},
{
name: "11 Brand-New Recipes to Try This Month",
url: "https://www.tasteofhome.com/collection/new-recipes-to-try/",
},
{
name: "19 Baked Pasta Recipes for Golden, Gooey Comfort",
url: "https://www.bonappetit.com/gallery/baked-pasta-recipes",
},
{
name: "Example",
url: "https://example.com",
},
{
name: "Example",
url: "https://example.com",
},
{
name: "Example",
url: "https://example.com",
},
{
name: "Example",
url: "https://example.com",
},
{
name: "Example",
url: "https://example.com",
},
{
name: "Example",
url: "https://example.com",
},
{
name: "Example",
url: "https://example.com",
},
],
};

View File

@ -23,7 +23,7 @@ async function processBatch() {
archiveAsScreenshot: true, archiveAsScreenshot: true,
}, },
}, },
screenshotPath: null, image: null,
}, },
{ {
collection: { collection: {
@ -31,7 +31,7 @@ async function processBatch() {
archiveAsScreenshot: true, archiveAsScreenshot: true,
}, },
}, },
screenshotPath: "pending", image: "pending",
}, },
/////////////////////// ///////////////////////
{ {
@ -40,7 +40,7 @@ async function processBatch() {
archiveAsPDF: true, archiveAsPDF: true,
}, },
}, },
pdfPath: null, pdf: null,
}, },
{ {
collection: { collection: {
@ -48,14 +48,14 @@ async function processBatch() {
archiveAsPDF: true, archiveAsPDF: true,
}, },
}, },
pdfPath: "pending", pdf: "pending",
}, },
/////////////////////// ///////////////////////
{ {
readabilityPath: null, readable: null,
}, },
{ {
readabilityPath: "pending", readable: "pending",
}, },
], ],
}, },
@ -80,7 +80,7 @@ async function processBatch() {
archiveAsScreenshot: true, archiveAsScreenshot: true,
}, },
}, },
screenshotPath: null, image: null,
}, },
{ {
collection: { collection: {
@ -88,7 +88,7 @@ async function processBatch() {
archiveAsScreenshot: true, archiveAsScreenshot: true,
}, },
}, },
screenshotPath: "pending", image: "pending",
}, },
/////////////////////// ///////////////////////
{ {
@ -97,7 +97,7 @@ async function processBatch() {
archiveAsPDF: true, archiveAsPDF: true,
}, },
}, },
pdfPath: null, pdf: null,
}, },
{ {
collection: { collection: {
@ -105,14 +105,14 @@ async function processBatch() {
archiveAsPDF: true, archiveAsPDF: true,
}, },
}, },
pdfPath: "pending", pdf: "pending",
}, },
/////////////////////// ///////////////////////
{ {
readabilityPath: null, readable: null,
}, },
{ {
readabilityPath: "pending", readable: "pending",
}, },
], ],
}, },