Skip to content

Commit c0f2dae

Browse files
ijxyalexcarpenterpanteliselef
authored
feat(backend): organization_domain webhook event types (#4819)
Co-authored-by: Alex Carpenter <im.alexcarpenter@gmail.com> Co-authored-by: panteliselef <panteliselef@outlook.com>
1 parent 5faa60e commit c0f2dae

File tree

13 files changed

+81
-17
lines changed

13 files changed

+81
-17
lines changed

.changeset/plenty-boxes-relax.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@clerk/tanstack-start': patch
3+
'@clerk/react-router': patch
4+
'@clerk/backend': patch
5+
'@clerk/nextjs': patch
6+
'@clerk/astro': patch
7+
'@clerk/remix': patch
8+
---
9+
10+
Adds types for organization domain webhook events

packages/astro/src/server/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ export type {
1414
// Resources
1515
AllowlistIdentifier,
1616
Client,
17-
OrganizationMembership,
1817
EmailAddress,
1918
ExternalAccount,
2019
Invitation,
2120
OauthAccessToken,
2221
Organization,
22+
OrganizationDomain,
2323
OrganizationInvitation,
24+
OrganizationMembership,
2425
OrganizationMembershipPublicUserData,
2526
PhoneNumber,
2627
Session,

packages/backend/src/api/resources/Enums.ts

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ export type OAuthStrategy = `oauth_${OAuthProvider}`;
2323

2424
export type OrganizationInvitationStatus = 'pending' | 'accepted' | 'revoked';
2525

26+
export type OrganizationDomainVerificationStatus = 'unverified' | 'verified';
27+
28+
export type OrganizationDomainVerificationStrategy = 'email_code'; // only available value for now
29+
30+
export type OrganizationEnrollmentMode = 'manual_invitation' | 'automatic_invitation' | 'automatic_suggestion';
31+
2632
export type OrganizationMembershipRole = OrganizationCustomRoleKey;
2733

2834
export type SignInStatus = 'needs_identifier' | 'needs_factor_one' | 'needs_factor_two' | 'complete';

packages/backend/src/api/resources/JSON.ts

+25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import type {
22
InvitationStatus,
3+
OrganizationDomainVerificationStatus,
4+
OrganizationDomainVerificationStrategy,
5+
OrganizationEnrollmentMode,
36
OrganizationInvitationStatus,
47
OrganizationMembershipRole,
58
SignInStatus,
@@ -19,6 +22,7 @@ export const ObjectType = {
1922
Invitation: 'invitation',
2023
OauthAccessToken: 'oauth_access_token',
2124
Organization: 'organization',
25+
OrganizationDomain: 'organization_domain',
2226
OrganizationInvitation: 'organization_invitation',
2327
OrganizationMembership: 'organization_membership',
2428
PhoneNumber: 'phone_number',
@@ -177,6 +181,27 @@ export interface OrganizationJSON extends ClerkResourceJSON {
177181
updated_at: number;
178182
}
179183

184+
export interface OrganizationDomainJSON extends ClerkResourceJSON {
185+
object: typeof ObjectType.OrganizationDomain;
186+
id: string;
187+
name: string;
188+
organization_id: string;
189+
enrollment_mode: OrganizationEnrollmentMode;
190+
verification: OrganizationDomainVerificationJSON | null;
191+
affiliation_email_address: string | null;
192+
created_at: number;
193+
updated_at: number;
194+
total_pending_invitations: number;
195+
total_pending_suggestions: number;
196+
}
197+
198+
export interface OrganizationDomainVerificationJSON {
199+
status: OrganizationDomainVerificationStatus;
200+
strategy: OrganizationDomainVerificationStrategy;
201+
attempts: number;
202+
expires_at: number;
203+
}
204+
180205
export interface OrganizationInvitationJSON extends ClerkResourceJSON {
181206
email_address: string;
182207
role: OrganizationMembershipRole;

packages/backend/src/api/resources/OrganizationDomain.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { OrganizationDomainJSON, OrganizationEnrollmentMode } from '@clerk/types';
2-
1+
import type { OrganizationEnrollmentMode } from './Enums';
2+
import type { OrganizationDomainJSON } from './JSON';
33
import { OrganizationDomainVerification } from './Verification';
44

55
export class OrganizationDomain {

packages/backend/src/api/resources/Verification.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import type { OrganizationDomainVerificationJSON } from '@clerk/types';
2-
3-
import type { VerificationJSON } from './JSON';
1+
import type { OrganizationDomainVerificationJSON, VerificationJSON } from './JSON';
42

53
export class Verification {
64
constructor(

packages/backend/src/api/resources/Webhooks.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type {
22
DeletedObjectJSON,
33
EmailJSON,
4+
OrganizationDomainJSON,
45
OrganizationInvitationJSON,
56
OrganizationJSON,
67
OrganizationMembershipJSON,
@@ -30,6 +31,10 @@ export type OrganizationWebhookEvent =
3031
| Webhook<'organization.created' | 'organization.updated', OrganizationJSON>
3132
| Webhook<'organization.deleted', DeletedObjectJSON>;
3233

34+
export type OrganizationDomainWebhookEvent =
35+
| Webhook<'organizationDomain.created' | 'organizationDomain.updated', OrganizationDomainJSON>
36+
| Webhook<'organizationDomain.deleted', DeletedObjectJSON>;
37+
3338
export type OrganizationMembershipWebhookEvent = Webhook<
3439
'organizationMembership.created' | 'organizationMembership.deleted' | 'organizationMembership.updated',
3540
OrganizationMembershipJSON
@@ -53,6 +58,7 @@ export type WebhookEvent =
5358
| EmailWebhookEvent
5459
| SMSWebhookEvent
5560
| OrganizationWebhookEvent
61+
| OrganizationDomainWebhookEvent
5662
| OrganizationMembershipWebhookEvent
5763
| OrganizationInvitationWebhookEvent
5864
| RoleWebhookEvent

packages/backend/src/api/resources/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ export * from './TestingToken';
3737

3838
export type {
3939
EmailWebhookEvent,
40+
OrganizationWebhookEvent,
41+
OrganizationDomainWebhookEvent,
4042
OrganizationInvitationWebhookEvent,
4143
OrganizationMembershipWebhookEvent,
42-
OrganizationWebhookEvent,
44+
PermissionWebhookEvent,
45+
RoleWebhookEvent,
4346
SessionWebhookEvent,
4447
SMSWebhookEvent,
4548
UserWebhookEvent,

packages/backend/src/index.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ export type {
6565
InvitationJSON,
6666
OauthAccessTokenJSON,
6767
OrganizationJSON,
68+
OrganizationDomainJSON,
69+
OrganizationDomainVerificationJSON,
6870
OrganizationInvitationJSON,
6971
PublicOrganizationDataJSON,
7072
OrganizationMembershipJSON,
@@ -96,6 +98,8 @@ export type {
9698
Invitation,
9799
OauthAccessToken,
98100
Organization,
101+
OrganizationDomain,
102+
OrganizationDomainVerification,
99103
OrganizationInvitation,
100104
OrganizationMembership,
101105
OrganizationMembershipPublicUserData,
@@ -112,13 +116,16 @@ export type {
112116
* Webhooks event types
113117
*/
114118
export type {
115-
UserWebhookEvent,
116119
EmailWebhookEvent,
117-
SMSWebhookEvent,
118-
SessionWebhookEvent,
119120
OrganizationWebhookEvent,
120-
OrganizationMembershipWebhookEvent,
121+
OrganizationDomainWebhookEvent,
121122
OrganizationInvitationWebhookEvent,
123+
OrganizationMembershipWebhookEvent,
124+
RoleWebhookEvent,
125+
PermissionWebhookEvent,
126+
SessionWebhookEvent,
127+
SMSWebhookEvent,
128+
UserWebhookEvent,
122129
WebhookEvent,
123130
WebhookEventType,
124131
} from './api/resources/Webhooks';

packages/nextjs/src/server/index.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ export { clerkClient } from './clerkClient';
1212
export type {
1313
DeletedObjectJSON,
1414
EmailJSON,
15-
OrganizationInvitationJSON,
1615
OrganizationJSON,
16+
OrganizationDomainJSON,
17+
OrganizationDomainVerificationJSON,
18+
OrganizationInvitationJSON,
1719
OrganizationMembershipJSON,
1820
SessionJSON,
1921
SMSMessageJSON,
@@ -22,11 +24,14 @@ export type {
2224
WebhookEventType,
2325
UserWebhookEvent,
2426
EmailWebhookEvent,
25-
SMSWebhookEvent,
26-
SessionWebhookEvent,
2727
OrganizationWebhookEvent,
28+
OrganizationDomainWebhookEvent,
2829
OrganizationMembershipWebhookEvent,
2930
OrganizationInvitationWebhookEvent,
31+
PermissionWebhookEvent,
32+
RoleWebhookEvent,
33+
SessionWebhookEvent,
34+
SMSWebhookEvent,
3035
} from '@clerk/backend';
3136

3237
/**

packages/react-router/src/ssr/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ export type {
1212
// Resources
1313
AllowlistIdentifier,
1414
Client,
15-
OrganizationMembership,
1615
EmailAddress,
1716
ExternalAccount,
1817
Invitation,
1918
OauthAccessToken,
2019
Organization,
20+
OrganizationDomain,
2121
OrganizationInvitation,
22+
OrganizationMembership,
2223
OrganizationMembershipPublicUserData,
2324
PhoneNumber,
2425
Session,

packages/remix/src/ssr/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ export type {
1212
// Resources
1313
AllowlistIdentifier,
1414
Client,
15-
OrganizationMembership,
1615
EmailAddress,
1716
ExternalAccount,
1817
Invitation,
1918
OauthAccessToken,
2019
Organization,
20+
OrganizationDomain,
2121
OrganizationInvitation,
22+
OrganizationMembership,
2223
OrganizationMembershipPublicUserData,
2324
PhoneNumber,
2425
Session,

packages/tanstack-start/src/server/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ export type {
1414
// Resources
1515
AllowlistIdentifier,
1616
Client,
17-
OrganizationMembership,
1817
EmailAddress,
1918
ExternalAccount,
2019
Invitation,
2120
OauthAccessToken,
2221
Organization,
22+
OrganizationDomain,
2323
OrganizationInvitation,
24+
OrganizationMembership,
2425
OrganizationMembershipPublicUserData,
2526
PhoneNumber,
2627
Session,

0 commit comments

Comments
 (0)