Skip to content

Commit 21d28c9

Browse files
eunjae-leeclaude
andauthored
refactor: apply biome formatting to packages/trpc (calcom#27928)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f8a9341 commit 21d28c9

80 files changed

Lines changed: 498 additions & 454 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/trpc/react/trpc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ export const trpc: CreateTRPCNext<AppRouter, NextPageContext, null> = createTRPC
5656
typeof window !== "undefined"
5757
? "/api/trpc"
5858
: process.env.VERCEL_URL
59-
? `https://${process.env.VERCEL_URL}/api/trpc`
60-
: `${process.env.NEXT_PUBLIC_WEBAPP_URL}/api/trpc`;
59+
? `https://${process.env.VERCEL_URL}/api/trpc`
60+
: `${process.env.NEXT_PUBLIC_WEBAPP_URL}/api/trpc`;
6161

6262
/**
6363
* If you want to use SSR, you need to use the server's full URL

packages/trpc/server/createContext.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,22 @@ export type CreateInnerContextOptions = {
2222
sourceIp?: string;
2323
session?: Session | null;
2424
locale: string;
25-
user?:
26-
| Omit<
27-
PrismaUser,
28-
| "locale"
29-
| "twoFactorSecret"
30-
| "emailVerified"
31-
| "password"
32-
| "identityProviderId"
33-
| "invitedTo"
34-
| "allowDynamicBooking"
35-
| "verified"
36-
> & {
37-
locale: Exclude<PrismaUser["locale"], null>;
38-
credentials?: Credential[];
39-
selectedCalendars?: Partial<SelectedCalendar>[];
40-
rawAvatar?: string;
41-
};
25+
user?: Omit<
26+
PrismaUser,
27+
| "locale"
28+
| "twoFactorSecret"
29+
| "emailVerified"
30+
| "password"
31+
| "identityProviderId"
32+
| "invitedTo"
33+
| "allowDynamicBooking"
34+
| "verified"
35+
> & {
36+
locale: Exclude<PrismaUser["locale"], null>;
37+
credentials?: Credential[];
38+
selectedCalendars?: Partial<SelectedCalendar>[];
39+
rawAvatar?: string;
40+
};
4241
i18n?: Awaited<ReturnType<typeof serverSideTranslations>>;
4342
} & Partial<CreateContextOptions>;
4443

packages/trpc/server/middlewares/sessionMiddleware.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ export async function getUserFromSession(ctx: TRPCContextInner, session: Maybe<S
4545
safeStringify({ user, userFromDb, upId })
4646
);
4747

48-
const { email, username, id, uuid } = user;
49-
if (!email || !id) {
50-
return null; // should we return null here?
51-
}
48+
const { email, username, id, uuid } = user;
49+
if (!email || !id) {
50+
return null; // should we return null here?
51+
}
5252

5353
const userMetaData = userMetadata.parse(user.metadata || {});
5454
const orgMetadata = teamMetadataSchema.parse(user.profile?.organization?.metadata || {});
@@ -71,20 +71,20 @@ export async function getUserFromSession(ctx: TRPCContextInner, session: Maybe<S
7171
requestedSlug: orgMetadata?.requestedSlug ?? null,
7272
};
7373

74-
return {
75-
...user,
76-
avatar: `${WEBAPP_URL}/${user.username}/avatar.png${organization.id ? `?orgId=${organization.id}` : ""}`,
77-
// TODO: OrgNewSchema - later - We could consolidate the props in user.profile?.organization as organization is a profile thing now.
78-
organization,
79-
organizationId: organization.id,
80-
id,
81-
uuid,
82-
email,
83-
username,
84-
locale,
85-
defaultBookerLayouts: userMetaData?.defaultBookerLayouts || null,
86-
requiresBookerEmailVerification: user.requiresBookerEmailVerification,
87-
};
74+
return {
75+
...user,
76+
avatar: `${WEBAPP_URL}/${user.username}/avatar.png${organization.id ? `?orgId=${organization.id}` : ""}`,
77+
// TODO: OrgNewSchema - later - We could consolidate the props in user.profile?.organization as organization is a profile thing now.
78+
organization,
79+
organizationId: organization.id,
80+
id,
81+
uuid,
82+
email,
83+
username,
84+
locale,
85+
defaultBookerLayouts: userMetaData?.defaultBookerLayouts || null,
86+
requiresBookerEmailVerification: user.requiresBookerEmailVerification,
87+
};
8888
}
8989

9090
export type UserFromSession = Awaited<ReturnType<typeof getUserFromSession>>;

packages/trpc/server/procedures/pbacProcedures.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ describe("Feature Opt-In PBAC Procedures", () => {
134134
permissions.forEach(({ permission, operation }) => {
135135
it(`should use ${permission} for ${operation} operations`, async () => {
136136
createTeamPbacProcedure(permission);
137-
const middleware = mockAuthedProcedure.use.mock.calls[mockAuthedProcedure.use.mock.calls.length - 1][0];
137+
const middleware =
138+
mockAuthedProcedure.use.mock.calls[mockAuthedProcedure.use.mock.calls.length - 1][0];
138139

139140
mockCheckPermission.mockResolvedValue(true);
140141

@@ -298,7 +299,8 @@ describe("Feature Opt-In PBAC Procedures", () => {
298299
permissions.forEach(({ permission, operation }) => {
299300
it(`should use ${permission} for ${operation} operations`, async () => {
300301
createOrgPbacProcedure(permission);
301-
const middleware = mockAuthedProcedure.use.mock.calls[mockAuthedProcedure.use.mock.calls.length - 1][0];
302+
const middleware =
303+
mockAuthedProcedure.use.mock.calls[mockAuthedProcedure.use.mock.calls.length - 1][0];
302304

303305
const mockCtx = {
304306
user: {

packages/trpc/server/routers/apps/routing-forms/_router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const getHandler = async <
2727
T extends {
2828
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
2929
default: Function;
30-
}
30+
},
3131
>(
3232
/**
3333
* The name of the handler in cache. It has to be unique across all routes

packages/trpc/server/routers/apps/routing-forms/entityPrismaWhereClause.integration.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,9 @@ describe("entityPrismaWhereClause Integration Tests", () => {
407407
ctx: { prisma, user },
408408
input: { id: "test" },
409409
});
410-
} catch { void 0; }
410+
} catch {
411+
void 0;
412+
}
411413

412414
// eslint-disable-next-line @typescript-eslint/no-explicit-any
413415
whereClause = (prisma.app_RoutingForms_Form.deleteMany as any).mock.calls[0][0].where;
@@ -440,15 +442,16 @@ describe("entityPrismaWhereClause Integration Tests", () => {
440442
input: { id: "test" },
441443
});
442444
// eslint-disable-next-line @typescript-eslint/no-explicit-any
443-
const formQueryWhere = (prisma.app_RoutingForms_Form.findFirst as any).mock.calls[0][0].where
444-
.AND[0];
445+
const formQueryWhere = (prisma.app_RoutingForms_Form.findFirst as any).mock.calls[0][0].where.AND[0];
445446

446447
try {
447448
await deleteFormHandler({
448449
ctx: { prisma, user },
449450
input: { id: "test" },
450451
});
451-
} catch { void 0; }
452+
} catch {
453+
void 0;
454+
}
452455
// eslint-disable-next-line @typescript-eslint/no-explicit-any
453456
const deleteFormWhere = (prisma.app_RoutingForms_Form.deleteMany as any).mock.calls[0][0].where;
454457

packages/trpc/server/routers/apps/routing-forms/formMutation.handler.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,7 @@ export const formMutationHandler = async ({ ctx, input }: FormMutationHandlerOpt
363363
});
364364
}
365365

366-
let fields: NonNullable<typeof fieldsParsed.data>,
367-
routes: NonNullable<typeof routesParsed.data>;
366+
let fields: NonNullable<typeof fieldsParsed.data>, routes: NonNullable<typeof routesParsed.data>;
368367
if (shouldConnect) {
369368
routes = [
370369
// This connected route would automatically link the fields

packages/trpc/server/routers/loggedInViewer/teamsAndUserProfilesQuery.handler.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@ export const teamsAndUserProfilesQuery = async ({ ctx, input }: TeamsAndUserProf
6767
throw new TRPCError({ code: "INTERNAL_SERVER_ERROR" });
6868
}
6969

70-
let teamsData: typeof user.teams extends (infer T)[] ? (T & { team: T extends { team: infer U } ? U & { metadata: ReturnType<typeof teamMetadataSchema.parse> } : never })[] : never;
70+
let teamsData: typeof user.teams extends (infer T)[]
71+
? (T & {
72+
team: T extends { team: infer U }
73+
? U & { metadata: ReturnType<typeof teamMetadataSchema.parse> }
74+
: never;
75+
})[]
76+
: never;
7177

7278
if (input?.includeOrg) {
7379
teamsData = user.teams

packages/trpc/server/routers/publicViewer/checkIfUserEmailVerificationRequired.schema.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ export type TUserEmailVerificationRequiredSchema = {
55
email: string;
66
};
77

8-
export const ZUserEmailVerificationRequiredSchema: z.ZodType<TUserEmailVerificationRequiredSchema> = z.object({
9-
userSessionEmail: z.string().optional(),
10-
email: z.string(),
11-
});
8+
export const ZUserEmailVerificationRequiredSchema: z.ZodType<TUserEmailVerificationRequiredSchema> = z.object(
9+
{
10+
userSessionEmail: z.string().optional(),
11+
email: z.string(),
12+
}
13+
);

packages/trpc/server/routers/publicViewer/event.schema.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ export type TEventInputSchemaInput = {
1313

1414
export type TEventInputSchema = GetPublicEventInput;
1515

16-
export const ZEventInputSchema: z.ZodType<TEventInputSchema, z.ZodTypeDef, TEventInputSchemaInput> = z.object({
17-
username: z.string(),
18-
eventSlug: z.string(),
19-
isTeamEvent: z.boolean().optional(),
20-
org: z.string().nullable(),
21-
/**
22-
* Informs that the event request has been sent from a page that was reached by a redirect from non-org link(i.e. app.cal.com/username redirected to acme.cal.com/username)
23-
* Based on this decision like whether to allow unpublished organization's event to be served or not can be made.
24-
*/
25-
fromRedirectOfNonOrgLink: z.boolean().optional().default(false),
26-
});
16+
export const ZEventInputSchema: z.ZodType<TEventInputSchema, z.ZodTypeDef, TEventInputSchemaInput> = z.object(
17+
{
18+
username: z.string(),
19+
eventSlug: z.string(),
20+
isTeamEvent: z.boolean().optional(),
21+
org: z.string().nullable(),
22+
/**
23+
* Informs that the event request has been sent from a page that was reached by a redirect from non-org link(i.e. app.cal.com/username redirected to acme.cal.com/username)
24+
* Based on this decision like whether to allow unpublished organization's event to be served or not can be made.
25+
*/
26+
fromRedirectOfNonOrgLink: z.boolean().optional().default(false),
27+
}
28+
);

0 commit comments

Comments
 (0)