From d5279c51680ec4e0a39027a019f6be407fe06ac3 Mon Sep 17 00:00:00 2001 From: Haris Chaniotakis Date: Thu, 28 Sep 2023 18:07:16 +0300 Subject: [PATCH] feat(backend): Introduce a new getOrganizationInvitationList() method Introduce a new getOrganizationInvitationList() method on the Organization resource, which you can use in order to list the invitations. The new method supports filtering by status and also the default paginated parameters, limit and offset We also mark as deprecated the old getPendingOrganizationInvitationList, which was used to only list the pending organization invitations --- .changeset/thick-rings-complain.md | 5 +++ .../src/api/endpoints/OrganizationApi.ts | 31 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .changeset/thick-rings-complain.md diff --git a/.changeset/thick-rings-complain.md b/.changeset/thick-rings-complain.md new file mode 100644 index 00000000000..8e396729859 --- /dev/null +++ b/.changeset/thick-rings-complain.md @@ -0,0 +1,5 @@ +--- +'@clerk/backend': minor +--- + +Introduce a new getOrganizationInvitationList() method, along with support for filtering by status and the regular limit & offset parameters, which it can be used in order to list the invitations of a specific organization. We also marked the old getPendingOrganizationInvitationList() method as deprecated diff --git a/packages/backend/src/api/endpoints/OrganizationApi.ts b/packages/backend/src/api/endpoints/OrganizationApi.ts index 906bb35a973..5113fa3a638 100644 --- a/packages/backend/src/api/endpoints/OrganizationApi.ts +++ b/packages/backend/src/api/endpoints/OrganizationApi.ts @@ -1,8 +1,14 @@ import runtime from '../../runtime'; import { joinPaths } from '../../util/path'; -import type { Organization, OrganizationInvitation, OrganizationMembership } from '../resources'; +import type { + Organization, + OrganizationInvitation, + OrganizationInvitationStatus, + OrganizationMembership, +} from '../resources'; import type { OrganizationMembershipRole } from '../resources/Enums'; import { AbstractAPI } from './AbstractApi'; +import { deprecated } from '@clerk/shared'; const basePath = '/organizations'; @@ -74,6 +80,13 @@ type CreateOrganizationInvitationParams = { publicMetadata?: OrganizationInvitationPublicMetadata; }; +type GetOrganizationInvitationListParams = { + organizationId: string; + status?: OrganizationInvitationStatus[]; + limit?: number; + offset?: number; +}; + type GetPendingOrganizationInvitationListParams = { organizationId: string; limit?: number; @@ -228,7 +241,23 @@ export class OrganizationAPI extends AbstractAPI { }); } + public async getOrganizationInvitationList(params: GetOrganizationInvitationListParams) { + const { organizationId, status, limit, offset } = params; + this.requireId(organizationId); + + return this.request({ + method: 'GET', + path: joinPaths(basePath, organizationId, 'invitations'), + queryParams: { status, limit, offset }, + }); + } + + /** + * @deprecated Use `getOrganizationInvitationList` instead along with the status parameter. + */ public async getPendingOrganizationInvitationList(params: GetPendingOrganizationInvitationListParams) { + deprecated('getPendingOrganizationInvitationList', 'Use `getOrganizationInvitationList` instead.'); + const { organizationId, limit, offset } = params; this.requireId(organizationId);