@cstar.help/js 0.9.0 → 0.10.1

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.
@@ -0,0 +1,135 @@
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 };
@@ -0,0 +1,135 @@
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 };