fix: Update prisma enums to platform libs#23604
Conversation
WalkthroughBumps apps/api/v2 dependency @calcom/platform-libraries 0.0.338 → 0.0.340. Replaces many enum imports (MembershipRole, CreationSource, SchedulingType, AttributeType, TimeUnit, WebhookTriggerEvents, WorkflowTriggerEvents, WorkflowActions, WorkflowTemplates) from Possibly related PRs
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
apps/api/v2/src/modules/workflows/inputs/workflow-trigger.input.ts (1)
101-104: Bug: @isin used with nested array — validation will always fail.
@IsIn([WORKFLOW_TRIGGER_TYPES])wraps the allowed values array in another array. Use the array directly.Apply:
- @IsIn([WORKFLOW_TRIGGER_TYPES]) + @IsIn(WORKFLOW_TRIGGER_TYPES)apps/api/v2/src/modules/workflows/inputs/workflow-step.input.ts (1)
59-66: Fix inverted entry in TEMPLATES_TO_ENUM (REMINDER).The first mapping is reversed versus the others and likely wrong at runtime. Align all keys to template strings and values to enum members.
export const TEMPLATES_TO_ENUM = { - [WorkflowTemplates.REMINDER]: REMINDER, - [CUSTOM]: WorkflowTemplates.CUSTOM, - [RESCHEDULED]: WorkflowTemplates.RESCHEDULED, - [CANCELLED]: WorkflowTemplates.CANCELLED, - [COMPLETED]: WorkflowTemplates.COMPLETED, - [RATING]: WorkflowTemplates.RATING, + [REMINDER]: WorkflowTemplates.REMINDER, + [CUSTOM]: WorkflowTemplates.CUSTOM, + [RESCHEDULED]: WorkflowTemplates.RESCHEDULED, + [CANCELLED]: WorkflowTemplates.CANCELLED, + [COMPLETED]: WorkflowTemplates.COMPLETED, + [RATING]: WorkflowTemplates.RATING, } as const;apps/api/v2/src/modules/webhooks/outputs/webhook.output.ts (1)
52-55: Fix DTO type/decorator mismatch for DeleteManyWebhooksOutputResponseDto.data.
datais typed asstringbut decorated as a nested WebhookOutputDto — this will confuse Swagger and may break validation.Apply one of the following; Option A aligns with current
stringtype:export class DeleteManyWebhooksOutputResponseDto { @ApiProperty({ example: SUCCESS_STATUS, enum: [SUCCESS_STATUS, ERROR_STATUS] }) @IsEnum([SUCCESS_STATUS, ERROR_STATUS]) @Expose() status!: typeof SUCCESS_STATUS | typeof ERROR_STATUS; - @Expose() - @ValidateNested() - @Type(() => WebhookOutputDto) - data!: string; + @Expose() + data!: string; }If
datashould be a DTO (or array), change the type instead:- data!: string; + @ValidateNested({ each: true }) + @Type(() => WebhookOutputDto) + data!: WebhookOutputDto[]; // or WebhookOutputDtoapps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.ts (1)
2193-2196: Syntax error: stray "+" before expectThere's a leading "+" causing a test compile failure.
Apply this diff:
- const responseBody: ApiSuccessResponse<EventTypeOutput_2024_06_14> = response.body; - const updatedEventType = responseBody.data; - +expect(updatedEventType.hidden).toBe(false); + const responseBody: ApiSuccessResponse<EventTypeOutput_2024_06_14> = response.body; + const updatedEventType = responseBody.data; + expect(updatedEventType.hidden).toBe(false);
🧹 Nitpick comments (17)
apps/api/v2/src/modules/workflows/inputs/workflow-trigger.input.ts (1)
132-165: Consistency: add validators to constant-typed trigger DTOs.Several DTOs (Rejected/Requested/PaymentInitiated/Paid/NoShowUpdated) lack
@IsString()and@IsIn([...]), unlike others. Add for uniform validation.Example for one DTO (repeat similarly for the others):
export class OnRejectedTriggerDto { @ApiProperty({ description: "Trigger type for the workflow", }) + @IsString() + @IsIn([BOOKING_REJECTED]) type: typeof BOOKING_REJECTED = BOOKING_REJECTED; }apps/api/v2/src/modules/organizations/memberships/inputs/create-organization-membership.input.ts (1)
16-21: Avoid enum drift in Swagger docs.Hard-coding string literals can desync from MembershipRole. Reference the enum directly.
- @ApiProperty({ - enum: ["MEMBER", "OWNER", "ADMIN"], - description: "If you are platform customer then managed users should only have MEMBER role.", - }) + @ApiProperty({ + enum: MembershipRole, + description: "If you are platform customer then managed users should only have MEMBER role.", + })apps/api/v2/src/modules/auth/guards/organization-roles/organization-roles.guard.ts (1)
66-67: Minor: simplify empty-roles check.
Object.keys(allowedRoles)?.lengthis redundant for arrays.- if (!allowedRoles?.length || !Object.keys(allowedRoles)?.length) { + if (!allowedRoles?.length) { return true; }apps/api/v2/src/modules/memberships/memberships.repository.ts (1)
10-21: Preferselectto limit payloads in read paths.To align with our Prisma guideline (“only select data you need”), consider adding
selectwhere full objects aren’t required (e.g., findMembershipByTeamId, findOrgUserMembership, getUserAdminOrOwnerTeamMembership).Example for findMembershipByTeamId:
async findMembershipByTeamId(teamId: number, userId: number) { - const membership = await this.dbRead.prisma.membership.findUnique({ + const membership = await this.dbRead.prisma.membership.findUnique({ where: { userId_teamId: { userId: userId, teamId: teamId, }, }, + select: { id: true, userId: true, teamId: true, role: true, accepted: true }, });Also applies to: 53-64, 127-138
apps/api/v2/src/modules/organizations/event-types/services/output.service.ts (3)
106-108: Prefer enum comparisons over string literals.Use
SchedulingType.MANAGEDandSchedulingType.ROUND_ROBINfor type safety and future-proofing.- databaseEventType.schedulingType === "MANAGED" + databaseEventType.schedulingType === SchedulingType.MANAGED ? await this.getManagedEventTypeHosts(databaseEventType.id) : await this.getNonManagedEventTypeHosts(databaseEventType.hosts, databaseEventType.schedulingType); @@ - if (schedulingType === "ROUND_ROBIN") { + if (schedulingType === SchedulingType.ROUND_ROBIN) {Also applies to: 175-176
47-47: Duplicate key in Pick list.
"lockTimeZoneToggleOnBookingPage"appears twice. Remove the duplicate.| "lockTimeZoneToggleOnBookingPage" @@ - | "lockTimeZoneToggleOnBookingPage"Also applies to: 75-75
147-162: Batch user lookups to avoid N+1 queries in getManagedEventTypeHosts.Mirror the batching approach used in
getNonManagedEventTypeHosts.- async getManagedEventTypeHosts(eventTypeId: number) { - const children = await this.teamsEventTypesRepository.getEventTypeChildren(eventTypeId); - const transformedHosts: TeamEventTypeResponseHost[] = []; - for (const child of children) { - if (child.userId) { - const user = await this.usersRepository.findById(child.userId); - transformedHosts.push({ - userId: child.userId, - name: user?.name || "", - username: user?.username || "", - avatarUrl: user?.avatarUrl, - }); - } - } - return transformedHosts; - } + async getManagedEventTypeHosts(eventTypeId: number) { + const children = await this.teamsEventTypesRepository.getEventTypeChildren(eventTypeId); + const userIds = children.filter(c => !!c.userId).map(c => c.userId!) ; + const users = await this.usersRepository.findByIds(userIds); + const byId = new Map(users.map(u => [u.id, u])); + return children + .filter(c => !!c.userId) + .map((c) => { + const u = byId.get(c.userId!); + return { + userId: c.userId!, + name: u?.name || "", + username: u?.username || "", + avatarUrl: u?.avatarUrl, + } as TeamEventTypeResponseHost; + }); + }apps/api/v2/src/modules/teams/memberships/outputs/team-membership.output.ts (1)
74-78: Avoid enum drift in Swagger: use MembershipRole values instead of hard-coded strings.Keeps docs in sync if enum changes upstream.
- @ApiProperty({ enum: ["MEMBER", "OWNER", "ADMIN"] }) + @ApiProperty({ enum: Object.values(MembershipRole) })apps/api/v2/src/modules/organizations/memberships/inputs/update-organization-membership.input.ts (1)
12-15: Keep OpenAPI enum synced with source enum.Use runtime values from MembershipRole to prevent drift.
- @ApiPropertyOptional({ enum: ["MEMBER", "OWNER", "ADMIN"] }) + @ApiPropertyOptional({ enum: Object.values(MembershipRole) })apps/api/v2/src/modules/teams/memberships/inputs/create-team-membership.input.ts (1)
16-19: De-duplicate enum literals in Swagger.Derive from MembershipRole to keep docs aligned.
- @ApiPropertyOptional({ enum: ["MEMBER", "OWNER", "ADMIN"], default: "MEMBER" }) + @ApiPropertyOptional({ enum: Object.values(MembershipRole), default: MembershipRole.MEMBER })apps/api/v2/src/modules/teams/memberships/inputs/update-team-membership.input.ts (1)
12-15: Avoid Swagger enum drift by using the source enum.Use MembershipRole directly instead of a hard-coded string array for docs.
Apply:
- @ApiPropertyOptional({ enum: ["MEMBER", "OWNER", "ADMIN"] }) + @ApiPropertyOptional({ enum: MembershipRole })apps/api/v2/src/ee/bookings/2024-04-15/controllers/bookings.controller.ts (1)
512-542: Possible unused helper — consider cleanup.createNextApiRecurringBookingRequest appears unused within this controller; if not referenced elsewhere, remove to reduce maintenance surface.
apps/api/v2/src/modules/workflows/workflows.repository.ts (1)
22-33: Prefer Prismaselectoverincludeto limit payloads.Multiple queries expand relations with
include(steps, activeOn). To align with the repo guideline (“never use include; always select”), switch toselectand enumerate only necessary fields (including top-level fields you actually need).I can draft
selectshapes (e.g.,activeOn: { select: { eventTypeId: true } }and minimal fields forWorkflow/WorkflowStep) if you share which fields are consumed downstream.Also applies to: 37-48, 54-63
apps/api/v2/src/modules/users/users.repository.ts (2)
73-87: Align Prisma queries withselectto avoid overfetching and accidental PII exposure.Several lookups use
includeonuser,profiles, calendars, etc. Preferselectand define a reusableuserSafeSelectto consistently whitelist fields returned from repositories.Example pattern for
findByIdWithProfile:- return this.dbRead.prisma.user.findUnique({ - where: { id: userId }, - include: { - movedToProfile: { include: { organization: { select: { isPlatform: true, name: true, slug: true, id: true } } } }, - profiles: { include: { organization: { select: { isPlatform: true, name: true, slug: true, id: true } } } }, - }, - }); + const userSafeSelect = { + id: true, + email: true, + username: true, + locale: true, + defaultScheduleId: true, + movedToProfile: { + select: { organization: { select: { isPlatform: true, name: true, slug: true, id: true } } }, + }, + profiles: { + select: { organization: { select: { isPlatform: true, name: true, slug: true, id: true } }, username: true, id: true }, + }, + } as const; + return this.dbRead.prisma.user.findUnique({ + where: { id: userId }, + select: userSafeSelect, + });If helpful, I can propagate this refactor across the repository queries in this file.
Also applies to: 89-108, 153-167, 283-293, 133-143
260-264: No-op setter — remove or implement intended normalization.formatInput reassigns the same value; either implement the intended transformation (e.g., normalize weekStart) or drop the method.
- formatInput(userInput: CreateManagedUserInput | UpdateManagedUserInput) { - if (userInput.weekStart) { - userInput.weekStart = userInput.weekStart; - } - } + // formatInput reserved for future normalization; currently unused.apps/api/v2/src/modules/organizations/teams/index/outputs/organization-team.output.ts (1)
14-19: Optional: use enum directly in Swagger/class-validator decoratorsUsing the enum object avoids duplicating allowed values and keeps it future-proof if new roles are added.
Apply this diff:
- @ApiProperty({ - example: MembershipRole.MEMBER, - enum: [MembershipRole.ADMIN, MembershipRole.OWNER, MembershipRole.MEMBER], - }) - @IsEnum([MembershipRole.ADMIN, MembershipRole.OWNER, MembershipRole.MEMBER]) + @ApiProperty({ example: MembershipRole.MEMBER, enum: MembershipRole }) + @IsEnum(MembershipRole)apps/api/v2/src/modules/oauth-clients/controllers/oauth-clients/oauth-clients.controller.ts (1)
72-75: Avoid logging full request bodiesBody may contain sensitive/PII. Prefer allowlisting fields in logs.
Apply this diff:
- this.logger.log( - `For organisation ${organizationId} creating OAuth Client with data: ${JSON.stringify(body)}` - ); + this.logger.log( + `For organisation ${organizationId} creating OAuth Client with data: ${JSON.stringify({ + name: body?.name, + redirectUris: body?.redirectUris?.length, + permissions: body?.permissions, + })}` + );- this.logger.log(`For client ${clientId} updating OAuth Client with data: ${JSON.stringify(body)}`); + this.logger.log( + `For client ${clientId} updating OAuth Client with data: ${JSON.stringify({ + name: body?.name, + redirectUris: body?.redirectUris?.length, + permissions: body?.permissions, + })}` + );Also applies to: 143-144
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (34)
apps/api/v2/package.json(1 hunks)apps/api/v2/src/ee/bookings/2024-04-15/controllers/bookings.controller.ts(1 hunks)apps/api/v2/src/ee/bookings/2024-08-13/services/input.service.ts(1 hunks)apps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.ts(1 hunks)apps/api/v2/src/lib/roles/constants.ts(1 hunks)apps/api/v2/src/modules/auth/decorators/roles/membership-roles.decorator.ts(1 hunks)apps/api/v2/src/modules/auth/guards/organization-roles/organization-roles.guard.ts(1 hunks)apps/api/v2/src/modules/memberships/memberships.repository.ts(1 hunks)apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-users/oauth-client-users.controller.ts(1 hunks)apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.ts(1 hunks)apps/api/v2/src/modules/oauth-clients/controllers/oauth-clients/oauth-clients.controller.ts(1 hunks)apps/api/v2/src/modules/oauth-clients/services/oauth-clients-users.service.ts(1 hunks)apps/api/v2/src/modules/organizations/attributes/index/inputs/create-organization-attribute.input.ts(1 hunks)apps/api/v2/src/modules/organizations/attributes/index/inputs/update-organization-attribute.input.ts(1 hunks)apps/api/v2/src/modules/organizations/event-types/organizations-event-types.e2e-spec.ts(1 hunks)apps/api/v2/src/modules/organizations/event-types/services/output.service.ts(1 hunks)apps/api/v2/src/modules/organizations/memberships/inputs/create-organization-membership.input.ts(1 hunks)apps/api/v2/src/modules/organizations/memberships/inputs/update-organization-membership.input.ts(1 hunks)apps/api/v2/src/modules/organizations/teams/index/outputs/organization-team.output.ts(1 hunks)apps/api/v2/src/modules/organizations/teams/memberships/inputs/create-organization-team-membership.input.ts(1 hunks)apps/api/v2/src/modules/organizations/teams/memberships/inputs/update-organization-team-membership.input.ts(1 hunks)apps/api/v2/src/modules/organizations/users/index/inputs/create-organization-user.input.ts(1 hunks)apps/api/v2/src/modules/organizations/users/index/services/organizations-users-service.ts(1 hunks)apps/api/v2/src/modules/teams/memberships/inputs/create-team-membership.input.ts(1 hunks)apps/api/v2/src/modules/teams/memberships/inputs/update-team-membership.input.ts(1 hunks)apps/api/v2/src/modules/teams/memberships/outputs/team-membership.output.ts(1 hunks)apps/api/v2/src/modules/users/users.repository.ts(1 hunks)apps/api/v2/src/modules/webhooks/inputs/webhook.input.ts(1 hunks)apps/api/v2/src/modules/webhooks/outputs/webhook.output.ts(1 hunks)apps/api/v2/src/modules/workflows/inputs/workflow-step.input.ts(1 hunks)apps/api/v2/src/modules/workflows/inputs/workflow-trigger.input.ts(1 hunks)apps/api/v2/src/modules/workflows/workflows.repository.ts(1 hunks)apps/api/v2/test/fixtures/repository/membership.repository.fixture.ts(1 hunks)packages/platform/libraries/index.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
**/*.ts: For Prisma queries, only select data you need; never useinclude, always useselect
Ensure thecredential.keyfield is never returned from tRPC endpoints or APIs
Files:
apps/api/v2/src/modules/organizations/memberships/inputs/create-organization-membership.input.tsapps/api/v2/src/modules/oauth-clients/controllers/oauth-client-users/oauth-client-users.controller.tsapps/api/v2/src/modules/workflows/inputs/workflow-trigger.input.tsapps/api/v2/src/modules/teams/memberships/inputs/update-team-membership.input.tsapps/api/v2/src/lib/roles/constants.tsapps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.tsapps/api/v2/src/modules/auth/guards/organization-roles/organization-roles.guard.tsapps/api/v2/src/modules/workflows/inputs/workflow-step.input.tsapps/api/v2/src/modules/organizations/event-types/services/output.service.tsapps/api/v2/src/modules/webhooks/outputs/webhook.output.tsapps/api/v2/src/modules/oauth-clients/services/oauth-clients-users.service.tsapps/api/v2/src/modules/organizations/users/index/services/organizations-users-service.tsapps/api/v2/src/modules/webhooks/inputs/webhook.input.tsapps/api/v2/src/modules/organizations/event-types/organizations-event-types.e2e-spec.tsapps/api/v2/src/modules/organizations/attributes/index/inputs/update-organization-attribute.input.tsapps/api/v2/src/modules/teams/memberships/inputs/create-team-membership.input.tsapps/api/v2/src/ee/bookings/2024-08-13/services/input.service.tsapps/api/v2/test/fixtures/repository/membership.repository.fixture.tsapps/api/v2/src/modules/organizations/teams/memberships/inputs/create-organization-team-membership.input.tsapps/api/v2/src/modules/organizations/memberships/inputs/update-organization-membership.input.tsapps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.tsapps/api/v2/src/modules/auth/decorators/roles/membership-roles.decorator.tsapps/api/v2/src/modules/organizations/users/index/inputs/create-organization-user.input.tsapps/api/v2/src/modules/organizations/attributes/index/inputs/create-organization-attribute.input.tsapps/api/v2/src/modules/workflows/workflows.repository.tsapps/api/v2/src/ee/bookings/2024-04-15/controllers/bookings.controller.tsapps/api/v2/src/modules/memberships/memberships.repository.tsapps/api/v2/src/modules/users/users.repository.tsapps/api/v2/src/modules/organizations/teams/index/outputs/organization-team.output.tspackages/platform/libraries/index.tsapps/api/v2/src/modules/organizations/teams/memberships/inputs/update-organization-team-membership.input.tsapps/api/v2/src/modules/oauth-clients/controllers/oauth-clients/oauth-clients.controller.tsapps/api/v2/src/modules/teams/memberships/outputs/team-membership.output.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js
.utc()in hot paths like loops
Files:
apps/api/v2/src/modules/organizations/memberships/inputs/create-organization-membership.input.tsapps/api/v2/src/modules/oauth-clients/controllers/oauth-client-users/oauth-client-users.controller.tsapps/api/v2/src/modules/workflows/inputs/workflow-trigger.input.tsapps/api/v2/src/modules/teams/memberships/inputs/update-team-membership.input.tsapps/api/v2/src/lib/roles/constants.tsapps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.tsapps/api/v2/src/modules/auth/guards/organization-roles/organization-roles.guard.tsapps/api/v2/src/modules/workflows/inputs/workflow-step.input.tsapps/api/v2/src/modules/organizations/event-types/services/output.service.tsapps/api/v2/src/modules/webhooks/outputs/webhook.output.tsapps/api/v2/src/modules/oauth-clients/services/oauth-clients-users.service.tsapps/api/v2/src/modules/organizations/users/index/services/organizations-users-service.tsapps/api/v2/src/modules/webhooks/inputs/webhook.input.tsapps/api/v2/src/modules/organizations/event-types/organizations-event-types.e2e-spec.tsapps/api/v2/src/modules/organizations/attributes/index/inputs/update-organization-attribute.input.tsapps/api/v2/src/modules/teams/memberships/inputs/create-team-membership.input.tsapps/api/v2/src/ee/bookings/2024-08-13/services/input.service.tsapps/api/v2/test/fixtures/repository/membership.repository.fixture.tsapps/api/v2/src/modules/organizations/teams/memberships/inputs/create-organization-team-membership.input.tsapps/api/v2/src/modules/organizations/memberships/inputs/update-organization-membership.input.tsapps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.tsapps/api/v2/src/modules/auth/decorators/roles/membership-roles.decorator.tsapps/api/v2/src/modules/organizations/users/index/inputs/create-organization-user.input.tsapps/api/v2/src/modules/organizations/attributes/index/inputs/create-organization-attribute.input.tsapps/api/v2/src/modules/workflows/workflows.repository.tsapps/api/v2/src/ee/bookings/2024-04-15/controllers/bookings.controller.tsapps/api/v2/src/modules/memberships/memberships.repository.tsapps/api/v2/src/modules/users/users.repository.tsapps/api/v2/src/modules/organizations/teams/index/outputs/organization-team.output.tspackages/platform/libraries/index.tsapps/api/v2/src/modules/organizations/teams/memberships/inputs/update-organization-team-membership.input.tsapps/api/v2/src/modules/oauth-clients/controllers/oauth-clients/oauth-clients.controller.tsapps/api/v2/src/modules/teams/memberships/outputs/team-membership.output.ts
**/*.{ts,tsx,js,jsx}
⚙️ CodeRabbit configuration file
Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.
Files:
apps/api/v2/src/modules/organizations/memberships/inputs/create-organization-membership.input.tsapps/api/v2/src/modules/oauth-clients/controllers/oauth-client-users/oauth-client-users.controller.tsapps/api/v2/src/modules/workflows/inputs/workflow-trigger.input.tsapps/api/v2/src/modules/teams/memberships/inputs/update-team-membership.input.tsapps/api/v2/src/lib/roles/constants.tsapps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.tsapps/api/v2/src/modules/auth/guards/organization-roles/organization-roles.guard.tsapps/api/v2/src/modules/workflows/inputs/workflow-step.input.tsapps/api/v2/src/modules/organizations/event-types/services/output.service.tsapps/api/v2/src/modules/webhooks/outputs/webhook.output.tsapps/api/v2/src/modules/oauth-clients/services/oauth-clients-users.service.tsapps/api/v2/src/modules/organizations/users/index/services/organizations-users-service.tsapps/api/v2/src/modules/webhooks/inputs/webhook.input.tsapps/api/v2/src/modules/organizations/event-types/organizations-event-types.e2e-spec.tsapps/api/v2/src/modules/organizations/attributes/index/inputs/update-organization-attribute.input.tsapps/api/v2/src/modules/teams/memberships/inputs/create-team-membership.input.tsapps/api/v2/src/ee/bookings/2024-08-13/services/input.service.tsapps/api/v2/test/fixtures/repository/membership.repository.fixture.tsapps/api/v2/src/modules/organizations/teams/memberships/inputs/create-organization-team-membership.input.tsapps/api/v2/src/modules/organizations/memberships/inputs/update-organization-membership.input.tsapps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.tsapps/api/v2/src/modules/auth/decorators/roles/membership-roles.decorator.tsapps/api/v2/src/modules/organizations/users/index/inputs/create-organization-user.input.tsapps/api/v2/src/modules/organizations/attributes/index/inputs/create-organization-attribute.input.tsapps/api/v2/src/modules/workflows/workflows.repository.tsapps/api/v2/src/ee/bookings/2024-04-15/controllers/bookings.controller.tsapps/api/v2/src/modules/memberships/memberships.repository.tsapps/api/v2/src/modules/users/users.repository.tsapps/api/v2/src/modules/organizations/teams/index/outputs/organization-team.output.tspackages/platform/libraries/index.tsapps/api/v2/src/modules/organizations/teams/memberships/inputs/update-organization-team-membership.input.tsapps/api/v2/src/modules/oauth-clients/controllers/oauth-clients/oauth-clients.controller.tsapps/api/v2/src/modules/teams/memberships/outputs/team-membership.output.ts
**/*.{service,repository}.ts
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
Avoid dot-suffixes like
.service.tsor.repository.tsfor new files; reserve.test.ts,.spec.ts,.types.tsfor their specific purposes
Files:
apps/api/v2/src/modules/organizations/event-types/services/output.service.tsapps/api/v2/src/modules/oauth-clients/services/oauth-clients-users.service.tsapps/api/v2/src/ee/bookings/2024-08-13/services/input.service.tsapps/api/v2/src/modules/workflows/workflows.repository.tsapps/api/v2/src/modules/memberships/memberships.repository.tsapps/api/v2/src/modules/users/users.repository.ts
🧠 Learnings (5)
📚 Learning: 2025-08-26T20:09:17.089Z
Learnt from: Udit-takkar
PR: calcom/cal.com#22995
File: packages/features/ee/workflows/components/WorkflowStepContainer.tsx:641-649
Timestamp: 2025-08-26T20:09:17.089Z
Learning: In packages/features/ee/workflows/components/WorkflowStepContainer.tsx, Cal.AI actions are intentionally filtered out/hidden for organization workflows when props.isOrganization is true. This restriction is by design per maintainer Udit-takkar in PR #22995, despite the broader goal of enabling Cal.AI self-serve.
Applied to files:
apps/api/v2/src/modules/workflows/inputs/workflow-step.input.ts
📚 Learning: 2025-08-27T13:32:46.887Z
Learnt from: supalarry
PR: calcom/cal.com#23364
File: apps/api/v2/src/ee/event-types/event-types_2024_06_14/transformers/internal-to-api/internal-to-api.spec.ts:295-296
Timestamp: 2025-08-27T13:32:46.887Z
Learning: In calcom/cal.com, when transforming booking fields from internal to API format, tests in organizations-event-types.e2e-spec.ts already expect name field label and placeholder to be empty strings ("") rather than undefined. PR changes that set these to explicit empty strings are typically fixing implementation to match existing test expectations rather than breaking changes.
Applied to files:
apps/api/v2/src/modules/organizations/event-types/services/output.service.tsapps/api/v2/src/modules/organizations/event-types/organizations-event-types.e2e-spec.tsapps/api/v2/src/ee/bookings/2024-08-13/services/input.service.tsapps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.tsapps/api/v2/src/ee/bookings/2024-04-15/controllers/bookings.controller.ts
📚 Learning: 2025-08-21T13:44:06.805Z
Learnt from: supalarry
PR: calcom/cal.com#23217
File: apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/output-event-types.service.ts:93-94
Timestamp: 2025-08-21T13:44:06.805Z
Learning: In apps/api/v2/src/ee/event-types/event-types_2024_06_14/event-types.repository.ts, repository functions that use explicit Prisma select clauses (like getEventTypeWithSeats) are used for specific purposes and don't need to include all EventType fields like bookingRequiresAuthentication. These methods don't feed into the general OutputEventTypesService_2024_06_14 flow.
Applied to files:
apps/api/v2/src/modules/organizations/event-types/services/output.service.tsapps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.ts
📚 Learning: 2025-09-03T11:54:05.409Z
Learnt from: supalarry
PR: calcom/cal.com#23514
File: apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts:579-582
Timestamp: 2025-09-03T11:54:05.409Z
Learning: In calcom/cal.com bookings repository methods, when Prisma select uses `eventType: true`, all eventType fields including seatsShowAttendees are automatically included in the selection. Explicit field selection is not required when using `true` for nested relations.
Applied to files:
apps/api/v2/src/modules/organizations/event-types/services/output.service.ts
📚 Learning: 2025-09-03T11:54:05.409Z
Learnt from: supalarry
PR: calcom/cal.com#23514
File: apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts:579-582
Timestamp: 2025-09-03T11:54:05.409Z
Learning: In calcom/cal.com bookings repository methods, when Prisma include uses `eventType: true`, all eventType fields including seatsShowAttendees are automatically included in the selection. Explicit field selection is not required when using `true` for nested relations.
Applied to files:
apps/api/v2/src/modules/organizations/event-types/services/output.service.ts
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Install dependencies / Yarn install & cache
🔇 Additional comments (31)
apps/api/v2/src/modules/workflows/inputs/workflow-trigger.input.ts (1)
5-5: Import path migration acknowledged.TimeUnit and WorkflowTriggerEvents moved to platform-libraries; no behavioral change here.
apps/api/v2/src/modules/organizations/memberships/inputs/create-organization-membership.input.ts (1)
4-4: Import path migration looks good.MembershipRole now sourced from platform-libraries; type/default remain correct.
apps/api/v2/src/modules/auth/guards/organization-roles/organization-roles.guard.ts (1)
9-9: Import path migration looks good.Type-only use of MembershipRole aligns with platform-libraries export.
apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.ts (1)
24-24: Import path migration looks good.MembershipRole now from platform-libraries; role checks remain unchanged.
apps/api/v2/src/modules/webhooks/inputs/webhook.input.ts (1)
4-4: LGTM: import migrated to platform-libraries.Switching WebhookTriggerEvents to @calcom/platform-libraries aligns with the PR goal; no API surface change in this DTO.
apps/api/v2/src/modules/workflows/inputs/workflow-step.input.ts (1)
5-5: LGTM: enum imports consolidated under platform-libraries.WorkflowActions and WorkflowTemplates re-exports look consistent with the migration.
apps/api/v2/src/modules/organizations/event-types/organizations-event-types.e2e-spec.ts (1)
27-27: LGTM: SchedulingType import updated.Tests still exercise both enum and string representations elsewhere; this change is non-functional.
apps/api/v2/src/modules/memberships/memberships.repository.ts (1)
4-4: LGTM: MembershipRole import migrated.Type-only usage in createMembership remains correct.
apps/api/v2/src/modules/oauth-clients/services/oauth-clients-users.service.ts (1)
14-14: LGTM: CreationSource import switched to platform-libraries.No behavior change; value CreationSource.API_V2 remains the same.
apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-users/oauth-client-users.controller.ts (1)
38-38: Approve: no lingering enum imports
No imports from "@calcom/prisma/enums" detected inapps/api/v2. MembershipRole import is properly migrated and decorator usage remains consistent.apps/api/v2/src/modules/webhooks/outputs/webhook.output.ts (1)
6-6: Confirm runtime enum availability
Ensure theexport { WebhookTriggerEvents } from "@calcom/prisma/enums"re-export brings in a value-bearing enum (object) at runtime—otherwiseclass-validator’sIsEnum()won’t work.apps/api/v2/src/modules/organizations/event-types/services/output.service.ts (1)
15-15: SchedulingType import migrated — looks good.apps/api/v2/test/fixtures/repository/membership.repository.fixture.ts (1)
6-6: Confirm MembershipRole value compatibility
Ensure the values exposed by MembershipRole (from @calcom/platform-libraries) exactly match the MembershipRole enum in your Prisma schema to prevent type/value mismatches during inserts.apps/api/v2/src/modules/organizations/attributes/index/inputs/update-organization-attribute.input.ts (1)
4-4: Confirm runtime export of AttributeType
Unable to locate a runtime enum export in@calcom/platform-libraries; ensureAttributeTypeis re-exported as a runtime enum soIsEnum(AttributeType)validates correctly.apps/api/v2/src/modules/organizations/attributes/index/inputs/create-organization-attribute.input.ts (1)
14-14: LGTM! Import path successfully updated to platform libraries.The import source for
AttributeTypehas been correctly updated from@calcom/prisma/enumsto@calcom/platform-libraries, aligning with the broader migration strategy in this PR.apps/api/v2/src/lib/roles/constants.ts (1)
1-1: LGTM! Import path successfully updated to platform libraries.The import source for
MembershipRolehas been correctly updated from@calcom/prisma/enumsto@calcom/platform-libraries, maintaining consistency with the PR's migration strategy.apps/api/v2/src/modules/organizations/teams/memberships/inputs/create-organization-team-membership.input.ts (1)
4-4: LGTM! Import path successfully updated to platform libraries.The import source for
MembershipRolehas been correctly updated from@calcom/prisma/enumsto@calcom/platform-libraries, consistent with the broader enum migration in this PR.apps/api/v2/package.json (1)
41-41: LGTM! Version bump aligns with the migration.The dependency
@calcom/platform-librarieshas been correctly bumped from version 0.0.338 to 0.0.339, which supports the consolidated enum exports that this PR is migrating to.apps/api/v2/src/modules/organizations/teams/memberships/inputs/update-organization-team-membership.input.ts (1)
4-4: LGTM! Import path successfully updated to platform libraries.The import source for
MembershipRolehas been correctly updated from@calcom/prisma/enumsto@calcom/platform-libraries, maintaining consistency with the PR's migration strategy.apps/api/v2/src/modules/auth/decorators/roles/membership-roles.decorator.ts (1)
3-3: LGTM—no remaining @calcom/prisma/enums imports; please manually confirm that MembershipRole is exported by @calcom/platform-librariesapps/api/v2/src/ee/bookings/2024-08-13/services/input.service.ts (1)
32-32: LGTM: CreationSource import path updated.Usage of CreationSource.API_V2 below (Lines 125, 129, 264, 545, 549) remains correct.
apps/api/v2/src/modules/teams/memberships/outputs/team-membership.output.ts (1)
5-5: LGTM: MembershipRole import migrated to platform-libraries.apps/api/v2/src/modules/organizations/memberships/inputs/update-organization-membership.input.ts (1)
4-4: LGTM: MembershipRole import path updated.apps/api/v2/src/modules/teams/memberships/inputs/create-team-membership.input.ts (1)
4-4: LGTM: MembershipRole import path updated.apps/api/v2/src/modules/teams/memberships/inputs/update-team-membership.input.ts (1)
4-4: Enum import path migration LGTM.Matches the platform-libraries consolidation.
apps/api/v2/src/modules/workflows/workflows.repository.ts (1)
6-6: Enum import path migration LGTM.TimeUnit and WorkflowTriggerEvents from platform-libraries are correct.
apps/api/v2/src/modules/users/users.repository.ts (2)
8-8: Enum import path migration LGTM.CreationSource from platform-libraries keeps semantics unchanged (API_V2).
10-13: Verify downstream usage of optionalprofiles
Ensure all callers handleprofilespossibly beingundefinedornullbefore accessing its properties.apps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.ts (1)
33-33: Enum import migration looks correctImporting SchedulingType from @calcom/platform-libraries aligns with the new re-export surface.
apps/api/v2/src/modules/organizations/teams/index/outputs/organization-team.output.ts (1)
6-6: Enum source updated to platform-libraries — goodMembershipRole import now points to @calcom/platform-libraries, consistent with the PR’s goal.
apps/api/v2/src/modules/oauth-clients/controllers/oauth-clients/oauth-clients.controller.ts (1)
40-40: Enum import migration looks correctMembershipRole now comes from @calcom/platform-libraries; decorators still reference the same values.
| getBookingForReschedule, | ||
| ErrorCode, | ||
| } from "@calcom/platform-libraries"; | ||
| import { CreationSource } from "@calcom/platform-libraries"; |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Enum import path migration LGTM.
CreationSource via @calcom/platform-libraries aligns with the new export surface.
Quick check for any stale CreationSource imports:
🏁 Script executed:
#!/bin/bash
rg -nP 'CreationSource.*from\s+["'\'']@calcom/prisma/enums["'\'']' --type=ts --type=tsxLength of output: 117
🏁 Script executed:
#!/bin/bash
# Search for stale CreationSource imports from @calcom/prisma/enums
rg -n "CreationSource.*from\s+['\"]@calcom/prisma/enums['\"]" -g '*.ts' -g '*.tsx'Length of output: 4907
Replace stale CreationSource imports
40 occurrences of
import { CreationSource } from "@calcom/prisma/enums";remain across the codebase; update each to
import { CreationSource } from "@calcom/platform-libraries";🤖 Prompt for AI Agents
In apps/api/v2/src/ee/bookings/2024-04-15/controllers/bookings.controller.ts
around line 60, the file imports CreationSource from the stale module
"@calcom/prisma/enums"; replace that import to use the new module
"@calcom/platform-libraries". Update the import statement to import
CreationSource from "@calcom/platform-libraries" and run a quick project-wide
search to replace the remaining occurrences (40 total) of the old import with
the new one.
| import { IsString, IsOptional, IsBoolean, IsEnum } from "class-validator"; | ||
|
|
||
| import { MembershipRole } from "@calcom/prisma/enums"; | ||
| import { MembershipRole } from "@calcom/platform-libraries"; |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Enum import path migration LGTM.
Importing MembershipRole from @calcom/platform-libraries is consistent with the PR’s objective.
Run to confirm no lingering enum imports from @calcom/prisma/enums:
🏁 Script executed:
#!/bin/bash
rg -nP 'from\s+["'\'']@calcom/prisma/enums["'\'']' --type=ts --type=tsx -SLength of output: 104
🏁 Script executed:
#!/bin/bash
rg -nP 'from\s+["'"'"']@calcom/prisma/enums["'"'"']' -g '*.ts' -g '*.tsx' -nLength of output: 75021
Migrate all remaining enum imports to @calcom/platform-libraries
The codebase still contains hundreds of imports from @calcom/prisma/enums (e.g. packages/emails/src/templates/OrganizerScheduledEmail.tsx, packages/trpc/server/routers/viewer/teams/changeMemberRole.handler.ts, etc.). Replace every import { … } from "@calcom/prisma/enums" with the corresponding import from @calcom/platform-libraries.
🤖 Prompt for AI Agents
In
apps/api/v2/src/modules/organizations/users/index/inputs/create-organization-user.input.ts
around line 5, replace any import of enums from "@calcom/prisma/enums" with the
corresponding import from "@calcom/platform-libraries"; specifically ensure
MembershipRole is imported from "@calcom/platform-libraries" (remove the old
prisma enums import), update any references if needed, and run a repo-wide
search to swap remaining "@calcom/prisma/enums" imports to
"@calcom/platform-libraries" to complete the migration.
apps/api/v2/src/modules/organizations/users/index/services/organizations-users-service.ts
Show resolved
Hide resolved
| @@ -2,7 +2,7 @@ import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger"; | |||
| import { Expose, Transform, Type } from "class-transformer"; | |||
| import { IsBoolean, IsInt, IsObject, IsOptional, IsString, ValidateNested } from "class-validator"; | |||
There was a problem hiding this comment.
Fix validator: email is marked @isboolean but typed string.
Use @isemail (and import it) to avoid invalid validation and inaccurate OpenAPI docs.
Apply:
-import { IsBoolean, IsInt, IsObject, IsOptional, IsString, ValidateNested } from "class-validator";
+import { IsBoolean, IsEmail, IsInt, IsObject, IsOptional, IsString, ValidateNested } from "class-validator";- @IsBoolean()
+ @IsEmail()
@Expose()
- @ApiProperty()
+ @ApiProperty({ format: "email" })
readonly email!: string;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| import { IsBoolean, IsInt, IsObject, IsOptional, IsString, ValidateNested } from "class-validator"; | |
| // apps/api/v2/src/modules/teams/memberships/outputs/team-membership.output.ts | |
| import { IsBoolean, IsEmail, IsInt, IsObject, IsOptional, IsString, ValidateNested } from "class-validator"; | |
| export class TeamMembershipOutput { | |
| // … | |
| @IsEmail() | |
| @Expose() | |
| @ApiProperty({ format: "email" }) | |
| readonly email!: string; | |
| // … | |
| } |
🤖 Prompt for AI Agents
In apps/api/v2/src/modules/teams/memberships/outputs/team-membership.output.ts
around line 3, the email property is incorrectly validated with @IsBoolean while
its type is string; replace @IsBoolean with @IsEmail and add IsEmail to the
import list from "class-validator" so validation and generated OpenAPI docs
correctly treat the field as an email address.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
E2E results are ready! |
What does this PR do?
Updates @calcom/prisma/enums paths to @calcom/platform-libraries for prisma enums