From c45d6d7b5aaca7695ec8f697aa35897b869ae2b6 Mon Sep 17 00:00:00 2001 From: ijxy <32483798+ijxy@users.noreply.github.com> Date: Fri, 20 Dec 2024 00:15:28 +0000 Subject: [PATCH] feat(backend): organization_domain webhook event types Adds the types for Organization Domain webhook events --- .changeset/plenty-boxes-relax.md | 5 ++++ packages/backend/src/api/resources/Enums.ts | 6 +++++ packages/backend/src/api/resources/JSON.ts | 25 +++++++++++++++++++ .../src/api/resources/OrganizationDomain.ts | 4 +-- .../backend/src/api/resources/Verification.ts | 4 +-- .../backend/src/api/resources/Webhooks.ts | 6 +++++ 6 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 .changeset/plenty-boxes-relax.md diff --git a/.changeset/plenty-boxes-relax.md b/.changeset/plenty-boxes-relax.md new file mode 100644 index 0000000000..2368e9d569 --- /dev/null +++ b/.changeset/plenty-boxes-relax.md @@ -0,0 +1,5 @@ +--- +'@clerk/backend': patch +--- + +Add and export Organization Domain webhook event types diff --git a/packages/backend/src/api/resources/Enums.ts b/packages/backend/src/api/resources/Enums.ts index 320b3efd7b..f1eeb58016 100644 --- a/packages/backend/src/api/resources/Enums.ts +++ b/packages/backend/src/api/resources/Enums.ts @@ -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'; diff --git a/packages/backend/src/api/resources/JSON.ts b/packages/backend/src/api/resources/JSON.ts index 0c5c544ba6..3a1f4897fd 100644 --- a/packages/backend/src/api/resources/JSON.ts +++ b/packages/backend/src/api/resources/JSON.ts @@ -1,5 +1,8 @@ import type { InvitationStatus, + OrganizationDomainVerificationStatus, + OrganizationDomainVerificationStrategy, + OrganizationEnrollmentMode, OrganizationInvitationStatus, OrganizationMembershipRole, SignInStatus, @@ -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', @@ -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; diff --git a/packages/backend/src/api/resources/OrganizationDomain.ts b/packages/backend/src/api/resources/OrganizationDomain.ts index c9baddeee1..ee672a6926 100644 --- a/packages/backend/src/api/resources/OrganizationDomain.ts +++ b/packages/backend/src/api/resources/OrganizationDomain.ts @@ -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 { diff --git a/packages/backend/src/api/resources/Verification.ts b/packages/backend/src/api/resources/Verification.ts index 451556ecd2..a28d2eb010 100644 --- a/packages/backend/src/api/resources/Verification.ts +++ b/packages/backend/src/api/resources/Verification.ts @@ -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( diff --git a/packages/backend/src/api/resources/Webhooks.ts b/packages/backend/src/api/resources/Webhooks.ts index 6c2848a01d..ea0c0e6be9 100644 --- a/packages/backend/src/api/resources/Webhooks.ts +++ b/packages/backend/src/api/resources/Webhooks.ts @@ -1,6 +1,7 @@ import type { DeletedObjectJSON, EmailJSON, + OrganizationDomainJSON, OrganizationInvitationJSON, OrganizationJSON, OrganizationMembershipJSON, @@ -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 @@ -53,6 +58,7 @@ export type WebhookEvent = | EmailWebhookEvent | SMSWebhookEvent | OrganizationWebhookEvent + | OrganizationDomainWebhookEvent | OrganizationMembershipWebhookEvent | OrganizationInvitationWebhookEvent | RoleWebhookEvent