forked from clerk/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebhooks.ts
More file actions
61 lines (49 loc) · 1.8 KB
/
Copy pathWebhooks.ts
File metadata and controls
61 lines (49 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import type {
DeletedObjectJSON,
EmailJSON,
OrganizationInvitationJSON,
OrganizationJSON,
OrganizationMembershipJSON,
PermissionJSON,
RoleJSON,
SessionJSON,
SMSMessageJSON,
UserJSON,
} from './JSON';
type Webhook<EvtType, Data> = { type: EvtType; object: 'event'; data: Data };
export type UserWebhookEvent =
| Webhook<'user.created' | 'user.updated', UserJSON>
| Webhook<'user.deleted', DeletedObjectJSON>;
export type EmailWebhookEvent = Webhook<'email.created', EmailJSON>;
export type SMSWebhookEvent = Webhook<'sms.created', SMSMessageJSON>;
export type SessionWebhookEvent = Webhook<
'session.created' | 'session.ended' | 'session.removed' | 'session.revoked',
SessionJSON
>;
export type OrganizationWebhookEvent =
| Webhook<'organization.created' | 'organization.updated', OrganizationJSON>
| Webhook<'organization.deleted', DeletedObjectJSON>;
export type OrganizationMembershipWebhookEvent = Webhook<
'organizationMembership.created' | 'organizationMembership.deleted' | 'organizationMembership.updated',
OrganizationMembershipJSON
>;
export type OrganizationInvitationWebhookEvent = Webhook<
'organizationInvitation.accepted' | 'organizationInvitation.created' | 'organizationInvitation.revoked',
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
| RoleWebhookEvent
| PermissionWebhookEvent;
export type WebhookEventType = WebhookEvent['type'];