@foru-ms/sdk 0.1.0 → 1.1.0

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.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +189 -0
  3. package/dist/Client.d.ts +18 -0
  4. package/dist/Client.js +18 -0
  5. package/dist/index.d.ts +9 -0
  6. package/dist/index.js +9 -0
  7. package/dist/resources/Auth.d.ts +12 -0
  8. package/dist/resources/Auth.js +19 -0
  9. package/dist/resources/Integrations.d.ts +20 -0
  10. package/dist/resources/Integrations.js +30 -0
  11. package/dist/resources/Notifications.d.ts +32 -0
  12. package/dist/resources/Notifications.js +48 -0
  13. package/dist/resources/Posts.d.ts +13 -0
  14. package/dist/resources/Posts.js +55 -0
  15. package/dist/resources/PrivateMessages.d.ts +29 -0
  16. package/dist/resources/PrivateMessages.js +44 -0
  17. package/dist/resources/Reports.d.ts +46 -0
  18. package/dist/resources/Reports.js +56 -0
  19. package/dist/resources/Roles.d.ts +26 -0
  20. package/dist/resources/Roles.js +44 -0
  21. package/dist/resources/SSO.d.ts +17 -0
  22. package/dist/resources/SSO.js +25 -0
  23. package/dist/resources/Search.d.ts +11 -0
  24. package/dist/resources/Search.js +20 -0
  25. package/dist/resources/Stats.d.ts +13 -0
  26. package/dist/resources/Stats.js +22 -0
  27. package/dist/resources/Tags.d.ts +27 -0
  28. package/dist/resources/Tags.js +47 -0
  29. package/dist/resources/Threads.d.ts +14 -0
  30. package/dist/resources/Threads.js +61 -0
  31. package/dist/resources/Users.d.ts +47 -0
  32. package/dist/resources/Users.js +54 -0
  33. package/dist/resources/Webhooks.d.ts +35 -0
  34. package/dist/resources/Webhooks.js +44 -0
  35. package/dist/types.d.ts +149 -0
  36. package/package.json +17 -4
  37. package/src/Client.ts +27 -0
  38. package/src/index.ts +9 -0
  39. package/src/resources/Auth.ts +28 -0
  40. package/src/resources/Integrations.ts +39 -0
  41. package/src/resources/Notifications.ts +69 -0
  42. package/src/resources/Posts.ts +67 -0
  43. package/src/resources/PrivateMessages.ts +67 -0
  44. package/src/resources/Reports.ts +93 -0
  45. package/src/resources/Roles.ts +64 -0
  46. package/src/resources/SSO.ts +33 -0
  47. package/src/resources/Search.ts +27 -0
  48. package/src/resources/Stats.ts +31 -0
  49. package/src/resources/Tags.ts +68 -0
  50. package/src/resources/Threads.ts +74 -0
  51. package/src/resources/Users.ts +91 -0
  52. package/src/resources/Webhooks.ts +60 -0
  53. package/src/types.ts +165 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Foru.ms
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,189 @@
1
+ # @foru-ms/sdk
2
+
3
+ The official JavaScript/TypeScript SDK for [Foru.ms](https://foru.ms). Build powerful community features directly into your application.
4
+
5
+ This SDK is fully typed and provides a comprehensive interface to the Foru.ms API.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @foru-ms/sdk
11
+ # or
12
+ yarn add @foru-ms/sdk
13
+ # or
14
+ pnpm add @foru-ms/sdk
15
+ ```
16
+
17
+ ## Setup & Initialization
18
+
19
+ ```typescript
20
+ import { ForumClient } from '@foru-ms/sdk';
21
+
22
+ const client = new ForumClient({
23
+ apiKey: 'your_api_key',
24
+ // baseUrl: 'https://api.foru.ms/v1' // Optional
25
+ });
26
+
27
+ // Set an authentication token (JWT) for user-scoped requests
28
+ client.setToken('user_jwt_token');
29
+ ```
30
+
31
+ ## API Reference
32
+
33
+ ### Auth (`client.auth`)
34
+
35
+ * `login(payload: { login: string; password: string })`: Login a user. Returns `{ token: string }`.
36
+ * `register(payload: RegisterPayload)`: Register a new user.
37
+ * `me()`: Get specific details of the currently authenticated user.
38
+ * `forgotPassword(email: string)`: Initiate password reset flow.
39
+ * `resetPassword(payload: { password: string; oldPassword?: string; email?: string; token?: string })`: Reset password using token or old password.
40
+
41
+ ### Threads (`client.threads`)
42
+
43
+ * `list(params: { limit?: number; filter?: 'newest' | 'oldest'; tagId?: string; categoryId?: string; cursor?: string })`: List threads.
44
+ * `create(payload: CreateThreadPayload)`: Create a new thread.
45
+ * `retrieve(id: string)`: Get a thread by ID.
46
+ * `update(id: string, payload: UpdateThreadPayload)`: Update a thread.
47
+ * `delete(id: string)`: Delete a thread.
48
+ * `getPosts(id: string, params: { cursor?: string; filter?: 'newest' | 'oldest' })`: Get posts in a thread.
49
+ * `like(id: string, userId: string, extendedData?: any)`: Like a thread.
50
+ * `unlike(id: string, userId: string)`: Unlike a thread.
51
+ * `dislike(id: string, userId: string, extendedData?: any)`: Dislike a thread.
52
+ * `undislike(id: string, userId: string)`: Remove dislike from a thread.
53
+ * `subscribe(id: string, userId: string)`: Subscribe to a thread.
54
+ * `unsubscribe(id: string, userId: string)`: Unsubscribe from a thread.
55
+ * `vote(id: string, userId: string, optionId: string)`: Vote in a thread poll.
56
+ * `voteUpdate(id: string, userId: string, optionId: string)`: Change vote.
57
+ * `unvote(id: string, userId: string)`: Remove vote.
58
+
59
+ ### Posts (`client.posts`)
60
+
61
+ * `list(params: { limit?: number; cursor?: string; filter?: 'newest' | 'oldest'; threadId?: string })`: List posts (flat).
62
+ * `create(payload: CreatePostPayload)`: Create a reply.
63
+ * `retrieve(id: string)`: Get a post by ID.
64
+ * `update(id: string, payload: UpdatePostPayload)`: Update a post.
65
+ * `delete(id: string)`: Delete a post.
66
+ * `getChildren(id: string, params: { cursor?: string; filter?: 'newest' | 'oldest' })`: Get child posts (nested replies).
67
+ * `like(id: string, userId: string, extendedData?: any)`: Like a post.
68
+ * `unlike(id: string, userId: string)`: Unlike a post.
69
+ * `dislike(id: string, userId: string, extendedData?: any)`: Dislike a post.
70
+ * `undislike(id: string, userId: string)`: Remove dislike.
71
+ * `upvote(id: string, userId: string, extendedData?: any)`: Upvote a post.
72
+ * `unupvote(id: string, userId: string)`: Remove upvote.
73
+ * `downvote(id: string, userId: string, extendedData?: any)`: Downvote a post.
74
+ * `undownvote(id: string, userId: string)`: Remove downvote.
75
+
76
+ ### Users (`client.users`)
77
+
78
+ * `list(params: { query?: string; filter?: 'newest' | 'oldest'; cursor?: string })`: List users.
79
+ * `retrieve(id: string)`: Get user by ID.
80
+ * `create(payload: any)`: Create a user (Admin).
81
+ * `update(id: string, payload: any)`: Update a user.
82
+ * `delete(id: string)`: Delete a user.
83
+ * `getFollowers(id: string, params: { cursor?: string })`: Get user's followers.
84
+ * `getFollowing(id: string, params: { cursor?: string })`: Get who a user follows.
85
+ * `follow(id: string, followerId: string, extendedData?: any)`: Follow a user.
86
+ * `unfollow(id: string, followerId: string)`: Unfollow a user.
87
+
88
+ ### Tags (`client.tags`)
89
+
90
+ * `list(params: { query?: string; cursor?: string })`: List tags.
91
+ * `create(payload: { name: string; description?: string; color?: string; extendedData?: any })`: Create a tag.
92
+ * `retrieve(id: string, params?: { userId?: string })`: Get a tag.
93
+ * `update(id: string, payload: any)`: Update a tag.
94
+ * `delete(id: string)`: Delete a tag.
95
+ * `subscribe(id: string, userId: string)`: Subscribe to a tag.
96
+ * `unsubscribe(id: string, userId: string)`: Unsubscribe from a tag.
97
+ * `listSubscribed(params: { userId: string; cursor?: string })`: List tags a user is subscribed to.
98
+
99
+ ### Notifications (`client.notifications`)
100
+
101
+ * `list(params: { userId: string; read?: boolean; filter?: string; cursor?: string })`: List notifications.
102
+ * `markAllAsRead(userId: string, read?: boolean)`: Bulk update read status.
103
+ * `create(payload: any)`: Create a notification manually.
104
+ * `retrieve(id: string)`: Get a notification.
105
+ * `update(id: string, payload: { read: boolean })`: Update a notification.
106
+ * `delete(id: string)`: Delete a notification.
107
+
108
+ ### Search (`client.search`)
109
+
110
+ * `search(params: { query: string; type: 'threads' | 'posts' | 'users' | 'tags'; cursor?: string })`: Polymorphic search.
111
+
112
+ ### Webhooks (`client.webhooks`)
113
+
114
+ * `list()`: List webhooks.
115
+ * `create(payload: { name: string; url: string; events: string[] })`: Create a webhook.
116
+ * `retrieve(id: string)`: Get a webhook.
117
+ * `update(id: string, payload: any)`: Update a webhook.
118
+ * `delete(id: string)`: Delete a webhook.
119
+ * `getDeliveries(id: string, params: { cursor?: string })`: Get webhook delivery history.
120
+
121
+ ### Stats (`client.stats`)
122
+
123
+ * `get(params?: { filter?: string; threadCursor?: string; postCursor?: string; ... })`: Get instance statistics.
124
+
125
+ ### Integrations (`client.integrations`)
126
+
127
+ * `list()`: Get all configured integrations.
128
+ * `create(payload: { type: string; name: string; config: any })`: Configure an integration (Slack, Discord, etc.).
129
+ * `retrieve(id: string)`: Get integration details.
130
+ * `delete(id: string)`: Remove an integration.
131
+
132
+ ### Private Messages (`client.privateMessages`)
133
+
134
+ * `list(params: { userId?: string; cursor?: string })`: List private messages.
135
+ * `create(payload: { title?: string; body: string; recipientId: string; senderId?: string })`: Send a direct message.
136
+ * `retrieve(id: string)`: Get a message thread.
137
+ * `reply(id: string, payload: { body: string; senderId: string; recipientId: string })`: Reply to a message.
138
+ * `delete(id: string)`: Delete a message.
139
+
140
+ ### Reports (`client.reports`)
141
+
142
+ * `list(params: { reporterId?: string; reportedId?: string; read?: boolean; cursor?: string })`: List reports.
143
+ * `create(payload: { reporterId: string; type: string; description?: string; ... })`: Submit a report.
144
+ * `batchUpdate(payload: { reportIds: string[]; read: boolean })`: Bulk update status.
145
+ * `retrieve(id: string)`: Get a report.
146
+ * `update(id: string, payload: any)`: Update report details.
147
+ * `delete(id: string)`: Delete a report.
148
+ * `updateStatus(id: string, read: boolean)`: Update read status of a report.
149
+
150
+ ### Roles (`client.roles`)
151
+
152
+ * `list(params: { cursor?: string })`: List user roles.
153
+ * `create(payload: { name: string; description?: string; color?: string })`: Create a new role.
154
+ * `retrieve(id: string)`: Get a role.
155
+ * `update(id: string, payload: any)`: Update a role.
156
+ * `delete(id: string)`: Delete a role.
157
+
158
+ ### SSO (`client.sso`)
159
+
160
+ * `list()`: List SSO providers.
161
+ * `create(payload: { provider: string; domain: string; config: any })`: Configure SSO.
162
+ * `delete(id: string)`: Remove SSO provider.
163
+
164
+ ## Types
165
+
166
+ Import interfaces directly from the package:
167
+
168
+ ```typescript
169
+ import {
170
+ Thread, Post, User, Tag, Notification,
171
+ LoginResponse, RegisterPayload
172
+ } from '@foru-ms/sdk';
173
+ ```
174
+
175
+ ## Error Handling
176
+
177
+ All methods return a Promise. If the API returns a non-200 status, the Promise rejects with an Error object containing the server message.
178
+
179
+ ```typescript
180
+ try {
181
+ await client.threads.create({ ... });
182
+ } catch (err: any) {
183
+ console.error("Error creating thread:", err.message);
184
+ }
185
+ ```
186
+
187
+ ## License
188
+
189
+ MIT
package/dist/Client.d.ts CHANGED
@@ -3,6 +3,15 @@ import { ThreadsResource } from './resources/Threads';
3
3
  import { PostsResource } from './resources/Posts';
4
4
  import { UsersResource } from './resources/Users';
5
5
  import { TagsResource } from './resources/Tags';
6
+ import { NotificationsResource } from './resources/Notifications';
7
+ import { SearchResource } from './resources/Search';
8
+ import { WebhooksResource } from './resources/Webhooks';
9
+ import { StatsResource } from './resources/Stats';
10
+ import { IntegrationsResource } from './resources/Integrations';
11
+ import { PrivateMessagesResource } from './resources/PrivateMessages';
12
+ import { ReportsResource } from './resources/Reports';
13
+ import { RolesResource } from './resources/Roles';
14
+ import { SSOResource } from './resources/SSO';
6
15
  export declare class ForumClient {
7
16
  apiKey: string;
8
17
  token: string | null;
@@ -12,6 +21,15 @@ export declare class ForumClient {
12
21
  posts: PostsResource;
13
22
  users: UsersResource;
14
23
  tags: TagsResource;
24
+ notifications: NotificationsResource;
25
+ search: SearchResource;
26
+ webhooks: WebhooksResource;
27
+ stats: StatsResource;
28
+ integrations: IntegrationsResource;
29
+ privateMessages: PrivateMessagesResource;
30
+ reports: ReportsResource;
31
+ roles: RolesResource;
32
+ sso: SSOResource;
15
33
  constructor(options: {
16
34
  apiKey: string;
17
35
  baseUrl?: string;
package/dist/Client.js CHANGED
@@ -6,6 +6,15 @@ const Threads_1 = require("./resources/Threads");
6
6
  const Posts_1 = require("./resources/Posts");
7
7
  const Users_1 = require("./resources/Users");
8
8
  const Tags_1 = require("./resources/Tags");
9
+ const Notifications_1 = require("./resources/Notifications");
10
+ const Search_1 = require("./resources/Search");
11
+ const Webhooks_1 = require("./resources/Webhooks");
12
+ const Stats_1 = require("./resources/Stats");
13
+ const Integrations_1 = require("./resources/Integrations");
14
+ const PrivateMessages_1 = require("./resources/PrivateMessages");
15
+ const Reports_1 = require("./resources/Reports");
16
+ const Roles_1 = require("./resources/Roles");
17
+ const SSO_1 = require("./resources/SSO");
9
18
  // Polyfill fetch if needed (e.g. older Node versions)
10
19
  const fetch = globalThis.fetch || require('cross-fetch');
11
20
  class ForumClient {
@@ -18,6 +27,15 @@ class ForumClient {
18
27
  this.posts = new Posts_1.PostsResource(this);
19
28
  this.users = new Users_1.UsersResource(this);
20
29
  this.tags = new Tags_1.TagsResource(this);
30
+ this.notifications = new Notifications_1.NotificationsResource(this);
31
+ this.search = new Search_1.SearchResource(this);
32
+ this.webhooks = new Webhooks_1.WebhooksResource(this);
33
+ this.stats = new Stats_1.StatsResource(this);
34
+ this.integrations = new Integrations_1.IntegrationsResource(this);
35
+ this.privateMessages = new PrivateMessages_1.PrivateMessagesResource(this);
36
+ this.reports = new Reports_1.ReportsResource(this);
37
+ this.roles = new Roles_1.RolesResource(this);
38
+ this.sso = new SSO_1.SSOResource(this);
21
39
  }
22
40
  async request(path, options = {}) {
23
41
  const headers = {
package/dist/index.d.ts CHANGED
@@ -5,3 +5,12 @@ export * from './resources/Threads';
5
5
  export * from './resources/Posts';
6
6
  export * from './resources/Users';
7
7
  export * from './resources/Tags';
8
+ export * from './resources/Notifications';
9
+ export * from './resources/Search';
10
+ export * from './resources/Webhooks';
11
+ export * from './resources/Stats';
12
+ export * from './resources/Integrations';
13
+ export * from './resources/PrivateMessages';
14
+ export * from './resources/Reports';
15
+ export * from './resources/Roles';
16
+ export * from './resources/SSO';
package/dist/index.js CHANGED
@@ -21,3 +21,12 @@ __exportStar(require("./resources/Threads"), exports);
21
21
  __exportStar(require("./resources/Posts"), exports);
22
22
  __exportStar(require("./resources/Users"), exports);
23
23
  __exportStar(require("./resources/Tags"), exports);
24
+ __exportStar(require("./resources/Notifications"), exports);
25
+ __exportStar(require("./resources/Search"), exports);
26
+ __exportStar(require("./resources/Webhooks"), exports);
27
+ __exportStar(require("./resources/Stats"), exports);
28
+ __exportStar(require("./resources/Integrations"), exports);
29
+ __exportStar(require("./resources/PrivateMessages"), exports);
30
+ __exportStar(require("./resources/Reports"), exports);
31
+ __exportStar(require("./resources/Roles"), exports);
32
+ __exportStar(require("./resources/SSO"), exports);
@@ -9,4 +9,16 @@ export declare class AuthResource {
9
9
  }): Promise<LoginResponse>;
10
10
  register(payload: import('../types').RegisterPayload): Promise<import('../types').User>;
11
11
  me(): Promise<import('../types').User>;
12
+ forgotPassword(email: string): Promise<{
13
+ resetToken?: string;
14
+ message?: string;
15
+ }>;
16
+ resetPassword(payload: {
17
+ password: string;
18
+ oldPassword?: string;
19
+ email?: string;
20
+ token?: string;
21
+ }): Promise<{
22
+ message: string;
23
+ }>;
12
24
  }
@@ -26,5 +26,24 @@ class AuthResource {
26
26
  method: 'GET',
27
27
  });
28
28
  }
29
+ async forgotPassword(email) {
30
+ return this.client.request('/auth/forgot-password', {
31
+ method: 'POST',
32
+ body: JSON.stringify({ email }),
33
+ });
34
+ }
35
+ async resetPassword(payload) {
36
+ const headers = {};
37
+ if (payload.token) {
38
+ headers['Authorization'] = `Bearer ${payload.token}`;
39
+ }
40
+ // Remove token from body
41
+ const { token, ...body } = payload;
42
+ return this.client.request('/auth/reset-password', {
43
+ method: 'POST',
44
+ headers,
45
+ body: JSON.stringify(body),
46
+ });
47
+ }
29
48
  }
30
49
  exports.AuthResource = AuthResource;
@@ -0,0 +1,20 @@
1
+ import { ForumClient } from '../Client';
2
+ import { Integration, IntegrationListResponse } from '../types';
3
+ export declare class IntegrationsResource {
4
+ private client;
5
+ constructor(client: ForumClient);
6
+ list(): Promise<IntegrationListResponse>;
7
+ create(payload: {
8
+ type: 'SLACK' | 'DISCORD' | 'SALESFORCE' | 'HUBSPOT' | 'OKTA' | 'AUTH0';
9
+ name: string;
10
+ config: any;
11
+ }): Promise<{
12
+ integration: Integration;
13
+ }>;
14
+ retrieve(id: string): Promise<{
15
+ integration: Integration;
16
+ }>;
17
+ delete(id: string): Promise<{
18
+ success: boolean;
19
+ }>;
20
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IntegrationsResource = void 0;
4
+ class IntegrationsResource {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ async list() {
9
+ return this.client.request('/integrations', {
10
+ method: 'GET',
11
+ });
12
+ }
13
+ async create(payload) {
14
+ return this.client.request('/integrations', {
15
+ method: 'POST',
16
+ body: JSON.stringify(payload),
17
+ });
18
+ }
19
+ async retrieve(id) {
20
+ return this.client.request(`/integrations/${id}`, {
21
+ method: 'GET',
22
+ });
23
+ }
24
+ async delete(id) {
25
+ return this.client.request(`/integrations/${id}`, {
26
+ method: 'DELETE',
27
+ });
28
+ }
29
+ }
30
+ exports.IntegrationsResource = IntegrationsResource;
@@ -0,0 +1,32 @@
1
+ import { ForumClient } from '../Client';
2
+ import { NotificationListResponse, Notification } from '../types';
3
+ export declare class NotificationsResource {
4
+ private client;
5
+ constructor(client: ForumClient);
6
+ list(params: {
7
+ userId: string;
8
+ read?: boolean;
9
+ filter?: 'newest' | 'oldest';
10
+ cursor?: string;
11
+ }): Promise<NotificationListResponse>;
12
+ markAllAsRead(userId: string, read?: boolean): Promise<{
13
+ count: number;
14
+ }>;
15
+ retrieve(id: string): Promise<Notification>;
16
+ update(id: string, payload: {
17
+ read: boolean;
18
+ }): Promise<Notification>;
19
+ delete(id: string): Promise<Notification & {
20
+ deleted: boolean;
21
+ }>;
22
+ create(payload: {
23
+ threadId?: string;
24
+ postId?: string;
25
+ privateMessageId?: string;
26
+ notifierId: string;
27
+ notifiedId: string;
28
+ type: string;
29
+ description?: string;
30
+ extendedData?: Record<string, any>;
31
+ }): Promise<Notification>;
32
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotificationsResource = void 0;
4
+ class NotificationsResource {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ async list(params) {
9
+ const searchParams = new URLSearchParams();
10
+ Object.entries(params).forEach(([key, value]) => {
11
+ if (value !== undefined) {
12
+ searchParams.append(key, String(value));
13
+ }
14
+ });
15
+ return this.client.request(`/notifications?${searchParams.toString()}`, {
16
+ method: 'GET',
17
+ });
18
+ }
19
+ async markAllAsRead(userId, read = true) {
20
+ return this.client.request('/notifications', {
21
+ method: 'PATCH',
22
+ body: JSON.stringify({ userId, read }),
23
+ });
24
+ }
25
+ async retrieve(id) {
26
+ return this.client.request(`/notification/${id}`, {
27
+ method: 'GET',
28
+ });
29
+ }
30
+ async update(id, payload) {
31
+ return this.client.request(`/notification/${id}`, {
32
+ method: 'PATCH',
33
+ body: JSON.stringify(payload),
34
+ });
35
+ }
36
+ async delete(id) {
37
+ return this.client.request(`/notification/${id}`, {
38
+ method: 'DELETE',
39
+ });
40
+ }
41
+ async create(payload) {
42
+ return this.client.request('/notification', {
43
+ method: 'POST',
44
+ body: JSON.stringify(payload),
45
+ });
46
+ }
47
+ }
48
+ exports.NotificationsResource = NotificationsResource;
@@ -18,4 +18,17 @@ export declare class PostsResource {
18
18
  }): Promise<import('../types').Post & {
19
19
  deleted: boolean;
20
20
  }>;
21
+ getChildren(id: string, params?: {
22
+ query?: string;
23
+ cursor?: string;
24
+ filter?: 'newest' | 'oldest';
25
+ }): Promise<any>;
26
+ like(id: string, userId?: string, extendedData?: any): Promise<any>;
27
+ unlike(id: string, userId: string): Promise<any>;
28
+ dislike(id: string, userId?: string, extendedData?: any): Promise<any>;
29
+ undislike(id: string, userId: string): Promise<any>;
30
+ upvote(id: string, userId?: string, extendedData?: any): Promise<any>;
31
+ unupvote(id: string, userId: string): Promise<any>;
32
+ downvote(id: string, userId?: string, extendedData?: any): Promise<any>;
33
+ undownvote(id: string, userId: string): Promise<any>;
21
34
  }
@@ -41,5 +41,60 @@ class PostsResource {
41
41
  body: payload ? JSON.stringify(payload) : undefined,
42
42
  });
43
43
  }
44
+ async getChildren(id, params) {
45
+ const searchParams = new URLSearchParams();
46
+ if (params) {
47
+ Object.entries(params).forEach(([key, value]) => {
48
+ if (value !== undefined) {
49
+ searchParams.append(key, value);
50
+ }
51
+ });
52
+ }
53
+ return this.client.request(`/post/${id}/posts?${searchParams.toString()}`, { method: 'GET' });
54
+ }
55
+ async like(id, userId, extendedData) {
56
+ return this.client.request(`/post/${id}/likes`, {
57
+ method: 'POST',
58
+ body: JSON.stringify({ userId, extendedData }),
59
+ });
60
+ }
61
+ async unlike(id, userId) {
62
+ return this.client.request(`/post/${id}/likes?userId=${userId}`, {
63
+ method: 'DELETE',
64
+ });
65
+ }
66
+ async dislike(id, userId, extendedData) {
67
+ return this.client.request(`/post/${id}/dislikes`, {
68
+ method: 'POST',
69
+ body: JSON.stringify({ userId, extendedData }),
70
+ });
71
+ }
72
+ async undislike(id, userId) {
73
+ return this.client.request(`/post/${id}/dislikes?userId=${userId}`, {
74
+ method: 'DELETE',
75
+ });
76
+ }
77
+ async upvote(id, userId, extendedData) {
78
+ return this.client.request(`/post/${id}/upvotes`, {
79
+ method: 'POST',
80
+ body: JSON.stringify({ userId, extendedData }),
81
+ });
82
+ }
83
+ async unupvote(id, userId) {
84
+ return this.client.request(`/post/${id}/upvotes?userId=${userId}`, {
85
+ method: 'DELETE',
86
+ });
87
+ }
88
+ async downvote(id, userId, extendedData) {
89
+ return this.client.request(`/post/${id}/downvotes`, {
90
+ method: 'POST',
91
+ body: JSON.stringify({ userId, extendedData }),
92
+ });
93
+ }
94
+ async undownvote(id, userId) {
95
+ return this.client.request(`/post/${id}/downvotes?userId=${userId}`, {
96
+ method: 'DELETE',
97
+ });
98
+ }
44
99
  }
45
100
  exports.PostsResource = PostsResource;
@@ -0,0 +1,29 @@
1
+ import { ForumClient } from '../Client';
2
+ import { PrivateMessage, PrivateMessageListResponse } from '../types';
3
+ export declare class PrivateMessagesResource {
4
+ private client;
5
+ constructor(client: ForumClient);
6
+ list(params?: {
7
+ query?: string;
8
+ userId?: string;
9
+ filter?: 'newest' | 'oldest';
10
+ cursor?: string;
11
+ }): Promise<PrivateMessageListResponse>;
12
+ create(payload: {
13
+ title?: string;
14
+ body: string;
15
+ recipientId: string;
16
+ senderId?: string;
17
+ extendedData?: Record<string, any>;
18
+ }): Promise<PrivateMessage>;
19
+ retrieve(id: string): Promise<PrivateMessage>;
20
+ reply(id: string, payload: {
21
+ body: string;
22
+ senderId: string;
23
+ recipientId: string;
24
+ extendedData?: Record<string, any>;
25
+ }): Promise<PrivateMessage>;
26
+ delete(id: string): Promise<PrivateMessage & {
27
+ deleted: boolean;
28
+ }>;
29
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PrivateMessagesResource = void 0;
4
+ class PrivateMessagesResource {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ async list(params) {
9
+ const searchParams = new URLSearchParams();
10
+ if (params) {
11
+ Object.entries(params).forEach(([key, value]) => {
12
+ if (value !== undefined) {
13
+ searchParams.append(key, value);
14
+ }
15
+ });
16
+ }
17
+ return this.client.request(`/private-messages?${searchParams.toString()}`, {
18
+ method: 'GET',
19
+ });
20
+ }
21
+ async create(payload) {
22
+ return this.client.request('/private-message', {
23
+ method: 'POST',
24
+ body: JSON.stringify(payload),
25
+ });
26
+ }
27
+ async retrieve(id) {
28
+ return this.client.request(`/private-message/${id}`, {
29
+ method: 'GET',
30
+ });
31
+ }
32
+ async reply(id, payload) {
33
+ return this.client.request(`/private-message/${id}`, {
34
+ method: 'POST',
35
+ body: JSON.stringify(payload),
36
+ });
37
+ }
38
+ async delete(id) {
39
+ return this.client.request(`/private-message/${id}`, {
40
+ method: 'DELETE',
41
+ });
42
+ }
43
+ }
44
+ exports.PrivateMessagesResource = PrivateMessagesResource;