Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: V2 Org Memberships #15578

Merged
merged 22 commits into from
Jul 18, 2024
Merged

feat: V2 Org Memberships #15578

merged 22 commits into from
Jul 18, 2024

Conversation

alishaz-polymath
Copy link
Member

@alishaz-polymath alishaz-polymath commented Jun 26, 2024

What does this PR do?

/organizations/:orgId/membership - isOrganizationGuard

GET - RolesGuard (ADMIN) - Get all memberships within the organization
POST - RolesGuard (ADMIN) - Create a membership within the organization

/organizations/:orgId/membership/:membershipId - isOrganizationGuard

GET - RolesGuard (ADMIN) - Get a membership within the organization
PATCH - RolesGuard (ADMIN) - Can only patch a membership that is part of the organization
DELETE - RolesGuard (ADMIN) - Can only delete a membership already part of the organization

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected)
  • N/A - docs are auto generated, I have added a Docs issue here if this PR makes changes that would require a documentation change
  • I have added or modified automated tests that prove my fix is effective or that my feature works (PRs might be rejected if logical changes are not properly tested)

How should this be tested?

yarn test:e2e organizations-membership.controller.e2e-spec.ts

Copy link

vercel bot commented Jun 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ai ❌ Failed (Inspect) Jul 18, 2024 3:27am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Jul 18, 2024 3:27am
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Jul 18, 2024 3:27am

@alishaz-polymath alishaz-polymath marked this pull request as ready for review July 2, 2024 12:47
@dosubot dosubot bot added api area: API, enterprise API, access token, OAuth organizations area: organizations, orgs platform Anything related to our platform plan ✨ feature New feature or request labels Jul 2, 2024
@graphite-app graphite-app bot requested a review from a team July 2, 2024 12:47
@Roles("ORG_ADMIN")
@UseGuards(IsMembershipInOrg)
@Delete("/:membershipId")
@HttpCode(HttpStatus.OK)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when returning 200, we should return the deleted entity

if we don't want to return content use HttpStatus.NO_CONTENT

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About the status codes, wouldn't it make sense to return 204 for deleted intead of 200?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also 201 for Create

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

204 is returned by using HttpStatus.NO_CONTENT yes

Copy link
Contributor

@ThyMinimalDev ThyMinimalDev Jul 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also 201 for Create

yes indeed, let's start using HttpStatus.CREATED for that (nest.js by default will return 201 on POST)

