chore: Upgrade prisma to 6.7.0 (#21264)

* chore: Upgrade prisma to 6.7.0

* Build fixes

* type fixes

Signed-off-by: Omar López <[email protected]>

* Update schema.prisma

* Patching

* Revert "Update schema.prisma"

This reverts commit 47d8618bf89ef4d007b30084df766f17281e21a1.

* Revert "Patching"

This reverts commit a1d2e3040e71690a44d4324db95d73b4d68c6adb.

* Revert schema changes

Signed-off-by: Omar López <[email protected]>

* WIP

Signed-off-by: Omar López <[email protected]>

* Update getPublicEvent.ts

* Update imports

Signed-off-by: Omar López <[email protected]>

* Update gitignore

Signed-off-by: Omar López <[email protected]>

* update remaining imports

Signed-off-by: Omar López <[email protected]>

* Delete .cursor/config.json

* Discard changes to packages/features/eventtypes/lib/getPublicEvent.ts

* Update _get.ts

* Update user.ts

* Update .gitignore

* update

* Update WorkflowStepContainer.tsx

* Update next-auth-custom-adapter.ts

* Update getPublicEvent.ts

* Update workflow.ts

* Update next-auth-custom-adapter.ts

* Update next-auth-options.ts

* Update bookingScenario.ts

* fix missing imports

* upgrades prismock

Signed-off-by: Omar López <[email protected]>

* patches prismock

Signed-off-by: Omar López <[email protected]>

* Update reschedule.test.ts

* Update prisma.ts

* patch prismock

Signed-off-by: Omar López <[email protected]>

* fix enums imports

Signed-off-by: Omar López <[email protected]>

* Revert "Update prisma.ts"

This reverts commit 64edcf8db54171ff4456c209d563b5d431d99619.

* Revert "patch prismock"

This reverts commit e95819113dc9d88e7130947aa120cd42710977c8.

* fix patch

* Fix test that overrun the boundary, it shouldn't test too much

* Move prisma import to changeSMSLockState

* Bring back broken test without illegal imports

* Merge with main and fix filter hosts by same round robin host

* Fixed buildDryRunBooking fn tests

* Fix and move ooo create or update handler test

* Fix packages/features/eventtypes/lib/isCurrentlyAvailable.test.ts

* Fix packages/trpc/server/routers/viewer/organizations/listMembers.handler.test.ts

* Mock @calcom/prisma

* Fix: verify-email.test.ts

* fix: Moved WebhookService test and fixed default import mock

* Fix: Added missing prisma mock, handleNewBooking uses that of course

* We're not testing createContext here

* fix: Prisma mock fix for listMembers.test.ts

* More fixes to broken testcases

* Forgot to remove borked test

* Prevent the need to mock a lot of dependencies by moving out buildBaseWhereCondition to its own file

* Temporarily skip getCalendarEvents, needs a rewrite

* Fix: turns out you can access protected in testcases

* fix further mocks

* Added packages/features/insights/server/buildBaseWhereCondition.ts, types

* Always great to have a mock and then not use it

* And one less again.

* fix: confirm.handler.test, didn't mock prisma

* fix: Address minor nit by @eunjae & fix ImpersonationProvider test

* Updated isPrismaAvailableCheck that doesn't crash on import

* fix: Get Prisma directly from the client, it usually involves the Validator and does not need 'local' inclusion

* Add zod-prisma-types without the generator enabled (commented out)

* Uncomment and see what happens

* Change method of import as imports did not work in Input Schemas

* Remove custom 'zod' booking model, it does not belong with Prisma

* Fix all other global Model imports

* Rewrite most schema includes AND remove barrel file

* Add bookingCreateBodySchema to features/bookings

* Flurry of type fixes for compatibility with new zod gen

* Refactor out the custom prisma type createEventTypeInput

* Work around nullable eventTypeLocations

* HandlePayment type fix

* More fixes, final fix remaining is CompleteEventType

* Should fix a bunch more booking related type errors

* Missed one

* Some props missing from BookingCreateBodySchema

* Fix location type in handleChildrenEventTypes

* Little bit hacky imo but it works

* Final type error \o/

* Forgot to include Prisma

* Do not include zod-utils in booker/types

* Oops, was already including Booker/types

* Fix membership type, also disallow updating createdAt/updatedAt, make part of patch/post

* Fix api v1 type errors

* Fix EventTypeDescription typings

* Remove getParserWithGeneric, use userBodySchema with UserSchema

* use centralized timeZoneSchema

* Implement feedback by @zomars

* Couple of WIP pushes

* Fix tests

* Type fixes in `handleChildrenEventTypes` test

* Try and parse metadata before use

* Change zod-prisma-types configuration for optimal performance

* Fix prisma validator error in `prisma/selects/credential`

* Disable seperate relations model, hits a bug

* Import absolute - this makes rollup work in @platform/libraries

* Attempt at removing resolutions override

* Refactor using `Prisma.validator` to `satisfies`

* Build atoms using @calcom/prisma/client

* Build atoms using @calcom/prisma/client

* fixes

* Update eventTypeSelect.ts

* Adjust `eventTypeMetaDataSchemaWithUntypedApps` from `unknown` to `record(any)`

* `EventTypeDescription` rely on `descriptionAsSafeHTML` instead of `description`

* Add `seatsPerTimeSlot` to event type public select

* Fix typing in `users-public-view` getServerSide props

* Add missing `schedulingType` to prop

* chore: bump platform libraries

* Function return type is illegal, not sure how this passed eslint (#21567)

* Merged with main

* Update updateTokenObject.ts

* Update handleResponse.ts

* Update index.ts

* Update handleChildrenEventTypes.ts

* Update booking-idempotency-key.ts

* Update WebhookService.test.ts

* Update events.test.ts

* Update queued-response.test.ts

* Update events.test.ts

* Update getRoutedUrl.test.ts

* fix: type checks

Signed-off-by: Omar López <[email protected]>

* fixes

Signed-off-by: Omar López <[email protected]>

* chore: bump platform libraries

* Update yarn.lock

* more fixes

Signed-off-by: Omar López <[email protected]>

* fixes

Signed-off-by: Omar López <[email protected]>

* biuld fixes

* chore: bump platform libraries

* Update conferencing.repository.ts

* Update conferencing.repository.ts

* Update getCalendarsEvents.test.ts

* Update vite.config.js

* chore: bump platform libraries

* Update users.ts

* Discard changes to docs/api-reference/v2/openapi.json

* Update vite.config.ts

* updated platform libraries

* Update get.handler.test.ts

* Update get.handler.test.ts

* Update schema.prisma

* Discard changes to docs/api-reference/v2/openapi.json

* Update next-auth-custom-adapter.ts

* Update team.ts

* Flurry of type fixes

* Fix majority of insight related type errors

* Type fixes for unlink of account

* Make user nullable again

* Fixed a bunch of unit tests and one type error

* Attempted mock fix

* Attempted fix for Attribute type

* Ensure default import becomes prisma, but not direct usage

* Import default as prisma in prisma.module

* Add attributeOption to attribute type

* Fix calcom/prisma mock

* Refactor Prisma client imports to @calcom/prisma/client

Updated all imports from '@prisma/client' to '@calcom/prisma/client' across tests and repository files for consistency and to use the correct Prisma client package. This change improves maintainability and ensures the correct client is referenced throughout the codebase.

* Undo removal of max-warnings=0 to get main to merge

* Remove unit tests for e2e fixtures, provide new prisma mock

* Mock @calcom/prisma in event manager

* Mock @calcom/prisma in event manager

* Add correct format even with --no-verify

* Mock prisma in CalendarManager

* Add mock for permission-check.service

* Better injection in PrismaApiKeyRepository imports

* More mock fixes :)

* Fix listMembers.handler.test

* Fix User import

* Appropriately adjust all types to be imported as types, there were a lot of types imported as normal deps

* Why was this a thing?

* Strictly speaking; Not using prismock anymore

* Ditched patch file for prismock

* Fix output.service.ts platform type imports, need concrete for plainToClass

* Better typing and tests for unlinkConnectedAccount.handler

* Small type fix

* Disable calendar cache tests as they are dependent on prismock

* chore: bump platform lib

* getRoutedUrl test remove of unused import

* Extract select to external const on getEventTypesFromDB

* Direct select of userSelect from selects/user

* fix type error from merging 23653

* Fixed integration tests by removing hardcoded values that were possible due to mocking, but as its now directly hitting the db no longer

* fix: vite config atoms prisma client type location

* revert: example app prisma client

* revert: example app prisma client

* bump platform libs

* fix: use class instead of type for DI of PlatformBookingsService

* update platform libs

* remove unused variable

* chore: generate prisma client for api v2

* fix: api v2 e2e

* fix: atoms e2e

* fix: atoms e2e

* fix: atoms e2e

* fix: api v2 e2e

* fix: tsconfig apiv2 enums

* publish libraries

* Simplify check for existence teamId

---------

Signed-off-by: Omar López <[email protected]>
Co-authored-by: Alex van Andel <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: supalarry <[email protected]>
Co-authored-by: cal.com <[email protected]>
Co-authored-by: Morgan <[email protected]>
Co-authored-by: Benny Joo <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-09-11 15:27:50 +01:00
1 parent a55d56f260
commit c28eb90928
623 files changed
+4363 -12559

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
import { beforeEach } from "vitest";
import { mockDeep, mockReset } from "vitest-mock-extended";
import type { PrismaClient } from "@calcom/prisma";
beforeEach(() => {
mockReset(prisma);
});
const prisma = mockDeep<PrismaClient>();
export { prisma };
-1
View File
@@ -1 +0,0 @@
export * from "../../../node_modules/.prisma/client/index.d";
-1
View File
@@ -1 +0,0 @@
export * from "@prisma/client";
@@ -1,6 +1,5 @@
import { Prisma } from "@prisma/client";
import { IdempotencyKeyService } from "@calcom/lib/idempotencyKey/idempotencyKeyService";
import { Prisma } from "@calcom/prisma/client";
import { BookingStatus } from "@calcom/prisma/enums";
export function bookingIdempotencyKeyExtension() {
@@ -1,4 +1,4 @@
import { Prisma } from "@prisma/client";
import { Prisma } from "@calcom/prisma/client";
export const checkUndefinedInValue = (where: any) => {
if (where) {
@@ -1,4 +1,4 @@
import { Prisma } from "@prisma/client";
import { Prisma } from "@calcom/prisma/client";
export function excludeLockedUsersExtension() {
return Prisma.defineExtension({
@@ -1,4 +1,4 @@
import { Prisma } from "@prisma/client";
import { Prisma } from "@calcom/prisma/client";
export function excludePendingPaymentsExtension() {
return Prisma.defineExtension({
+2 -2
View File
@@ -1,9 +1,9 @@
import { Prisma } from "@prisma/client";
import type { PrismaClient } from "@prisma/client";
import { waitUntil } from "@vercel/functions";
import { UsageEvent, LicenseKeySingleton } from "@calcom/ee/common/server/LicenseKeyService";
import { DeploymentRepository } from "@calcom/lib/server/repository/deployment";
import { Prisma } from "@calcom/prisma/client";
import type { PrismaClient } from "@calcom/prisma/client";
async function incrementUsage(prismaClient: PrismaClient, event?: UsageEvent) {
const deploymentRepo = new DeploymentRepository(prismaClient);
+5 -7
View File
@@ -1,5 +1,4 @@
import type { Prisma } from "@prisma/client";
import { PrismaClient } from "@prisma/client";
import { PrismaClient, type Prisma } from "@calcom/prisma/client";
import { bookingIdempotencyKeyExtension } from "./extensions/booking-idempotency-key";
import { disallowUndefinedDeleteUpdateManyExtension } from "./extensions/disallow-undefined-delete-update-many";
@@ -35,8 +34,7 @@ if (!isNaN(loggerLevel)) {
}
}
const baseClient =
globalForPrisma.baseClient || new PrismaClient(prismaOptions);
const baseClient = globalForPrisma.baseClient || new PrismaClient(prismaOptions);
export const customPrisma = (options?: Prisma.PrismaClientOptions) =>
new PrismaClient({ ...prismaOptions, ...options })
@@ -80,10 +78,10 @@ type OmitPrismaClient = Omit<
>;
// we cant pass tx to functions as types miss match since we have a custom prisma client https://github.com/prisma/prisma/discussions/20924#discussioncomment-10077649
export type {
OmitPrismaClient as PrismaTransaction,
export type {
OmitPrismaClient as PrismaTransaction,
// we re-export the native PrismaClient type for backwards-compatibility.
PrismaClient
PrismaClient,
};
/**
+8 -8
View File
@@ -1,17 +1,17 @@
import { Prisma } from "@prisma/client";
import { Prisma } from "./client";
import prisma from ".";
export async function isPrismaAvailableCheck() {
export async function isPrismaAvailableCheck(): Promise<boolean> {
try {
await prisma.$queryRaw`SELECT 1`;
const { PrismaClient } = await import("./client");
const prisma = new PrismaClient();
await prisma.$queryRawUnsafe("SELECT 1");
await prisma.$disconnect();
return true;
} catch (e: unknown) {
if (e instanceof Prisma.PrismaClientInitializationError) {
// Database might not available at build time.
return false;
} else {
throw e;
}
throw e;
}
}
@@ -1,4 +1,4 @@
import type { PrismaClient } from "@prisma/client";
import type { PrismaClient } from "../client";
function middleware(prisma: PrismaClient) {
/***********************************/
@@ -0,0 +1,11 @@
-- AlterTable
ALTER TABLE "_PlatformOAuthClientToUser" ADD CONSTRAINT "_PlatformOAuthClientToUser_AB_pkey" PRIMARY KEY ("A", "B");
-- DropIndex
DROP INDEX "_PlatformOAuthClientToUser_AB_unique";
-- AlterTable
ALTER TABLE "_user_eventtype" ADD CONSTRAINT "_user_eventtype_AB_pkey" PRIMARY KEY ("A", "B");
-- DropIndex
DROP INDEX "_user_eventtype_AB_unique";
@@ -1,3 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
# It should be added in your version-control system (e.g., Git)
provider = "postgresql"
+6 -6
View File
@@ -27,14 +27,14 @@
},
"dependencies": {
"@calcom/lib": "*",
"@prisma/client": "^5.4.2",
"@prisma/extension-accelerate": "^0.6.2",
"@prisma/generator-helper": "^5.4.2",
"prisma": "^5.4.2",
"prisma-kysely": "^1.7.1",
"@prisma/client": "^6.7.0",
"@prisma/extension-accelerate": "^1.3.0",
"@prisma/generator-helper": "^6.7.0",
"prisma": "^6.7.0",
"prisma-kysely": "^1.8.0",
"ts-node": "^10.9.1",
"zod": "^3.22.4",
"zod-prisma": "^0.5.4"
"zod-prisma-types": "^3.2.4"
},
"main": "index.ts",
"types": "index.d.ts",
+59 -46
View File
@@ -10,13 +10,26 @@ datasource db {
generator client {
provider = "prisma-client-js"
previewFeatures = ["views"]
output = "./client"
binaryTargets = ["native", "debian-openssl-1.1.x"]
}
generator client_for_api_v2 {
provider = "prisma-client-js"
previewFeatures = ["views"]
output = "../../apps/api/v2/client"
binaryTargets = ["native", "debian-openssl-1.1.x"]
}
generator zod {
provider = "zod-prisma"
output = "./zod"
imports = "./zod-utils"
relationModel = "default"
provider = "zod-prisma-types"
output = "./zod"
useMultipleFiles = true
createInputTypes = false
addIncludeType = false
addSelectType = false
validateWhereUniqueInput = false
/// createRelationValuesTypes = true
}
generator kysely {
@@ -103,16 +116,16 @@ model CalVideoSettings {
model EventType {
id Int @id @default(autoincrement())
/// @zod.min(1)
/// @zod.string.min(1)
title String
/// @zod.custom(imports.eventTypeSlug)
/// @zod.import(["import { eventTypeSlug } from '../../zod-utils'"]).custom.use(eventTypeSlug)
slug String
description String?
interfaceLanguage String?
position Int @default(0)
/// @zod.custom(imports.eventTypeLocations)
/// @zod.import(["import { eventTypeLocations } from '../../zod-utils'"]).custom.use(eventTypeLocations)
locations Json?
/// @zod.min(1)
/// @zod.number.min(1)
length Int
offsetStart Int @default(0)
hidden Boolean @default(false)
@@ -138,13 +151,13 @@ model EventType {
parentId Int?
parent EventType? @relation("managed_eventtype", fields: [parentId], references: [id], onDelete: Cascade)
children EventType[] @relation("managed_eventtype")
/// @zod.custom(imports.eventTypeBookingFields)
/// @zod.import(["import { eventTypeBookingFields } from '../../zod-utils'"]).custom.use(eventTypeBookingFields)
bookingFields Json?
timeZone String?
periodType PeriodType @default(UNLIMITED)
/// @zod.custom(imports.coerceToDate)
/// @zod.import(["import { coerceToDate } from '../../zod-utils'"]).custom.use(coerceToDate)
periodStartDate DateTime?
/// @zod.custom(imports.coerceToDate)
/// @zod.import(["import { coerceToDate } from '../../zod-utils'"]).custom.use(coerceToDate)
periodEndDate DateTime?
periodDays Int?
periodCountCalendarDays Boolean?
@@ -157,12 +170,12 @@ model EventType {
canSendCalVideoTranscriptionEmails Boolean @default(true)
autoTranslateDescriptionEnabled Boolean @default(false)
/// @zod.custom(imports.recurringEventType)
/// @zod.import(["import { recurringEventType } from '../../zod-utils'"]).custom.use(recurringEventType)
recurringEvent Json?
disableGuests Boolean @default(false)
hideCalendarNotes Boolean @default(false)
hideCalendarEventDetails Boolean @default(false)
/// @zod.min(0)
/// @zod.number.min(0)
minimumBookingNotice Int @default(120)
beforeEventBuffer Int @default(0)
afterEventBuffer Int @default(0)
@@ -182,15 +195,15 @@ model EventType {
// currency is deprecated. It has now moved to metadata.apps.stripe.currency. Plan to drop this column.
currency String @default("usd")
slotInterval Int?
/// @zod.custom(imports.EventTypeMetaDataSchema)
/// @zod.import(["import { EventTypeMetaDataSchema } from '../../zod-utils'"]).custom.use(EventTypeMetaDataSchema)
metadata Json?
/// @zod.custom(imports.successRedirectUrl)
/// @zod.import(["import { successRedirectUrl } from '../../zod-utils'"]).custom.use(successRedirectUrl)
successRedirectUrl String?
forwardParamsSuccessRedirect Boolean? @default(true)
workflows WorkflowsOnEventTypes[]
/// @zod.custom(imports.intervalLimitsType)
/// @zod.import(["import { intervalLimitsType } from '../../zod-utils'"]).custom.use(intervalLimitsType)
bookingLimits Json?
/// @zod.custom(imports.intervalLimitsType)
/// @zod.import(["import { intervalLimitsType } from '../../zod-utils'"]).custom.use(intervalLimitsType)
durationLimits Json?
isInstantEvent Boolean @default(false)
instantMeetingExpiryTimeOffsetInSeconds Int @default(90)
@@ -200,7 +213,7 @@ model EventType {
assignAllTeamMembers Boolean @default(false)
// It is applicable only when assignAllTeamMembers is true and it filters out all the team members using rrSegmentQueryValue
assignRRMembersUsingSegment Boolean @default(false)
/// @zod.custom(imports.rrSegmentQueryValueSchema)
/// @zod.import(["import { rrSegmentQueryValueSchema } from '../../zod-utils'"]).custom.use(rrSegmentQueryValueSchema)
rrSegmentQueryValue Json?
useEventTypeDestinationCalendarEmail Boolean @default(false)
aiPhoneCallConfig AIPhoneCallConfiguration?
@@ -213,11 +226,11 @@ model EventType {
hideOrganizerEmail Boolean @default(false)
maxActiveBookingsPerBooker Int?
maxActiveBookingPerBookerOfferReschedule Boolean @default(false)
/// @zod.custom(imports.emailSchema)
/// @zod.import(["import { emailSchema } from '@calcom/lib/emailSchema'"]).custom.use(emailSchema)
customReplyToEmail String?
calVideoSettings CalVideoSettings?
/// @zod.custom(imports.eventTypeColor)
/// @zod.import(["import { eventTypeColor } from '../../zod-utils'"]).custom.use(eventTypeColor)
eventTypeColor Json?
rescheduleWithSameRoundRobinHost Boolean @default(false)
@@ -285,7 +298,7 @@ model DestinationCalendar {
id Int @id @default(autoincrement())
integration String
externalId String
/// @zod.custom(imports.emailSchema)
/// @zod.import(["import { emailSchema } from '@calcom/lib/emailSchema'"]).custom.use(emailSchema)
primaryEmail String?
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
userId Int? @unique
@@ -336,7 +349,7 @@ model User {
id Int @id @default(autoincrement())
username String?
name String?
/// @zod.custom(imports.emailSchema)
/// @zod.import(["import { emailSchema } from '@calcom/lib/emailSchema'"]).custom.use(emailSchema)
email String
emailVerified DateTime?
password UserPassword?
@@ -388,7 +401,7 @@ model User {
// receive monthly digest email for teams or not
receiveMonthlyDigestEmail Boolean? @default(true)
/// @zod.custom(imports.userMetadata)
/// @zod.import(["import { userMetadata } from '../../zod-utils'"]).custom.use(userMetadata)
metadata Json?
verified Boolean? @default(false)
role UserPermissionRole @default(USER)
@@ -493,11 +506,11 @@ model Profile {
model Team {
id Int @id @default(autoincrement())
/// @zod.min(1)
/// @zod.string.min(1)
name String
// It is unique across teams and organizations. We don't have a strong reason for organization and team slug to be conflicting, could be fixed.
// Sub-teams could have same slug across different organizations but not within the same organization.
/// @zod.min(1)
/// @zod.string.min(1)
slug String?
logoUrl String?
calVideoLogo String?
@@ -512,7 +525,7 @@ model Team {
eventTypes EventType[]
workflows Workflow[]
createdAt DateTime @default(now())
/// @zod.custom(imports.teamMetadataSchema)
/// @zod.import(["import { teamMetadataSchema } from '../../zod-utils'"]).custom.use(teamMetadataSchema)
metadata Json?
theme String?
rrResetInterval RRResetInterval? @default(MONTH)
@@ -561,7 +574,7 @@ model Team {
features TeamFeatures[]
/// @zod.custom(imports.intervalLimitsType)
/// @zod.import(["import { intervalLimitsType } from '../../zod-utils'"]).custom.use(intervalLimitsType)
bookingLimits Json?
includeManagedEventsInLimits Boolean @default(false)
internalNotePresets InternalNotePreset[]
@@ -716,9 +729,9 @@ model InstantMeetingToken {
model BookingReference {
id Int @id @default(autoincrement())
/// @zod.min(1)
/// @zod.string.min(1)
type String
/// @zod.min(1)
/// @zod.string.min(1)
uid String
meetingId String?
thirdPartyRecurringEventId String?
@@ -773,7 +786,7 @@ model Booking {
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
userId Int?
// User's email at the time of booking
/// @zod.custom(imports.emailSchema)
/// @zod.import(["import { emailSchema } from '@calcom/lib/emailSchema'"]).custom.use(emailSchema)
userPrimaryEmail String?
references BookingReference[]
eventType EventType? @relation(fields: [eventTypeId], references: [id])
@@ -781,7 +794,7 @@ model Booking {
title String
description String?
customInputs Json?
/// @zod.custom(imports.bookingResponses)
/// @zod.import(["import { bookingResponses } from '../../zod-utils'"]).custom.use(bookingResponses)
responses Json?
startTime DateTime
endTime DateTime
@@ -808,7 +821,7 @@ model Booking {
workflowReminders WorkflowReminder[]
scheduledJobs String[] // scheduledJobs is deprecated, please use scheduledTriggers instead
seatsReferences BookingSeat[]
/// @zod.custom(imports.bookingMetadataSchema)
/// @zod.import(["import { bookingMetadataSchema } from '../../zod-utils'"]).custom.use(bookingMetadataSchema)
metadata Json?
isRecorded Boolean @default(false)
iCalUID String? @default("")
@@ -819,9 +832,9 @@ model Booking {
noShowHost Boolean? @default(false)
scheduledTriggers WebhookScheduledTriggers[]
oneTimePassword String? @unique @default(uuid())
/// @zod.email()
/// @zod.import(["import { emailSchema } from '@calcom/lib/emailSchema'"]).custom.use(emailSchema)
cancelledBy String?
/// @zod.email()
/// @zod.import(["import { emailSchema } from '@calcom/lib/emailSchema'"]).custom.use(emailSchema)
rescheduledBy String?
// Ah, made a typo here. Should have been routedFromRoutingFormRe"s"ponse. Live with it :(
routedFromRoutingFormReponse App_RoutingForms_FormResponse?
@@ -948,7 +961,7 @@ model EventTypeCustomInput {
eventType EventType @relation(fields: [eventTypeId], references: [id], onDelete: Cascade)
label String
type EventTypeCustomInputType
/// @zod.custom(imports.customInputOptionSchema)
/// @zod.import(["import { customInputOptionSchema } from '../../zod-utils'"]).custom.use(customInputOptionSchema)
options Json?
required Boolean
placeholder String @default("")
@@ -1031,7 +1044,7 @@ model Webhook {
teamId Int?
eventTypeId Int?
platformOAuthClientId String?
/// @zod.url()
/// @zod.string.url()
subscriberUrl String
payloadTemplate String?
createdAt DateTime @default(now())
@@ -1197,7 +1210,7 @@ model App_RoutingForms_Form {
responses App_RoutingForms_FormResponse[]
queuedResponses App_RoutingForms_QueuedFormResponse[]
disabled Boolean @default(false)
/// @zod.custom(imports.RoutingFormSettings)
/// @zod.import(["import { RoutingFormSettings } from '../../zod-utils'"]).custom.use(RoutingFormSettings)
settings Json?
incompleteBookingActions App_RoutingForms_IncompleteBookingActions[]
@@ -1455,7 +1468,7 @@ model Deployment {
/// This is a single row table, so we use a fixed id
id Int @id @default(1)
logo String?
/// @zod.custom(imports.DeploymentTheme)
/// @zod.import(["import { DeploymentTheme } from '../../zod-utils'"]).custom.use(DeploymentTheme)
theme Json?
licenseKey String?
// We encrypt the signature token in the deployment table with the current calendso encryption key
@@ -1530,7 +1543,7 @@ model BookingSeat {
booking Booking @relation(fields: [bookingId], references: [id], onDelete: Cascade)
attendeeId Int @unique
attendee Attendee @relation(fields: [attendeeId], references: [id], onDelete: Cascade)
/// @zod.custom(imports.bookingSeatDataSchema)
/// @zod.import(["import { bookingSeatDataSchema } from '../../zod-utils'"]).custom.use(bookingSeatDataSchema)
data Json?
metadata Json?
@@ -2137,7 +2150,7 @@ model DelegationCredential {
workspacePlatform WorkspacePlatform @relation(fields: [workspacePlatformId], references: [id], onDelete: Cascade)
workspacePlatformId Int
// Provides possibility to have different service accounts for different organizations if the need arises, but normally they should be the same
/// @zod.custom(imports.serviceAccountKeySchema)
/// @zod.import(["import { serviceAccountKeySchema } from '../../zod-utils'"]).custom.use(serviceAccountKeySchema)
serviceAccountKey Json
enabled Boolean @default(false)
// lastEnabledAt is set when the delegation credential is enabled
@@ -2166,7 +2179,7 @@ model DomainWideDelegation {
workspacePlatform WorkspacePlatform @relation(fields: [workspacePlatformId], references: [id], onDelete: Cascade)
workspacePlatformId Int
// Provides possibility to have different service accounts for different organizations if the need arises, but normally they should be the same
/// @zod.custom(imports.serviceAccountKeySchema)
/// @zod.import(["import { serviceAccountKeySchema } from '../../zod-utils'"]).custom.use(serviceAccountKeySchema)
serviceAccountKey Json
enabled Boolean @default(false)
organizationId Int
@@ -2186,12 +2199,12 @@ model DomainWideDelegation {
// It is for delegation credential
model WorkspacePlatform {
id Int @id @default(autoincrement())
/// @zod.min(1)
/// @zod.string.min(1)
slug String
/// @zod.min(1)
/// @zod.string.min(1)
name String
description String
/// @zod.custom(imports.serviceAccountKeySchema)
/// @zod.import(["import { serviceAccountKeySchema } from '../../zod-utils'"]).custom.use(serviceAccountKeySchema)
defaultServiceAccountKey Json
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@ -2298,10 +2311,10 @@ model OrganizationOnboarding {
stripeSubscriptionId String?
stripeSubscriptionItemId String?
/// @zod.custom(imports.orgOnboardingInvitedMembersSchema)
/// @zod.import(["import { orgOnboardingInvitedMembersSchema } from '../../zod-utils'"]).custom.use(orgOnboardingInvitedMembersSchema)
invitedMembers Json @default("[]")
/// @zod.custom(imports.orgOnboardingTeamsSchema)
/// @zod.import(["import { orgOnboardingTeamsSchema } from '../../zod-utils'"]).custom.use(orgOnboardingTeamsSchema)
teams Json @default("[]")
// Completion status
+1 -1
View File
@@ -2,12 +2,12 @@
* @deprecated
* This file is deprecated. The only use of this file is to seed the database for E2E tests. Each test should take care of seeding it's own data going forward.
*/
import type { Prisma } from "@prisma/client";
import dotEnv from "dotenv";
import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData";
import prisma from ".";
import type { Prisma } from "./client";
import { AppCategories } from "./enums";
dotEnv.config({ path: "../../.env.appStore" });
+2 -2
View File
@@ -1,12 +1,12 @@
import { faker } from "@faker-js/faker";
import type { Prisma } from "@prisma/client";
import { PrismaClient } from "@prisma/client";
import { v4 as uuidv4 } from "uuid";
import dayjs from "@calcom/dayjs";
import { hashPassword } from "@calcom/features/auth/lib/hashPassword";
import { BookingStatus, AssignmentReasonEnum } from "@calcom/prisma/enums";
import type { Prisma } from "./client";
import { PrismaClient } from "./client";
import { seedAttributes, seedRoutingFormResponses, seedRoutingForms } from "./seed-utils";
function getRandomRatingFeedback() {
+1 -1
View File
@@ -1,5 +1,4 @@
import { faker } from "@faker-js/faker";
import type { Prisma, UserPermissionRole } from "@prisma/client";
import { randomUUID } from "crypto";
import { uuid } from "short-uuid";
import type z from "zod";
@@ -10,6 +9,7 @@ import { DEFAULT_SCHEDULE, getAvailabilityFromSchedule } from "@calcom/lib/avail
import { MembershipRole } from "@calcom/prisma/enums";
import prisma from ".";
import type { Prisma, UserPermissionRole } from "./client";
import type { teamMetadataSchema } from "./zod-utils";
export async function createUserAndEventType({
+3 -3
View File
@@ -1,6 +1,3 @@
import type { Membership, Team, User } from "@prisma/client";
import { Prisma } from "@prisma/client";
import type { UserPermissionRole } from "@prisma/client";
import { uuid } from "short-uuid";
import type z from "zod";
@@ -15,6 +12,9 @@ import { BookingStatus, MembershipRole, RedirectType, SchedulingType } from "@ca
import type { Ensure } from "@calcom/types/utils";
import prisma from ".";
import type { Membership, Team, User } from "./client";
import { Prisma } from "./client";
import type { UserPermissionRole } from "./client";
import mainAppStore from "./seed-app-store";
import mainHugeEventTypesSeed from "./seed-huge-event-types";
import { createUserAndEventType } from "./seed-utils";
+1 -1
View File
@@ -1,4 +1,4 @@
import type { Prisma } from "@prisma/client";
import type { Prisma } from "@calcom/prisma/client";
export const safeAppSelect = {
slug: true,
+1 -1
View File
@@ -1,4 +1,4 @@
import type { Prisma } from "@prisma/client";
import type { Prisma } from "@calcom/prisma/client";
export const bookingMinimalSelect = {
id: true,
+1 -1
View File
@@ -1,4 +1,4 @@
import type { Prisma } from "@prisma/client";
import type { Prisma } from "@calcom/prisma/client";
export const credentialForCalendarServiceSelect = {
id: true,
+2 -1
View File
@@ -1,4 +1,4 @@
import type { Prisma } from "@prisma/client";
import type { Prisma } from "@calcom/prisma/client";
export const baseEventTypeSelect = {
id: true,
@@ -16,6 +16,7 @@ export const baseEventTypeSelect = {
requiresConfirmation: true,
requiresBookerEmailVerification: true,
canSendCalVideoTranscriptionEmails: true,
seatsPerTimeSlot: true,
} satisfies Prisma.EventTypeSelect;
export const bookEventTypeSelect = {
+1 -1
View File
@@ -1,4 +1,4 @@
import type { Prisma } from "@prisma/client";
import type { Prisma } from "@calcom/prisma/client";
export const paymentDataSelect = {
data: true,
+13 -15
View File
@@ -1,4 +1,4 @@
import type { Prisma } from "@prisma/client";
import type { Prisma } from "@calcom/prisma/client";
export const availabilityUserSelect = {
id: true,
@@ -43,17 +43,15 @@ export const baseUserSelect = {
} satisfies Prisma.UserSelect;
export const userSelect = {
select: {
name: true,
allowDynamicBooking: true,
destinationCalendar: true,
locale: true,
hideBranding: true,
theme: true,
brandColor: true,
darkBrandColor: true,
metadata: true,
locked: true,
...availabilityUserSelect,
},
} satisfies Prisma.UserArgs;
name: true,
allowDynamicBooking: true,
destinationCalendar: true,
locale: true,
hideBranding: true,
theme: true,
brandColor: true,
darkBrandColor: true,
metadata: true,
locked: true,
...availabilityUserSelect,
} satisfies Prisma.UserSelect;
+3 -2
View File
@@ -1,4 +1,3 @@
import type { Prisma } from "@prisma/client";
import type { UnitTypeLongPlural } from "dayjs";
import type { TFunction } from "i18next";
import z, { ZodNullable, ZodObject, ZodOptional } from "zod";
@@ -22,6 +21,8 @@ import { zodAttributesQueryValue } from "@calcom/lib/raqb/zod";
import { slugify } from "@calcom/lib/slugify";
import { EventTypeCustomInputType } from "@calcom/prisma/enums";
import type { Prisma } from "./client";
// Let's not import 118kb just to get an enum
export enum Frequency {
YEARLY = 0,
@@ -129,7 +130,7 @@ const _eventTypeMetaDataSchemaWithoutApps = z.object({
export const eventTypeMetaDataSchemaWithUntypedApps = _eventTypeMetaDataSchemaWithoutApps.merge(
z.object({
apps: z.unknown().optional(),
apps: z.record(z.string(), z.any()).optional(),
})
);
-102
View File
@@ -1,102 +0,0 @@
// `responses` is merged with it during handleNewBooking call because `responses` schema is dynamic and depends on eventType
import z, { ZodNullable, ZodObject, ZodOptional } from "zod";
import { timeZoneSchema } from "@calcom/lib/dayjs/timeZone.schema";
// TODO: Move this out of here. Importing from app-store is a circular package dependency.
import { routingFormResponseInDbSchema } from "@calcom/app-store/routing-forms/zod";
import { CreationSource } from "@calcom/prisma/enums";
export const bookingCreateBodySchema = z.object({
end: z.string().optional(),
eventTypeId: z.number(),
eventTypeSlug: z.string().optional(),
rescheduleUid: z.string().optional(),
recurringEventId: z.string().optional(),
rescheduledBy: z.string().email({ message: "Invalid email" }).optional(),
start: z.string(),
timeZone: timeZoneSchema,
user: z.union([z.string(), z.array(z.string())]).optional(),
language: z.string(),
bookingUid: z.string().optional(),
metadata: z.record(z.string()),
hasHashedBookingLink: z.boolean().optional(),
hashedLink: z.string().nullish(),
seatReferenceUid: z.string().optional(),
orgSlug: z.string().optional(),
teamMemberEmail: z.string().nullish(),
crmOwnerRecordType: z.string().nullish(),
crmRecordId: z.string().nullish(),
routedTeamMemberIds: z.array(z.number()).nullish(),
routingFormResponseId: z.number().optional(),
skipContactOwner: z.boolean().optional(),
crmAppSlug: z.string().nullish().optional(),
cfToken: z.string().nullish().optional(),
/**
* Holds the corrected responses of the Form for a booking, provided during rerouting
*/
reroutingFormResponses: routingFormResponseInDbSchema.optional(),
/**
* Used to identify if the booking is a dry run.
*/
_isDryRun: z.boolean().optional(),
/** Whether to override the cache */
_shouldServeCache: z.boolean().optional(),
tracking: z.object({
utm_source: z.string().optional(),
utm_medium: z.string().optional(),
utm_campaign: z.string().optional(),
utm_term: z.string().optional(),
utm_content: z.string().optional(),
}).optional(),
dub_id: z.string().nullish(),
creationSource: z.nativeEnum(CreationSource).optional(),
});
export type BookingCreateBody = z.input<typeof bookingCreateBodySchema>;
export const extendedBookingCreateBody = bookingCreateBodySchema.merge(
z.object({
noEmail: z.boolean().optional(),
recurringCount: z.number().optional(),
allRecurringDates: z
.array(
z.object({
start: z.string(),
end: z.string(),
})
)
.optional(),
currentRecurringIndex: z.number().optional(),
appsStatus: z
.array(
z.object({
appName: z.string(),
success: z.number(),
failures: z.number(),
type: z.string(),
errors: z.string().array(),
warnings: z.string().array().optional(),
})
)
.optional(),
luckyUsers: z.array(z.number()).optional(),
customInputs: z.undefined().optional(),
})
);
// It has only the legacy props that are part of `responses` now. The API can still hit old props
export const bookingCreateSchemaLegacyPropsForApi = z.object({
email: z.string(),
name: z.string(),
guests: z.array(z.string()).optional(),
notes: z.string().optional(),
location: z.string(),
smsReminderNumber: z.string().optional().nullable(),
rescheduleReason: z.string().optional(),
customInputs: z.array(z.object({ label: z.string(), value: z.union([z.string(), z.boolean()]) })),
});
// This is the schema that is used for the API. It has all the legacy props that are part of `responses` now.
export const bookingCreateBodySchemaForApi = extendedBookingCreateBody.merge(
bookingCreateSchemaLegacyPropsForApi.partial()
);
-54
View File
@@ -1,54 +0,0 @@
import { SchedulingType } from "@calcom/prisma/enums";
import { z } from "zod";
import * as imports from "../../zod-utils";
import { MIN_EVENT_DURATION_MINUTES, MAX_EVENT_DURATION_MINUTES } from "@calcom/lib/constants";
// TODO: figure out why EventTypeModel is being called even if it's not imported here, causing a circular dependency
// import { _EventTypeModel } from "../eventtype";
const calVideoSettingsSchema = z
.object({
disableRecordingForGuests: z.boolean().nullish(),
disableRecordingForOrganizer: z.boolean().nullish(),
redirectUrlOnExit: z.string().url().nullish(),
enableAutomaticRecordingForOrganizer: z.boolean().nullish(),
enableAutomaticTranscription: z.boolean().nullish(),
disableTranscriptionForGuests: z.boolean().nullish(),
disableTranscriptionForOrganizer: z.boolean().nullish(),
})
.optional()
.nullable();
export const createEventTypeInput = z.object({
title: z.string().trim().min(1),
slug: imports.eventTypeSlug,
description: z.string().nullish(),
length: z.number().int().min(MIN_EVENT_DURATION_MINUTES).max(MAX_EVENT_DURATION_MINUTES),
hidden: z.boolean(),
teamId: z.number().int().nullish(),
schedulingType: z.nativeEnum(SchedulingType).nullish(),
locations: imports.eventTypeLocations,
metadata: imports.EventTypeMetaDataSchema.optional(),
disableGuests: z.boolean().optional(),
slotInterval: z.number().min(0).nullish(),
minimumBookingNotice: z.number().int().min(0).optional(),
beforeEventBuffer: z.number().int().min(0).optional(),
afterEventBuffer: z.number().int().min(0).optional(),
scheduleId: z.number().int().optional(),
calVideoSettings: calVideoSettingsSchema
})
.partial({ hidden: true, locations: true })
.refine((data) => (data.teamId ? data.teamId && data.schedulingType : true), {
path: ["schedulingType"],
message: "You must select a scheduling type for team events",
});
export const EventTypeDuplicateInput = z.object({
id: z.number(),
slug: z.string(),
title: z.string().trim().min(1),
description: z.string(),
length: z.number().int().min(MIN_EVENT_DURATION_MINUTES).max(MAX_EVENT_DURATION_MINUTES),
teamId: z.number().nullish(),
}).strict();
export type EventTypeLocation = (z.infer<typeof imports.eventTypeLocations>)[number];
-45
View File
@@ -1,45 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
import { WebhookTriggerEvents, TimeUnit } from "@prisma/client"
import { CompleteUser, UserModel, CompleteTeam, TeamModel, CompleteEventType, EventTypeModel, CompletePlatformOAuthClient, PlatformOAuthClientModel, CompleteApp, AppModel, CompleteWebhookScheduledTriggers, WebhookScheduledTriggersModel } from "./index"
export const _WebhookModel = z.object({
id: z.string(),
userId: z.number().int().nullish(),
teamId: z.number().int().nullish(),
eventTypeId: z.number().int().nullish(),
platformOAuthClientId: z.string().nullish(),
subscriberUrl: z.string().url(),
payloadTemplate: z.string().nullish(),
createdAt: z.date(),
active: z.boolean(),
eventTriggers: z.nativeEnum(WebhookTriggerEvents).array(),
appId: z.string().nullish(),
secret: z.string().nullish(),
platform: z.boolean(),
time: z.number().int().nullish(),
timeUnit: z.nativeEnum(TimeUnit).nullish(),
})
export interface CompleteWebhook extends z.infer<typeof _WebhookModel> {
user?: CompleteUser | null
team?: CompleteTeam | null
eventType?: CompleteEventType | null
platformOAuthClient?: CompletePlatformOAuthClient | null
app?: CompleteApp | null
scheduledTriggers: CompleteWebhookScheduledTriggers[]
}
/**
* WebhookModel contains all relations on your model in addition to the scalars
*
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const WebhookModel: z.ZodSchema<CompleteWebhook> = z.lazy(() => _WebhookModel.extend({
user: UserModel.nullish(),
team: TeamModel.nullish(),
eventType: EventTypeModel.nullish(),
platformOAuthClient: PlatformOAuthClientModel.nullish(),
app: AppModel.nullish(),
scheduledTriggers: WebhookScheduledTriggersModel.array(),
}))