11import type { ClerkPaginationRequest } from '@clerk/types' ;
2+ import { joinPaths } from 'src/util/path' ;
23
4+ import type { DeletedObject } from '../resources/DeletedObject' ;
35import type { PaginatedResourceResponse } from '../resources/Deserializer' ;
46import type { WaitlistEntryStatus } from '../resources/Enums' ;
57import type { WaitlistEntry } from '../resources/WaitlistEntry' ;
@@ -22,7 +24,18 @@ type WaitlistEntryCreateParams = {
2224 notify ?: boolean ;
2325} ;
2426
27+ type WaitlistEntryInviteParams = {
28+ /**
29+ * When true, do not error if an invitation already exists. Default: false.
30+ */
31+ ignoreExisting ?: boolean ;
32+ } ;
33+
2534export class WaitlistEntryAPI extends AbstractAPI {
35+ /**
36+ * List waitlist entries.
37+ * @param params Optional parameters (e.g., `query`, `status`, `orderBy`).
38+ */
2639 public async list ( params : WaitlistEntryListParams = { } ) {
2740 return this . request < PaginatedResourceResponse < WaitlistEntry > > ( {
2841 method : 'GET' ,
@@ -31,11 +44,56 @@ export class WaitlistEntryAPI extends AbstractAPI {
3144 } ) ;
3245 }
3346
47+ /**
48+ * Create a waitlist entry.
49+ * @param params The parameters for creating a waitlist entry.
50+ */
3451 public async create ( params : WaitlistEntryCreateParams ) {
3552 return this . request < WaitlistEntry > ( {
3653 method : 'POST' ,
3754 path : basePath ,
3855 bodyParams : params ,
3956 } ) ;
4057 }
58+
59+ /**
60+ * Invite a waitlist entry.
61+ * @param id The waitlist entry ID.
62+ * @param params Optional parameters (e.g., `ignoreExisting`).
63+ */
64+ public async invite ( id : string , params : WaitlistEntryInviteParams = { } ) {
65+ this . requireId ( id ) ;
66+
67+ return this . request < WaitlistEntry > ( {
68+ method : 'POST' ,
69+ path : joinPaths ( basePath , id , 'invite' ) ,
70+ bodyParams : params ,
71+ } ) ;
72+ }
73+
74+ /**
75+ * Reject a waitlist entry.
76+ * @param id The waitlist entry ID.
77+ */
78+ public async reject ( id : string ) {
79+ this . requireId ( id ) ;
80+
81+ return this . request < WaitlistEntry > ( {
82+ method : 'POST' ,
83+ path : joinPaths ( basePath , id , 'reject' ) ,
84+ } ) ;
85+ }
86+
87+ /**
88+ * Delete a waitlist entry.
89+ * @param id The waitlist entry ID.
90+ */
91+ public async delete ( id : string ) {
92+ this . requireId ( id ) ;
93+
94+ return this . request < DeletedObject > ( {
95+ method : 'DELETE' ,
96+ path : joinPaths ( basePath , id ) ,
97+ } ) ;
98+ }
4199}
0 commit comments