async updateMembership(
@Param("orgId", ParseIntPipe) orgId: number,
@Param("membershipId", ParseIntPipe) membershipId: number,
@Body() body: CreateOrgMembershipDto
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be able to partially update membership

@Body() body: Partial<CreateOrgMembershipDto>

@Param("orgId", ParseIntPipe) orgId: number,
@Param("membershipId", ParseIntPipe) membershipId: number
): Promise<GetOrgMembership> {
const membership = await this.organizationsMembershipService.getOrgMembership(orgId, membershipId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the guard IsMembershipInOrg is already populating the request with the correct membership, use the decorator @GetMembership instead

@Get("/:membershipId")
async getUserSchedule(
@Param("orgId", ParseIntPipe) orgId: number,
@Param("membershipId", ParseIntPipe) membershipId: number
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GetMembership() membership: Membership

ThyMinimalDev
ThyMinimalDev previously approved these changes Jul 17, 2024
Copy link
Contributor

@ThyMinimalDev ThyMinimalDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, followup pr for memberships of teams within an org

Copy link
Contributor

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

Eighty-seven Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (350 KB)
/apps 276.73 KB 504.36 KB 144.10% (🟢 -2.13%)
/apps/[slug] 294.29 KB 521.92 KB 149.12% (🟢 -2.14%)
/apps/[slug]/[...pages] 586.55 KB 814.18 KB 232.62% (🟢 -1.74%)
/apps/categories 254.06 KB 481.69 KB 137.63% (🟢 -1.86%)
/apps/categories/[category] 258.85 KB 486.48 KB 138.99% (🟢 -2.12%)
/apps/installation/[[...step]] 466.72 KB 694.35 KB 198.39% (🔴 +85.44%)
/apps/installed/[category] 277.97 KB 505.6 KB 144.46% (🟢 -1.90%)
/auth/saml-idp 12.22 KB 239.85 KB 68.53% (🟢 -20.80%)
/availability 426.39 KB 654.02 KB 186.86% (🟢 -1.72%)
/availability/[schedule] 410.26 KB 637.89 KB 182.25% (🟢 -1.73%)
/bookings/[status] 324.05 KB 551.68 KB 157.62% (🟢 -1.75%)
/enterprise 254.12 KB 481.74 KB 137.64% (🟢 -1.85%)
/event-types 559.21 KB 786.84 KB 224.81% (🟢 -1.76%)
/event-types/[type] 435.58 KB 663.2 KB 189.49% (🟢 -1.70%)
/getting-started/[[...step]] 447.98 KB 675.61 KB 193.03% (🟡 +10.68%)
/insights 474.06 KB 701.69 KB 200.48% (🟢 -1.85%)
/more 253.62 KB 481.25 KB 137.50% (🟢 -1.85%)
/org/[orgSlug] 265.76 KB 493.39 KB 140.97% (🟢 -0.17%)
/org/[orgSlug]/[user] 271.88 KB 499.5 KB 142.72% (🟢 -0.18%)
/org/[orgSlug]/[user]/embed 271.9 KB 499.53 KB 142.72% (🟢 -0.17%)
/org/[orgSlug]/embed 265.78 KB 493.41 KB 140.97% (🟢 -0.17%)
/org/[orgSlug]/team/[slug] 265.77 KB 493.39 KB 140.97% (🟢 -0.17%)
/settings/admin 260.09 KB 487.72 KB 139.35% (🟢 -1.83%)
/settings/admin/apps 273.46 KB 501.08 KB 143.17% (🟢 -1.82%)
/settings/admin/apps/[category] 273.44 KB 501.07 KB 143.16% (🟢 -1.82%)
/settings/admin/flags 263.92 KB 491.55 KB 140.44% (🟢 -1.83%)
/settings/admin/impersonation 260.48 KB 488.11 KB 139.46% (🟢 -1.83%)
/settings/admin/lockedSMS 281.58 KB 509.2 KB 145.49% (🟢 -1.80%)
/settings/admin/oAuth 272.2 KB 499.83 KB 142.81% (🟢 -1.82%)
/settings/admin/orgMigrations/_OrgMigrationLayout 249.02 KB 476.65 KB 136.18% (🟢 -1.82%)
/settings/admin/orgMigrations/moveTeamToOrg 298.78 KB 526.4 KB 150.40% (🟢 -1.81%)
/settings/admin/orgMigrations/moveUserToOrg 318.61 KB 546.23 KB 156.07% (🟢 -1.78%)
/settings/admin/orgMigrations/removeTeamFromOrg 298.54 KB 526.17 KB 150.33% (🟢 -1.80%)
/settings/admin/orgMigrations/removeUserFromOrg 298.55 KB 526.18 KB 150.34% (🟢 -1.81%)
/settings/admin/organizations 261.98 KB 489.6 KB 139.89% (🟢 -1.83%)
/settings/admin/organizations/[id]/edit 260.64 KB 488.27 KB 139.50% (🟢 -1.83%)
/settings/admin/users 262.75 KB 490.37 KB 140.11% (🟢 -1.83%)
/settings/admin/users/[id]/edit 391.93 KB 619.56 KB 177.02% (🟢 -1.80%)
/settings/admin/users/add 391.6 KB 619.23 KB 176.92% (🟢 -1.79%)
/settings/billing 260.3 KB 487.92 KB 139.41% (🟢 -1.83%)
/settings/developer/api-keys 264.69 KB 492.32 KB 140.66% (🟢 -1.83%)
/settings/developer/webhooks 264.86 KB 492.49 KB 140.71% (🟢 -1.83%)
/settings/developer/webhooks/[id] 265.84 KB 493.47 KB 140.99% (🟢 -1.81%)
/settings/developer/webhooks/new 265.87 KB 493.5 KB 141.00% (🟢 -1.81%)
/settings/my-account/appearance 313.29 KB 540.92 KB 154.55% (🟢 -1.83%)
/settings/my-account/calendars 271.69 KB 499.32 KB 142.66% (🟢 -1.87%)
/settings/my-account/conferencing 272.6 KB 500.23 KB 142.92% (🟢 -1.87%)
/settings/my-account/general 375.79 KB 603.42 KB 172.41% (🟢 -1.83%)
/settings/my-account/out-of-office 265.32 KB 492.95 KB 140.84% (🟢 -1.83%)
/settings/my-account/profile 408.23 KB 635.86 KB 181.67% (🟢 -1.82%)
/settings/organizations/[id]/about 159.66 KB 387.29 KB 110.65% (🟡 +0.47%)
/settings/organizations/[id]/add-teams 159.65 KB 387.28 KB 110.65% (🟡 +0.47%)
/settings/organizations/admin-api 260.25 KB 487.88 KB 139.39% (🟢 -1.83%)
/settings/organizations/appearance 122.33 KB 349.96 KB 99.99% (🟢 -48.03%)
/settings/organizations/billing 260.33 KB 487.96 KB 139.42% (🟢 -1.83%)
/settings/organizations/dsync 292.95 KB 520.58 KB 148.74% (🟢 -1.83%)
/settings/organizations/general 348.64 KB 576.27 KB 164.65% (🟢 -1.82%)
/settings/organizations/members 399.82 KB 627.44 KB 179.27% (🟢 -1.82%)
/settings/organizations/new 159.66 KB 387.29 KB 110.65% (🟡 +0.48%)
/settings/organizations/privacy 265.85 KB 493.48 KB 140.99% (🟢 -1.83%)
/settings/organizations/profile 413.11 KB 640.74 KB 183.07% (🟡 +1.71%)
/settings/organizations/sso 270.92 KB 498.55 KB 142.44% (🟢 -1.83%)
/settings/organizations/teams/other 261.16 KB 488.79 KB 139.65% (🟢 -1.83%)
/settings/organizations/teams/other/[id]/appearance 273.06 KB 500.69 KB 143.05% (🟢 -1.78%)
/settings/organizations/teams/other/[id]/members 267.76 KB 495.39 KB 141.54% (🟢 -1.83%)
/settings/organizations/teams/other/[id]/profile 470.55 KB 698.18 KB 199.48% (🟢 -2.09%)
/settings/platform 258.72 KB 486.35 KB 138.96% (🟢 -1.85%)
/settings/platform/new 120.67 KB 348.3 KB 99.51% (🟡 +0.51%)
/settings/platform/oauth-clients/[clientId]/edit 257.03 KB 484.66 KB 138.47% (🟢 -1.85%)
/settings/platform/oauth-clients/create 256.17 KB 483.8 KB 138.23% (🟢 -1.85%)
/settings/security/impersonation 265.5 KB 493.13 KB 140.89% (🟢 -1.83%)
/settings/security/password 303.67 KB 531.3 KB 151.80% (🟢 -1.81%)
/settings/security/sso 270.37 KB 498 KB 142.29% (🟢 -1.83%)
/settings/security/two-factor-auth 268.98 KB 496.61 KB 141.89% (🟢 -1.83%)
/settings/teams 259.83 KB 487.46 KB 139.27% (🟢 -1.83%)
/settings/teams/[id]/appearance 273.05 KB 500.68 KB 143.05% (🟢 -1.78%)
/settings/teams/[id]/billing 260.33 KB 487.96 KB 139.42% (🟢 -1.83%)
/settings/teams/[id]/members 377.88 KB 605.51 KB 173.00% (🟢 -1.82%)
/settings/teams/[id]/profile 471.34 KB 698.96 KB 199.70% (🟢 -2.08%)
/settings/teams/new 193 KB 420.63 KB 120.18% (🟢 -1.83%)
/team/[slug] 265.69 KB 493.32 KB 140.95% (🟢 -0.17%)
/team/[slug]/embed 265.76 KB 493.39 KB 140.97% (🟢 -0.17%)
/teams 253.85 KB 481.48 KB 137.57% (🟢 -1.86%)
/upgrade 253.97 KB 481.6 KB 137.60% (🟢 -1.85%)
/video/[uid] 290.26 KB 517.89 KB 147.97% (🟢 -0.44%)
/workflows 285.87 KB 513.5 KB 146.71% (🟢 -1.79%)
/workflows/[workflow] 414.14 KB 641.77 KB 183.36% (🟢 -1.57%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.

@ThyMinimalDev ThyMinimalDev merged commit 22fc47f into main Jul 18, 2024
35 of 37 checks passed
@ThyMinimalDev ThyMinimalDev deleted the feat/api-v2-org-memberships branch July 18, 2024 03:43
p6l-richard pushed a commit to p6l-richard/cal.com-fork that referenced this pull request Jul 22, 2024
* init

* --WIP

* WIP

* ...

* more wip

* doc

* address feedback --WIP

* further requested changes

* fix

* add missing parseIntPipe

* chore: code review comments + e2e tests

* fixup! chore: code review comments + e2e tests

* fixup! fixup! chore: code review comments + e2e tests

* fix: don't allow passing teamId for org membership create/update

* fix: improve docs and DTOs

---------

Co-authored-by: Morgan Vernay <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api area: API, enterprise API, access token, OAuth core area: core, team members only ✨ feature New feature or request organizations area: organizations, orgs platform Anything related to our platform plan ready-for-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants