@cstar.help/js 0.2.1 → 0.3.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.
@@ -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;
@@ -328,6 +328,13 @@ var WebhooksResource = class extends BaseResource {
328
328
  }
329
329
  };
330
330
 
331
+ // src/resources/categories.ts
332
+ var CategoriesResource = class extends BaseResource {
333
+ constructor(client) {
334
+ super(client, "/categories");
335
+ }
336
+ };
337
+
331
338
  // src/index.ts
332
339
  var CStarClient = class {
333
340
  constructor(config) {
@@ -336,6 +343,7 @@ var CStarClient = class {
336
343
  this.customers = new CustomersResource(this.client);
337
344
  this.articles = new ArticlesResource(this.client);
338
345
  this.webhooks = new WebhooksResource(this.client);
346
+ this.categories = new CategoriesResource(this.client);
339
347
  }
340
348
  /** Whether this client is using test mode keys (sk_test_* or pk_test_*). */
341
349
  get isTestMode() {
package/dist/index.d.cts CHANGED
@@ -429,6 +429,48 @@ declare class WebhooksResource extends BaseResource<Webhook, WebhookListParams,
429
429
  }): Promise<ApiResponse<WebhookTestResult>>;
430
430
  }
431
431
 
432
+ /** A cStar article category. */
433
+ interface Category {
434
+ id: string;
435
+ object: 'category';
436
+ name: string;
437
+ slug: string;
438
+ description: string | null;
439
+ icon: string | null;
440
+ color: string | null;
441
+ sortOrder: number;
442
+ isPublic: boolean;
443
+ createdAt: string;
444
+ updatedAt: string;
445
+ }
446
+ /** Parameters for listing categories. */
447
+ interface CategoryListParams extends PaginationParams {
448
+ isPublic?: boolean;
449
+ }
450
+ /** Parameters for creating a category. */
451
+ interface CategoryCreateParams {
452
+ name: string;
453
+ description?: string;
454
+ icon?: string;
455
+ color?: string;
456
+ sortOrder?: number;
457
+ isPublic?: boolean;
458
+ }
459
+ /** Parameters for updating a category. */
460
+ interface CategoryUpdateParams {
461
+ name?: string;
462
+ description?: string;
463
+ icon?: string;
464
+ color?: string;
465
+ sortOrder?: number;
466
+ isPublic?: boolean;
467
+ }
468
+
469
+ /** Manage article categories. */
470
+ declare class CategoriesResource extends BaseResource<Category, CategoryListParams, CategoryCreateParams, CategoryUpdateParams> {
471
+ constructor(client: HttpClient);
472
+ }
473
+
432
474
  /** Error type constants matching the cStar API. */
433
475
  declare const ErrorType: {
434
476
  readonly AUTHENTICATION_ERROR: "authentication_error";
@@ -480,7 +522,7 @@ interface CStarClientConfig {
480
522
  apiKey: string;
481
523
  /** Your team ID. */
482
524
  teamId: string;
483
- /** Override the base URL (defaults to https://app.cstar.help). */
525
+ /** Override the base URL (defaults to https://www.cstar.help). */
484
526
  baseUrl?: string;
485
527
  /** API version header (defaults to 2026-03-01). */
486
528
  version?: string;
@@ -510,10 +552,12 @@ declare class CStarClient {
510
552
  readonly articles: ArticlesResource;
511
553
  /** Manage webhook endpoints. */
512
554
  readonly webhooks: WebhooksResource;
555
+ /** Manage article categories. */
556
+ readonly categories: CategoriesResource;
513
557
  private readonly client;
514
558
  constructor(config: CStarClientConfig);
515
559
  /** Whether this client is using test mode keys (sk_test_* or pk_test_*). */
516
560
  get isTestMode(): boolean;
517
561
  }
518
562
 
519
- export { type ApiErrorBody, type ApiResponse, type Article, type ArticleCreateParams, type ArticleListParams, type ArticleUpdateParams, CStarAuthenticationError, CStarClient, type CStarClientConfig, CStarError, CStarNotFoundError, CStarRateLimitError, CStarValidationError, type Customer, type CustomerCreateParams, type CustomerListParams, type CustomerUpdateParams, type DeleteResponse, ErrorType, type ListResponse, type Message, type MessageCreateParams, type Metadata, type PaginationInfo, type PaginationParams, type RequestOptions, type Ticket, type TicketCreateParams, type TicketCustomerSummary, type TicketListParams, type TicketUpdateParams, type Webhook, type WebhookCreateParams, type WebhookEvent, type WebhookEventData, type WebhookEventType, type WebhookListParams, type WebhookTestResult, type WebhookUpdateParams };
563
+ export { type ApiErrorBody, type ApiResponse, type Article, type ArticleCreateParams, type ArticleListParams, type ArticleUpdateParams, CStarAuthenticationError, CStarClient, type CStarClientConfig, CStarError, CStarNotFoundError, CStarRateLimitError, CStarValidationError, type Category, type CategoryCreateParams, type CategoryListParams, type CategoryUpdateParams, type Customer, type CustomerCreateParams, type CustomerListParams, type CustomerUpdateParams, type DeleteResponse, ErrorType, type ListResponse, type Message, type MessageCreateParams, type Metadata, type PaginationInfo, type PaginationParams, type RequestOptions, type Ticket, type TicketCreateParams, type TicketCustomerSummary, type TicketListParams, type TicketUpdateParams, type Webhook, type WebhookCreateParams, type WebhookEvent, type WebhookEventData, type WebhookEventType, type WebhookListParams, type WebhookTestResult, type WebhookUpdateParams };
package/dist/index.d.ts CHANGED
@@ -429,6 +429,48 @@ declare class WebhooksResource extends BaseResource<Webhook, WebhookListParams,
429
429
  }): Promise<ApiResponse<WebhookTestResult>>;
