Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
*/
Comment on lines +255 to +257

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's use the deprecate utility function inside the method as well. That way devs using that function can see warnings at runtime

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added!

public async getPendingOrganizationInvitationList(params: GetPendingOrganizationInvitationListParams) {
deprecated('getPendingOrganizationInvitationList', 'Use `getOrganizationInvitationList` instead.');

const { organizationId, limit, offset } = params;
this.requireId(organizationId);

Expand Down