@cstar.help/js 0.8.0 → 0.10.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/dist/chat/index.cjs +51 -0
- package/dist/chat/index.d.cts +22 -0
- package/dist/chat/index.d.ts +22 -0
- package/dist/chat/index.js +51 -0
- package/dist/community/index.cjs +65 -0
- package/dist/community/index.d.cts +35 -1
- package/dist/community/index.d.ts +35 -1
- package/dist/community/index.js +65 -0
- package/dist/proactive/index.cjs +465 -0
- package/dist/proactive/index.d.cts +134 -0
- package/dist/proactive/index.d.ts +134 -0
- package/dist/proactive/index.js +440 -0
- package/package.json +11 -1
package/dist/chat/index.cjs
CHANGED
|
@@ -554,6 +554,57 @@ var ChatCommunityApi = class {
|
|
|
554
554
|
});
|
|
555
555
|
return response.data.post;
|
|
556
556
|
}
|
|
557
|
+
/** Update a post. Only the original author can edit. */
|
|
558
|
+
async updatePost(postId, params) {
|
|
559
|
+
const teamId = this.chat.getTeamId();
|
|
560
|
+
if (!teamId) throw new Error("Not identified. Call chat.identify() first.");
|
|
561
|
+
const response = await this.chat.fetch("/api/widget/community", {
|
|
562
|
+
method: "POST",
|
|
563
|
+
body: {
|
|
564
|
+
teamId,
|
|
565
|
+
action: "updatePost",
|
|
566
|
+
postId,
|
|
567
|
+
title: params.title,
|
|
568
|
+
body: params.body,
|
|
569
|
+
customFields: params.customFields
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
return response.data.post;
|
|
573
|
+
}
|
|
574
|
+
/** Delete a post (soft delete). Only the original author can delete. */
|
|
575
|
+
async deletePost(postId) {
|
|
576
|
+
const teamId = this.chat.getTeamId();
|
|
577
|
+
if (!teamId) throw new Error("Not identified. Call chat.identify() first.");
|
|
578
|
+
await this.chat.fetch("/api/widget/community", {
|
|
579
|
+
method: "POST",
|
|
580
|
+
body: { teamId, action: "deletePost", postId }
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
/** Update a comment. Only the original author can edit. */
|
|
584
|
+
async updateComment(postId, commentId, params) {
|
|
585
|
+
const teamId = this.chat.getTeamId();
|
|
586
|
+
if (!teamId) throw new Error("Not identified. Call chat.identify() first.");
|
|
587
|
+
const response = await this.chat.fetch("/api/widget/community", {
|
|
588
|
+
method: "POST",
|
|
589
|
+
body: {
|
|
590
|
+
teamId,
|
|
591
|
+
action: "updateComment",
|
|
592
|
+
postId,
|
|
593
|
+
commentId,
|
|
594
|
+
commentBody: params.body
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
return response.data.comment;
|
|
598
|
+
}
|
|
599
|
+
/** Delete a comment (soft delete). Only the original author can delete. */
|
|
600
|
+
async deleteComment(postId, commentId) {
|
|
601
|
+
const teamId = this.chat.getTeamId();
|
|
602
|
+
if (!teamId) throw new Error("Not identified. Call chat.identify() first.");
|
|
603
|
+
await this.chat.fetch("/api/widget/community", {
|
|
604
|
+
method: "POST",
|
|
605
|
+
body: { teamId, action: "deleteComment", postId, commentId }
|
|
606
|
+
});
|
|
607
|
+
}
|
|
557
608
|
/** Toggle vote on a post. Returns new vote state and count. */
|
|
558
609
|
async vote(postId) {
|
|
559
610
|
const teamId = this.chat.getTeamId();
|
package/dist/chat/index.d.cts
CHANGED
|
@@ -117,6 +117,20 @@ interface CommunityCreatePostParams {
|
|
|
117
117
|
/** Image attachments (max 10, images only, 5MB each). */
|
|
118
118
|
attachments?: CommunityAttachment[];
|
|
119
119
|
}
|
|
120
|
+
/** Parameters for updating a post as the original author. */
|
|
121
|
+
interface CommunityUpdatePostParams {
|
|
122
|
+
/** Updated post title. */
|
|
123
|
+
title?: string;
|
|
124
|
+
/** Updated post body/content. */
|
|
125
|
+
body?: string;
|
|
126
|
+
/** Updated custom field values keyed by field definition ID. */
|
|
127
|
+
customFields?: Record<string, string>;
|
|
128
|
+
}
|
|
129
|
+
/** Parameters for updating a comment as the original author. */
|
|
130
|
+
interface CommunityUpdateCommentParams {
|
|
131
|
+
/** Updated comment body text. */
|
|
132
|
+
body: string;
|
|
133
|
+
}
|
|
120
134
|
/** Parameters for creating a comment as an identified customer. */
|
|
121
135
|
interface CommunityCreateCommentParams {
|
|
122
136
|
/** Comment body text. */
|
|
@@ -276,6 +290,14 @@ declare class ChatCommunityApi {
|
|
|
276
290
|
constructor(chat: ChatClient);
|
|
277
291
|
/** Create a new community post as the identified customer. */
|
|
278
292
|
createPost(params: CommunityCreatePostParams): Promise<CommunityCreatedPost>;
|
|
293
|
+
/** Update a post. Only the original author can edit. */
|
|
294
|
+
updatePost(postId: string, params: CommunityUpdatePostParams): Promise<CommunityCreatedPost>;
|
|
295
|
+
/** Delete a post (soft delete). Only the original author can delete. */
|
|
296
|
+
deletePost(postId: string): Promise<void>;
|
|
297
|
+
/** Update a comment. Only the original author can edit. */
|
|
298
|
+
updateComment(postId: string, commentId: string, params: CommunityUpdateCommentParams): Promise<CommunityCreatedComment>;
|
|
299
|
+
/** Delete a comment (soft delete). Only the original author can delete. */
|
|
300
|
+
deleteComment(postId: string, commentId: string): Promise<void>;
|
|
279
301
|
/** Toggle vote on a post. Returns new vote state and count. */
|
|
280
302
|
vote(postId: string): Promise<CommunityVoteResult>;
|
|
281
303
|
/** Add a comment to a post. Supports 1-level nesting via parentCommentId. */
|
package/dist/chat/index.d.ts
CHANGED
|
@@ -117,6 +117,20 @@ interface CommunityCreatePostParams {
|
|
|
117
117
|
/** Image attachments (max 10, images only, 5MB each). */
|
|
118
118
|
attachments?: CommunityAttachment[];
|
|
119
119
|
}
|
|
120
|
+
/** Parameters for updating a post as the original author. */
|
|
121
|
+
interface CommunityUpdatePostParams {
|
|
122
|
+
/** Updated post title. */
|
|
123
|
+
title?: string;
|
|
124
|
+
/** Updated post body/content. */
|
|
125
|
+
body?: string;
|
|
126
|
+
/** Updated custom field values keyed by field definition ID. */
|
|
127
|
+
customFields?: Record<string, string>;
|
|
128
|
+
}
|
|
129
|
+
/** Parameters for updating a comment as the original author. */
|
|
130
|
+
interface CommunityUpdateCommentParams {
|
|
131
|
+
/** Updated comment body text. */
|
|
132
|
+
body: string;
|
|
133
|
+
}
|
|
120
134
|
/** Parameters for creating a comment as an identified customer. */
|
|
121
135
|
interface CommunityCreateCommentParams {
|
|
122
136
|
/** Comment body text. */
|
|
@@ -276,6 +290,14 @@ declare class ChatCommunityApi {
|
|
|
276
290
|
constructor(chat: ChatClient);
|
|
277
291
|
/** Create a new community post as the identified customer. */
|
|
278
292
|
createPost(params: CommunityCreatePostParams): Promise<CommunityCreatedPost>;
|
|
293
|
+
/** Update a post. Only the original author can edit. */
|
|
294
|
+
updatePost(postId: string, params: CommunityUpdatePostParams): Promise<CommunityCreatedPost>;
|
|
295
|
+
/** Delete a post (soft delete). Only the original author can delete. */
|
|
296
|
+
deletePost(postId: string): Promise<void>;
|
|
297
|
+
/** Update a comment. Only the original author can edit. */
|
|
298
|
+
updateComment(postId: string, commentId: string, params: CommunityUpdateCommentParams): Promise<CommunityCreatedComment>;
|
|
299
|
+
/** Delete a comment (soft delete). Only the original author can delete. */
|
|
300
|
+
deleteComment(postId: string, commentId: string): Promise<void>;
|
|
279
301
|
/** Toggle vote on a post. Returns new vote state and count. */
|
|
280
302
|
vote(postId: string): Promise<CommunityVoteResult>;
|
|
281
303
|
/** Add a comment to a post. Supports 1-level nesting via parentCommentId. */
|
package/dist/chat/index.js
CHANGED
|
@@ -518,6 +518,57 @@ var ChatCommunityApi = class {
|
|
|
518
518
|
});
|
|
519
519
|
return response.data.post;
|
|
520
520
|
}
|
|
521
|
+
/** Update a post. Only the original author can edit. */
|
|
522
|
+
async updatePost(postId, params) {
|
|
523
|
+
const teamId = this.chat.getTeamId();
|
|
524
|
+
if (!teamId) throw new Error("Not identified. Call chat.identify() first.");
|
|
525
|
+
const response = await this.chat.fetch("/api/widget/community", {
|
|
526
|
+
method: "POST",
|
|
527
|
+
body: {
|
|
528
|
+
teamId,
|
|
529
|
+
action: "updatePost",
|
|
530
|
+
postId,
|
|
531
|
+
title: params.title,
|
|
532
|
+
body: params.body,
|
|
533
|
+
customFields: params.customFields
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
return response.data.post;
|
|
537
|
+
}
|
|
538
|
+
/** Delete a post (soft delete). Only the original author can delete. */
|
|
539
|
+
async deletePost(postId) {
|
|
540
|
+
const teamId = this.chat.getTeamId();
|
|
541
|
+
if (!teamId) throw new Error("Not identified. Call chat.identify() first.");
|
|
542
|
+
await this.chat.fetch("/api/widget/community", {
|
|
543
|
+
method: "POST",
|
|
544
|
+
body: { teamId, action: "deletePost", postId }
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
/** Update a comment. Only the original author can edit. */
|
|
548
|
+
async updateComment(postId, commentId, params) {
|
|
549
|
+
const teamId = this.chat.getTeamId();
|
|
550
|
+
if (!teamId) throw new Error("Not identified. Call chat.identify() first.");
|
|
551
|
+
const response = await this.chat.fetch("/api/widget/community", {
|
|
552
|
+
method: "POST",
|
|
553
|
+
body: {
|
|
554
|
+
teamId,
|
|
555
|
+
action: "updateComment",
|
|
556
|
+
postId,
|
|
557
|
+
commentId,
|
|
558
|
+
commentBody: params.body
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
return response.data.comment;
|
|
562
|
+
}
|
|
563
|
+
/** Delete a comment (soft delete). Only the original author can delete. */
|
|
564
|
+
async deleteComment(postId, commentId) {
|
|
565
|
+
const teamId = this.chat.getTeamId();
|
|
566
|
+
if (!teamId) throw new Error("Not identified. Call chat.identify() first.");
|
|
567
|
+
await this.chat.fetch("/api/widget/community", {
|
|
568
|
+
method: "POST",
|
|
569
|
+
body: { teamId, action: "deleteComment", postId, commentId }
|
|
570
|
+
});
|
|
571
|
+
}
|
|
521
572
|
/** Toggle vote on a post. Returns new vote state and count. */
|
|
522
573
|
async vote(postId) {
|
|
523
574
|
const teamId = this.chat.getTeamId();
|
package/dist/community/index.cjs
CHANGED
|
@@ -108,6 +108,71 @@ var CommunityClient = class {
|
|
|
108
108
|
});
|
|
109
109
|
return response.data.post;
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Update a post. Only the original author can edit.
|
|
113
|
+
* Requires an active session token.
|
|
114
|
+
*/
|
|
115
|
+
async updatePost(postId, params) {
|
|
116
|
+
const teamId = this.resolveTeamId();
|
|
117
|
+
const response = await this.authenticatedFetch("/api/widget/community", {
|
|
118
|
+
method: "POST",
|
|
119
|
+
body: {
|
|
120
|
+
teamId,
|
|
121
|
+
action: "updatePost",
|
|
122
|
+
postId,
|
|
123
|
+
title: params.title,
|
|
124
|
+
body: params.body,
|
|
125
|
+
customFields: params.customFields
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
return response.data.post;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Delete a post (soft delete). Only the original author can delete.
|
|
132
|
+
* Requires an active session token.
|
|
133
|
+
*/
|
|
134
|
+
async deletePost(postId) {
|
|
135
|
+
const teamId = this.resolveTeamId();
|
|
136
|
+
await this.authenticatedFetch(
|
|
137
|
+
"/api/widget/community",
|
|
138
|
+
{
|
|
139
|
+
method: "POST",
|
|
140
|
+
body: { teamId, action: "deletePost", postId }
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Update a comment. Only the original author can edit.
|
|
146
|
+
* Requires an active session token.
|
|
147
|
+
*/
|
|
148
|
+
async updateComment(postId, commentId, params) {
|
|
149
|
+
const teamId = this.resolveTeamId();
|
|
150
|
+
const response = await this.authenticatedFetch("/api/widget/community", {
|
|
151
|
+
method: "POST",
|
|
152
|
+
body: {
|
|
153
|
+
teamId,
|
|
154
|
+
action: "updateComment",
|
|
155
|
+
postId,
|
|
156
|
+
commentId,
|
|
157
|
+
commentBody: params.body
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
return response.data.comment;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Delete a comment (soft delete). Only the original author can delete.
|
|
164
|
+
* Requires an active session token.
|
|
165
|
+
*/
|
|
166
|
+
async deleteComment(postId, commentId) {
|
|
167
|
+
const teamId = this.resolveTeamId();
|
|
168
|
+
await this.authenticatedFetch(
|
|
169
|
+
"/api/widget/community",
|
|
170
|
+
{
|
|
171
|
+
method: "POST",
|
|
172
|
+
body: { teamId, action: "deleteComment", postId, commentId }
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
}
|
|
111
176
|
/**
|
|
112
177
|
* Toggle vote on a post. Returns new vote state and count.
|
|
113
178
|
* Requires an active session token.
|
|
@@ -25,6 +25,20 @@ interface CommunityCreatePostParams {
|
|
|
25
25
|
/** Image attachments (max 10, images only, 5MB each). */
|
|
26
26
|
attachments?: CommunityAttachment[];
|
|
27
27
|
}
|
|
28
|
+
/** Parameters for updating a post as the original author. */
|
|
29
|
+
interface CommunityUpdatePostParams {
|
|
30
|
+
/** Updated post title. */
|
|
31
|
+
title?: string;
|
|
32
|
+
/** Updated post body/content. */
|
|
33
|
+
body?: string;
|
|
34
|
+
/** Updated custom field values keyed by field definition ID. */
|
|
35
|
+
customFields?: Record<string, string>;
|
|
36
|
+
}
|
|
37
|
+
/** Parameters for updating a comment as the original author. */
|
|
38
|
+
interface CommunityUpdateCommentParams {
|
|
39
|
+
/** Updated comment body text. */
|
|
40
|
+
body: string;
|
|
41
|
+
}
|
|
28
42
|
/** Parameters for creating a comment as an identified customer. */
|
|
29
43
|
interface CommunityCreateCommentParams {
|
|
30
44
|
/** Comment body text. */
|
|
@@ -213,6 +227,26 @@ declare class CommunityClient {
|
|
|
213
227
|
* @throws Error if no session token is set or the request fails
|
|
214
228
|
*/
|
|
215
229
|
createPost(params: CommunityCreatePostParams): Promise<CommunityCreatedPost>;
|
|
230
|
+
/**
|
|
231
|
+
* Update a post. Only the original author can edit.
|
|
232
|
+
* Requires an active session token.
|
|
233
|
+
*/
|
|
234
|
+
updatePost(postId: string, params: CommunityUpdatePostParams): Promise<CommunityCreatedPost>;
|
|
235
|
+
/**
|
|
236
|
+
* Delete a post (soft delete). Only the original author can delete.
|
|
237
|
+
* Requires an active session token.
|
|
238
|
+
*/
|
|
239
|
+
deletePost(postId: string): Promise<void>;
|
|
240
|
+
/**
|
|
241
|
+
* Update a comment. Only the original author can edit.
|
|
242
|
+
* Requires an active session token.
|
|
243
|
+
*/
|
|
244
|
+
updateComment(postId: string, commentId: string, params: CommunityUpdateCommentParams): Promise<CommunityCreatedComment>;
|
|
245
|
+
/**
|
|
246
|
+
* Delete a comment (soft delete). Only the original author can delete.
|
|
247
|
+
* Requires an active session token.
|
|
248
|
+
*/
|
|
249
|
+
deleteComment(postId: string, commentId: string): Promise<void>;
|
|
216
250
|
/**
|
|
217
251
|
* Toggle vote on a post. Returns new vote state and count.
|
|
218
252
|
* Requires an active session token.
|
|
@@ -246,4 +280,4 @@ declare class CommunityClient {
|
|
|
246
280
|
private fetch;
|
|
247
281
|
}
|
|
248
282
|
|
|
249
|
-
export { CommunityClient, type CommunityComment, type CommunityConfig, type CommunityCreateCommentParams, type CommunityCreatePostParams, type CommunityCreatedComment, type CommunityCreatedPost, type CommunityFollowResult, type CommunityPost, type CommunityPostDetail, type CommunityPostListParams, type CommunitySearchResult, type CommunityTopic, type CommunityVoteResult };
|
|
283
|
+
export { CommunityClient, type CommunityComment, type CommunityConfig, type CommunityCreateCommentParams, type CommunityCreatePostParams, type CommunityCreatedComment, type CommunityCreatedPost, type CommunityFollowResult, type CommunityPost, type CommunityPostDetail, type CommunityPostListParams, type CommunitySearchResult, type CommunityTopic, type CommunityUpdateCommentParams, type CommunityUpdatePostParams, type CommunityVoteResult };
|
|
@@ -25,6 +25,20 @@ interface CommunityCreatePostParams {
|
|
|
25
25
|
/** Image attachments (max 10, images only, 5MB each). */
|
|
26
26
|
attachments?: CommunityAttachment[];
|
|
27
27
|
}
|
|
28
|
+
/** Parameters for updating a post as the original author. */
|
|
29
|
+
interface CommunityUpdatePostParams {
|
|
30
|
+
/** Updated post title. */
|
|
31
|
+
title?: string;
|
|
32
|
+
/** Updated post body/content. */
|
|
33
|
+
body?: string;
|
|
34
|
+
/** Updated custom field values keyed by field definition ID. */
|
|
35
|
+
customFields?: Record<string, string>;
|
|
36
|
+
}
|
|
37
|
+
/** Parameters for updating a comment as the original author. */
|
|
38
|
+
interface CommunityUpdateCommentParams {
|
|
39
|
+
/** Updated comment body text. */
|
|
40
|
+
body: string;
|
|
41
|
+
}
|
|
28
42
|
/** Parameters for creating a comment as an identified customer. */
|
|
29
43
|
interface CommunityCreateCommentParams {
|
|
30
44
|
/** Comment body text. */
|
|
@@ -213,6 +227,26 @@ declare class CommunityClient {
|
|
|
213
227
|
* @throws Error if no session token is set or the request fails
|
|
214
228
|
*/
|
|
215
229
|
createPost(params: CommunityCreatePostParams): Promise<CommunityCreatedPost>;
|
|
230
|
+
/**
|
|
231
|
+
* Update a post. Only the original author can edit.
|
|
232
|
+
* Requires an active session token.
|
|
233
|
+
*/
|
|
234
|
+
updatePost(postId: string, params: CommunityUpdatePostParams): Promise<CommunityCreatedPost>;
|
|
235
|
+
/**
|
|
236
|
+
* Delete a post (soft delete). Only the original author can delete.
|
|
237
|
+
* Requires an active session token.
|
|
238
|
+
*/
|
|
239
|
+
deletePost(postId: string): Promise<void>;
|
|
240
|
+
/**
|
|
241
|
+
* Update a comment. Only the original author can edit.
|
|
242
|
+
* Requires an active session token.
|
|
243
|
+
*/
|
|
244
|
+
updateComment(postId: string, commentId: string, params: CommunityUpdateCommentParams): Promise<CommunityCreatedComment>;
|
|
245
|
+
/**
|
|
246
|
+
* Delete a comment (soft delete). Only the original author can delete.
|
|
247
|
+
* Requires an active session token.
|
|
248
|
+
*/
|
|
249
|
+
deleteComment(postId: string, commentId: string): Promise<void>;
|
|
216
250
|
/**
|
|
217
251
|
* Toggle vote on a post. Returns new vote state and count.
|
|
218
252
|
* Requires an active session token.
|
|
@@ -246,4 +280,4 @@ declare class CommunityClient {
|
|
|
246
280
|
private fetch;
|
|
247
281
|
}
|
|
248
282
|
|
|
249
|
-
export { CommunityClient, type CommunityComment, type CommunityConfig, type CommunityCreateCommentParams, type CommunityCreatePostParams, type CommunityCreatedComment, type CommunityCreatedPost, type CommunityFollowResult, type CommunityPost, type CommunityPostDetail, type CommunityPostListParams, type CommunitySearchResult, type CommunityTopic, type CommunityVoteResult };
|
|
283
|
+
export { CommunityClient, type CommunityComment, type CommunityConfig, type CommunityCreateCommentParams, type CommunityCreatePostParams, type CommunityCreatedComment, type CommunityCreatedPost, type CommunityFollowResult, type CommunityPost, type CommunityPostDetail, type CommunityPostListParams, type CommunitySearchResult, type CommunityTopic, type CommunityUpdateCommentParams, type CommunityUpdatePostParams, type CommunityVoteResult };
|
package/dist/community/index.js
CHANGED
|
@@ -84,6 +84,71 @@ var CommunityClient = class {
|
|
|
84
84
|
});
|
|
85
85
|
return response.data.post;
|
|
86
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Update a post. Only the original author can edit.
|
|
89
|
+
* Requires an active session token.
|
|
90
|
+
*/
|
|
91
|
+
async updatePost(postId, params) {
|
|
92
|
+
const teamId = this.resolveTeamId();
|
|
93
|
+
const response = await this.authenticatedFetch("/api/widget/community", {
|
|
94
|
+
method: "POST",
|
|
95
|
+
body: {
|
|
96
|
+
teamId,
|
|
97
|
+
action: "updatePost",
|
|
98
|
+
postId,
|
|
99
|
+
title: params.title,
|
|
100
|
+
body: params.body,
|
|
101
|
+
customFields: params.customFields
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return response.data.post;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Delete a post (soft delete). Only the original author can delete.
|
|
108
|
+
* Requires an active session token.
|
|
109
|
+
*/
|
|
110
|
+
async deletePost(postId) {
|
|
111
|
+
const teamId = this.resolveTeamId();
|
|
112
|
+
await this.authenticatedFetch(
|
|
113
|
+
"/api/widget/community",
|
|
114
|
+
{
|
|
115
|
+
method: "POST",
|
|
116
|
+
body: { teamId, action: "deletePost", postId }
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Update a comment. Only the original author can edit.
|
|
122
|
+
* Requires an active session token.
|
|
123
|
+
*/
|
|
124
|
+
async updateComment(postId, commentId, params) {
|
|
125
|
+
const teamId = this.resolveTeamId();
|
|
126
|
+
const response = await this.authenticatedFetch("/api/widget/community", {
|
|
127
|
+
method: "POST",
|
|
128
|
+
body: {
|
|
129
|
+
teamId,
|
|
130
|
+
action: "updateComment",
|
|
131
|
+
postId,
|
|
132
|
+
commentId,
|
|
133
|
+
commentBody: params.body
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
return response.data.comment;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Delete a comment (soft delete). Only the original author can delete.
|
|
140
|
+
* Requires an active session token.
|
|
141
|
+
*/
|
|
142
|
+
async deleteComment(postId, commentId) {
|
|
143
|
+
const teamId = this.resolveTeamId();
|
|
144
|
+
await this.authenticatedFetch(
|
|
145
|
+
"/api/widget/community",
|
|
146
|
+
{
|
|
147
|
+
method: "POST",
|
|
148
|
+
body: { teamId, action: "deleteComment", postId, commentId }
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
}
|
|
87
152
|
/**
|
|
88
153
|
* Toggle vote on a post. Returns new vote state and count.
|
|
89
154
|
* Requires an active session token.
|