Skip to content

Commit

Permalink
feat(backend): organization_domain webhook event types
Browse files Browse the repository at this point in the history
Adds the types for Organization Domain webhook events
  • Loading branch information
ijxy committed Dec 20, 2024
1 parent c6837d1 commit c45d6d7
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/plenty-boxes-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/backend': patch
---

Add and export Organization Domain webhook event types
6 changes: 6 additions & 0 deletions packages/backend/src/api/resources/Enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export type OAuthStrategy = `oauth_${OAuthProvider}`;

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

export type OrganizationDomainVerificationStatus = 'unverified' | 'verified';

export type OrganizationDomainVerificationStrategy = 'email_code'; // only available value for now

export type OrganizationEnrollmentMode = 'manual_invitation' | 'automatic_invitation' | 'automatic_suggestion';

export type OrganizationMembershipRole = OrganizationCustomRoleKey;

export type SignInStatus = 'needs_identifier' | 'needs_factor_one' | 'needs_factor_two' | 'complete';
Expand Down
25 changes: 25 additions & 0 deletions packages/backend/src/api/resources/JSON.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type {
InvitationStatus,
OrganizationDomainVerificationStatus,
OrganizationDomainVerificationStrategy,
OrganizationEnrollmentMode,
OrganizationInvitationStatus,
OrganizationMembershipRole,
SignInStatus,
Expand All @@ -18,6 +21,7 @@ export const ObjectType = {
Invitation: 'invitation',
OauthAccessToken: 'oauth_access_token',
Organization: 'organization',
OrganizationDomain: 'organization_domain',
OrganizationInvitation: 'organization_invitation',
OrganizationMembership: 'organization_membership',
PhoneNumber: 'phone_number',
Expand Down Expand Up @@ -171,6 +175,27 @@ export interface OrganizationJSON extends ClerkResourceJSON {
updated_at: number;
}

export interface OrganizationDomainJSON extends ClerkResourceJSON {
object: typeof ObjectType.OrganizationDomain;
id: string;
name: string;
organization_id: string;
enrollment_mode: OrganizationEnrollmentMode;
verification: OrganizationDomainVerificationJSON | null;
affiliation_email_address: string | null;
created_at: number;
updated_at: number;
total_pending_invitations: number;
total_pending_suggestions: number;
}

export interface OrganizationDomainVerificationJSON {
status: OrganizationDomainVerificationStatus;
strategy: OrganizationDomainVerificationStrategy;
attempts: number;
expires_at: number;
}

export interface OrganizationInvitationJSON extends ClerkResourceJSON {
email_address: string;
role: OrganizationMembershipRole;
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/api/resources/OrganizationDomain.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { OrganizationDomainJSON, OrganizationEnrollmentMode } from '@clerk/types';

import type { OrganizationEnrollmentMode } from './Enums';
import type { OrganizationDomainJSON } from './JSON';
import { OrganizationDomainVerification } from './Verification';

export class OrganizationDomain {
Expand Down
4 changes: 1 addition & 3 deletions packages/backend/src/api/resources/Verification.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type { OrganizationDomainVerificationJSON } from '@clerk/types';

import type { VerificationJSON } from './JSON';
import type { OrganizationDomainVerificationJSON, VerificationJSON } from './JSON';

export class Verification {
constructor(
Expand Down
6 changes: 6 additions & 0 deletions packages/backend/src/api/resources/Webhooks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {
DeletedObjectJSON,
EmailJSON,
OrganizationDomainJSON,
OrganizationInvitationJSON,
OrganizationJSON,
OrganizationMembershipJSON,
Expand Down Expand Up @@ -30,6 +31,10 @@ export type OrganizationWebhookEvent =
| Webhook<'organization.created' | 'organization.updated', OrganizationJSON>
| Webhook<'organization.deleted', DeletedObjectJSON>;

export type OrganizationDomainWebhookEvent =
| Webhook<'organizationDomain.created' | 'organizationDomain.updated', OrganizationDomainJSON>
| Webhook<'organizationDomain.deleted', DeletedObjectJSON>;

export type OrganizationMembershipWebhookEvent = Webhook<
'organizationMembership.created' | 'organizationMembership.deleted' | 'organizationMembership.updated',
OrganizationMembershipJSON
Expand All @@ -53,6 +58,7 @@ export type WebhookEvent =
| EmailWebhookEvent
| SMSWebhookEvent
| OrganizationWebhookEvent
| OrganizationDomainWebhookEvent
| OrganizationMembershipWebhookEvent
| OrganizationInvitationWebhookEvent
| RoleWebhookEvent
Expand Down

0 comments on commit c45d6d7

Please sign in to comment.