@foru-ms/sdk 1.2.5 → 1.2.7

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 CHANGED
@@ -210,12 +210,12 @@ Check the `/examples` directory for detailed examples:
210
210
  ### Threads (`client.threads`)
211
211
 
212
212
  **Thread Management**
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).
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).
214
214
  * `create(payload: CreateThreadPayload)`: Create a new thread.
215
215
  * `retrieve(id: string)`: Get a thread by ID.
216
216
  * `update(id: string, payload: UpdateThreadPayload)`: Update a thread.
217
217
  * `delete(id: string)`: Delete a thread.
218
- * `getPosts(id: string, params: { query?: string; cursor?: string; filter?: 'newest' | 'oldest'; limit?: number })`: Get posts in a thread.
218
+ * `getPosts(id: string, params?: { query?: string; cursor?: string; filter?: 'newest' | 'oldest'; limit?: number })`: Get posts in a thread.
219
219
 
220
220
  **Thread Interactions**
221
221
  * `like(id: string, userId?: string, extendedData?: any)`: Like a thread.
@@ -249,7 +249,7 @@ Check the `/examples` directory for detailed examples:
249
249
  ### Posts (`client.posts`)
250
250
 
251
251
  **Post Management**
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).
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).
253
253
  * `create(payload: CreatePostPayload)`: Create a new post/reply.
254
254
  * `retrieve(id: string)`: Get a post by ID.
255
255
  * `update(id: string, payload: UpdatePostPayload)`: Update a post.
@@ -288,7 +288,7 @@ Check the `/examples` directory for detailed examples:
288
288
  ### Tags (`client.tags`)
289
289
 
290
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.
291
+ * `listSubscribed(params?: { userId?: string; query?: string; cursor?: string; limit?: number })`: List tags a user is subscribed to.
292
292
  * `create(payload: { name: string; description?: string; color?: string; extendedData?: Record<string, any> })`: Create a tag.
293
293
  * `retrieve(id: string, params?: { userId?: string })`: Get a tag with optional user context.
294
294
  * `update(id: string, payload: { name?: string; description?: string; color?: string; extendedData?: Record<string, any> })`: Update a tag.
@@ -301,7 +301,7 @@ Check the `/examples` directory for detailed examples:
301
301
 
302
302
  ### Notifications (`client.notifications`)
303
303
 
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).
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).
305
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.
306
306
  * `retrieve(id: string, userId?: string)`: Get a notification by ID.
307
307
  * `update(id: string, payload: { userId?: string; read: boolean })`: Update a notification's read status.
@@ -552,6 +552,12 @@ We welcome contributions! Please see our contributing guidelines for more inform
552
552
 
553
553
  ## Changelog
554
554
 
555
+ ### v1.2.7
556
+ - Fixed issue with optional parameters not being optional in typescript
557
+
558
+ ### v1.2.6
559
+ - Fixed issue with optional parameters not being optional in typescript
560
+
555
561
  ### v1.2.5
556
562
  - Added optional `userId` parameter to methods that accept it
557
563
 
