Skip to content

Commit 727ee71

Browse files
rename prisma to __unsafePrisma
1 parent 53ffb9f commit 727ee71

File tree

22 files changed

+92
-97
lines changed

22 files changed

+92
-97
lines changed

packages/web/src/actions.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { addUserToOrganization, orgHasAvailability } from "@/lib/authUtils";
66
import { ErrorCode } from "@/lib/errorCodes";
77
import { notFound, orgNotFound, ServiceError } from "@/lib/serviceError";
88
import { getOrgMetadata, isHttpError, isServiceError } from "@/lib/utils";
9-
import { prisma } from "@/prisma";
9+
import { __unsafePrisma } from "@/prisma";
1010
import { render } from "@react-email/components";
1111
import { generateApiKey, getTokenFromConfig } from "@sourcebot/shared";
1212
import { ConnectionSyncJobStatus, OrgRole, Prisma, RepoIndexingJobStatus, RepoIndexingJobType } from "@sourcebot/db";
@@ -928,7 +928,7 @@ export const getOrgAccountRequests = async () => sew(() =>
928928
}));
929929

930930
export const createAccountRequest = async (userId: string) => sew(async () => {
931-
const user = await prisma.user.findUnique({
931+
const user = await __unsafePrisma.user.findUnique({
932932
where: {
933933
id: userId,
934934
},
@@ -938,7 +938,7 @@ export const createAccountRequest = async (userId: string) => sew(async () => {
938938
return notFound("User not found");
939939
}
940940

941-
const org = await prisma.org.findUnique({
941+
const org = await __unsafePrisma.org.findUnique({
942942
where: {
943943
id: SINGLE_TENANT_ORG_ID,
944944
},
@@ -948,7 +948,7 @@ export const createAccountRequest = async (userId: string) => sew(async () => {
948948
return notFound("Organization not found");
949949
}
950950

951-
const existingRequest = await prisma.accountRequest.findUnique({
951+
const existingRequest = await __unsafePrisma.accountRequest.findUnique({
952952
where: {
953953
requestedById_orgId: {
954954
requestedById: userId,
@@ -966,7 +966,7 @@ export const createAccountRequest = async (userId: string) => sew(async () => {
966966
}
967967

968968
if (!existingRequest) {
969-
await prisma.accountRequest.create({
969+
await __unsafePrisma.accountRequest.create({
970970
data: {
971971
requestedById: userId,
972972
orgId: org.id,
@@ -979,7 +979,7 @@ export const createAccountRequest = async (userId: string) => sew(async () => {
979979
// on user creation (the header isn't set when next-auth calls onCreateUser for some reason)
980980
const deploymentUrl = env.AUTH_URL;
981981

982-
const owner = await prisma.user.findFirst({
982+
const owner = await __unsafePrisma.user.findFirst({
983983
where: {
984984
orgs: {
985985
some: {
@@ -1030,7 +1030,7 @@ export const createAccountRequest = async (userId: string) => sew(async () => {
10301030
});
10311031

10321032
export const getMemberApprovalRequired = async (): Promise<boolean | ServiceError> => sew(async () => {
1033-
const org = await prisma.org.findUnique({
1033+
const org = await __unsafePrisma.org.findUnique({
10341034
where: {
10351035
id: SINGLE_TENANT_ORG_ID,
10361036
},
@@ -1277,7 +1277,7 @@ export const getRepoImage = async (repoId: number): Promise<ArrayBuffer | Servic
12771277
});
12781278

12791279
export const getAnonymousAccessStatus = async (): Promise<boolean | ServiceError> => sew(async () => {
1280-
const org = await prisma.org.findUnique({
1280+
const org = await __unsafePrisma.org.findUnique({
12811281
where: { id: SINGLE_TENANT_ORG_ID },
12821282
});
12831283
if (!org) {

packages/web/src/app/(app)/askgh/[owner]/[repo]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { addGithubRepo } from "@/features/workerApi/actions";
22
import { isServiceError } from "@/lib/utils";
33
import { ServiceErrorException } from "@/lib/serviceError";
4-
import { prisma } from "@/prisma";
4+
import { __unsafePrisma } from "@/prisma";
55
import { getRepoInfo } from "./api";
66
import { CustomSlateEditor } from "@/features/chat/customSlateEditor";
77
import { RepoIndexedGuard } from "./components/repoIndexedGuard";
@@ -21,7 +21,7 @@ export default async function GitHubRepoPage(props: PageProps) {
2121
const repoId = await (async () => {
2222
// 1. Look up repo by owner/repo
2323
const displayName = `${owner}/${repo}`;
24-
const existingRepo = await prisma.repo.findFirst({
24+
const existingRepo = await __unsafePrisma.repo.findFirst({
2525
where: {
2626
displayName: displayName,
2727
external_codeHostType: 'github',

packages/web/src/app/(app)/chat/[id]/opengraph-image.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ImageResponse } from 'next/og';
22
import { notFound } from 'next/navigation';
3-
import { prisma } from '@/prisma';
3+
import { __unsafePrisma } from '@/prisma';
44
import { ChatVisibility } from '@sourcebot/db';
55
import { env } from "@sourcebot/shared";
66
import { minidenticon } from 'minidenticons';
@@ -22,7 +22,7 @@ interface ImageProps {
2222
export default async function Image({ params }: ImageProps) {
2323
const { id } = await params;
2424

25-
const chat = await prisma.chat.findUnique({
25+
const chat = await __unsafePrisma.chat.findUnique({
2626
where: {
2727
id,
2828
},

packages/web/src/app/(app)/chat/[id]/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { auth } from '@/auth';
1313
import { AnimatedResizableHandle } from '@/components/ui/animatedResizableHandle';
1414
import { ChatSidePanel } from '../components/chatSidePanel';
1515
import { ResizablePanelGroup } from '@/components/ui/resizable';
16-
import { prisma } from '@/prisma';
16+
import { __unsafePrisma } from '@/prisma';
1717
import { ChatVisibility } from '@sourcebot/db';
1818
import { Metadata } from 'next';
1919
import { SBChatMessage } from '@/features/chat/types';
@@ -26,10 +26,10 @@ interface PageProps {
2626
}>;
2727
}
2828

29-
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
29+
export const generateMetadata = async ({ params }: PageProps): Promise<Metadata> => {
3030
const { id } = await params;
3131

32-
const chat = await prisma.chat.findUnique({
32+
const chat = await __unsafePrisma.chat.findUnique({
3333
where: {
3434
id,
3535
},

packages/web/src/app/(app)/layout.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { prisma } from "@/prisma";
1+
import { __unsafePrisma } from "@/prisma";
22
import { auth } from "@/auth";
33
import { isServiceError } from "@/lib/utils";
44
import { SINGLE_TENANT_ORG_ID } from "@/lib/constants";
@@ -35,7 +35,7 @@ export default async function Layout(props: LayoutProps) {
3535
children
3636
} = props;
3737

38-
const org = await prisma.org.findUnique({
38+
const org = await __unsafePrisma.org.findUnique({
3939
where: { id: SINGLE_TENANT_ORG_ID },
4040
});
4141

@@ -59,7 +59,7 @@ export default async function Layout(props: LayoutProps) {
5959

6060
// If the user is authenticated, we must check if they're a member of the org
6161
if (session) {
62-
const membership = await prisma.userToOrg.findUnique({
62+
const membership = await __unsafePrisma.userToOrg.findUnique({
6363
where: {
6464
orgId_userId: {
6565
orgId: org.id,
@@ -85,7 +85,7 @@ export default async function Layout(props: LayoutProps) {
8585
</div>
8686
)
8787
} else {
88-
const hasPendingApproval = await prisma.accountRequest.findFirst({
88+
const hasPendingApproval = await __unsafePrisma.accountRequest.findFirst({
8989
where: {
9090
orgId: org.id,
9191
requestedById: session.user.id

packages/web/src/app/api/(server)/ee/oauth/register/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { apiHandler } from '@/lib/apiHandler';
22
import { requestBodySchemaValidationError, serviceErrorResponse } from '@/lib/serviceError';
3-
import { prisma } from '@/prisma';
3+
import { __unsafePrisma } from '@/prisma';
44
import { hasEntitlement } from '@sourcebot/shared';
55
import { NextRequest } from 'next/server';
66
import { z } from 'zod';
@@ -39,7 +39,7 @@ export const POST = apiHandler(async (request: NextRequest) => {
3939
);
4040
}
4141

42-
const client = await prisma.oAuthClient.create({
42+
const client = await __unsafePrisma.oAuthClient.create({
4343
data: {
4444
name: client_name,
4545
logoUri: logo_uri ?? null,

packages/web/src/app/components/organizationAccessSettings.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { AnonymousAccessToggle } from "./anonymousAccessToggle"
33
import { OrganizationAccessSettingsWrapper } from "./organizationAccessSettingsWrapper"
44
import { getOrgMetadata } from "@/lib/utils"
55
import { SINGLE_TENANT_ORG_ID } from "@/lib/constants"
6-
import { prisma } from "@/prisma"
6+
import { __unsafePrisma } from "@/prisma"
77
import { hasEntitlement, env } from "@sourcebot/shared"
88

99
export async function OrganizationAccessSettings() {
10-
const org = await prisma.org.findUnique({ where: { id: SINGLE_TENANT_ORG_ID } });
10+
const org = await __unsafePrisma.org.findUnique({ where: { id: SINGLE_TENANT_ORG_ID } });
1111
if (!org) {
1212
return <div>Error loading organization</div>
1313
}

packages/web/src/app/invite/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { auth } from "@/auth";
2-
import { prisma } from "@/prisma";
2+
import { __unsafePrisma } from "@/prisma";
33
import { SINGLE_TENANT_ORG_ID } from "@/lib/constants";
44
import { notFound, redirect } from "next/navigation";
55
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
@@ -17,7 +17,7 @@ interface InvitePageProps {
1717

1818
export default async function InvitePage(props: InvitePageProps) {
1919
const searchParams = await props.searchParams;
20-
const org = await prisma.org.findUnique({ where: { id: SINGLE_TENANT_ORG_ID } });
20+
const org = await __unsafePrisma.org.findUnique({ where: { id: SINGLE_TENANT_ORG_ID } });
2121
if (!org || !org.isOnboarded) {
2222
return redirect("/onboard");
2323
}
@@ -33,7 +33,7 @@ export default async function InvitePage(props: InvitePageProps) {
3333
return <WelcomeCard inviteLinkId={inviteLinkId} providers={providers} />;
3434
}
3535

36-
const membership = await prisma.userToOrg.findUnique({
36+
const membership = await __unsafePrisma.userToOrg.findUnique({
3737
where: {
3838
orgId_userId: {
3939
orgId: org.id,

packages/web/src/app/login/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { redirect } from "next/navigation";
44
import { Footer } from "@/app/components/footer";
55
import { getIdentityProviderMetadata } from "@/lib/identityProviders";
66
import { SINGLE_TENANT_ORG_ID } from "@/lib/constants";
7-
import { prisma } from "@/prisma";
7+
import { __unsafePrisma } from "@/prisma";
88
import { getAnonymousAccessStatus } from "@/actions";
99
import { isServiceError } from "@/lib/utils";
1010
import { env } from "@sourcebot/shared";
@@ -23,7 +23,7 @@ export default async function Login(props: LoginProps) {
2323
return redirect("/");
2424
}
2525

26-
const org = await prisma.org.findUnique({ where: { id: SINGLE_TENANT_ORG_ID } });
26+
const org = await __unsafePrisma.org.findUnique({ where: { id: SINGLE_TENANT_ORG_ID } });
2727
if (!org || !org.isOnboarded) {
2828
return redirect("/onboard");
2929
}

packages/web/src/app/oauth/authorize/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { auth } from '@/auth';
22
import { LogoutEscapeHatch } from '@/app/components/logoutEscapeHatch';
33
import { ConsentScreen } from './components/consentScreen';
4-
import { prisma } from '@/prisma';
4+
import { __unsafePrisma } from '@/prisma';
55
import { hasEntitlement } from '@sourcebot/shared';
66
import { redirect } from 'next/navigation';
77

@@ -47,7 +47,7 @@ export default async function AuthorizePage({ searchParams }: AuthorizePageProps
4747
return <ErrorPage message={`Unsupported code_challenge_method: ${code_challenge_method}. Only "S256" is supported.`} />;
4848
}
4949

50-
const client = await prisma.oAuthClient.findUnique({ where: { id: client_id } });
50+
const client = await __unsafePrisma.oAuthClient.findUnique({ where: { id: client_id } });
5151

5252
if (!client) {
5353
return <ErrorPage message="Unknown client_id. The application has not been registered." />;

0 commit comments

Comments
 (0)