@foru-ms/sdk 0.1.0 → 0.2.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.
- package/README.md +144 -0
- package/dist/Client.d.ts +18 -0
- package/dist/Client.js +18 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/resources/Auth.d.ts +12 -0
- package/dist/resources/Auth.js +19 -0
- package/dist/resources/Integrations.d.ts +20 -0
- package/dist/resources/Integrations.js +30 -0
- package/dist/resources/Notifications.d.ts +32 -0
- package/dist/resources/Notifications.js +48 -0
- package/dist/resources/Posts.d.ts +13 -0
- package/dist/resources/Posts.js +55 -0
- package/dist/resources/PrivateMessages.d.ts +29 -0
- package/dist/resources/PrivateMessages.js +44 -0
- package/dist/resources/Reports.d.ts +46 -0
- package/dist/resources/Reports.js +56 -0
- package/dist/resources/Roles.d.ts +26 -0
- package/dist/resources/Roles.js +44 -0
- package/dist/resources/SSO.d.ts +17 -0
- package/dist/resources/SSO.js +25 -0
- package/dist/resources/Search.d.ts +11 -0
- package/dist/resources/Search.js +20 -0
- package/dist/resources/Stats.d.ts +13 -0
- package/dist/resources/Stats.js +22 -0
- package/dist/resources/Tags.d.ts +27 -0
- package/dist/resources/Tags.js +47 -0
- package/dist/resources/Threads.d.ts +14 -0
- package/dist/resources/Threads.js +61 -0
- package/dist/resources/Users.d.ts +47 -0
- package/dist/resources/Users.js +54 -0
- package/dist/resources/Webhooks.d.ts +35 -0
- package/dist/resources/Webhooks.js +44 -0
- package/dist/types.d.ts +149 -0
- package/package.json +1 -1
- package/src/Client.ts +27 -0
- package/src/index.ts +9 -0
- package/src/resources/Auth.ts +28 -0
- package/src/resources/Integrations.ts +39 -0
- package/src/resources/Notifications.ts +69 -0
- package/src/resources/Posts.ts +67 -0
- package/src/resources/PrivateMessages.ts +67 -0
- package/src/resources/Reports.ts +93 -0
- package/src/resources/Roles.ts +64 -0
- package/src/resources/SSO.ts +33 -0
- package/src/resources/Search.ts +27 -0
- package/src/resources/Stats.ts +31 -0
- package/src/resources/Tags.ts +68 -0
- package/src/resources/Threads.ts +74 -0
- package/src/resources/Users.ts +91 -0
- package/src/resources/Webhooks.ts +60 -0
- package/src/types.ts +165 -0
package/README.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
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
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @foru-ms/sdk
|
|
9
|
+
# or
|
|
10
|
+
yarn add @foru-ms/sdk
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @foru-ms/sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Getting Started
|
|
16
|
+
|
|
17
|
+
Initialize the client with your API key. You can find your API key in the Foru.ms dashboard.
|
|
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, defaults to production URL
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Authentication
|
|
29
|
+
|
|
30
|
+
Identify the current user to perform actions on their behalf. Use `authToken` obtained via login or your own auth provider integration.
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
// Login with username/password
|
|
34
|
+
const { token } = await client.auth.login({
|
|
35
|
+
login: 'username',
|
|
36
|
+
password: 'password'
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Or set an existing token
|
|
40
|
+
client.setToken(token);
|
|
41
|
+
|
|
42
|
+
// Get current user details
|
|
43
|
+
const me = await client.auth.me();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Usage Examples
|
|
47
|
+
|
|
48
|
+
### Threads
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
// List threads
|
|
52
|
+
const { threads } = await client.threads.list({
|
|
53
|
+
limit: 10,
|
|
54
|
+
filter: 'newest'
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Create a thread
|
|
58
|
+
const newThread = await client.threads.create({
|
|
59
|
+
title: 'Hello World',
|
|
60
|
+
body: 'This is my first thread via the SDK!',
|
|
61
|
+
tags: ['introduction', 'general']
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Interact with a thread
|
|
65
|
+
await client.threads.like(newThread.id, currentUser.id);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Posts (Replies)
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
// Reply to a thread
|
|
72
|
+
const post = await client.posts.create({
|
|
73
|
+
threadId: 'thread_123',
|
|
74
|
+
body: 'Great discussion!'
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Get replies for a post (threaded view)
|
|
78
|
+
const { posts } = await client.posts.getChildren('post_123');
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Users & Social
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
// Follow a user
|
|
85
|
+
await client.users.follow('target_user_id', 'current_user_id');
|
|
86
|
+
|
|
87
|
+
// Get user feed/followers
|
|
88
|
+
const { followers } = await client.users.getFollowers('user_123');
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Real-time Notifications
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// Get notifications
|
|
95
|
+
const { list } = await client.notifications.list({ userId: 'user_123' });
|
|
96
|
+
|
|
97
|
+
// Mark as read
|
|
98
|
+
await client.notifications.markAllAsRead('user_123');
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Resources
|
|
102
|
+
|
|
103
|
+
The SDK covers the full Foru.ms API surface:
|
|
104
|
+
|
|
105
|
+
* `client.auth`: Authentication & Registration
|
|
106
|
+
* `client.threads`: Discussions & Polls
|
|
107
|
+
* `client.posts`: Replies & Nested Comments
|
|
108
|
+
* `client.users`: User Profiles & Social Graph
|
|
109
|
+
* `client.tags`: Categorization & Subscriptions
|
|
110
|
+
* `client.notifications`: Alerts & Activity
|
|
111
|
+
* `client.search`: Unified Search
|
|
112
|
+
* `client.webhooks`: Event Subscriptions
|
|
113
|
+
* `client.stats`: Community Analytics
|
|
114
|
+
* `client.integrations`: 3rd Party Connections (Slack, Discord, etc.)
|
|
115
|
+
* `client.privateMessages`: Direct Messaging
|
|
116
|
+
* `client.reports`: Moderation & Safety
|
|
117
|
+
* `client.roles`: Permission Management
|
|
118
|
+
* `client.sso`: Single Sign-On Configuration
|
|
119
|
+
|
|
120
|
+
## TypeScript Support
|
|
121
|
+
|
|
122
|
+
This SDK is written in TypeScript and provides complete type definitions for all requests and responses.
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
import { Thread, User } from '@foru-ms/sdk';
|
|
126
|
+
|
|
127
|
+
const thread: Thread = await client.threads.retrieve('thread_123');
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Error Handling
|
|
131
|
+
|
|
132
|
+
API errors throw standard JavaScript errors with messages from the server.
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
try {
|
|
136
|
+
await client.threads.create({ ... });
|
|
137
|
+
} catch (error) {
|
|
138
|
+
console.error('API Error:', error.message);
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
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);
|
package/dist/resources/Auth.d.ts
CHANGED
|
@@ -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
|
}
|
package/dist/resources/Auth.js
CHANGED
|
@@ -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
|
}
|
package/dist/resources/Posts.js
CHANGED
|
@@ -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;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ForumClient } from '../Client';
|
|
2
|
+
import { Report, ReportListResponse } from '../types';
|
|
3
|
+
export declare class ReportsResource {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: ForumClient);
|
|
6
|
+
list(params?: {
|
|
7
|
+
reporterId?: string;
|
|
8
|
+
reportedId?: string;
|
|
9
|
+
read?: boolean;
|
|
10
|
+
cursor?: string;
|
|
11
|
+
filter?: 'newest' | 'oldest';
|
|
12
|
+
}): Promise<ReportListResponse>;
|
|
13
|
+
create(payload: {
|
|
14
|
+
reporterId: string;
|
|
15
|
+
reportedId?: string;
|
|
16
|
+
threadId?: string;
|
|
17
|
+
postId?: string;
|
|
18
|
+
privateMessageId?: string;
|
|
19
|
+
type?: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
extendedData?: Record<string, any>;
|
|
22
|
+
}): Promise<Report>;
|
|
23
|
+
batchUpdate(payload: {
|
|
24
|
+
reportIds: string[];
|
|
25
|
+
read: boolean;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
count?: number;
|
|
28
|
+
message?: string;
|
|
29
|
+
}>;
|
|
30
|
+
retrieve(id: string): Promise<Report>;
|
|
31
|
+
update(id: string, payload: {
|
|
32
|
+
threadId?: string;
|
|
33
|
+
postId?: string;
|
|
34
|
+
privateMessageId?: string;
|
|
35
|
+
reportedId?: string;
|
|
36
|
+
reporterId?: string;
|
|
37
|
+
type?: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
read?: boolean;
|
|
40
|
+
extendedData?: Record<string, any>;
|
|
41
|
+
}): Promise<Report>;
|
|
42
|
+
delete(id: string): Promise<Report & {
|
|
43
|
+
deleted: boolean;
|
|
44
|
+
}>;
|
|
45
|
+
updateStatus(id: string, read: boolean): Promise<Report>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReportsResource = void 0;
|
|
4
|
+
class ReportsResource {
|
|
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, String(value));
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return this.client.request(`/reports?${searchParams.toString()}`, {
|
|
18
|
+
method: 'GET',
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
async create(payload) {
|
|
22
|
+
return this.client.request('/report', {
|
|
23
|
+
method: 'POST',
|
|
24
|
+
body: JSON.stringify(payload),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async batchUpdate(payload) {
|
|
28
|
+
return this.client.request('/reports', {
|
|
29
|
+
method: 'PATCH',
|
|
30
|
+
body: JSON.stringify(payload),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async retrieve(id) {
|
|
34
|
+
return this.client.request(`/report/${id}`, {
|
|
35
|
+
method: 'GET',
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async update(id, payload) {
|
|
39
|
+
return this.client.request(`/report/${id}`, {
|
|
40
|
+
method: 'PUT',
|
|
41
|
+
body: JSON.stringify(payload),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async delete(id) {
|
|
45
|
+
return this.client.request(`/report/${id}`, {
|
|
46
|
+
method: 'DELETE',
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async updateStatus(id, read) {
|
|
50
|
+
return this.client.request(`/report/${id}`, {
|
|
51
|
+
method: 'PATCH',
|
|
52
|
+
body: JSON.stringify({ read }),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.ReportsResource = ReportsResource;
|