@cstar.help/js 0.2.0 → 0.3.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 +1 -1
- package/dist/auth/index.cjs +1 -1
- package/dist/auth/index.d.cts +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +1 -1
- package/dist/chat/index.cjs +1 -1
- package/dist/chat/index.d.cts +1 -1
- package/dist/chat/index.d.ts +1 -1
- package/dist/chat/index.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/library/index.cjs +23 -1
- package/dist/library/index.d.cts +13 -1
- package/dist/library/index.d.ts +13 -1
- package/dist/library/index.js +23 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -140,7 +140,7 @@ const event = await constructEventAsync(rawBody, signature, secret);
|
|
|
140
140
|
const cstar = new CStarClient({
|
|
141
141
|
apiKey: 'sk_live_...', // Required — secret or publishable key
|
|
142
142
|
teamId: 'tm_...', // Required — your team ID
|
|
143
|
-
baseUrl: 'https://...', // Optional — defaults to https://
|
|
143
|
+
baseUrl: 'https://...', // Optional — defaults to https://www.cstar.help
|
|
144
144
|
version: '2026-03-01', // Optional — API version header
|
|
145
145
|
maxRetries: 3, // Optional — retry attempts for 5xx/429
|
|
146
146
|
timeout: 30000 // Optional — request timeout in ms
|
package/dist/auth/index.cjs
CHANGED
|
@@ -23,7 +23,7 @@ __export(auth_exports, {
|
|
|
23
23
|
AuthClient: () => AuthClient
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(auth_exports);
|
|
26
|
-
var DEFAULT_BASE_URL = "https://
|
|
26
|
+
var DEFAULT_BASE_URL = "https://www.cstar.help";
|
|
27
27
|
var AuthClient = class {
|
|
28
28
|
constructor(config) {
|
|
29
29
|
this.session = null;
|
package/dist/auth/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
interface AuthConfig {
|
|
3
3
|
/** Team slug (e.g., 'acme'). Identifies which team's customers to authenticate. */
|
|
4
4
|
teamSlug: string;
|
|
5
|
-
/** Override the base URL (defaults to https://
|
|
5
|
+
/** Override the base URL (defaults to https://www.cstar.help). */
|
|
6
6
|
baseUrl?: string;
|
|
7
7
|
}
|
|
8
8
|
/** A customer identity returned from auth endpoints. */
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
interface AuthConfig {
|
|
3
3
|
/** Team slug (e.g., 'acme'). Identifies which team's customers to authenticate. */
|
|
4
4
|
teamSlug: string;
|
|
5
|
-
/** Override the base URL (defaults to https://
|
|
5
|
+
/** Override the base URL (defaults to https://www.cstar.help). */
|
|
6
6
|
baseUrl?: string;
|
|
7
7
|
}
|
|
8
8
|
/** A customer identity returned from auth endpoints. */
|
package/dist/auth/index.js
CHANGED
package/dist/chat/index.cjs
CHANGED
|
@@ -275,7 +275,7 @@ var PresenceManager = class {
|
|
|
275
275
|
};
|
|
276
276
|
|
|
277
277
|
// src/chat/index.ts
|
|
278
|
-
var DEFAULT_BASE_URL = "https://
|
|
278
|
+
var DEFAULT_BASE_URL = "https://www.cstar.help";
|
|
279
279
|
var DEFAULT_POLLING_INTERVAL = 3e3;
|
|
280
280
|
var ChatClient = class {
|
|
281
281
|
constructor(config) {
|
package/dist/chat/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
interface ChatConfig {
|
|
3
3
|
/** Team slug (e.g., 'acme'). Used to identify the team. */
|
|
4
4
|
teamSlug: string;
|
|
5
|
-
/** Override the base URL (defaults to https://
|
|
5
|
+
/** Override the base URL (defaults to https://www.cstar.help). */
|
|
6
6
|
baseUrl?: string;
|
|
7
7
|
/** Supabase project URL for realtime subscriptions (optional). */
|
|
8
8
|
supabaseUrl?: string;
|
package/dist/chat/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
interface ChatConfig {
|
|
3
3
|
/** Team slug (e.g., 'acme'). Used to identify the team. */
|
|
4
4
|
teamSlug: string;
|
|
5
|
-
/** Override the base URL (defaults to https://
|
|
5
|
+
/** Override the base URL (defaults to https://www.cstar.help). */
|
|
6
6
|
baseUrl?: string;
|
|
7
7
|
/** Supabase project URL for realtime subscriptions (optional). */
|
|
8
8
|
supabaseUrl?: string;
|
package/dist/chat/index.js
CHANGED
|
@@ -239,7 +239,7 @@ var PresenceManager = class {
|
|
|
239
239
|
};
|
|
240
240
|
|
|
241
241
|
// src/chat/index.ts
|
|
242
|
-
var DEFAULT_BASE_URL = "https://
|
|
242
|
+
var DEFAULT_BASE_URL = "https://www.cstar.help";
|
|
243
243
|
var DEFAULT_POLLING_INTERVAL = 3e3;
|
|
244
244
|
var ChatClient = class {
|
|
245
245
|
constructor(config) {
|
package/dist/index.cjs
CHANGED
|
@@ -97,8 +97,8 @@ function parseError(statusCode, body, retryAfter) {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
// src/client.ts
|
|
100
|
-
var SDK_VERSION = "0.2.
|
|
101
|
-
var DEFAULT_BASE_URL = "https://
|
|
100
|
+
var SDK_VERSION = "0.2.1";
|
|
101
|
+
var DEFAULT_BASE_URL = "https://www.cstar.help";
|
|
102
102
|
var DEFAULT_API_VERSION = "2026-03-01";
|
|
103
103
|
var DEFAULT_MAX_RETRIES = 3;
|
|
104
104
|
var DEFAULT_TIMEOUT = 3e4;
|
package/dist/index.d.cts
CHANGED
|
@@ -480,7 +480,7 @@ interface CStarClientConfig {
|
|
|
480
480
|
apiKey: string;
|
|
481
481
|
/** Your team ID. */
|
|
482
482
|
teamId: string;
|
|
483
|
-
/** Override the base URL (defaults to https://
|
|
483
|
+
/** Override the base URL (defaults to https://www.cstar.help). */
|
|
484
484
|
baseUrl?: string;
|
|
485
485
|
/** API version header (defaults to 2026-03-01). */
|
|
486
486
|
version?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -480,7 +480,7 @@ interface CStarClientConfig {
|
|
|
480
480
|
apiKey: string;
|
|
481
481
|
/** Your team ID. */
|
|
482
482
|
teamId: string;
|
|
483
|
-
/** Override the base URL (defaults to https://
|
|
483
|
+
/** Override the base URL (defaults to https://www.cstar.help). */
|
|
484
484
|
baseUrl?: string;
|
|
485
485
|
/** API version header (defaults to 2026-03-01). */
|
|
486
486
|
version?: string;
|
package/dist/index.js
CHANGED
|
@@ -65,8 +65,8 @@ function parseError(statusCode, body, retryAfter) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
// src/client.ts
|
|
68
|
-
var SDK_VERSION = "0.2.
|
|
69
|
-
var DEFAULT_BASE_URL = "https://
|
|
68
|
+
var SDK_VERSION = "0.2.1";
|
|
69
|
+
var DEFAULT_BASE_URL = "https://www.cstar.help";
|
|
70
70
|
var DEFAULT_API_VERSION = "2026-03-01";
|
|
71
71
|
var DEFAULT_MAX_RETRIES = 3;
|
|
72
72
|
var DEFAULT_TIMEOUT = 3e4;
|
package/dist/library/index.cjs
CHANGED
|
@@ -23,7 +23,7 @@ __export(library_exports, {
|
|
|
23
23
|
LibraryClient: () => LibraryClient
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(library_exports);
|
|
26
|
-
var DEFAULT_BASE_URL = "https://
|
|
26
|
+
var DEFAULT_BASE_URL = "https://www.cstar.help";
|
|
27
27
|
var LibraryClient = class {
|
|
28
28
|
constructor(config) {
|
|
29
29
|
this.resolvedTeamId = null;
|
|
@@ -67,6 +67,28 @@ var LibraryClient = class {
|
|
|
67
67
|
if (params?.limit) queryParams.limit = String(params.limit);
|
|
68
68
|
return this.fetch(`/api/library/${this.teamSlug}/search`, queryParams);
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Record a view for an article. Call this from the client when an article
|
|
72
|
+
* page is displayed to track view counts accurately.
|
|
73
|
+
*
|
|
74
|
+
* ```typescript
|
|
75
|
+
* // On article page mount
|
|
76
|
+
* await library.recordView('getting-started');
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
async recordView(slug) {
|
|
80
|
+
const url = `${this.baseUrl}/api/library/${this.teamSlug}/articles/${slug}/view`;
|
|
81
|
+
const response = await globalThis.fetch(url, {
|
|
82
|
+
method: "POST",
|
|
83
|
+
headers: { "Content-Type": "application/json" }
|
|
84
|
+
});
|
|
85
|
+
if (!response.ok) {
|
|
86
|
+
const errorBody = await response.json().catch(() => ({ error: "Request failed" }));
|
|
87
|
+
throw new Error(errorBody.error ?? `View tracking failed: ${response.status}`);
|
|
88
|
+
}
|
|
89
|
+
const body = await response.json();
|
|
90
|
+
return { viewCount: body.viewCount };
|
|
91
|
+
}
|
|
70
92
|
/** Get the most viewed articles, sorted by view count descending. */
|
|
71
93
|
async popularArticles(limit = 5) {
|
|
72
94
|
const articles = await this.articles({ limit: 50 });
|
package/dist/library/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
interface LibraryConfig {
|
|
3
3
|
/** Team slug (e.g., 'acme'). Identifies the knowledge base to query. */
|
|
4
4
|
teamSlug: string;
|
|
5
|
-
/** Override the base URL (defaults to https://
|
|
5
|
+
/** Override the base URL (defaults to https://www.cstar.help). */
|
|
6
6
|
baseUrl?: string;
|
|
7
7
|
}
|
|
8
8
|
/** A published article in the public knowledge base. */
|
|
@@ -82,6 +82,18 @@ declare class LibraryClient {
|
|
|
82
82
|
* Returns matching articles with relevance ranking.
|
|
83
83
|
*/
|
|
84
84
|
search(query: string, params?: LibrarySearchParams): Promise<LibrarySearchResult>;
|
|
85
|
+
/**
|
|
86
|
+
* Record a view for an article. Call this from the client when an article
|
|
87
|
+
* page is displayed to track view counts accurately.
|
|
88
|
+
*
|
|
89
|
+
* ```typescript
|
|
90
|
+
* // On article page mount
|
|
91
|
+
* await library.recordView('getting-started');
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
recordView(slug: string): Promise<{
|
|
95
|
+
viewCount: number;
|
|
96
|
+
}>;
|
|
85
97
|
/** Get the most viewed articles, sorted by view count descending. */
|
|
86
98
|
popularArticles(limit?: number): Promise<LibraryArticle[]>;
|
|
87
99
|
/** Get aggregate stats for this knowledge base (article count, category count, total views). */
|
package/dist/library/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
interface LibraryConfig {
|
|
3
3
|
/** Team slug (e.g., 'acme'). Identifies the knowledge base to query. */
|
|
4
4
|
teamSlug: string;
|
|
5
|
-
/** Override the base URL (defaults to https://
|
|
5
|
+
/** Override the base URL (defaults to https://www.cstar.help). */
|
|
6
6
|
baseUrl?: string;
|
|
7
7
|
}
|
|
8
8
|
/** A published article in the public knowledge base. */
|
|
@@ -82,6 +82,18 @@ declare class LibraryClient {
|
|
|
82
82
|
* Returns matching articles with relevance ranking.
|
|
83
83
|
*/
|
|
84
84
|
search(query: string, params?: LibrarySearchParams): Promise<LibrarySearchResult>;
|
|
85
|
+
/**
|
|
86
|
+
* Record a view for an article. Call this from the client when an article
|
|
87
|
+
* page is displayed to track view counts accurately.
|
|
88
|
+
*
|
|
89
|
+
* ```typescript
|
|
90
|
+
* // On article page mount
|
|
91
|
+
* await library.recordView('getting-started');
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
recordView(slug: string): Promise<{
|
|
95
|
+
viewCount: number;
|
|
96
|
+
}>;
|
|
85
97
|
/** Get the most viewed articles, sorted by view count descending. */
|
|
86
98
|
popularArticles(limit?: number): Promise<LibraryArticle[]>;
|
|
87
99
|
/** Get aggregate stats for this knowledge base (article count, category count, total views). */
|
package/dist/library/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/library/index.ts
|
|
2
|
-
var DEFAULT_BASE_URL = "https://
|
|
2
|
+
var DEFAULT_BASE_URL = "https://www.cstar.help";
|
|
3
3
|
var LibraryClient = class {
|
|
4
4
|
constructor(config) {
|
|
5
5
|
this.resolvedTeamId = null;
|
|
@@ -43,6 +43,28 @@ var LibraryClient = class {
|
|
|
43
43
|
if (params?.limit) queryParams.limit = String(params.limit);
|
|
44
44
|
return this.fetch(`/api/library/${this.teamSlug}/search`, queryParams);
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Record a view for an article. Call this from the client when an article
|
|
48
|
+
* page is displayed to track view counts accurately.
|
|
49
|
+
*
|
|
50
|
+
* ```typescript
|
|
51
|
+
* // On article page mount
|
|
52
|
+
* await library.recordView('getting-started');
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
async recordView(slug) {
|
|
56
|
+
const url = `${this.baseUrl}/api/library/${this.teamSlug}/articles/${slug}/view`;
|
|
57
|
+
const response = await globalThis.fetch(url, {
|
|
58
|
+
method: "POST",
|
|
59
|
+
headers: { "Content-Type": "application/json" }
|
|
60
|
+
});
|
|
61
|
+
if (!response.ok) {
|
|
62
|
+
const errorBody = await response.json().catch(() => ({ error: "Request failed" }));
|
|
63
|
+
throw new Error(errorBody.error ?? `View tracking failed: ${response.status}`);
|
|
64
|
+
}
|
|
65
|
+
const body = await response.json();
|
|
66
|
+
return { viewCount: body.viewCount };
|
|
67
|
+
}
|
|
46
68
|
/** Get the most viewed articles, sorted by view count descending. */
|
|
47
69
|
async popularArticles(limit = 5) {
|
|
48
70
|
const articles = await this.articles({ limit: 50 });
|