@roundtable-bb/sdk 0.1.5 → 0.1.9
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/README.md +1 -1
- package/dist/generated/client.d.ts +211 -38
- package/dist/generated/client.d.ts.map +1 -1
- package/dist/generated/client.js +173 -113
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/request.d.ts +9 -0
- package/dist/request.d.ts.map +1 -1
- package/dist/request.js +20 -2
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +4 -2
- package/src/generated/client.ts +232 -120
- package/src/index.ts +1 -1
- package/src/request.ts +36 -3
package/dist/generated/client.js
CHANGED
|
@@ -1,267 +1,327 @@
|
|
|
1
1
|
// AUTO-GENERATED — do not edit manually.
|
|
2
2
|
// Run `nx run @roundtable-bb/sdk:codegen` to regenerate.
|
|
3
3
|
import { request } from '../request.js';
|
|
4
|
-
export class
|
|
4
|
+
export class AcpClient {
|
|
5
5
|
opts;
|
|
6
6
|
constructor(opts) {
|
|
7
7
|
this.opts = opts;
|
|
8
8
|
}
|
|
9
9
|
/** Export a signed tenant backup (platform owners only) */
|
|
10
10
|
backupTenant(params, query) {
|
|
11
|
-
return request(this.opts, 'GET', `/tenants/${params.
|
|
11
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/backup`, { query, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
12
12
|
}
|
|
13
13
|
/** Count read and unread notifications */
|
|
14
14
|
countNotifications() {
|
|
15
|
-
return request(this.opts, 'GET', '/notifications/count', {
|
|
15
|
+
return request(this.opts, 'GET', '/api/notifications/count', { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
16
16
|
}
|
|
17
17
|
/** Create a platform-scoped API key (returned once in full) */
|
|
18
18
|
createApiKey(body) {
|
|
19
|
-
return request(this.opts, 'POST', '/platform/api-keys', { body,
|
|
19
|
+
return request(this.opts, 'POST', '/api/platform/api-keys', { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
20
20
|
}
|
|
21
21
|
/** Create a category (requires category.create permission) */
|
|
22
|
-
createCategory(body) {
|
|
23
|
-
return request(this.opts, 'POST',
|
|
22
|
+
createCategory(params, body) {
|
|
23
|
+
return request(this.opts, 'POST', `/api/tenants/${params.tenantId}/categories`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
24
24
|
}
|
|
25
25
|
/** Create a group (requires group.create permission) */
|
|
26
|
-
createGroup(body) {
|
|
27
|
-
return request(this.opts, 'POST',
|
|
26
|
+
createGroup(params, body) {
|
|
27
|
+
return request(this.opts, 'POST', `/api/tenants/${params.tenantId}/groups`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
28
28
|
}
|
|
29
29
|
/** Create a post in a thread */
|
|
30
30
|
createPost(params, body) {
|
|
31
|
-
|
|
32
|
-
throw new Error('createPost requires a token (API key or JWT)');
|
|
33
|
-
return request(this.opts, 'POST', `/threads/${params.threadId}/posts`, { body });
|
|
31
|
+
return request(this.opts, 'POST', `/api/tenants/${params.tenantId}/threads/${params.threadId}/posts`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
34
32
|
}
|
|
35
33
|
/** Create a new tenant (requires allow_tenant_creation platform setting or platform owner) */
|
|
36
34
|
createTenant(body) {
|
|
37
|
-
return request(this.opts, 'POST', '/tenants', { body,
|
|
35
|
+
return request(this.opts, 'POST', '/api/tenants', { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
38
36
|
}
|
|
39
37
|
/** Create a thread (and its first post) */
|
|
40
38
|
createThread(params, body) {
|
|
41
|
-
|
|
42
|
-
throw new Error('createThread requires a token (API key or JWT)');
|
|
43
|
-
return request(this.opts, 'POST', `/categories/${params.categoryId}/threads`, { body });
|
|
39
|
+
return request(this.opts, 'POST', `/api/tenants/${params.tenantId}/categories/${params.categoryId}/threads`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
44
40
|
}
|
|
45
41
|
/** Delete a platform-scoped API key */
|
|
46
42
|
deleteApiKey(params) {
|
|
47
|
-
return request(this.opts, 'DELETE', `/platform/api-keys/${params.
|
|
43
|
+
return request(this.opts, 'DELETE', `/api/platform/api-keys/${params.keyId}`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
48
44
|
}
|
|
49
45
|
/** Delete a category (requires category.delete permission) */
|
|
50
46
|
deleteCategory(params) {
|
|
51
|
-
return request(this.opts, 'DELETE', `/categories/${params.
|
|
47
|
+
return request(this.opts, 'DELETE', `/api/tenants/${params.tenantId}/categories/${params.categoryId}`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
52
48
|
}
|
|
53
49
|
/** Delete a group (requires group.delete permission) */
|
|
54
50
|
deleteGroup(params) {
|
|
55
|
-
return request(this.opts, 'DELETE', `/groups/${params.
|
|
51
|
+
return request(this.opts, 'DELETE', `/api/tenants/${params.tenantId}/groups/${params.groupId}`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
56
52
|
}
|
|
57
53
|
/** Delete a notification */
|
|
58
54
|
deleteNotification(params) {
|
|
59
|
-
return request(this.opts, 'DELETE', `/notifications/${params.
|
|
55
|
+
return request(this.opts, 'DELETE', `/api/notifications/${params.notificationId}`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
60
56
|
}
|
|
61
57
|
/** Soft-delete a post */
|
|
62
58
|
deletePost(params) {
|
|
63
|
-
|
|
64
|
-
throw new Error('deletePost requires a token (API key or JWT)');
|
|
65
|
-
return request(this.opts, 'DELETE', `/posts/${params.id}`);
|
|
59
|
+
return request(this.opts, 'DELETE', `/api/tenants/${params.tenantId}/posts/${params.postId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
66
60
|
}
|
|
67
61
|
/** Delete a thread */
|
|
68
62
|
deleteThread(params) {
|
|
69
|
-
|
|
70
|
-
throw new Error('deleteThread requires a token (API key or JWT)');
|
|
71
|
-
return request(this.opts, 'DELETE', `/threads/${params.id}`);
|
|
63
|
+
return request(this.opts, 'DELETE', `/api/tenants/${params.tenantId}/threads/${params.threadId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
72
64
|
}
|
|
73
65
|
/** Exchange session cookie for a short-lived tenant JWT */
|
|
74
66
|
exchangeTenantToken() {
|
|
75
|
-
return request(this.opts, 'POST', '/tenant-token', {
|
|
67
|
+
return request(this.opts, 'POST', '/api/tenant-token', { routeAuth: { acceptsBetterAuth: true } });
|
|
76
68
|
}
|
|
77
69
|
/** Get a single category */
|
|
78
70
|
getCategory(params) {
|
|
79
|
-
|
|
80
|
-
throw new Error('getCategory requires a token (API key or JWT)');
|
|
81
|
-
return request(this.opts, 'GET', `/categories/${params.id}`);
|
|
71
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/categories/${params.categoryId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
82
72
|
}
|
|
83
73
|
/** Get a group */
|
|
84
74
|
getGroup(params) {
|
|
85
|
-
|
|
86
|
-
throw new Error('getGroup requires a token (API key or JWT)');
|
|
87
|
-
return request(this.opts, 'GET', `/groups/${params.id}`);
|
|
75
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/groups/${params.groupId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
88
76
|
}
|
|
89
77
|
/** Get own profile */
|
|
90
78
|
getMe() {
|
|
91
|
-
|
|
92
|
-
throw new Error('getMe requires a token (API key or JWT)');
|
|
93
|
-
return request(this.opts, 'GET', '/users/me');
|
|
79
|
+
return request(this.opts, 'GET', '/api/users/me', { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
94
80
|
}
|
|
95
81
|
/** Get the current owner of a tenant */
|
|
96
82
|
getTenantOwner(params) {
|
|
97
|
-
return request(this.opts, 'GET', `/tenants/${params.
|
|
83
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/owner`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
98
84
|
}
|
|
99
85
|
/** Get a single thread */
|
|
100
86
|
getThread(params) {
|
|
101
|
-
|
|
102
|
-
throw new Error('getThread requires a token (API key or JWT)');
|
|
103
|
-
return request(this.opts, 'GET', `/threads/${params.id}`);
|
|
87
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/threads/${params.threadId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
104
88
|
}
|
|
105
89
|
/** Get read status for the current user in a thread */
|
|
106
90
|
getThreadReadStatus(params) {
|
|
107
|
-
|
|
108
|
-
throw new Error('getThreadReadStatus requires a token (API key or JWT)');
|
|
109
|
-
return request(this.opts, 'GET', `/threads/${params.id}/read-status`);
|
|
91
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/threads/${params.threadId}/read-status`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
110
92
|
}
|
|
111
93
|
/** Get a user profile by ID */
|
|
112
94
|
getUser(params) {
|
|
113
|
-
|
|
114
|
-
throw new Error('getUser requires a token (API key or JWT)');
|
|
115
|
-
return request(this.opts, 'GET', `/users/${params.id}`);
|
|
95
|
+
return request(this.opts, 'GET', `/api/users/${params.userId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
116
96
|
}
|
|
117
97
|
/** Get user group memberships in the current tenant */
|
|
118
98
|
getUserMembership(params) {
|
|
119
|
-
|
|
120
|
-
throw new Error('getUserMembership requires a token (API key or JWT)');
|
|
121
|
-
return request(this.opts, 'GET', `/users/${params.id}/membership`);
|
|
99
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/users/${params.userId}/membership`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
122
100
|
}
|
|
123
101
|
/** Grant platform owner status to a user (platform owners only) */
|
|
124
102
|
grantPlatformOwner(body) {
|
|
125
|
-
return request(this.opts, 'POST', '/platform/owners', { body,
|
|
103
|
+
return request(this.opts, 'POST', '/api/platform/owners', { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
126
104
|
}
|
|
127
105
|
/** List your platform-scoped API keys */
|
|
128
106
|
listApiKeys() {
|
|
129
|
-
return request(this.opts, 'GET', '/platform/api-keys', {
|
|
107
|
+
return request(this.opts, 'GET', '/api/platform/api-keys', { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
130
108
|
}
|
|
131
109
|
/** List visible categories for the requesting user */
|
|
132
|
-
listCategories() {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
110
|
+
listCategories(params) {
|
|
111
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/categories`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
112
|
+
}
|
|
113
|
+
/** List members of a group */
|
|
114
|
+
listGroupMembers(params) {
|
|
115
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/groups/${params.groupId}/members`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
136
116
|
}
|
|
137
117
|
/** List groups */
|
|
138
|
-
listGroups() {
|
|
139
|
-
|
|
140
|
-
throw new Error('listGroups requires a token (API key or JWT)');
|
|
141
|
-
return request(this.opts, 'GET', '/groups');
|
|
118
|
+
listGroups(params) {
|
|
119
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/groups`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
142
120
|
}
|
|
143
121
|
/** Get unified notification inbox */
|
|
144
122
|
listNotifications(query) {
|
|
145
|
-
return request(this.opts, 'GET', '/notifications', { query,
|
|
123
|
+
return request(this.opts, 'GET', '/api/notifications', { query, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
146
124
|
}
|
|
147
125
|
/** List platform owner user IDs (platform owners only) */
|
|
148
126
|
listPlatformOwners() {
|
|
149
|
-
return request(this.opts, 'GET', '/platform/owners', {
|
|
127
|
+
return request(this.opts, 'GET', '/api/platform/owners', { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
150
128
|
}
|
|
151
129
|
/** List all platform settings (platform owners only) */
|
|
152
130
|
listPlatformSettings() {
|
|
153
|
-
return request(this.opts, 'GET', '/platform/settings', {
|
|
131
|
+
return request(this.opts, 'GET', '/api/platform/settings', { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
154
132
|
}
|
|
155
133
|
/** List posts in a thread — cursor pagination or anchor via ?from=postId */
|
|
156
134
|
listPosts(params, query) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
135
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/threads/${params.threadId}/posts`, { query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
136
|
+
}
|
|
137
|
+
/** List tenants owned by the current user (platform owners see all) */
|
|
138
|
+
listTenants(query) {
|
|
139
|
+
return request(this.opts, 'GET', '/api/tenants', { query, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
160
140
|
}
|
|
161
141
|
/** List threads in a category */
|
|
162
142
|
listThreads(params, query) {
|
|
163
|
-
|
|
164
|
-
throw new Error('listThreads requires a token (API key or JWT)');
|
|
165
|
-
return request(this.opts, 'GET', `/categories/${params.categoryId}/threads`, { query });
|
|
143
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/categories/${params.categoryId}/threads`, { query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
166
144
|
}
|
|
167
145
|
/** Mark a notification as read */
|
|
168
146
|
markNotificationRead(params) {
|
|
169
|
-
return request(this.opts, 'PATCH', `/notifications/${params.
|
|
147
|
+
return request(this.opts, 'PATCH', `/api/notifications/${params.notificationId}/read`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
170
148
|
}
|
|
171
149
|
/** Set the position of each category (requires category.edit permission) */
|
|
172
|
-
reorderCategories(body) {
|
|
173
|
-
return request(this.opts, 'PUT',
|
|
150
|
+
reorderCategories(params, body) {
|
|
151
|
+
return request(this.opts, 'PUT', `/api/tenants/${params.tenantId}/categories/reorder`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
174
152
|
}
|
|
175
153
|
/** Set the position of each group (requires group.edit permission) */
|
|
176
|
-
reorderGroups(body) {
|
|
177
|
-
return request(this.opts, 'PUT',
|
|
154
|
+
reorderGroups(params, body) {
|
|
155
|
+
return request(this.opts, 'PUT', `/api/tenants/${params.tenantId}/groups/reorder`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
178
156
|
}
|
|
179
157
|
/** Restore a tenant from a signed backup (platform owners only) */
|
|
180
158
|
restoreTenant(params, body) {
|
|
181
|
-
return request(this.opts, 'POST', `/tenants/${params.
|
|
159
|
+
return request(this.opts, 'POST', `/api/tenants/${params.tenantId}/restore`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
182
160
|
}
|
|
183
161
|
/** Revoke platform owner status from a user (platform owners only) */
|
|
184
162
|
revokePlatformOwner(params) {
|
|
185
|
-
return request(this.opts, 'DELETE', `/platform/owners/${params.userId}`, {
|
|
163
|
+
return request(this.opts, 'DELETE', `/api/platform/owners/${params.userId}`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
186
164
|
}
|
|
187
165
|
/** Full-text search across threads and posts (visible categories only) */
|
|
188
|
-
search(query) {
|
|
189
|
-
|
|
190
|
-
throw new Error('search requires a token (API key or JWT)');
|
|
191
|
-
return request(this.opts, 'GET', '/search', { query });
|
|
166
|
+
search(params, query) {
|
|
167
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/search`, { query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
192
168
|
}
|
|
193
169
|
/** Set category visibility for a group (requires group.edit permission) */
|
|
194
170
|
setGroupCategories(params, body) {
|
|
195
|
-
|
|
196
|
-
throw new Error('setGroupCategories requires a token (API key or JWT)');
|
|
197
|
-
return request(this.opts, 'PUT', `/groups/${params.id}/categories`, { body });
|
|
171
|
+
return request(this.opts, 'PUT', `/api/tenants/${params.tenantId}/groups/${params.groupId}/categories`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
198
172
|
}
|
|
199
173
|
/** Replace all permissions for a group (requires group.edit permission) */
|
|
200
174
|
setGroupPermissions(params, body) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
175
|
+
return request(this.opts, 'PUT', `/api/tenants/${params.tenantId}/groups/${params.groupId}/permissions`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
176
|
+
}
|
|
177
|
+
/** Set or remove the custom domain for a tenant */
|
|
178
|
+
setTenantCustomDomain(params, body) {
|
|
179
|
+
return request(this.opts, 'PUT', `/api/tenants/${params.tenantId}/custom-domain`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
204
180
|
}
|
|
205
181
|
/** Mark a thread as read up to a given post */
|
|
206
182
|
setThreadReadStatus(params, body) {
|
|
207
|
-
|
|
208
|
-
throw new Error('setThreadReadStatus requires a token (API key or JWT)');
|
|
209
|
-
return request(this.opts, 'PUT', `/threads/${params.id}/read-status`, { body });
|
|
183
|
+
return request(this.opts, 'PUT', `/api/tenants/${params.tenantId}/threads/${params.threadId}/read-status`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
210
184
|
}
|
|
211
185
|
/** Replace user group assignments in the current tenant (requires group.assign permission) */
|
|
212
186
|
setUserGroups(params, body) {
|
|
213
|
-
|
|
214
|
-
throw new Error('setUserGroups requires a token (API key or JWT)');
|
|
215
|
-
return request(this.opts, 'PUT', `/users/${params.id}/membership`, { body });
|
|
187
|
+
return request(this.opts, 'PUT', `/api/tenants/${params.tenantId}/users/${params.userId}/membership`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
216
188
|
}
|
|
217
189
|
/** Subscribe to a thread */
|
|
218
190
|
subscribeThread(params) {
|
|
219
|
-
|
|
220
|
-
throw new Error('subscribeThread requires a token (API key or JWT)');
|
|
221
|
-
return request(this.opts, 'POST', `/threads/${params.id}/subscribe`);
|
|
191
|
+
return request(this.opts, 'POST', `/api/tenants/${params.tenantId}/threads/${params.threadId}/subscribe`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
222
192
|
}
|
|
223
193
|
/** Transfer tenant ownership to another existing user (only the current owner can do this) */
|
|
224
194
|
transferTenantOwner(params, body) {
|
|
225
|
-
return request(this.opts, 'PUT', `/tenants/${params.
|
|
195
|
+
return request(this.opts, 'PUT', `/api/tenants/${params.tenantId}/owner`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
226
196
|
}
|
|
227
197
|
/** Unsubscribe from a thread */
|
|
228
198
|
unsubscribeThread(params) {
|
|
229
|
-
|
|
230
|
-
throw new Error('unsubscribeThread requires a token (API key or JWT)');
|
|
231
|
-
return request(this.opts, 'DELETE', `/threads/${params.id}/subscribe`);
|
|
199
|
+
return request(this.opts, 'DELETE', `/api/tenants/${params.tenantId}/threads/${params.threadId}/subscribe`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
232
200
|
}
|
|
233
201
|
/** Update a category (requires category.edit permission) */
|
|
234
202
|
updateCategory(params, body) {
|
|
235
|
-
|
|
236
|
-
throw new Error('updateCategory requires a token (API key or JWT)');
|
|
237
|
-
return request(this.opts, 'PATCH', `/categories/${params.id}`, { body });
|
|
203
|
+
return request(this.opts, 'PATCH', `/api/tenants/${params.tenantId}/categories/${params.categoryId}`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
238
204
|
}
|
|
239
205
|
/** Update a group (requires group.edit permission) */
|
|
240
206
|
updateGroup(params, body) {
|
|
241
|
-
|
|
242
|
-
throw new Error('updateGroup requires a token (API key or JWT)');
|
|
243
|
-
return request(this.opts, 'PATCH', `/groups/${params.id}`, { body });
|
|
207
|
+
return request(this.opts, 'PATCH', `/api/tenants/${params.tenantId}/groups/${params.groupId}`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
244
208
|
}
|
|
245
209
|
/** Update own profile */
|
|
246
210
|
updateMe(body) {
|
|
247
|
-
|
|
248
|
-
throw new Error('updateMe requires a token (API key or JWT)');
|
|
249
|
-
return request(this.opts, 'PATCH', '/users/me', { body });
|
|
211
|
+
return request(this.opts, 'PATCH', '/api/users/me', { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
250
212
|
}
|
|
251
213
|
/** Update a platform setting (platform owners only) */
|
|
252
214
|
updatePlatformSetting(params, body) {
|
|
253
|
-
return request(this.opts, 'PATCH', `/platform/settings/${params.key}`, { body,
|
|
215
|
+
return request(this.opts, 'PATCH', `/api/platform/settings/${params.key}`, { body, routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true } });
|
|
216
|
+
}
|
|
217
|
+
/** Edit a post (author or post.edit permission) */
|
|
218
|
+
updatePost(params, body) {
|
|
219
|
+
return request(this.opts, 'PATCH', `/api/tenants/${params.tenantId}/posts/${params.postId}`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
220
|
+
}
|
|
221
|
+
/** Update a thread (title, pin, lock, move) */
|
|
222
|
+
updateThread(params, body) {
|
|
223
|
+
return request(this.opts, 'PATCH', `/api/tenants/${params.tenantId}/threads/${params.threadId}`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
export class TenantClient {
|
|
227
|
+
opts;
|
|
228
|
+
constructor(opts) {
|
|
229
|
+
this.opts = opts;
|
|
230
|
+
}
|
|
231
|
+
/** Count read and unread notifications */
|
|
232
|
+
countNotifications() {
|
|
233
|
+
return request(this.opts, 'GET', '/api/notifications/count', { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
234
|
+
}
|
|
235
|
+
/** Create a post in a thread */
|
|
236
|
+
createPost(params, body) {
|
|
237
|
+
return request(this.opts, 'POST', `/api/tenants/${params.tenantId}/threads/${params.threadId}/posts`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
238
|
+
}
|
|
239
|
+
/** Create a thread (and its first post) */
|
|
240
|
+
createThread(params, body) {
|
|
241
|
+
return request(this.opts, 'POST', `/api/tenants/${params.tenantId}/categories/${params.categoryId}/threads`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
242
|
+
}
|
|
243
|
+
/** Soft-delete a post */
|
|
244
|
+
deletePost(params) {
|
|
245
|
+
return request(this.opts, 'DELETE', `/api/tenants/${params.tenantId}/posts/${params.postId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
246
|
+
}
|
|
247
|
+
/** Delete a thread */
|
|
248
|
+
deleteThread(params) {
|
|
249
|
+
return request(this.opts, 'DELETE', `/api/tenants/${params.tenantId}/threads/${params.threadId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
250
|
+
}
|
|
251
|
+
/** Exchange session cookie for a short-lived tenant JWT */
|
|
252
|
+
exchangeTenantToken() {
|
|
253
|
+
return request(this.opts, 'POST', '/api/tenant-token', { routeAuth: { acceptsBetterAuth: true, tenantUseCredentials: true } });
|
|
254
|
+
}
|
|
255
|
+
/** Get a single category */
|
|
256
|
+
getCategory(params) {
|
|
257
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/categories/${params.categoryId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
258
|
+
}
|
|
259
|
+
/** Get a group */
|
|
260
|
+
getGroup(params) {
|
|
261
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/groups/${params.groupId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
262
|
+
}
|
|
263
|
+
/** Get own profile */
|
|
264
|
+
getMe() {
|
|
265
|
+
return request(this.opts, 'GET', '/api/users/me', { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
266
|
+
}
|
|
267
|
+
/** Get a single thread */
|
|
268
|
+
getThread(params) {
|
|
269
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/threads/${params.threadId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
270
|
+
}
|
|
271
|
+
/** Get read status for the current user in a thread */
|
|
272
|
+
getThreadReadStatus(params) {
|
|
273
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/threads/${params.threadId}/read-status`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
274
|
+
}
|
|
275
|
+
/** Get a user profile by ID */
|
|
276
|
+
getUser(params) {
|
|
277
|
+
return request(this.opts, 'GET', `/api/users/${params.userId}`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
278
|
+
}
|
|
279
|
+
/** Get user group memberships in the current tenant */
|
|
280
|
+
getUserMembership(params) {
|
|
281
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/users/${params.userId}/membership`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
282
|
+
}
|
|
283
|
+
/** List visible categories for the requesting user */
|
|
284
|
+
listCategories(params) {
|
|
285
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/categories`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
286
|
+
}
|
|
287
|
+
/** List members of a group */
|
|
288
|
+
listGroupMembers(params) {
|
|
289
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/groups/${params.groupId}/members`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
290
|
+
}
|
|
291
|
+
/** List groups */
|
|
292
|
+
listGroups(params) {
|
|
293
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/groups`, { routeAuth: { acceptsApiKey: true, acceptsBetterAuth: true, acceptsTenantJwt: true } });
|
|
294
|
+
}
|
|
295
|
+
/** List posts in a thread — cursor pagination or anchor via ?from=postId */
|
|
296
|
+
listPosts(params, query) {
|
|
297
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/threads/${params.threadId}/posts`, { query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
298
|
+
}
|
|
299
|
+
/** List threads in a category */
|
|
300
|
+
listThreads(params, query) {
|
|
301
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/categories/${params.categoryId}/threads`, { query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
302
|
+
}
|
|
303
|
+
/** Full-text search across threads and posts (visible categories only) */
|
|
304
|
+
search(params, query) {
|
|
305
|
+
return request(this.opts, 'GET', `/api/tenants/${params.tenantId}/search`, { query, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
306
|
+
}
|
|
307
|
+
/** Mark a thread as read up to a given post */
|
|
308
|
+
setThreadReadStatus(params, body) {
|
|
309
|
+
return request(this.opts, 'PUT', `/api/tenants/${params.tenantId}/threads/${params.threadId}/read-status`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
310
|
+
}
|
|
311
|
+
/** Subscribe to a thread */
|
|
312
|
+
subscribeThread(params) {
|
|
313
|
+
return request(this.opts, 'POST', `/api/tenants/${params.tenantId}/threads/${params.threadId}/subscribe`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
314
|
+
}
|
|
315
|
+
/** Unsubscribe from a thread */
|
|
316
|
+
unsubscribeThread(params) {
|
|
317
|
+
return request(this.opts, 'DELETE', `/api/tenants/${params.tenantId}/threads/${params.threadId}/subscribe`, { routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
254
318
|
}
|
|
255
319
|
/** Edit a post (author or post.edit permission) */
|
|
256
320
|
updatePost(params, body) {
|
|
257
|
-
|
|
258
|
-
throw new Error('updatePost requires a token (API key or JWT)');
|
|
259
|
-
return request(this.opts, 'PATCH', `/posts/${params.id}`, { body });
|
|
321
|
+
return request(this.opts, 'PATCH', `/api/tenants/${params.tenantId}/posts/${params.postId}`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
260
322
|
}
|
|
261
323
|
/** Update a thread (title, pin, lock, move) */
|
|
262
324
|
updateThread(params, body) {
|
|
263
|
-
|
|
264
|
-
throw new Error('updateThread requires a token (API key or JWT)');
|
|
265
|
-
return request(this.opts, 'PATCH', `/threads/${params.id}`, { body });
|
|
325
|
+
return request(this.opts, 'PATCH', `/api/tenants/${params.tenantId}/threads/${params.threadId}`, { body, routeAuth: { acceptsApiKey: true, acceptsTenantJwt: true } });
|
|
266
326
|
}
|
|
267
327
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAC/D,YAAY,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACxD,mBAAmB,sBAAsB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { AcpClient, TenantClient } from './generated/client.js';
|
package/dist/request.d.ts
CHANGED
|
@@ -2,9 +2,18 @@ export interface RoundtableClientOpts {
|
|
|
2
2
|
baseUrl: string;
|
|
3
3
|
token?: string;
|
|
4
4
|
}
|
|
5
|
+
interface RouteAuth {
|
|
6
|
+
acceptsApiKey?: boolean;
|
|
7
|
+
acceptsBetterAuth?: boolean;
|
|
8
|
+
acceptsTenantJwt?: boolean;
|
|
9
|
+
requiresToken?: boolean;
|
|
10
|
+
tenantUseCredentials?: boolean;
|
|
11
|
+
}
|
|
5
12
|
export declare function request<T>(opts: RoundtableClientOpts, method: string, path: string, options?: {
|
|
6
13
|
body?: unknown;
|
|
7
14
|
query?: Record<string, unknown>;
|
|
8
15
|
useCredentials?: boolean;
|
|
16
|
+
routeAuth?: RouteAuth;
|
|
9
17
|
}): Promise<T>;
|
|
18
|
+
export {};
|
|
10
19
|
//# sourceMappingURL=request.d.ts.map
|
package/dist/request.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,wBAAsB,OAAO,CAAC,CAAC,EAC7B,IAAI,EAAE,oBAAoB,EAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,UAAU,SAAS;IACjB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B;AAED,wBAAsB,OAAO,CAAC,CAAC,EAC7B,IAAI,EAAE,oBAAoB,EAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;IACR,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB,GACA,OAAO,CAAC,CAAC,CAAC,CA6CZ"}
|
package/dist/request.js
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
export async function request(opts, method, path, options) {
|
|
2
|
+
const routeAuth = options?.routeAuth;
|
|
3
|
+
let useCredentials = options?.useCredentials ?? false;
|
|
4
|
+
// Decide auth strategy
|
|
5
|
+
if (routeAuth) {
|
|
6
|
+
// TenantClient: use credentials if explicitly required by route
|
|
7
|
+
if (routeAuth.tenantUseCredentials) {
|
|
8
|
+
useCredentials = true;
|
|
9
|
+
}
|
|
10
|
+
// If token is available, use it (prefer token over credentials)
|
|
11
|
+
else if (opts.token && routeAuth.acceptsApiKey) {
|
|
12
|
+
useCredentials = false;
|
|
13
|
+
}
|
|
14
|
+
// If no token but route accepts better-auth: use credentials
|
|
15
|
+
else if (!opts.token && routeAuth.acceptsBetterAuth) {
|
|
16
|
+
useCredentials = true;
|
|
17
|
+
}
|
|
18
|
+
// Otherwise: make request without auth (backend will respond 401/403 if needed)
|
|
19
|
+
}
|
|
2
20
|
const url = new URL(`${opts.baseUrl}${path}`);
|
|
3
21
|
if (options?.query) {
|
|
4
22
|
for (const [k, v] of Object.entries(options.query)) {
|
|
@@ -8,10 +26,10 @@ export async function request(opts, method, path, options) {
|
|
|
8
26
|
}
|
|
9
27
|
const res = await fetch(url.toString(), {
|
|
10
28
|
method,
|
|
11
|
-
credentials:
|
|
29
|
+
credentials: useCredentials ? 'include' : undefined,
|
|
12
30
|
headers: {
|
|
13
31
|
...(options?.body !== undefined ? { 'Content-Type': 'application/json' } : {}),
|
|
14
|
-
...(opts.token ? { Authorization: `Bearer ${opts.token}` } : {}),
|
|
32
|
+
...(opts.token && !useCredentials ? { Authorization: `Bearer ${opts.token}` } : {}),
|
|
15
33
|
},
|
|
16
34
|
body: options?.body !== undefined ? JSON.stringify(options.body) : undefined,
|
|
17
35
|
});
|