@cstar.help/js 0.7.0 → 0.9.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.
@@ -548,11 +548,63 @@ var ChatCommunityApi = class {
548
548
  action: "createPost",
549
549
  title: params.title,
550
550
  body: params.body,
551
- topicId: params.topicId
551
+ topicId: params.topicId,
552
+ customFields: params.customFields
552
553
  }
553
554
  });
554
555
  return response.data.post;
555
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
+ }
556
608
  /** Toggle vote on a post. Returns new vote state and count. */
557
609
  async vote(postId) {
558
610
  const teamId = this.chat.getTeamId();
@@ -112,9 +112,25 @@ interface CommunityCreatePostParams {
112
112
  body?: string;
113
113
  /** Topic UUID to post in. */
114
114
  topicId: string;
115
+ /** Custom field values keyed by field definition ID. */
116
+ customFields?: Record<string, string>;
115
117
  /** Image attachments (max 10, images only, 5MB each). */
116
118
  attachments?: CommunityAttachment[];
117
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
+ }
118
134
  /** Parameters for creating a comment as an identified customer. */
119
135
  interface CommunityCreateCommentParams {
120
136
  /** Comment body text. */
@@ -274,6 +290,14 @@ declare class ChatCommunityApi {
274
290
  constructor(chat: ChatClient);
275
291
  /** Create a new community post as the identified customer. */
276
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>;
277
301
  /** Toggle vote on a post. Returns new vote state and count. */
278
302
  vote(postId: string): Promise<CommunityVoteResult>;
279
303
  /** Add a comment to a post. Supports 1-level nesting via parentCommentId. */
@@ -112,9 +112,25 @@ interface CommunityCreatePostParams {
112
112
  body?: string;
113
113
  /** Topic UUID to post in. */
114
114
  topicId: string;
115
+ /** Custom field values keyed by field definition ID. */
116
+ customFields?: Record<string, string>;
115
117
  /** Image attachments (max 10, images only, 5MB each). */
116
118
  attachments?: CommunityAttachment[];
117
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
+ }
118
134
  /** Parameters for creating a comment as an identified customer. */
119
135
  interface CommunityCreateCommentParams {
120
136
  /** Comment body text. */
@@ -274,6 +290,14 @@ declare class ChatCommunityApi {
274
290
  constructor(chat: ChatClient);
275
291
  /** Create a new community post as the identified customer. */
276
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>;
277
301
  /** Toggle vote on a post. Returns new vote state and count. */
278
302
  vote(postId: string): Promise<CommunityVoteResult>;
279
303
  /** Add a comment to a post. Supports 1-level nesting via parentCommentId. */
@@ -512,11 +512,63 @@ var ChatCommunityApi = class {
512
512
  action: "createPost",
513
513
  title: params.title,
514
514
  body: params.body,
515
- topicId: params.topicId
515
+ topicId: params.topicId,
516
+ customFields: params.customFields
516
517
  }
517
518
  });
518
519
  return response.data.post;
519
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
+ }
520
572
  /** Toggle vote on a post. Returns new vote state and count. */
521
573
  async vote(postId) {
522
574
  const teamId = this.chat.getTeamId();
@@ -102,11 +102,77 @@ var CommunityClient = class {
102
102
  action: "createPost",
103
103
  title: params.title,
104
104
  body: params.body,
105
- topicId: params.topicId
105
+ topicId: params.topicId,
106
+ customFields: params.customFields
106
107
  }
107
108
  });
108
109
  return response.data.post;
109
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
+ }
110
176
  /**
111
177
  * Toggle vote on a post. Returns new vote state and count.
112
178
  * Requires an active session token.
@@ -20,9 +20,25 @@ interface CommunityCreatePostParams {
20
20
  body?: string;
21
21
  /** Topic UUID to post in. */
22
22
  topicId: string;
23
+ /** Custom field values keyed by field definition ID. */
24
+ customFields?: Record<string, string>;
23
25
  /** Image attachments (max 10, images only, 5MB each). */
24
26
  attachments?: CommunityAttachment[];
25
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
+ }
26
42
  /** Parameters for creating a comment as an identified customer. */
