perf: reduce TypeScript type bloat in tRPC package via z.ZodType annotations (#25845)

* fix: prevent Prisma conditional types from leaking into .d.ts files

This PR addresses TypeScript performance issues caused by Prisma's conditional types leaking through the type graph:

1. Replace Prisma.UserGetPayload with explicit UpdatedUserResult type in updateProfile.handler.ts
2. Replace Prisma.EventTypeGetPayload with explicit UpdatedEventTypeResult type in update.handler.ts
3. Replace Prisma.OutOfOfficeEntryGetPayload with explicit OOOEntryResult type in outOfOfficeCreateOrUpdate.handler.ts
4. Replace Prisma.CredentialGetPayload with explicit Credential type in getUserConnectedApps.handler.ts
5. Fix inconsistent DI usage in EventTypeRepository - use this.prismaClient instead of global prisma singleton

These changes prevent massive recursive Prisma types from propagating through the type graph and being emitted in .d.ts files, which improves TypeScript performance.

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* fix: correct reasonId type to number | null in OOOEntryResult

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* perf: add z.ZodType annotations to reduce .d.ts file sizes

- Annotate exported Zod schemas with z.ZodType<T> to prevent full Zod generic tree from being emitted in declaration files
- eventTypes/types.d.ts reduced from 231KB to 115KB (50% reduction)
- _app.d.ts reduced from 782KB to 753KB (3.7% reduction)
- viewer/_router.d.ts reduced from 722KB to 695KB (3.7% reduction)
- workflows/getAllActiveWorkflows.schema.d.ts significantly reduced
- routing-forms/formMutation.schema.d.ts significantly reduced

Files modified:
- packages/trpc/server/routers/viewer/eventTypes/types.ts
- packages/trpc/server/routers/viewer/workflows/getAllActiveWorkflows.schema.ts
- packages/trpc/server/routers/apps/routing-forms/formMutation.schema.ts
- packages/features/eventtypes/lib/types.ts

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* perf: comprehensive z.ZodType annotations to reduce .d.ts file sizes

Applied z.ZodType<T> annotations to 89 schema files across the tRPC package.
This prevents TypeScript from emitting the full Zod generic tree in .d.ts files,
reducing declaration file sizes for downstream consumers.

Files modified include schemas in:
- viewer/teams (round-robin, managed events, invitations, etc.)
- viewer/bookings (get, find, confirm, etc.)
- viewer/eventTypes (get, delete, getByViewer, etc.)
- viewer/workflows (list, delete, verify, etc.)
- viewer/auth (changePassword, verifyPassword, etc.)
- viewer/apiKeys (create, delete, edit, etc.)
- viewer/sso (get, update, delete, updateOIDC)
- viewer/oAuth (addClient, generateAuthCode)
- viewer/calendars (setDestinationCalendar)
- viewer/deploymentSetup (update, validateLicense)
- apps/routing-forms (formQuery, deleteForm, etc.)
- publicViewer (submitRating, markHostAsNoShow, etc.)
- loggedInViewer (eventTypeOrder, routingFormOrder, etc.)

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* fix: revert slots/types.ts z.ZodType annotation that caused type mismatch

The slots/types.ts schema has a transform that converts duration from
string to number, which makes the z.ZodType<T> annotation incompatible.
Reverting to original to fix Unit test failure.

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* fix: use 3-generic z.ZodType pattern for schemas with .default() modifiers

For schemas with .default() modifiers, the input and output types differ:
- Input type: field is optional (what callers send)
- Output type: field is required (what handlers receive after parsing)

This commit:
1. Fixes get.schema.ts (offset has .default(0))
2. Fixes removeMember.schema.ts (isOrg has .default(false))
3. Fixes resendInvitation.schema.ts (isOrg has .default(false))
4. Fixes listMembers.schema.ts (limit has .default(10))
5. Fixes getByViewer.schema.ts (limit has .default(10))
6. Reverts eventTypes/types.ts (complex transforms hard to model)
7. Reverts features/eventtypes/lib/types.ts (complex transforms hard to model)

The 3-generic pattern z.ZodType<Output, z.ZodTypeDef, Input> properly models
the difference between input and output types while still preventing the full
Zod generic tree from being emitted in .d.ts files.

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* fix: use 3-generic z.ZodType pattern for schemas with transforms/defaults

- organizations/update.schema.ts: orgId has .transform() that converts string to number, so input type is string | number but output type is number
- publicViewer/event.schema.ts: fromRedirectOfNonOrgLink has .default(false), so input has it optional but output has it required

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* fix: use 3-generic z.ZodType pattern for updateProfile.schema.ts

Address reviewer feedback: isDeleted field in secondaryEmails has .default(false),
so input type has it optional but output type has it required.

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* chore: remove explanatory comments from schema files

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* fix: use 3-generic z.ZodType pattern for addClient.schema.ts enablePkce field

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* fix: address Hariom's PR feedback

- Rename TGetInputSchemaInput to TGetInputRawSchema in get.schema.ts
- Use Prisma-free JsonValue type from @calcom/types/Json in updateProfile.handler.ts
- Fix publish.schema.ts with 3-generic pattern for z.coerce.number()

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* fix: add sort field to TGetInputSchema types

Added sort field to both TGetInputRawSchema and TGetInputSchema types
to match the Zod schema that was updated in main branch.

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Keith Williams
2025-12-17 15:06:57 -03:00
committed by GitHub
co-authored by Devin AI
parent c20f6cbdd6
commit 15b1675db1
93 changed files with 908 additions and 303 deletions
@@ -8,11 +8,7 @@ import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import { eventTypeSelect } from "@calcom/lib/server/eventTypeSelect";
import type { PrismaClient } from "@calcom/prisma";
import {
prisma,
availabilityUserSelect,
userSelect as userSelectWithSelectedCalendars,
} from "@calcom/prisma";
import { availabilityUserSelect, userSelect as userSelectWithSelectedCalendars } from "@calcom/prisma";
import type { EventType as PrismaEventType } from "@calcom/prisma/client";
import type { Prisma } from "@calcom/prisma/client";
import { MembershipRole } from "@calcom/prisma/enums";
@@ -490,7 +486,7 @@ export class EventTypeRepository {
if (!teamMembership) throw new ErrorWithCode(ErrorCode.Unauthorized, "User is not a member of this team");
return await prisma.eventType.findMany({
return await this.prismaClient.eventType.findMany({
where: {
teamId,
...where,
@@ -1,7 +1,9 @@
import z from "zod";
export const ZDeleteFormInputSchema = z.object({
export type TDeleteFormInputSchema = {
id: string;
};
export const ZDeleteFormInputSchema: z.ZodType<TDeleteFormInputSchema> = z.object({
id: z.string(),
});
export type TDeleteFormInputSchema = z.infer<typeof ZDeleteFormInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZFormQueryInputSchema = z.object({
export type TFormQueryInputSchema = {
id: string;
};
export const ZFormQueryInputSchema: z.ZodType<TFormQueryInputSchema> = z.object({
id: z.string(),
});
export type TFormQueryInputSchema = z.infer<typeof ZFormQueryInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZGetAttributesForTeamInputSchema = z.object({
export type TGetAttributesForTeamInputSchema = {
teamId: number;
};
export const ZGetAttributesForTeamInputSchema: z.ZodType<TGetAttributesForTeamInputSchema> = z.object({
teamId: z.number(),
});
export type TGetAttributesForTeamInputSchema = z.infer<typeof ZGetAttributesForTeamInputSchema>;
@@ -1,9 +1,10 @@
import z from "zod";
export const ZGetIncompleteBookingSettingsInputSchema = z.object({
formId: z.string(),
});
export type TGetIncompleteBookingSettingsInputSchema = {
formId: string;
};
export type TGetIncompleteBookingSettingsInputSchema = z.infer<
typeof ZGetIncompleteBookingSettingsInputSchema
>;
export const ZGetIncompleteBookingSettingsInputSchema: z.ZodType<TGetIncompleteBookingSettingsInputSchema> =
z.object({
formId: z.string(),
});
@@ -1,5 +1,9 @@
import { z } from "zod";
export const ZFormByResponseIdInputSchema = z.object({
export type TFormByResponseIdInputSchema = {
formResponseId: number;
};
export const ZFormByResponseIdInputSchema: z.ZodType<TFormByResponseIdInputSchema> = z.object({
formResponseId: z.number(),
});
@@ -1,9 +1,10 @@
import { z } from "zod";
export const ZAddNotificationsSubscriptionInputSchema = z.object({
subscription: z.string(),
});
export type TAddNotificationsSubscriptionInputSchema = {
subscription: string;
};
export type TAddNotificationsSubscriptionInputSchema = z.infer<
typeof ZAddNotificationsSubscriptionInputSchema
>;
export const ZAddNotificationsSubscriptionInputSchema: z.ZodType<TAddNotificationsSubscriptionInputSchema> =
z.object({
subscription: z.string(),
});
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZAddSecondaryEmailInputSchema = z.object({
export type TAddSecondaryEmailInputSchema = {
email: string;
};
export const ZAddSecondaryEmailInputSchema: z.ZodType<TAddSecondaryEmailInputSchema> = z.object({
email: z.string(),
});
export type TAddSecondaryEmailInputSchema = z.infer<typeof ZAddSecondaryEmailInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZConnectAndJoinInputSchema = z.object({
export type TConnectAndJoinInputSchema = {
token: string;
};
export const ZConnectAndJoinInputSchema: z.ZodType<TConnectAndJoinInputSchema> = z.object({
token: z.string(),
});
export type TConnectAndJoinInputSchema = z.infer<typeof ZConnectAndJoinInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZEventTypeOrderInputSchema = z.object({
export type TEventTypeOrderInputSchema = {
ids: number[];
};
export const ZEventTypeOrderInputSchema: z.ZodType<TEventTypeOrderInputSchema> = z.object({
ids: z.array(z.number()),
});
export type TEventTypeOrderInputSchema = z.infer<typeof ZEventTypeOrderInputSchema>;
@@ -1,9 +1,10 @@
import { z } from "zod";
export const ZRemoveNotificationsSubscriptionInputSchema = z.object({
subscription: z.string(),
});
export type TRemoveNotificationsSubscriptionInputSchema = {
subscription: string;
};
export type TRemoveNotificationsSubscriptionInputSchema = z.infer<
typeof ZRemoveNotificationsSubscriptionInputSchema
>;
export const ZRemoveNotificationsSubscriptionInputSchema: z.ZodType<TRemoveNotificationsSubscriptionInputSchema> =
z.object({
subscription: z.string(),
});
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZRoutingFormOrderInputSchema = z.object({
export type TRoutingFormOrderInputSchema = {
ids: string[];
};
export const ZRoutingFormOrderInputSchema: z.ZodType<TRoutingFormOrderInputSchema> = z.object({
ids: z.array(z.string()),
});
export type TRoutingFormOrderInputSchema = z.infer<typeof ZRoutingFormOrderInputSchema>;
@@ -1,8 +1,11 @@
import { z } from "zod";
export const ZUserEmailVerificationRequiredSchema = z.object({
export type TUserEmailVerificationRequiredSchema = {
userSessionEmail?: string;
email: string;
};
export const ZUserEmailVerificationRequiredSchema: z.ZodType<TUserEmailVerificationRequiredSchema> = z.object({
userSessionEmail: z.string().optional(),
email: z.string(),
});
export type TUserEmailVerificationRequiredSchema = z.infer<typeof ZUserEmailVerificationRequiredSchema>;
@@ -1,6 +1,24 @@
import z from "zod";
export const ZEventInputSchema = z.object({
// Note: fromRedirectOfNonOrgLink has .default(false), so input has it optional but output has it required
export type TEventInputSchemaInput = {
username: string;
eventSlug: string;
isTeamEvent?: boolean;
org: string | null;
fromRedirectOfNonOrgLink?: boolean;
};
export type TEventInputSchema = {
username: string;
eventSlug: string;
isTeamEvent?: boolean;
org: string | null;
fromRedirectOfNonOrgLink: boolean;
};
export const ZEventInputSchema: z.ZodType<TEventInputSchema, z.ZodTypeDef, TEventInputSchemaInput> = z.object({
username: z.string(),
eventSlug: z.string(),
isTeamEvent: z.boolean().optional(),
@@ -11,5 +29,3 @@ export const ZEventInputSchema = z.object({
*/
fromRedirectOfNonOrgLink: z.boolean().optional().default(false),
});
export type TEventInputSchema = z.infer<typeof ZEventInputSchema>;
@@ -1,8 +1,11 @@
import { z } from "zod";
export const ZMarkHostAsNoShowInputSchema = z.object({
export type TNoShowInputSchema = {
bookingUid: string;
noShowHost: boolean;
};
export const ZMarkHostAsNoShowInputSchema: z.ZodType<TNoShowInputSchema> = z.object({
bookingUid: z.string(),
noShowHost: z.boolean(),
});
export type TNoShowInputSchema = z.infer<typeof ZMarkHostAsNoShowInputSchema>;
@@ -2,8 +2,10 @@ import { z } from "zod";
import { emailSchema } from "@calcom/lib/emailSchema";
export const ZSamlTenantProductInputSchema = z.object({
export type TSamlTenantProductInputSchema = {
email: string;
};
export const ZSamlTenantProductInputSchema: z.ZodType<TSamlTenantProductInputSchema> = z.object({
email: emailSchema,
});
export type TSamlTenantProductInputSchema = z.infer<typeof ZSamlTenantProductInputSchema>;
@@ -1,9 +1,13 @@
import { z } from "zod";
export const ZSubmitRatingInputSchema = z.object({
export type TSubmitRatingInputSchema = {
bookingUid: string;
rating: number;
comment?: string;
};
export const ZSubmitRatingInputSchema: z.ZodType<TSubmitRatingInputSchema> = z.object({
bookingUid: z.string(),
rating: z.number(),
comment: z.string().optional(),
});
export type TSubmitRatingInputSchema = z.infer<typeof ZSubmitRatingInputSchema>;
@@ -1,11 +1,17 @@
import { z } from "zod";
export const ZCreateInputSchema = z.object({
export type TCreateInputSchema = {
note?: string | null;
expiresAt?: Date | null;
neverExpires?: boolean;
appId?: string | null;
teamId?: number;
};
export const ZCreateInputSchema: z.ZodType<TCreateInputSchema> = z.object({
note: z.string().optional().nullish(),
expiresAt: z.date().optional().nullable(),
neverExpires: z.boolean().optional(),
appId: z.string().optional().nullable(),
teamId: z.number().optional(),
});
export type TCreateInputSchema = z.infer<typeof ZCreateInputSchema>;
@@ -1,8 +1,11 @@
import { z } from "zod";
export const ZDeleteInputSchema = z.object({
export type TDeleteInputSchema = {
id: string;
eventTypeId?: number;
};
export const ZDeleteInputSchema: z.ZodType<TDeleteInputSchema> = z.object({
id: z.string(),
eventTypeId: z.number().optional(),
});
export type TDeleteInputSchema = z.infer<typeof ZDeleteInputSchema>;
@@ -1,9 +1,13 @@
import { z } from "zod";
export const ZEditInputSchema = z.object({
export type TEditInputSchema = {
id: string;
note?: string | null;
expiresAt?: Date;
};
export const ZEditInputSchema: z.ZodType<TEditInputSchema> = z.object({
id: z.string(),
note: z.string().optional().nullish(),
expiresAt: z.date().optional(),
});
export type TEditInputSchema = z.infer<typeof ZEditInputSchema>;
@@ -1,8 +1,11 @@
import { z } from "zod";
export const ZFindKeyOfTypeInputSchema = z.object({
export type TFindKeyOfTypeInputSchema = {
appId?: string;
teamId?: number;
};
export const ZFindKeyOfTypeInputSchema: z.ZodType<TFindKeyOfTypeInputSchema> = z.object({
appId: z.string().optional(),
teamId: z.number().optional(),
});
export type TFindKeyOfTypeInputSchema = z.infer<typeof ZFindKeyOfTypeInputSchema>;
@@ -2,14 +2,19 @@ import { z } from "zod";
import { zodAttributesQueryValue } from "@calcom/lib/raqb/zod";
export const ZFindTeamMembersMatchingAttributeLogicInputSchema = z.object({
teamId: z.number(),
attributesQueryValue: zodAttributesQueryValue.nullable(),
isPreview: z.boolean().optional(),
_enablePerf: z.boolean().optional(),
_concurrency: z.number().optional(),
});
export type TFindTeamMembersMatchingAttributeLogicInputSchema = {
teamId: number;
attributesQueryValue: z.infer<typeof zodAttributesQueryValue> | null;
isPreview?: boolean;
_enablePerf?: boolean;
_concurrency?: number;
};
export type TFindTeamMembersMatchingAttributeLogicInputSchema = z.infer<
typeof ZFindTeamMembersMatchingAttributeLogicInputSchema
>;
export const ZFindTeamMembersMatchingAttributeLogicInputSchema: z.ZodType<TFindTeamMembersMatchingAttributeLogicInputSchema> =
z.object({
teamId: z.number(),
attributesQueryValue: zodAttributesQueryValue.nullable(),
isPreview: z.boolean().optional(),
_enablePerf: z.boolean().optional(),
_concurrency: z.number().optional(),
});
@@ -1,8 +1,11 @@
import { z } from "zod";
export const ZChangePasswordInputSchema = z.object({
export type TChangePasswordInputSchema = {
oldPassword: string;
newPassword: string;
};
export const ZChangePasswordInputSchema: z.ZodType<TChangePasswordInputSchema> = z.object({
oldPassword: z.string(),
newPassword: z.string(),
});
export type TChangePasswordInputSchema = z.infer<typeof ZChangePasswordInputSchema>;
@@ -1,10 +1,15 @@
import { z } from "zod";
export const ZSendVerifyEmailCodeSchema = z.object({
export type TSendVerifyEmailCodeSchema = {
email: string;
username?: string;
language: string;
isVerifyingEmail?: boolean;
};
export const ZSendVerifyEmailCodeSchema: z.ZodType<TSendVerifyEmailCodeSchema> = z.object({
email: z.string().min(1),
username: z.string().optional(),
language: z.string(),
isVerifyingEmail: z.boolean().optional(),
});
export type TSendVerifyEmailCodeSchema = z.infer<typeof ZSendVerifyEmailCodeSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZVerifyPasswordInputSchema = z.object({
export type TVerifyPasswordInputSchema = {
passwordInput: string;
};
export const ZVerifyPasswordInputSchema: z.ZodType<TVerifyPasswordInputSchema> = z.object({
passwordInput: z.string(),
});
export type TVerifyPasswordInputSchema = z.infer<typeof ZVerifyPasswordInputSchema>;
@@ -1,6 +1,12 @@
import { z } from "zod";
export const ZCreateInputSchema = z.object({
export type TCreateInputSchema = {
name: string;
schedule?: { start: Date; end: Date }[][];
eventTypeId?: number;
};
export const ZCreateInputSchema: z.ZodType<TCreateInputSchema> = z.object({
name: z.string(),
schedule: z
.array(
@@ -14,5 +20,3 @@ export const ZCreateInputSchema = z.object({
.optional(),
eventTypeId: z.number().optional(),
});
export type TCreateInputSchema = z.infer<typeof ZCreateInputSchema>;
@@ -1,6 +1,14 @@
import { z } from "zod";
const ZGuestSchema = z.object({
type TGuestSchema = {
email: string;
name?: string;
timeZone?: string;
phoneNumber?: string;
language?: string;
};
const ZGuestSchema: z.ZodType<TGuestSchema> = z.object({
email: z.string().email(),
name: z.string().optional(),
timeZone: z.string().optional(),
@@ -8,9 +16,12 @@ const ZGuestSchema = z.object({
language: z.string().optional(),
});
export const ZAddGuestsInputSchema = z.object({
export type TAddGuestsInputSchema = {
bookingId: number;
guests: TGuestSchema[];
};
export const ZAddGuestsInputSchema: z.ZodType<TAddGuestsInputSchema> = z.object({
bookingId: z.number(),
guests: z.array(ZGuestSchema),
});
export type TAddGuestsInputSchema = z.infer<typeof ZAddGuestsInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZFindInputSchema = z.object({
export type TFindInputSchema = {
bookingUid?: string;
};
export const ZFindInputSchema: z.ZodType<TFindInputSchema> = z.object({
bookingUid: z.string().optional(),
});
export type TFindInputSchema = z.infer<typeof ZFindInputSchema>;
@@ -2,7 +2,47 @@ import { z } from "zod";
import { ZTextFilterValue } from "@calcom/features/data-table/lib/types";
export const ZGetInputSchema = z.object({
// Note: offset has .default(0), so input type has it optional but output type has it required
type BookingStatus = "upcoming" | "recurring" | "past" | "cancelled" | "unconfirmed";
type TGetInputSchemaFilters = {
teamIds?: number[];
userIds?: number[];
status?: BookingStatus;
statuses?: BookingStatus[];
eventTypeIds?: number[];
attendeeEmail?: string | z.infer<typeof ZTextFilterValue>;
attendeeName?: string | z.infer<typeof ZTextFilterValue>;
bookingUid?: string;
afterStartDate?: string;
beforeEndDate?: string;
afterUpdatedDate?: string;
beforeUpdatedDate?: string;
afterCreatedDate?: string;
beforeCreatedDate?: string;
};
type TGetInputSchemaSort = {
sortStart?: "asc" | "desc";
};
export type TGetInputRawSchema = {
filters: TGetInputSchemaFilters;
limit: number;
offset?: number;
cursor?: string;
sort?: TGetInputSchemaSort;
};
export type TGetInputSchema = {
filters: TGetInputSchemaFilters;
limit: number;
offset: number;
cursor?: string;
sort?: TGetInputSchemaSort;
};
export const ZGetInputSchema: z.ZodType<TGetInputSchema, z.ZodTypeDef, TGetInputRawSchema> = z.object({
filters: z.object({
teamIds: z.number().array().optional(),
userIds: z.number().array().optional(),
@@ -31,5 +71,3 @@ export const ZGetInputSchema = z.object({
})
.optional(),
});
export type TGetInputSchema = z.infer<typeof ZGetInputSchema>;
@@ -1,8 +1,10 @@
import { z } from "zod";
export const ZGetAuditLogsInputSchema = z.object({
bookingUid: z.string(),
export type TGetAuditLogsInputSchema = {
bookingUid: string;
};
export const ZGetAuditLogsInputSchema: z.ZodType<TGetAuditLogsInputSchema> = z.object({
bookingUid: z.string(),
});
export type TGetAuditLogsInputSchema = z.infer<typeof ZGetAuditLogsInputSchema>;
@@ -1,5 +1,9 @@
import { z } from "zod";
export const ZGetBookingAttendeesInputSchema = z.object({ seatReferenceUid: z.string().uuid() });
export type TGetBookingAttendeesInputSchema = {
seatReferenceUid: string;
};
export type TGetBookingAttendeesInputSchema = z.infer<typeof ZGetBookingAttendeesInputSchema>;
export const ZGetBookingAttendeesInputSchema: z.ZodType<TGetBookingAttendeesInputSchema> = z.object({
seatReferenceUid: z.string().uuid(),
});
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZGetBookingDetailsInputSchema = z.object({
export type TGetBookingDetailsInputSchema = {
uid: string;
};
export const ZGetBookingDetailsInputSchema: z.ZodType<TGetBookingDetailsInputSchema> = z.object({
uid: z.string(),
});
export type TGetBookingDetailsInputSchema = z.infer<typeof ZGetBookingDetailsInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZInstantBookingInputSchema = z.object({
export type TInstantBookingInputSchema = {
bookingId: number;
};
export const ZInstantBookingInputSchema: z.ZodType<TInstantBookingInputSchema> = z.object({
bookingId: z.number(),
});
export type TInstantBookingInputSchema = z.infer<typeof ZInstantBookingInputSchema>;
@@ -2,10 +2,14 @@ import { z } from "zod";
import { BookingReportReason } from "@calcom/prisma/enums";
export const ZReportBookingInputSchema = z.object({
export type TReportBookingInputSchema = {
bookingUid: string;
reason: BookingReportReason;
description?: string;
};
export const ZReportBookingInputSchema: z.ZodType<TReportBookingInputSchema> = z.object({
bookingUid: z.string(),
reason: z.nativeEnum(BookingReportReason),
description: z.string().optional(),
});
export type TReportBookingInputSchema = z.infer<typeof ZReportBookingInputSchema>;
@@ -1,8 +1,11 @@
import { z } from "zod";
export const ZRequestRescheduleInputSchema = z.object({
export type TRequestRescheduleInputSchema = {
bookingUid: string;
rescheduleReason?: string;
};
export const ZRequestRescheduleInputSchema: z.ZodType<TRequestRescheduleInputSchema> = z.object({
bookingUid: z.string(),
rescheduleReason: z.string().optional(),
});
export type TRequestRescheduleInputSchema = z.infer<typeof ZRequestRescheduleInputSchema>;
@@ -1,10 +1,15 @@
import { z } from "zod";
export const ZSetDestinationCalendarInputSchema = z.object({
export type TSetDestinationCalendarInputSchema = {
integration: string;
externalId: string;
eventTypeId?: number | null;
bookingId?: number | null;
};
export const ZSetDestinationCalendarInputSchema: z.ZodType<TSetDestinationCalendarInputSchema> = z.object({
integration: z.string(),
externalId: z.string(),
eventTypeId: z.number().nullish(),
bookingId: z.number().nullish(),
});
export type TSetDestinationCalendarInputSchema = z.infer<typeof ZSetDestinationCalendarInputSchema>;
@@ -1,8 +1,11 @@
import { z } from "zod";
export const ZUpdateInputSchema = z.object({
export type TUpdateInputSchema = {
licenseKey?: string;
signatureToken?: string;
};
export const ZUpdateInputSchema: z.ZodType<TUpdateInputSchema> = z.object({
licenseKey: z.string().optional(),
signatureToken: z.string().optional(),
});
export type TUpdateInputSchema = z.infer<typeof ZUpdateInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZValidateLicenseInputSchema = z.object({
export type TValidateLicenseInputSchema = {
licenseKey: string;
};
export const ZValidateLicenseInputSchema: z.ZodType<TValidateLicenseInputSchema> = z.object({
licenseKey: z.string().min(1, "License key is required"),
});
export type TValidateLicenseInputSchema = z.infer<typeof ZValidateLicenseInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZDeleteInputSchema = z.object({
export type TDeleteInputSchema = {
id: number;
};
export const ZDeleteInputSchema: z.ZodType<TDeleteInputSchema> = z.object({
id: z.number(),
});
export type TDeleteInputSchema = z.infer<typeof ZDeleteInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZGetInputSchema = z.object({
export type TGetInputSchema = {
id: number;
};
export const ZGetInputSchema: z.ZodType<TGetInputSchema> = z.object({
id: z.number(),
});
export type TGetInputSchema = z.infer<typeof ZGetInputSchema>;
@@ -2,23 +2,51 @@ import { z } from "zod";
import { SchedulingType } from "@calcom/prisma/enums";
export const filterQuerySchemaStrict = z.object({
// Define types first to use with z.ZodType annotation
export type TFilterQuerySchemaStrict = {
teamIds?: number[];
upIds?: string[];
schedulingTypes?: SchedulingType[];
};
export const filterQuerySchemaStrict: z.ZodType<TFilterQuerySchemaStrict> = z.object({
teamIds: z.number().array().optional(),
// A user can only filter by only his userId
upIds: z.string().array().max(1).optional(),
schedulingTypes: z.nativeEnum(SchedulingType).array().optional(),
});
export const ZEventTypeInputSchema = z
export type TEventTypeInputSchema = {
filters?: TFilterQuerySchemaStrict;
forRoutingForms?: boolean;
} | null | undefined;
export const ZEventTypeInputSchema: z.ZodType<TEventTypeInputSchema> = z
.object({
filters: filterQuerySchemaStrict.optional(),
forRoutingForms: z.boolean().optional(),
})
.nullish();
export type TEventTypeInputSchema = z.infer<typeof ZEventTypeInputSchema>;
export type TGetEventTypesFromGroupSchemaInput = {
filters?: TFilterQuerySchemaStrict;
forRoutingForms?: boolean;
cursor?: number | null;
limit?: number;
group: { teamId?: number | null; parentId?: number | null };
searchQuery?: string;
};
export const ZGetEventTypesFromGroupSchema = z.object({
export type TGetEventTypesFromGroupSchema = {
filters?: TFilterQuerySchemaStrict;
forRoutingForms?: boolean;
cursor?: number | null;
limit: number;
group: { teamId?: number | null; parentId?: number | null };
searchQuery?: string;
};
export const ZGetEventTypesFromGroupSchema: z.ZodType<TGetEventTypesFromGroupSchema, z.ZodTypeDef, TGetEventTypesFromGroupSchemaInput> = z.object({
filters: filterQuerySchemaStrict.optional(),
forRoutingForms: z.boolean().optional(),
cursor: z.number().nullish(),
@@ -26,5 +54,3 @@ export const ZGetEventTypesFromGroupSchema = z.object({
group: z.object({ teamId: z.number().nullish(), parentId: z.number().nullish() }),
searchQuery: z.string().optional(),
});
export type TGetEventTypesFromGroupSchema = z.infer<typeof ZGetEventTypesFromGroupSchema>;
@@ -684,7 +684,14 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
slug: true,
schedulingType: true,
} satisfies Prisma.EventTypeSelect;
let updatedEventType: Prisma.EventTypeGetPayload<{ select: typeof updatedEventTypeSelect }>;
// Explicit type to avoid Prisma.EventTypeGetPayload conditional types leaking into .d.ts files
type UpdatedEventTypeResult = {
slug: string;
schedulingType: import("@calcom/prisma/enums").SchedulingType | null;
};
let updatedEventType: UpdatedEventTypeResult;
try {
updatedEventType = await ctx.prisma.eventType.update({
where: { id },
@@ -18,6 +18,7 @@ import slugify from "@calcom/lib/slugify";
import { validateBookerLayouts } from "@calcom/lib/validateBookerLayouts";
import { prisma } from "@calcom/prisma";
import { Prisma } from "@calcom/prisma/client";
import type { JsonValue } from "@calcom/types/Json";
import { userMetadata as userMetadataSchema } from "@calcom/prisma/zod-utils";
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
@@ -240,7 +241,22 @@ export const updateProfileHandler = async ({ ctx, input }: UpdateProfileOptions)
},
} satisfies Prisma.UserDefaultArgs;
let updatedUser: Prisma.UserGetPayload<typeof updatedUserSelect>;
// Explicit type to avoid Prisma.UserGetPayload conditional types leaking into .d.ts files
type UpdatedUserResult = {
id: number;
username: string | null;
email: string;
identityProvider: string | null;
identityProviderId: string | null;
metadata: JsonValue;
name: string | null;
createdDate: Date;
avatarUrl: string | null;
locale: string | null;
schedules: { id: number }[];
};
let updatedUser: UpdatedUserResult;
try {
updatedUser = await prisma.user.update({
@@ -4,12 +4,87 @@ import { FULL_NAME_LENGTH_MAX_LIMIT } from "@calcom/lib/constants";
import { timeZoneSchema } from "@calcom/lib/dayjs/timeZone.schema";
import { bookerLayouts, userMetadata } from "@calcom/prisma/zod-utils";
export const updateUserMetadataAllowedKeys = z.object({
export type TUpdateUserMetadataAllowedKeys = {
sessionTimeout?: number;
defaultBookerLayouts?: z.infer<typeof bookerLayouts>;
};
export const updateUserMetadataAllowedKeys: z.ZodType<TUpdateUserMetadataAllowedKeys> = z.object({
sessionTimeout: z.number().optional(), // Minutes
defaultBookerLayouts: bookerLayouts.optional(),
});
export const ZUpdateProfileInputSchema = z.object({
export type TUpdateProfileInputSchemaInput = {
username?: string;
name?: string;
email?: string;
bio?: string;
avatarUrl?: string | null;
timeZone?: string;
weekStart?: string;
hideBranding?: boolean;
allowDynamicBooking?: boolean;
allowSEOIndexing?: boolean;
receiveMonthlyDigestEmail?: boolean;
requiresBookerEmailVerification?: boolean;
brandColor?: string;
darkBrandColor?: string;
theme?: string | null;
appTheme?: string | null;
completedOnboarding?: boolean;
locale?: string;
timeFormat?: number;
disableImpersonation?: boolean;
metadata?: z.infer<typeof userMetadata>;
travelSchedules?: {
id?: number;
timeZone: string;
endDate?: Date;
startDate: Date;
}[];
secondaryEmails?: {
id: number;
email: string;
isDeleted?: boolean;
}[];
};
export type TUpdateProfileInputSchema = {
username?: string;
name?: string;
email?: string;
bio?: string;
avatarUrl?: string | null;
timeZone?: string;
weekStart?: string;
hideBranding?: boolean;
allowDynamicBooking?: boolean;
allowSEOIndexing?: boolean;
receiveMonthlyDigestEmail?: boolean;
requiresBookerEmailVerification?: boolean;
brandColor?: string;
darkBrandColor?: string;
theme?: string | null;
appTheme?: string | null;
completedOnboarding?: boolean;
locale?: string;
timeFormat?: number;
disableImpersonation?: boolean;
metadata?: z.infer<typeof userMetadata>;
travelSchedules?: {
id?: number;
timeZone: string;
endDate?: Date;
startDate: Date;
}[];
secondaryEmails?: {
id: number;
email: string;
isDeleted: boolean;
}[];
};
export const ZUpdateProfileInputSchema: z.ZodType<TUpdateProfileInputSchema, z.ZodTypeDef, TUpdateProfileInputSchemaInput> = z.object({
username: z.string().optional(),
name: z.string().max(FULL_NAME_LENGTH_MAX_LIMIT).optional(),
email: z.string().optional(),
@@ -51,5 +126,3 @@ export const ZUpdateProfileInputSchema = z.object({
)
.optional(),
});
export type TUpdateProfileInputSchema = z.infer<typeof ZUpdateProfileInputSchema>;
@@ -1,10 +1,22 @@
import { z } from "zod";
export const ZAddClientInputSchema = z.object({
export type TAddClientInputSchemaInput = {
name: string;
redirectUri: string;
logo: string;
enablePkce?: boolean;
};
export type TAddClientInputSchema = {
name: string;
redirectUri: string;
logo: string;
enablePkce: boolean;
};
export const ZAddClientInputSchema: z.ZodType<TAddClientInputSchema, z.ZodTypeDef, TAddClientInputSchemaInput> = z.object({
name: z.string(),
redirectUri: z.string(),
logo: z.string(),
enablePkce: z.boolean().optional().default(false),
});
export type TAddClientInputSchema = z.infer<typeof ZAddClientInputSchema>;
@@ -1,11 +1,17 @@
import { z } from "zod";
export const ZGenerateAuthCodeInputSchema = z.object({
export type TGenerateAuthCodeInputSchema = {
clientId: string;
scopes: string[];
teamSlug?: string;
codeChallenge?: string;
codeChallengeMethod?: "S256";
};
export const ZGenerateAuthCodeInputSchema: z.ZodType<TGenerateAuthCodeInputSchema> = z.object({
clientId: z.string(),
scopes: z.array(z.string()),
teamSlug: z.string().optional(),
codeChallenge: z.string().optional(),
codeChallengeMethod: z.enum(["S256"]).optional(),
});
export type TGenerateAuthCodeInputSchema = z.infer<typeof ZGenerateAuthCodeInputSchema>;
@@ -9,7 +9,6 @@ import type { OOOEntryPayloadType } from "@calcom/features/webhooks/lib/sendPayl
import sendPayload from "@calcom/features/webhooks/lib/sendPayload";
import { getTranslation } from "@calcom/lib/server/i18n";
import prisma from "@calcom/prisma";
import type { Prisma } from "@calcom/prisma/client";
import { WebhookTriggerEvents } from "@calcom/prisma/enums";
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
@@ -196,7 +195,23 @@ export const outOfOfficeCreateOrUpdate = async ({ ctx, input }: TBookingRedirect
toUserId: toUserId ? toUserId : null,
},
});
let resultRedirect: Prisma.OutOfOfficeEntryGetPayload<{ select: typeof selectOOOEntries }> | null = null;
// Explicit type to avoid Prisma.OutOfOfficeEntryGetPayload conditional types leaking into .d.ts files
type OOOEntryResult = {
id: number;
start: Date;
end: Date;
createdAt: Date;
updatedAt: Date;
notes: string | null;
showNotePublicly: boolean;
reason: { reason: string; emoji: string } | null;
reasonId: number | null;
user: { id: number; name: string | null; email: string; timeZone: string };
toUser: { id: number; name: string | null; email: string; timeZone: string } | null;
uuid: string;
};
let resultRedirect: OOOEntryResult | null = null;
if (createdOrUpdatedOutOfOffice) {
const findRedirect = await prisma.outOfOfficeEntry.findUnique({
where: {
@@ -9,7 +9,16 @@ const ZListMembersFilter = z.object({
value: ZFilterValue,
});
export const ZListMembersInputSchema = z.object({
export type TListMembersSchema = {
limit: number;
offset: number;
searchTerm?: string;
expand?: ("attributes")[];
filters?: { id: string; value: z.infer<typeof ZFilterValue> }[];
oAuthClientId?: string;
};
export const ZListMembersInputSchema: z.ZodType<TListMembersSchema> = z.object({
limit: z.number().min(1).max(100),
offset: z.number(),
searchTerm: z.string().optional(),
@@ -17,5 +26,3 @@ export const ZListMembersInputSchema = z.object({
filters: z.array(ZListMembersFilter).optional(),
oAuthClientId: z.string().optional(),
});
export type TListMembersSchema = z.infer<typeof ZListMembersInputSchema>;
@@ -3,7 +3,81 @@ import { z } from "zod";
import { timeZoneSchema } from "@calcom/lib/dayjs/timeZone.schema";
import { teamMetadataStrictSchema } from "@calcom/prisma/zod-utils";
export const ZUpdateInputSchema = z.object({
// Note: orgId has .transform() that converts string to number, so input accepts string | number but output is always number
export type TUpdateInputSchemaInput = {
name?: string;
orgId?: string | number;
bio?: string;
logoUrl?: string | null;
calVideoLogo?: string | null;
banner?: string | null;
slug?: string;
hideBranding?: boolean;
hideBookATeamMember?: boolean;
brandColor?: string;
darkBrandColor?: string;
theme?: string | null;
timeZone?: string;
weekStart?: string;
timeFormat?: number;
metadata?: z.infer<ReturnType<typeof teamMetadataStrictSchema.unwrap>>;
lockEventTypeCreation?: boolean;
lockEventTypeCreationOptions?: "DELETE" | "HIDE";
adminGetsNoSlotsNotification?: boolean;
allowSEOIndexing?: boolean;
orgProfileRedirectsToVerifiedDomain?: boolean;
disablePhoneOnlySMSNotifications?: boolean;
disableAutofillOnBookingPage?: boolean;
orgAutoJoinOnSignup?: boolean;
disableAttendeeConfirmationEmail?: boolean;
disableAttendeeCancellationEmail?: boolean;
disableAttendeeRescheduledEmail?: boolean;
disableAttendeeRequestEmail?: boolean;
disableAttendeeReassignedEmail?: boolean;
disableAttendeeAwaitingPaymentEmail?: boolean;
disableAttendeeRescheduleRequestEmail?: boolean;
disableAttendeeLocationChangeEmail?: boolean;
disableAttendeeNewEventEmail?: boolean;
};
export type TUpdateInputSchema = {
name?: string;
orgId?: number;
bio?: string;
logoUrl?: string | null;
calVideoLogo?: string | null;
banner?: string | null;
slug?: string;
hideBranding?: boolean;
hideBookATeamMember?: boolean;
brandColor?: string;
darkBrandColor?: string;
theme?: string | null;
timeZone?: string;
weekStart?: string;
timeFormat?: number;
metadata?: z.infer<ReturnType<typeof teamMetadataStrictSchema.unwrap>>;
lockEventTypeCreation?: boolean;
lockEventTypeCreationOptions?: "DELETE" | "HIDE";
adminGetsNoSlotsNotification?: boolean;
allowSEOIndexing?: boolean;
orgProfileRedirectsToVerifiedDomain?: boolean;
disablePhoneOnlySMSNotifications?: boolean;
disableAutofillOnBookingPage?: boolean;
orgAutoJoinOnSignup?: boolean;
disableAttendeeConfirmationEmail?: boolean;
disableAttendeeCancellationEmail?: boolean;
disableAttendeeRescheduledEmail?: boolean;
disableAttendeeRequestEmail?: boolean;
disableAttendeeReassignedEmail?: boolean;
disableAttendeeAwaitingPaymentEmail?: boolean;
disableAttendeeRescheduleRequestEmail?: boolean;
disableAttendeeLocationChangeEmail?: boolean;
disableAttendeeNewEventEmail?: boolean;
};
export const ZUpdateInputSchema: z.ZodType<TUpdateInputSchema, z.ZodTypeDef, TUpdateInputSchemaInput> = z.object({
name: z.string().optional(),
orgId: z
.string()
@@ -47,5 +121,3 @@ export const ZUpdateInputSchema = z.object({
disableAttendeeLocationChangeEmail: z.boolean().optional(),
disableAttendeeNewEventEmail: z.boolean().optional(),
});
export type TUpdateInputSchema = z.infer<typeof ZUpdateInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZDeleteInputSchema = z.object({
export type TDeleteInputSchema = {
teamId: number | null;
};
export const ZDeleteInputSchema: z.ZodType<TDeleteInputSchema> = z.object({
teamId: z.union([z.number(), z.null()]),
});
export type TDeleteInputSchema = z.infer<typeof ZDeleteInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZGetInputSchema = z.object({
export type TGetInputSchema = {
teamId: number | null;
};
export const ZGetInputSchema: z.ZodType<TGetInputSchema> = z.object({
teamId: z.union([z.number(), z.null()]),
});
export type TGetInputSchema = z.infer<typeof ZGetInputSchema>;
@@ -1,8 +1,11 @@
import { z } from "zod";
export const ZUpdateInputSchema = z.object({
export type TUpdateInputSchema = {
encodedRawMetadata: string;
teamId: number | null;
};
export const ZUpdateInputSchema: z.ZodType<TUpdateInputSchema> = z.object({
encodedRawMetadata: z.string(),
teamId: z.union([z.number(), z.null()]),
});
export type TUpdateInputSchema = z.infer<typeof ZUpdateInputSchema>;
@@ -1,10 +1,15 @@
import { z } from "zod";
export const ZUpdateOIDCInputSchema = z.object({
export type TUpdateOIDCInputSchema = {
teamId: number | null;
clientId: string;
clientSecret: string;
wellKnownUrl: string;
};
export const ZUpdateOIDCInputSchema: z.ZodType<TUpdateOIDCInputSchema> = z.object({
teamId: z.union([z.number(), z.null()]),
clientId: z.string(),
clientSecret: z.string(),
wellKnownUrl: z.string(),
});
export type TUpdateOIDCInputSchema = z.infer<typeof ZUpdateOIDCInputSchema>;
@@ -1,8 +1,11 @@
import { z } from "zod";
export const ZAcceptOrLeaveInputSchema = z.object({
export type TAcceptOrLeaveInputSchema = {
teamId: number;
accept: boolean;
};
export const ZAcceptOrLeaveInputSchema: z.ZodType<TAcceptOrLeaveInputSchema> = z.object({
teamId: z.number(),
accept: z.boolean(),
});
export type TAcceptOrLeaveInputSchema = z.infer<typeof ZAcceptOrLeaveInputSchema>;
@@ -1,9 +1,13 @@
import { z } from "zod";
export const ZAddMembersToEventTypes = z.object({
export type TAddMembersToEventTypes = {
userIds: number[];
teamId: number;
eventTypeIds: number[];
};
export const ZAddMembersToEventTypes: z.ZodType<TAddMembersToEventTypes> = z.object({
userIds: z.array(z.number()),
teamId: z.number(),
eventTypeIds: z.array(z.number()),
});
export type TAddMembersToEventTypes = z.infer<typeof ZAddMembersToEventTypes>;
@@ -2,10 +2,14 @@ import { z } from "zod";
import { MembershipRole } from "@calcom/prisma/enums";
export const ZChangeMemberRoleInputSchema = z.object({
export type TChangeMemberRoleInputSchema = {
teamId: number;
memberId: number;
role: MembershipRole | string;
};
export const ZChangeMemberRoleInputSchema: z.ZodType<TChangeMemberRoleInputSchema> = z.object({
teamId: z.number(),
memberId: z.number(),
role: z.union([z.nativeEnum(MembershipRole), z.string()]), // Support both traditional roles and custom role IDs
});
export type TChangeMemberRoleInputSchema = z.infer<typeof ZChangeMemberRoleInputSchema>;
@@ -1,8 +1,11 @@
import { z } from "zod";
export const ZCheckIfMembershipExistsInputSchema = z.object({
export type TCheckIfMembershipExistsInputSchema = {
teamId: number;
value: string;
};
export const ZCheckIfMembershipExistsInputSchema: z.ZodType<TCheckIfMembershipExistsInputSchema> = z.object({
teamId: z.number(),
value: z.string(),
});
export type TCheckIfMembershipExistsInputSchema = z.infer<typeof ZCheckIfMembershipExistsInputSchema>;
@@ -2,7 +2,15 @@ import { z } from "zod";
import slugify from "@calcom/lib/slugify";
export const ZCreateInputSchema = z.object({
export type TCreateInputSchema = {
name: string;
slug: string;
logo?: string | null;
bio?: string;
isOnboarding?: boolean;
};
export const ZCreateInputSchema: z.ZodType<TCreateInputSchema> = z.object({
name: z.string(),
slug: z.string().transform((val) => slugify(val.trim())),
logo: z
@@ -13,5 +21,3 @@ export const ZCreateInputSchema = z.object({
bio: z.string().optional(),
isOnboarding: z.boolean().optional(),
});
export type TCreateInputSchema = z.infer<typeof ZCreateInputSchema>;
@@ -1,8 +1,11 @@
import { z } from "zod";
export const ZCreateInviteInputSchema = z.object({
export type TCreateInviteInputSchema = {
teamId: number;
token?: string;
};
export const ZCreateInviteInputSchema: z.ZodType<TCreateInviteInputSchema> = z.object({
teamId: z.number(),
token: z.string().optional(),
});
export type TCreateInviteInputSchema = z.infer<typeof ZCreateInviteInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZDeleteInputSchema = z.object({
export type TDeleteInputSchema = {
teamId: number;
};
export const ZDeleteInputSchema: z.ZodType<TDeleteInputSchema> = z.object({
teamId: z.number(),
});
export type TDeleteInputSchema = z.infer<typeof ZDeleteInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZDeleteInviteInputSchema = z.object({
export type TDeleteInviteInputSchema = {
token: string;
};
export const ZDeleteInviteInputSchema: z.ZodType<TDeleteInviteInputSchema> = z.object({
token: z.string(),
});
export type TDeleteInviteInputSchema = z.infer<typeof ZDeleteInviteInputSchema>;
@@ -1,8 +1,11 @@
import { z } from "zod";
export const ZGetSchema = z.object({
export type TGetInputSchema = {
teamId: number;
isOrg?: boolean;
};
export const ZGetSchema: z.ZodType<TGetInputSchema> = z.object({
teamId: z.number(),
isOrg: z.boolean().optional(),
});
export type TGetInputSchema = z.infer<typeof ZGetSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZGetInternalNotesPresetsInputSchema = z.object({
export type TGetInternalNotesPresetsInputSchema = {
teamId: number;
};
export const ZGetInternalNotesPresetsInputSchema: z.ZodType<TGetInternalNotesPresetsInputSchema> = z.object({
teamId: z.number(),
});
export type TGetInternalNotesPresetsInputSchema = z.infer<typeof ZGetInternalNotesPresetsInputSchema>;
@@ -2,12 +2,18 @@ import { z } from "zod";
import { timeZoneSchema } from "@calcom/lib/dayjs/timeZone.schema";
export const ZGetMemberAvailabilityInputSchema = z.object({
export type TGetMemberAvailabilityInputSchema = {
teamId: number;
memberId: number;
timezone: string;
dateFrom: string;
dateTo: string;
};
export const ZGetMemberAvailabilityInputSchema: z.ZodType<TGetMemberAvailabilityInputSchema> = z.object({
teamId: z.number(),
memberId: z.number(),
timezone: timeZoneSchema,
dateFrom: z.string(),
dateTo: z.string(),
});
export type TGetMemberAvailabilityInputSchema = z.infer<typeof ZGetMemberAvailabilityInputSchema>;
@@ -1,8 +1,11 @@
import { z } from "zod";
export const ZGetMembershipbyUserInputSchema = z.object({
export type TGetMembershipbyUserInputSchema = {
teamId: number;
memberId: number;
};
export const ZGetMembershipbyUserInputSchema: z.ZodType<TGetMembershipbyUserInputSchema> = z.object({
teamId: z.number(),
memberId: z.number(),
});
export type TGetMembershipbyUserInputSchema = z.infer<typeof ZGetMembershipbyUserInputSchema>;
@@ -28,7 +28,12 @@ const credentialSelect = {
},
} satisfies Prisma.CredentialSelect;
type Credential = Prisma.CredentialGetPayload<{ select: typeof credentialSelect }>;
// Explicit type to avoid Prisma.CredentialGetPayload conditional types leaking into .d.ts files
type Credential = {
userId: number | null;
app: { slug: string; categories: AppCategories[] } | null;
destinationCalendars: { externalId: string }[];
};
type Apps = {
name: string | null;
@@ -1,8 +1,11 @@
import { z } from "zod";
export const ZGetUserConnectedAppsInputSchema = z.object({
export type TGetUserConnectedAppsInputSchema = {
userIds: number[];
teamId: number;
};
export const ZGetUserConnectedAppsInputSchema: z.ZodType<TGetUserConnectedAppsInputSchema> = z.object({
userIds: z.array(z.number()),
teamId: z.number(),
});
export type TGetUserConnectedAppsInputSchema = z.infer<typeof ZGetUserConnectedAppsInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZHasEditPermissionForUserSchema = z.object({
export type THasEditPermissionForUserSchema = {
memberId: number;
};
export const ZHasEditPermissionForUserSchema: z.ZodType<THasEditPermissionForUserSchema> = z.object({
memberId: z.number(),
});
export type THasEditPermissionForUserSchema = z.infer<typeof ZHasEditPermissionForUserSchema>;
@@ -2,9 +2,12 @@ import { z } from "zod";
import { CreationSource } from "@calcom/prisma/enums";
export const ZInviteMemberByTokenSchemaInputSchema = z.object({
export type TInviteMemberByTokenSchemaInputSchema = {
token: string;
creationSource: CreationSource;
};
export const ZInviteMemberByTokenSchemaInputSchema: z.ZodType<TInviteMemberByTokenSchemaInputSchema> = z.object({
token: z.string(),
creationSource: z.nativeEnum(CreationSource),
});
export type TInviteMemberByTokenSchemaInputSchema = z.infer<typeof ZInviteMemberByTokenSchemaInputSchema>;
@@ -1,10 +1,24 @@
import { z } from "zod";
export const ZListMembersInputSchema = z.object({
// Note: limit has .default(10), so input type has it optional but output type has it required
export type TListMembersInputSchemaInput = {
teamId: number;
limit?: number;
searchTerm?: string;
cursor?: number | null;
};
export type TListMembersInputSchema = {
teamId: number;
limit: number;
searchTerm?: string;
cursor?: number | null;
};
export const ZListMembersInputSchema: z.ZodType<TListMembersInputSchema, z.ZodTypeDef, TListMembersInputSchemaInput> = z.object({
teamId: z.number(),
limit: z.number().default(10),
searchTerm: z.string().optional(),
cursor: z.number().optional().nullable(),
});
export type TListMembersInputSchema = z.infer<typeof ZListMembersInputSchema>;
@@ -1,12 +1,15 @@
import { z } from "zod";
export const ZManagedEventManualReassignInputSchema = z.object({
bookingId: z.number().int(),
teamMemberId: z.number().int(),
reassignReason: z.string().optional(),
});
export type TManagedEventManualReassignInputSchema = {
bookingId: number;
teamMemberId: number;
reassignReason?: string;
};
export type TManagedEventManualReassignInputSchema = z.infer<
typeof ZManagedEventManualReassignInputSchema
>;
export const ZManagedEventManualReassignInputSchema: z.ZodType<TManagedEventManualReassignInputSchema> =
z.object({
bookingId: z.number().int(),
teamMemberId: z.number().int(),
reassignReason: z.string().optional(),
});
@@ -1,8 +1,10 @@
import { z } from "zod";
export const ZManagedEventReassignInputSchema = z.object({
export type TManagedEventReassignInputSchema = {
bookingId: number;
};
export const ZManagedEventReassignInputSchema: z.ZodType<TManagedEventReassignInputSchema> = z.object({
bookingId: z.number().int(),
});
export type TManagedEventReassignInputSchema = z.infer<typeof ZManagedEventReassignInputSchema>;
@@ -1,7 +1,13 @@
import { z } from "zod";
export const ZPublishInputSchema = z.object({
export type TPublishInputRawSchema = {
teamId: string | number;
};
export type TPublishInputSchema = {
teamId: number;
};
export const ZPublishInputSchema: z.ZodType<TPublishInputSchema, z.ZodTypeDef, TPublishInputRawSchema> = z.object({
teamId: z.coerce.number(),
});
export type TPublishInputSchema = z.infer<typeof ZPublishInputSchema>;
@@ -1,9 +1,13 @@
import { z } from "zod";
export const ZRemoveHostsFromEventTypes = z.object({
export type TRemoveHostsFromEventTypes = {
userIds: number[];
teamId: number;
eventTypeIds: number[];
};
export const ZRemoveHostsFromEventTypes: z.ZodType<TRemoveHostsFromEventTypes> = z.object({
userIds: z.array(z.number()),
teamId: z.number(),
eventTypeIds: z.array(z.number()),
});
export type TRemoveHostsFromEventTypes = z.infer<typeof ZRemoveHostsFromEventTypes>;
@@ -1,9 +1,21 @@
import { z } from "zod";
export const ZRemoveMemberInputSchema = z.object({
// Note: isOrg has .default(false), so input type has it optional but output type has it required
export type TRemoveMemberInputSchemaInput = {
teamIds: number[];
memberIds: number[];
isOrg?: boolean;
};
export type TRemoveMemberInputSchema = {
teamIds: number[];
memberIds: number[];
isOrg: boolean;
};
export const ZRemoveMemberInputSchema: z.ZodType<TRemoveMemberInputSchema, z.ZodTypeDef, TRemoveMemberInputSchemaInput> = z.object({
teamIds: z.array(z.number()),
memberIds: z.array(z.number()),
isOrg: z.boolean().default(false),
});
export type TRemoveMemberInputSchema = z.infer<typeof ZRemoveMemberInputSchema>;
@@ -2,11 +2,23 @@ import { z } from "zod";
import { emailSchema } from "@calcom/lib/emailSchema";
export const ZResendInvitationInputSchema = z.object({
export type TResendInvitationInputSchemaInput = {
teamId: number;
email: string;
language: string;
isOrg?: boolean;
};
export type TResendInvitationInputSchema = {
teamId: number;
email: string;
language: string;
isOrg: boolean;
};
export const ZResendInvitationInputSchema: z.ZodType<TResendInvitationInputSchema, z.ZodTypeDef, TResendInvitationInputSchemaInput> = z.object({
teamId: z.number(),
email: emailSchema,
language: z.string(),
isOrg: z.boolean().default(false),
});
export type TResendInvitationInputSchema = z.infer<typeof ZResendInvitationInputSchema>;
@@ -1,12 +1,17 @@
import { z } from "zod";
// New schema for fetching hosts
export const ZGetRoundRobinHostsInputSchema = z.object({
export type TGetRoundRobinHostsToReassignInputSchema = {
bookingId: number;
exclude: "fixedHosts";
cursor?: number;
limit?: number;
searchTerm?: string;
};
export const ZGetRoundRobinHostsInputSchema: z.ZodType<TGetRoundRobinHostsToReassignInputSchema> = z.object({
bookingId: z.number(),
exclude: z.literal("fixedHosts"),
cursor: z.number().optional(), // For pagination
cursor: z.number().optional(),
limit: z.number().min(1).max(100).optional(),
searchTerm: z.string().optional(),
});
export type TGetRoundRobinHostsToReassignInputSchema = z.infer<typeof ZGetRoundRobinHostsInputSchema>;
@@ -1,9 +1,13 @@
import { z } from "zod";
export const ZRoundRobinManualReassignInputSchema = z.object({
export type TRoundRobinManualReassignInputSchema = {
bookingId: number;
teamMemberId: number;
reassignReason?: string;
};
export const ZRoundRobinManualReassignInputSchema: z.ZodType<TRoundRobinManualReassignInputSchema> = z.object({
bookingId: z.number(),
teamMemberId: z.number(),
reassignReason: z.string().optional(),
});
export type TRoundRobinManualReassignInputSchema = z.infer<typeof ZRoundRobinManualReassignInputSchema>;
@@ -1,8 +1,11 @@
import { z } from "zod";
export const ZRoundRobinReassignInputSchema = z.object({
export type TRoundRobinReassignInputSchema = {
teamId: number;
bookingId: number;
};
export const ZRoundRobinReassignInputSchema: z.ZodType<TRoundRobinReassignInputSchema> = z.object({
teamId: z.number(),
bookingId: z.number(),
});
export type TRoundRobinReassignInputSchema = z.infer<typeof ZRoundRobinReassignInputSchema>;
@@ -1,8 +1,11 @@
import { z } from "zod";
export const ZSetInviteExpirationInputSchema = z.object({
export type TSetInviteExpirationInputSchema = {
token: string;
expiresInDays?: number;
};
export const ZSetInviteExpirationInputSchema: z.ZodType<TSetInviteExpirationInputSchema> = z.object({
token: z.string(),
expiresInDays: z.number().optional(),
});
export type TSetInviteExpirationInputSchema = z.infer<typeof ZSetInviteExpirationInputSchema>;
@@ -1,6 +1,15 @@
import { z } from "zod";
export const ZUpdateInternalNotesPresetsInputSchema = z.object({
export type TUpdateInternalNotesPresetsInputSchema = {
teamId: number;
presets: {
id: number;
name: string;
cancellationReason?: string;
}[];
};
export const ZUpdateInternalNotesPresetsInputSchema: z.ZodType<TUpdateInternalNotesPresetsInputSchema> = z.object({
teamId: z.number(),
presets: z.array(
z.object({
@@ -10,5 +19,3 @@ export const ZUpdateInternalNotesPresetsInputSchema = z.object({
})
),
});
export type TUpdateInternalNotesPresetsInputSchema = z.infer<typeof ZUpdateInternalNotesPresetsInputSchema>;
@@ -1,9 +1,13 @@
import { z } from "zod";
export const ZUpdateMembershipInputSchema = z.object({
export type TUpdateMembershipInputSchema = {
teamId: number;
memberId: number;
disableImpersonation: boolean;
};
export const ZUpdateMembershipInputSchema: z.ZodType<TUpdateMembershipInputSchema> = z.object({
teamId: z.number(),
memberId: z.number(),
disableImpersonation: z.boolean(),
});
export type TUpdateMembershipInputSchema = z.infer<typeof ZUpdateMembershipInputSchema>;
@@ -1,8 +1,11 @@
import { z } from "zod";
export const ZActivateEventTypeInputSchema = z.object({
export type TActivateEventTypeInputSchema = {
eventTypeId: number;
workflowId: number;
};
export const ZActivateEventTypeInputSchema: z.ZodType<TActivateEventTypeInputSchema> = z.object({
eventTypeId: z.number(),
workflowId: z.number(),
});
export type TActivateEventTypeInputSchema = z.infer<typeof ZActivateEventTypeInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZCreateInputSchema = z.object({
export type TCreateInputSchema = {
teamId?: number;
};
export const ZCreateInputSchema: z.ZodType<TCreateInputSchema> = z.object({
teamId: z.number().optional(),
});
export type TCreateInputSchema = z.infer<typeof ZCreateInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZDeleteInputSchema = z.object({
export type TDeleteInputSchema = {
id: number;
};
export const ZDeleteInputSchema: z.ZodType<TDeleteInputSchema> = z.object({
id: z.number(),
});
export type TDeleteInputSchema = z.infer<typeof ZDeleteInputSchema>;
@@ -8,7 +8,31 @@ import {
} from "@calcom/ee/workflows/lib/constants";
import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
export const ZWorkflow = z.object({
// Define types first to use with z.ZodType annotations
type TWorkflow = {
id: number;
name: string;
trigger: (typeof WORKFLOW_TRIGGER_EVENTS)[number];
time: number | null;
timeUnit: (typeof TIME_UNIT)[number] | null;
userId: number | null;
teamId: number | null;
steps: {
id: number;
action: (typeof WORKFLOW_ACTIONS)[number];
sendTo: string | null;
template: (typeof WORKFLOW_TEMPLATES)[number];
reminderBody: string | null;
emailSubject: string | null;
numberRequired: boolean | null;
sender: string | null;
includeCalendarEvent: boolean;
numberVerificationPending: boolean;
verifiedAt?: Date | null;
}[];
};
export const ZWorkflow: z.ZodType<TWorkflow> = z.object({
id: z.number(),
name: z.string(),
trigger: z.enum(WORKFLOW_TRIGGER_EVENTS),
@@ -33,14 +57,29 @@ export const ZWorkflow = z.object({
.array(),
});
export const ZWorkflows = z
type TWorkflows = { workflow: TWorkflow }[] | undefined;
export const ZWorkflows: z.ZodType<TWorkflows> = z
.object({
workflow: ZWorkflow,
})
.array()
.optional();
export const ZGetAllActiveWorkflowsInputSchema = z.object({
export type TGetAllActiveWorkflowsInputSchema = {
eventType: {
id: number;
teamId?: number | null;
parent?: {
id: number | null;
teamId: number | null;
} | null;
metadata: z.infer<typeof EventTypeMetaDataSchema>;
userId?: number | null;
};
};
export const ZGetAllActiveWorkflowsInputSchema: z.ZodType<TGetAllActiveWorkflowsInputSchema> = z.object({
eventType: z.object({
id: z.number(),
teamId: z.number().optional().nullable(),
@@ -55,5 +94,3 @@ export const ZGetAllActiveWorkflowsInputSchema = z.object({
userId: z.number().optional().nullable(),
}),
});
export type TGetAllActiveWorkflowsInputSchema = z.infer<typeof ZGetAllActiveWorkflowsInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZGetVerifiedEmailsInputSchema = z.object({
export type TGetVerifiedEmailsInputSchema = {
teamId?: number;
};
export const ZGetVerifiedEmailsInputSchema: z.ZodType<TGetVerifiedEmailsInputSchema> = z.object({
teamId: z.number().optional(),
});
export type TGetVerifiedEmailsInputSchema = z.infer<typeof ZGetVerifiedEmailsInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZGetVerifiedNumbersInputSchema = z.object({
export type TGetVerifiedNumbersInputSchema = {
teamId?: number;
};
export const ZGetVerifiedNumbersInputSchema: z.ZodType<TGetVerifiedNumbersInputSchema> = z.object({
teamId: z.number().optional(),
});
export type TGetVerifiedNumbersInputSchema = z.infer<typeof ZGetVerifiedNumbersInputSchema>;
@@ -1,9 +1,13 @@
import { z } from "zod";
export const ZListInputSchema = z.object({
export type TListInputSchema = {
teamId?: number;
userId?: number;
includeOnlyEventTypeWorkflows: boolean;
};
export const ZListInputSchema: z.ZodType<TListInputSchema> = z.object({
teamId: z.number().optional(),
userId: z.number().optional(),
includeOnlyEventTypeWorkflows: z.boolean(),
});
export type TListInputSchema = z.infer<typeof ZListInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZSendVerificationCodeInputSchema = z.object({
export type TSendVerificationCodeInputSchema = {
phoneNumber: string;
};
export const ZSendVerificationCodeInputSchema: z.ZodType<TSendVerificationCodeInputSchema> = z.object({
phoneNumber: z.string(),
});
export type TSendVerificationCodeInputSchema = z.infer<typeof ZSendVerificationCodeInputSchema>;
@@ -1,9 +1,13 @@
import { z } from "zod";
export const ZVerifyEmailCodeInputSchema = z.object({
export type TVerifyEmailCodeInputSchema = {
teamId?: number;
code: string;
email: string;
};
export const ZVerifyEmailCodeInputSchema: z.ZodType<TVerifyEmailCodeInputSchema> = z.object({
teamId: z.number().optional(),
code: z.string(),
email: z.string(),
});
export type TVerifyEmailCodeInputSchema = z.infer<typeof ZVerifyEmailCodeInputSchema>;
@@ -1,9 +1,13 @@
import { z } from "zod";
export const ZVerifyPhoneNumberInputSchema = z.object({
export type TVerifyPhoneNumberInputSchema = {
phoneNumber: string;
code: string;
teamId?: number;
};
export const ZVerifyPhoneNumberInputSchema: z.ZodType<TVerifyPhoneNumberInputSchema> = z.object({
phoneNumber: z.string(),
code: z.string(),
teamId: z.number().optional(),
});
export type TVerifyPhoneNumberInputSchema = z.infer<typeof ZVerifyPhoneNumberInputSchema>;
@@ -1,7 +1,9 @@
import { z } from "zod";
export const ZWorkflowOrderInputSchema = z.object({
export type TWorkflowOrderInputSchema = {
ids: number[];
};
export const ZWorkflowOrderInputSchema: z.ZodType<TWorkflowOrderInputSchema> = z.object({
ids: z.array(z.number()),
});
export type TWorkflowOrderInputSchema = z.infer<typeof ZWorkflowOrderInputSchema>;