@roundtable-bb/sdk 0.1.9 → 0.1.13

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