27
43
  interface CommunityCreateCommentParams {
28
44
  /** Comment body text. */
@@ -92,6 +108,7 @@ interface CommunityTopic {
92
108
  icon: string;
93
109
  visibility: 'public' | 'members_only';
94
110
  sort_order: number;
111
+ postCount: number;
95
112
  customFields: TopicCustomField[];
96
113
  }
97
114
  /** A public community post. */
@@ -210,6 +227,26 @@ declare class CommunityClient {
210
227
  * @throws Error if no session token is set or the request fails
211
228
  */
212
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>;
213
250
  /**
214
251
  * Toggle vote on a post. Returns new vote state and count.
215
252
  * Requires an active session token.
@@ -243,4 +280,4 @@ declare class CommunityClient {
243
280
  private fetch;
244
281
  }
245
282
 
246
- 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 };
@@ -20,9 +20,25 @@ interface CommunityCreatePostParams {
20
20
  body?: string;
21
21
  /** Topic UUID to post in. */
22
22
  topicId: string;
23
+ /** Custom field values keyed by field definition ID. */
24
+ customFields?: Record<string, string>;
23
25
  /** Image attachments (max 10, images only, 5MB each). */
24
26
  attachments?: CommunityAttachment[];
25
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
+ }
26
42
  /** Parameters for creating a comment as an identified customer. */
27
43
  interface CommunityCreateCommentParams {
28
44
  /** Comment body text. */
@@ -92,6 +108,7 @@ interface CommunityTopic {
92
108
  icon: string;
93
109
  visibility: 'public' | 'members_only';
94
110
  sort_order: number;
111
+ postCount: number;
95
112
  customFields: TopicCustomField[];
96
113
  }
97
114
  /** A public community post. */
@@ -210,6 +227,26 @@ declare class CommunityClient {
210
227
  * @throws Error if no session token is set or the request fails
211
228
  */
212
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>;
213
250
  /**
214
251
  * Toggle vote on a post. Returns new vote state and count.
215
252
  * Requires an active session token.
@@ -243,4 +280,4 @@ declare class CommunityClient {
243
280
  private fetch;
244
281
  }
245
282
 
246
- 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 };
@@ -78,11 +78,77 @@ var CommunityClient = class {
78
78
  action: "createPost",
79
79
  title: params.title,
80
80
  body: params.body,
81
- topicId: params.topicId
81
+ topicId: params.topicId,
82
+ customFields: params.customFields
82
83
  }
83
84
  });
84
85
  return response.data.post;
85
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
+ }
86
152
  /**
87
153
  * Toggle vote on a post. Returns new vote state and count.
88
154
  * Requires an active session token.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cstar.help/js",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Official TypeScript SDK for the cStar customer support platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -1,135 +0,0 @@
1
- /** Configuration for the LibraryClient. */
2
- interface LibraryConfig {
3
- /** Team slug (e.g., 'acme'). Identifies the knowledge base to query. */
4
- teamSlug: string;
5
- /** Override the base URL (defaults to https://www.cstar.help). */
6
- baseUrl?: string;
7
- }
8
- /** A published article in the public knowledge base. */
9
- interface LibraryArticle {
10
- id: string;
11
- team_id: string;
12
- title: string;
13
- slug: string;
14
- excerpt: string;
15
- content: string;
16
- category: string;
17
- tags: string[];
18
- view_count: number;
19
- published_at: string;
20
- created_at: string;
21
- updated_at: string;
22
- meta_description?: string;
23
- }
24
- /** A category in the knowledge base. */
25
- interface Category {
26
- id: string;
27
- team_id: string;
28
- name: string;
29
- slug: string;
30
- description?: string;
31
- icon?: string;
32
- color?: string;
33
- sort_order: number;
34
- is_public: boolean;
35
- article_count: number;
36
- }
37
- /** Parameters for listing articles. */
38
- interface LibraryArticleListParams {
39
- categorySlug?: string;
40
- limit?: number;
41
- offset?: number;
42
- }
43
- /** Parameters for searching articles. */
44
- interface LibrarySearchParams {
45
- limit?: number;
46
- }
47
- /** Search results. */
48
- interface LibrarySearchResult {
49
- data: LibraryArticle[];
50
- count: number;
51
- query: string;
52
- }
53
- /** Aggregate stats for a public knowledge base. */
54
- interface LibraryStats {
55
- totalArticles: number;
56
- totalCategories: number;
57
- totalViews: number;
58
- }
59
- /** Parameters for submitting article feedback. */
60
- interface ArticleFeedbackParams {
61
- /** Whether the article was helpful. */
62
- isHelpful: boolean;
63
- /** Optional text feedback from the user. */
64
- feedbackText?: string;
65
- /** Optional fingerprint to prevent duplicate votes (e.g., session ID or hashed IP). */
66
- userFingerprint?: string;
67
- }
68
- /** Result of submitting article feedback. */
69
- interface ArticleFeedbackResult {
70
- success: boolean;
71
- message?: string;
72
- error?: string;
73
- }
74
-
75
- /**
76
- * Public knowledge base client. No authentication required.
77
- *
78
- * ```typescript
79
- * const library = new LibraryClient({ teamSlug: 'acme' });
80
- * const categories = await library.categories();
81
- * const results = await library.search('reset password');
82
- * ```
83
- */
84
- declare class LibraryClient {
85
- private readonly baseUrl;
86
- private readonly teamSlug;
87
- private resolvedTeamId;
88
- constructor(config: LibraryConfig);
89
- /** List all public categories with article counts. */
90
- categories(): Promise<Category[]>;
91
- /** List published articles, optionally filtered by category. */
92
- articles(params?: LibraryArticleListParams): Promise<LibraryArticle[]>;
93
- /** Get a single article by slug. */
94
- article(slug: string): Promise<LibraryArticle>;
95
- /**
96
- * Full-text search across article titles, excerpts, and content.
97
- * Returns matching articles with relevance ranking.
98
- */
99
- search(query: string, params?: LibrarySearchParams): Promise<LibrarySearchResult>;
100
- /**
101
- * Record a view for an article. Call this from the client when an article
102
- * page is displayed to track view counts accurately.
103
- *
104
- * ```typescript
105
- * // On article page mount
106
- * await library.recordView('getting-started');
107
- * ```
108
- */
109
- recordView(slug: string): Promise<{
110
- viewCount: number;
111
- }>;
112
- /**
113
- * Submit feedback for an article ("Was this helpful?").
114
- *
115
- * ```typescript
116
- * // User clicked "Yes, helpful"
117
- * await library.submitFeedback('getting-started', { isHelpful: true });
118
- *
119
- * // With optional text and fingerprint to prevent duplicates
120
- * await library.submitFeedback('getting-started', {
121
- * isHelpful: false,
122
- * feedbackText: 'The code example was outdated',
123
- * userFingerprint: sessionId
124
- * });
125
- * ```
126
- */
127
- submitFeedback(slug: string, params: ArticleFeedbackParams): Promise<ArticleFeedbackResult>;
128
- /** Get the most viewed articles, sorted by view count descending. */
129
- popularArticles(limit?: number): Promise<LibraryArticle[]>;
130
- /** Get aggregate stats for this knowledge base (article count, category count, total views). */
131
- stats(): Promise<LibraryStats>;
132
- private fetch;
133
- }
134
-
135
- export { type ArticleFeedbackParams, type ArticleFeedbackResult, type Category, type LibraryArticle, type LibraryArticleListParams, LibraryClient, type LibraryConfig, type LibrarySearchParams, type LibrarySearchResult, type LibraryStats };
@@ -1,135 +0,0 @@
1
- /** Configuration for the LibraryClient. */
2
- interface LibraryConfig {
3
- /** Team slug (e.g., 'acme'). Identifies the knowledge base to query. */
4
- teamSlug: string;
5
- /** Override the base URL (defaults to https://www.cstar.help). */
6
- baseUrl?: string;
7
- }
8
- /** A published article in the public knowledge base. */
9
- interface LibraryArticle {
10
- id: string;
11
- team_id: string;
12
- title: string;
13
- slug: string;
14
- excerpt: string;
15
- content: string;
16
- category: string;
17
- tags: string[];
18
- view_count: number;
19
- published_at: string;
20
- created_at: string;
21
- updated_at: string;
22
- meta_description?: string;
23
- }
24
- /** A category in the knowledge base. */
25
- interface Category {
26
- id: string;
27
- team_id: string;
28
- name: string;
29
- slug: string;
30
- description?: string;
31
- icon?: string;
32
- color?: string;
33
- sort_order: number;
34
- is_public: boolean;
35
- article_count: number;
36
- }
37
- /** Parameters for listing articles. */
38
- interface LibraryArticleListParams {
39
- categorySlug?: string;
40
- limit?: number;
41
- offset?: number;
42
- }
43
- /** Parameters for searching articles. */
44
- interface LibrarySearchParams {
45
- limit?: number;
46
- }
47
- /** Search results. */
48
- interface LibrarySearchResult {
49
- data: LibraryArticle[];
50
- count: number;
51
- query: string;
52
- }
53
- /** Aggregate stats for a public knowledge base. */
54
- interface LibraryStats {
55
- totalArticles: number;
56
- totalCategories: number;
57
- totalViews: number;
58
- }
59
- /** Parameters for submitting article feedback. */
60
- interface ArticleFeedbackParams {
61
- /** Whether the article was helpful. */
62
- isHelpful: boolean;
63
- /** Optional text feedback from the user. */
64
- feedbackText?: string;
65
- /** Optional fingerprint to prevent duplicate votes (e.g., session ID or hashed IP). */
66
- userFingerprint?: string;
67
- }
68
- /** Result of submitting article feedback. */
69
- interface ArticleFeedbackResult {
70
- success: boolean;
71
- message?: string;
72
- error?: string;
73
- }
74
-
75
- /**
76
- * Public knowledge base client. No authentication required.
77
- *
78
- * ```typescript
79
- * const library = new LibraryClient({ teamSlug: 'acme' });
80
- * const categories = await library.categories();
81
- * const results = await library.search('reset password');
82
- * ```
83
- */
84
- declare class LibraryClient {
85
- private readonly baseUrl;
86
- private readonly teamSlug;
87
- private resolvedTeamId;
88
- constructor(config: LibraryConfig);
89
- /** List all public categories with article counts. */
90
- categories(): Promise<Category[]>;
91
- /** List published articles, optionally filtered by category. */
92
- articles(params?: LibraryArticleListParams): Promise<LibraryArticle[]>;
93
- /** Get a single article by slug. */
94
- article(slug: string): Promise<LibraryArticle>;
95
- /**
96
- * Full-text search across article titles, excerpts, and content.
97
- * Returns matching articles with relevance ranking.
98
- */
99
- search(query: string, params?: LibrarySearchParams): Promise<LibrarySearchResult>;
100
- /**
101
- * Record a view for an article. Call this from the client when an article
102
- * page is displayed to track view counts accurately.
103
- *
104
- * ```typescript
105
- * // On article page mount
106
- * await library.recordView('getting-started');
107
- * ```
108
- */
109
- recordView(slug: string): Promise<{
110
- viewCount: number;
111
- }>;
112
- /**
113
- * Submit feedback for an article ("Was this helpful?").
114
- *
115
- * ```typescript
116
- * // User clicked "Yes, helpful"
117
- * await library.submitFeedback('getting-started', { isHelpful: true });
118
- *
119
- * // With optional text and fingerprint to prevent duplicates
120
- * await library.submitFeedback('getting-started', {
121
- * isHelpful: false,
122
- * feedbackText: 'The code example was outdated',
123
- * userFingerprint: sessionId
124
- * });
125
- * ```
126
- */
127
- submitFeedback(slug: string, params: ArticleFeedbackParams): Promise<ArticleFeedbackResult>;
128
- /** Get the most viewed articles, sorted by view count descending. */
129
- popularArticles(limit?: number): Promise<LibraryArticle[]>;
130
- /** Get aggregate stats for this knowledge base (article count, category count, total views). */
131
- stats(): Promise<LibraryStats>;
132
- private fetch;
133
- }
134
-
135
- export { type ArticleFeedbackParams, type ArticleFeedbackResult, type Category, type LibraryArticle, type LibraryArticleListParams, LibraryClient, type LibraryConfig, type LibrarySearchParams, type LibrarySearchResult, type LibraryStats };