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

chore(backend): Added types to webhook json for waitlist entry #5148

Open
wants to merge 4 commits 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
5 changes: 5 additions & 0 deletions .changeset/green-starfishes-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/backend': patch
---

Added WaitlistEntryJSON and updated WebhookEvent to include WaitlistEntry
Copy link
Member

@panteliselef panteliselef Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Added WaitlistEntryJSON and updated WebhookEvent to include WaitlistEntry
Add waitlist entry types
- `WaitlistEntryJSON`
- `WaitlistEntryWebhookEvent`
Update `WebhookEvent` to include `WaitlistEntryWebhookEvent`

12 changes: 12 additions & 0 deletions packages/backend/src/api/resources/JSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const ObjectType = {
SignUpAttempt: 'sign_up_attempt',
SmsMessage: 'sms_message',
User: 'user',
WaitlistEntry: 'waitlist_entry',
Web3Wallet: 'web3_wallet',
Token: 'token',
TotalCount: 'total_count',
Expand Down Expand Up @@ -382,6 +383,17 @@ export interface VerificationJSON extends ClerkResourceJSON {
message?: string | null;
}

export interface WaitlistEntryJSON extends ClerkResourceJSON {
created_at: number;
email_address: string;
id: string;
invitation: InvitationJSON | null;
is_locked: boolean;
object: typeof ObjectType.WaitlistEntry;
status: string;
updated_at: number;
}

export interface Web3WalletJSON extends ClerkResourceJSON {
object: typeof ObjectType.Web3Wallet;
web3_wallet: string;
Expand Down
6 changes: 5 additions & 1 deletion packages/backend/src/api/resources/Webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
SessionJSON,
SMSMessageJSON,
UserJSON,
WaitlistEntryJSON,
} from './JSON';

type Webhook<EvtType, Data> = { type: EvtType; object: 'event'; data: Data };
Expand Down Expand Up @@ -52,6 +53,8 @@ export type PermissionWebhookEvent = Webhook<
PermissionJSON
>;

export type WaitlistEntryWebhookEvent = Webhook<'waitlistEntry.created' | 'waitlistEntry.updated', WaitlistEntryJSON>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @mackenzienolan,
can you include the WaitlistEntryWebhookEvent in the webhooks export we have in packages/backend/src/api/resources/index.ts? :)

export type {
  EmailWebhookEvent,
  OrganizationWebhookEvent,
  OrganizationDomainWebhookEvent,
  OrganizationInvitationWebhookEvent,
  OrganizationMembershipWebhookEvent,
  PermissionWebhookEvent,
  RoleWebhookEvent,
  SessionWebhookEvent,
  SMSWebhookEvent,
  UserWebhookEvent,
  WebhookEvent,
  WebhookEventType,
  WaitlistEntryWebhookEvent,
} from './Webhooks';


export type WebhookEvent =
| UserWebhookEvent
| SessionWebhookEvent
Expand All @@ -62,6 +65,7 @@ export type WebhookEvent =
| OrganizationMembershipWebhookEvent
| OrganizationInvitationWebhookEvent
| RoleWebhookEvent
| PermissionWebhookEvent;
| PermissionWebhookEvent
| WaitlistEntryWebhookEvent;

export type WebhookEventType = WebhookEvent['type'];