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 2 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`

11 changes: 11 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,16 @@ export interface VerificationJSON extends ClerkResourceJSON {
message?: string | null;
}

export interface WaitlistEntryJSON extends ClerkResourceJSON {
created_at: number;
email_address: string;
id: string;
invitation: InvitationJSON | null;
object: typeof ObjectType.WaitlistEntry;
status: string;
updated_at: number;
}
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,
Thank you for the contribution 🤝

We should add also the is_locked: boolean property because we return the same resource as we have in the Backend API ref

Copy link
Author

Choose a reason for hiding this comment

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

Nice catch! Added is_locked. Was checking the webhook catalog and didn't double check the api.


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'];