Skip to content

Commit

Permalink
feat(backend): Introduce a new getOrganizationInvitationList() method
Browse files Browse the repository at this point in the history
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
  • Loading branch information
chanioxaris committed Sep 29, 2023
1 parent 14825b9 commit 94c36c7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/thick-rings-complain.md
Original file line number Diff line number Diff line change
@@ -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
31 changes: 30 additions & 1 deletion packages/backend/src/api/endpoints/OrganizationApi.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -74,6 +80,13 @@ type CreateOrganizationInvitationParams = {
publicMetadata?: OrganizationInvitationPublicMetadata;
};

type GetOrganizationInvitationListParams = {
organizationId: string;
status?: OrganizationInvitationStatus[];
limit?: number;
offset?: number;
};

type GetPendingOrganizationInvitationListParams = {
organizationId: string;
limit?: number;
Expand Down Expand Up @@ -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<OrganizationInvitation[]>({
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);

Expand Down

0 comments on commit 94c36c7

Please sign in to comment.