@@ -3,7 +3,7 @@ import { NotificationListResponse, Notification } from '../types';
3
3
  export declare class NotificationsResource {
4
4
  private client;
5
5
  constructor(client: ForumClient);
6
- list(params: {
6
+ list(params?: {
7
7
  userId?: string;
8
8
  read?: boolean;
9
9
  filter?: 'newest' | 'oldest';
@@ -7,11 +7,13 @@ class NotificationsResource {
7
7
  }
8
8
  async list(params) {
9
9
  const searchParams = new URLSearchParams();
10
- Object.entries(params).forEach(([key, value]) => {
11
- if (value !== undefined) {
12
- searchParams.append(key, String(value));
13
- }
14
- });
10
+ if (params) {
11
+ Object.entries(params).forEach(([key, value]) => {
12
+ if (value !== undefined) {
13
+ searchParams.append(key, String(value));
14
+ }
15
+ });
16
+ }
15
17
  return this.client.request(`/notifications?${searchParams.toString()}`, {
16
18
  method: 'GET',
17
19
  });
@@ -40,7 +40,7 @@ export declare class TagsResource {
40
40
  cursor?: string;
41
41
  limit?: number;
42
42
  }): Promise<any>;
43
- listSubscribed(params: {
43
+ listSubscribed(params?: {
44
44
  userId?: string;
45
45
  query?: string;
46
46
  cursor?: string;
@@ -81,11 +81,13 @@ class TagsResource {
81
81
  }
82
82
  async listSubscribed(params) {
83
83
  const searchParams = new URLSearchParams();
84
- Object.entries(params).forEach(([key, value]) => {
85
- if (value !== undefined) {
86
- searchParams.append(key, value);
87
- }
88
- });
84
+ if (params) {
85
+ Object.entries(params).forEach(([key, value]) => {
86
+ if (value !== undefined) {
87
+ searchParams.append(key, value);
88
+ }
89
+ });
90
+ }
89
91
  return this.client.request(`/tags/subscribed?${searchParams.toString()}`, {
90
92
  method: 'GET',
91
93
  });
@@ -59,8 +59,8 @@ export declare class UsersResource {
59
59
  nextUserCursor?: string;
60
60
  count: number;
61
61
  }>;
62
- follow(id: string, followerId: string, extendedData?: any): Promise<any>;
63
- unfollow(id: string, followerId: string): Promise<any>;
62
+ follow(id: string, followerId?: string, extendedData?: any): Promise<any>;
63
+ unfollow(id: string, followerId?: string): Promise<any>;
64
64
  getFollowing(id: string, params?: {
65
65
  query?: string;
66
66
  cursor?: string;
@@ -86,8 +86,9 @@ class UsersResource {
86
86
  });
87
87
  }
88
88
  async unfollow(id, followerId) {
89
- return this.client.request(`/user/${id}/followers?followerId=${followerId}`, {
89
+ return this.client.request(`/user/${id}/followers`, {
90
90
  method: 'DELETE',
91
+ body: JSON.stringify({ followerId }),
91
92
  });
92
93
  }
93
94
  async getFollowing(id, params) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foru-ms/sdk",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "JavaScript SDK for Foru.ms",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,7 +8,7 @@ export class NotificationsResource {
8
8
  this.client = client;
9
9
  }
10
10
 
11
- async list(params: {
11
+ async list(params?: {
12
12
  userId?: string;
13
13
  read?: boolean;
14
14
  filter?: 'newest' | 'oldest';
@@ -16,11 +16,13 @@ export class NotificationsResource {
16
16
  limit?: number;
17
17
  }): Promise<NotificationListResponse> {
18
18
  const searchParams = new URLSearchParams();
19
- Object.entries(params).forEach(([key, value]) => {
20
- if (value !== undefined) {
21
- searchParams.append(key, String(value));
22
- }
23
- });
19
+ if (params) {
20
+ Object.entries(params).forEach(([key, value]) => {
21
+ if (value !== undefined) {
22
+ searchParams.append(key, String(value));
23
+ }
24
+ });
25
+ }
24
26
 
25
27
  return this.client.request<NotificationListResponse>(`/notifications?${searchParams.toString()}`, {
26
28
  method: 'GET',
@@ -113,18 +113,20 @@ export class TagsResource {
113
113
  return this.client.request(`/tag/${id}/subscribers?${searchParams.toString()}`, { method: 'GET' });
114
114
  }
115
115
 
116
- async listSubscribed(params: {
116
+ async listSubscribed(params?: {
117
117
  userId?: string;
118
118
  query?: string;
119
119
  cursor?: string;
120
120
  limit?: number;
121
121
  }): Promise<TagListResponse> {
122
122
  const searchParams = new URLSearchParams();
123
- Object.entries(params).forEach(([key, value]) => {
124
- if (value !== undefined) {
125
- searchParams.append(key, value as string);
126
- }
127
- });
123
+ if (params) {
124
+ Object.entries(params).forEach(([key, value]) => {
125
+ if (value !== undefined) {
126
+ searchParams.append(key, value as string);
127
+ }
128
+ });
129
+ }
128
130
 
129
131
  return this.client.request<TagListResponse>(`/tags/subscribed?${searchParams.toString()}`, {
130
132
  method: 'GET',
@@ -133,16 +133,17 @@ export class UsersResource {
133
133
  });
134
134
  }
135
135
 
136
- async follow(id: string, followerId: string, extendedData?: any): Promise<any> {
136
+ async follow(id: string, followerId?: string, extendedData?: any): Promise<any> {
137
137
  return this.client.request(`/user/${id}/followers`, {
138
138
  method: 'POST',
139
139
  body: JSON.stringify({ followerId, extendedData }),
140
140
  });
141
141
  }
142
142
 
143
- async unfollow(id: string, followerId: string): Promise<any> {
144
- return this.client.request(`/user/${id}/followers?followerId=${followerId}`, {
143
+ async unfollow(id: string, followerId?: string): Promise<any> {
144
+ return this.client.request(`/user/${id}/followers`, {
145
145
  method: 'DELETE',
146
+ body: JSON.stringify({ followerId }),
146
147
  });
147
148
  }
148
149