@cstar.help/js 0.3.1 → 0.3.3
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/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/library/index.cjs +28 -0
- package/dist/library/index.d.cts +32 -1
- package/dist/library/index.d.ts +32 -1
- package/dist/library/index.js +28 -0
- package/dist/webhook/index.d.cts +1 -1
- package/dist/webhook/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -278,7 +278,7 @@ interface Article {
|
|
|
278
278
|
slug: string | null;
|
|
279
279
|
excerpt: string | null;
|
|
280
280
|
content: string | null;
|
|
281
|
-
|
|
281
|
+
categoryId: string | null;
|
|
282
282
|
status: 'draft' | 'published';
|
|
283
283
|
tags: string[];
|
|
284
284
|
notes: string | null;
|
|
@@ -306,7 +306,7 @@ interface ArticleCreateParams {
|
|
|
306
306
|
title: string;
|
|
307
307
|
content?: string;
|
|
308
308
|
excerpt?: string;
|
|
309
|
-
|
|
309
|
+
categoryId?: string;
|
|
310
310
|
status?: 'draft' | 'published';
|
|
311
311
|
tags?: string[];
|
|
312
312
|
notes?: string;
|
|
@@ -320,7 +320,7 @@ interface ArticleUpdateParams {
|
|
|
320
320
|
title?: string;
|
|
321
321
|
content?: string;
|
|
322
322
|
excerpt?: string;
|
|
323
|
-
|
|
323
|
+
categoryId?: string;
|
|
324
324
|
status?: 'draft' | 'published';
|
|
325
325
|
tags?: string[];
|
|
326
326
|
notes?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -278,7 +278,7 @@ interface Article {
|
|
|
278
278
|
slug: string | null;
|
|
279
279
|
excerpt: string | null;
|
|
280
280
|
content: string | null;
|
|
281
|
-
|
|
281
|
+
categoryId: string | null;
|
|
282
282
|
status: 'draft' | 'published';
|
|
283
283
|
tags: string[];
|
|
284
284
|
notes: string | null;
|
|
@@ -306,7 +306,7 @@ interface ArticleCreateParams {
|
|
|
306
306
|
title: string;
|
|
307
307
|
content?: string;
|
|
308
308
|
excerpt?: string;
|
|
309
|
-
|
|
309
|
+
categoryId?: string;
|
|
310
310
|
status?: 'draft' | 'published';
|
|
311
311
|
tags?: string[];
|
|
312
312
|
notes?: string;
|
|
@@ -320,7 +320,7 @@ interface ArticleUpdateParams {
|
|
|
320
320
|
title?: string;
|
|
321
321
|
content?: string;
|
|
322
322
|
excerpt?: string;
|
|
323
|
-
|
|
323
|
+
categoryId?: string;
|
|
324
324
|
status?: 'draft' | 'published';
|
|
325
325
|
tags?: string[];
|
|
326
326
|
notes?: string;
|
package/dist/library/index.cjs
CHANGED
|
@@ -89,6 +89,34 @@ var LibraryClient = class {
|
|
|
89
89
|
const body = await response.json();
|
|
90
90
|
return { viewCount: body.viewCount };
|
|
91
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Submit feedback for an article ("Was this helpful?").
|
|
94
|
+
*
|
|
95
|
+
* ```typescript
|
|
96
|
+
* // User clicked "Yes, helpful"
|
|
97
|
+
* await library.submitFeedback('getting-started', { isHelpful: true });
|
|
98
|
+
*
|
|
99
|
+
* // With optional text and fingerprint to prevent duplicates
|
|
100
|
+
* await library.submitFeedback('getting-started', {
|
|
101
|
+
* isHelpful: false,
|
|
102
|
+
* feedbackText: 'The code example was outdated',
|
|
103
|
+
* userFingerprint: sessionId
|
|
104
|
+
* });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
async submitFeedback(slug, params) {
|
|
108
|
+
const url = `${this.baseUrl}/api/library/${this.teamSlug}/articles/${slug}/feedback`;
|
|
109
|
+
const response = await globalThis.fetch(url, {
|
|
110
|
+
method: "POST",
|
|
111
|
+
headers: { "Content-Type": "application/json" },
|
|
112
|
+
body: JSON.stringify(params)
|
|
113
|
+
});
|
|
114
|
+
const body = await response.json();
|
|
115
|
+
if (!response.ok) {
|
|
116
|
+
throw new Error(body.error ?? `Feedback submission failed: ${response.status}`);
|
|
117
|
+
}
|
|
118
|
+
return body;
|
|
119
|
+
}
|
|
92
120
|
/** Get the most viewed articles, sorted by view count descending. */
|
|
93
121
|
async popularArticles(limit = 5) {
|
|
94
122
|
const articles = await this.articles({ limit: 50 });
|
package/dist/library/index.d.cts
CHANGED
|
@@ -56,6 +56,21 @@ interface LibraryStats {
|
|
|
56
56
|
totalCategories: number;
|
|
57
57
|
totalViews: number;
|
|
58
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
|
+
}
|
|
59
74
|
|
|
60
75
|
/**
|
|
61
76
|
* Public knowledge base client. No authentication required.
|
|
@@ -94,6 +109,22 @@ declare class LibraryClient {
|
|
|
94
109
|
recordView(slug: string): Promise<{
|
|
95
110
|
viewCount: number;
|
|
96
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>;
|
|
97
128
|
/** Get the most viewed articles, sorted by view count descending. */
|
|
98
129
|
popularArticles(limit?: number): Promise<LibraryArticle[]>;
|
|
99
130
|
/** Get aggregate stats for this knowledge base (article count, category count, total views). */
|
|
@@ -101,4 +132,4 @@ declare class LibraryClient {
|
|
|
101
132
|
private fetch;
|
|
102
133
|
}
|
|
103
134
|
|
|
104
|
-
export { type Category, type LibraryArticle, type LibraryArticleListParams, LibraryClient, type LibraryConfig, type LibrarySearchParams, type LibrarySearchResult, type LibraryStats };
|
|
135
|
+
export { type ArticleFeedbackParams, type ArticleFeedbackResult, type Category, type LibraryArticle, type LibraryArticleListParams, LibraryClient, type LibraryConfig, type LibrarySearchParams, type LibrarySearchResult, type LibraryStats };
|
package/dist/library/index.d.ts
CHANGED
|
@@ -56,6 +56,21 @@ interface LibraryStats {
|
|
|
56
56
|
totalCategories: number;
|
|
57
57
|
totalViews: number;
|
|
58
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
|
+
}
|
|
59
74
|
|
|
60
75
|
/**
|
|
61
76
|
* Public knowledge base client. No authentication required.
|
|
@@ -94,6 +109,22 @@ declare class LibraryClient {
|
|
|
94
109
|
recordView(slug: string): Promise<{
|
|
95
110
|
viewCount: number;
|
|
96
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>;
|
|
97
128
|
/** Get the most viewed articles, sorted by view count descending. */
|
|
98
129
|
popularArticles(limit?: number): Promise<LibraryArticle[]>;
|
|
99
130
|
/** Get aggregate stats for this knowledge base (article count, category count, total views). */
|
|
@@ -101,4 +132,4 @@ declare class LibraryClient {
|
|
|
101
132
|
private fetch;
|
|
102
133
|
}
|
|
103
134
|
|
|
104
|
-
export { type Category, type LibraryArticle, type LibraryArticleListParams, LibraryClient, type LibraryConfig, type LibrarySearchParams, type LibrarySearchResult, type LibraryStats };
|
|
135
|
+
export { type ArticleFeedbackParams, type ArticleFeedbackResult, type Category, type LibraryArticle, type LibraryArticleListParams, LibraryClient, type LibraryConfig, type LibrarySearchParams, type LibrarySearchResult, type LibraryStats };
|
package/dist/library/index.js
CHANGED
|
@@ -65,6 +65,34 @@ var LibraryClient = class {
|
|
|
65
65
|
const body = await response.json();
|
|
66
66
|
return { viewCount: body.viewCount };
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Submit feedback for an article ("Was this helpful?").
|
|
70
|
+
*
|
|
71
|
+
* ```typescript
|
|
72
|
+
* // User clicked "Yes, helpful"
|
|
73
|
+
* await library.submitFeedback('getting-started', { isHelpful: true });
|
|
74
|
+
*
|
|
75
|
+
* // With optional text and fingerprint to prevent duplicates
|
|
76
|
+
* await library.submitFeedback('getting-started', {
|
|
77
|
+
* isHelpful: false,
|
|
78
|
+
* feedbackText: 'The code example was outdated',
|
|
79
|
+
* userFingerprint: sessionId
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
async submitFeedback(slug, params) {
|
|
84
|
+
const url = `${this.baseUrl}/api/library/${this.teamSlug}/articles/${slug}/feedback`;
|
|
85
|
+
const response = await globalThis.fetch(url, {
|
|
86
|
+
method: "POST",
|
|
87
|
+
headers: { "Content-Type": "application/json" },
|
|
88
|
+
body: JSON.stringify(params)
|
|
89
|
+
});
|
|
90
|
+
const body = await response.json();
|
|
91
|
+
if (!response.ok) {
|
|
92
|
+
throw new Error(body.error ?? `Feedback submission failed: ${response.status}`);
|
|
93
|
+
}
|
|
94
|
+
return body;
|
|
95
|
+
}
|
|
68
96
|
/** Get the most viewed articles, sorted by view count descending. */
|
|
69
97
|
async popularArticles(limit = 5) {
|
|
70
98
|
const articles = await this.articles({ limit: 50 });
|
package/dist/webhook/index.d.cts
CHANGED
package/dist/webhook/index.d.ts
CHANGED