perf: Add an explicit DTO + other type improvements to membership repo#22163
perf: Add an explicit DTO + other type improvements to membership repo#22163
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
|
✅ No security or compliance issues detected. Reviewed everything up to a89a1a1. Security Overview
Detected Code Changes
Reply to this PR with |
Graphite Automations"Add foundation team as reviewer" took an action on this PR • (06/30/25)1 reviewer was added to this PR based on Keith Williams's automation. |
There was a problem hiding this comment.
cubic found 1 issue across 1 file. Review it in cubic.dev
React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.
| import { availabilityUserSelect, prisma, type PrismaTransaction, type PrismaClient } from "@calcom/prisma"; | ||
| import { MembershipRole } from "@calcom/prisma/client"; | ||
| import { Prisma } from "@calcom/prisma/client"; | ||
| import type { Prisma, Membership } from "@calcom/prisma/client"; |
There was a problem hiding this comment.
Now type only (through satisfies)
| }); | ||
| // this is explicit, and typed in TSelect default typings | ||
| select: select ?? { userId: true }, | ||
| })) as unknown as Promise<MembershipDTOFromSelect<TSelect>[]>; |
There was a problem hiding this comment.
Unfortunately there is no way to tell prisma.membership.findMany it will be compatible based on the given select (not enough overlap with the inferred types); however, we don't need that as we have direct control over the input and output and it is inferred based on the Prisma generated types.
E2E results are ready! |
hbjORbj
left a comment
There was a problem hiding this comment.
Love the changes. Let's get this in
| const teamParentSelect = Prisma.validator<Prisma.TeamSelect>()({ | ||
| type MembershipSelectableKeys = keyof typeof membershipSelect; | ||
|
|
||
| type MembershipPartialSelect = Partial<Record<MembershipSelectableKeys, boolean>>; |
eunjae-lee
left a comment
There was a problem hiding this comment.
Thanks for tagging me. The changes look very good.
|
This PR is being marked as stale due to inactivity. |
WalkthroughThe changes refactor TypeScript type usage and query construction in the Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
packages/lib/server/repository/membership.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-playwright". (The package "eslint-plugin-playwright" was not found when loaded as a Node module from the directory "".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following: The plugin "eslint-plugin-playwright" was referenced from the config file in ".eslintrc.js". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (1)packages/lib/server/repository/membership.ts (1)🔇 Additional comments (6)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
#22163) * perf: Add an explicit DTO + some other type improvements to membership repo * Bring back default to userId=true
What does this PR do?
Added an explicit Membership DTO and improved type safety in the membership repository to prevent TypeScript performance issues.
Fixes deployment issue introduced in #22057