@roundtable-bb/sdk 0.1.36 → 0.1.37
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.
- package/dist/index.js +797 -1
- package/package.json +2 -1
- package/dist/generated/client.js +0 -297
- package/dist/request.js +0 -56
package/dist/index.js
CHANGED
|
@@ -1 +1,797 @@
|
|
|
1
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
async function request(opts, method, path, options) {
|
|
4
|
+
const routeAuth = options?.routeAuth;
|
|
5
|
+
const authMethod = options?.authMethod;
|
|
6
|
+
let token;
|
|
7
|
+
let useCredentials = false;
|
|
8
|
+
if (authMethod) {
|
|
9
|
+
if (authMethod === 'apiKey') {
|
|
10
|
+
if (!opts.apiKey)
|
|
11
|
+
throw new Error('authMethod: apiKey is not configured');
|
|
12
|
+
token = opts.apiKey;
|
|
13
|
+
}
|
|
14
|
+
else if (authMethod === 'tenantToken') {
|
|
15
|
+
if (!opts.tenantToken)
|
|
16
|
+
throw new Error('authMethod: tenantToken is not configured');
|
|
17
|
+
token = opts.tenantToken;
|
|
18
|
+
}
|
|
19
|
+
else if (authMethod === 'betterAuth') {
|
|
20
|
+
useCredentials = true;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else if (routeAuth) {
|
|
24
|
+
if (opts.apiKey && routeAuth.acceptsApiKey) {
|
|
25
|
+
token = opts.apiKey;
|
|
26
|
+
}
|
|
27
|
+
else if (opts.tenantToken && routeAuth.acceptsTenantJwt) {
|
|
28
|
+
token = opts.tenantToken;
|
|
29
|
+
}
|
|
30
|
+
else if (routeAuth.acceptsBetterAuth) {
|
|
31
|
+
useCredentials = true;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const url = new URL(`${opts.baseURL}${path}`);
|
|
35
|
+
if (options?.query) {
|
|
36
|
+
for (const [k, v] of Object.entries(options.query)) {
|
|
37
|
+
if (v !== undefined && v !== null)
|
|
38
|
+
url.searchParams.set(k, String(v));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const res = await fetch(url.toString(), {
|
|
42
|
+
method,
|
|
43
|
+
credentials: useCredentials ? 'include' : undefined,
|
|
44
|
+
headers: {
|
|
45
|
+
...(options?.body !== undefined ? { 'Content-Type': 'application/json' } : {}),
|
|
46
|
+
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
|
47
|
+
},
|
|
48
|
+
body: options?.body !== undefined ? JSON.stringify(options.body) : undefined,
|
|
49
|
+
});
|
|
50
|
+
if (res.status === 204)
|
|
51
|
+
return undefined;
|
|
52
|
+
if (!res.ok) {
|
|
53
|
+
const err = await res.json().catch(() => ({ message: res.statusText }));
|
|
54
|
+
const msg = err.message ?? res.statusText;
|
|
55
|
+
throw Object.assign(new Error(msg), { status: res.status });
|
|
56
|
+
}
|
|
57
|
+
return (await res.json());
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// AUTO-GENERATED — do not edit manually.
|
|
61
|
+
// Run `nx run @roundtable-bb/sdk:codegen` to regenerate.
|
|
62
|
+
class RoundtableClient {
|
|
63
|
+
opts;
|
|
64
|
+
constructor(opts) {
|
|
65
|
+
this.opts = opts;
|
|
66
|
+
}
|
|
67
|
+
/** Export a signed tenant backup (platform owners only) */
|
|
68
|
+
backupTenant(params, query, options) {
|
|
69
|
+
return request(this.opts, 'GET', `/tenants/${params.tenantId}/backup`, { ...options, query, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
70
|
+
}
|
|
71
|
+
/** Count read and unread notifications */
|
|
72
|
+
countNotifications(options) {
|
|
73
|
+
return request(this.opts, 'GET', '/notifications/count', { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
74
|
+
}
|
|
75
|
+
/** Count unread private messages */
|
|
76
|
+
countUnreadMessages(options) {
|
|
77
|
+
return request(this.opts, 'GET', '/messages/count', { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
78
|
+
}
|
|
79
|
+
/** Create a platform-scoped API key (returned once in full) */
|
|
80
|
+
createApiKey(body, options) {
|
|
81
|
+
return request(this.opts, 'POST', '/platform/api-keys', { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
82
|
+
}
|
|
83
|
+
/** Create a category (requires category.manage permission) */
|
|
84
|
+
createCategory(params, body, options) {
|
|
85
|
+
return request(this.opts, 'POST', `/tenants/${params.tenantId}/categories`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
86
|
+
}
|
|
87
|
+
/** Create a forum (requires forum.manage permission) */
|
|
88
|
+
createForum(params, body, options) {
|
|
89
|
+
return request(this.opts, 'POST', `/tenants/${params.tenantId}/forums`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
90
|
+
}
|
|
91
|
+
/** Create a group (requires group.manage permission) */
|
|
92
|
+
createGroup(params, body, options) {
|
|
93
|
+
return request(this.opts, 'POST', `/tenants/${params.tenantId}/groups`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
94
|
+
}
|
|
95
|
+
/** Create a post in a thread */
|
|
96
|
+
createPost(params, body, options) {
|
|
97
|
+
return request(this.opts, 'POST', `/tenants/${params.tenantId}/threads/${params.threadId}/posts`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
98
|
+
}
|
|
99
|
+
/** Create a new tenant (requires allow_tenant_creation platform setting or platform owner) */
|
|
100
|
+
createTenant(body, options) {
|
|
101
|
+
return request(this.opts, 'POST', '/tenants', { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
102
|
+
}
|
|
103
|
+
/** Create a thread (and its first post) */
|
|
104
|
+
createThread(params, body, options) {
|
|
105
|
+
return request(this.opts, 'POST', `/tenants/${params.tenantId}/forums/${params.forumId}/threads`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
106
|
+
}
|
|
107
|
+
/** Delete a platform-scoped API key */
|
|
108
|
+
deleteApiKey(params, options) {
|
|
109
|
+
return request(this.opts, 'DELETE', `/platform/api-keys/${params.keyId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
110
|
+
}
|
|
111
|
+
/** Delete a category (requires category.manage permission) */
|
|
112
|
+
deleteCategory(params, options) {
|
|
113
|
+
return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/categories/${params.categoryId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
114
|
+
}
|
|
115
|
+
/** Delete a forum (requires forum.manage permission) */
|
|
116
|
+
deleteForum(params, options) {
|
|
117
|
+
return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/forums/${params.forumId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
118
|
+
}
|
|
119
|
+
/** Delete a group (requires group.manage permission) */
|
|
120
|
+
deleteGroup(params, options) {
|
|
121
|
+
return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/groups/${params.groupId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
122
|
+
}
|
|
123
|
+
/** Delete a private message */
|
|
124
|
+
deleteMessage(params, options) {
|
|
125
|
+
return request(this.opts, 'DELETE', `/messages/${params.messageId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
126
|
+
}
|
|
127
|
+
/** Delete a notification */
|
|
128
|
+
deleteNotification(params, options) {
|
|
129
|
+
return request(this.opts, 'DELETE', `/notifications/${params.notificationId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
130
|
+
}
|
|
131
|
+
/** Soft-delete a post */
|
|
132
|
+
deletePost(params, options) {
|
|
133
|
+
return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/posts/${params.postId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
134
|
+
}
|
|
135
|
+
/** Permanently delete a tenant and all its data (platform owners only) */
|
|
136
|
+
deleteTenant(params, options) {
|
|
137
|
+
return request(this.opts, 'DELETE', `/tenants/${params.tenantId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
138
|
+
}
|
|
139
|
+
/** Delete a thread */
|
|
140
|
+
deleteThread(params, options) {
|
|
141
|
+
return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/threads/${params.threadId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
142
|
+
}
|
|
143
|
+
/** Exchange session cookie for a short-lived tenant JWT */
|
|
144
|
+
exchangeTenantToken(options) {
|
|
145
|
+
return request(this.opts, 'POST', '/tenant-token', { ...options, routeAuth: { acceptsBetterAuth: true } });
|
|
146
|
+
}
|
|
147
|
+
/** Get a single category */
|
|
148
|
+
getCategory(params, options) {
|
|
149
|
+
return request(this.opts, 'GET', `/tenants/${params.tenantId}/categories/${params.categoryId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
150
|
+
}
|
|
151
|
+
/** Get a single forum */
|
|
152
|
+
getForum(params, options) {
|
|
153
|
+
return request(this.opts, 'GET', `/tenants/${params.tenantId}/forums/${params.forumId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
154
|
+
}
|
|
155
|
+
/** Get a group */
|
|
156
|
+
getGroup(params, options) {
|
|
157
|
+
return request(this.opts, 'GET', `/tenants/${params.tenantId}/groups/${params.groupId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
158
|
+
}
|
|
159
|
+
/** Get own profile */
|
|
160
|
+
getMe(options) {
|
|
161
|
+
return request(this.opts, 'GET', '/users/me', { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
162
|
+
}
|
|
163
|
+
/** Get tenant options and unsafe methods allowed */
|
|
164
|
+
getTenantOptions(params, options) {
|
|
165
|
+
return request(this.opts, 'GET', `/tenants/${params.tenantId}/options`, { ...options });
|
|
166
|
+
}
|
|
167
|
+
/** Get the current owner of a tenant */
|
|
168
|
+
getTenantOwner(params, options) {
|
|
169
|
+
return request(this.opts, 'GET', `/tenants/${params.tenantId}/owner`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
170
|
+
}
|
|
171
|
+
/** Get a single thread */
|
|
172
|
+
getThread(params, options) {
|
|
173
|
+
return request(this.opts, 'GET', `/tenants/${params.tenantId}/threads/${params.threadId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
174
|
+
}
|
|
175
|
+
/** Get read status for the current user in a thread */
|
|
176
|
+
getThreadReadStatus(params, options) {
|
|
177
|
+
return request(this.opts, 'GET', `/tenants/${params.tenantId}/threads/${params.threadId}/read-status`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
178
|
+
}
|
|
179
|
+
/** Get a user profile by ID */
|
|
180
|
+
getUser(params, options) {
|
|
181
|
+
return request(this.opts, 'GET', `/users/${params.userId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
182
|
+
}
|
|
183
|
+
/** Get user group memberships in the current tenant */
|
|
184
|
+
getUserMembership(params, options) {
|
|
185
|
+
return request(this.opts, 'GET', `/tenants/${params.tenantId}/users/${params.userId}/membership`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
186
|
+
}
|
|
187
|
+
/** Grant platform owner status to a user (platform owners only) */
|
|
188
|
+
grantPlatformOwner(body, options) {
|
|
189
|
+
return request(this.opts, 'POST', '/platform/owners', { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
190
|
+
}
|
|
191
|
+
/** List your platform-scoped API keys */
|
|
192
|
+
listApiKeys(options) {
|
|
193
|
+
return request(this.opts, 'GET', '/platform/api-keys', { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
194
|
+
}
|
|
195
|
+
/** List visible categories for the requesting user */
|
|
196
|
+
listCategories(params, options) {
|
|
197
|
+
return request(this.opts, 'GET', `/tenants/${params.tenantId}/categories`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
198
|
+
}
|
|
199
|
+
/** List messages exchanged with a specific user */
|
|
200
|
+
listConversationMessages(params, query, options) {
|
|
201
|
+
return request(this.opts, 'GET', `/messages/conversations/${params.userId}`, { ...options, query, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
202
|
+
}
|
|
203
|
+
/** List conversations for the current user */
|
|
204
|
+
listConversations(options) {
|
|
205
|
+
return request(this.opts, 'GET', '/messages/conversations', { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
206
|
+
}
|
|
207
|
+
/** List visible forums for the requesting user */
|
|
208
|
+
listForums(params, options) {
|
|
209
|
+
return request(this.opts, 'GET', `/tenants/${params.tenantId}/forums`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
210
|
+
}
|
|
211
|
+
/** List members of a group */
|
|
212
|
+
listGroupMembers(params, options) {
|
|
213
|
+
return request(this.opts, 'GET', `/tenants/${params.tenantId}/groups/${params.groupId}/members`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
214
|
+
}
|
|
215
|
+
/** List groups */
|
|
216
|
+
listGroups(params, options) {
|
|
217
|
+
return request(this.opts, 'GET', `/tenants/${params.tenantId}/groups`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
218
|
+
}
|
|
219
|
+
/** Get unified notification inbox */
|
|
220
|
+
listNotifications(query, options) {
|
|
221
|
+
return request(this.opts, 'GET', '/notifications', { ...options, query, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
222
|
+
}
|
|
223
|
+
/** List platform owner user IDs (platform owners only) */
|
|
224
|
+
listPlatformOwners(options) {
|
|
225
|
+
return request(this.opts, 'GET', '/platform/owners', { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
226
|
+
}
|
|
227
|
+
/** List all platform settings (platform owners only) */
|
|
228
|
+
listPlatformSettings(options) {
|
|
229
|
+
return request(this.opts, 'GET', '/platform/settings', { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
230
|
+
}
|
|
231
|
+
/** List posts in a thread — cursor pagination or anchor via ?from=postId */
|
|
232
|
+
listPosts(params, query, options) {
|
|
233
|
+
return request(this.opts, 'GET', `/tenants/${params.tenantId}/threads/${params.threadId}/posts`, { ...options, query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
234
|
+
}
|
|
235
|
+
/** List tenants owned by the current user (platform owners see all) */
|
|
236
|
+
listTenants(query, options) {
|
|
237
|
+
return request(this.opts, 'GET', '/tenants', { ...options, query, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
238
|
+
}
|
|
239
|
+
/** List threads in a forum */
|
|
240
|
+
listThreads(params, query, options) {
|
|
241
|
+
return request(this.opts, 'GET', `/tenants/${params.tenantId}/forums/${params.forumId}/threads`, { ...options, query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
242
|
+
}
|
|
243
|
+
/** Mark all notifications as read */
|
|
244
|
+
markAllNotificationRead(options) {
|
|
245
|
+
return request(this.opts, 'POST', '/notifications/read-all', { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
246
|
+
}
|
|
247
|
+
/** Mark all messages from a user as read */
|
|
248
|
+
markConversationRead(params, options) {
|
|
249
|
+
return request(this.opts, 'PATCH', `/messages/conversations/${params.userId}/read`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
250
|
+
}
|
|
251
|
+
/** Mark a message as read */
|
|
252
|
+
markMessageRead(params, options) {
|
|
253
|
+
return request(this.opts, 'PATCH', `/messages/${params.messageId}/read`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
254
|
+
}
|
|
255
|
+
/** Mark a notification as read */
|
|
256
|
+
markNotificationRead(params, options) {
|
|
257
|
+
return request(this.opts, 'PATCH', `/notifications/${params.notificationId}/read`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
258
|
+
}
|
|
259
|
+
/** Set tenant options */
|
|
260
|
+
putTenantOptions(params, body, options) {
|
|
261
|
+
return request(this.opts, 'PUT', `/tenants/${params.tenantId}/options`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
262
|
+
}
|
|
263
|
+
/** Set the position of each category (requires category.manage permission) */
|
|
264
|
+
reorderCategories(params, body, options) {
|
|
265
|
+
return request(this.opts, 'PUT', `/tenants/${params.tenantId}/categories/reorder`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
266
|
+
}
|
|
267
|
+
/** Set the position of each forum (requires forum.manage permission) */
|
|
268
|
+
reorderForums(params, body, options) {
|
|
269
|
+
return request(this.opts, 'PUT', `/tenants/${params.tenantId}/forums/reorder`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
270
|
+
}
|
|
271
|
+
/** Set the position of each group (requires group.manage permission) */
|
|
272
|
+
reorderGroups(params, body, options) {
|
|
273
|
+
return request(this.opts, 'PUT', `/tenants/${params.tenantId}/groups/reorder`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
274
|
+
}
|
|
275
|
+
/** Restore a tenant from a signed backup (platform owners only) */
|
|
276
|
+
restoreTenant(params, body, options) {
|
|
277
|
+
return request(this.opts, 'POST', `/tenants/${params.tenantId}/restore`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
278
|
+
}
|
|
279
|
+
/** Revoke platform owner status from a user (platform owners only) */
|
|
280
|
+
revokePlatformOwner(params, options) {
|
|
281
|
+
return request(this.opts, 'DELETE', `/platform/owners/${params.userId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
282
|
+
}
|
|
283
|
+
/** Full-text search across threads and posts (visible categories only) */
|
|
284
|
+
search(params, query, options) {
|
|
285
|
+
return request(this.opts, 'GET', `/tenants/${params.tenantId}/search`, { ...options, query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
286
|
+
}
|
|
287
|
+
/** Search users by display name or email (case-insensitive) */
|
|
288
|
+
searchUsers(query, options) {
|
|
289
|
+
return request(this.opts, 'GET', '/users/search', { ...options, query, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
290
|
+
}
|
|
291
|
+
/** Send a private message to another user */
|
|
292
|
+
sendMessage(body, options) {
|
|
293
|
+
return request(this.opts, 'POST', '/messages', { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
294
|
+
}
|
|
295
|
+
/** Set forum visibility for a group (requires group.manage or group.manage_protected permission) */
|
|
296
|
+
setGroupForums(params, body, options) {
|
|
297
|
+
return request(this.opts, 'PUT', `/tenants/${params.tenantId}/groups/${params.groupId}/forums`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
298
|
+
}
|
|
299
|
+
/** Replace all permissions for a group (requires group.manage permission) */
|
|
300
|
+
setGroupPermissions(params, body, options) {
|
|
301
|
+
return request(this.opts, 'PUT', `/tenants/${params.tenantId}/groups/${params.groupId}/permissions`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
302
|
+
}
|
|
303
|
+
/** Mark a thread as read up to a given post */
|
|
304
|
+
setThreadReadStatus(params, body, options) {
|
|
305
|
+
return request(this.opts, 'PUT', `/tenants/${params.tenantId}/threads/${params.threadId}/read-status`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
306
|
+
}
|
|
307
|
+
/** Replace user group assignments in the current tenant (requires group.manage permission) */
|
|
308
|
+
setUserGroups(params, body, options) {
|
|
309
|
+
return request(this.opts, 'PUT', `/tenants/${params.tenantId}/users/${params.userId}/membership`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
310
|
+
}
|
|
311
|
+
/** Subscribe to a thread */
|
|
312
|
+
subscribeThread(params, options) {
|
|
313
|
+
return request(this.opts, 'POST', `/tenants/${params.tenantId}/threads/${params.threadId}/subscribe`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
314
|
+
}
|
|
315
|
+
/** Transfer tenant ownership to another existing user (only the current owner can do this) */
|
|
316
|
+
transferTenantOwner(params, body, options) {
|
|
317
|
+
return request(this.opts, 'PUT', `/tenants/${params.tenantId}/owner`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
318
|
+
}
|
|
319
|
+
/** Unsubscribe from a thread */
|
|
320
|
+
unsubscribeThread(params, options) {
|
|
321
|
+
return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/threads/${params.threadId}/subscribe`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
322
|
+
}
|
|
323
|
+
/** Update a category (requires category.manage permission) */
|
|
324
|
+
updateCategory(params, body, options) {
|
|
325
|
+
return request(this.opts, 'PATCH', `/tenants/${params.tenantId}/categories/${params.categoryId}`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
326
|
+
}
|
|
327
|
+
/** Update a forum (requires forum.manage permission) */
|
|
328
|
+
updateForum(params, body, options) {
|
|
329
|
+
return request(this.opts, 'PATCH', `/tenants/${params.tenantId}/forums/${params.forumId}`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
330
|
+
}
|
|
331
|
+
/** Update a group (requires group.manage permission) */
|
|
332
|
+
updateGroup(params, body, options) {
|
|
333
|
+
return request(this.opts, 'PATCH', `/tenants/${params.tenantId}/groups/${params.groupId}`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
334
|
+
}
|
|
335
|
+
/** Update own profile */
|
|
336
|
+
updateMe(body, options) {
|
|
337
|
+
return request(this.opts, 'PATCH', '/users/me', { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
338
|
+
}
|
|
339
|
+
/** Update a platform setting (platform owners only) */
|
|
340
|
+
updatePlatformSetting(params, body, options) {
|
|
341
|
+
return request(this.opts, 'PATCH', `/platform/settings/${params.key}`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
342
|
+
}
|
|
343
|
+
/** Edit a post (author or post.edit permission) */
|
|
344
|
+
updatePost(params, body, options) {
|
|
345
|
+
return request(this.opts, 'PATCH', `/tenants/${params.tenantId}/posts/${params.postId}`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
346
|
+
}
|
|
347
|
+
/** Update a tenant's name, slug, or custom domain (tenant owner or platform owner) */
|
|
348
|
+
updateTenant(params, body, options) {
|
|
349
|
+
return request(this.opts, 'PATCH', `/tenants/${params.tenantId}`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
350
|
+
}
|
|
351
|
+
/** Update a thread (title, pin, lock, move) */
|
|
352
|
+
updateThread(params, body, options) {
|
|
353
|
+
return request(this.opts, 'PATCH', `/tenants/${params.tenantId}/threads/${params.threadId}`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const IdSchema = z.uuid();
|
|
358
|
+
const PaginationQuerySchema = z.object({
|
|
359
|
+
cursor: z.uuid().optional(),
|
|
360
|
+
limit: z.coerce.number().int().min(1).max(100).default(30),
|
|
361
|
+
});
|
|
362
|
+
const PaginatedResponseSchema = (itemSchema) => z.object({
|
|
363
|
+
items: z.array(itemSchema),
|
|
364
|
+
nextCursor: z.uuid().nullable(),
|
|
365
|
+
});
|
|
366
|
+
const ErrorSchema = z.object({
|
|
367
|
+
code: z.string(),
|
|
368
|
+
message: z.string(),
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
const TenantIdParamsSchema = z.object({
|
|
372
|
+
tenantId: z.coerce.number().int(),
|
|
373
|
+
});
|
|
374
|
+
const TenantCategoryIdParamsSchema = z.object({
|
|
375
|
+
tenantId: z.coerce.number().int(),
|
|
376
|
+
categoryId: IdSchema,
|
|
377
|
+
});
|
|
378
|
+
const TenantForumIdParamsSchema = z.object({
|
|
379
|
+
tenantId: z.coerce.number().int(),
|
|
380
|
+
forumId: IdSchema,
|
|
381
|
+
});
|
|
382
|
+
const TenantThreadIdParamsSchema = z.object({
|
|
383
|
+
tenantId: z.coerce.number().int(),
|
|
384
|
+
threadId: IdSchema,
|
|
385
|
+
});
|
|
386
|
+
const TenantPostIdParamsSchema = z.object({
|
|
387
|
+
tenantId: z.coerce.number().int(),
|
|
388
|
+
postId: IdSchema,
|
|
389
|
+
});
|
|
390
|
+
const TenantThreadPostIdParamsSchema = z.object({
|
|
391
|
+
tenantId: z.coerce.number().int(),
|
|
392
|
+
threadId: IdSchema,
|
|
393
|
+
postId: IdSchema,
|
|
394
|
+
});
|
|
395
|
+
const TenantGroupIdParamsSchema = z.object({
|
|
396
|
+
tenantId: z.coerce.number().int(),
|
|
397
|
+
groupId: IdSchema,
|
|
398
|
+
});
|
|
399
|
+
const TenantUserIdParamsSchema = z.object({
|
|
400
|
+
tenantId: z.coerce.number().int(),
|
|
401
|
+
userId: IdSchema,
|
|
402
|
+
});
|
|
403
|
+
const NotificationIdParamsSchema = z.object({
|
|
404
|
+
notificationId: IdSchema,
|
|
405
|
+
});
|
|
406
|
+
const MessageIdParamsSchema = z.object({
|
|
407
|
+
messageId: IdSchema,
|
|
408
|
+
});
|
|
409
|
+
const UserIdParamsSchema = z.object({
|
|
410
|
+
userId: IdSchema,
|
|
411
|
+
});
|
|
412
|
+
const KeyIdParamsSchema = z.object({
|
|
413
|
+
keyId: z.uuid(),
|
|
414
|
+
});
|
|
415
|
+
const PlatformSettingKeyParamsSchema = z.object({
|
|
416
|
+
key: z.string(),
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
const UserProfileSchema = z.object({
|
|
420
|
+
userId: IdSchema,
|
|
421
|
+
displayName: z.string(),
|
|
422
|
+
avatarUrl: z.url().nullable(),
|
|
423
|
+
updatedAt: z.iso.datetime(),
|
|
424
|
+
});
|
|
425
|
+
const UserMembershipSchema = z.object({
|
|
426
|
+
userId: IdSchema,
|
|
427
|
+
groups: z.array(z.object({ id: IdSchema, name: z.string() })),
|
|
428
|
+
});
|
|
429
|
+
const UpdateUserProfileSchema = z.object({
|
|
430
|
+
displayName: z
|
|
431
|
+
.string()
|
|
432
|
+
.min(3)
|
|
433
|
+
.max(30)
|
|
434
|
+
.regex(/^[\p{L}\p{N}_.\-']{3,30}$/u, 'name must contain only alphanumeric characters, underscores, and dots')
|
|
435
|
+
.optional(),
|
|
436
|
+
avatarUrl: z.url().nullable().optional(),
|
|
437
|
+
});
|
|
438
|
+
const UserSummarySchema = UserProfileSchema.pick({
|
|
439
|
+
userId: true,
|
|
440
|
+
displayName: true,
|
|
441
|
+
avatarUrl: true,
|
|
442
|
+
});
|
|
443
|
+
const GroupMemberSchema = UserSummarySchema.extend({
|
|
444
|
+
joinedAt: z.iso.datetime(),
|
|
445
|
+
});
|
|
446
|
+
const UserSearchResultSchema = z.object({
|
|
447
|
+
id: IdSchema,
|
|
448
|
+
displayName: z.string(),
|
|
449
|
+
avatarUrl: z.url().nullable(),
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
const CategorySchema = z.object({
|
|
453
|
+
id: IdSchema,
|
|
454
|
+
name: z.string(),
|
|
455
|
+
description: z.string().nullable(),
|
|
456
|
+
position: z.number().int(),
|
|
457
|
+
createdAt: z.iso.datetime(),
|
|
458
|
+
});
|
|
459
|
+
const CreateCategorySchema = z.object({
|
|
460
|
+
name: z.string().min(1).max(200),
|
|
461
|
+
description: z.string().max(1000).nullable().optional(),
|
|
462
|
+
});
|
|
463
|
+
const UpdateCategorySchema = CreateCategorySchema.partial();
|
|
464
|
+
const ReorderCategorySchema = z.array(z.object({ id: IdSchema, position: z.number().int().min(0) }));
|
|
465
|
+
|
|
466
|
+
const ForumSchema = z.object({
|
|
467
|
+
id: IdSchema,
|
|
468
|
+
categoryId: IdSchema,
|
|
469
|
+
name: z.string(),
|
|
470
|
+
description: z.string().nullable(),
|
|
471
|
+
position: z.number().int(),
|
|
472
|
+
threadCount: z.number().int(),
|
|
473
|
+
isHidden: z.boolean(),
|
|
474
|
+
createdAt: z.iso.datetime(),
|
|
475
|
+
});
|
|
476
|
+
const CreateForumSchema = z.object({
|
|
477
|
+
categoryId: IdSchema,
|
|
478
|
+
name: z.string().min(1).max(200),
|
|
479
|
+
description: z.string().max(1000).nullable().optional(),
|
|
480
|
+
isHidden: z.boolean().optional(),
|
|
481
|
+
});
|
|
482
|
+
const UpdateForumSchema = z.object({
|
|
483
|
+
name: z.string().min(1).max(200).optional(),
|
|
484
|
+
description: z.string().max(1000).nullable().optional(),
|
|
485
|
+
isHidden: z.boolean().optional(),
|
|
486
|
+
});
|
|
487
|
+
const ReorderForumSchema = z.array(z.object({ id: IdSchema, position: z.number().int().min(0) }));
|
|
488
|
+
|
|
489
|
+
const ThreadSchema = z.object({
|
|
490
|
+
id: IdSchema,
|
|
491
|
+
forumId: IdSchema,
|
|
492
|
+
title: z.string(),
|
|
493
|
+
authorId: IdSchema,
|
|
494
|
+
author: UserSummarySchema,
|
|
495
|
+
postCount: z.number().int(),
|
|
496
|
+
isPinned: z.boolean(),
|
|
497
|
+
isLocked: z.boolean(),
|
|
498
|
+
lastPostAt: z.iso.datetime().nullable(),
|
|
499
|
+
createdAt: z.iso.datetime(),
|
|
500
|
+
});
|
|
501
|
+
const CreateThreadSchema = z.object({
|
|
502
|
+
title: z.string().min(1).max(500),
|
|
503
|
+
content: z.string().min(1),
|
|
504
|
+
});
|
|
505
|
+
const UpdateThreadSchema = z.object({
|
|
506
|
+
title: z.string().min(1).max(500).optional(),
|
|
507
|
+
isPinned: z.boolean().optional(),
|
|
508
|
+
isLocked: z.boolean().optional(),
|
|
509
|
+
forumId: IdSchema.optional(),
|
|
510
|
+
});
|
|
511
|
+
const ThreadReadStatusSchema = z.object({
|
|
512
|
+
lastReadPostId: IdSchema.nullable(),
|
|
513
|
+
});
|
|
514
|
+
const SetThreadReadStatusSchema = z.object({
|
|
515
|
+
lastReadPostId: IdSchema,
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
const PostSchema = z.object({
|
|
519
|
+
id: IdSchema,
|
|
520
|
+
threadId: IdSchema,
|
|
521
|
+
authorId: IdSchema,
|
|
522
|
+
author: UserSummarySchema,
|
|
523
|
+
content: z.string().nullable(),
|
|
524
|
+
deletedAt: z.iso.datetime().nullable(),
|
|
525
|
+
createdAt: z.iso.datetime(),
|
|
526
|
+
updatedAt: z.iso.datetime(),
|
|
527
|
+
});
|
|
528
|
+
const CreatePostSchema = z.object({
|
|
529
|
+
content: z.string().min(1),
|
|
530
|
+
});
|
|
531
|
+
const UpdatePostSchema = z.object({
|
|
532
|
+
content: z.string().min(1),
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
const PostsQuerySchema = PaginationQuerySchema.extend({
|
|
536
|
+
from: IdSchema.optional(),
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
const PERMISSIONS = {
|
|
540
|
+
'thread.create': { isInternal: false },
|
|
541
|
+
'thread.manage': { isInternal: false },
|
|
542
|
+
'post.create': { isInternal: false },
|
|
543
|
+
'post.manage': { isInternal: false },
|
|
544
|
+
'category.manage': { isInternal: false },
|
|
545
|
+
'forum.manage': { isInternal: false },
|
|
546
|
+
'group.manage': { isInternal: false },
|
|
547
|
+
'group.manage_protected': { isInternal: true },
|
|
548
|
+
};
|
|
549
|
+
const allPermissionKeys = Object.keys(PERMISSIONS);
|
|
550
|
+
const assignablePermissionKeys = Object.entries(PERMISSIONS)
|
|
551
|
+
.filter(([, v]) => !v.isInternal)
|
|
552
|
+
.map(([k]) => k);
|
|
553
|
+
const PermissionSchema = z.enum(allPermissionKeys);
|
|
554
|
+
const AssignablePermissionSchema = z.enum(assignablePermissionKeys);
|
|
555
|
+
const GroupSchema = z.object({
|
|
556
|
+
id: IdSchema,
|
|
557
|
+
name: z.string(),
|
|
558
|
+
description: z.string().nullable(),
|
|
559
|
+
position: z.number().int(),
|
|
560
|
+
isProtected: z.boolean(),
|
|
561
|
+
permissions: z.array(PermissionSchema),
|
|
562
|
+
visibleForumIds: z.array(IdSchema),
|
|
563
|
+
});
|
|
564
|
+
const CreateGroupSchema = z.object({
|
|
565
|
+
name: z.string().min(1).max(100),
|
|
566
|
+
description: z.string().max(500).nullable().optional(),
|
|
567
|
+
});
|
|
568
|
+
const UpdateGroupSchema = CreateGroupSchema.partial();
|
|
569
|
+
const SetGroupPermissionsSchema = z.object({
|
|
570
|
+
permissions: z.array(AssignablePermissionSchema),
|
|
571
|
+
});
|
|
572
|
+
const SetGroupForumsSchema = z.object({
|
|
573
|
+
forumIds: z.array(IdSchema),
|
|
574
|
+
});
|
|
575
|
+
const SetUserGroupsSchema = z.object({
|
|
576
|
+
groupIds: z.array(IdSchema),
|
|
577
|
+
});
|
|
578
|
+
const ReorderGroupSchema = z.array(z.object({ id: IdSchema, position: z.number().int().min(0) }));
|
|
579
|
+
|
|
580
|
+
const NotificationTypeSchema = z.enum(['new_post']);
|
|
581
|
+
const NotificationSchema = z.object({
|
|
582
|
+
id: IdSchema,
|
|
583
|
+
userId: IdSchema,
|
|
584
|
+
tenantId: z.number().int(),
|
|
585
|
+
type: NotificationTypeSchema,
|
|
586
|
+
payload: z.record(z.string(), z.unknown()),
|
|
587
|
+
readAt: z.iso.datetime().nullable(),
|
|
588
|
+
createdAt: z.iso.datetime(),
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
const NotificationCountSchema = z.object({
|
|
592
|
+
read: z.number().int(),
|
|
593
|
+
unread: z.number().int(),
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
const MessageSchema = z.object({
|
|
597
|
+
id: IdSchema,
|
|
598
|
+
senderId: IdSchema,
|
|
599
|
+
recipientId: IdSchema,
|
|
600
|
+
tenantId: z.number().int().nullable(),
|
|
601
|
+
body: z.string().min(1).max(4000),
|
|
602
|
+
readAt: z.iso.datetime().nullable(),
|
|
603
|
+
createdAt: z.iso.datetime(),
|
|
604
|
+
});
|
|
605
|
+
const SendMessageBodySchema = z.object({
|
|
606
|
+
recipientId: IdSchema,
|
|
607
|
+
body: z.string().min(1).max(4000),
|
|
608
|
+
});
|
|
609
|
+
const ConversationSummarySchema = z.object({
|
|
610
|
+
userId: IdSchema,
|
|
611
|
+
lastMessage: MessageSchema,
|
|
612
|
+
unreadCount: z.number().int(),
|
|
613
|
+
});
|
|
614
|
+
const MessageCountSchema = z.object({
|
|
615
|
+
unread: z.number().int(),
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
const ApiKeySchema = z.object({
|
|
619
|
+
id: IdSchema,
|
|
620
|
+
name: z.string(),
|
|
621
|
+
lastUsedAt: z.iso.datetime().nullable(),
|
|
622
|
+
createdAt: z.iso.datetime(),
|
|
623
|
+
});
|
|
624
|
+
const CreatedApiKeySchema = ApiKeySchema.extend({
|
|
625
|
+
key: z.string(),
|
|
626
|
+
});
|
|
627
|
+
const CreateApiKeySchema = z.object({
|
|
628
|
+
name: z.string().min(1).max(100),
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
const SearchResultTypeSchema = z.enum(['thread', 'post']);
|
|
632
|
+
const SearchResultSchema = z.object({
|
|
633
|
+
type: SearchResultTypeSchema,
|
|
634
|
+
id: IdSchema,
|
|
635
|
+
threadId: IdSchema,
|
|
636
|
+
forumId: IdSchema,
|
|
637
|
+
title: z.string().nullable(),
|
|
638
|
+
excerpt: z.string(),
|
|
639
|
+
authorId: IdSchema,
|
|
640
|
+
createdAt: z.iso.datetime(),
|
|
641
|
+
});
|
|
642
|
+
const SearchQuerySchema = z.object({
|
|
643
|
+
q: z.string().min(1).max(500),
|
|
644
|
+
type: SearchResultTypeSchema.optional(),
|
|
645
|
+
categoryId: IdSchema.optional(),
|
|
646
|
+
limit: z.coerce.number().int().min(1).max(50).default(20),
|
|
647
|
+
});
|
|
648
|
+
const SearchResponseSchema = z.object({
|
|
649
|
+
results: z.array(SearchResultSchema),
|
|
650
|
+
total: z.number().int(),
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
const SLUG_REGEX = /^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/;
|
|
654
|
+
const SLUG_MESSAGE = 'slug must be lowercase alphanumeric with hyphens, no dots, no leading/trailing hyphens';
|
|
655
|
+
const HOSTNAME_REGEX = /^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)*[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
|
|
656
|
+
const HOSTNAME_MESSAGE = 'domain must be a valid hostname';
|
|
657
|
+
const TenantSchema = z.object({
|
|
658
|
+
id: z.number().int(),
|
|
659
|
+
name: z.string(),
|
|
660
|
+
slug: z.string(),
|
|
661
|
+
customDomain: z.string().nullable(),
|
|
662
|
+
createdAt: z.string(),
|
|
663
|
+
});
|
|
664
|
+
const CreateTenantSchema = z.object({
|
|
665
|
+
name: z.string().min(1).max(100),
|
|
666
|
+
slug: z.string().min(1).max(63).regex(SLUG_REGEX, SLUG_MESSAGE),
|
|
667
|
+
});
|
|
668
|
+
const UpdateTenantSchema = z
|
|
669
|
+
.object({
|
|
670
|
+
name: z.string().min(1).max(100).optional(),
|
|
671
|
+
slug: z.string().min(1).max(63).regex(SLUG_REGEX, SLUG_MESSAGE).optional(),
|
|
672
|
+
customDomain: z
|
|
673
|
+
.string()
|
|
674
|
+
.min(1)
|
|
675
|
+
.regex(HOSTNAME_REGEX, HOSTNAME_MESSAGE)
|
|
676
|
+
.nullable()
|
|
677
|
+
.optional(),
|
|
678
|
+
})
|
|
679
|
+
.refine((data) => Object.keys(data).length > 0, {
|
|
680
|
+
message: 'at least one field must be provided',
|
|
681
|
+
});
|
|
682
|
+
const OwnedTenantSchema = z.object({
|
|
683
|
+
id: z.number().int(),
|
|
684
|
+
name: z.string(),
|
|
685
|
+
slug: z.string(),
|
|
686
|
+
customDomain: z.string().nullable(),
|
|
687
|
+
});
|
|
688
|
+
const TenantOptionsSchema = z.object({
|
|
689
|
+
allowedUnsafeMethods: z.object({
|
|
690
|
+
notifications: z.boolean(),
|
|
691
|
+
profile: z.boolean(),
|
|
692
|
+
}),
|
|
693
|
+
customOptions: z.record(z.string(), z.unknown()),
|
|
694
|
+
});
|
|
695
|
+
const SetTenantOptionsSchema = z.object({
|
|
696
|
+
customOptions: z.record(z.string(), z.unknown()),
|
|
697
|
+
});
|
|
698
|
+
const TenantTokenSchema = z.object({
|
|
699
|
+
token: z.string(),
|
|
700
|
+
expiresIn: z.number().int(),
|
|
701
|
+
payload: z.object({
|
|
702
|
+
userId: z.string(),
|
|
703
|
+
tenantId: z.number().int(),
|
|
704
|
+
}),
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
const TenantOwnerSchema = z.object({
|
|
708
|
+
userId: z.string().nullable(),
|
|
709
|
+
});
|
|
710
|
+
const TransferTenantOwnerSchema = z.object({
|
|
711
|
+
userId: z.string(),
|
|
712
|
+
});
|
|
713
|
+
|
|
714
|
+
z.record(z.string(), z.string()).optional();
|
|
715
|
+
const BackupCategorySchema = z.object({
|
|
716
|
+
id: z.string(),
|
|
717
|
+
name: z.string(),
|
|
718
|
+
description: z.string().nullable(),
|
|
719
|
+
position: z.number().int(),
|
|
720
|
+
});
|
|
721
|
+
const BackupGroupSchema = z.object({
|
|
722
|
+
id: z.string(),
|
|
723
|
+
name: z.string(),
|
|
724
|
+
description: z.string().nullable(),
|
|
725
|
+
position: z.number().int(),
|
|
726
|
+
permissions: z.array(z.string()),
|
|
727
|
+
visibleForumIds: z.array(z.string()),
|
|
728
|
+
});
|
|
729
|
+
const BackupMembershipSchema = z.object({
|
|
730
|
+
userId: z.string(),
|
|
731
|
+
groupId: z.string(),
|
|
732
|
+
});
|
|
733
|
+
const BackupThreadSchema = z.object({
|
|
734
|
+
id: z.string(),
|
|
735
|
+
forumId: z.string(),
|
|
736
|
+
title: z.string(),
|
|
737
|
+
authorId: z.string(),
|
|
738
|
+
isPinned: z.boolean(),
|
|
739
|
+
isLocked: z.boolean(),
|
|
740
|
+
lastPostAt: z.string().nullable(),
|
|
741
|
+
createdAt: z.string(),
|
|
742
|
+
});
|
|
743
|
+
const BackupPostSchema = z.object({
|
|
744
|
+
id: z.string(),
|
|
745
|
+
threadId: z.string(),
|
|
746
|
+
authorId: z.string(),
|
|
747
|
+
content: z.string().nullable(),
|
|
748
|
+
createdAt: z.string(),
|
|
749
|
+
updatedAt: z.string(),
|
|
750
|
+
});
|
|
751
|
+
const BackupDataSchema = z.object({
|
|
752
|
+
settings: z.record(z.string(), z.string()).optional(),
|
|
753
|
+
categories: z.array(BackupCategorySchema),
|
|
754
|
+
groups: z.array(BackupGroupSchema),
|
|
755
|
+
memberships: z.array(BackupMembershipSchema),
|
|
756
|
+
threads: z.array(BackupThreadSchema),
|
|
757
|
+
posts: z.array(BackupPostSchema),
|
|
758
|
+
});
|
|
759
|
+
const BackupPayloadSchema = z.object({
|
|
760
|
+
version: z.literal(1),
|
|
761
|
+
exportedAt: z.string(),
|
|
762
|
+
sourceTenantId: z.number().int(),
|
|
763
|
+
includeContent: z.boolean(),
|
|
764
|
+
data: BackupDataSchema,
|
|
765
|
+
signature: z.string(),
|
|
766
|
+
});
|
|
767
|
+
const TenantBackupSchema = BackupPayloadSchema;
|
|
768
|
+
const BackupQuerySchema = z.object({
|
|
769
|
+
includeContent: z.coerce.boolean().default(false),
|
|
770
|
+
});
|
|
771
|
+
|
|
772
|
+
const RestoreTenantSchema = z.object({
|
|
773
|
+
payload: BackupPayloadSchema,
|
|
774
|
+
includeContent: z.boolean(),
|
|
775
|
+
force: z.boolean().default(false),
|
|
776
|
+
});
|
|
777
|
+
const RestoreTenantResponseSchema = z.object({
|
|
778
|
+
signatureValid: z.boolean(),
|
|
779
|
+
});
|
|
780
|
+
const RestoreErrorSchema = z.object({
|
|
781
|
+
code: z.string(),
|
|
782
|
+
message: z.string(),
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
const PlatformSettingSchema = z.object({
|
|
786
|
+
key: z.string(),
|
|
787
|
+
value: z.unknown(),
|
|
788
|
+
updatedAt: z.iso.datetime(),
|
|
789
|
+
});
|
|
790
|
+
const UpdatePlatformSettingSchema = z.object({
|
|
791
|
+
value: z.unknown(),
|
|
792
|
+
});
|
|
793
|
+
const GrantPlatformOwnerSchema = z.object({
|
|
794
|
+
userId: z.uuid(),
|
|
795
|
+
});
|
|
796
|
+
|
|
797
|
+
export { ApiKeySchema, AssignablePermissionSchema, BackupPayloadSchema, BackupQuerySchema, CategorySchema, ConversationSummarySchema, CreateApiKeySchema, CreateCategorySchema, CreateForumSchema, CreateGroupSchema, CreatePostSchema, CreateTenantSchema, CreateThreadSchema, CreatedApiKeySchema, ErrorSchema, ForumSchema, GrantPlatformOwnerSchema, GroupMemberSchema, GroupSchema, IdSchema, KeyIdParamsSchema, MessageCountSchema, MessageIdParamsSchema, MessageSchema, NotificationCountSchema, NotificationIdParamsSchema, NotificationSchema, NotificationTypeSchema, OwnedTenantSchema, PERMISSIONS, PaginatedResponseSchema, PaginationQuerySchema, PermissionSchema, PlatformSettingKeyParamsSchema, PlatformSettingSchema, PostSchema, PostsQuerySchema, ReorderCategorySchema, ReorderForumSchema, ReorderGroupSchema, RestoreErrorSchema, RestoreTenantResponseSchema, RestoreTenantSchema, RoundtableClient, SearchQuerySchema, SearchResponseSchema, SearchResultSchema, SearchResultTypeSchema, SendMessageBodySchema, SetGroupForumsSchema, SetGroupPermissionsSchema, SetTenantOptionsSchema, SetThreadReadStatusSchema, SetUserGroupsSchema, TenantBackupSchema, TenantCategoryIdParamsSchema, TenantForumIdParamsSchema, TenantGroupIdParamsSchema, TenantIdParamsSchema, TenantOptionsSchema, TenantOwnerSchema, TenantPostIdParamsSchema, TenantSchema, TenantThreadIdParamsSchema, TenantThreadPostIdParamsSchema, TenantTokenSchema, TenantUserIdParamsSchema, ThreadReadStatusSchema, ThreadSchema, TransferTenantOwnerSchema, UpdateCategorySchema, UpdateForumSchema, UpdateGroupSchema, UpdatePlatformSettingSchema, UpdatePostSchema, UpdateTenantSchema, UpdateThreadSchema, UpdateUserProfileSchema, UserIdParamsSchema, UserMembershipSchema, UserProfileSchema, UserSearchResultSchema, UserSummarySchema };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roundtable-bb/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.37",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"esbuild": "*",
|
|
21
21
|
"rollup": "^4.62.4",
|
|
22
22
|
"rollup-plugin-dts": "^6.5.1",
|
|
23
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
23
24
|
"@roundtable-bb/types": "*"
|
|
24
25
|
},
|
|
25
26
|
"peerDependencies": {
|
package/dist/generated/client.js
DELETED
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
// AUTO-GENERATED — do not edit manually.
|
|
2
|
-
// Run `nx run @roundtable-bb/sdk:codegen` to regenerate.
|
|
3
|
-
import { request } from '../request.js';
|
|
4
|
-
export class RoundtableClient {
|
|
5
|
-
opts;
|
|
6
|
-
constructor(opts) {
|
|
7
|
-
this.opts = opts;
|
|
8
|
-
}
|
|
9
|
-
/** Export a signed tenant backup (platform owners only) */
|
|
10
|
-
backupTenant(params, query, options) {
|
|
11
|
-
return request(this.opts, 'GET', `/tenants/${params.tenantId}/backup`, { ...options, query, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
12
|
-
}
|
|
13
|
-
/** Count read and unread notifications */
|
|
14
|
-
countNotifications(options) {
|
|
15
|
-
return request(this.opts, 'GET', '/notifications/count', { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
16
|
-
}
|
|
17
|
-
/** Count unread private messages */
|
|
18
|
-
countUnreadMessages(options) {
|
|
19
|
-
return request(this.opts, 'GET', '/messages/count', { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
20
|
-
}
|
|
21
|
-
/** Create a platform-scoped API key (returned once in full) */
|
|
22
|
-
createApiKey(body, options) {
|
|
23
|
-
return request(this.opts, 'POST', '/platform/api-keys', { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
24
|
-
}
|
|
25
|
-
/** Create a category (requires category.manage permission) */
|
|
26
|
-
createCategory(params, body, options) {
|
|
27
|
-
return request(this.opts, 'POST', `/tenants/${params.tenantId}/categories`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
28
|
-
}
|
|
29
|
-
/** Create a forum (requires forum.manage permission) */
|
|
30
|
-
createForum(params, body, options) {
|
|
31
|
-
return request(this.opts, 'POST', `/tenants/${params.tenantId}/forums`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
32
|
-
}
|
|
33
|
-
/** Create a group (requires group.manage permission) */
|
|
34
|
-
createGroup(params, body, options) {
|
|
35
|
-
return request(this.opts, 'POST', `/tenants/${params.tenantId}/groups`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
36
|
-
}
|
|
37
|
-
/** Create a post in a thread */
|
|
38
|
-
createPost(params, body, options) {
|
|
39
|
-
return request(this.opts, 'POST', `/tenants/${params.tenantId}/threads/${params.threadId}/posts`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
40
|
-
}
|
|
41
|
-
/** Create a new tenant (requires allow_tenant_creation platform setting or platform owner) */
|
|
42
|
-
createTenant(body, options) {
|
|
43
|
-
return request(this.opts, 'POST', '/tenants', { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
44
|
-
}
|
|
45
|
-
/** Create a thread (and its first post) */
|
|
46
|
-
createThread(params, body, options) {
|
|
47
|
-
return request(this.opts, 'POST', `/tenants/${params.tenantId}/forums/${params.forumId}/threads`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
48
|
-
}
|
|
49
|
-
/** Delete a platform-scoped API key */
|
|
50
|
-
deleteApiKey(params, options) {
|
|
51
|
-
return request(this.opts, 'DELETE', `/platform/api-keys/${params.keyId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
52
|
-
}
|
|
53
|
-
/** Delete a category (requires category.manage permission) */
|
|
54
|
-
deleteCategory(params, options) {
|
|
55
|
-
return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/categories/${params.categoryId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
56
|
-
}
|
|
57
|
-
/** Delete a forum (requires forum.manage permission) */
|
|
58
|
-
deleteForum(params, options) {
|
|
59
|
-
return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/forums/${params.forumId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
60
|
-
}
|
|
61
|
-
/** Delete a group (requires group.manage permission) */
|
|
62
|
-
deleteGroup(params, options) {
|
|
63
|
-
return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/groups/${params.groupId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
64
|
-
}
|
|
65
|
-
/** Delete a private message */
|
|
66
|
-
deleteMessage(params, options) {
|
|
67
|
-
return request(this.opts, 'DELETE', `/messages/${params.messageId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
68
|
-
}
|
|
69
|
-
/** Delete a notification */
|
|
70
|
-
deleteNotification(params, options) {
|
|
71
|
-
return request(this.opts, 'DELETE', `/notifications/${params.notificationId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
72
|
-
}
|
|
73
|
-
/** Soft-delete a post */
|
|
74
|
-
deletePost(params, options) {
|
|
75
|
-
return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/posts/${params.postId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
76
|
-
}
|
|
77
|
-
/** Permanently delete a tenant and all its data (platform owners only) */
|
|
78
|
-
deleteTenant(params, options) {
|
|
79
|
-
return request(this.opts, 'DELETE', `/tenants/${params.tenantId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
80
|
-
}
|
|
81
|
-
/** Delete a thread */
|
|
82
|
-
deleteThread(params, options) {
|
|
83
|
-
return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/threads/${params.threadId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
84
|
-
}
|
|
85
|
-
/** Exchange session cookie for a short-lived tenant JWT */
|
|
86
|
-
exchangeTenantToken(options) {
|
|
87
|
-
return request(this.opts, 'POST', '/tenant-token', { ...options, routeAuth: { acceptsBetterAuth: true } });
|
|
88
|
-
}
|
|
89
|
-
/** Get a single category */
|
|
90
|
-
getCategory(params, options) {
|
|
91
|
-
return request(this.opts, 'GET', `/tenants/${params.tenantId}/categories/${params.categoryId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
92
|
-
}
|
|
93
|
-
/** Get a single forum */
|
|
94
|
-
getForum(params, options) {
|
|
95
|
-
return request(this.opts, 'GET', `/tenants/${params.tenantId}/forums/${params.forumId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
96
|
-
}
|
|
97
|
-
/** Get a group */
|
|
98
|
-
getGroup(params, options) {
|
|
99
|
-
return request(this.opts, 'GET', `/tenants/${params.tenantId}/groups/${params.groupId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
100
|
-
}
|
|
101
|
-
/** Get own profile */
|
|
102
|
-
getMe(options) {
|
|
103
|
-
return request(this.opts, 'GET', '/users/me', { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
104
|
-
}
|
|
105
|
-
/** Get tenant options and unsafe methods allowed */
|
|
106
|
-
getTenantOptions(params, options) {
|
|
107
|
-
return request(this.opts, 'GET', `/tenants/${params.tenantId}/options`, { ...options });
|
|
108
|
-
}
|
|
109
|
-
/** Get the current owner of a tenant */
|
|
110
|
-
getTenantOwner(params, options) {
|
|
111
|
-
return request(this.opts, 'GET', `/tenants/${params.tenantId}/owner`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
112
|
-
}
|
|
113
|
-
/** Get a single thread */
|
|
114
|
-
getThread(params, options) {
|
|
115
|
-
return request(this.opts, 'GET', `/tenants/${params.tenantId}/threads/${params.threadId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
116
|
-
}
|
|
117
|
-
/** Get read status for the current user in a thread */
|
|
118
|
-
getThreadReadStatus(params, options) {
|
|
119
|
-
return request(this.opts, 'GET', `/tenants/${params.tenantId}/threads/${params.threadId}/read-status`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
120
|
-
}
|
|
121
|
-
/** Get a user profile by ID */
|
|
122
|
-
getUser(params, options) {
|
|
123
|
-
return request(this.opts, 'GET', `/users/${params.userId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
124
|
-
}
|
|
125
|
-
/** Get user group memberships in the current tenant */
|
|
126
|
-
getUserMembership(params, options) {
|
|
127
|
-
return request(this.opts, 'GET', `/tenants/${params.tenantId}/users/${params.userId}/membership`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
128
|
-
}
|
|
129
|
-
/** Grant platform owner status to a user (platform owners only) */
|
|
130
|
-
grantPlatformOwner(body, options) {
|
|
131
|
-
return request(this.opts, 'POST', '/platform/owners', { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
132
|
-
}
|
|
133
|
-
/** List your platform-scoped API keys */
|
|
134
|
-
listApiKeys(options) {
|
|
135
|
-
return request(this.opts, 'GET', '/platform/api-keys', { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
136
|
-
}
|
|
137
|
-
/** List visible categories for the requesting user */
|
|
138
|
-
listCategories(params, options) {
|
|
139
|
-
return request(this.opts, 'GET', `/tenants/${params.tenantId}/categories`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
140
|
-
}
|
|
141
|
-
/** List messages exchanged with a specific user */
|
|
142
|
-
listConversationMessages(params, query, options) {
|
|
143
|
-
return request(this.opts, 'GET', `/messages/conversations/${params.userId}`, { ...options, query, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
144
|
-
}
|
|
145
|
-
/** List conversations for the current user */
|
|
146
|
-
listConversations(options) {
|
|
147
|
-
return request(this.opts, 'GET', '/messages/conversations', { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
148
|
-
}
|
|
149
|
-
/** List visible forums for the requesting user */
|
|
150
|
-
listForums(params, options) {
|
|
151
|
-
return request(this.opts, 'GET', `/tenants/${params.tenantId}/forums`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
152
|
-
}
|
|
153
|
-
/** List members of a group */
|
|
154
|
-
listGroupMembers(params, options) {
|
|
155
|
-
return request(this.opts, 'GET', `/tenants/${params.tenantId}/groups/${params.groupId}/members`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
156
|
-
}
|
|
157
|
-
/** List groups */
|
|
158
|
-
listGroups(params, options) {
|
|
159
|
-
return request(this.opts, 'GET', `/tenants/${params.tenantId}/groups`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
160
|
-
}
|
|
161
|
-
/** Get unified notification inbox */
|
|
162
|
-
listNotifications(query, options) {
|
|
163
|
-
return request(this.opts, 'GET', '/notifications', { ...options, query, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
164
|
-
}
|
|
165
|
-
/** List platform owner user IDs (platform owners only) */
|
|
166
|
-
listPlatformOwners(options) {
|
|
167
|
-
return request(this.opts, 'GET', '/platform/owners', { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
168
|
-
}
|
|
169
|
-
/** List all platform settings (platform owners only) */
|
|
170
|
-
listPlatformSettings(options) {
|
|
171
|
-
return request(this.opts, 'GET', '/platform/settings', { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
172
|
-
}
|
|
173
|
-
/** List posts in a thread — cursor pagination or anchor via ?from=postId */
|
|
174
|
-
listPosts(params, query, options) {
|
|
175
|
-
return request(this.opts, 'GET', `/tenants/${params.tenantId}/threads/${params.threadId}/posts`, { ...options, query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
176
|
-
}
|
|
177
|
-
/** List tenants owned by the current user (platform owners see all) */
|
|
178
|
-
listTenants(query, options) {
|
|
179
|
-
return request(this.opts, 'GET', '/tenants', { ...options, query, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
180
|
-
}
|
|
181
|
-
/** List threads in a forum */
|
|
182
|
-
listThreads(params, query, options) {
|
|
183
|
-
return request(this.opts, 'GET', `/tenants/${params.tenantId}/forums/${params.forumId}/threads`, { ...options, query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
184
|
-
}
|
|
185
|
-
/** Mark all notifications as read */
|
|
186
|
-
markAllNotificationRead(options) {
|
|
187
|
-
return request(this.opts, 'POST', '/notifications/read-all', { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
188
|
-
}
|
|
189
|
-
/** Mark all messages from a user as read */
|
|
190
|
-
markConversationRead(params, options) {
|
|
191
|
-
return request(this.opts, 'PATCH', `/messages/conversations/${params.userId}/read`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
192
|
-
}
|
|
193
|
-
/** Mark a message as read */
|
|
194
|
-
markMessageRead(params, options) {
|
|
195
|
-
return request(this.opts, 'PATCH', `/messages/${params.messageId}/read`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
196
|
-
}
|
|
197
|
-
/** Mark a notification as read */
|
|
198
|
-
markNotificationRead(params, options) {
|
|
199
|
-
return request(this.opts, 'PATCH', `/notifications/${params.notificationId}/read`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
200
|
-
}
|
|
201
|
-
/** Set tenant options */
|
|
202
|
-
putTenantOptions(params, body, options) {
|
|
203
|
-
return request(this.opts, 'PUT', `/tenants/${params.tenantId}/options`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
204
|
-
}
|
|
205
|
-
/** Set the position of each category (requires category.manage permission) */
|
|
206
|
-
reorderCategories(params, body, options) {
|
|
207
|
-
return request(this.opts, 'PUT', `/tenants/${params.tenantId}/categories/reorder`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
208
|
-
}
|
|
209
|
-
/** Set the position of each forum (requires forum.manage permission) */
|
|
210
|
-
reorderForums(params, body, options) {
|
|
211
|
-
return request(this.opts, 'PUT', `/tenants/${params.tenantId}/forums/reorder`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
212
|
-
}
|
|
213
|
-
/** Set the position of each group (requires group.manage permission) */
|
|
214
|
-
reorderGroups(params, body, options) {
|
|
215
|
-
return request(this.opts, 'PUT', `/tenants/${params.tenantId}/groups/reorder`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
216
|
-
}
|
|
217
|
-
/** Restore a tenant from a signed backup (platform owners only) */
|
|
218
|
-
restoreTenant(params, body, options) {
|
|
219
|
-
return request(this.opts, 'POST', `/tenants/${params.tenantId}/restore`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
220
|
-
}
|
|
221
|
-
/** Revoke platform owner status from a user (platform owners only) */
|
|
222
|
-
revokePlatformOwner(params, options) {
|
|
223
|
-
return request(this.opts, 'DELETE', `/platform/owners/${params.userId}`, { ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
224
|
-
}
|
|
225
|
-
/** Full-text search across threads and posts (visible categories only) */
|
|
226
|
-
search(params, query, options) {
|
|
227
|
-
return request(this.opts, 'GET', `/tenants/${params.tenantId}/search`, { ...options, query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
228
|
-
}
|
|
229
|
-
/** Search users by display name or email (case-insensitive) */
|
|
230
|
-
searchUsers(query, options) {
|
|
231
|
-
return request(this.opts, 'GET', '/users/search', { ...options, query, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
232
|
-
}
|
|
233
|
-
/** Send a private message to another user */
|
|
234
|
-
sendMessage(body, options) {
|
|
235
|
-
return request(this.opts, 'POST', '/messages', { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
236
|
-
}
|
|
237
|
-
/** Set forum visibility for a group (requires group.manage or group.manage_protected permission) */
|
|
238
|
-
setGroupForums(params, body, options) {
|
|
239
|
-
return request(this.opts, 'PUT', `/tenants/${params.tenantId}/groups/${params.groupId}/forums`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
240
|
-
}
|
|
241
|
-
/** Replace all permissions for a group (requires group.manage permission) */
|
|
242
|
-
setGroupPermissions(params, body, options) {
|
|
243
|
-
return request(this.opts, 'PUT', `/tenants/${params.tenantId}/groups/${params.groupId}/permissions`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
244
|
-
}
|
|
245
|
-
/** Mark a thread as read up to a given post */
|
|
246
|
-
setThreadReadStatus(params, body, options) {
|
|
247
|
-
return request(this.opts, 'PUT', `/tenants/${params.tenantId}/threads/${params.threadId}/read-status`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
248
|
-
}
|
|
249
|
-
/** Replace user group assignments in the current tenant (requires group.manage permission) */
|
|
250
|
-
setUserGroups(params, body, options) {
|
|
251
|
-
return request(this.opts, 'PUT', `/tenants/${params.tenantId}/users/${params.userId}/membership`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
252
|
-
}
|
|
253
|
-
/** Subscribe to a thread */
|
|
254
|
-
subscribeThread(params, options) {
|
|
255
|
-
return request(this.opts, 'POST', `/tenants/${params.tenantId}/threads/${params.threadId}/subscribe`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
256
|
-
}
|
|
257
|
-
/** Transfer tenant ownership to another existing user (only the current owner can do this) */
|
|
258
|
-
transferTenantOwner(params, body, options) {
|
|
259
|
-
return request(this.opts, 'PUT', `/tenants/${params.tenantId}/owner`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
260
|
-
}
|
|
261
|
-
/** Unsubscribe from a thread */
|
|
262
|
-
unsubscribeThread(params, options) {
|
|
263
|
-
return request(this.opts, 'DELETE', `/tenants/${params.tenantId}/threads/${params.threadId}/subscribe`, { ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
264
|
-
}
|
|
265
|
-
/** Update a category (requires category.manage permission) */
|
|
266
|
-
updateCategory(params, body, options) {
|
|
267
|
-
return request(this.opts, 'PATCH', `/tenants/${params.tenantId}/categories/${params.categoryId}`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
268
|
-
}
|
|
269
|
-
/** Update a forum (requires forum.manage permission) */
|
|
270
|
-
updateForum(params, body, options) {
|
|
271
|
-
return request(this.opts, 'PATCH', `/tenants/${params.tenantId}/forums/${params.forumId}`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
272
|
-
}
|
|
273
|
-
/** Update a group (requires group.manage permission) */
|
|
274
|
-
updateGroup(params, body, options) {
|
|
275
|
-
return request(this.opts, 'PATCH', `/tenants/${params.tenantId}/groups/${params.groupId}`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
276
|
-
}
|
|
277
|
-
/** Update own profile */
|
|
278
|
-
updateMe(body, options) {
|
|
279
|
-
return request(this.opts, 'PATCH', '/users/me', { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
280
|
-
}
|
|
281
|
-
/** Update a platform setting (platform owners only) */
|
|
282
|
-
updatePlatformSetting(params, body, options) {
|
|
283
|
-
return request(this.opts, 'PATCH', `/platform/settings/${params.key}`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
284
|
-
}
|
|
285
|
-
/** Edit a post (author or post.edit permission) */
|
|
286
|
-
updatePost(params, body, options) {
|
|
287
|
-
return request(this.opts, 'PATCH', `/tenants/${params.tenantId}/posts/${params.postId}`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
288
|
-
}
|
|
289
|
-
/** Update a tenant's name, slug, or custom domain (tenant owner or platform owner) */
|
|
290
|
-
updateTenant(params, body, options) {
|
|
291
|
-
return request(this.opts, 'PATCH', `/tenants/${params.tenantId}`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
292
|
-
}
|
|
293
|
-
/** Update a thread (title, pin, lock, move) */
|
|
294
|
-
updateThread(params, body, options) {
|
|
295
|
-
return request(this.opts, 'PATCH', `/tenants/${params.tenantId}/threads/${params.threadId}`, { body, ...options, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
296
|
-
}
|
|
297
|
-
}
|
package/dist/request.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
export async function request(opts, method, path, options) {
|
|
2
|
-
const routeAuth = options?.routeAuth;
|
|
3
|
-
const authMethod = options?.authMethod;
|
|
4
|
-
let token;
|
|
5
|
-
let useCredentials = false;
|
|
6
|
-
if (authMethod) {
|
|
7
|
-
if (authMethod === 'apiKey') {
|
|
8
|
-
if (!opts.apiKey)
|
|
9
|
-
throw new Error('authMethod: apiKey is not configured');
|
|
10
|
-
token = opts.apiKey;
|
|
11
|
-
}
|
|
12
|
-
else if (authMethod === 'tenantToken') {
|
|
13
|
-
if (!opts.tenantToken)
|
|
14
|
-
throw new Error('authMethod: tenantToken is not configured');
|
|
15
|
-
token = opts.tenantToken;
|
|
16
|
-
}
|
|
17
|
-
else if (authMethod === 'betterAuth') {
|
|
18
|
-
useCredentials = true;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
else if (routeAuth) {
|
|
22
|
-
if (opts.apiKey && routeAuth.acceptsApiKey) {
|
|
23
|
-
token = opts.apiKey;
|
|
24
|
-
}
|
|
25
|
-
else if (opts.tenantToken && routeAuth.acceptsTenantJwt) {
|
|
26
|
-
token = opts.tenantToken;
|
|
27
|
-
}
|
|
28
|
-
else if (routeAuth.acceptsBetterAuth) {
|
|
29
|
-
useCredentials = true;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const url = new URL(`${opts.baseURL}${path}`);
|
|
33
|
-
if (options?.query) {
|
|
34
|
-
for (const [k, v] of Object.entries(options.query)) {
|
|
35
|
-
if (v !== undefined && v !== null)
|
|
36
|
-
url.searchParams.set(k, String(v));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const res = await fetch(url.toString(), {
|
|
40
|
-
method,
|
|
41
|
-
credentials: useCredentials ? 'include' : undefined,
|
|
42
|
-
headers: {
|
|
43
|
-
...(options?.body !== undefined ? { 'Content-Type': 'application/json' } : {}),
|
|
44
|
-
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
|
45
|
-
},
|
|
46
|
-
body: options?.body !== undefined ? JSON.stringify(options.body) : undefined,
|
|
47
|
-
});
|
|
48
|
-
if (res.status === 204)
|
|
49
|
-
return undefined;
|
|
50
|
-
if (!res.ok) {
|
|
51
|
-
const err = await res.json().catch(() => ({ message: res.statusText }));
|
|
52
|
-
const msg = err.message ?? res.statusText;
|
|
53
|
-
throw Object.assign(new Error(msg), { status: res.status });
|
|
54
|
-
}
|
|
55
|
-
return (await res.json());
|
|
56
|
-
}
|