@foru-ms/sdk 1.2.3 → 1.2.5
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 +65 -33
- package/dist/resources/Notifications.d.ts +4 -3
- package/dist/resources/Posts.d.ts +11 -5
- package/dist/resources/Posts.js +12 -4
- package/dist/resources/PrivateMessages.d.ts +1 -0
- package/dist/resources/Reports.d.ts +1 -0
- package/dist/resources/Roles.d.ts +1 -0
- package/dist/resources/Search.d.ts +1 -0
- package/dist/resources/Tags.d.ts +7 -3
- package/dist/resources/Tags.js +2 -1
- package/dist/resources/Threads.d.ts +17 -10
- package/dist/resources/Threads.js +12 -6
- package/dist/resources/Users.d.ts +5 -0
- package/dist/resources/Webhooks.d.ts +1 -0
- package/dist/resources/Webhooks.js +2 -0
- package/examples/error-handling.ts +0 -1
- package/examples/managing-threads.ts +0 -2
- package/examples/pagination.ts +1 -2
- package/package.json +1 -1
- package/src/resources/Notifications.ts +4 -3
- package/src/resources/Posts.ts +23 -9
- package/src/resources/PrivateMessages.ts +1 -0
- package/src/resources/Reports.ts +1 -0
- package/src/resources/Roles.ts +1 -0
- package/src/resources/Search.ts +1 -0
- package/src/resources/Tags.ts +9 -4
- package/src/resources/Threads.ts +29 -16
- package/src/resources/Users.ts +5 -0
- package/src/resources/Webhooks.ts +2 -1
package/README.md
CHANGED
|
@@ -43,7 +43,6 @@ client.setToken('user_jwt_token');
|
|
|
43
43
|
const thread = await client.threads.create({
|
|
44
44
|
title: 'My First Thread',
|
|
45
45
|
body: 'Hello, Foru.ms!',
|
|
46
|
-
userId: 'user-123',
|
|
47
46
|
});
|
|
48
47
|
|
|
49
48
|
// List threads with auto-pagination
|
|
@@ -97,7 +96,7 @@ The SDK provides multiple ways to handle pagination:
|
|
|
97
96
|
```typescript
|
|
98
97
|
// Auto-pagination with async iterator
|
|
99
98
|
for await (const thread of client.pagination.paginateAll(
|
|
100
|
-
(cursor) => client.threads.list({ cursor, filter: 'newest' })
|
|
99
|
+
(cursor) => client.threads.list({ cursor, filter: 'newest', limit: 25 })
|
|
101
100
|
)) {
|
|
102
101
|
console.log(thread.title);
|
|
103
102
|
}
|
|
@@ -108,15 +107,38 @@ const allThreads = await client.pagination.fetchAllPages(
|
|
|
108
107
|
5 // max pages
|
|
109
108
|
);
|
|
110
109
|
|
|
111
|
-
// Manual pagination
|
|
110
|
+
// Manual pagination with custom page size
|
|
112
111
|
let cursor: string | undefined;
|
|
113
112
|
do {
|
|
114
|
-
const response = await client.threads.list({
|
|
113
|
+
const response = await client.threads.list({
|
|
114
|
+
cursor,
|
|
115
|
+
limit: 50 // Request up to 50 items per page (max)
|
|
116
|
+
});
|
|
115
117
|
// Process threads...
|
|
116
118
|
cursor = response.nextThreadCursor;
|
|
117
119
|
} while (cursor);
|
|
118
120
|
```
|
|
119
121
|
|
|
122
|
+
### Pagination Limit Parameter
|
|
123
|
+
|
|
124
|
+
All paginated endpoints support an optional `limit` parameter to control page size:
|
|
125
|
+
|
|
126
|
+
- **Min**: 1
|
|
127
|
+
- **Max**: 50
|
|
128
|
+
- **Default**: 15
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
// Get 50 threads per page (maximum)
|
|
132
|
+
const threads = await client.threads.list({ limit: 50 });
|
|
133
|
+
|
|
134
|
+
// Get 10 users per page
|
|
135
|
+
const users = await client.users.list({ limit: 10 });
|
|
136
|
+
|
|
137
|
+
// Limit applies to all paginated endpoints
|
|
138
|
+
const posts = await client.posts.list({ limit: 25 });
|
|
139
|
+
const notifications = await client.notifications.list({ limit: 30 });
|
|
140
|
+
```
|
|
141
|
+
|
|
120
142
|
## Webhooks
|
|
121
143
|
|
|
122
144
|
Verify webhook signatures for security. All webhooks include:
|
|
@@ -188,31 +210,31 @@ Check the `/examples` directory for detailed examples:
|
|
|
188
210
|
### Threads (`client.threads`)
|
|
189
211
|
|
|
190
212
|
**Thread Management**
|
|
191
|
-
* `list(params: { query?: string; tagId?: string; filter?: 'newest' | 'oldest'; type?: 'created' | 'liked' | 'disliked' | 'upvoted' | 'downvoted' | 'subscribed'; cursor?: string; userId?: string })`: List threads with filtering options.
|
|
213
|
+
* `list(params: { query?: string; tagId?: string; filter?: 'newest' | 'oldest'; type?: 'created' | 'liked' | 'disliked' | 'upvoted' | 'downvoted' | 'subscribed'; cursor?: string; userId?: string; limit?: number })`: List threads with filtering options. `limit` controls page size (1-50, default: 15).
|
|
192
214
|
* `create(payload: CreateThreadPayload)`: Create a new thread.
|
|
193
215
|
* `retrieve(id: string)`: Get a thread by ID.
|
|
194
216
|
* `update(id: string, payload: UpdateThreadPayload)`: Update a thread.
|
|
195
217
|
* `delete(id: string)`: Delete a thread.
|
|
196
|
-
* `getPosts(id: string, params: { query?: string; cursor?: string; filter?: 'newest' | 'oldest' })`: Get posts in a thread.
|
|
218
|
+
* `getPosts(id: string, params: { query?: string; cursor?: string; filter?: 'newest' | 'oldest'; limit?: number })`: Get posts in a thread.
|
|
197
219
|
|
|
198
220
|
**Thread Interactions**
|
|
199
221
|
* `like(id: string, userId?: string, extendedData?: any)`: Like a thread.
|
|
200
222
|
* `unlike(id: string, userId?: string)`: Unlike a thread.
|
|
201
|
-
* `getLikes(id: string, params?: { cursor?: string })`: Get users who liked a thread with pagination.
|
|
223
|
+
* `getLikes(id: string, params?: { cursor?: string; limit?: number })`: Get users who liked a thread with pagination.
|
|
202
224
|
* `dislike(id: string, userId?: string, extendedData?: any)`: Dislike a thread.
|
|
203
225
|
* `undislike(id: string, userId?: string)`: Remove dislike from a thread.
|
|
204
|
-
* `getDislikes(id: string, params?: { cursor?: string })`: Get users who disliked a thread with pagination.
|
|
226
|
+
* `getDislikes(id: string, params?: { cursor?: string; limit?: number })`: Get users who disliked a thread with pagination.
|
|
205
227
|
* `upvote(id: string, userId?: string, extendedData?: any)`: Upvote a thread.
|
|
206
228
|
* `unupvote(id: string, userId?: string)`: Remove upvote from a thread.
|
|
207
|
-
* `getUpvotes(id: string, params?: { cursor?: string })`: Get users who upvoted a thread with pagination.
|
|
229
|
+
* `getUpvotes(id: string, params?: { cursor?: string; limit?: number })`: Get users who upvoted a thread with pagination.
|
|
208
230
|
* `downvote(id: string, userId?: string, extendedData?: any)`: Downvote a thread.
|
|
209
231
|
* `undownvote(id: string, userId?: string)`: Remove downvote from a thread.
|
|
210
|
-
* `getDownvotes(id: string, params?: { cursor?: string })`: Get users who downvoted a thread with pagination.
|
|
232
|
+
* `getDownvotes(id: string, params?: { cursor?: string; limit?: number })`: Get users who downvoted a thread with pagination.
|
|
211
233
|
|
|
212
234
|
**Thread Subscriptions**
|
|
213
235
|
* `subscribe(id: string, userId?: string, extendedData?: any)`: Subscribe to a thread.
|
|
214
236
|
* `unsubscribe(id: string, userId?: string)`: Unsubscribe from a thread.
|
|
215
|
-
* `getSubscribers(id: string, params?: { cursor?: string })`: Get users subscribed to a thread with pagination.
|
|
237
|
+
* `getSubscribers(id: string, params?: { cursor?: string; limit?: number })`: Get users subscribed to a thread with pagination.
|
|
216
238
|
|
|
217
239
|
**Thread Polls**
|
|
218
240
|
* `createPoll(id: string, payload: { title?: string; expiresAt?: string; options: Array<{ title: string; color?: string; extendedData?: any }>, extendedData?: any })`: Create a poll for a thread.
|
|
@@ -227,59 +249,59 @@ Check the `/examples` directory for detailed examples:
|
|
|
227
249
|
### Posts (`client.posts`)
|
|
228
250
|
|
|
229
251
|
**Post Management**
|
|
230
|
-
* `list(params: { query?: string; filter?: 'newest' | 'oldest'; type?: 'created' | 'liked' | 'disliked' | 'upvoted' | 'downvoted'; cursor?: string; userId?: string })`: List posts with filtering options.
|
|
252
|
+
* `list(params: { query?: string; filter?: 'newest' | 'oldest'; type?: 'created' | 'liked' | 'disliked' | 'upvoted' | 'downvoted'; cursor?: string; userId?: string; limit?: number })`: List posts with filtering options. `limit` controls page size (1-50, default: 15).
|
|
231
253
|
* `create(payload: CreatePostPayload)`: Create a new post/reply.
|
|
232
254
|
* `retrieve(id: string)`: Get a post by ID.
|
|
233
255
|
* `update(id: string, payload: UpdatePostPayload)`: Update a post.
|
|
234
256
|
* `delete(id: string, payload?: { userId?: string })`: Delete a post.
|
|
235
|
-
* `getChildren(id: string, params?: { query?: string; cursor?: string; filter?: 'newest' | 'oldest' })`: Get child posts (nested replies).
|
|
257
|
+
* `getChildren(id: string, params?: { query?: string; cursor?: string; filter?: 'newest' | 'oldest'; limit?: number })`: Get child posts (nested replies).
|
|
236
258
|
|
|
237
259
|
**Post Interactions**
|
|
238
260
|
* `like(id: string, userId?: string, extendedData?: any)`: Like a post.
|
|
239
261
|
* `unlike(id: string, userId?: string)`: Unlike a post.
|
|
240
|
-
* `getLikes(id: string, params?: { cursor?: string })`: Get users who liked a post with pagination.
|
|
262
|
+
* `getLikes(id: string, params?: { cursor?: string; limit?: number })`: Get users who liked a post with pagination.
|
|
241
263
|
* `dislike(id: string, userId?: string, extendedData?: any)`: Dislike a post.
|
|
242
264
|
* `undislike(id: string, userId?: string)`: Remove dislike from a post.
|
|
243
|
-
* `getDislikes(id: string, params?: { cursor?: string })`: Get users who disliked a post with pagination.
|
|
265
|
+
* `getDislikes(id: string, params?: { cursor?: string; limit?: number })`: Get users who disliked a post with pagination.
|
|
244
266
|
* `upvote(id: string, userId?: string, extendedData?: any)`: Upvote a post.
|
|
245
267
|
* `unupvote(id: string, userId?: string)`: Remove upvote from a post.
|
|
246
|
-
* `getUpvotes(id: string, params?: { cursor?: string })`: Get users who upvoted a post with pagination.
|
|
268
|
+
* `getUpvotes(id: string, params?: { cursor?: string; limit?: number })`: Get users who upvoted a post with pagination.
|
|
247
269
|
* `downvote(id: string, userId?: string, extendedData?: any)`: Downvote a post.
|
|
248
270
|
* `undownvote(id: string, userId?: string)`: Remove downvote from a post.
|
|
249
|
-
* `getDownvotes(id: string, params?: { cursor?: string })`: Get users who downvoted a post with pagination.
|
|
271
|
+
* `getDownvotes(id: string, params?: { cursor?: string; limit?: number })`: Get users who downvoted a post with pagination.
|
|
250
272
|
|
|
251
273
|
### Users (`client.users`)
|
|
252
274
|
|
|
253
|
-
* `list(params?: { query?: string; filter?: 'newest' | 'oldest'; cursor?: string })`: List users.
|
|
275
|
+
* `list(params?: { query?: string; filter?: 'newest' | 'oldest'; cursor?: string; limit?: number })`: List users. `limit` controls page size (1-50, default: 15).
|
|
254
276
|
* `retrieve(userId: string)`: Get user by ID.
|
|
255
277
|
* `create(payload: { username: string; email: string; password: string; displayName?: string; emailVerified?: boolean; roles?: string[]; bio?: string; signature?: string; url?: string; extendedData?: Record<string, any> })`: Create a user (Admin).
|
|
256
278
|
* `update(id: string, payload: { username?: string; email?: string; password?: string; displayName?: string; emailVerified?: boolean; roles?: string[]; bio?: string; signature?: string; url?: string; extendedData?: Record<string, any> })`: Update a user.
|
|
257
279
|
* `delete(id: string)`: Delete a user.
|
|
258
|
-
* `getThreads(id: string, params?: { query?: string; cursor?: string; filter?: 'newest' | 'oldest' })`: Get all threads created by a user.
|
|
259
|
-
* `getPosts(id: string, params?: { query?: string; cursor?: string; filter?: 'newest' | 'oldest' })`: Get all posts created by a user.
|
|
260
|
-
* `getFollowers(id: string, params?: { query?: string; cursor?: string; filter?: 'newest' | 'oldest' })`: Get user's followers.
|
|
261
|
-
* `getFollowing(id: string, params?: { query?: string; cursor?: string; filter?: 'newest' | 'oldest' })`: Get who a user follows.
|
|
280
|
+
* `getThreads(id: string, params?: { query?: string; cursor?: string; filter?: 'newest' | 'oldest'; limit?: number })`: Get all threads created by a user.
|
|
281
|
+
* `getPosts(id: string, params?: { query?: string; cursor?: string; filter?: 'newest' | 'oldest'; limit?: number })`: Get all posts created by a user.
|
|
282
|
+
* `getFollowers(id: string, params?: { query?: string; cursor?: string; filter?: 'newest' | 'oldest'; limit?: number })`: Get user's followers.
|
|
283
|
+
* `getFollowing(id: string, params?: { query?: string; cursor?: string; filter?: 'newest' | 'oldest'; limit?: number })`: Get who a user follows.
|
|
262
284
|
* `follow(id: string, followerId?: string, extendedData?: any)`: Follow a user.
|
|
263
285
|
* `unfollow(id: string, followerId?: string)`: Unfollow a user.
|
|
264
286
|
|
|
265
287
|
|
|
266
288
|
### Tags (`client.tags`)
|
|
267
289
|
|
|
268
|
-
* `list(params?: { query?: string; cursor?: string })`: List all tags.
|
|
269
|
-
* `listSubscribed(params: { userId?: string; query?: string; cursor?: string })`: List tags a user is subscribed to.
|
|
290
|
+
* `list(params?: { query?: string; cursor?: string; limit?: number })`: List all tags. `limit` controls page size (1-50, default: 15).
|
|
291
|
+
* `listSubscribed(params: { userId?: string; query?: string; cursor?: string; limit?: number })`: List tags a user is subscribed to.
|
|
270
292
|
* `create(payload: { name: string; description?: string; color?: string; extendedData?: Record<string, any> })`: Create a tag.
|
|
271
293
|
* `retrieve(id: string, params?: { userId?: string })`: Get a tag with optional user context.
|
|
272
294
|
* `update(id: string, payload: { name?: string; description?: string; color?: string; extendedData?: Record<string, any> })`: Update a tag.
|
|
273
295
|
* `delete(id: string)`: Delete a tag.
|
|
274
|
-
* `getThreads(id: string, params?: { query?: string; cursor?: string; filter?: 'newest' | 'oldest' })`: Get all threads with a specific tag.
|
|
296
|
+
* `getThreads(id: string, params?: { query?: string; cursor?: string; filter?: 'newest' | 'oldest'; limit?: number })`: Get all threads with a specific tag.
|
|
275
297
|
* `subscribe(id: string, userId?: string)`: Subscribe to a tag.
|
|
276
298
|
* `unsubscribe(id: string, userId?: string)`: Unsubscribe from a tag.
|
|
277
|
-
* `getSubscribers(id: string, params?: { cursor?: string })`: Get users subscribed to a tag with pagination.
|
|
299
|
+
* `getSubscribers(id: string, params?: { cursor?: string; limit?: number })`: Get users subscribed to a tag with pagination.
|
|
278
300
|
|
|
279
301
|
|
|
280
302
|
### Notifications (`client.notifications`)
|
|
281
303
|
|
|
282
|
-
* `list(params: { userId?: string; read?: boolean; filter?: 'newest' | 'oldest'; cursor?: string })`: List notifications for a user.
|
|
304
|
+
* `list(params: { userId?: string; read?: boolean; filter?: 'newest' | 'oldest'; cursor?: string; limit?: number })`: List notifications for a user. `limit` controls page size (1-50, default: 15).
|
|
283
305
|
* `create(payload: { threadId?: string; postId?: string; privateMessageId?: string; notifierId?: string; notifiedId: string; type: string; description?: string; extendedData?: Record<string, any> })`: Create a notification manually.
|
|
284
306
|
* `retrieve(id: string, userId?: string)`: Get a notification by ID.
|
|
285
307
|
* `update(id: string, payload: { userId?: string; read: boolean })`: Update a notification's read status.
|
|
@@ -288,7 +310,7 @@ Check the `/examples` directory for detailed examples:
|
|
|
288
310
|
|
|
289
311
|
### Search (`client.search`)
|
|
290
312
|
|
|
291
|
-
* `search(params: { query: string; type: 'threads' | 'posts' | 'users' | 'tags'; cursor?: string })`: Polymorphic search.
|
|
313
|
+
* `search(params: { query: string; type: 'threads' | 'posts' | 'users' | 'tags'; cursor?: string; limit?: number })`: Polymorphic search. `limit` controls page size (1-50, default: 15).
|
|
292
314
|
|
|
293
315
|
### Webhooks (`client.webhooks`)
|
|
294
316
|
|
|
@@ -297,7 +319,7 @@ Check the `/examples` directory for detailed examples:
|
|
|
297
319
|
* `retrieve(id: string)`: Get a webhook by ID.
|
|
298
320
|
* `update(id: string, payload: { name?: string; url?: string; events?: string[]; active?: boolean })`: Update a webhook configuration.
|
|
299
321
|
* `delete(id: string)`: Delete a webhook.
|
|
300
|
-
* `getDeliveries(id: string, params?: { cursor?: string })`: Get webhook delivery history with pagination. Track successful and failed deliveries.
|
|
322
|
+
* `getDeliveries(id: string, params?: { cursor?: string; limit?: number })`: Get webhook delivery history with pagination. Track successful and failed deliveries. `limit` controls page size (1-50, default: 15).
|
|
301
323
|
* `verifySignature(payload: any, signature: string, timestamp: string, secret: string, maxAge?: number)`: Verify webhook signature for security. Uses HMAC-SHA256. Default maxAge is 5 minutes to prevent replay attacks.
|
|
302
324
|
|
|
303
325
|
### Stats (`client.stats`)
|
|
@@ -317,7 +339,7 @@ Check the `/examples` directory for detailed examples:
|
|
|
317
339
|
|
|
318
340
|
### Private Messages (`client.privateMessages`)
|
|
319
341
|
|
|
320
|
-
* `list(params?: { query?: string; userId?: string; filter?: 'newest' | 'oldest'; cursor?: string })`: List private messages.
|
|
342
|
+
* `list(params?: { query?: string; userId?: string; filter?: 'newest' | 'oldest'; cursor?: string; limit?: number })`: List private messages. `limit` controls page size (1-50, default: 15).
|
|
321
343
|
* `create(payload: { title?: string; body: string; recipientId: string; senderId?: string; extendedData?: Record<string, any> })`: Send a new private message.
|
|
322
344
|
* `retrieve(id: string, userId?: string)`: Get a message by ID.
|
|
323
345
|
* `reply(id: string, payload: { body: string; senderId?: string; title?: string; extendedData?: Record<string, any> })`: Reply to a message thread.
|
|
@@ -326,7 +348,7 @@ Check the `/examples` directory for detailed examples:
|
|
|
326
348
|
|
|
327
349
|
### Reports (`client.reports`)
|
|
328
350
|
|
|
329
|
-
* `list(params?: { reporterId?: string; reportedId?: string; read?: boolean; cursor?: string; filter?: 'newest' | 'oldest' })`: List reports with filtering options.
|
|
351
|
+
* `list(params?: { reporterId?: string; reportedId?: string; read?: boolean; cursor?: string; filter?: 'newest' | 'oldest'; limit?: number })`: List reports with filtering options. `limit` controls page size (1-50, default: 15).
|
|
330
352
|
* `create(payload: { reporterId?: string; reportedId?: string; threadId?: string; postId?: string; privateMessageId?: string; type?: string; description?: string; extendedData?: Record<string, any> })`: Submit a new report.
|
|
331
353
|
* `retrieve(id: string)`: Get a report by ID.
|
|
332
354
|
* `update(id: string, payload: { threadId?: string; postId?: string; privateMessageId?: string; reportedId?: string; reporterId?: string; type?: string; description?: string; read?: boolean; extendedData?: Record<string, any> })`: Update report details (full update).
|
|
@@ -336,7 +358,7 @@ Check the `/examples` directory for detailed examples:
|
|
|
336
358
|
|
|
337
359
|
### Roles (`client.roles`)
|
|
338
360
|
|
|
339
|
-
* `list(params?: { filter?: 'newest' | 'oldest'; cursor?: string })`: List user roles.
|
|
361
|
+
* `list(params?: { filter?: 'newest' | 'oldest'; cursor?: string; limit?: number })`: List user roles. `limit` controls page size (1-50, default: 15).
|
|
340
362
|
* `create(payload: { name: string; description?: string; color?: string; extendedData?: Record<string, any> })`: Create a new role.
|
|
341
363
|
* `retrieve(id: string)`: Get a role by ID.
|
|
342
364
|
* `update(id: string, payload: { name?: string; description?: string; color?: string; extendedData?: Record<string, any> })`: Update a role.
|
|
@@ -525,11 +547,21 @@ We welcome contributions! Please see our contributing guidelines for more inform
|
|
|
525
547
|
## Support
|
|
526
548
|
|
|
527
549
|
- Support: https://foru.ms/support
|
|
528
|
-
- Documentation: https://
|
|
550
|
+
- Documentation: https://foru.ms/docs
|
|
529
551
|
- Issues: https://github.com/foru-ms/sdk/issues
|
|
530
552
|
|
|
531
553
|
## Changelog
|
|
532
554
|
|
|
555
|
+
### v1.2.5
|
|
556
|
+
- Added optional `userId` parameter to methods that accept it
|
|
557
|
+
|
|
558
|
+
### v1.2.4
|
|
559
|
+
- Pagination Enhancement: Added configurable `limit` query parameter to all paginated endpoints
|
|
560
|
+
- Allows clients to control page size (min: 1, max: 50, default: 15)
|
|
561
|
+
- Applied to all list operations across Threads, Posts, Users, Tags, Notifications, Private Messages, Reports, Roles, Search, and Webhooks
|
|
562
|
+
- Updated documentation with usage examples and parameter specifications
|
|
563
|
+
- Improves API flexibility for different use cases (mobile, desktop, batch processing)
|
|
564
|
+
|
|
533
565
|
### v1.2.3
|
|
534
566
|
- README documentation update
|
|
535
567
|
- Enhanced all API reference sections with:
|
|
@@ -4,12 +4,13 @@ export declare class NotificationsResource {
|
|
|
4
4
|
private client;
|
|
5
5
|
constructor(client: ForumClient);
|
|
6
6
|
list(params: {
|
|
7
|
-
userId
|
|
7
|
+
userId?: string;
|
|
8
8
|
read?: boolean;
|
|
9
9
|
filter?: 'newest' | 'oldest';
|
|
10
10
|
cursor?: string;
|
|
11
|
+
limit?: number;
|
|
11
12
|
}): Promise<NotificationListResponse>;
|
|
12
|
-
markAllAsRead(userId
|
|
13
|
+
markAllAsRead(userId?: string, read?: boolean): Promise<{
|
|
13
14
|
count: number;
|
|
14
15
|
}>;
|
|
15
16
|
retrieve(id: string): Promise<Notification>;
|
|
@@ -23,7 +24,7 @@ export declare class NotificationsResource {
|
|
|
23
24
|
threadId?: string;
|
|
24
25
|
postId?: string;
|
|
25
26
|
privateMessageId?: string;
|
|
26
|
-
notifierId
|
|
27
|
+
notifierId?: string;
|
|
27
28
|
notifiedId: string;
|
|
28
29
|
type: string;
|
|
29
30
|
description?: string;
|
|
@@ -9,12 +9,13 @@ export declare class PostsResource {
|
|
|
9
9
|
type?: InteractionType;
|
|
10
10
|
cursor?: string;
|
|
11
11
|
userId?: string;
|
|
12
|
+
limit?: number;
|
|
12
13
|
}): Promise<PostListResponse>;
|
|
13
14
|
create(payload: import('../types').CreatePostPayload): Promise<import('../types').Post>;
|
|
14
15
|
retrieve(postId: string): Promise<import('../types').Post>;
|
|
15
16
|
update(postId: string, payload: import('../types').UpdatePostPayload): Promise<import('../types').Post>;
|
|
16
17
|
delete(postId: string, payload?: {
|
|
17
|
-
userId
|
|
18
|
+
userId?: string;
|
|
18
19
|
}): Promise<import('../types').Post & {
|
|
19
20
|
deleted: boolean;
|
|
20
21
|
}>;
|
|
@@ -22,25 +23,30 @@ export declare class PostsResource {
|
|
|
22
23
|
query?: string;
|
|
23
24
|
cursor?: string;
|
|
24
25
|
filter?: 'newest' | 'oldest';
|
|
26
|
+
limit?: number;
|
|
25
27
|
}): Promise<any>;
|
|
26
28
|
like(id: string, userId?: string, extendedData?: any): Promise<any>;
|
|
27
|
-
unlike(id: string, userId
|
|
29
|
+
unlike(id: string, userId?: string): Promise<any>;
|
|
28
30
|
getLikes(id: string, params?: {
|
|
29
31
|
cursor?: string;
|
|
32
|
+
limit?: number;
|
|
30
33
|
}): Promise<any>;
|
|
31
34
|
dislike(id: string, userId?: string, extendedData?: any): Promise<any>;
|
|
32
|
-
undislike(id: string, userId
|
|
35
|
+
undislike(id: string, userId?: string): Promise<any>;
|
|
33
36
|
getDislikes(id: string, params?: {
|
|
34
37
|
cursor?: string;
|
|
38
|
+
limit?: number;
|
|
35
39
|
}): Promise<any>;
|
|
36
40
|
upvote(id: string, userId?: string, extendedData?: any): Promise<any>;
|
|
37
|
-
unupvote(id: string, userId
|
|
41
|
+
unupvote(id: string, userId?: string): Promise<any>;
|
|
38
42
|
getUpvotes(id: string, params?: {
|
|
39
43
|
cursor?: string;
|
|
44
|
+
limit?: number;
|
|
40
45
|
}): Promise<any>;
|
|
41
46
|
downvote(id: string, userId?: string, extendedData?: any): Promise<any>;
|
|
42
|
-
undownvote(id: string, userId
|
|
47
|
+
undownvote(id: string, userId?: string): Promise<any>;
|
|
43
48
|
getDownvotes(id: string, params?: {
|
|
44
49
|
cursor?: string;
|
|
50
|
+
limit?: number;
|
|
45
51
|
}): Promise<any>;
|
|
46
52
|
}
|
package/dist/resources/Posts.js
CHANGED
|
@@ -59,7 +59,9 @@ class PostsResource {
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
async unlike(id, userId) {
|
|
62
|
-
return this.client.request(`/post/${id}/likes?userId=${userId}`, {
|
|
62
|
+
return userId ? this.client.request(`/post/${id}/likes?userId=${userId}`, {
|
|
63
|
+
method: 'DELETE',
|
|
64
|
+
}) : this.client.request(`/post/${id}/likes`, {
|
|
63
65
|
method: 'DELETE',
|
|
64
66
|
});
|
|
65
67
|
}
|
|
@@ -81,7 +83,9 @@ class PostsResource {
|
|
|
81
83
|
});
|
|
82
84
|
}
|
|
83
85
|
async undislike(id, userId) {
|
|
84
|
-
return this.client.request(`/post/${id}/dislikes?userId=${userId}`, {
|
|
86
|
+
return userId ? this.client.request(`/post/${id}/dislikes?userId=${userId}`, {
|
|
87
|
+
method: 'DELETE',
|
|
88
|
+
}) : this.client.request(`/post/${id}/dislikes`, {
|
|
85
89
|
method: 'DELETE',
|
|
86
90
|
});
|
|
87
91
|
}
|
|
@@ -103,7 +107,9 @@ class PostsResource {
|
|
|
103
107
|
});
|
|
104
108
|
}
|
|
105
109
|
async unupvote(id, userId) {
|
|
106
|
-
return this.client.request(`/post/${id}/upvotes?userId=${userId}`, {
|
|
110
|
+
return userId ? this.client.request(`/post/${id}/upvotes?userId=${userId}`, {
|
|
111
|
+
method: 'DELETE',
|
|
112
|
+
}) : this.client.request(`/post/${id}/upvotes`, {
|
|
107
113
|
method: 'DELETE',
|
|
108
114
|
});
|
|
109
115
|
}
|
|
@@ -125,7 +131,9 @@ class PostsResource {
|
|
|
125
131
|
});
|
|
126
132
|
}
|
|
127
133
|
async undownvote(id, userId) {
|
|
128
|
-
return this.client.request(`/post/${id}/downvotes?userId=${userId}`, {
|
|
134
|
+
return userId ? this.client.request(`/post/${id}/downvotes?userId=${userId}`, {
|
|
135
|
+
method: 'DELETE',
|
|
136
|
+
}) : this.client.request(`/post/${id}/downvotes`, {
|
|
129
137
|
method: 'DELETE',
|
|
130
138
|
});
|
|
131
139
|
}
|
package/dist/resources/Tags.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare class TagsResource {
|
|
|
6
6
|
list(params?: {
|
|
7
7
|
query?: string;
|
|
8
8
|
cursor?: string;
|
|
9
|
+
limit?: number;
|
|
9
10
|
}): Promise<TagListResponse>;
|
|
10
11
|
create(payload: {
|
|
11
12
|
name: string;
|
|
@@ -31,15 +32,18 @@ export declare class TagsResource {
|
|
|
31
32
|
query?: string;
|
|
32
33
|
cursor?: string;
|
|
33
34
|
filter?: 'newest' | 'oldest';
|
|
35
|
+
limit?: number;
|
|
34
36
|
}): Promise<import('../types').ThreadListResponse>;
|
|
35
|
-
subscribe(id: string, userId
|
|
36
|
-
unsubscribe(id: string, userId
|
|
37
|
+
subscribe(id: string, userId?: string): Promise<any>;
|
|
38
|
+
unsubscribe(id: string, userId?: string): Promise<any>;
|
|
37
39
|
getSubscribers(id: string, params?: {
|
|
38
40
|
cursor?: string;
|
|
41
|
+
limit?: number;
|
|
39
42
|
}): Promise<any>;
|
|
40
43
|
listSubscribed(params: {
|
|
41
|
-
userId
|
|
44
|
+
userId?: string;
|
|
42
45
|
query?: string;
|
|
43
46
|
cursor?: string;
|
|
47
|
+
limit?: number;
|
|
44
48
|
}): Promise<TagListResponse>;
|
|
45
49
|
}
|
package/dist/resources/Tags.js
CHANGED
|
@@ -63,8 +63,9 @@ class TagsResource {
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
async unsubscribe(id, userId) {
|
|
66
|
-
return this.client.request(`/tag/${id}/subscribers
|
|
66
|
+
return this.client.request(`/tag/${id}/subscribers`, {
|
|
67
67
|
method: 'DELETE',
|
|
68
|
+
body: JSON.stringify({ userId }),
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
71
|
async getSubscribers(id, params) {
|
|
@@ -10,12 +10,13 @@ export declare class ThreadsResource {
|
|
|
10
10
|
type?: InteractionType;
|
|
11
11
|
cursor?: string;
|
|
12
12
|
userId?: string;
|
|
13
|
+
limit?: number;
|
|
13
14
|
}): Promise<ThreadListResponse>;
|
|
14
15
|
create(payload: import('../types').CreateThreadPayload): Promise<import('../types').Thread>;
|
|
15
16
|
retrieve(threadId: string): Promise<import('../types').Thread>;
|
|
16
17
|
update(threadId: string, payload: import('../types').UpdateThreadPayload): Promise<import('../types').Thread>;
|
|
17
18
|
delete(threadId: string, payload?: {
|
|
18
|
-
userId
|
|
19
|
+
userId?: string;
|
|
19
20
|
}): Promise<import('../types').Thread & {
|
|
20
21
|
deleted: boolean;
|
|
21
22
|
}>;
|
|
@@ -23,34 +24,40 @@ export declare class ThreadsResource {
|
|
|
23
24
|
query?: string;
|
|
24
25
|
cursor?: string;
|
|
25
26
|
filter?: 'newest' | 'oldest';
|
|
27
|
+
limit?: number;
|
|
26
28
|
}): Promise<any>;
|
|
27
29
|
like(id: string, userId?: string, extendedData?: any): Promise<any>;
|
|
28
|
-
unlike(id: string, userId
|
|
30
|
+
unlike(id: string, userId?: string): Promise<any>;
|
|
29
31
|
getLikes(id: string, params?: {
|
|
30
32
|
cursor?: string;
|
|
33
|
+
limit?: number;
|
|
31
34
|
}): Promise<any>;
|
|
32
35
|
dislike(id: string, userId?: string, extendedData?: any): Promise<any>;
|
|
33
|
-
undislike(id: string, userId
|
|
36
|
+
undislike(id: string, userId?: string): Promise<any>;
|
|
34
37
|
getDislikes(id: string, params?: {
|
|
35
38
|
cursor?: string;
|
|
39
|
+
limit?: number;
|
|
36
40
|
}): Promise<any>;
|
|
37
|
-
subscribe(id: string, userId
|
|
38
|
-
unsubscribe(id: string, userId
|
|
41
|
+
subscribe(id: string, userId?: string, extendedData?: any): Promise<any>;
|
|
42
|
+
unsubscribe(id: string, userId?: string): Promise<any>;
|
|
39
43
|
getSubscribers(id: string, params?: {
|
|
40
44
|
cursor?: string;
|
|
45
|
+
limit?: number;
|
|
41
46
|
}): Promise<any>;
|
|
42
47
|
upvote(id: string, userId?: string, extendedData?: any): Promise<any>;
|
|
43
|
-
unupvote(id: string, userId
|
|
48
|
+
unupvote(id: string, userId?: string): Promise<any>;
|
|
44
49
|
getUpvotes(id: string, params?: {
|
|
45
50
|
cursor?: string;
|
|
51
|
+
limit?: number;
|
|
46
52
|
}): Promise<any>;
|
|
47
53
|
downvote(id: string, userId?: string, extendedData?: any): Promise<any>;
|
|
48
|
-
undownvote(id: string, userId
|
|
54
|
+
undownvote(id: string, userId?: string): Promise<any>;
|
|
49
55
|
getDownvotes(id: string, params?: {
|
|
50
56
|
cursor?: string;
|
|
57
|
+
limit?: number;
|
|
51
58
|
}): Promise<any>;
|
|
52
59
|
getPoll(threadId: string, userId?: string): Promise<any>;
|
|
53
|
-
vote(id: string, optionId: string, userId
|
|
54
|
-
voteUpdate(id: string, optionId: string, userId
|
|
55
|
-
unvote(id: string, userId
|
|
60
|
+
vote(id: string, optionId: string, userId?: string): Promise<any>;
|
|
61
|
+
voteUpdate(id: string, optionId: string, userId?: string): Promise<any>;
|
|
62
|
+
unvote(id: string, userId?: string): Promise<any>;
|
|
56
63
|
}
|
|
@@ -59,8 +59,9 @@ class ThreadsResource {
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
async unlike(id, userId) {
|
|
62
|
-
return this.client.request(`/thread/${id}/likes
|
|
62
|
+
return this.client.request(`/thread/${id}/likes`, {
|
|
63
63
|
method: 'DELETE',
|
|
64
|
+
body: JSON.stringify({ userId }),
|
|
64
65
|
});
|
|
65
66
|
}
|
|
66
67
|
async getLikes(id, params) {
|
|
@@ -81,8 +82,9 @@ class ThreadsResource {
|
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
84
|
async undislike(id, userId) {
|
|
84
|
-
return this.client.request(`/thread/${id}/dislikes
|
|
85
|
+
return this.client.request(`/thread/${id}/dislikes`, {
|
|
85
86
|
method: 'DELETE',
|
|
87
|
+
body: JSON.stringify({ userId }),
|
|
86
88
|
});
|
|
87
89
|
}
|
|
88
90
|
async getDislikes(id, params) {
|
|
@@ -103,8 +105,9 @@ class ThreadsResource {
|
|
|
103
105
|
});
|
|
104
106
|
}
|
|
105
107
|
async unsubscribe(id, userId) {
|
|
106
|
-
return this.client.request(`/thread/${id}/subscribers
|
|
108
|
+
return this.client.request(`/thread/${id}/subscribers`, {
|
|
107
109
|
method: 'DELETE',
|
|
110
|
+
body: JSON.stringify({ userId }),
|
|
108
111
|
});
|
|
109
112
|
}
|
|
110
113
|
async getSubscribers(id, params) {
|
|
@@ -125,8 +128,9 @@ class ThreadsResource {
|
|
|
125
128
|
});
|
|
126
129
|
}
|
|
127
130
|
async unupvote(id, userId) {
|
|
128
|
-
return this.client.request(`/thread/${id}/upvotes
|
|
131
|
+
return this.client.request(`/thread/${id}/upvotes`, {
|
|
129
132
|
method: 'DELETE',
|
|
133
|
+
body: JSON.stringify({ userId }),
|
|
130
134
|
});
|
|
131
135
|
}
|
|
132
136
|
async getUpvotes(id, params) {
|
|
@@ -147,8 +151,9 @@ class ThreadsResource {
|
|
|
147
151
|
});
|
|
148
152
|
}
|
|
149
153
|
async undownvote(id, userId) {
|
|
150
|
-
return this.client.request(`/thread/${id}/downvotes
|
|
154
|
+
return this.client.request(`/thread/${id}/downvotes`, {
|
|
151
155
|
method: 'DELETE',
|
|
156
|
+
body: JSON.stringify({ userId }),
|
|
152
157
|
});
|
|
153
158
|
}
|
|
154
159
|
async getDownvotes(id, params) {
|
|
@@ -183,8 +188,9 @@ class ThreadsResource {
|
|
|
183
188
|
});
|
|
184
189
|
}
|
|
185
190
|
async unvote(id, userId) {
|
|
186
|
-
return this.client.request(`/thread/${id}/poll/votes
|
|
191
|
+
return this.client.request(`/thread/${id}/poll/votes`, {
|
|
187
192
|
method: 'DELETE',
|
|
193
|
+
body: JSON.stringify({ userId }),
|
|
188
194
|
});
|
|
189
195
|
}
|
|
190
196
|
}
|
|
@@ -7,6 +7,7 @@ export declare class UsersResource {
|
|
|
7
7
|
query?: string;
|
|
8
8
|
filter?: 'newest' | 'oldest';
|
|
9
9
|
cursor?: string;
|
|
10
|
+
limit?: number;
|
|
10
11
|
}): Promise<UserListResponse>;
|
|
11
12
|
retrieve(userId: string): Promise<User>;
|
|
12
13
|
create(payload: {
|
|
@@ -40,16 +41,19 @@ export declare class UsersResource {
|
|
|
40
41
|
query?: string;
|
|
41
42
|
cursor?: string;
|
|
42
43
|
filter?: 'newest' | 'oldest';
|
|
44
|
+
limit?: number;
|
|
43
45
|
}): Promise<import('../types').ThreadListResponse>;
|
|
44
46
|
getPosts(id: string, params?: {
|
|
45
47
|
query?: string;
|
|
46
48
|
cursor?: string;
|
|
47
49
|
filter?: 'newest' | 'oldest';
|
|
50
|
+
limit?: number;
|
|
48
51
|
}): Promise<import('../types').PostListResponse>;
|
|
49
52
|
getFollowers(id: string, params?: {
|
|
50
53
|
query?: string;
|
|
51
54
|
cursor?: string;
|
|
52
55
|
filter?: 'newest' | 'oldest';
|
|
56
|
+
limit?: number;
|
|
53
57
|
}): Promise<{
|
|
54
58
|
followers: User[];
|
|
55
59
|
nextUserCursor?: string;
|
|
@@ -61,6 +65,7 @@ export declare class UsersResource {
|
|
|
61
65
|
query?: string;
|
|
62
66
|
cursor?: string;
|
|
63
67
|
filter?: 'newest' | 'oldest';
|
|
68
|
+
limit?: number;
|
|
64
69
|
}): Promise<{
|
|
65
70
|
following: any[];
|
|
66
71
|
nextUserCursor?: string;
|
|
@@ -70,6 +70,8 @@ class WebhooksResource {
|
|
|
70
70
|
const searchParams = new URLSearchParams();
|
|
71
71
|
if (params === null || params === void 0 ? void 0 : params.cursor)
|
|
72
72
|
searchParams.append('cursor', params.cursor);
|
|
73
|
+
if (params === null || params === void 0 ? void 0 : params.limit)
|
|
74
|
+
searchParams.append('limit', params.limit.toString());
|
|
73
75
|
return this.client.request(`/webhooks/${id}/deliveries?${searchParams.toString()}`, {
|
|
74
76
|
method: 'GET',
|
|
75
77
|
});
|
|
@@ -79,7 +79,6 @@ async function main() {
|
|
|
79
79
|
const post = await client.posts.create({
|
|
80
80
|
threadId: newThread.id,
|
|
81
81
|
body: 'Thanks for posting! Check out our documentation.',
|
|
82
|
-
userId: 'moderator-123',
|
|
83
82
|
});
|
|
84
83
|
console.log('Post created:', post.id);
|
|
85
84
|
|
|
@@ -87,7 +86,6 @@ async function main() {
|
|
|
87
86
|
const reply = await client.posts.create({
|
|
88
87
|
threadId: newThread.id,
|
|
89
88
|
body: 'Thank you! That helps a lot.',
|
|
90
|
-
userId,
|
|
91
89
|
parentId: post.id, // This makes it a reply
|
|
92
90
|
});
|
|
93
91
|
console.log('Reply created:', reply.id);
|
package/examples/pagination.ts
CHANGED
|
@@ -58,8 +58,7 @@ async function main() {
|
|
|
58
58
|
const response = await client.posts.list({
|
|
59
59
|
cursor,
|
|
60
60
|
filter: 'newest',
|
|
61
|
-
type: 'created',
|
|
62
|
-
userId: 'user-123',
|
|
61
|
+
type: 'created',
|
|
63
62
|
});
|
|
64
63
|
|
|
65
64
|
console.log(`Page ${++pageCount}:`, response.posts.length, 'posts');
|
package/package.json
CHANGED
|
@@ -9,10 +9,11 @@ export class NotificationsResource {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
async list(params: {
|
|
12
|
-
userId
|
|
12
|
+
userId?: string;
|
|
13
13
|
read?: boolean;
|
|
14
14
|
filter?: 'newest' | 'oldest';
|
|
15
15
|
cursor?: string;
|
|
16
|
+
limit?: number;
|
|
16
17
|
}): Promise<NotificationListResponse> {
|
|
17
18
|
const searchParams = new URLSearchParams();
|
|
18
19
|
Object.entries(params).forEach(([key, value]) => {
|
|
@@ -26,7 +27,7 @@ export class NotificationsResource {
|
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
async markAllAsRead(userId
|
|
30
|
+
async markAllAsRead(userId?: string, read: boolean = true): Promise<{ count: number }> {
|
|
30
31
|
return this.client.request<{ count: number }>('/notifications', {
|
|
31
32
|
method: 'PATCH',
|
|
32
33
|
body: JSON.stringify({ userId, read }),
|
|
@@ -55,7 +56,7 @@ export class NotificationsResource {
|
|
|
55
56
|
threadId?: string;
|
|
56
57
|
postId?: string;
|
|
57
58
|
privateMessageId?: string;
|
|
58
|
-
notifierId
|
|
59
|
+
notifierId?: string;
|
|
59
60
|
notifiedId: string;
|
|
60
61
|
type: string;
|
|
61
62
|
description?: string;
|
package/src/resources/Posts.ts
CHANGED
|
@@ -14,6 +14,7 @@ export class PostsResource {
|
|
|
14
14
|
type?: InteractionType;
|
|
15
15
|
cursor?: string;
|
|
16
16
|
userId?: string;
|
|
17
|
+
limit?: number;
|
|
17
18
|
}): Promise<PostListResponse> {
|
|
18
19
|
const searchParams = new URLSearchParams();
|
|
19
20
|
if (params) {
|
|
@@ -49,7 +50,7 @@ export class PostsResource {
|
|
|
49
50
|
});
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
async delete(postId: string, payload?: { userId
|
|
53
|
+
async delete(postId: string, payload?: { userId?: string }): Promise<import('../types').Post & { deleted: boolean }> {
|
|
53
54
|
return this.client.request<import('../types').Post & { deleted: boolean }>(`/post/${postId}`, {
|
|
54
55
|
method: 'DELETE',
|
|
55
56
|
body: payload ? JSON.stringify(payload) : undefined,
|
|
@@ -59,6 +60,7 @@ export class PostsResource {
|
|
|
59
60
|
query?: string;
|
|
60
61
|
cursor?: string;
|
|
61
62
|
filter?: 'newest' | 'oldest';
|
|
63
|
+
limit?: number;
|
|
62
64
|
}): Promise<any> {
|
|
63
65
|
const searchParams = new URLSearchParams();
|
|
64
66
|
if (params) {
|
|
@@ -78,14 +80,17 @@ export class PostsResource {
|
|
|
78
80
|
});
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
async unlike(id: string, userId
|
|
82
|
-
return this.client.request(`/post/${id}/likes?userId=${userId}`, {
|
|
83
|
+
async unlike(id: string, userId?: string): Promise<any> {
|
|
84
|
+
return userId ? this.client.request(`/post/${id}/likes?userId=${userId}`, {
|
|
85
|
+
method: 'DELETE',
|
|
86
|
+
}) : this.client.request(`/post/${id}/likes`, {
|
|
83
87
|
method: 'DELETE',
|
|
84
88
|
});
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
async getLikes(id: string, params?: {
|
|
88
92
|
cursor?: string;
|
|
93
|
+
limit?: number;
|
|
89
94
|
}): Promise<any> {
|
|
90
95
|
const searchParams = new URLSearchParams();
|
|
91
96
|
if (params) {
|
|
@@ -105,14 +110,17 @@ export class PostsResource {
|
|
|
105
110
|
});
|
|
106
111
|
}
|
|
107
112
|
|
|
108
|
-
async undislike(id: string, userId
|
|
109
|
-
return this.client.request(`/post/${id}/dislikes?userId=${userId}`, {
|
|
113
|
+
async undislike(id: string, userId?: string): Promise<any> {
|
|
114
|
+
return userId ? this.client.request(`/post/${id}/dislikes?userId=${userId}`, {
|
|
115
|
+
method: 'DELETE',
|
|
116
|
+
}) : this.client.request(`/post/${id}/dislikes`, {
|
|
110
117
|
method: 'DELETE',
|
|
111
118
|
});
|
|
112
119
|
}
|
|
113
120
|
|
|
114
121
|
async getDislikes(id: string, params?: {
|
|
115
122
|
cursor?: string;
|
|
123
|
+
limit?: number;
|
|
116
124
|
}): Promise<any> {
|
|
117
125
|
const searchParams = new URLSearchParams();
|
|
118
126
|
if (params) {
|
|
@@ -132,14 +140,17 @@ export class PostsResource {
|
|
|
132
140
|
});
|
|
133
141
|
}
|
|
134
142
|
|
|
135
|
-
async unupvote(id: string, userId
|
|
136
|
-
return this.client.request(`/post/${id}/upvotes?userId=${userId}`, {
|
|
143
|
+
async unupvote(id: string, userId?: string): Promise<any> {
|
|
144
|
+
return userId ? this.client.request(`/post/${id}/upvotes?userId=${userId}`, {
|
|
145
|
+
method: 'DELETE',
|
|
146
|
+
}) : this.client.request(`/post/${id}/upvotes`, {
|
|
137
147
|
method: 'DELETE',
|
|
138
148
|
});
|
|
139
149
|
}
|
|
140
150
|
|
|
141
151
|
async getUpvotes(id: string, params?: {
|
|
142
152
|
cursor?: string;
|
|
153
|
+
limit?: number;
|
|
143
154
|
}): Promise<any> {
|
|
144
155
|
const searchParams = new URLSearchParams();
|
|
145
156
|
if (params) {
|
|
@@ -159,14 +170,17 @@ export class PostsResource {
|
|
|
159
170
|
});
|
|
160
171
|
}
|
|
161
172
|
|
|
162
|
-
async undownvote(id: string, userId
|
|
163
|
-
return this.client.request(`/post/${id}/downvotes?userId=${userId}`, {
|
|
173
|
+
async undownvote(id: string, userId?: string): Promise<any> {
|
|
174
|
+
return userId ? this.client.request(`/post/${id}/downvotes?userId=${userId}`, {
|
|
175
|
+
method: 'DELETE',
|
|
176
|
+
}) : this.client.request(`/post/${id}/downvotes`, {
|
|
164
177
|
method: 'DELETE',
|
|
165
178
|
});
|
|
166
179
|
}
|
|
167
180
|
|
|
168
181
|
async getDownvotes(id: string, params?: {
|
|
169
182
|
cursor?: string;
|
|
183
|
+
limit?: number;
|
|
170
184
|
}): Promise<any> {
|
|
171
185
|
const searchParams = new URLSearchParams();
|
|
172
186
|
if (params) {
|
package/src/resources/Reports.ts
CHANGED
package/src/resources/Roles.ts
CHANGED
package/src/resources/Search.ts
CHANGED
|
@@ -12,6 +12,7 @@ export class SearchResource {
|
|
|
12
12
|
query: string;
|
|
13
13
|
type: 'threads' | 'posts' | 'users' | 'tags';
|
|
14
14
|
cursor?: string;
|
|
15
|
+
limit?: number;
|
|
15
16
|
}): Promise<SearchResponse> {
|
|
16
17
|
const searchParams = new URLSearchParams();
|
|
17
18
|
Object.entries(params).forEach(([key, value]) => {
|
package/src/resources/Tags.ts
CHANGED
|
@@ -11,6 +11,7 @@ export class TagsResource {
|
|
|
11
11
|
async list(params?: {
|
|
12
12
|
query?: string;
|
|
13
13
|
cursor?: string;
|
|
14
|
+
limit?: number;
|
|
14
15
|
}): Promise<TagListResponse> {
|
|
15
16
|
const searchParams = new URLSearchParams();
|
|
16
17
|
if (params) {
|
|
@@ -68,6 +69,7 @@ export class TagsResource {
|
|
|
68
69
|
query?: string;
|
|
69
70
|
cursor?: string;
|
|
70
71
|
filter?: 'newest' | 'oldest';
|
|
72
|
+
limit?: number;
|
|
71
73
|
}): Promise<import('../types').ThreadListResponse> {
|
|
72
74
|
const searchParams = new URLSearchParams();
|
|
73
75
|
if (params) {
|
|
@@ -82,21 +84,23 @@ export class TagsResource {
|
|
|
82
84
|
});
|
|
83
85
|
}
|
|
84
86
|
|
|
85
|
-
async subscribe(id: string, userId
|
|
87
|
+
async subscribe(id: string, userId?: string): Promise<any> {
|
|
86
88
|
return this.client.request(`/tag/${id}/subscribers`, {
|
|
87
89
|
method: 'POST',
|
|
88
90
|
body: JSON.stringify({ userId }),
|
|
89
91
|
});
|
|
90
92
|
}
|
|
91
93
|
|
|
92
|
-
async unsubscribe(id: string, userId
|
|
93
|
-
return this.client.request(`/tag/${id}/subscribers
|
|
94
|
+
async unsubscribe(id: string, userId?: string): Promise<any> {
|
|
95
|
+
return this.client.request(`/tag/${id}/subscribers`, {
|
|
94
96
|
method: 'DELETE',
|
|
97
|
+
body: JSON.stringify({ userId }),
|
|
95
98
|
});
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
async getSubscribers(id: string, params?: {
|
|
99
102
|
cursor?: string;
|
|
103
|
+
limit?: number;
|
|
100
104
|
}): Promise<any> {
|
|
101
105
|
const searchParams = new URLSearchParams();
|
|
102
106
|
if (params) {
|
|
@@ -110,9 +114,10 @@ export class TagsResource {
|
|
|
110
114
|
}
|
|
111
115
|
|
|
112
116
|
async listSubscribed(params: {
|
|
113
|
-
userId
|
|
117
|
+
userId?: string;
|
|
114
118
|
query?: string;
|
|
115
119
|
cursor?: string;
|
|
120
|
+
limit?: number;
|
|
116
121
|
}): Promise<TagListResponse> {
|
|
117
122
|
const searchParams = new URLSearchParams();
|
|
118
123
|
Object.entries(params).forEach(([key, value]) => {
|
package/src/resources/Threads.ts
CHANGED
|
@@ -15,6 +15,7 @@ export class ThreadsResource {
|
|
|
15
15
|
type?: InteractionType;
|
|
16
16
|
cursor?: string;
|
|
17
17
|
userId?: string;
|
|
18
|
+
limit?: number;
|
|
18
19
|
}): Promise<ThreadListResponse> {
|
|
19
20
|
const searchParams = new URLSearchParams();
|
|
20
21
|
if (params) {
|
|
@@ -50,7 +51,7 @@ export class ThreadsResource {
|
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
async delete(threadId: string, payload?: { userId
|
|
54
|
+
async delete(threadId: string, payload?: { userId?: string }): Promise<import('../types').Thread & { deleted: boolean }> {
|
|
54
55
|
return this.client.request<import('../types').Thread & { deleted: boolean }>(`/thread/${threadId}`, {
|
|
55
56
|
method: 'DELETE',
|
|
56
57
|
body: payload ? JSON.stringify(payload) : undefined,
|
|
@@ -60,6 +61,7 @@ export class ThreadsResource {
|
|
|
60
61
|
query?: string;
|
|
61
62
|
cursor?: string;
|
|
62
63
|
filter?: 'newest' | 'oldest';
|
|
64
|
+
limit?: number;
|
|
63
65
|
}): Promise<any> {
|
|
64
66
|
const searchParams = new URLSearchParams();
|
|
65
67
|
if (params) {
|
|
@@ -79,14 +81,16 @@ export class ThreadsResource {
|
|
|
79
81
|
});
|
|
80
82
|
}
|
|
81
83
|
|
|
82
|
-
async unlike(id: string, userId
|
|
83
|
-
return this.client.request(`/thread/${id}/likes
|
|
84
|
+
async unlike(id: string, userId?: string): Promise<any> {
|
|
85
|
+
return this.client.request(`/thread/${id}/likes`, {
|
|
84
86
|
method: 'DELETE',
|
|
87
|
+
body: JSON.stringify({ userId }),
|
|
85
88
|
});
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
async getLikes(id: string, params?: {
|
|
89
92
|
cursor?: string;
|
|
93
|
+
limit?: number;
|
|
90
94
|
}): Promise<any> {
|
|
91
95
|
const searchParams = new URLSearchParams();
|
|
92
96
|
if (params) {
|
|
@@ -106,14 +110,16 @@ export class ThreadsResource {
|
|
|
106
110
|
});
|
|
107
111
|
}
|
|
108
112
|
|
|
109
|
-
async undislike(id: string, userId
|
|
110
|
-
return this.client.request(`/thread/${id}/dislikes
|
|
113
|
+
async undislike(id: string, userId?: string): Promise<any> {
|
|
114
|
+
return this.client.request(`/thread/${id}/dislikes`, {
|
|
111
115
|
method: 'DELETE',
|
|
116
|
+
body: JSON.stringify({ userId }),
|
|
112
117
|
});
|
|
113
118
|
}
|
|
114
119
|
|
|
115
120
|
async getDislikes(id: string, params?: {
|
|
116
121
|
cursor?: string;
|
|
122
|
+
limit?: number;
|
|
117
123
|
}): Promise<any> {
|
|
118
124
|
const searchParams = new URLSearchParams();
|
|
119
125
|
if (params) {
|
|
@@ -126,21 +132,23 @@ export class ThreadsResource {
|
|
|
126
132
|
return this.client.request(`/thread/${id}/dislikes?${searchParams.toString()}`, { method: 'GET' });
|
|
127
133
|
}
|
|
128
134
|
|
|
129
|
-
async subscribe(id: string, userId
|
|
135
|
+
async subscribe(id: string, userId?: string, extendedData?: any): Promise<any> {
|
|
130
136
|
return this.client.request(`/thread/${id}/subscribers`, {
|
|
131
137
|
method: 'POST',
|
|
132
138
|
body: JSON.stringify({ userId, extendedData }),
|
|
133
139
|
});
|
|
134
140
|
}
|
|
135
141
|
|
|
136
|
-
async unsubscribe(id: string, userId
|
|
137
|
-
return this.client.request(`/thread/${id}/subscribers
|
|
142
|
+
async unsubscribe(id: string, userId?: string): Promise<any> {
|
|
143
|
+
return this.client.request(`/thread/${id}/subscribers`, {
|
|
138
144
|
method: 'DELETE',
|
|
145
|
+
body: JSON.stringify({ userId }),
|
|
139
146
|
});
|
|
140
147
|
}
|
|
141
148
|
|
|
142
149
|
async getSubscribers(id: string, params?: {
|
|
143
150
|
cursor?: string;
|
|
151
|
+
limit?: number;
|
|
144
152
|
}): Promise<any> {
|
|
145
153
|
const searchParams = new URLSearchParams();
|
|
146
154
|
if (params) {
|
|
@@ -160,14 +168,16 @@ export class ThreadsResource {
|
|
|
160
168
|
});
|
|
161
169
|
}
|
|
162
170
|
|
|
163
|
-
async unupvote(id: string, userId
|
|
164
|
-
return this.client.request(`/thread/${id}/upvotes
|
|
171
|
+
async unupvote(id: string, userId?: string): Promise<any> {
|
|
172
|
+
return this.client.request(`/thread/${id}/upvotes`, {
|
|
165
173
|
method: 'DELETE',
|
|
174
|
+
body: JSON.stringify({ userId }),
|
|
166
175
|
});
|
|
167
176
|
}
|
|
168
177
|
|
|
169
178
|
async getUpvotes(id: string, params?: {
|
|
170
179
|
cursor?: string;
|
|
180
|
+
limit?: number;
|
|
171
181
|
}): Promise<any> {
|
|
172
182
|
const searchParams = new URLSearchParams();
|
|
173
183
|
if (params) {
|
|
@@ -187,14 +197,16 @@ export class ThreadsResource {
|
|
|
187
197
|
});
|
|
188
198
|
}
|
|
189
199
|
|
|
190
|
-
async undownvote(id: string, userId
|
|
191
|
-
return this.client.request(`/thread/${id}/downvotes
|
|
200
|
+
async undownvote(id: string, userId?: string): Promise<any> {
|
|
201
|
+
return this.client.request(`/thread/${id}/downvotes`, {
|
|
192
202
|
method: 'DELETE',
|
|
203
|
+
body: JSON.stringify({ userId }),
|
|
193
204
|
});
|
|
194
205
|
}
|
|
195
206
|
|
|
196
207
|
async getDownvotes(id: string, params?: {
|
|
197
208
|
cursor?: string;
|
|
209
|
+
limit?: number;
|
|
198
210
|
}): Promise<any> {
|
|
199
211
|
const searchParams = new URLSearchParams();
|
|
200
212
|
if (params) {
|
|
@@ -220,23 +232,24 @@ export class ThreadsResource {
|
|
|
220
232
|
);
|
|
221
233
|
}
|
|
222
234
|
|
|
223
|
-
async vote(id: string, optionId: string, userId
|
|
235
|
+
async vote(id: string, optionId: string, userId?: string): Promise<any> {
|
|
224
236
|
return this.client.request(`/thread/${id}/poll/votes`, {
|
|
225
237
|
method: 'POST',
|
|
226
238
|
body: JSON.stringify({ optionId, userId }),
|
|
227
239
|
});
|
|
228
240
|
}
|
|
229
241
|
|
|
230
|
-
async voteUpdate(id: string, optionId: string, userId
|
|
242
|
+
async voteUpdate(id: string, optionId: string, userId?: string): Promise<any> {
|
|
231
243
|
return this.client.request(`/thread/${id}/poll/votes`, {
|
|
232
244
|
method: 'PUT',
|
|
233
245
|
body: JSON.stringify({ optionId, userId }),
|
|
234
246
|
});
|
|
235
247
|
}
|
|
236
248
|
|
|
237
|
-
async unvote(id: string, userId
|
|
238
|
-
return this.client.request(`/thread/${id}/poll/votes
|
|
249
|
+
async unvote(id: string, userId?: string): Promise<any> {
|
|
250
|
+
return this.client.request(`/thread/${id}/poll/votes`, {
|
|
239
251
|
method: 'DELETE',
|
|
252
|
+
body: JSON.stringify({ userId }),
|
|
240
253
|
});
|
|
241
254
|
}
|
|
242
255
|
}
|
package/src/resources/Users.ts
CHANGED
|
@@ -12,6 +12,7 @@ export class UsersResource {
|
|
|
12
12
|
query?: string;
|
|
13
13
|
filter?: 'newest' | 'oldest';
|
|
14
14
|
cursor?: string;
|
|
15
|
+
limit?: number;
|
|
15
16
|
}): Promise<UserListResponse> {
|
|
16
17
|
const searchParams = new URLSearchParams();
|
|
17
18
|
if (params) {
|
|
@@ -79,6 +80,7 @@ export class UsersResource {
|
|
|
79
80
|
query?: string;
|
|
80
81
|
cursor?: string;
|
|
81
82
|
filter?: 'newest' | 'oldest';
|
|
83
|
+
limit?: number;
|
|
82
84
|
}): Promise<import('../types').ThreadListResponse> {
|
|
83
85
|
const searchParams = new URLSearchParams();
|
|
84
86
|
if (params) {
|
|
@@ -97,6 +99,7 @@ export class UsersResource {
|
|
|
97
99
|
query?: string;
|
|
98
100
|
cursor?: string;
|
|
99
101
|
filter?: 'newest' | 'oldest';
|
|
102
|
+
limit?: number;
|
|
100
103
|
}): Promise<import('../types').PostListResponse> {
|
|
101
104
|
const searchParams = new URLSearchParams();
|
|
102
105
|
if (params) {
|
|
@@ -115,6 +118,7 @@ export class UsersResource {
|
|
|
115
118
|
query?: string;
|
|
116
119
|
cursor?: string;
|
|
117
120
|
filter?: 'newest' | 'oldest';
|
|
121
|
+
limit?: number;
|
|
118
122
|
}): Promise<{ followers: User[]; nextUserCursor?: string; count: number }> {
|
|
119
123
|
const searchParams = new URLSearchParams();
|
|
120
124
|
if (params) {
|
|
@@ -146,6 +150,7 @@ export class UsersResource {
|
|
|
146
150
|
query?: string;
|
|
147
151
|
cursor?: string;
|
|
148
152
|
filter?: 'newest' | 'oldest';
|
|
153
|
+
limit?: number;
|
|
149
154
|
}): Promise<{ following: any[]; nextUserCursor?: string; count: number }> {
|
|
150
155
|
const searchParams = new URLSearchParams();
|
|
151
156
|
if (params) {
|
|
@@ -83,9 +83,10 @@ export class WebhooksResource {
|
|
|
83
83
|
* @param params - Query parameters
|
|
84
84
|
* @returns Promise resolving to delivery history
|
|
85
85
|
*/
|
|
86
|
-
async getDeliveries(id: string, params?: { cursor?: string }): Promise<{ deliveries: any[]; total: number; nextCursor?: string }> {
|
|
86
|
+
async getDeliveries(id: string, params?: { cursor?: string; limit?: number }): Promise<{ deliveries: any[]; total: number; nextCursor?: string }> {
|
|
87
87
|
const searchParams = new URLSearchParams();
|
|
88
88
|
if (params?.cursor) searchParams.append('cursor', params.cursor);
|
|
89
|
+
if (params?.limit) searchParams.append('limit', params.limit.toString());
|
|
89
90
|
|
|
90
91
|
return this.client.request<{ deliveries: any[]; total: number; nextCursor?: string }>(`/webhooks/${id}/deliveries?${searchParams.toString()}`, {
|
|
91
92
|
method: 'GET',
|