@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 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://app.cstar.help
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
@@ -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://app.cstar.help";
26
+ var DEFAULT_BASE_URL = "https://www.cstar.help";
27
27
  var AuthClient = class {
28
28
  constructor(config) {
29
29
  this.session = null;
@@ -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://app.cstar.help). */
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. */
@@ -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://app.cstar.help). */
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. */
@@ -1,5 +1,5 @@
1
1
  // src/auth/index.ts
2
- var DEFAULT_BASE_URL = "https://app.cstar.help";
2
+ var DEFAULT_BASE_URL = "https://www.cstar.help";
3
3
  var AuthClient = class {
4
4
  constructor(config) {
5
5
  this.session = null;
@@ -275,7 +275,7 @@ var PresenceManager = class {
275
275
  };
276
276
 
277
277
  // src/chat/index.ts
278
- var DEFAULT_BASE_URL = "https://app.cstar.help";
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) {
@@ -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://app.cstar.help). */
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;
@@ -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://app.cstar.help). */
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;
@@ -239,7 +239,7 @@ var PresenceManager = class {
239
239
  };
240
240
 
241
241
  // src/chat/index.ts
242
- var DEFAULT_BASE_URL = "https://app.cstar.help";
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.0";
101
- var DEFAULT_BASE_URL = "https://app.cstar.help";
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://app.cstar.help). */
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://app.cstar.help). */
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.0";
69
- var DEFAULT_BASE_URL = "https://app.cstar.help";
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;
@@ -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://app.cstar.help";
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 });
@@ -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://app.cstar.help). */
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). */
@@ -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://app.cstar.help). */
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). */
@@ -1,5 +1,5 @@
1
1
  // src/library/index.ts
2
- var DEFAULT_BASE_URL = "https://app.cstar.help";
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 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cstar.help/js",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Official TypeScript SDK for the cStar customer support platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",