430
430
  }
431
431
 
432
+ /** A cStar article category. */
433
+ interface Category {
434
+ id: string;
435
+ object: 'category';
436
+ name: string;
437
+ slug: string;
438
+ description: string | null;
439
+ icon: string | null;
440
+ color: string | null;
441
+ sortOrder: number;
442
+ isPublic: boolean;
443
+ createdAt: string;
444
+ updatedAt: string;
445
+ }
446
+ /** Parameters for listing categories. */
447
+ interface CategoryListParams extends PaginationParams {
448
+ isPublic?: boolean;
449
+ }
450
+ /** Parameters for creating a category. */
451
+ interface CategoryCreateParams {
452
+ name: string;
453
+ description?: string;
454
+ icon?: string;
455
+ color?: string;
456
+ sortOrder?: number;
457
+ isPublic?: boolean;
458
+ }
459
+ /** Parameters for updating a category. */
460
+ interface CategoryUpdateParams {
461
+ name?: string;
462
+ description?: string;
463
+ icon?: string;
464
+ color?: string;
465
+ sortOrder?: number;
466
+ isPublic?: boolean;
467
+ }
468
+
469
+ /** Manage article categories. */
470
+ declare class CategoriesResource extends BaseResource<Category, CategoryListParams, CategoryCreateParams, CategoryUpdateParams> {
471
+ constructor(client: HttpClient);
472
+ }
473
+
432
474
  /** Error type constants matching the cStar API. */
433
475
  declare const ErrorType: {
434
476
  readonly AUTHENTICATION_ERROR: "authentication_error";
@@ -480,7 +522,7 @@ interface CStarClientConfig {
480
522
  apiKey: string;
481
523
  /** Your team ID. */
482
524
  teamId: string;
483
- /** Override the base URL (defaults to https://app.cstar.help). */
525
+ /** Override the base URL (defaults to https://www.cstar.help). */
484
526
  baseUrl?: string;
485
527
  /** API version header (defaults to 2026-03-01). */
486
528
  version?: string;
@@ -510,10 +552,12 @@ declare class CStarClient {
510
552
  readonly articles: ArticlesResource;
511
553
  /** Manage webhook endpoints. */
512
554
  readonly webhooks: WebhooksResource;
555
+ /** Manage article categories. */
556
+ readonly categories: CategoriesResource;
513
557
  private readonly client;
514
558
  constructor(config: CStarClientConfig);
515
559
  /** Whether this client is using test mode keys (sk_test_* or pk_test_*). */
516
560
  get isTestMode(): boolean;
517
561
  }
518
562
 
519
- export { type ApiErrorBody, type ApiResponse, type Article, type ArticleCreateParams, type ArticleListParams, type ArticleUpdateParams, CStarAuthenticationError, CStarClient, type CStarClientConfig, CStarError, CStarNotFoundError, CStarRateLimitError, CStarValidationError, type Customer, type CustomerCreateParams, type CustomerListParams, type CustomerUpdateParams, type DeleteResponse, ErrorType, type ListResponse, type Message, type MessageCreateParams, type Metadata, type PaginationInfo, type PaginationParams, type RequestOptions, type Ticket, type TicketCreateParams, type TicketCustomerSummary, type TicketListParams, type TicketUpdateParams, type Webhook, type WebhookCreateParams, type WebhookEvent, type WebhookEventData, type WebhookEventType, type WebhookListParams, type WebhookTestResult, type WebhookUpdateParams };
563
+ export { type ApiErrorBody, type ApiResponse, type Article, type ArticleCreateParams, type ArticleListParams, type ArticleUpdateParams, CStarAuthenticationError, CStarClient, type CStarClientConfig, CStarError, CStarNotFoundError, CStarRateLimitError, CStarValidationError, type Category, type CategoryCreateParams, type CategoryListParams, type CategoryUpdateParams, type Customer, type CustomerCreateParams, type CustomerListParams, type CustomerUpdateParams, type DeleteResponse, ErrorType, type ListResponse, type Message, type MessageCreateParams, type Metadata, type PaginationInfo, type PaginationParams, type RequestOptions, type Ticket, type TicketCreateParams, type TicketCustomerSummary, type TicketListParams, type TicketUpdateParams, type Webhook, type WebhookCreateParams, type WebhookEvent, type WebhookEventData, type WebhookEventType, type WebhookListParams, type WebhookTestResult, type WebhookUpdateParams };
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;
@@ -296,6 +296,13 @@ var WebhooksResource = class extends BaseResource {
296
296
  }
297
297
  };
298
298
 
299
+ // src/resources/categories.ts
300
+ var CategoriesResource = class extends BaseResource {
301
+ constructor(client) {
302
+ super(client, "/categories");
303
+ }
304
+ };
305
+
299
306
  // src/index.ts
300
307
  var CStarClient = class {
301
308
  constructor(config) {
@@ -304,6 +311,7 @@ var CStarClient = class {
304
311
  this.customers = new CustomersResource(this.client);
305
312
  this.articles = new ArticlesResource(this.client);
306
313
  this.webhooks = new WebhooksResource(this.client);
314
+ this.categories = new CategoriesResource(this.client);
307
315
  }
308
316
  /** Whether this client is using test mode keys (sk_test_* or pk_test_*). */
309
317
  get isTestMode() {
@@ -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.1",
3
+ "version": "0.3.1",
4
4
  "description": "Official TypeScript SDK for the cStar customer support platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",