@roundtable-bb/sdk 0.1.26 → 0.1.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,453 +0,0 @@
1
- // AUTO-GENERATED — do not edit manually.
2
- // Run `nx run @roundtable-bb/sdk:codegen` to regenerate.
3
-
4
- import type { ApiKey, BackupPayload, Category, CreateApiKey, CreateCategory, CreateForum, CreateGroup, CreatePost, CreateTenant, CreateThread, CreatedApiKey, Forum, GrantPlatformOwner, Group, GroupMember, Id, Notification, NotificationCount, OwnedTenant, PaginatedResponse, PlatformSetting, Post, ReorderCategory, RestoreTenant, RestoreTenantResponse, SearchResponse, SearchResultType, SetCustomDomain, SetGroupForums, SetGroupPermissions, SetThreadReadStatus, SetUserGroups, Tenant, TenantOwner, TenantToken, Thread, ThreadReadStatus, TransferTenantOwner, UpdateCategory, UpdateForum, UpdateGroup, UpdatePlatformSetting, UpdateThread, UpdateUserProfile, UserMembership, UserProfile } from '@roundtable-bb/types'
5
- import { request, type RoundtableClientOpts } from '../request.js'
6
-
7
- export class AcpClient {
8
- constructor(private readonly opts: RoundtableClientOpts) {}
9
-
10
- /** Export a signed tenant backup (platform owners only) */
11
- backupTenant(params: { tenantId: string }, query?: { includeContent?: boolean }): Promise<BackupPayload> {
12
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/backup`, { query, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
13
- }
14
-
15
- /** Count read and unread notifications */
16
- countNotifications(): Promise<NotificationCount> {
17
- return request(this.opts, 'GET', '/notifications/count', { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } })
18
- }
19
-
20
- /** Create a platform-scoped API key (returned once in full) */
21
- createApiKey(body: CreateApiKey): Promise<CreatedApiKey> {
22
- return request(this.opts, 'POST', '/platform/api-keys', { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
23
- }
24
-
25
- /** Create a category (requires category.manage permission) */
26
- createCategory(params: { tenantId: string }, body: CreateCategory): Promise<Category> {
27
- return request(this.opts, 'POST', `/tenants/${params.tenantId}/categories`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
28
- }
29
-
30
- /** Create a forum (requires forum.manage permission) */
31
- createForum(params: { tenantId: string }, body: CreateForum): Promise<Forum> {
32
- return request(this.opts, 'POST', `/tenants/${params.tenantId}/forums`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
33
- }
34
-
35
- /** Create a group (requires group.manage permission) */
36
- createGroup(params: { tenantId: string }, body: CreateGroup): Promise<Group> {
37
- return request(this.opts, 'POST', `/tenants/${params.tenantId}/groups`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
38
- }
39
-
40
- /** Create a post in a thread */
41
- createPost(params: { tenantId: string; threadId: string }, body: CreatePost): Promise<Post> {
42
- return request(this.opts, 'POST', `/tenants/${params.tenantId}/threads/${params.threadId}/posts`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
43
- }
44
-
45
- /** Create a new tenant (requires allow_tenant_creation platform setting or platform owner) */
46
- createTenant(body: CreateTenant): Promise<Tenant> {
47
- return request(this.opts, 'POST', '/tenants', { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
48
- }
49
-
50
- /** Create a thread (and its first post) */
51
- createThread(params: { tenantId: string; forumId: string }, body: CreateThread): Promise<Thread> {
52
- return request(this.opts, 'POST', `/tenants/${params.tenantId}/forums/${params.forumId}/threads`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
53
- }
54
-
55
- /** Delete a platform-scoped API key */
56
- deleteApiKey(params: { keyId: string }): Promise<void> {
57
- return request(this.opts, 'DELETE', `/platform/api-keys/${params.keyId}`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
58
- }
59
-
60
- /** Delete a category (requires category.manage permission) */
61
- deleteCategory(params: { tenantId: string; categoryId: string }): Promise<void> {
62
- return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/categories/${params.categoryId}`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
63
- }
64
-
65
- /** Delete a forum (requires forum.manage permission) */
66
- deleteForum(params: { tenantId: string; forumId: string }): Promise<void> {
67
- return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/forums/${params.forumId}`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
68
- }
69
-
70
- /** Delete a group (requires group.manage permission) */
71
- deleteGroup(params: { tenantId: string; groupId: string }): Promise<void> {
72
- return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/groups/${params.groupId}`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
73
- }
74
-
75
- /** Delete a notification */
76
- deleteNotification(params: { notificationId: string }): Promise<void> {
77
- return request(this.opts, 'DELETE', `/notifications/${params.notificationId}`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
78
- }
79
-
80
- /** Soft-delete a post */
81
- deletePost(params: { tenantId: string; postId: string }): Promise<void> {
82
- return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/posts/${params.postId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
83
- }
84
-
85
- /** Delete a thread */
86
- deleteThread(params: { tenantId: string; threadId: string }): Promise<void> {
87
- return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/threads/${params.threadId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
88
- }
89
-
90
- /** Exchange session cookie for a short-lived tenant JWT */
91
- exchangeTenantToken(): Promise<TenantToken> {
92
- return request(this.opts, 'POST', '/tenant-token', { routeAuth: { acceptsBetterAuth: true } })
93
- }
94
-
95
- /** Get a single category */
96
- getCategory(params: { tenantId: string; categoryId: string }): Promise<Category> {
97
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/categories/${params.categoryId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
98
- }
99
-
100
- /** Get a single forum */
101
- getForum(params: { tenantId: string; forumId: string }): Promise<Forum> {
102
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/forums/${params.forumId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
103
- }
104
-
105
- /** Get a group */
106
- getGroup(params: { tenantId: string; groupId: string }): Promise<Group> {
107
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/groups/${params.groupId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
108
- }
109
-
110
- /** Get own profile */
111
- getMe(): Promise<UserProfile> {
112
- return request(this.opts, 'GET', '/users/me', { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } })
113
- }
114
-
115
- /** Get the current owner of a tenant */
116
- getTenantOwner(params: { tenantId: string }): Promise<TenantOwner> {
117
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/owner`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
118
- }
119
-
120
- /** Get a single thread */
121
- getThread(params: { tenantId: string; threadId: string }): Promise<Thread> {
122
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/threads/${params.threadId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
123
- }
124
-
125
- /** Get read status for the current user in a thread */
126
- getThreadReadStatus(params: { tenantId: string; threadId: string }): Promise<ThreadReadStatus> {
127
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/threads/${params.threadId}/read-status`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
128
- }
129
-
130
- /** Get a user profile by ID */
131
- getUser(params: { userId: string }): Promise<UserProfile> {
132
- return request(this.opts, 'GET', `/users/${params.userId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
133
- }
134
-
135
- /** Get user group memberships in the current tenant */
136
- getUserMembership(params: { tenantId: string; userId: string }): Promise<UserMembership> {
137
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/users/${params.userId}/membership`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
138
- }
139
-
140
- /** Grant platform owner status to a user (platform owners only) */
141
- grantPlatformOwner(body: GrantPlatformOwner): Promise<void> {
142
- return request(this.opts, 'POST', '/platform/owners', { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
143
- }
144
-
145
- /** List your platform-scoped API keys */
146
- listApiKeys(): Promise<ApiKey[]> {
147
- return request(this.opts, 'GET', '/platform/api-keys', { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
148
- }
149
-
150
- /** List visible categories for the requesting user */
151
- listCategories(params: { tenantId: string }): Promise<Category[]> {
152
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/categories`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } })
153
- }
154
-
155
- /** List visible forums for the requesting user */
156
- listForums(params: { tenantId: string }): Promise<Forum[]> {
157
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/forums`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } })
158
- }
159
-
160
- /** List members of a group */
161
- listGroupMembers(params: { tenantId: string; groupId: string }): Promise<GroupMember[]> {
162
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/groups/${params.groupId}/members`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } })
163
- }
164
-
165
- /** List groups */
166
- listGroups(params: { tenantId: string }): Promise<Group[]> {
167
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/groups`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } })
168
- }
169
-
170
- /** Get unified notification inbox */
171
- listNotifications(query?: { cursor?: Id; limit?: number; unreadOnly?: boolean }): Promise<PaginatedResponse<Notification>> {
172
- return request(this.opts, 'GET', '/notifications', { query, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
173
- }
174
-
175
- /** List platform owner user IDs (platform owners only) */
176
- listPlatformOwners(): Promise<string[]> {
177
- return request(this.opts, 'GET', '/platform/owners', { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
178
- }
179
-
180
- /** List all platform settings (platform owners only) */
181
- listPlatformSettings(): Promise<PlatformSetting[]> {
182
- return request(this.opts, 'GET', '/platform/settings', { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
183
- }
184
-
185
- /** List posts in a thread — cursor pagination or anchor via ?from=postId */
186
- listPosts(params: { tenantId: string; threadId: string }, query?: { cursor?: Id; limit?: number; from?: Id }): Promise<PaginatedResponse<Post>> {
187
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/threads/${params.threadId}/posts`, { query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
188
- }
189
-
190
- /** List tenants owned by the current user (platform owners see all) */
191
- listTenants(query?: { search?: string }): Promise<OwnedTenant[]> {
192
- return request(this.opts, 'GET', '/tenants', { query, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
193
- }
194
-
195
- /** List threads in a forum */
196
- listThreads(params: { tenantId: string; forumId: string }, query?: { cursor?: Id; limit?: number }): Promise<PaginatedResponse<Thread>> {
197
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/forums/${params.forumId}/threads`, { query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
198
- }
199
-
200
- /** Mark a notification as read */
201
- markNotificationRead(params: { notificationId: string }): Promise<Notification> {
202
- return request(this.opts, 'PATCH', `/notifications/${params.notificationId}/read`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
203
- }
204
-
205
- /** Set the position of each category (requires category.manage permission) */
206
- reorderCategories(params: { tenantId: string }, body: ReorderCategory): Promise<void> {
207
- return request(this.opts, 'PUT', `/tenants/${params.tenantId}/categories/reorder`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
208
- }
209
-
210
- /** Set the position of each forum (requires forum.manage permission) */
211
- reorderForums(params: { tenantId: string }, body: ReorderCategory): Promise<void> {
212
- return request(this.opts, 'PUT', `/tenants/${params.tenantId}/forums/reorder`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
213
- }
214
-
215
- /** Set the position of each group (requires group.manage permission) */
216
- reorderGroups(params: { tenantId: string }, body: ReorderCategory): Promise<void> {
217
- return request(this.opts, 'PUT', `/tenants/${params.tenantId}/groups/reorder`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
218
- }
219
-
220
- /** Restore a tenant from a signed backup (platform owners only) */
221
- restoreTenant(params: { tenantId: string }, body: RestoreTenant): Promise<RestoreTenantResponse> {
222
- return request(this.opts, 'POST', `/tenants/${params.tenantId}/restore`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
223
- }
224
-
225
- /** Revoke platform owner status from a user (platform owners only) */
226
- revokePlatformOwner(params: { userId: string }): Promise<void> {
227
- return request(this.opts, 'DELETE', `/platform/owners/${params.userId}`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
228
- }
229
-
230
- /** Full-text search across threads and posts (visible categories only) */
231
- search(params: { tenantId: string }, query?: { q: string; type?: SearchResultType; categoryId?: Id; limit?: number }): Promise<SearchResponse> {
232
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/search`, { query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
233
- }
234
-
235
- /** Search users by display name or email (case-insensitive) */
236
- searchUsers(query?: { q: string }): Promise<unknown> {
237
- return request(this.opts, 'GET', '/users/search', { query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
238
- }
239
-
240
- /** Set forum visibility for a group (requires group.manage or group.manage_protected permission) */
241
- setGroupForums(params: { tenantId: string; groupId: string }, body: SetGroupForums): Promise<Group> {
242
- return request(this.opts, 'PUT', `/tenants/${params.tenantId}/groups/${params.groupId}/forums`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
243
- }
244
-
245
- /** Replace all permissions for a group (requires group.manage permission) */
246
- setGroupPermissions(params: { tenantId: string; groupId: string }, body: SetGroupPermissions): Promise<Group> {
247
- return request(this.opts, 'PUT', `/tenants/${params.tenantId}/groups/${params.groupId}/permissions`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
248
- }
249
-
250
- /** Set or remove the custom domain for a tenant */
251
- setTenantCustomDomain(params: { tenantId: string }, body: SetCustomDomain): Promise<void> {
252
- return request(this.opts, 'PUT', `/tenants/${params.tenantId}/custom-domain`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
253
- }
254
-
255
- /** Mark a thread as read up to a given post */
256
- setThreadReadStatus(params: { tenantId: string; threadId: string }, body: SetThreadReadStatus): Promise<void> {
257
- return request(this.opts, 'PUT', `/tenants/${params.tenantId}/threads/${params.threadId}/read-status`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
258
- }
259
-
260
- /** Replace user group assignments in the current tenant (requires group.manage permission) */
261
- setUserGroups(params: { tenantId: string; userId: string }, body: SetUserGroups): Promise<UserMembership> {
262
- return request(this.opts, 'PUT', `/tenants/${params.tenantId}/users/${params.userId}/membership`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
263
- }
264
-
265
- /** Subscribe to a thread */
266
- subscribeThread(params: { tenantId: string; threadId: string }): Promise<void> {
267
- return request(this.opts, 'POST', `/tenants/${params.tenantId}/threads/${params.threadId}/subscribe`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
268
- }
269
-
270
- /** Transfer tenant ownership to another existing user (only the current owner can do this) */
271
- transferTenantOwner(params: { tenantId: string }, body: TransferTenantOwner): Promise<void> {
272
- return request(this.opts, 'PUT', `/tenants/${params.tenantId}/owner`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
273
- }
274
-
275
- /** Unsubscribe from a thread */
276
- unsubscribeThread(params: { tenantId: string; threadId: string }): Promise<void> {
277
- return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/threads/${params.threadId}/subscribe`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
278
- }
279
-
280
- /** Update a category (requires category.manage permission) */
281
- updateCategory(params: { tenantId: string; categoryId: string }, body: UpdateCategory): Promise<Category> {
282
- return request(this.opts, 'PATCH', `/tenants/${params.tenantId}/categories/${params.categoryId}`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
283
- }
284
-
285
- /** Update a forum (requires forum.manage permission) */
286
- updateForum(params: { tenantId: string; forumId: string }, body: UpdateForum): Promise<Forum> {
287
- return request(this.opts, 'PATCH', `/tenants/${params.tenantId}/forums/${params.forumId}`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
288
- }
289
-
290
- /** Update a group (requires group.manage permission) */
291
- updateGroup(params: { tenantId: string; groupId: string }, body: UpdateGroup): Promise<Group> {
292
- return request(this.opts, 'PATCH', `/tenants/${params.tenantId}/groups/${params.groupId}`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
293
- }
294
-
295
- /** Update own profile */
296
- updateMe(body: UpdateUserProfile): Promise<UserProfile> {
297
- return request(this.opts, 'PATCH', '/users/me', { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
298
- }
299
-
300
- /** Update a platform setting (platform owners only) */
301
- updatePlatformSetting(params: { key: string }, body: UpdatePlatformSetting): Promise<PlatformSetting> {
302
- return request(this.opts, 'PATCH', `/platform/settings/${params.key}`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } })
303
- }
304
-
305
- /** Edit a post (author or post.edit permission) */
306
- updatePost(params: { tenantId: string; postId: string }, body: CreatePost): Promise<Post> {
307
- return request(this.opts, 'PATCH', `/tenants/${params.tenantId}/posts/${params.postId}`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
308
- }
309
-
310
- /** Update a thread (title, pin, lock, move) */
311
- updateThread(params: { tenantId: string; threadId: string }, body: UpdateThread): Promise<Thread> {
312
- return request(this.opts, 'PATCH', `/tenants/${params.tenantId}/threads/${params.threadId}`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
313
- }
314
- }
315
-
316
- export class TenantClient {
317
- constructor(private readonly opts: RoundtableClientOpts) {}
318
-
319
- /** Count read and unread notifications */
320
- countNotifications(): Promise<NotificationCount> {
321
- return request(this.opts, 'GET', '/notifications/count', { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } })
322
- }
323
-
324
- /** Create a post in a thread */
325
- createPost(params: { tenantId: string; threadId: string }, body: CreatePost): Promise<Post> {
326
- return request(this.opts, 'POST', `/tenants/${params.tenantId}/threads/${params.threadId}/posts`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
327
- }
328
-
329
- /** Create a thread (and its first post) */
330
- createThread(params: { tenantId: string; forumId: string }, body: CreateThread): Promise<Thread> {
331
- return request(this.opts, 'POST', `/tenants/${params.tenantId}/forums/${params.forumId}/threads`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
332
- }
333
-
334
- /** Soft-delete a post */
335
- deletePost(params: { tenantId: string; postId: string }): Promise<void> {
336
- return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/posts/${params.postId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
337
- }
338
-
339
- /** Delete a thread */
340
- deleteThread(params: { tenantId: string; threadId: string }): Promise<void> {
341
- return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/threads/${params.threadId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
342
- }
343
-
344
- /** Exchange session cookie for a short-lived tenant JWT */
345
- exchangeTenantToken(): Promise<TenantToken> {
346
- return request(this.opts, 'POST', '/tenant-token', { routeAuth: { acceptsBetterAuth: true, tenantUseCredentials: true } })
347
- }
348
-
349
- /** Get a single category */
350
- getCategory(params: { tenantId: string; categoryId: string }): Promise<Category> {
351
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/categories/${params.categoryId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
352
- }
353
-
354
- /** Get a single forum */
355
- getForum(params: { tenantId: string; forumId: string }): Promise<Forum> {
356
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/forums/${params.forumId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
357
- }
358
-
359
- /** Get a group */
360
- getGroup(params: { tenantId: string; groupId: string }): Promise<Group> {
361
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/groups/${params.groupId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
362
- }
363
-
364
- /** Get own profile */
365
- getMe(): Promise<UserProfile> {
366
- return request(this.opts, 'GET', '/users/me', { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } })
367
- }
368
-
369
- /** Get a single thread */
370
- getThread(params: { tenantId: string; threadId: string }): Promise<Thread> {
371
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/threads/${params.threadId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
372
- }
373
-
374
- /** Get read status for the current user in a thread */
375
- getThreadReadStatus(params: { tenantId: string; threadId: string }): Promise<ThreadReadStatus> {
376
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/threads/${params.threadId}/read-status`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
377
- }
378
-
379
- /** Get a user profile by ID */
380
- getUser(params: { userId: string }): Promise<UserProfile> {
381
- return request(this.opts, 'GET', `/users/${params.userId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
382
- }
383
-
384
- /** Get user group memberships in the current tenant */
385
- getUserMembership(params: { tenantId: string; userId: string }): Promise<UserMembership> {
386
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/users/${params.userId}/membership`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
387
- }
388
-
389
- /** List visible categories for the requesting user */
390
- listCategories(params: { tenantId: string }): Promise<Category[]> {
391
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/categories`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } })
392
- }
393
-
394
- /** List visible forums for the requesting user */
395
- listForums(params: { tenantId: string }): Promise<Forum[]> {
396
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/forums`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } })
397
- }
398
-
399
- /** List members of a group */
400
- listGroupMembers(params: { tenantId: string; groupId: string }): Promise<GroupMember[]> {
401
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/groups/${params.groupId}/members`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } })
402
- }
403
-
404
- /** List groups */
405
- listGroups(params: { tenantId: string }): Promise<Group[]> {
406
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/groups`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } })
407
- }
408
-
409
- /** List posts in a thread — cursor pagination or anchor via ?from=postId */
410
- listPosts(params: { tenantId: string; threadId: string }, query?: { cursor?: Id; limit?: number; from?: Id }): Promise<PaginatedResponse<Post>> {
411
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/threads/${params.threadId}/posts`, { query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
412
- }
413
-
414
- /** List threads in a forum */
415
- listThreads(params: { tenantId: string; forumId: string }, query?: { cursor?: Id; limit?: number }): Promise<PaginatedResponse<Thread>> {
416
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/forums/${params.forumId}/threads`, { query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
417
- }
418
-
419
- /** Full-text search across threads and posts (visible categories only) */
420
- search(params: { tenantId: string }, query?: { q: string; type?: SearchResultType; categoryId?: Id; limit?: number }): Promise<SearchResponse> {
421
- return request(this.opts, 'GET', `/tenants/${params.tenantId}/search`, { query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
422
- }
423
-
424
- /** Search users by display name or email (case-insensitive) */
425
- searchUsers(query?: { q: string }): Promise<unknown> {
426
- return request(this.opts, 'GET', '/users/search', { query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
427
- }
428
-
429
- /** Mark a thread as read up to a given post */
430
- setThreadReadStatus(params: { tenantId: string; threadId: string }, body: SetThreadReadStatus): Promise<void> {
431
- return request(this.opts, 'PUT', `/tenants/${params.tenantId}/threads/${params.threadId}/read-status`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
432
- }
433
-
434
- /** Subscribe to a thread */
435
- subscribeThread(params: { tenantId: string; threadId: string }): Promise<void> {
436
- return request(this.opts, 'POST', `/tenants/${params.tenantId}/threads/${params.threadId}/subscribe`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
437
- }
438
-
439
- /** Unsubscribe from a thread */
440
- unsubscribeThread(params: { tenantId: string; threadId: string }): Promise<void> {
441
- return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/threads/${params.threadId}/subscribe`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
442
- }
443
-
444
- /** Edit a post (author or post.edit permission) */
445
- updatePost(params: { tenantId: string; postId: string }, body: CreatePost): Promise<Post> {
446
- return request(this.opts, 'PATCH', `/tenants/${params.tenantId}/posts/${params.postId}`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
447
- }
448
-
449
- /** Update a thread (title, pin, lock, move) */
450
- updateThread(params: { tenantId: string; threadId: string }, body: UpdateThread): Promise<Thread> {
451
- return request(this.opts, 'PATCH', `/tenants/${params.tenantId}/threads/${params.threadId}`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } })
452
- }
453
- }
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export { AcpClient, TenantClient } from './generated/client.js';
2
- export type { RoundtableClientOpts } from './request.js';
3
- export type * from '@roundtable-bb/types';
package/src/request.ts DELETED
@@ -1,74 +0,0 @@
1
- export interface RoundtableClientOpts {
2
- baseURL: string;
3
- token?: string;
4
- }
5
-
6
- interface RouteAuth {
7
- acceptsApiKey?: boolean;
8
- acceptsBetterAuth?: boolean;
9
- acceptsTenantJwt?: boolean;
10
- requiresToken?: boolean;
11
- tenantUseCredentials?: boolean;
12
- }
13
-
14
- export async function request<T>(
15
- opts: RoundtableClientOpts,
16
- method: string,
17
- path: string,
18
- options?: {
19
- body?: unknown;
20
- query?: Record<string, unknown>;
21
- useCredentials?: boolean;
22
- routeAuth?: RouteAuth;
23
- },
24
- ): Promise<T> {
25
- const routeAuth = options?.routeAuth;
26
- let useCredentials = options?.useCredentials ?? false;
27
-
28
- // Decide auth strategy
29
- if (routeAuth) {
30
- // TenantClient: use credentials if explicitly required by route
31
- if (routeAuth.tenantUseCredentials) {
32
- useCredentials = true;
33
- }
34
- // If token is available, use it (prefer token over credentials)
35
- else if (opts.token && routeAuth.acceptsApiKey) {
36
- useCredentials = false;
37
- }
38
- // If no token but route accepts better-auth: use credentials
39
- else if (!opts.token && routeAuth.acceptsBetterAuth) {
40
- useCredentials = true;
41
- }
42
- // Otherwise: make request without auth (backend will respond 401/403 if needed)
43
- }
44
-
45
- const url = new URL(`${opts.baseURL}${path}`);
46
- if (options?.query) {
47
- for (const [k, v] of Object.entries(options.query)) {
48
- if (v !== undefined && v !== null) url.searchParams.set(k, String(v));
49
- }
50
- }
51
-
52
- const res = await fetch(url.toString(), {
53
- method,
54
- credentials: useCredentials ? 'include' : undefined,
55
- headers: {
56
- ...(options?.body !== undefined
57
- ? { 'Content-Type': 'application/json' }
58
- : {}),
59
- ...(opts.token && !useCredentials
60
- ? { Authorization: `Bearer ${opts.token}` }
61
- : {}),
62
- },
63
- body:
64
- options?.body !== undefined ? JSON.stringify(options.body) : undefined,
65
- });
66
-
67
- if (res.status === 204) return undefined as T;
68
- if (!res.ok) {
69
- const err = await res.json().catch(() => ({ message: res.statusText }));
70
- const msg = (err as { message?: string }).message ?? res.statusText;
71
- throw Object.assign(new Error(msg), { status: res.status });
72
- }
73
- return (await res.json()) as T;
74
- }