File tree 9 files changed +100
-4
lines changed
9 files changed +100
-4
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @clerk/backend ' : patch
3
+ ---
4
+
5
+ Adds the ability to list and create waitlist entries to the Backend API client.
6
+
7
+
8
+ ``` ts
9
+ import { createClerkClient } from ' @clerk/backend' ;
10
+
11
+ const clerkClient = createClerkClient (... );
12
+
13
+ await clerkClient .waitlistEntries .list ({... });
14
+ await clerkClient .waitlistEntries .create ({
15
+ emailAddress:
' [email protected] ' ,
16
+ notify: true
17
+ });
18
+ ```
Original file line number Diff line number Diff line change
1
+ import type { ClerkPaginationRequest } from '@clerk/types' ;
2
+
3
+ import type { PaginatedResourceResponse } from '../resources/Deserializer' ;
4
+ import type { WaitlistEntryStatus } from '../resources/Enums' ;
5
+ import type { WaitlistEntry } from '../resources/WaitlistEntry' ;
6
+ import { AbstractAPI } from './AbstractApi' ;
7
+ import type { WithSign } from './util-types' ;
8
+
9
+ const basePath = '/waitlist_entries' ;
10
+
11
+ type WaitlistEntryListParams = ClerkPaginationRequest < {
12
+ /**
13
+ * Filter waitlist entries by `email_address` or `id`
14
+ */
15
+ query ?: string ;
16
+ status ?: WaitlistEntryStatus ;
17
+ orderBy ?: WithSign < 'created_at' | 'invited_at' | 'email_address' > ;
18
+ } > ;
19
+
20
+ type WaitlistEntryCreateParams = {
21
+ emailAddress : string ;
22
+ notify ?: boolean ;
23
+ } ;
24
+
25
+ export class WaitlistEntryAPI extends AbstractAPI {
26
+ public async list ( params : WaitlistEntryListParams = { } ) {
27
+ return this . request < PaginatedResourceResponse < WaitlistEntry > > ( {
28
+ method : 'GET' ,
29
+ path : basePath ,
30
+ queryParams : params ,
31
+ } ) ;
32
+ }
33
+
34
+ public async create ( params : WaitlistEntryCreateParams ) {
35
+ return this . request < WaitlistEntry > ( {
36
+ method : 'POST' ,
37
+ path : basePath ,
38
+ bodyParams : params ,
39
+ } ) ;
40
+ }
41
+ }
Original file line number Diff line number Diff line change @@ -20,4 +20,5 @@ export * from './SessionApi';
20
20
export * from './SignInTokenApi' ;
21
21
export * from './TestingTokenApi' ;
22
22
export * from './UserApi' ;
23
+ export * from './WaitlistEntryApi' ;
23
24
export * from './WebhookApi' ;
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import {
20
20
SignInTokenAPI ,
21
21
TestingTokenAPI ,
22
22
UserAPI ,
23
+ WaitlistEntryAPI ,
23
24
WebhookAPI ,
24
25
} from './endpoints' ;
25
26
import { buildRequest } from './request' ;
@@ -55,6 +56,7 @@ export function createBackendApiClient(options: CreateBackendApiOptions) {
55
56
signInTokens : new SignInTokenAPI ( request ) ,
56
57
testingTokens : new TestingTokenAPI ( request ) ,
57
58
users : new UserAPI ( request ) ,
59
+ waitlistEntries : new WaitlistEntryAPI ( request ) ,
58
60
webhooks : new WebhookAPI ( request ) ,
59
61
} ;
60
62
}
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ import {
31
31
import { AccountlessApplication } from './AccountlessApplication' ;
32
32
import type { PaginatedResponseJSON } from './JSON' ;
33
33
import { ObjectType } from './JSON' ;
34
+ import { WaitlistEntry } from './WaitlistEntry' ;
34
35
35
36
type ResourceResponse < T > = {
36
37
data : T ;
@@ -135,6 +136,8 @@ function jsonToObject(item: any): any {
135
136
return getCount ( item ) ;
136
137
case ObjectType . User :
137
138
return User . fromJSON ( item ) ;
139
+ case ObjectType . WaitlistEntry :
140
+ return WaitlistEntry . fromJSON ( item ) ;
138
141
default :
139
142
return item ;
140
143
}
Original file line number Diff line number Diff line change @@ -54,3 +54,5 @@ export type ActorTokenStatus = (typeof ActorTokenStatus)[keyof typeof ActorToken
54
54
export type AllowlistIdentifierType = 'email_address' | 'phone_number' | 'web3_wallet' ;
55
55
56
56
export type BlocklistIdentifierType = AllowlistIdentifierType ;
57
+
58
+ export type WaitlistEntryStatus = 'pending' | 'invited' | 'completed' | 'rejected' ;
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import type {
11
11
OrganizationMembershipRole ,
12
12
SignInStatus ,
13
13
SignUpStatus ,
14
+ WaitlistEntryStatus ,
14
15
} from './Enums' ;
15
16
16
17
export const ObjectType = {
@@ -543,13 +544,13 @@ export interface VerificationJSON extends ClerkResourceJSON {
543
544
}
544
545
545
546
export interface WaitlistEntryJSON extends ClerkResourceJSON {
546
- created_at : number ;
547
- email_address : string ;
547
+ object : typeof ObjectType . WaitlistEntry ;
548
548
id : string ;
549
+ status : WaitlistEntryStatus ;
550
+ email_address : string ;
549
551
invitation : InvitationJSON | null ;
550
552
is_locked : boolean ;
551
- object : typeof ObjectType . WaitlistEntry ;
552
- status : string ;
553
+ created_at : number ;
553
554
updated_at : number ;
554
555
}
555
556
Original file line number Diff line number Diff line change
1
+ import type { WaitlistEntryStatus } from './Enums' ;
2
+ import { Invitation } from './Invitation' ;
3
+ import type { WaitlistEntryJSON } from './JSON' ;
4
+
5
+ export class WaitlistEntry {
6
+ constructor (
7
+ readonly id : string ,
8
+ readonly emailAddress : string ,
9
+ readonly status : WaitlistEntryStatus ,
10
+ readonly invitation : Invitation | null ,
11
+ readonly createdAt : number ,
12
+ readonly updatedAt : number ,
13
+ readonly isLocked ?: boolean ,
14
+ ) { }
15
+
16
+ static fromJSON ( data : WaitlistEntryJSON ) : WaitlistEntry {
17
+ return new WaitlistEntry (
18
+ data . id ,
19
+ data . email_address ,
20
+ data . status ,
21
+ data . invitation && Invitation . fromJSON ( data . invitation ) ,
22
+ data . created_at ,
23
+ data . updated_at ,
24
+ data . is_locked ,
25
+ ) ;
26
+ }
27
+ }
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ export * from './User';
45
45
export * from './Verification' ;
46
46
export * from './SamlConnection' ;
47
47
export * from './TestingToken' ;
48
+ export * from './WaitlistEntry' ;
48
49
49
50
export type {
50
51
EmailWebhookEvent ,
You can’t perform that action at this time.
0 commit comments