Skip to content

Commit

Permalink
chore(backend): Add webhook event types for roles and permissions (#4153
Browse files Browse the repository at this point in the history
)
  • Loading branch information
LauraBeatris authored Sep 11, 2024
1 parent ace56ba commit 8cecbe8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/mean-swans-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/backend": patch
---

Add webhook event types for roles and permissions
22 changes: 22 additions & 0 deletions packages/backend/src/api/resources/JSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export const ObjectType = {
Token: 'token',
TotalCount: 'total_count',
TestingToken: 'testing_token',
Role: 'role',
Permission: 'permission',
} as const;

export type ObjectType = (typeof ObjectType)[keyof typeof ObjectType];
Expand Down Expand Up @@ -377,3 +379,23 @@ export interface TestingTokenJSON {
token: string;
expires_at: number;
}

export interface RoleJSON extends ClerkResourceJSON {
object: typeof ObjectType.Role;
key: string;
name: string;
description: string;
permissions: PermissionJSON[];
is_creator_eligible: boolean;
created_at: number;
updated_at: number;
}

export interface PermissionJSON extends ClerkResourceJSON {
object: typeof ObjectType.Permission;
key: string;
name: string;
description: string;
created_at: number;
updated_at: number;
}
13 changes: 12 additions & 1 deletion packages/backend/src/api/resources/Webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import type {
OrganizationInvitationJSON,
OrganizationJSON,
OrganizationMembershipJSON,
PermissionJSON,
RoleJSON,
SessionJSON,
SMSMessageJSON,
UserJSON,
Expand Down Expand Up @@ -38,13 +40,22 @@ export type OrganizationInvitationWebhookEvent = Webhook<
OrganizationInvitationJSON
>;

export type RoleWebhookEvent = Webhook<'role.created' | 'role.updated' | 'role.deleted', RoleJSON>;

export type PermissionWebhookEvent = Webhook<
'permission.created' | 'permission.updated' | 'permission.deleted',
PermissionJSON
>;

export type WebhookEvent =
| UserWebhookEvent
| SessionWebhookEvent
| EmailWebhookEvent
| SMSWebhookEvent
| OrganizationWebhookEvent
| OrganizationMembershipWebhookEvent
| OrganizationInvitationWebhookEvent;
| OrganizationInvitationWebhookEvent
| RoleWebhookEvent
| PermissionWebhookEvent;

export type WebhookEventType = WebhookEvent['type'];

0 comments on commit 8cecbe8

Please sign in to comment.