diff --git a/.changeset/plenty-boxes-relax.md b/.changeset/plenty-boxes-relax.md new file mode 100644 index 0000000000..81d30ae6f3 --- /dev/null +++ b/.changeset/plenty-boxes-relax.md @@ -0,0 +1,10 @@ +--- +'@clerk/tanstack-start': patch +'@clerk/react-router': patch +'@clerk/backend': patch +'@clerk/nextjs': patch +'@clerk/astro': patch +'@clerk/remix': patch +--- + +Adds types for organization domain webhook events diff --git a/packages/astro/src/server/index.ts b/packages/astro/src/server/index.ts index fa5679c0f7..cef1456a20 100644 --- a/packages/astro/src/server/index.ts +++ b/packages/astro/src/server/index.ts @@ -14,13 +14,14 @@ export type { // Resources AllowlistIdentifier, Client, - OrganizationMembership, EmailAddress, ExternalAccount, Invitation, OauthAccessToken, Organization, + OrganizationDomain, OrganizationInvitation, + OrganizationMembership, OrganizationMembershipPublicUserData, PhoneNumber, Session, 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 diff --git a/packages/backend/src/api/resources/index.ts b/packages/backend/src/api/resources/index.ts index 20854c5644..c7e9a2711d 100644 --- a/packages/backend/src/api/resources/index.ts +++ b/packages/backend/src/api/resources/index.ts @@ -36,9 +36,12 @@ export * from './TestingToken'; export type { EmailWebhookEvent, + OrganizationWebhookEvent, + OrganizationDomainWebhookEvent, OrganizationInvitationWebhookEvent, OrganizationMembershipWebhookEvent, - OrganizationWebhookEvent, + PermissionWebhookEvent, + RoleWebhookEvent, SessionWebhookEvent, SMSWebhookEvent, UserWebhookEvent, diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts index 2a1659cbf7..f772e66bdc 100644 --- a/packages/backend/src/index.ts +++ b/packages/backend/src/index.ts @@ -65,6 +65,8 @@ export type { InvitationJSON, OauthAccessTokenJSON, OrganizationJSON, + OrganizationDomainJSON, + OrganizationDomainVerificationJSON, OrganizationInvitationJSON, PublicOrganizationDataJSON, OrganizationMembershipJSON, @@ -96,6 +98,8 @@ export type { Invitation, OauthAccessToken, Organization, + OrganizationDomain, + OrganizationDomainVerification, OrganizationInvitation, OrganizationMembership, OrganizationMembershipPublicUserData, @@ -112,13 +116,16 @@ export type { * Webhooks event types */ export type { - UserWebhookEvent, EmailWebhookEvent, - SMSWebhookEvent, - SessionWebhookEvent, OrganizationWebhookEvent, - OrganizationMembershipWebhookEvent, + OrganizationDomainWebhookEvent, OrganizationInvitationWebhookEvent, + OrganizationMembershipWebhookEvent, + RoleWebhookEvent, + PermissionWebhookEvent, + SessionWebhookEvent, + SMSWebhookEvent, + UserWebhookEvent, WebhookEvent, WebhookEventType, } from './api/resources/Webhooks'; diff --git a/packages/nextjs/src/server/index.ts b/packages/nextjs/src/server/index.ts index d1fd9b1192..33214d5f0e 100644 --- a/packages/nextjs/src/server/index.ts +++ b/packages/nextjs/src/server/index.ts @@ -12,8 +12,10 @@ export { clerkClient } from './clerkClient'; export type { DeletedObjectJSON, EmailJSON, - OrganizationInvitationJSON, OrganizationJSON, + OrganizationDomainJSON, + OrganizationDomainVerificationJSON, + OrganizationInvitationJSON, OrganizationMembershipJSON, SessionJSON, SMSMessageJSON, @@ -22,11 +24,14 @@ export type { WebhookEventType, UserWebhookEvent, EmailWebhookEvent, - SMSWebhookEvent, - SessionWebhookEvent, OrganizationWebhookEvent, + OrganizationDomainWebhookEvent, OrganizationMembershipWebhookEvent, OrganizationInvitationWebhookEvent, + PermissionWebhookEvent, + RoleWebhookEvent, + SessionWebhookEvent, + SMSWebhookEvent, } from '@clerk/backend'; /** diff --git a/packages/react-router/src/ssr/index.ts b/packages/react-router/src/ssr/index.ts index ab4d72778d..fcd02aa915 100644 --- a/packages/react-router/src/ssr/index.ts +++ b/packages/react-router/src/ssr/index.ts @@ -12,13 +12,14 @@ export type { // Resources AllowlistIdentifier, Client, - OrganizationMembership, EmailAddress, ExternalAccount, Invitation, OauthAccessToken, Organization, + OrganizationDomain, OrganizationInvitation, + OrganizationMembership, OrganizationMembershipPublicUserData, PhoneNumber, Session, diff --git a/packages/remix/src/ssr/index.ts b/packages/remix/src/ssr/index.ts index ab4d72778d..fcd02aa915 100644 --- a/packages/remix/src/ssr/index.ts +++ b/packages/remix/src/ssr/index.ts @@ -12,13 +12,14 @@ export type { // Resources AllowlistIdentifier, Client, - OrganizationMembership, EmailAddress, ExternalAccount, Invitation, OauthAccessToken, Organization, + OrganizationDomain, OrganizationInvitation, + OrganizationMembership, OrganizationMembershipPublicUserData, PhoneNumber, Session, diff --git a/packages/tanstack-start/src/server/index.ts b/packages/tanstack-start/src/server/index.ts index 05336c1438..4a56c1e5c1 100644 --- a/packages/tanstack-start/src/server/index.ts +++ b/packages/tanstack-start/src/server/index.ts @@ -14,13 +14,14 @@ export type { // Resources AllowlistIdentifier, Client, - OrganizationMembership, EmailAddress, ExternalAccount, Invitation, OauthAccessToken, Organization, + OrganizationDomain, OrganizationInvitation, + OrganizationMembership, OrganizationMembershipPublicUserData, PhoneNumber, Session,