Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(backend): organization_domain webhook event types #4819

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/plenty-boxes-relax.md
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion packages/astro/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ export type {
// Resources
AllowlistIdentifier,
Client,
OrganizationMembership,
EmailAddress,
ExternalAccount,
Invitation,
OauthAccessToken,
Organization,
OrganizationDomain,
OrganizationInvitation,
OrganizationMembership,
OrganizationMembershipPublicUserData,
PhoneNumber,
Session,
Expand Down
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
5 changes: 4 additions & 1 deletion packages/backend/src/api/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ export * from './TestingToken';

export type {
EmailWebhookEvent,
OrganizationWebhookEvent,
OrganizationDomainWebhookEvent,
OrganizationInvitationWebhookEvent,
OrganizationMembershipWebhookEvent,
OrganizationWebhookEvent,
PermissionWebhookEvent,
RoleWebhookEvent,
SessionWebhookEvent,
SMSWebhookEvent,
UserWebhookEvent,
Expand Down
15 changes: 11 additions & 4 deletions packages/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export type {
InvitationJSON,
OauthAccessTokenJSON,
OrganizationJSON,
OrganizationDomainJSON,
OrganizationDomainVerificationJSON,
OrganizationInvitationJSON,
PublicOrganizationDataJSON,
OrganizationMembershipJSON,
Expand Down Expand Up @@ -96,6 +98,8 @@ export type {
Invitation,
OauthAccessToken,
Organization,
OrganizationDomain,
OrganizationDomainVerification,
OrganizationInvitation,
OrganizationMembership,
OrganizationMembershipPublicUserData,
Expand All @@ -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';
Expand Down
11 changes: 8 additions & 3 deletions packages/nextjs/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ export { clerkClient } from './clerkClient';
export type {
DeletedObjectJSON,
EmailJSON,
OrganizationInvitationJSON,
OrganizationJSON,
OrganizationDomainJSON,
OrganizationDomainVerificationJSON,
OrganizationInvitationJSON,
OrganizationMembershipJSON,
SessionJSON,
SMSMessageJSON,
Expand All @@ -22,11 +24,14 @@ export type {
WebhookEventType,
UserWebhookEvent,
EmailWebhookEvent,
SMSWebhookEvent,
SessionWebhookEvent,
OrganizationWebhookEvent,
OrganizationDomainWebhookEvent,
OrganizationMembershipWebhookEvent,
OrganizationInvitationWebhookEvent,
PermissionWebhookEvent,
RoleWebhookEvent,
SessionWebhookEvent,
SMSWebhookEvent,
} from '@clerk/backend';

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/react-router/src/ssr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ export type {
// Resources
AllowlistIdentifier,
Client,
OrganizationMembership,
EmailAddress,
ExternalAccount,
Invitation,
OauthAccessToken,
Organization,
OrganizationDomain,
OrganizationInvitation,
OrganizationMembership,
OrganizationMembershipPublicUserData,
PhoneNumber,
Session,
Expand Down
3 changes: 2 additions & 1 deletion packages/remix/src/ssr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ export type {
// Resources
AllowlistIdentifier,
Client,
OrganizationMembership,
EmailAddress,
ExternalAccount,
Invitation,
OauthAccessToken,
Organization,
OrganizationDomain,
OrganizationInvitation,
OrganizationMembership,
OrganizationMembershipPublicUserData,
PhoneNumber,
Session,
Expand Down
3 changes: 2 additions & 1 deletion packages/tanstack-start/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ export type {
// Resources
AllowlistIdentifier,
Client,
OrganizationMembership,
EmailAddress,
ExternalAccount,
Invitation,
OauthAccessToken,
Organization,
OrganizationDomain,
OrganizationInvitation,
OrganizationMembership,
OrganizationMembershipPublicUserData,
PhoneNumber,
Session,
Expand Down
Loading